select-template.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="75%"
  11. >
  12. <ele-pro-table
  13. ref="table"
  14. :columns="columns"
  15. :datasource="templateList"
  16. row-key="id"
  17. height="calc(100vh - 350px)"
  18. :selection.sync="selection"
  19. :needPage="false"
  20. @refresh="getList"
  21. >
  22. </ele-pro-table>
  23. <div class="btns">
  24. <el-button type="primary" size="small" @click="selected">选择</el-button>
  25. <el-button size="small" @click="handleClose">关闭</el-button>
  26. </div>
  27. </el-dialog>
  28. </template>
  29. <script>
  30. import { produceTaskRecordRulesGetTemplateListByProduceTaskId } from '@/api/producetaskrecordrules/index.js';
  31. import dictMixins from '@/mixins/dictMixins';
  32. export default {
  33. mixins: [dictMixins],
  34. components: {},
  35. props: {
  36. // 工序id
  37. produceTaskId: {
  38. type: String,
  39. required: true
  40. }
  41. },
  42. data() {
  43. return {
  44. visible: false,
  45. // 表格列配置
  46. columns: [
  47. {
  48. width: 50,
  49. type: 'selection',
  50. columnKey: 'selection',
  51. align: 'center'
  52. },
  53. {
  54. columnKey: 'index',
  55. type: 'index',
  56. width: 45,
  57. align: 'center',
  58. reserveSelection: true
  59. },
  60. {
  61. prop: 'itemType',
  62. label: '类型',
  63. align: 'center',
  64. formatter: (row) => {
  65. return this.getDictValue('记录规则事项类型', row.itemType);
  66. }
  67. },
  68. {
  69. prop: 'executeMethod',
  70. label: '执行方式',
  71. align: 'center',
  72. formatter: (row) => {
  73. return this.getDictValue('记录规则执行方式', row.executeMethod);
  74. }
  75. },
  76. {
  77. prop: 'rulesName',
  78. label: '名称',
  79. align: 'center',
  80. formatter: (row) => {
  81. return row.rulesName || row.itemTaskName;
  82. }
  83. }
  84. ],
  85. title: '选择模板',
  86. selection: [],
  87. templateList: []
  88. };
  89. },
  90. mounted() {
  91. this.getList();
  92. },
  93. methods: {
  94. async getList() {
  95. const data = await produceTaskRecordRulesGetTemplateListByProduceTaskId(
  96. {
  97. produceTaskId: this.produceTaskId
  98. }
  99. );
  100. console.log('模板列表', data);
  101. this.templateList = data;
  102. },
  103. /* 刷新表格 */
  104. reload(where) {
  105. this.isCategory = false;
  106. this.$refs.table.reload({ pageNum: 1, where: where });
  107. },
  108. open() {
  109. this.visible = true;
  110. },
  111. handleClose() {
  112. this.visible = false;
  113. },
  114. selected() {
  115. if (!this.selection.length) {
  116. return this.$message.warning('请选择模板!');
  117. }
  118. this.$emit('confirm', this.selection);
  119. this.handleClose();
  120. }
  121. }
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. .btns {
  126. text-align: center;
  127. padding: 10px 0;
  128. }
  129. </style>