小说后台管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

218 line
5.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" />
  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.$index)"
  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. :btn5Data="btn5Data"
  68. :CategoryList="CategoryList"
  69. />
  70. <!-- 查看书籍弹窗-->
  71. <CheckBooksDialog :is-dialog="isCheckDialog" @handle-close="isCheckDialog = false" />
  72. </el-container>
  73. </template>
  74. <script>
  75. import ActionButton from "@/components/ActionButton/index";
  76. import CustomButton from "@/components/CustomButton/index";
  77. import EditDialog from "./components/edit-dialog";
  78. import CheckBooksDialog from "./components/check-books-dialog";
  79. import { getPlatformList, getCategoryList } from "@/api/sort-management";
  80. export default {
  81. components: {
  82. ActionButton,
  83. CustomButton,
  84. EditDialog,
  85. CheckBooksDialog,
  86. },
  87. data() {
  88. return {
  89. isCheckDialog: false,
  90. isEditDialog: false,
  91. editTitleDialog: "",
  92. // 分页数据
  93. totalCount: 0,
  94. currentPage: 1,
  95. limit: 20,
  96. // 返回的数据
  97. tableData: [],
  98. dropdownData: [],
  99. CategoryList: [],
  100. btn5Data: {},
  101. };
  102. },
  103. created() {
  104. this.init();
  105. },
  106. methods: {
  107. init() {
  108. this.onPlatformList();
  109. },
  110. onPlatformList() {
  111. getPlatformList().then((res) => {
  112. let obj = res.data;
  113. let arr = [];
  114. for (let i in obj) {
  115. arr.push({
  116. name: obj[i].name,
  117. value: obj[i].value,
  118. id: i,
  119. });
  120. }
  121. this.dropdownData = arr;
  122. this.btn5Data = arr[0];
  123. this.onCategoryList(arr[0].value);
  124. });
  125. },
  126. onCategoryList(source_platform) {
  127. getCategoryList({
  128. source_platform,
  129. }).then((res) => {
  130. this.tableData = res.data; // 分类列表
  131. });
  132. },
  133. handleButton5(data) {
  134. console.log(data)
  135. this.btn5Data = data;
  136. this.onCategoryList(data.value);
  137. this.$forceUpdate();
  138. },
  139. refreshData() {
  140. console.log("刷新");
  141. },
  142. // 打开编辑弹窗操作
  143. openEditDialog(row) {
  144. this.isEditDialog = true;
  145. if (row) {
  146. this.editTitleDialog = "编辑分类";
  147. } else {
  148. this.editTitleDialog = "新增分类";
  149. }
  150. },
  151. // 打开查看书籍弹窗
  152. openCheckBooksDialog() {
  153. this.isCheckDialog = true;
  154. },
  155. handleDelete(row) {
  156. this.$confirm(
  157. "是否确认删除该分类?删除后该分类信息将永久删除, 且不可复原, 请谨慎操作!",
  158. "删除提示",
  159. {
  160. confirmButtonText: "确定",
  161. cancelButtonText: "取消",
  162. type: "warning",
  163. }
  164. )
  165. .then(() => {
  166. this.selectItem = row;
  167. })
  168. .catch(() => {});
  169. },
  170. // limit 改变
  171. handleSizeChange(val) {
  172. console.log(`每页 ${val} 条`);
  173. this.limit = val;
  174. this._fetchData();
  175. },
  176. // 当前页面改变
  177. handleCurrentChange(val) {
  178. console.log(`当前页: ${val}`);
  179. this.currentPage = val;
  180. this._fetchData();
  181. },
  182. },
  183. };
  184. </script>
  185. <style lang="scss" scoped>
  186. .head-box {
  187. border-bottom: #f2f2f2 1px solid;
  188. display: flex;
  189. justify-content: space-between;
  190. padding: 0 50px 0 0px;
  191. box-sizing: border-box;
  192. .el-input__inner {
  193. width: 250px;
  194. }
  195. }
  196. .el-footer {
  197. width: 100%;
  198. display: flex;
  199. justify-content: center;
  200. align-items: center;
  201. }
  202. </style>