pickingList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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. <el-card shadow="never">
  13. <pickingListSearch @search="reload" ref="searchRef" />
  14. <ele-split-layout
  15. width="244px"
  16. allow-collapse
  17. :right-style="{ overflow: 'hidden' }"
  18. >
  19. <div class="ele-border-lighter split-layout-right-content">
  20. <AssetTree
  21. ref="assetTreeRef"
  22. :treeIds="treeIds"
  23. @handleNodeClick="handleNodeClick"
  24. @setRootId="setRootId"
  25. />
  26. </div>
  27. <!-- 表格 -->
  28. <template v-slot:content>
  29. <ele-pro-table
  30. :initLoad="false"
  31. ref="table"
  32. :columns="columns"
  33. :datasource="datasource"
  34. :selection.sync="selection"
  35. row-key="id"
  36. height="calc(100vh - 350px)"
  37. class="dict-table"
  38. :cache-key="tableKey"
  39. :row-style="rowStyle"
  40. :row-click-checked="true"
  41. :row-click-checked-intelligent="false"
  42. @update:selection="handleSelectionChange"
  43. >
  44. <template v-slot:toolbar>
  45. <el-alert
  46. type="info"
  47. :closable="false"
  48. class="ele-alert-border"
  49. style="width: 300px"
  50. >
  51. <i class="el-icon-info ele-text-info"></i>
  52. <span class="ele-text">
  53. <span>
  54. 已选择
  55. <b class="ele-text-info">{{ allSelection.length }}</b>
  56. 项数据<em></em>
  57. </span>
  58. </span>
  59. <el-link type="primary" :underline="false" @click="clearChoose">
  60. 清空
  61. </el-link>
  62. </el-alert>
  63. </template>
  64. <template v-slot:code="{ row }">
  65. {{ row.rootCategoryLevelId == 4 ? row.codeNumber : row.code }}
  66. </template>
  67. <template v-slot:runStatus="{ row }">
  68. {{ stateList[Number(row.runStatus)] }}
  69. </template>
  70. <template v-slot:vehicleLen="{ row }">
  71. {{ row.extInfo.vehicleLen || '-' }}
  72. {{ row.extInfo.wilde || '-' }} {{ row.extInfo.hight || '-' }}
  73. </template>
  74. <template v-slot:status="{ row }">
  75. <span
  76. :style="{ color: row.status == 0 ? '#157A2C' : '#FFA929' }"
  77. >{{
  78. row.status == 0 ? '空闲' : row.status == 1 ? '占用' : ''
  79. }}</span
  80. >
  81. </template>
  82. <template v-slot:packingCountBase="{ row }">
  83. {{ row.packingCountBase }} {{ row.minUnit }}
  84. </template>
  85. <template v-slot:availableCountBase="{ row }">
  86. {{ row.availableCountBase }} {{ row.measuringUnit }}
  87. </template>
  88. <template v-slot:weight="{ row }">
  89. {{ row.weight }} {{ row.weightUnit }}
  90. </template>
  91. <!-- 库存保质期 -->
  92. <template v-slot:expirationDate="{ row }">
  93. <span v-if="row.expirationDate">
  94. {{ row.expirationDate ? row.expirationDate : '-' }}
  95. {{
  96. row.expirationDateUnit == 'year'
  97. ? '年'
  98. : row.expirationDateUnit == 'month'
  99. ? '月'
  100. : '日'
  101. }}
  102. </span>
  103. </template>
  104. <!-- 质检状态 -->
  105. <template v-slot:qualityStatus="{ row }">
  106. <span v-if="row.qualityResult == 0 || row.qualityResult == 1"
  107. >已检</span
  108. >
  109. <span v-else-if="row.qualityStatus == 1">已检</span>
  110. <span v-else-if="row.qualityStatus == 0">未检</span>
  111. <span v-else>-</span>
  112. </template>
  113. <!-- 质检结果 -->
  114. <template v-slot:qualityResult="{ row }">
  115. <span v-if="row.qualityResult == 0 || row.qualityResult == ''"
  116. >合格</span
  117. >
  118. <span v-else-if="row.qualityResult == 1">不合格</span>
  119. <span v-else-if="row.qualityResult == 3">让步接收</span>
  120. <span v-else>-</span>
  121. </template>
  122. </ele-pro-table>
  123. </template>
  124. </ele-split-layout>
  125. </el-card>
  126. <div class="btns">
  127. <el-button type="primary" size="small" @click="selected">选择</el-button>
  128. <el-button size="small" @click="handleClose">关闭</el-button>
  129. </div>
  130. </el-dialog>
  131. </template>
  132. <script>
  133. import AssetTree from '../../components/assetTree.vue';
  134. import pickingListSearch from './pickingListSearch.vue';
  135. import {
  136. pageeLedgerMain,
  137. assetPage,
  138. listInProduct
  139. } from '@/api/produce/workOrder';
  140. export default {
  141. components: { AssetTree, pickingListSearch },
  142. props: {
  143. isType: {
  144. type: String,
  145. default: '',
  146. required: true
  147. }
  148. },
  149. data() {
  150. return {
  151. visible: false,
  152. id: null,
  153. treeIds: null,
  154. categoryLevelId: null,
  155. rootCategoryLevelId: null,
  156. isCategory: true,
  157. stateList: [
  158. '启动',
  159. '空闲',
  160. '运行',
  161. '故障',
  162. '检修',
  163. '停机',
  164. '待料',
  165. '占用'
  166. ],
  167. selection: [],
  168. allSelection: [],
  169. temporaryList: []
  170. };
  171. },
  172. computed: {
  173. tableKey() {
  174. return `table-${this.rootCategoryLevelId}`;
  175. },
  176. // 表格列配置
  177. columns() {
  178. return [
  179. {
  180. width: 45,
  181. type: 'selection',
  182. columnKey: 'selection',
  183. align: 'center',
  184. reserveSelection: true
  185. },
  186. {
  187. columnKey: 'index',
  188. label: '序号',
  189. type: 'index',
  190. width: 50,
  191. align: 'center'
  192. },
  193. {
  194. prop: 'code',
  195. label: '设备编码',
  196. slot: 'code'
  197. },
  198. {
  199. prop: 'codeNumber',
  200. label: '编号',
  201. showOverflowTooltip: true
  202. },
  203. {
  204. prop: 'name',
  205. label: '名称',
  206. showOverflowTooltip: true
  207. },
  208. {
  209. prop: 'brandNum',
  210. label: '牌号',
  211. showOverflowTooltip: true
  212. },
  213. {
  214. prop: 'specification',
  215. label: '规格',
  216. showOverflowTooltip: true
  217. },
  218. {
  219. prop: 'modelType',
  220. label: '型号',
  221. showOverflowTooltip: true
  222. },
  223. {
  224. prop: 'batchNo',
  225. label: '批次号',
  226. align: 'center'
  227. },
  228. // {
  229. // prop: 'manualBatchNo',
  230. // label: '批次号',
  231. // align: 'center'
  232. // },
  233. {
  234. prop: 'availableCountBase',
  235. label: '计量库存数量',
  236. sortable: 'custom',
  237. slot: 'availableCountBase',
  238. showOverflowTooltip: true,
  239. width: 130,
  240. align: 'center'
  241. },
  242. ...([1, 23, 8].includes(Number(this.rootCategoryLevelId))
  243. ? [
  244. {
  245. prop: 'packingCountBase',
  246. label: '包装库存',
  247. slot: 'packingCountBase',
  248. showOverflowTooltip: true
  249. }
  250. ]
  251. : []),
  252. {
  253. prop: 'weight',
  254. label: '重量',
  255. showOverflowTooltip: true,
  256. slot: 'weight'
  257. },
  258. {
  259. prop: 'expirationDate',
  260. slot: 'expirationDate',
  261. label: '库存保质期',
  262. width: 100
  263. },
  264. {
  265. prop: 'expirationTime',
  266. label: '周期倒计时',
  267. showOverflowTooltip: true,
  268. width: 100
  269. },
  270. {
  271. prop: 'qualityResult',
  272. slot: 'qualityResult',
  273. label: '质检结果',
  274. showOverflowTooltip: true,
  275. width: 100
  276. },
  277. {
  278. prop: 'qualityStatus',
  279. slot: 'qualityStatus',
  280. label: '质检状态',
  281. showOverflowTooltip: true,
  282. width: 100
  283. },
  284. {
  285. prop: 'pathName',
  286. width: 230,
  287. label: '仓库',
  288. showOverflowTooltip: true
  289. },
  290. ...(this.rootCategoryLevelId == '4'
  291. ? [
  292. {
  293. prop: 'workstationName',
  294. label: '工位',
  295. showOverflowTooltip: true
  296. },
  297. {
  298. prop: 'runStatus',
  299. label: '状态',
  300. slot: 'runStatus',
  301. showOverflowTooltip: true
  302. }
  303. ]
  304. : []),
  305. // ...(this.rootCategoryLevelId == '5'
  306. // ? [
  307. // {
  308. // prop: 'dieHoleNum',
  309. // label: '模孔数量',
  310. // showOverflowTooltip: true
  311. // },
  312. // {
  313. // prop: 'mandrelDiameter',
  314. // label: '芯棒直径',
  315. // showOverflowTooltip: true
  316. // },
  317. // {
  318. // prop: 'shrinkEffictive',
  319. // label: '收缩系数',
  320. // showOverflowTooltip: true
  321. // }
  322. // ]
  323. // : []),
  324. // ...(this.rootCategoryLevelId == '7'
  325. // ? [
  326. // {
  327. // prop: 'materialQuality',
  328. // label: '材质',
  329. // showOverflowTooltip: true
  330. // },
  331. // {
  332. // prop: 'vehicleLen',
  333. // label: '长宽高',
  334. // slot: 'vehicleLen',
  335. // showOverflowTooltip: true
  336. // }
  337. // ]
  338. // : []),
  339. ...(this.rootCategoryLevelId == '8'
  340. ? [
  341. {
  342. prop: 'extInfo.slotNum',
  343. label: '槽数',
  344. showOverflowTooltip: true
  345. }
  346. ]
  347. : []),
  348. ...(this.rootCategoryLevelId == '11'
  349. ? [
  350. {
  351. prop: 'status',
  352. label: '状态',
  353. slot: 'status',
  354. showOverflowTooltip: true
  355. },
  356. {
  357. prop: 'region',
  358. label: '位置',
  359. showOverflowTooltip: true
  360. }
  361. ]
  362. : [])
  363. ];
  364. }
  365. },
  366. watch: {},
  367. methods: {
  368. /* 表格数据源 */
  369. async datasource({ page, where, limit }) {
  370. let URL;
  371. let param = {
  372. ...where,
  373. pageNum: page,
  374. size: limit,
  375. categoryLevelId: this.categoryLevelId
  376. };
  377. if (this.isType == 'pick') {
  378. param.dimension = 1;
  379. URL = pageeLedgerMain;
  380. } else if (this.isType == 'feed') {
  381. if ([4, 7, 14].includes(Number(this.rootCategoryLevelId))) {
  382. URL = assetPage;
  383. } else if (this.rootCategoryLevelId == 2) {
  384. param.workOrderId = this.id;
  385. delete param.taskId;
  386. delete param.categoryLevelId;
  387. URL = listInProduct;
  388. } else if (
  389. ![2, 4, 7, 14].includes(Number(this.rootCategoryLevelId))
  390. ) {
  391. URL = assetPage;
  392. }
  393. } else if (this.isType == 'job') {
  394. URL = assetPage;
  395. }
  396. const res = await URL(param);
  397. if (this.rootCategoryLevelId == '11') {
  398. let _res = res;
  399. let _list = [];
  400. _res.list.forEach((e) => {
  401. if (e.aridRegionList && e.aridRegionList.length != 0) {
  402. e.aridRegionList.map((i) => {
  403. let obj = {
  404. name: e.name,
  405. region: e.extInfo.region,
  406. rootCategoryLevelId: e.rootCategoryLevelId,
  407. ...i,
  408. instanceId: i.id
  409. };
  410. _list.push(obj);
  411. });
  412. }
  413. });
  414. res.list = _list;
  415. return res;
  416. } else {
  417. let _res = res;
  418. let _list = [];
  419. _list.push(
  420. ..._res.list.map((i) => {
  421. const warehouseId = i.pathIds && i.pathIds.split(',')[0];
  422. return {
  423. warehouseId,
  424. ...i,
  425. instanceId: i.id
  426. };
  427. })
  428. );
  429. res.list = _list;
  430. return res;
  431. }
  432. },
  433. handleSelectionChange(data) {
  434. this.allSelection = data;
  435. },
  436. /* 清空选择 */
  437. clearChoose() {
  438. this.allSelection = [];
  439. this.$refs.table.clearSelection();
  440. },
  441. rowStyle({ row }) {
  442. return this.selection.includes(row) ? { background: '#e6f7ff' } : null;
  443. },
  444. handleNodeClick(data) {
  445. console.log(data, 'handleNodeClick');
  446. this.isCategory = true;
  447. this.categoryLevelId = data.id;
  448. this.rootCategoryLevelId = data.rootCategoryLevelId;
  449. this.reload();
  450. },
  451. setRootId(data) {
  452. this.categoryLevelId = data.id;
  453. this.rootCategoryLevelId = data.rootCategoryLevelId;
  454. this.reload();
  455. },
  456. /* 刷新表格 */
  457. reload(where) {
  458. this.$nextTick(() => {
  459. this.isCategory = false;
  460. this.$refs.table.reload({ pageNum: 1, where: where });
  461. });
  462. },
  463. onDone() {
  464. this.$nextTick(() => {
  465. this.allSelection.forEach((item) => {
  466. this.$refs.table.toggleRowSelection(item, true);
  467. });
  468. });
  469. },
  470. open(id, item, t) {
  471. this.id = id;
  472. if (t) {
  473. this.title = t;
  474. } else {
  475. this.title = '领料列表';
  476. }
  477. if (this.isType == 'pick') {
  478. this.temporaryList = item.pickList || [];
  479. this.allSelection = item.pickList || [];
  480. this.visible = true;
  481. this.$nextTick(() => {
  482. this.allSelection.forEach((item) => {
  483. this.$refs.table.toggleRowSelection(item, true);
  484. });
  485. });
  486. } else if (this.isType == 'feed') {
  487. let feedList = [];
  488. feedList = [
  489. ...item.modelList,
  490. ...item.equipmentList,
  491. ...item.instanceList,
  492. ...item.aridRegionList,
  493. ...item.turnover,
  494. ...item.palletList,
  495. ...item.revolvingDiskList,
  496. ...item.semiProductList
  497. ];
  498. this.temporaryList = feedList || [];
  499. this.allSelection = feedList || [];
  500. this.visible = true;
  501. this.$nextTick(() => {
  502. feedList.forEach((item) => {
  503. this.$refs.table.toggleRowSelection(item, true);
  504. });
  505. });
  506. } else if (this.isType == 'job') {
  507. let feedList = [];
  508. feedList = [...item.turnover, ...item.equipmentList];
  509. this.temporaryList = feedList || [];
  510. this.allSelection = feedList || [];
  511. this.visible = true;
  512. this.$nextTick(() => {
  513. feedList.forEach((item) => {
  514. this.$refs.table.toggleRowSelection(item, true);
  515. });
  516. });
  517. }
  518. },
  519. handleClose() {
  520. this.clearChoose();
  521. this.temporaryList = [];
  522. this.allSelection = [];
  523. this.visible = false;
  524. },
  525. selected() {
  526. if (this.allSelection.length == 0) {
  527. this.$message.warning('请选择物料');
  528. return false;
  529. }
  530. if (this.temporaryList.length > 0) {
  531. // 使用Promise来“模拟”异步操作
  532. new Promise((resolve) => {
  533. if (this.temporaryList.length > 0) {
  534. this.temporaryList.forEach((item) => {
  535. this.allSelection.forEach((item2) => {
  536. if (item.id == item2.id && this.isType == 'pick') {
  537. this.$set(
  538. item2,
  539. 'demandQuantity',
  540. item.demandQuantity || null
  541. );
  542. } else if (item.id == item2.id && this.isType == 'feed') {
  543. this.$set(item2, 'feedQuantity', item.feedQuantity || null);
  544. }
  545. });
  546. });
  547. }
  548. this.allSelection.sort(
  549. (a, b) => a.rootCategoryLevelId - b.rootCategoryLevelId
  550. );
  551. resolve();
  552. }).then(() => {
  553. this.$emit('allSelection', this.id, this.allSelection);
  554. this.handleClose();
  555. });
  556. } else {
  557. this.allSelection.sort(
  558. (a, b) => a.rootCategoryLevelId - b.rootCategoryLevelId
  559. );
  560. this.$emit('allSelection', this.id, this.allSelection);
  561. this.handleClose();
  562. }
  563. }
  564. },
  565. created() {
  566. if (this.isType == 'pick') {
  567. // this.treeIds = '1, 5, 7, 8, 10, 13, 14, 23, 26, 9, 28';
  568. this.treeIds = '9, 23, 2, 1, 4, 14, 5, 8, 16, 13, 15, 6, 10, 22';
  569. } else if (this.isType == 'feed') {
  570. this.treeIds = '1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 26, 9, 23,28';
  571. } else if (this.isType == 'job') {
  572. this.treeIds = '4, 7';
  573. }
  574. }
  575. };
  576. </script>
  577. <style lang="scss" scoped>
  578. .tree_col {
  579. border: 1px solid #eee;
  580. padding: 10px 0;
  581. box-sizing: border-box;
  582. height: 500px;
  583. overflow: auto;
  584. }
  585. .table_col {
  586. padding-left: 10px;
  587. ::v-deep .el-table th.el-table__cell {
  588. background: #f2f2f2;
  589. }
  590. }
  591. .pagination {
  592. text-align: right;
  593. padding: 10px 0;
  594. }
  595. .btns {
  596. text-align: center;
  597. padding: 10px 0;
  598. }
  599. .topsearch {
  600. margin-bottom: 15px;
  601. }
  602. ::v-deep .is-checked {
  603. background: #e6f7ff;
  604. }
  605. </style>