| | |
| | | <el-divider direction="vertical"></el-divider> |
| | | <span class="less-style">ç©æç¼å·ï¼ {{ row.materielCode }} </span> |
| | | <el-divider direction="vertical"></el-divider> |
| | | <span class="less-style" |
| | | >éæ±æ°éï¼ {{ row.orderQuantity }} |
| | | <span class="less-style"> |
| | | éæ±æ°éï¼ {{ requireQuantity }} |
| | | </span> |
| | | <el-divider direction="vertical"></el-divider> |
| | | <span :class="selectionClass" |
| | | >已鿰éï¼ {{ selectionSum }} |
| | | <span :class="selectionClass"> |
| | | 已鿰éï¼ {{ selectionSum }} |
| | | </span> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | |
| | | @row-click="handleRowClick" |
| | | height="500px" |
| | | @selection-change="handleSelectionChange" |
| | | @select="selectRowChange" |
| | | @select-all="selectAllChange" |
| | | > |
| | | <el-table-column type="selection" width="55"> </el-table-column> |
| | | <el-table-column |
| | |
| | | |
| | | <script> |
| | | import VolBox from "@/components/basic/VolBox.vue"; |
| | | // å¼å
¥ç«å°ç®¡çå·¥å
· |
| | | import { stationManager } from "@/../src/uitils/stationManager"; |
| | | |
| | | export default { |
| | |
| | | mainOrderNo: "", |
| | | pkcx: false, |
| | | showDetialBox: false, |
| | | showStationDialog: false, // ç«å°éæ©å¼¹çªæ¾ç¤ºæ§å¶ |
| | | showStationDialog: false, |
| | | tableData: [], |
| | | dictionaryList: null, // æ°å¢ï¼åå
¸æ°æ® |
| | | dictionaryList: null, |
| | | tableColumns: [ |
| | | { |
| | | prop: "materielCode", |
| | | title: "ç©æç¼å·", |
| | | type: "string", |
| | | width: 150, |
| | | }, |
| | | { |
| | | prop: "materielName", |
| | | title: "ç©æåç§°", |
| | | type: "string", |
| | | width: 150, |
| | | }, |
| | | { |
| | | prop: "palletCode", |
| | | title: "æçç¼å·", |
| | | type: "string", |
| | | width: 150, |
| | | }, |
| | | { |
| | | prop: "barcode", |
| | | title: "æ¡ç ", |
| | | type: "string", |
| | | width: 150, |
| | | }, |
| | | { |
| | | prop: "locationCode", |
| | | title: "è´§ä½ç¼å·", |
| | | type: "string", |
| | | width: 180, |
| | | }, |
| | | { |
| | | prop: "useableQuantity", |
| | | title: "å¯ç¨æ°é", |
| | | type: "string", |
| | | }, |
| | | { |
| | | prop: "supplyCode", |
| | | title: "ä¾åºå", |
| | | type: "string", |
| | | }, |
| | | { |
| | | prop: "batchNo", |
| | | title: "æ¹æ¬¡å·", |
| | | type: "string", |
| | | }, |
| | | { prop: "materielCode", title: "ç©æç¼å·", type: "string", width: 150 }, |
| | | { prop: "materielName", title: "ç©æåç§°", type: "string", width: 150 }, |
| | | { prop: "palletCode", title: "æçç¼å·", type: "string", width: 150 }, |
| | | { prop: "barcode", title: "æ¡ç ", type: "string", width: 150 }, |
| | | { prop: "locationCode", title: "è´§ä½ç¼å·", type: "string", width: 180 }, |
| | | { prop: "useableQuantity", title: "å¯ç¨æ°é", type: "string" }, |
| | | { prop: "supplyCode", title: "ä¾åºå", type: "string" }, |
| | | { prop: "batchNo", title: "æ¹æ¬¡å·", type: "string" }, |
| | | { |
| | | prop: "stockStatus", |
| | | title: "åºåæç»ç¶æ", |
| | |
| | | width: 90, |
| | | bindKey: "stockStatusEmun", |
| | | }, |
| | | { |
| | | prop: "stockId", |
| | | title: "åºå主é®", |
| | | type: "string", |
| | | }, |
| | | { |
| | | prop: "orderDetailId", |
| | | title: "åæ®æç»ä¸»é®", |
| | | type: "string", |
| | | }, |
| | | { prop: "stockId", title: "åºå主é®", type: "string" }, |
| | | { prop: "orderDetailId", title: "åæ®æç»ä¸»é®", type: "string" }, |
| | | ], |
| | | selection: [], |
| | | selectionSum: 0, |
| | | selectionClass: "less-style", |
| | | originalQuantity: 0, |
| | | |
| | | // ç«å°ç¸å
³æ°æ® |
| | | stations: [ |
| | | { label: "ç«å°2", value: "2-1" }, |
| | | { label: "ç«å°3", value: "3-1" }, |
| | | ], |
| | | stationForm: { |
| | | selectedPlatform: "", // ä¿®æ¹å段å以å¹é
åæ° |
| | | selectedPlatform: "", |
| | | }, |
| | | isProcessingSelect: false, |
| | | }; |
| | | }, |
| | | computed: { |
| | | requireQuantity() { |
| | | if (!this.row) return 0; |
| | | return this.row.orderQuantity - this.row.lockQuantity - (this.row.moveQty || 0); |
| | | }, |
| | | isFull() { |
| | | return this.selectionSum >= this.requireQuantity && this.requireQuantity > 0; |
| | | } |
| | | }, |
| | | methods: { |
| | | open(row, orderNo) { |
| | | this.row = row; |
| | | this.mainOrderNo = orderNo; |
| | | this.showDetialBox = true; |
| | | this.originalQuantity = this.row.lockQuantity; |
| | | this.selectionSum = this.row.lockQuantity; |
| | | |
| | | // å è½½åå
¸æ°æ® |
| | | this.originalQuantity = 0; |
| | | this.selectionSum = 0; |
| | | this.selection = []; |
| | | |
| | | this.getDictionaryData(); |
| | | this.getData(); |
| | | |
| | | if (this.selectionSum == this.row.orderQuantity) { |
| | | this.selectionClass = "equle-style"; |
| | | } else if (this.selectionSum < this.row.orderQuantity) { |
| | | this.selectionClass = "less-style"; |
| | | } else { |
| | | this.selectionClass = "more-style"; |
| | | } |
| | | this.updateSelectionStyle(); |
| | | }, |
| | | |
| | | // è·ååå
¸æ°æ® |
| | | getDictionaryData() { |
| | | if (this.dictionaryList) { |
| | | return; |
| | |
| | | }); |
| | | }, |
| | | |
| | | // è·ååå
¸å¼ |
| | | getDictionary(row, column) { |
| | | if (this.dictionaryList) { |
| | | var item = this.dictionaryList.find((x) => x.dicNo == column.bindKey); |
| | |
| | | } else { |
| | | return row[column.prop]; |
| | | } |
| | | } else { |
| | | return row[column.prop]; |
| | | } |
| | | } |
| | | return row[column.prop]; |
| | | }, |
| | | |
| | | // æå¼ç«å°éæ©å¼¹çª |
| | | openStationDialog() { |
| | | if (this.selection.length <= 0) { |
| | | return this.$message.error("请å
å¾éè¦åºåºçåºå"); |
| | | } |
| | | |
| | | // ä»ç¼åä¸è·åé»è®¤ç«å° |
| | | const cachedStation = stationManager.getStation(); |
| | | this.stationForm.selectedPlatform = cachedStation || ""; |
| | | |
| | | this.showStationDialog = true; |
| | | }, |
| | | |
| | | // 确认åºåº |
| | | async confirmOutbound() { |
| | | if (!this.stationForm.selectedPlatform) { |
| | | return this.$message.error("è¯·éæ©åºåºç«å°"); |
| | | } |
| | | |
| | | // åå¤è¯·æ±åæ° |
| | | const requestParams = { |
| | | detailIds: [this.row.id], // åºåºåçæç»ID |
| | | outboundTargetLocation: this.stationForm.selectedPlatform, // éæ©çç«å° |
| | | outboundQuantity: this.selectionSum, // 已鿰é |
| | | operator: this.getCurrentOperator(), // è·åå½åæä½äºº |
| | | orderNo: this.mainOrderNo, // åæ®ç¼å· |
| | | stockDetailIds: this.selection.map(item => item.stockId) // åºåæç»ä¸»é®æ°ç» |
| | | detailIds: [this.row.id], |
| | | outboundTargetLocation: this.stationForm.selectedPlatform, |
| | | outboundQuantity: this.selectionSum, |
| | | operator: this.getCurrentOperator(), |
| | | orderNo: this.mainOrderNo, |
| | | stockDetailIds: this.selection.map((item) => item.stockId), |
| | | }; |
| | | |
| | | try { |
| | |
| | | requestParams, |
| | | "æ°æ®å¤çä¸" |
| | | ); |
| | | |
| | | if (!x.status) { |
| | | return this.$message.error(x.message); |
| | | } |
| | | |
| | | this.$message.success("åºåºä»»å¡å建æå"); |
| | | this.showStationDialog = false; |
| | | this.showDetialBox = false; |
| | |
| | | } |
| | | }, |
| | | |
| | | // è·åå½åæä½äºº |
| | | getCurrentOperator() { |
| | | // å¯ä»¥ä»æ¬å°åå¨ãVuexæå
¨å±ç¶æä¸è·åå½åç¨æ· |
| | | try { |
| | | // 示ä¾ï¼ä»localStorageè·åç¨æ·ä¿¡æ¯ |
| | | const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}'); |
| | | const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}"); |
| | | if (userInfo.userName) { |
| | | return userInfo.userName; |
| | | } |
| | | |
| | | // 示ä¾ï¼ä»Vuexè·åç¨æ·ä¿¡æ¯ |
| | | if (this.$store && this.$store.state.user) { |
| | | return this.$store.state.user.userName; |
| | | } |
| | | } catch (error) { |
| | | console.error('è·åæä½äººä¿¡æ¯å¤±è´¥:', error); |
| | | console.error("è·åæä½äººä¿¡æ¯å¤±è´¥:", error); |
| | | } |
| | | |
| | | // é»è®¤æä½äºº |
| | | return "admin"; |
| | | }, |
| | | |
| | |
| | | ) |
| | | .then((x) => { |
| | | this.tableData = x; |
| | | this.clearSelection(); |
| | | }); |
| | | }, |
| | | |
| | | handleSelectionChange(val) { |
| | | this.selection = val; |
| | | this.selectionSum = |
| | | val.reduce( |
| | | (accumulator, currentValue) => |
| | | accumulator + currentValue["useableQuantity"], |
| | | 0 |
| | | ) + this.originalQuantity; |
| | | if (this.selectionSum == this.row.orderQuantity) { |
| | | this.selectionClass = "equle-style"; |
| | | } else if (this.selectionSum < this.row.orderQuantity) { |
| | | this.selectionClass = "less-style"; |
| | | } else { |
| | | this.selectionClass = "more-style"; |
| | | // ç¹å»è¡å¾é - æç»ä¿®å¤ç |
| | | handleRowClick(row) { |
| | | // 夿å½åè¡æ¯å¦å·²éä¸ |
| | | const isSelected = this.selection.some(s => s.stockId === row.stockId); |
| | | |
| | | // å·²éä¸ â å
è®¸åæ¶å¾é |
| | | if (isSelected) { |
| | | this.$refs.singleTable.toggleRowSelection(row); |
| | | return; |
| | | } |
| | | |
| | | // æªéä¸ + 已满 â ç¦æ¢æ°å¢ï¼æ¥é |
| | | if (this.isFull) { |
| | | this.$message.error(`已达å°éæ±æ°é ${this.requireQuantity}ï¼æ æ³åå¾éåºåï¼`); |
| | | return; |
| | | } |
| | | |
| | | // æ£å¸¸å¾é |
| | | this.$refs.singleTable.toggleRowSelection(row); |
| | | }, |
| | | |
| | | // å¾éæ¡éæ© - æç»ä¿®å¤ç |
| | | selectRowChange(selection, row) { |
| | | if (this.isProcessingSelect) return; |
| | | |
| | | const isAdding = selection.some(x => x.stockId === row.stockId); |
| | | |
| | | // æ°å¢å¾é + 已满 â æ¦æª |
| | | if (isAdding && this.isFull) { |
| | | this.isProcessingSelect = true; |
| | | this.$message.error(`已达å°éæ±æ°é ${this.requireQuantity}ï¼æ æ³åå¾éï¼`); |
| | | this.$nextTick(() => { |
| | | this.$refs.singleTable.toggleRowSelection(row, false); |
| | | this.isProcessingSelect = false; |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | toggleSelection(rows) { |
| | | if (rows) { |
| | | rows.forEach((row) => { |
| | | this.$refs.singleTable.toggleRowSelection(row); |
| | | }); |
| | | } else { |
| | | // å
¨é - æç»ä¿®å¤ç |
| | | selectAllChange(selection) { |
| | | if (this.isProcessingSelect) return; |
| | | |
| | | const allTotal = this.tableData.reduce((sum, item) => sum + (item.useableQuantity || 0), 0); |
| | | const need = this.requireQuantity; |
| | | |
| | | if (allTotal > need && selection.length > 0) { |
| | | this.isProcessingSelect = true; |
| | | this.$message.error(`å
¨éæ°éè¶
åºéæ±ï¼å·²æ¸
ç©ºéæ©ï¼`); |
| | | |
| | | this.$refs.singleTable.clearSelection(); |
| | | this.selection = []; |
| | | this.selectionSum = 0; |
| | | this.updateSelectionStyle(); |
| | | |
| | | this.$nextTick(() => { |
| | | this.isProcessingSelect = false; |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | // éæ©è®¡ç® |
| | | handleSelectionChange(val) { |
| | | if (this.isProcessingSelect) return; |
| | | |
| | | let total = val.reduce((s, i) => s + (i.useableQuantity || 0), 0); |
| | | const need = this.requireQuantity; |
| | | |
| | | this.selectionSum = total >= need ? need : total; |
| | | this.selection = val; |
| | | this.updateSelectionStyle(); |
| | | }, |
| | | |
| | | updateSelectionStyle() { |
| | | if (this.isFull) { |
| | | this.selectionClass = "equle-style"; |
| | | } else { |
| | | this.selectionClass = "less-style"; |
| | | } |
| | | }, |
| | | |
| | | clearSelection() { |
| | | this.$refs.singleTable.clearSelection(); |
| | | }, |
| | | |
| | | handleRowClick(row) { |
| | | this.$refs.singleTable.toggleRowSelection(row); |
| | | this.selection = []; |
| | | this.selectionSum = 0; |
| | | this.updateSelectionStyle(); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .less-style { |
| | | color: black; |
| | | } |
| | | |
| | | .equle-style { |
| | | color: green; |
| | | } |
| | | |
| | | .more-style { |
| | | color: red; |
| | | } |
| | | |
| | | /* ç«å°éæ©å¼¹çªæ ·å¼ */ |
| | | .station-dialog-content { |
| | | padding: 10px 0; |
| | | } |
| | | |
| | | .dialog-footer { |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | gap: 10px; |
| | | } |
| | | |
| | | .text-button:hover { |
| | | background-color: #f0f9eb !important; |
| | | } |
| | | |
| | | .el-table .warning-row { |
| | | background: oldlace; |
| | | } |
| | | |
| | | .box-table .el-table tbody tr:hover > td { |
| | | background-color: #d8e0d4 !important; |
| | | } |
| | | |
| | | .box-table .el-table tbody tr.current-row > td { |
| | | background-color: #f0f9eb !important; |
| | | } |
| | | |
| | | .el-table .success-row { |
| | | background: #f0f9eb; |
| | | } |
| | | |
| | | .box-table .el-table { |
| | | border: 1px solid #ebeef5; |
| | | } |
| | | |
| | | .box-head .el-alert__content { |
| | | width: 100%; |
| | | } |
| | | .less-style { color: black; } |
| | | .equle-style { color: green; } |
| | | .more-style { color: red; } |
| | | .station-dialog-content { padding: 10px 0; } |
| | | .dialog-footer { display: flex; justify-content: flex-end; gap: 10px; } |
| | | .text-button:hover { background-color: #f0f9eb !important; } |
| | | .el-table .warning-row { background: oldlace; } |
| | | .box-table .el-table tbody tr:hover > td { background-color: #d8e0d4 !important; } |
| | | .box-table .el-table tbody tr.current-row > td { background-color: #f0f9eb !important; } |
| | | .el-table .success-row { background: #f0f9eb; } |
| | | .box-table .el-table { border: 1px solid #ebeef5; } |
| | | .box-head .el-alert__content { width: 100%; } |
| | | </style> |