user-list.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div>
  3. <user-search @search="reload" ref="searchRef">
  4. </user-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" height="calc(100vh - 265px)"
  7. full-height="calc(100vh - 116px)" tool-class="ele-toolbar-form" cache-key="systemOrgUserTable">
  8. <!-- 表头工具栏 -->
  9. <template v-slot:toolbar>
  10. <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openAdd()">
  11. 新增
  12. </el-button>
  13. </template>
  14. <!-- 编码列 -->
  15. <template v-slot:name="{ row }">
  16. {{ row.qualityStandard.name }}
  17. </template>
  18. <template v-slot:code="{ row }">
  19. {{ row.qualityStandard.code }}
  20. </template>
  21. <template v-slot:status="{ row }">
  22. {{ row.status == 1 ? '启用' : '停用' }}
  23. </template>
  24. <template v-slot:mode="{ row }">
  25. {{getDictValue('质检方式', row.mode)}}
  26. </template>
  27. <template v-slot:version="{ row }">
  28. {{ row.version }}
  29. </template>
  30. <template v-slot:action="{ row }">
  31. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(row)">
  32. 编辑
  33. </el-link>
  34. <el-popconfirm class="ele-action" title="确定要删除此干燥区吗?" @confirm="remove(row)">
  35. <template v-slot:reference>
  36. <el-link type="danger" :underline="false" icon="el-icon-delete">
  37. 删除
  38. </el-link>
  39. </template>
  40. </el-popconfirm>
  41. </template>
  42. </ele-pro-table>
  43. <Add @chooseProcess="chooseProcess" ref="addRef" />
  44. <edit ref="edit" @done="done"></edit>
  45. </div>
  46. </template>
  47. <script>
  48. import userSearch from './user-search.vue';
  49. import { getList, removeItem, saveBatch } from '@/api/inspectionClassify/index';
  50. import dictMixins from '@/mixins/dictMixins';
  51. import Add from './add.vue';
  52. import Edit from './edit.vue'
  53. export default {
  54. mixins: [dictMixins],
  55. components: { userSearch, Add, Edit },
  56. props: {
  57. // 类别id
  58. categoryId: [Number, String],
  59. rootId: [Number, String],
  60. },
  61. data() {
  62. return {
  63. // 当前编辑数据
  64. current: null,
  65. // 表格列配置
  66. columns: [
  67. {
  68. columnKey: 'index',
  69. type: 'index',
  70. label: '序号',
  71. width: 55,
  72. align: 'center',
  73. },
  74. {
  75. prop: 'name',
  76. label: '标准名称',
  77. showOverflowTooltip: true,
  78. minWidth: 110,
  79. slot: 'name',
  80. },
  81. {
  82. prop: 'code',
  83. label: '标准编码',
  84. showOverflowTooltip: true,
  85. minWidth: 110,
  86. slot: 'code',
  87. },
  88. {
  89. prop: 'status',
  90. label: '状态',
  91. align: 'center',
  92. minWidth: 110,
  93. slot: 'status',
  94. },
  95. {
  96. prop: 'mode',
  97. label: '类型',
  98. align: 'center',
  99. minWidth: 110,
  100. slot: 'mode',
  101. },
  102. {
  103. prop: 'version',
  104. label: '版本号',
  105. align: 'center',
  106. minWidth: 110,
  107. slot: 'version',
  108. },
  109. {
  110. label: '操作',
  111. prop: 'action',
  112. slot: 'action',
  113. action: 'action'
  114. }
  115. ]
  116. };
  117. },
  118. created() {
  119. this.requestDict('质检方式');
  120. },
  121. methods: {
  122. /* 表格数据源 */
  123. datasource({ page, limit, where }) {
  124. return getList({
  125. ...where,
  126. pageNum: page,
  127. size: limit,
  128. categoryLevelId: this.categoryId,
  129. rootCategoryLevelId: this.rootId
  130. });
  131. },
  132. /* 刷新表格 */
  133. reload(where) {
  134. this.$refs.table.reload({ pageNum: 1, where: where , categoryLevelId: this.categoryId, rootCategoryLevelId: this.rootId});
  135. },
  136. /* 打开编辑弹窗 */
  137. openAdd() {
  138. this.$refs.addRef.open(this.categoryId);
  139. },
  140. openEdit(row) {
  141. this.$refs.edit.open(row);
  142. },
  143. chooseProcess(data) {
  144. saveBatch(data).then(res => {
  145. console.log(res)
  146. if (res.code == 0) {
  147. this.$message.success(res.message)
  148. this.reload()
  149. }
  150. })
  151. },
  152. /* 删除 */
  153. remove(row) {
  154. const loading = this.$loading({ lock: true });
  155. removeItem([row.id])
  156. .then((msg) => {
  157. loading.close();
  158. this.$message.success(msg);
  159. this.reload();
  160. })
  161. .catch((e) => {
  162. loading.close();
  163. });
  164. },
  165. done() {
  166. this.$refs.searchRef.search();
  167. }
  168. },
  169. watch: {
  170. // 监听类别id变化
  171. categoryId() {
  172. this.reload();
  173. }
  174. }
  175. };
  176. </script>