report-equipment.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <ele-modal
  3. :visible.sync="visible"
  4. title="添加工单-选择设备"
  5. width="65vw"
  6. append-to-body
  7. :maxable="true"
  8. >
  9. <div class="search-box">
  10. 设备名称
  11. <el-input placeholder="请输入" v-model="name"></el-input>
  12. </div>
  13. <!-- 数据表格 -->
  14. <!-- :highlight-current-row="isSingle" -->
  15. <ele-pro-table
  16. ref="table"
  17. :columns="columns"
  18. @done="handleDone"
  19. row-key="id"
  20. :needPage="false"
  21. :initLoad="false"
  22. :selection.sync="selectionList"
  23. :datasource="datasourceShow"
  24. :current.sync="current"
  25. highlight-current-row
  26. height="45vh"
  27. @row-click="choose"
  28. >
  29. <template v-slot:select="{ row }">
  30. <el-radio class="radio" v-model="radio" :label="row.id"
  31. ><i></i
  32. ></el-radio>
  33. </template>
  34. </ele-pro-table>
  35. <div class="footer" slot="footer">
  36. <el-button @click="cancel">取消</el-button>
  37. <el-button @click="confirm" type="primary">确定</el-button>
  38. </div>
  39. </ele-modal>
  40. </template>
  41. <script>
  42. import { getDeviceByTaskId } from '@/api/produceOrder/index';
  43. export default {
  44. props: {
  45. taskId: {
  46. type: String,
  47. default: ''
  48. }
  49. },
  50. data() {
  51. return {
  52. visible: false,
  53. current: null,
  54. name: '',
  55. selectionList: [],
  56. memoList: [],
  57. datasource: [],
  58. isSingle: false,
  59. callback: null,
  60. radio: ''
  61. };
  62. },
  63. computed: {
  64. columns() {
  65. const list = [
  66. {
  67. label: '设备编码',
  68. prop: 'code'
  69. },
  70. {
  71. label: '设备名称',
  72. prop: 'name'
  73. },
  74. // {
  75. // label: '生产状态',
  76. // prop: 'status'
  77. // },
  78. {
  79. label: '未完成工单数',
  80. prop: 'incompleteOrderNum'
  81. },
  82. {
  83. label: '预计完成时间',
  84. prop: 'planCompleteDate'
  85. },
  86. // {
  87. // label: '产能',
  88. // prop: 'capacityNum',
  89. // width: 200,
  90. // formatter: (row) =>
  91. // row.capacityNum + ' ' + row.capacityUnit + '/' + row.capacityTime
  92. // },
  93. {
  94. label: '末单牌号',
  95. prop: 'lastOrderGrade'
  96. }
  97. ];
  98. if (!this.isSingle) {
  99. list.push({
  100. slot: 'select',
  101. prop: 'select',
  102. label: '选择',
  103. align: 'center'
  104. });
  105. }
  106. return list;
  107. },
  108. datasourceShow() {
  109. return this.datasource?.filter((item) => {
  110. if (this.name) {
  111. return item.name.includes(this.name);
  112. }
  113. return true;
  114. });
  115. }
  116. },
  117. methods: {
  118. openSingle(list = [], callback) {
  119. this.memoList = list;
  120. this.callback = callback;
  121. this.isSingle = true;
  122. this.visible = true;
  123. this._getList();
  124. },
  125. handleDone({ data }) {
  126. if (this.memoList.length) {
  127. this.$nextTick(() => {
  128. this.$refs.table.setCurrentRow(
  129. data.find(
  130. (item) =>
  131. item.id ==
  132. (this.memoList[0].deviceId ||
  133. this.memoList[0].sourceInstanceId)
  134. )
  135. );
  136. });
  137. }
  138. },
  139. async _getList() {
  140. const data = await getDeviceByTaskId({
  141. rootCategoryLevelId: '4',
  142. taskId: this.taskId
  143. });
  144. this.datasource = data || [];
  145. },
  146. confirm() {
  147. if (this.isSingle) {
  148. if (!this.current) return this.$message.error('请选择数据');
  149. this.callback && this.callback(this.current);
  150. } else {
  151. if (!this.current) return this.$message.error('请选择数据');
  152. this.$emit('success', [this.current]);
  153. }
  154. this.cancel();
  155. },
  156. cancel() {
  157. this.$refs.table.setCurrentRow();
  158. this.$refs.table.clearSelection();
  159. this.radio = '';
  160. this.current = null;
  161. this.visible = false;
  162. },
  163. // 单击获取id
  164. choose(row) {
  165. this.current = row;
  166. this.radio = row.id;
  167. }
  168. }
  169. };
  170. </script>
  171. <style lang="scss" scoped>
  172. .search-box {
  173. display: flex;
  174. justify-content: flex-start;
  175. align-items: center;
  176. margin-bottom: 20px;
  177. .el-input {
  178. width: 220px;
  179. margin: 0 32px;
  180. }
  181. }
  182. </style>