index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. :selection.sync="selection"
  11. row-key="id"
  12. cache-key="systemUserTable"
  13. >
  14. <!-- 表头工具栏 -->
  15. <template v-slot:toolbar>
  16. <el-button
  17. size="small"
  18. type="primary"
  19. icon="el-icon-plus"
  20. class="ele-btn-icon"
  21. @click="openEdit()"
  22. >
  23. 新建
  24. </el-button>
  25. </template>
  26. <!-- 操作列 -->
  27. <template v-slot:action="{ row }">
  28. <el-link
  29. type="primary"
  30. :underline="false"
  31. icon="el-icon-edit"
  32. @click="openEdit(row)"
  33. >
  34. 编辑
  35. </el-link>
  36. <el-popconfirm
  37. class="ele-action"
  38. title="确定要删除此物料组吗?"
  39. @confirm="remove(row)"
  40. >
  41. <template v-slot:reference>
  42. <el-link type="danger" :underline="false" icon="el-icon-delete">
  43. 删除
  44. </el-link>
  45. </template>
  46. </el-popconfirm>
  47. </template>
  48. </ele-pro-table>
  49. </el-card>
  50. <!-- 编辑弹窗 -->
  51. <list-edit
  52. :visible.sync="showEdit"
  53. :data="current"
  54. @done="reload"
  55. ref="listEdit"
  56. />
  57. </div>
  58. </template>
  59. <script>
  60. import { getGroupPage , removeItem } from '@/api/material/list';
  61. import ListEdit from './components/list-edit.vue';
  62. export default {
  63. name: 'MaterialList',
  64. components: {
  65. ListEdit
  66. },
  67. data () {
  68. return {
  69. // 表格列配置
  70. columns: [
  71. {
  72. columnKey: 'index',
  73. type: 'index',
  74. width: 55,
  75. align: 'center',
  76. showOverflowTooltip: true,
  77. fixed: 'left',
  78. label: '序号'
  79. },
  80. {
  81. prop: 'name',
  82. label: '物料组名称',
  83. showOverflowTooltip: true,
  84. minWidth: 110
  85. },
  86. {
  87. prop: 'code',
  88. label: '物料组编码',
  89. showOverflowTooltip: true,
  90. minWidth: 110
  91. },
  92. {
  93. prop: 'categoryLevelRootName',
  94. label: '关联分类树',
  95. showOverflowTooltip: true,
  96. minWidth: 110,
  97. formatter:(_row, _column, cellValue) => {
  98. return _row.categoryLevelRootName+'分类';
  99. }
  100. },
  101. {
  102. columnKey: 'action',
  103. label: '操作',
  104. width: 220,
  105. align: 'center',
  106. resizable: false,
  107. slot: 'action',
  108. showOverflowTooltip: true
  109. }
  110. ],
  111. // 表格选中数据
  112. selection: [],
  113. // 当前编辑数据
  114. current: null,
  115. // 是否显示编辑弹窗
  116. showEdit: false
  117. };
  118. },
  119. methods: {
  120. /* 表格数据源 */
  121. datasource ({ page, limit, where, order }) {
  122. return getGroupPage({ ...where, ...order, pageNum: page, size: limit });
  123. },
  124. /* 刷新表格 */
  125. reload (where) {
  126. this.$refs.table.reload({ page: 1, where: where });
  127. },
  128. /* 打开编辑弹窗 */
  129. openEdit (row) {
  130. this.current = row;
  131. this.showEdit = true;
  132. this.$refs.listEdit.$refs.form &&this.$refs.listEdit.$refs.form.clearValidate();
  133. },
  134. /* 删除 */
  135. remove (row) {
  136. const loading = this.$loading({ lock: true });
  137. removeItem([row.id])
  138. .then((msg) => {
  139. loading.close();
  140. this.$message.success(msg);
  141. this.reload();
  142. })
  143. .catch((e) => {
  144. loading.close();
  145. // this.$message.error(e.message);
  146. });
  147. }
  148. }
  149. };
  150. </script>