| | |
| | | buttons: { view: [], box: [], detail: [] }, // æ©å±æé® |
| | | methods: { |
| | | onInit() { |
| | | // åæçç¹æé®é»è¾ä¿ç |
| | | let OrderStockTakeBtn = this.buttons.find(x => x.value === 'OrderStockTake'); |
| | | if (OrderStockTakeBtn) { |
| | | OrderStockTakeBtn.onClick = function () { |
| | | let rows = this.$refs.table.getSelected(); |
| | | if (rows.length === 0) return this.$error("è¯·éæ©ä¸æ¡çç¹åæ®æ°æ®ï¼"); |
| | | if (rows.length > 1) return this.$error("åªè½éæ©ä¸æ¡çç¹åæ®æ°æ®ï¼"); |
| | | |
| | | const selectedReceiptNo = rows[0].orderNo; |
| | | if (!selectedReceiptNo) return this.$error("éä¸çåæ®ç¼ºå°ææçåæ®å·ï¼"); |
| | | this.$refs.gridBody.open(selectedReceiptNo); |
| | | }; |
| | | } |
| | | |
| | | // çå¬åæå¼¹çªäºä»¶ï¼ä¿çï¼ |
| | | this.$nextTick(() => { |
| | |
| | | }); |
| | | |
| | | // ========== æ°å¢æä½åï¼äººå·¥å¹³è´¦ + ææ¶æå平账 ========== |
| | | this.columns.push({ |
| | | field: 'operation', |
| | | title: 'æä½', |
| | | width: 200, |
| | | fixed: 'right', |
| | | align: 'center', |
| | | formatter: (row) => { |
| | | return ` |
| | | <span style="cursor: pointer;color: #2d8cf0;margin-right: 10px;" class="manual-reconciliation"> |
| | | <i class="el-icon-check"></i>人工平账 |
| | | </span> |
| | | <span style="cursor: pointer;color: #1989fa;" class="misc-reconciliation"> |
| | | <i class="el-icon-edit"></i>ææ¶æå平账 |
| | | </span> |
| | | `; |
| | | }, |
| | | click: (row, column, event) => { |
| | | const target = event.target; |
| | | // åºåç¹å»çæ¯äººå·¥å¹³è´¦è¿æ¯ææ¶æå平账 |
| | | if (target.closest('.manual-reconciliation')) { |
| | | this.handleManualReconciliation(row); // 人工平账é»è¾ |
| | | } else if (target.closest('.misc-reconciliation')) { |
| | | this.handleMiscReconciliation(row); // ææ¶æå平账é»è¾ |
| | | } |
| | | } |
| | | }); |
| | | |
| | | }, |
| | | |
| | | // ========== äººå·¥å¹³è´¦æ ¸å¿é»è¾ ========== |
| | | handleManualReconciliation(row) { |
| | | // å¼¹åºç¡®è®¤æ¡ |
| | | ElMessageBox.confirm( |
| | | 'ç¡®è®¤è¦æ§è¡äººå·¥å¹³è´¦æä½åï¼', |
| | | 'æä½ç¡®è®¤', |
| | | { |
| | | confirmButtonText: '确认', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | } |
| | | ).then(async () => { |
| | | // æ·»å é®ç½©å±é²æ¢éå¤ç¹å» |
| | | const loading = ElLoading.service({ |
| | | lock: true, |
| | | text: 'å¤çä¸ï¼è¯·ç¨å...', |
| | | background: 'rgba(0, 0, 0, 0.7)' |
| | | }); |
| | | |
| | | try { |
| | | // è°ç¨äººå·¥å¹³è´¦æ¥å£ |
| | | const response = await this.http.get(`/api/TakeStockOrder/ManualReconciliation?id=${row.id}`); |
| | | if (response.status) { |
| | | ElMessage.success('人工平账æä½æåï¼'); |
| | | this.$refs.table.reload(); // å·æ°è¡¨æ ¼ |
| | | } else { |
| | | ElMessage.error(`æä½å¤±è´¥ï¼${response.message || 'æªç¥é误'}`); |
| | | } |
| | | } catch (error) { |
| | | } finally { |
| | | // å
³éé®ç½©å± |
| | | loading.close(); |
| | | } |
| | | }).catch(() => { |
| | | ElMessage.info('å·²åæ¶äººå·¥å¹³è´¦æä½'); |
| | | }); |
| | | }, |
| | | |
| | | // ========== ææ¶æåå¹³è´¦æ ¸å¿é»è¾ï¼ä¿®æ¹åï¼ ========== |
| | | handleMiscReconciliation(row) { |
| | | // éä¸å½åè¡ |
| | | const table = this.$refs.table.$refs.table; |
| | | if (table) { |
| | | table.clearSelection(); |
| | | table.toggleRowSelection(row, true); |
| | | } |
| | | |
| | | // è°ç¨æ¥å£è·åææ¶æåå¹³è´¦æ°æ® |
| | | const fetchMiscData = async () => { |
| | | const loading = ElLoading.service({ |
| | | lock: true, |
| | | text: 'å è½½æ°æ®ä¸...', |
| | | background: 'rgba(0, 0, 0, 0.7)' |
| | | }); |
| | | |
| | | try { |
| | | // è°ç¨æ¥å£ï¼ä¼ érowä¸çremarkåidåæ° |
| | | const response = await this.http.get(`/api/TakeStockOrder/SelectOrder?remark=${row.remark || ''}&id=${row.id}`); |
| | | loading.close(); |
| | | |
| | | if (response.status) { |
| | | if (!Array.isArray(response.data) || response.data.length === 0) { |
| | | ElMessage.warning("æªæ¥è¯¢å°ç¸å
³æ°æ®"); |
| | | // æå¼ç©ºæ°æ®çå¼¹çª |
| | | this.$refs.gridHeader.open(row, []); |
| | | return; |
| | | } |
| | | |
| | | // æåéè¦å±ç¤ºçåæ®µ |
| | | const displayData = response.data.map(item => ({ |
| | | orderId: item.orderId || '', |
| | | materielCode: item.materielCode || '', |
| | | materielName: item.materielName || '', |
| | | batchNo: item.batchNo || '', |
| | | orderQuantity: item.orderQuantity || 0, |
| | | unit: item.unit || '', |
| | | supplyCode: item.supplyCode || '', |
| | | warehouseCode: item.warehouseCode || '' |
| | | })); |
| | | |
| | | // æå¼å¼¹çªå¹¶ä¼ éå¤çåçæ°æ® |
| | | this.$refs.gridHeader.open(row, displayData); |
| | | } else { |
| | | ElMessage.error(`æ¥è¯¢å¤±è´¥ï¼${response.message || 'æªç¥é误'}`); |
| | | } |
| | | } catch (error) { |
| | | loading.close(); |
| | | ElMessage.error(`ç½ç»å¼å¸¸ï¼${error.message || 'æ¥å£è°ç¨å¤±è´¥'}`); |
| | | } |
| | | }; |
| | | |
| | | // æ§è¡æ°æ®æ¥è¯¢å¹¶æå¼å¼¹çª |
| | | fetchMiscData(); |
| | | }, |
| | | |
| | | |
| | | onInited() { |
| | | // æ¡æ¶åå§åå®æåæ§è¡ |