instanceBom.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <div>
  3. <div class="title_box rx-bc mt6">
  4. <div class="name">{{ title }} ({{ list.length || 0 }})个 </div>
  5. <div class="rx-bc"> </div>
  6. </div>
  7. <ele-pro-table
  8. ref="table"
  9. :needPage="false"
  10. :columns="columns"
  11. :datasource="list"
  12. class="time-form"
  13. max-height="600"
  14. @columns-change="handleColumnChange"
  15. :cache-key="cacheKeyUrl"
  16. >
  17. <template v-slot:feedQuantity="{ row, $index }">
  18. <el-input
  19. size="mini"
  20. class="content_num"
  21. v-model="row.feedQuantity"
  22. placeholder="数量"
  23. >
  24. <template slot="append">{{ row.unit }}</template>
  25. </el-input>
  26. </template>
  27. <template v-slot:position="{ row, $index }">
  28. <el-input
  29. size="mini"
  30. class="content_num"
  31. v-model="row.extInfo.position"
  32. placeholder="位置"
  33. />
  34. </template>
  35. <template v-slot:weightUnit="{ row, $index }">
  36. <div v-if="currentTaskDiagram.isFirstTask == 1" class="flex-div">
  37. <el-input
  38. v-model="row.extInfo.weight"
  39. size="mini"
  40. :disabled="isDetails"
  41. style="width: 100%"
  42. >
  43. <template slot="append">
  44. <div> {{ row.extInfo.weightUnit }}</div>
  45. </template>
  46. </el-input>
  47. </div>
  48. <div v-if="currentTaskDiagram.isFirstTask == 0">
  49. {{ row.extInfo.newWeight || 0 }}
  50. {{ row.extInfo.weightUnit }}</div
  51. >
  52. </template>
  53. <template v-slot:deviceId="{ row, $index }">
  54. <el-select
  55. v-if="deviceList?.length > 0"
  56. class="content_num"
  57. filterable
  58. v-model="row.deviceId"
  59. placeholder="请选择"
  60. @change="(e) => selectVal(e, row, $index)"
  61. size="mini"
  62. >
  63. <el-option
  64. v-for="item in deviceList"
  65. :label="item.name + '-' + item.codeNumber"
  66. :value="item.id"
  67. :key="item.id"
  68. >
  69. </el-option>
  70. </el-select>
  71. </template>
  72. <template v-slot:heatNumber="{ row, $index }">
  73. <el-input
  74. size="mini"
  75. class="content_num"
  76. v-model="row.extInfo.heatNumber"
  77. placeholder="请输入炉次号"
  78. />
  79. </template>
  80. <!-- 操作列 -->
  81. <template v-slot:action="{ row, $index }" v-if="!isDetails">
  82. <el-link type="danger" @click="getDelete($index)">删除</el-link>
  83. </template>
  84. </ele-pro-table>
  85. </div>
  86. </template>
  87. <script>
  88. import tabMixins from '@/mixins/tableColumnsMixin';
  89. export default {
  90. mixins: [tabMixins],
  91. props: {
  92. list: {
  93. type: Array,
  94. default: () => []
  95. },
  96. equipmentList: {
  97. type: Array,
  98. default: () => []
  99. },
  100. currentTaskDiagram: {
  101. type: Object,
  102. default: () => {}
  103. },
  104. isDetails: {
  105. type: Boolean,
  106. default: false
  107. },
  108. workInfo: {
  109. type: Object,
  110. default: () => {}
  111. },
  112. title: {
  113. type: String,
  114. default: '物料清单'
  115. }
  116. },
  117. computed: {
  118. clientEnvironmentId() {
  119. return this.$store.state.user.info.clientEnvironmentId;
  120. },
  121. columns() {
  122. return [
  123. ...[
  124. {
  125. width: 55,
  126. type: 'index',
  127. columnKey: 'index',
  128. align: 'center',
  129. label: '序号',
  130. fixed: 'left'
  131. },
  132. {
  133. minWidth: 120,
  134. prop: 'code',
  135. label: '编码',
  136. align: 'center',
  137. fixed: 'left',
  138. showOverflowTooltip: true
  139. },
  140. {
  141. minWidth: 140,
  142. prop: 'name',
  143. label: '名称',
  144. align: 'center',
  145. showOverflowTooltip: true
  146. },
  147. {
  148. width: 150,
  149. prop: 'feedQuantity',
  150. label: '数量',
  151. slot: 'feedQuantity',
  152. align: 'center'
  153. },
  154. {
  155. width: 150,
  156. prop: 'position',
  157. label: '位置',
  158. slot: 'position',
  159. align: 'center'
  160. },
  161. {
  162. width: 150,
  163. prop: 'modelType',
  164. label: '型号',
  165. slot: 'modelType',
  166. align: 'center',
  167. showOverflowTooltip: true
  168. },
  169. {
  170. width: 150,
  171. prop: 'specification',
  172. label: '规格',
  173. slot: 'specification',
  174. align: 'center',
  175. showOverflowTooltip: true
  176. },
  177. {
  178. width: 150,
  179. prop: 'brandNum',
  180. label: '牌号',
  181. slot: 'brandNum',
  182. align: 'center',
  183. showOverflowTooltip: true
  184. },
  185. {
  186. width: 120,
  187. prop: 'weightUnit',
  188. label:
  189. this.currentTaskDiagram &&
  190. this.currentTaskDiagram.isFirstTask == 1
  191. ? '物料重量'
  192. : '上道工序重量',
  193. slot: 'weightUnit',
  194. align: 'center',
  195. showOverflowTooltip: true
  196. },
  197. {
  198. minWidth: 120,
  199. prop: 'extInfo.engrave',
  200. label: '刻码',
  201. slot: 'engrave',
  202. align: 'center'
  203. },
  204. {
  205. minWidth: 160,
  206. prop: 'extInfo.materielCode',
  207. label: '物料代号',
  208. align: 'center',
  209. slot: 'materielCode'
  210. },
  211. {
  212. minWidth: 150,
  213. prop: 'deviceId',
  214. label: '设备',
  215. align: 'center',
  216. slot: 'deviceId'
  217. },
  218. {
  219. minWidth: 100,
  220. prop: 'heatNumber',
  221. label: '炉次号',
  222. slot: 'heatNumber',
  223. align: 'center'
  224. },
  225. {
  226. columnKey: 'action',
  227. label: '操作',
  228. width: 120,
  229. align: 'center',
  230. resizable: false,
  231. slot: 'action',
  232. fixed: 'right',
  233. showOverflowTooltip: true
  234. }
  235. ],
  236. this.workInfo.singleReport == 0
  237. ? {
  238. minWidth: 120,
  239. label: '投料类型',
  240. align: 'center',
  241. formatter: () => {
  242. return '批量投料';
  243. },
  244. showOverflowTooltip: true
  245. }
  246. : {
  247. show: false,
  248. width: 1
  249. }
  250. ];
  251. }
  252. },
  253. watch: {
  254. equipmentList: {
  255. immediate: true,
  256. deep: true,
  257. handler(newVal) {
  258. this.deviceList = newVal;
  259. this.changeHeatNumber();
  260. }
  261. }
  262. },
  263. data() {
  264. return {
  265. deviceList: [],
  266. cacheKeyUrl: 'mes_produce_feeding_instanceBom'
  267. };
  268. },
  269. methods: {
  270. getDelete(index) {
  271. this.list.splice(index, 1);
  272. },
  273. selectVal(e, item, idx) {
  274. console.log(e, item, idx);
  275. let obj = this.deviceList.find((f) => f.id == e);
  276. this.$set(
  277. this.list[idx],
  278. 'deviceName',
  279. obj.name + '-' + obj.codeNumber
  280. );
  281. this.$set(
  282. this.list[idx]['extInfo'],
  283. 'heatNumber',
  284. obj.extInfo.heatNumber
  285. );
  286. },
  287. changeHeatNumber() {
  288. this.deviceList.forEach((f) => {
  289. this.list.forEach((o) => {
  290. if (
  291. o.deviceId &&
  292. f.id == o.deviceId &&
  293. this.deviceList.length > 1
  294. ) {
  295. o.extInfo.heatNumber = f.extInfo.heatNumber;
  296. o['workstationName'] = f.workstationName;
  297. } else if (this.deviceList.length == 1) {
  298. o['deviceName'] = this.deviceList[0].name;
  299. o['deviceId'] = this.deviceList[0].id;
  300. o['workstationName'] = this.deviceList[0].workstationName;
  301. this.$set(
  302. o.extInfo,
  303. 'heatNumber',
  304. this.deviceList[0].extInfo.heatNumber
  305. );
  306. this.$forceUpdate();
  307. }
  308. });
  309. });
  310. }
  311. }
  312. };
  313. </script>
  314. <style lang="scss" scoped>
  315. .mb4 {
  316. margin-bottom: 4px;
  317. }
  318. .content_num {
  319. --input-background-color: #f0f8f2;
  320. }
  321. .flex-div {
  322. display: flex;
  323. }
  324. ::v-deep .el-input-group__append {
  325. padding: 0 10px !important;
  326. }
  327. </style>