小说后台管理系统
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

258 líneas
6.4 KiB

  1. <template>
  2. <el-container>
  3. <el-main>
  4. <ActionButton
  5. :open-btn1="true"
  6. :text-btn1="'新增分类'"
  7. :open-btn5="true"
  8. :text-btn5="btn5Data.name"
  9. :type-btn5="'warning'"
  10. :icon-btn5="'el-icon-tickets'"
  11. @handle-button5="handleButton5"
  12. @handle-refresh="refreshData"
  13. @handle-button1="openEditDialog(null)"
  14. :dropdownData="dropdownData"
  15. />
  16. <div>
  17. <el-table :data="tableData" border fit tooltip-effect="dark">
  18. <el-table-column type="index" label="序号" align="center" width="80" />
  19. <el-table-column label="分类" align="center" prop="category_name" />
  20. <el-table-column label="书源" align="center">
  21. <template slot-scope="scope">{{ btn5Data.name }}</template>
  22. </el-table-column>
  23. <el-table-column label="采集书籍数量" align="center" prop="count_num" />
  24. <el-table-column prop="address" label="操作" align="center">
  25. <template slot-scope="scope">
  26. <CustomButton
  27. tip-text="查看明细"
  28. type="warning"
  29. icon="el-icon-tickets"
  30. @onClick="openCheckBooksDialog(scope.row)"
  31. />
  32. <CustomButton
  33. tip-text="编辑"
  34. type="primary"
  35. icon="edit"
  36. is-svg
  37. @onClick="openEditDialog(scope.row)"
  38. />
  39. <CustomButton
  40. tip-text="删除"
  41. type="danger"
  42. icon="delete"
  43. is-svg
  44. @onClick="handleDelete(scope.row)"
  45. />
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <!-- <el-footer>
  50. <el-pagination
  51. :current-page="currentPage"
  52. :page-sizes="[5, 10, 15, 20, 30]"
  53. :page-size="limit"
  54. layout="total, prev, pager, next, sizes, jumper"
  55. :total="totalCount"
  56. @size-change="handleSizeChange"
  57. @current-change="handleCurrentChange"
  58. />
  59. </el-footer> -->
  60. </div>
  61. </el-main>
  62. <!-- 编辑、新增弹窗-->
  63. <EditDialog
  64. :is-dialog="isEditDialog"
  65. :dialog-title="editTitleDialog"
  66. @handle-close="isEditDialog = false"
  67. :dropdownData="dropdownData"
  68. :CategoryList="CategoryList"
  69. :selectItem="selectItem"
  70. @handle-success="onHandleSuccess"
  71. />
  72. <!-- 查看书籍弹窗-->
  73. <CheckBooksDialog
  74. :mod="booksData"
  75. :booksItem="booksItem"
  76. :is-dialog="isCheckDialog"
  77. @handle-close="isCheckDialog = false"
  78. />
  79. </el-container>
  80. </template>
  81. <script>
  82. import ActionButton from "@/components/ActionButton/index";
  83. import CustomButton from "@/components/CustomButton/index";
  84. import EditDialog from "./components/edit-dialog";
  85. import CheckBooksDialog from "./components/check-books-dialog";
  86. import {
  87. getPlatformList,
  88. getCategoryList,
  89. getCategoryShow,
  90. getCategoryDelete,
  91. } from "@/api/sort-management";
  92. export default {
  93. components: {
  94. ActionButton,
  95. CustomButton,
  96. EditDialog,
  97. CheckBooksDialog,
  98. },
  99. data() {
  100. return {
  101. isCheckDialog: false,
  102. isEditDialog: false,
  103. editTitleDialog: "",
  104. // 分页数据
  105. totalCount: 0,
  106. currentPage: 1,
  107. limit: 20,
  108. // 返回的数据
  109. tableData: [],
  110. dropdownData: [],
  111. CategoryList: [],
  112. btn5Data: {},
  113. booksData: null,
  114. booksItem: null,
  115. selectItem: {},
  116. };
  117. },
  118. created() {
  119. this.init();
  120. },
  121. methods: {
  122. init(refresh = false) {
  123. this.onPlatformList(refresh);
  124. },
  125. onHandleSuccess() {
  126. this.init();
  127. this.isEditDialog = false;
  128. },
  129. onPlatformList(refresh) {
  130. getPlatformList().then((res) => {
  131. let obj = res.data;
  132. let arr = [];
  133. for (let i in obj) {
  134. arr.push({
  135. name: obj[i].name,
  136. value: obj[i].value,
  137. id: i,
  138. });
  139. }
  140. this.dropdownData = arr;
  141. this.btn5Data = arr[0];
  142. this.onCategoryList(arr[0].value);
  143. refresh && this.$message.success("刷新成功");
  144. });
  145. },
  146. onCategoryList(source_platform) {
  147. getCategoryList({
  148. source_platform: source_platform,
  149. need_num: true,
  150. }).then((res) => {
  151. this.tableData = res.data; // 分类列表
  152. });
  153. },
  154. handleButton5(data) {
  155. this.btn5Data = data;
  156. this.onCategoryList(data.value);
  157. this.$forceUpdate();
  158. },
  159. refreshData() {
  160. this.init(true);
  161. },
  162. // 打开编辑弹窗操作
  163. openEditDialog(row) {
  164. this.isEditDialog = true;
  165. if (row) {
  166. this.editTitleDialog = "编辑分类";
  167. this.selectItem = {
  168. source_platform: row.id,
  169. name: row.category_name,
  170. };
  171. } else {
  172. this.editTitleDialog = "新增分类";
  173. }
  174. },
  175. // 打开查看书籍弹窗
  176. openCheckBooksDialog(data) {
  177. this.booksData = [];
  178. getCategoryShow(data.id, {
  179. source_platform: this.btn5Data.value,
  180. }).then((res) => {
  181. this.booksData = res.data;
  182. this.booksItem = {
  183. data: data,
  184. btn5Data: this.btn5Data,
  185. };
  186. });
  187. this.isCheckDialog = true;
  188. },
  189. handleDelete(row) {
  190. this.$confirm(
  191. "是否确认删除该分类?删除后该分类信息将永久删除, 且不可复原, 请谨慎操作!",
  192. "删除提示",
  193. {
  194. confirmButtonText: "确定",
  195. cancelButtonText: "取消",
  196. type: "warning",
  197. }
  198. )
  199. .then(() => {
  200. console.log(row);
  201. getCategoryDelete(row.id).then((res) => {
  202. this.init();
  203. });
  204. })
  205. .catch(() => {});
  206. },
  207. // limit 改变
  208. handleSizeChange(val) {
  209. console.log(`每页 ${val} 条`);
  210. this.limit = val;
  211. this._fetchData();
  212. },
  213. // 当前页面改变
  214. handleCurrentChange(val) {
  215. console.log(`当前页: ${val}`);
  216. this.currentPage = val;
  217. this._fetchData();
  218. },
  219. },
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. .head-box {
  224. border-bottom: #f2f2f2 1px solid;
  225. display: flex;
  226. justify-content: space-between;
  227. padding: 0 50px 0 0px;
  228. box-sizing: border-box;
  229. .el-input__inner {
  230. width: 250px;
  231. }
  232. }
  233. .el-footer {
  234. width: 100%;
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. }
  239. </style>