jobDialog.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. v-if="visible"
  5. :visible.sync="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="70%"
  11. >
  12. <el-card shadow="never">
  13. <user-search :typeList="typeOptions" @search="reload" />
  14. <!-- 数据表格 -->
  15. <ele-pro-table
  16. ref="table"
  17. :columns="columns"
  18. :datasource="datasource"
  19. :selection.sync="selection"
  20. row-key="id"
  21. >
  22. </ele-pro-table>
  23. </el-card>
  24. <div class="btns">
  25. <el-button type="primary" size="small" @click="selected">选择</el-button>
  26. <el-button size="small" @click="handleClose">关闭</el-button>
  27. </div>
  28. </el-dialog>
  29. </template>
  30. <script>
  31. import dictMixins from '@/mixins/dictMixins';
  32. import UserSearch from '@/views/factoryModel/jobManagement/components/user-search.vue';
  33. import { getProfessionPageList } from '@/api/factoryModel';
  34. export default {
  35. components: { UserSearch },
  36. mixins: [dictMixins],
  37. data() {
  38. return {
  39. visible: false,
  40. title: '产品参数',
  41. levelOptions: [
  42. {
  43. label: '初级',
  44. value: '1'
  45. },
  46. {
  47. label: '中级',
  48. value: '2'
  49. },
  50. {
  51. label: '高级',
  52. value: '3'
  53. }
  54. ],
  55. // 表格列配置
  56. columns: [
  57. {
  58. columnKey: 'selection',
  59. type: 'selection',
  60. width: 45,
  61. align: 'center',
  62. fixed: 'left'
  63. },
  64. {
  65. label: '序号',
  66. type: 'index',
  67. width: 55,
  68. align: 'center'
  69. },
  70. {
  71. slot: 'type',
  72. label: '类型',
  73. showOverflowTooltip: true,
  74. align: 'center',
  75. minWidth: 110,
  76. formatter: (_row) => {
  77. return this.getDictValue('工种类型', _row.type);
  78. }
  79. },
  80. {
  81. align: 'center',
  82. prop: 'code',
  83. label: '编码',
  84. showOverflowTooltip: true,
  85. minWidth: 110
  86. },
  87. {
  88. slot: 'name',
  89. prop: 'name',
  90. label: '名称',
  91. showOverflowTooltip: true,
  92. align: 'center',
  93. minWidth: 110
  94. },
  95. {
  96. slot: 'level',
  97. prop: 'level',
  98. label: '等级',
  99. showOverflowTooltip: true,
  100. align: 'center',
  101. minWidth: 110,
  102. formatter: (_row) => {
  103. return this.levelOptions.filter(
  104. (item) => _row.level == item.value
  105. )[0].label;
  106. }
  107. },
  108. {
  109. slot: 'hourCost',
  110. prop: 'hourCost',
  111. label: '标准工时费',
  112. showOverflowTooltip: true,
  113. align: 'center',
  114. minWidth: 110
  115. }
  116. ],
  117. statusList: [
  118. { label: '工艺', value: 0 },
  119. { label: '工序', value: 1 },
  120. { label: '产品', value: 2 },
  121. { label: '原料', value: 3 },
  122. { label: '设备', value: 4 },
  123. { label: '其他', value: 5 }
  124. ],
  125. // 表格选中数据
  126. selection: [],
  127. tableData: [],
  128. current: null
  129. };
  130. },
  131. created() {
  132. this.requestDict('工种类型');
  133. },
  134. computed: {
  135. typeOptions() {
  136. return this.dict[this.dictEnum['工种类型']];
  137. }
  138. },
  139. methods: {
  140. /* 表格数据源 */
  141. async datasource({ page, limit, where, order }) {
  142. const res = await getProfessionPageList({
  143. ...where,
  144. ...order,
  145. pageNum: page,
  146. size: limit
  147. });
  148. return res;
  149. },
  150. /* 刷新表格 */
  151. reload(where) {
  152. this.$refs.table.reload({ page: 1, where: where });
  153. },
  154. open(item, current) {
  155. if (item) {
  156. this.tableData = JSON.parse(JSON.stringify(item));
  157. }
  158. if (current) {
  159. this.current = current;
  160. }
  161. this.visible = true;
  162. },
  163. handleClose() {
  164. this.visible = false;
  165. this.$refs.table.setSelectedRows([]);
  166. this.selection = [];
  167. },
  168. selected() {
  169. if (!this.selection.length) {
  170. this.$message.error('请至少选择一条数据');
  171. return;
  172. }
  173. this.$emit('chooseModal', this.selection, this.current);
  174. this.handleClose();
  175. }
  176. }
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. .btns {
  181. text-align: center;
  182. padding: 10px 0;
  183. }
  184. </style>