user-edit.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <el-dialog :title="title" v-if="visible" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
  3. :close-on-press-escape="false" append-to-body width="70%">
  4. <el-card shadow="never">
  5. <userEditSearch @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection" row-key="id">
  8. <template v-slot:status="{ row }">
  9. {{ row.status ? '启用' : "停用" }}
  10. </template>
  11. <template v-slot:type="{ row }">
  12. {{ getDictValue('质检标准类型', row.type) }}
  13. </template>
  14. </ele-pro-table>
  15. </el-card>
  16. <div class="btns">
  17. <el-button type="primary" size="small" @click="selected">选择</el-button>
  18. <el-button size="small" @click="handleClose">关闭</el-button>
  19. </div>
  20. </el-dialog>
  21. </template>
  22. <script>
  23. import { getList } from '@/api/inspectionStandard';
  24. import userEditSearch from './user-edit-search.vue'
  25. import dictMixins from '@/mixins/dictMixins';
  26. export default {
  27. components: {
  28. userEditSearch
  29. },
  30. mixins: [dictMixins],
  31. data() {
  32. return {
  33. visible: false,
  34. title: '选择工序',
  35. // 表格列配置
  36. columns: [
  37. {
  38. columnKey: 'selection',
  39. type: 'selection',
  40. width: 45,
  41. align: 'center',
  42. selectable: (row, index) => {
  43. return !this.processData.some((it) => it.id == row.id);
  44. },
  45. reserveSelection: true,
  46. fixed: 'left'
  47. },
  48. {
  49. prop: 'code',
  50. label: '质检编码'
  51. },
  52. {
  53. label: '质检名称',
  54. prop: 'name'
  55. },
  56. {
  57. label: '状态',
  58. prop: 'status',
  59. slot: 'status'
  60. },
  61. {
  62. label: '版本号',
  63. prop: 'version',
  64. },
  65. {
  66. label: '标准类型',
  67. prop: 'type',
  68. slot: 'type',
  69. },
  70. {
  71. label: '标准代码',
  72. prop: 'standardCode',
  73. },
  74. ],
  75. // 表格选中数据
  76. selection: [],
  77. processData: [],
  78. categoryId: null
  79. }
  80. },
  81. watch: {
  82. },
  83. methods: {
  84. open(categoryId) {
  85. this.categoryId = categoryId
  86. this.visible = true
  87. },
  88. /* 表格数据源 */
  89. async datasource({ page, limit, where }) {
  90. const res = await getList({
  91. ...where,
  92. categoryId: this.categoryId,
  93. pageNum: page,
  94. size: limit
  95. });
  96. return res;
  97. },
  98. /* 刷新表格 */
  99. reload(where) {
  100. this.$refs.table.reload({ page: 1, where: where });
  101. },
  102. handleClose() {
  103. this.visible = false
  104. this.$refs.table.setSelectedRows([]);
  105. this.selection = []
  106. },
  107. selected() {
  108. if (!this.selection.length) {
  109. this.$message.error('请至少选择一条数据');
  110. return;
  111. }
  112. let _arr = []
  113. _arr = this.selection.map(m => {
  114. return {
  115. name: m.name,
  116. code: m.code,
  117. qualityStandardId: m.id,
  118. status: true,
  119. mode: null,
  120. version: null
  121. }
  122. })
  123. this.$emit('chooseProcess', _arr)
  124. this.handleClose()
  125. },
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .btns {
  131. text-align: center;
  132. padding: 10px 0;
  133. }
  134. </style>