index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 条件区 -->
  5. <classify-manage-search @search="reload" />
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. :page-size="pageSize"
  11. @columns-change="handleColumnChange"
  12. :cache-key="cacheKeyUrl"
  13. >
  14. <template v-slot:toolbar>
  15. <el-button
  16. size="small"
  17. type="primary"
  18. icon="el-icon-plus"
  19. class="ele-btn-icon"
  20. @click="openAddDialog(null)"
  21. v-if="$hasPermission('main:categorylevel:save')"
  22. >
  23. 新建
  24. </el-button>
  25. <!--<el-button
  26. size="small"
  27. icon="el-icon-upload"
  28. class="ele-btn-icon"
  29. @click="uploadFile()"
  30. >
  31. 导入
  32. </el-button>-->
  33. </template>
  34. <!-- 操作列 -->
  35. <template v-slot:action="{ row }">
  36. <el-link
  37. type="primary"
  38. :underline="false"
  39. icon="el-icon-edit"
  40. @click="openAddDialog(row)"
  41. v-if="$hasPermission('main:categorylevel:update')"
  42. >
  43. 编辑
  44. </el-link>
  45. <el-link
  46. type="primary"
  47. :underline="false"
  48. @click="junmpEdit(row)"
  49. >
  50. 下级分类
  51. </el-link>
  52. <el-popconfirm
  53. class="ele-action"
  54. title="确定要删除此分类吗?"
  55. @confirm="deleteCategory(row)"
  56. v-if="$hasPermission('main:categorylevel:delete')"
  57. >
  58. <template v-slot:reference>
  59. <el-link type="danger" :underline="false" icon="el-icon-delete">
  60. 删除
  61. </el-link>
  62. </template>
  63. </el-popconfirm>
  64. </template>
  65. </ele-pro-table>
  66. </el-card>
  67. <list-edit ref="editRef" @done="reload" />
  68. <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
  69. </div>
  70. </template>
  71. <script>
  72. import tabMixins from '@/mixins/tableColumnsMixin';
  73. import ListEdit from './components/list-edit.vue';
  74. import ClassifyManageSearch from './components/classifyManageSearch.vue';
  75. import importDialog from "@/components/upload/import-dialog.vue";
  76. import { getSubPage, deleteCategory } from '@/api/classifyManage';
  77. export default {
  78. mixins: [tabMixins],
  79. components: { ClassifyManageSearch, ListEdit, importDialog},
  80. data () {
  81. return {
  82. editData: null,
  83. moudleName : "mainCategoryLevel",
  84. columns: [
  85. {
  86. prop: 'code',
  87. label: '类型编码'
  88. },
  89. {
  90. prop: 'name',
  91. label: '类型名称'
  92. },
  93. {
  94. prop: 'ruleCode',
  95. label: '编码规则'
  96. },
  97. {
  98. prop: 'remark',
  99. label: '描述'
  100. },
  101. {
  102. columnKey: 'action',
  103. label: '操作',
  104. width: 250,
  105. align: 'center',
  106. slot: 'action',
  107. fixed: 'right'
  108. },
  109. {
  110. prop: 'isEnabled',
  111. align: 'center',
  112. label: '状态',
  113. showOverflowTooltip: true,
  114. formatter: (row, column) => {
  115. return row.isEnabled === 0
  116. ? '停用'
  117. : row.isEnabled === 1
  118. ? '启用'
  119. : '';
  120. }
  121. },
  122. ],
  123. searchForm: {},
  124. tableData: [
  125. {
  126. s1: '1'
  127. }
  128. ],
  129. total: 0,
  130. size: 10,
  131. page: 1,
  132. pageSize: this.$store.state.tablePageSize,
  133. cacheKeyUrl: '4e99a929-treeClassify'
  134. };
  135. },
  136. methods: {
  137. openAddDialog (editData) {
  138. if(editData) {
  139. editData.type = editData.type + ''
  140. }
  141. this.$refs.editRef.open(editData);
  142. },
  143. reload (params) {
  144. this.$refs.table.reload({ pageNum: 1, where: params });
  145. },
  146. async deleteCategory ({ id }) {
  147. const res = await deleteCategory(id);
  148. if (res?.code == '0') {
  149. this.$message.success('删除成功!');
  150. this.$refs.table.reload();
  151. }
  152. },
  153. datasource ({ page, where, limit }) {
  154. return getSubPage({
  155. ...where,
  156. parentId: 0,
  157. pageNum: page,
  158. size: limit
  159. });
  160. },
  161. reset () {},
  162. // 编辑
  163. junmpEdit ({ id }) {
  164. this.$router.push({
  165. path: '/treeClassify/details',
  166. query: {
  167. id
  168. }
  169. });
  170. },
  171. uploadFile () {
  172. this.$refs.importDialogRef.open();
  173. },
  174. }
  175. };
  176. </script>
  177. <style lang="scss" scoped>
  178. .app-container {
  179. background: #f0f3f3;
  180. min-height: calc(100vh - 84px);
  181. }
  182. .zw-page-table {
  183. background: #ffffff;
  184. padding-top: 20px;
  185. }
  186. .pagination-wrap {
  187. display: flex;
  188. justify-content: flex-end;
  189. padding: 10px 0;
  190. }
  191. .table {
  192. width: 100%;
  193. margin-top: 10px;
  194. }
  195. </style>