ParamModal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <el-dialog :title="title" :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. <user-search @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection"
  8. row-key="code">
  9. <template v-slot:status="{ row }">
  10. {{ checkType(row.categoryType) }}
  11. </template>
  12. <!-- 状态列 -->
  13. <template v-slot:textType="{ row }">
  14. {{ row.textType == 1 ? '数值' : row.textType == 2 ? '选择' : row.textType == 3 ? '产品参数' : row.textType == 4
  15. ? '规格' :
  16. '' }}
  17. </template>
  18. </ele-pro-table>
  19. </el-card>
  20. <div class="btns">
  21. <el-button type="primary" size="small" @click="selected">选择</el-button>
  22. <el-button size="small" @click="handleClose">关闭</el-button>
  23. </div>
  24. </el-dialog>
  25. </template>
  26. <script>
  27. import UserSearch from '@/views/technology/parameter/components/user-search.vue'
  28. import parameter from '@/api/technology/parameter';
  29. export default {
  30. components: { UserSearch },
  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.tableData.some((it) => it.id == row.id);
  44. },
  45. reserveSelection: true,
  46. fixed: 'left'
  47. },
  48. {
  49. prop: 'code',
  50. label: '参数编码',
  51. showOverflowTooltip: true,
  52. align: 'center',
  53. minWidth: 110
  54. },
  55. {
  56. prop: 'name',
  57. label: '参数名称',
  58. showOverflowTooltip: true,
  59. align: 'center',
  60. minWidth: 110
  61. },
  62. {
  63. prop: 'textType',
  64. label: '参数类型',
  65. showOverflowTooltip: true,
  66. align: 'center',
  67. slot: 'textType',
  68. minWidth: 110
  69. },
  70. {
  71. align: 'center',
  72. prop: 'description',
  73. label: '文本描述',
  74. showOverflowTooltip: true,
  75. minWidth: 110
  76. },
  77. {
  78. prop: 'maxValue',
  79. label: '参数上限',
  80. align: 'center',
  81. showOverflowTooltip: true
  82. },
  83. {
  84. prop: 'minValue',
  85. label: '参数下限',
  86. align: 'center',
  87. showOverflowTooltip: true
  88. },
  89. {
  90. prop: 'defaultValue',
  91. label: '默认值',
  92. align: 'center',
  93. showOverflowTooltip: true
  94. },
  95. {
  96. prop: 'categoryType',
  97. label: '参数分类',
  98. align: 'center',
  99. slot: 'status',
  100. showOverflowTooltip: true
  101. },
  102. ],
  103. statusList: [
  104. { label: '工艺', value: 0 },
  105. { label: '工序', value: 1 },
  106. { label: '产品', value: 2 },
  107. { label: '原料', value: 3 },
  108. { label: '设备', value: 4 },
  109. { label: '其他', value: 5 }
  110. ],
  111. // 表格选中数据
  112. selection: [],
  113. tableData: [],
  114. current: null
  115. }
  116. },
  117. watch: {
  118. },
  119. methods: {
  120. /*回显类型 */
  121. checkType(id) {
  122. const obj = this.statusList.find((item) => item.value == id);
  123. return obj.label;
  124. },
  125. /* 表格数据源 */
  126. async datasource({ page, limit, where, order }) {
  127. const res = await parameter.list({
  128. ...where,
  129. ...order,
  130. pageNum: page,
  131. size: limit
  132. });
  133. return res;
  134. },
  135. /* 刷新表格 */
  136. reload(where) {
  137. this.$refs.table.reload({ page: 1, where: where });
  138. },
  139. open(item, current) {
  140. if (item) {
  141. this.tableData = item
  142. }
  143. if(current) {
  144. this.current = current
  145. }
  146. this.visible = true
  147. },
  148. handleClose() {
  149. this.visible = false
  150. this.$refs.table.setSelectedRows([]);
  151. this.selection = []
  152. },
  153. selected() {
  154. if (!this.selection.length) {
  155. this.$message.error('请至少选择一条数据');
  156. return;
  157. }
  158. this.$emit('chooseModal', this.selection, this.current)
  159. this.handleClose()
  160. },
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .btns {
  166. text-align: center;
  167. padding: 10px 0;
  168. }
  169. </style>