diff --git a/src/api/npcIqc/npcIqc.js b/src/api/npcIqc/npcIqc.js index 027b556..27d31e4 100644 --- a/src/api/npcIqc/npcIqc.js +++ b/src/api/npcIqc/npcIqc.js @@ -14,6 +14,15 @@ export const getAvailablePoList = (data) => createAPI(`/srm/logistics/getAvailab // 新增物流:将选中的PO订单绑定到指定物流单号(更新 c_flexid) export const updateLogisticsPo = (data) => createAPI(`/srm/logistics/updateLogisticsPo`, 'post', data) +// 移除:将选中订单的 c_flexid 置空、Telex 重置为 No +export const removeLogisticsPo = (data) => createAPI(`/srm/logistics/removeLogisticsPo`, 'post', data) + +// 编辑:将物流单号下所有PO的 Telex_Release 批量更新 +export const updateTelexRelease = (data) => createAPI(`/srm/logistics/updateTelexRelease`, 'post', data) + +// 编辑:修改物流单号(旧单号整组迁移到新单号) +export const changeLogisticsFlexId = (data) => createAPI(`/srm/logistics/changeLogisticsFlexId`, 'post', data) + // 下载导入模板 export const downloadTemplate = () => { return createAPI('/npcIqc/downloadTemplate', 'post', {}, { responseType: 'blob' }) diff --git a/src/views/modules/npcIqc/logisticsManagement.vue b/src/views/modules/npcIqc/logisticsManagement.vue index 0af6f59..82b24c9 100644 --- a/src/views/modules/npcIqc/logisticsManagement.vue +++ b/src/views/modules/npcIqc/logisticsManagement.vue @@ -3,7 +3,7 @@
- + @@ -32,7 +32,7 @@ style="margin-top: 0px; width: 100%;"> + + + @@ -129,22 +139,35 @@ @getBaseData="getBaseData"> - - + + - - + + + + - 供应商编码 - + + - + + + + + +
- 新增 + 增加
+ + + - 关闭 + 保存 + 关闭 + +
+ + + + + + + + + + + + + 确认 + 取消 + + + + + + + + + + + + + + 查询 + + import LogisticsAttachmentTab from './com_logisticsAttachmentTab.vue' -import { searchLogistics, getPoList, getAvailablePoList, updateLogisticsPo } from '@/api/npcIqc/npcIqc.js' +import ComPoOrderCustomerPicker from '@/views/modules/order/com_poOrder_CustomerPicker.vue' +import { searchLogistics, getPoList, getAvailablePoList, updateLogisticsPo, removeLogisticsPo, updateTelexRelease, changeLogisticsFlexId } from '@/api/npcIqc/npcIqc.js' import Chooselist from '@/views/modules/common/Chooselist_eam' import excel from '@/utils/excel-util.js' export default { components: { LogisticsAttachmentTab, + ComPoOrderCustomerPicker, Chooselist }, data () { @@ -246,22 +309,55 @@ export default { targetField: '', // 供应商选择回调目标:'search' 主查询 | 'add' 新增弹窗 supplierChooseTarget: 'search', + // 新增/编辑物流弹窗模式:'add' 新增 | 'edit' 编辑 + dialogMode: 'add', // 新增物流相关 addDialogVisible: false, addForm: { flexId: '', supplierNo: '', - supplierName: '' + supplierName: '', + customer: '' }, addPoList: [], addPoLoading: false, // 新增物流弹窗内表格高度(填满弹窗固定高度的剩余空间) addPoTableHeight: 430, + // 编辑界面 Telex_Release 下拉(库内存 Yes/No 全拼) + telexRelease: 'No', + yesNoTextOptions: [ + { label: 'Yes', value: 'Yes' }, + { label: 'No', value: 'No' } + ], + // 编辑界面本次暂存(未保存)的新增/移除订单号,点"保存"才写库 + pendingAddOrderNos: [], + pendingRemoveOrderNos: [], + // 编辑界面 Telex 是否被用户改动(未改动则保存时不写库,避免默认值误重置) + telexDirty: false, + // 编辑界面物流单号暂存:originalFlexId=进入时数据库值,flexIdDirty=是否已改动(点保存才写库) + originalFlexId: '', + flexIdDirty: false, + editSaving: false, + // 修改物流单号弹窗 + changeFlexIdDialogVisible: false, + newFlexIdInput: '', // 选择PO弹窗相关 availableDialogVisible: false, availablePoList: [], availableLoading: false, - availableSelection: [] + availableSelection: [], + // 选择PO弹窗筛选条件(PO/Item/Method) + availableSearch: { + po: '', + item: '', + method: '' + }, + // Method 下拉选项(与 poOrder 运输方式口径一致) + methodOptions: [ + { label: '海运 SEA', value: 'SEA' }, + { label: '空运 AIR', value: 'AIR' }, + { label: '陆运 ROAD', value: 'ROAD' } + ] } }, mounted () { @@ -385,9 +481,39 @@ export default { // 打开新增物流弹窗 openAddDialog () { - this.addForm = { flexId: '', supplierNo: '', supplierName: '' } + this.dialogMode = 'add' + this.addForm = { flexId: '', supplierNo: '', supplierName: '', customer: '' } + this.addPoList = [] + this.telexRelease = 'No' + this.availableSearch = { po: '', item: '', method: '' } + this.addDialogVisible = true + }, + + // 打开编辑物流弹窗(从主表行进入,字段锁定) + openEditDialog (row) { + if (!row || !row.flexId) { + this.$message.warning('该行无物流单号,无法编辑') + return + } + this.dialogMode = 'edit' + this.addForm = { + flexId: row.flexId, + supplierNo: row.supplierNo || '', + supplierName: row.supplierName || '', + customer: '' + } this.addPoList = [] + this.telexRelease = 'No' + this.telexDirty = false + this.pendingAddOrderNos = [] + this.pendingRemoveOrderNos = [] + this.originalFlexId = row.flexId + this.flexIdDirty = false + this.editSaving = false + this.availableSearch = { po: '', item: '', method: '' } this.addDialogVisible = true + // 打开即加载该物流单号+供应商下已关联的PO + this.loadAddPoList() }, // 供应商编码选择(新增弹窗专用,复用 Chooselist) @@ -424,6 +550,10 @@ export default { } else { this.addPoList = [] } + // 编辑界面:Customer 从已关联的PO锁定带出(不可编辑) + if (this.dialogMode === 'edit') { + this.addForm.customer = (this.addPoList[0] && this.addPoList[0].ccustomer) || '' + } this.addPoLoading = false }).catch(() => { this.addPoList = [] @@ -433,8 +563,12 @@ export default { // 打开选择PO弹窗 openAvailableDialog () { + if (!this.addForm.customer) { + this.$message.warning('请先选择Customer') + return + } if (!this.addForm.flexId || !this.addForm.supplierNo) { - this.$message.warning('请先填写物流单号和供应商编码') + this.$message.warning('请先填写LOGISTICS ID和供应商编码') return } this.availableSelection = [] @@ -448,7 +582,11 @@ export default { const params = { flexId: this.addForm.flexId, supplierNo: this.addForm.supplierNo, + customer: this.addForm.customer || '', site: this.$store.state.user.site, + po: this.availableSearch.po || '', + item: this.availableSearch.item || '', + method: this.availableSearch.method || '', page: 1, limit: 1000 } @@ -465,17 +603,40 @@ export default { }) }, + // 选择PO弹窗查询(PO/Item/Method) + searchAvailablePo () { + this.loadAvailablePoList() + }, + // 选择PO多选变化 handleAvailableSelectionChange (val) { this.availableSelection = val }, - // 保存选中的PO:更新其 c_flexid 并刷新第一个弹窗 + // 保存选中的PO:新增模式立即写库;编辑模式仅前端暂存(点底部"保存"才写库) saveAvailablePo () { if (!this.availableSelection.length) { this.$message.warning('请至少选择一条PO') return } + if (this.dialogMode === 'edit') { + // 编辑模式:只改前端 addPoList,不碰数据库 + this.availableSelection.forEach(row => { + if (!this.addPoList.some(exist => exist.orderNo === row.orderNo)) { + this.addPoList.push(row) + } + // 若之前暂存过移除,则抵消 + const rmIdx = this.pendingRemoveOrderNos.indexOf(row.orderNo) + if (rmIdx !== -1) this.pendingRemoveOrderNos.splice(rmIdx, 1) + // 记录待新增 + if (this.pendingAddOrderNos.indexOf(row.orderNo) === -1) { + this.pendingAddOrderNos.push(row.orderNo) + } + }) + this.availableDialogVisible = false + this.$message.success('已添加,点击底部"保存"后生效') + return + } const params = { flexId: this.addForm.flexId, supplierNo: this.addForm.supplierNo, @@ -497,6 +658,142 @@ export default { }) }, + // 移除:将该PO订单的 c_flexid 置空、Telex 重置为 No(按 order_no 整单) + handleRemovePo (row) { + if (!this.addForm.flexId) { + this.$message.warning('请先填写LOGISTICS ID') + return + } + this.$confirm(`确认将订单 ${row.orderRef1 || row.orderNo} 从该物流单号移除?移除后其 Telex_Release 将重置为 No。`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + if (this.dialogMode === 'edit') { + // 编辑模式:只改前端,不碰数据库 + const idx = this.addPoList.findIndex(r => r.orderNo === row.orderNo) + if (idx !== -1) this.addPoList.splice(idx, 1) + const addIdx = this.pendingAddOrderNos.indexOf(row.orderNo) + if (addIdx !== -1) { + // 本次暂存新增又移除 → 直接抵消,不需写库 + this.pendingAddOrderNos.splice(addIdx, 1) + } else if (this.pendingRemoveOrderNos.indexOf(row.orderNo) === -1) { + // 数据库已有的 → 记录为待移除 + this.pendingRemoveOrderNos.push(row.orderNo) + } + this.$message.success('已移除,点击底部"保存"后生效') + return + } + const params = { + site: this.$store.state.user.site, + flexId: this.addForm.flexId, + supplierNo: this.addForm.supplierNo, + orderNoList: [row.orderNo] + } + removeLogisticsPo(params).then(({ data }) => { + if (data.code === 0) { + this.$message.success('移除成功') + this.loadAddPoList() + this.getMainData() + } else { + this.$message.error(data.msg || '移除失败') + } + }).catch(() => { + this.$message.error('移除失败') + }) + }).catch(() => {}) + }, + + // 编辑界面:点击底部"保存"才一次性提交本次所有暂存改动(移除→改单号→新增→Telex) + saveEditAll () { + if (!this.addForm.flexId) { + this.$message.warning('缺少物流单号') + return + } + const site = this.$store.state.user.site + const supplierNo = this.addForm.supplierNo + const oldFlexId = this.originalFlexId // 数据库当前值 + const newFlexId = this.addForm.flexId // 可能已暂存修改 + const flexIdChanged = this.flexIdDirty && newFlexId !== oldFlexId + const removeList = this.pendingRemoveOrderNos.slice() + const addList = this.pendingAddOrderNos.slice() + const commitTelex = this.telexDirty + if (!removeList.length && !addList.length && !commitTelex && !flexIdChanged) { + // 无任何改动:直接关闭弹窗(不写库),避免点了“没反应” + this.addDialogVisible = false + return + } + this.editSaving = true + let chain = Promise.resolve() + // 1. 移除:仍按数据库原物流单号(oldFlexId)解除(此时尚未迁移) + if (removeList.length) { + chain = chain.then(() => removeLogisticsPo({ site, flexId: oldFlexId, supplierNo, orderNoList: removeList }).then(({ data }) => { + if (data.code !== 0) throw new Error(data.msg || '移除失败') + })) + } + // 2. 物流单号变更:整组 old→new + if (flexIdChanged) { + chain = chain.then(() => changeLogisticsFlexId({ site, flexId: oldFlexId, supplierNo, newFlexId }).then(({ data }) => { + if (data.code !== 0) throw new Error(data.msg || '物流单号修改失败') + })) + } + // 3. 新增:绑定到最终物流单号(newFlexId) + if (addList.length) { + chain = chain.then(() => updateLogisticsPo({ site, flexId: newFlexId, supplierNo, orderNoList: addList }).then(({ data }) => { + if (data.code !== 0) throw new Error(data.msg || '绑定失败') + })) + } + // 4. Telex:按最终物流单号批量刷新 + if (commitTelex) { + chain = chain.then(() => updateTelexRelease({ site, flexId: newFlexId, supplierNo, telexRelease: this.telexRelease }).then(({ data }) => { + if (data.code !== 0) throw new Error(data.msg || 'Telex_Release 保存失败') + })) + } + chain.then(() => { + this.$message.success('保存成功') + this.pendingAddOrderNos = [] + this.pendingRemoveOrderNos = [] + this.telexDirty = false + this.flexIdDirty = false + this.originalFlexId = newFlexId + this.addDialogVisible = false + this.getMainData() + }).catch(err => { + this.$message.error((err && err.message) || '保存失败') + // 部分提交可能已生效,回退前端显示为库中实际值,避免新旧单号不一致 + this.addForm.flexId = this.originalFlexId + this.flexIdDirty = false + this.loadAddPoList() + this.getMainData() + }).finally(() => { + this.editSaving = false + }) + }, + + // 打开修改物流单号弹窗 + openChangeFlexIdDialog () { + this.newFlexIdInput = this.addForm.flexId + this.changeFlexIdDialogVisible = true + }, + + // 确认修改物流单号:编辑界面仅前端暂存,点底部"保存"才写库 + confirmChangeFlexId () { + const newVal = (this.newFlexIdInput || '').trim() + if (!newVal) { + this.$message.warning('新物流单号不能为空') + return + } + if (newVal === this.addForm.flexId) { + this.changeFlexIdDialogVisible = false + return + } + // 只改前端显示值(锁定输入框会跟着变),标记待改,不动数据库 + this.addForm.flexId = newVal + this.flexIdDirty = true + this.changeFlexIdDialogVisible = false + this.$message.success('已修改,点击底部"保存"后生效') + }, + // 加载PO清单 loadPoList () { if (!this.currentRow.flexId) { @@ -653,7 +950,7 @@ export default { // 定义导出列配置 const columnMapping = [ - { columnProp: 'flexId', columnLabel: '进仓编号' }, + { columnProp: 'flexId', columnLabel: 'LOGISTICS ID' }, { columnProp: 'supplierNo', columnLabel: '供应商编码' }, { columnProp: 'supplierName', columnLabel: '供应商名称' }, { columnProp: 'poCount', columnLabel: 'PO数量' }, diff --git a/src/views/modules/order/poOrder.vue b/src/views/modules/order/poOrder.vue index 6b37776..fa7ea9b 100644 --- a/src/views/modules/order/poOrder.vue +++ b/src/views/modules/order/poOrder.vue @@ -33,7 +33,7 @@ {{ editMode ? '确定' : '编辑' }} 取消 - 同步运输周期 + 同步运输周期 新增 查看价格表 拆单到新PO @@ -50,7 +50,7 @@ @current-change="onTableCurrentChange" @selection-change="onSyncSelectionChange"> @@ -581,6 +581,80 @@
+ + +
+ 可修改勾选行的始发港、目的港和运输方式,确认后按新值同步运输周期并连带重算相关日期 +
+ + + + + + + + + + + + + + + + +
+ ({ + rowKey: `${r.orderNo || ''}_${r.itemNo || ''}_${idx}`, + site: r.site, + orderNo: r.orderNo, + itemNo: r.itemNo, + item: r.item, + customer: r.customer, + departure: r.departure, + destination: r.destination, + shipVia: r.shipVia, + wantReceiveDate: r.wantReceiveDate, + narrival: r.narrival + })) + this.syncTransitCycleDialogVisible = true + }, + + /** 弹窗内确认同步:逐项校验后按行传当前值,后端逐行取 ori_transit_cycle 并连带重算日期 */ + confirmSyncTransitCycle () { + if (this.syncTransitCycleSaving) { + return + } + const rows = this.syncDialogRows || [] + if (!rows.length) { + this.$message.warning('没有可同步的行') + return + } + const invalid = rows.find(r => !r.departure || !r.destination || !r.shipVia) + if (invalid) { + this.$message.warning(`行 ${invalid.orderNo || ''}-${invalid.itemNo || ''} 的始发港、目的港和运输方式不能为空`) + return + } const payload = rows.map(r => ({ site: r.site, orderNo: r.orderNo, @@ -4203,6 +4336,7 @@ export default { cancelButtonText: '取消', type: 'warning' }).then(() => { + this.syncTransitCycleSaving = true syncOriTransitCycle(payload).then(({ data }) => { if (data && data.code === 0) { const d = data.data || {} @@ -4211,13 +4345,19 @@ export default { if (s.unmatchedCount) msg += `,其中 ${s.unmatchedCount} 条未匹配到周期` if (s.skipCount) msg += `,跳过 ${s.skipCount} 条` this.$message.success(msg) + this.syncTransitCycleDialogVisible = false this.syncSelection = [] + if (this.$refs.poTable && this.$refs.poTable.clearSelection) { + this.$refs.poTable.clearSelection() + } this.getDataList() } else { this.$message.error((data && data.msg) || '同步失败') } }).catch(error => { this.$message.error('同步失败: ' + error.message) + }).finally(() => { + this.syncTransitCycleSaving = false }) }).catch(() => {}) }, diff --git a/src/views/modules/order/poOrderAdvancedQueryConfig.js b/src/views/modules/order/poOrderAdvancedQueryConfig.js index 0bac1c6..96e78c3 100644 --- a/src/views/modules/order/poOrderAdvancedQueryConfig.js +++ b/src/views/modules/order/poOrderAdvancedQueryConfig.js @@ -76,6 +76,7 @@ export const PO_ADVANCED_QUERY_FIELD_CONFIG = [ { sortOrder: 25, field: 'narrival', label: 'Final Confirmed Arrival Date', sqlColumn: 'pod.c_narrival', dataType: 'date' }, { sortOrder: 26, field: 'crd', label: 'PI Confirmed CRD', sqlColumn: 'pod.c_crd', dataType: 'date' }, { sortOrder: 27, field: 'crdOri', label: 'Original CRD', sqlColumn: 'pod.c_crd_ori', dataType: 'date' }, + { sortOrder: 27, field: 'originalTt', label: 'Original TT', sqlColumn: 'pod.original_tt', dataType: 'number' }, { sortOrder: 27, field: 'inspection', label: 'Inspection Date', sqlColumn: 'pod.c_inspection', dataType: 'date' }, { sortOrder: 28, field: 'realCrd', label: 'Actual Completion Date', sqlColumn: 'pod.c_real_crd', dataType: 'date' }, { sortOrder: 29, field: 'eta', label: 'ETA', sqlColumn: 'pod.c_eta', dataType: 'date' },