bookList.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="mainBox">
  3. <!--搜索功能 start------------------------------------------------------------>
  4. <div class="layerBox_search">
  5. <div class="layerBoxLine">
  6. <el-row>
  7. <el-col :span="6">
  8. <div class="searchBox">
  9. <div class="searchTitle">标题名称:</div>
  10. <el-input placeholder="请输入标题名称" autocomplete="off" v-model="getApiData.title" />
  11. </div>
  12. </el-col>
  13. <el-col :span="6">
  14. <div class="searchBox">
  15. <div class="searchTitle">网站名称:</div>
  16. <el-input placeholder="请输入网站名称" autocomplete="off" v-model="getApiData.website_name" />
  17. </div>
  18. </el-col>
  19. <!-- <el-col :span="6">
  20. <div class="searchBox">
  21. <div class="searchTitle">审核:</div>
  22. <el-select v-model="getApiData.status" placeholder="请处理状态..">
  23. <el-option label="未审核" value="1"></el-option>
  24. <el-option label="已审核" value='2'></el-option>
  25. <el-option label=" 已拒绝" value="3"></el-option>
  26. </el-select>
  27. </div>
  28. </el-col> -->
  29. </el-row>
  30. </div>
  31. </div>
  32. <div class="layerBoxNoBg">
  33. <div>
  34. <el-button type="primary" @click="goCreat">发布书刊音像</el-button>
  35. </div>
  36. <div>
  37. <el-button @click="clearSearchList">重置</el-button>
  38. <el-button type="primary" @click="getData('search')">搜索</el-button>
  39. </div>
  40. </div>
  41. <!--搜索功能 end------------------------------------------------------------>
  42. <!--表格内容 start------------------------------------------------------------>
  43. <div class="layerBox">
  44. <tableTitle :name="tableDivTitle" />
  45. <el-row>
  46. <template>
  47. <el-table :data="tableData" style="width: 100%">
  48. <el-table-column fixed prop="id" label="编号" width="50"></el-table-column>
  49. <el-table-column prop="title" label="标题名称" width="">
  50. </el-table-column>
  51. <el-table-column prop="city_name" label="行政区划" width="">
  52. </el-table-column>
  53. <el-table-column prop="website_name" label="网站名称" width="">
  54. </el-table-column>
  55. <el-table-column prop="cat_name" label="栏目名称" width="">
  56. </el-table-column>
  57. <el-table-column prop="status" label="审核状态" width="">
  58. <template slot-scope="scope">
  59. <span v-if="scope.row.status == 1">
  60. 未审核
  61. </span>
  62. <span v-if="scope.row.status == 2">
  63. 已审核
  64. </span>
  65. <span v-if="scope.row.status == 3">
  66. 已拒绝
  67. </span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
  71. <el-table-column fixed="right" label="操作" width="300" header-align="center">
  72. <template slot-scope="scope">
  73. <div class="listBtnBox">
  74. <div class="listUpBtn" v-if="type_id == 10000" @click="returnRow(scope.row.id, tableData)"><i
  75. class="el-icon-refresh-right"></i>撤回</div>
  76. <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i
  77. class="el-icon-delete"></i>删除</div>
  78. <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i
  79. class="el-icon-edit-outline"></i>编辑</div>
  80. </div>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. </template>
  85. </el-row>
  86. </div>
  87. <!--分页 start------------------------------------------------------------>
  88. <div class="alignBox">
  89. <el-row>
  90. <el-col :span="24">
  91. <el-pagination @size-change="handleSizeChange" :current-page="getApiData.page"
  92. @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper"
  93. :total="allCount"></el-pagination>
  94. </el-col>
  95. </el-row>
  96. </div>
  97. <!--分页 end------------------------------------------------------------>
  98. <!--表格内容 end------------------------------------------------------------>
  99. </div>
  100. </template>
  101. <script>
  102. //表格标题
  103. import tableTitle from './components/tableTitle';
  104. //获得用户身份
  105. import { getUseType } from '@/utils/auth'
  106. //引入公用样式
  107. import '@/styles/global.less';
  108. export default {
  109. components: {
  110. tableTitle,//表格标题
  111. },
  112. data() {
  113. return {
  114. //1.列表和分页相关 start ------------------------------------------------------------>
  115. tableDivTitle: "书刊音像列表",
  116. tableData: [],//内容
  117. editId: 0,//要修改的网站id
  118. getApiData: {
  119. title: "",//标题
  120. website_name: "",//网站名称
  121. status: 2,//发布状态
  122. page: 1,//当前是第几页
  123. page_size: 10,//一共多少条
  124. },
  125. allCount: 0,//总条数
  126. type_id: 0,
  127. //分页相关 end ------------------------------------------------------------>
  128. }
  129. },
  130. methods: {
  131. //1.列表和分页相关 start ------------------------------------------------------------>
  132. //1.1 开始请求列表信息方法
  133. getData(type) {
  134. if (type == "search") {
  135. this.getApiData.page = 1;
  136. }
  137. console.log(this.getApiData, '---1--')
  138. this.$store.dispatch('news/getBookList', this.getApiData).then(res => {
  139. console.log(this.getApiData, '---2-')
  140. let data = [];
  141. for (let item of res.data.rows) {
  142. data.push(item)
  143. }
  144. this.tableData = res.data.rows; //给与内容
  145. this.allCount = res.data.count; //给与总条数
  146. })
  147. },
  148. // 1.2.1 撤回
  149. returnRow(id) {
  150. this.$confirm('确定要撤回吗?', '提示', {
  151. confirmButtonText: '撤回',
  152. cancelButtonText: '取消',
  153. type: 'warning'
  154. }).then(() => {
  155. //撤回,把文章状态修改为0,重新进行审核
  156. this.upRow(id, 1)
  157. })
  158. },
  159. //1.2 删除内容
  160. deleteRow(id) {
  161. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  162. confirmButtonText: '确定',
  163. cancelButtonText: '取消',
  164. type: 'warning'
  165. }).then(() => {
  166. console.log("当前删除:" + id)
  167. this.$store.dispatch('news/deleteBook', { id: id }).then(res => {
  168. this.getData();
  169. this.$message({
  170. type: 'success',
  171. message: '删除成功!'
  172. });
  173. }).catch(() => {
  174. this.$message({
  175. type: 'warning',
  176. message: '网络错误,请重试!'
  177. });
  178. })
  179. }).catch(() => {
  180. this.$message({
  181. type: 'warning',
  182. message: '已取消删除'
  183. });
  184. });
  185. },
  186. //1.3 修改网站状态
  187. upRow(id, status) {
  188. let data = {
  189. id: id,
  190. status: status
  191. }
  192. this.$store.dispatch('news/updateBookStatus', data).then(res => {
  193. if (res.code == 200) {
  194. this.$message({
  195. type: 'success',
  196. message: '审核状态已修改!'
  197. });
  198. this.getData();
  199. }
  200. }).catch(() => {
  201. this.$message({
  202. type: 'warning',
  203. message: '已取消删除'
  204. });
  205. });
  206. },
  207. //1.4 列表内容分页
  208. //直接跳转
  209. handleSizeChange(val) {
  210. this.getApiData.page = val;
  211. this.getData();
  212. },
  213. //1.5 点击分页
  214. handleCurrentChange(val) {
  215. this.getApiData.page = val;
  216. this.getData();
  217. },
  218. //1.6 重置按钮
  219. clearSearchList() {
  220. this.tableData = [];
  221. this.getApiData.title = "";
  222. this.getApiData.level = "";
  223. this.getApiData.page = 1;
  224. this.getApiData.pageSize = 10;
  225. this.getData();
  226. },
  227. //列表和分页相关 end ------------------------------------------------------------>
  228. //2.添加新闻 start ------------------------------------------------------------>
  229. //跳转到通知发布页面
  230. goCreat() {
  231. this.$router.push({
  232. path: '/addBook',
  233. });
  234. },
  235. goEdit(id) {
  236. let data = {
  237. id: id
  238. }
  239. this.$router.push({
  240. path: '/addBook',
  241. query: data
  242. });
  243. }
  244. //添加新闻 end ------------------------------------------------------------>
  245. },
  246. mounted() {
  247. this.type_id = getUseType()
  248. //1.获得初始数据
  249. this.getData();
  250. }
  251. }
  252. </script>
  253. <style scoped lang="less"></style>