15 changed files with 6803 additions and 6702 deletions
-
6739src/views/modules/sampleTracking/projectProofTracking.vue
-
469src/views/modules/sampleTracking/projectProofTracking/constants.js
-
38src/views/modules/sampleTracking/projectProofTracking/directives.js
-
511src/views/modules/sampleTracking/projectProofTracking/mixins/costComments.js
-
180src/views/modules/sampleTracking/projectProofTracking/mixins/npiSync.js
-
1065src/views/modules/sampleTracking/projectProofTracking/mixins/oneKeyDialog.js
-
688src/views/modules/sampleTracking/projectProofTracking/mixins/processColumns.js
-
912src/views/modules/sampleTracking/projectProofTracking/mixins/processConfigDialogs.js
-
407src/views/modules/sampleTracking/projectProofTracking/mixins/processEdit.js
-
373src/views/modules/sampleTracking/projectProofTracking/mixins/processStatus.js
-
233src/views/modules/sampleTracking/projectProofTracking/mixins/proofDialog.js
-
236src/views/modules/sampleTracking/projectProofTracking/mixins/roleCustomer.js
-
301src/views/modules/sampleTracking/projectProofTracking/mixins/trackingColumns.js
-
594src/views/modules/sampleTracking/projectProofTracking/mixins/trackingList.js
-
759src/views/modules/sampleTracking/projectProofTracking/projectProofTracking.css
6739
src/views/modules/sampleTracking/projectProofTracking.vue
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,469 @@ |
|||
// 打样跟踪页常量:默认工序列、默认列表列、成本列、一键创建角色字段等。
|
|||
export const DEFAULT_PROCESS_COLUMNS = [ |
|||
{ label: 'Raw Material', code: 'rawMaterial', planField: 'rawMaterialPlanDate', actualField: 'rawMaterialActualDate', statusField: 'rawMaterialStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Cylinder/Cutter', code: 'cylinderCutter', planField: 'cylinderCutterPlanDate', actualField: 'cylinderCutterActualDate', statusField: 'cylinderCutterStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Lamination', code: 'lamination', planField: 'laminationPlanDate', actualField: 'laminationActualDate', statusField: 'laminationStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Printing', code: 'printing', planField: 'printingPlanDate', actualField: 'printingActualDate', statusField: 'printingStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Etching', code: 'etching', planField: 'etchingPlanDate', actualField: 'etchingActualDate', statusField: 'etchingStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Slitting&Packing', code: 'slittingPacking', planField: 'slittingPackingPlanDate', actualField: 'slittingPackingActualDate', statusField: 'slittingPackingStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Bonding', code: 'bonding', planField: 'bondingPlanDate', actualField: 'bondingActualDate', statusField: 'bondingStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'CL60/CL822', code: 'cl60Cl822', planField: 'cl60Cl822PlanDate', actualField: 'cl60Cl822ActualDate', statusField: 'cl60Cl822Status', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Spotting', code: 'spotting', planField: 'spottingPlanDate', actualField: 'spottingActualDate', statusField: 'spottingStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Encoding', code: 'encoding', planField: 'encodingPlanDate', actualField: 'encodingActualDate', statusField: 'encodingStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Die cut', code: 'dieCut', planField: 'dieCutPlanDate', actualField: 'dieCutActualDate', statusField: 'dieCutStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Inspection', code: 'inspection', planField: 'inspectionPlanDate', actualField: 'inspectionActualDate', statusField: 'inspectionStatus', processCategoryCode: '', processCategoryName: '' }, |
|||
{ label: 'Delivery&Package', code: 'deliveryPackage', planField: 'deliveryPackagePlanDate', actualField: 'deliveryPackageActualDate', statusField: 'deliveryPackageStatus', processCategoryCode: '', processCategoryName: '' } |
|||
] |
|||
|
|||
export function cloneDefaultProcessColumns () { |
|||
return DEFAULT_PROCESS_COLUMNS.map(item => Object.assign({}, item)) |
|||
} |
|||
|
|||
export function buildProcessCodeLabelMapByRows (rows) { |
|||
const nextMap = {} |
|||
if (!Array.isArray(rows)) { |
|||
return nextMap |
|||
} |
|||
rows.forEach(item => { |
|||
if (!item) { |
|||
return |
|||
} |
|||
const code = item.code == null ? '' : String(item.code).trim() |
|||
const label = item.label == null ? '' : String(item.label).trim() |
|||
if (!code || !label) { |
|||
return |
|||
} |
|||
// 同时缓存原始编码与小写编码,兼容历史配置大小写不一致的场景。
|
|||
nextMap[code] = label |
|||
nextMap[code.toLowerCase()] = label |
|||
}) |
|||
return nextMap |
|||
} |
|||
|
|||
export const ONE_KEY_ROLE_FIELDS = [ |
|||
'projectManager', |
|||
'projectOwner', |
|||
'engineer', |
|||
'cManufactureEngineer', |
|||
'cQualityEngineer1', |
|||
'cQualityEngineer2', |
|||
'cQualityEngineer3', |
|||
'cQualityEngineer4', |
|||
'cQualityEngineer5', |
|||
'cQualityEngineer6', |
|||
'cQualityEngineer7', |
|||
'ipqcHardTag', |
|||
'docEngineer', |
|||
'docEngineer2' |
|||
] |
|||
|
|||
export const COST_MANUAL_COLUMNS = ['customizedForMasAls', 'tpKctUsd', 'toolingCostCn', 'sampleCostFromFnCn'] |
|||
export const COST_CALCULATED_COLUMNS = ['sampleCostUsd', 'toolingCostUsd', 'sampleAndToolingCostUsd', 'sampleCostFromFnUsd'] |
|||
export const CUSTOMIZED_FOR_MAS_ALS_OPTIONS = [ |
|||
'PM-standard', |
|||
'PM-Customized for ALS', |
|||
'PM-Customized for MAS', |
|||
'PO' |
|||
] |
|||
|
|||
export const DEFAULT_TRACKING_COLUMNS = [ |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ProjectNo', |
|||
columnProp: 'projectNo', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: '项目编码', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ProjectDesc', |
|||
columnProp: 'projectDesc', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: '项目描述', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 120, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1TestPartNo', |
|||
columnProp: 'testPartNo', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: '项目物料', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1PartDesc', |
|||
columnProp: 'partDesc', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: '物料描述', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: 'left', |
|||
columnWidth: 150, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1DryWetType', |
|||
columnProp: 'dryWetType', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: '分类', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 70, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ProjectRegion', |
|||
columnProp: 'cProjectRegion', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: '区域', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1CustomerDesc', |
|||
columnProp: 'customerDesc', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: '客户名称', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 130, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1Engineer', |
|||
columnProp: 'engineer', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: 'Engineer', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 120, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ProjectManager', |
|||
columnProp: 'projectManager', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: 'PM/Sales', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 120, |
|||
showOverflowTooltip: true |
|||
}, |
|||
// 紧跟 PM/Sales:下拉可选,也允许手工录入文本。
|
|||
{ |
|||
serialNumber: 'proofTrackingTable1CustomizedForMasAls', |
|||
columnProp: 'customizedForMasAls', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: 'Customized for MAS/ALS', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 180, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ProofingNo', |
|||
columnProp: 'proofingNo', |
|||
headerAlign: 'center', |
|||
align: 'left', |
|||
columnLabel: '打样单号', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: true |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ProofingStatus', |
|||
columnProp: 'proofingStatus', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: '打样状态', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 80, |
|||
showOverflowTooltip: false |
|||
}, |
|||
// Sample Qty / Year / Month / LT 为计算列;仅 PM inquery time 落库。
|
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleQty', |
|||
columnProp: 'sampleQty', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample Qty', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: false |
|||
}, |
|||
// 成本列紧跟 Sample Qty:单价、模具费、样品费都按数量折算,和数量放在一起看。
|
|||
{ |
|||
serialNumber: 'proofTrackingTable1TpKctUsd', |
|||
columnProp: 'tpKctUsd', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'TP(KCT/USD)', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 120, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleCostUsd', |
|||
columnProp: 'sampleCostUsd', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample Cost/USD', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 140, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ToolingCostCn', |
|||
columnProp: 'toolingCostCn', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Tooling cost/CN', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 140, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1ToolingCostUsd', |
|||
columnProp: 'toolingCostUsd', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Tooling Cost/USD', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 150, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleAndToolingCostUsd', |
|||
columnProp: 'sampleAndToolingCostUsd', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample and Tooling Cost/USD', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 210, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleCostFromFnCn', |
|||
columnProp: 'sampleCostFromFnCn', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample Cost from FN/CN', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 180, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleCostFromFnUsd', |
|||
columnProp: 'sampleCostFromFnUsd', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample Cost from FN/USD', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 190, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1PmInqueryTime', |
|||
columnProp: 'pmInqueryTime', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'PM inquery time', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 120, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleMakingYear', |
|||
columnProp: 'sampleMakingYear', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample making Year', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleMakingMonth', |
|||
columnProp: 'sampleMakingMonth', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample making Month', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleLt', |
|||
columnProp: 'sampleLt', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample LT', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 90, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1SampleLtInquery', |
|||
columnProp: 'sampleLtInquery', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Sample LT(Inquery)', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 140, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1Baseline', |
|||
columnProp: 'baseline', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Baseline', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 100, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1DeliveryVariance', |
|||
columnProp: 'deliveryVariance', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Delivery Variance', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 110, |
|||
showOverflowTooltip: false |
|||
}, |
|||
{ |
|||
serialNumber: 'proofTrackingTable1TrackingStatus', |
|||
columnProp: 'trackingStatus', |
|||
headerAlign: 'center', |
|||
align: 'center', |
|||
columnLabel: 'Tracking Status', |
|||
columnHidden: false, |
|||
columnImage: false, |
|||
columnSortable: false, |
|||
status: true, |
|||
fixed: '', |
|||
columnWidth: 150, |
|||
showOverflowTooltip: true |
|||
} |
|||
] |
|||
|
|||
export function cloneDefaultTrackingColumns () { |
|||
return DEFAULT_TRACKING_COLUMNS.map(item => Object.assign({}, item)) |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
// 打样跟踪页局部指令:Comments 进入编辑态时自动聚焦并把光标移到末尾。
|
|||
|
|||
function focusCommentsNativeInput (el, vnode) { |
|||
const doFocus = () => { |
|||
const componentInput = vnode && vnode.componentInstance && vnode.componentInstance.$refs |
|||
? vnode.componentInstance.$refs.input |
|||
: null |
|||
const inputEl = componentInput || (el && el.querySelector ? el.querySelector('input') : null) |
|||
if (!inputEl || typeof inputEl.focus !== 'function') { |
|||
return false |
|||
} |
|||
inputEl.focus() |
|||
const textLength = inputEl.value ? String(inputEl.value).length : 0 |
|||
if (typeof inputEl.setSelectionRange === 'function') { |
|||
inputEl.setSelectionRange(textLength, textLength) |
|||
} |
|||
return true |
|||
} |
|||
if (doFocus()) { |
|||
return |
|||
} |
|||
setTimeout(doFocus, 0) |
|||
setTimeout(doFocus, 50) |
|||
setTimeout(doFocus, 100) |
|||
} |
|||
|
|||
export const focusCommentsInput = { |
|||
inserted (el, binding, vnode) { |
|||
if (binding.value) { |
|||
focusCommentsNativeInput(el, vnode) |
|||
} |
|||
}, |
|||
componentUpdated (el, binding, vnode) { |
|||
if (binding.value && !binding.oldValue) { |
|||
focusCommentsNativeInput(el, vnode) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,511 @@ |
|||
// 打样跟踪页 mixin:Comments 行内编辑、成本列编辑与计算、汇率保存/按汇率重算
|
|||
import { updateProofTrackingComments, updateProofTrackingCost, saveProofTrackingExchangeRate, refreshProofTrackingCostByRate } from '@/api/sampleTracking/sampleTracking' |
|||
import { COST_MANUAL_COLUMNS, COST_CALCULATED_COLUMNS } from '../constants' |
|||
|
|||
export default { |
|||
methods: { |
|||
isCommentsEditing (row) { |
|||
return !!row && row.trackingId === this.commentsEditingTrackingId |
|||
}, |
|||
startCommentsEdit (row) { |
|||
if (!row || !row.trackingId || this.commentsSaveLoading) { |
|||
return |
|||
} |
|||
this.commentsEditingTrackingId = row.trackingId |
|||
this.commentsDraft = row.comments || '' |
|||
}, |
|||
cancelCommentsEdit () { |
|||
if (this.commentsSaveLoading) { |
|||
return |
|||
} |
|||
this.commentsEditingTrackingId = null |
|||
this.commentsDraft = '' |
|||
}, |
|||
handleCommentsBlur (row) { |
|||
if (this.commentsSaveLoading || !this.isCommentsEditing(row)) { |
|||
return |
|||
} |
|||
const comments = this.commentsDraft == null ? '' : String(this.commentsDraft) |
|||
if (comments.trim()) { |
|||
this.saveCommentsEdit(row, { |
|||
fromBlur: true, |
|||
draftComments: comments |
|||
}) |
|||
return |
|||
} |
|||
this.cancelCommentsEdit() |
|||
}, |
|||
saveCommentsEdit (row, options) { |
|||
const saveOptions = options || {} |
|||
const fromBlur = !!saveOptions.fromBlur |
|||
if (this.commentsSaveLoading) { |
|||
return |
|||
} |
|||
if (!row || !row.trackingId) { |
|||
this.$message.warning('跟踪记录ID不能为空') |
|||
return |
|||
} |
|||
const comments = Object.prototype.hasOwnProperty.call(saveOptions, 'draftComments') |
|||
? (saveOptions.draftComments == null ? '' : String(saveOptions.draftComments)) |
|||
: (this.commentsDraft == null ? '' : String(this.commentsDraft)) |
|||
if (comments === (row.comments || '')) { |
|||
this.cancelCommentsEdit() |
|||
return |
|||
} |
|||
if (fromBlur) { |
|||
this.commentsEditingTrackingId = null |
|||
this.commentsDraft = '' |
|||
} |
|||
this.commentsSaveLoading = true |
|||
updateProofTrackingComments({ |
|||
trackingId: row.trackingId, |
|||
comments: comments, |
|||
updateBy: this.$store.state.user.name |
|||
}).then(({ data }) => { |
|||
this.commentsSaveLoading = false |
|||
if (data && data.code === 0) { |
|||
row.comments = comments |
|||
this.$message.success('Comments保存成功') |
|||
this.cancelCommentsEdit() |
|||
} else { |
|||
this.$message.error(data.msg || 'Comments保存失败') |
|||
} |
|||
}).catch(() => { |
|||
this.commentsSaveLoading = false |
|||
this.$message.error('Comments保存异常') |
|||
}) |
|||
}, |
|||
isCostManualColumn (columnProp) { |
|||
return COST_MANUAL_COLUMNS.indexOf(columnProp) > -1 |
|||
}, |
|||
isCostCalculatedColumn (columnProp) { |
|||
return COST_CALCULATED_COLUMNS.indexOf(columnProp) > -1 |
|||
}, |
|||
isCostEditing (row, columnProp) { |
|||
return !!row && this.costEditingKey === `${row.trackingId}:${columnProp}` |
|||
}, |
|||
isCostEditingRow (row) { |
|||
if (!row || !this.costEditingKey) { |
|||
return false |
|||
} |
|||
return this.costEditingKey.indexOf(`${row.trackingId}:`) === 0 |
|||
}, |
|||
formatCostDisplay (value) { |
|||
if (value == null || String(value).trim() === '') { |
|||
return '' |
|||
} |
|||
const number = Number(value) |
|||
if (!Number.isFinite(number)) { |
|||
return String(value) |
|||
} |
|||
return number.toFixed(6).replace(/\.?0+$/, '') |
|||
}, |
|||
// 费用金额固定两位。汇率仍走 formatCostDisplay,避免把 6.685421 收成 6.69。
|
|||
formatCostAmount (value) { |
|||
if (value == null || String(value).trim() === '') { |
|||
return '' |
|||
} |
|||
const number = Number(value) |
|||
if (!Number.isFinite(number)) { |
|||
return String(value) |
|||
} |
|||
return this.roundCost(number).toFixed(2) |
|||
}, |
|||
roundCost (value) { |
|||
const number = Number(value) |
|||
if (!Number.isFinite(number)) { |
|||
return null |
|||
} |
|||
return Math.round((number + Number.EPSILON) * 100) / 100 |
|||
}, |
|||
toCostNumber (value) { |
|||
if (value == null || String(value).trim() === '') { |
|||
return null |
|||
} |
|||
const number = Number(value) |
|||
return Number.isFinite(number) ? number : null |
|||
}, |
|||
getRowSampleQty (row) { |
|||
if (!row) { |
|||
return null |
|||
} |
|||
const qty = row.sampleQty != null && row.sampleQty !== '' ? row.sampleQty : row.proofingNumber |
|||
return this.toCostNumber(qty) |
|||
}, |
|||
getCostRateNumber () { |
|||
const rate = this.toCostNumber(this.usdCnyExchangeRate) |
|||
return rate != null && rate > 0 ? rate : null |
|||
}, |
|||
getCostManualDisplay (row, columnProp) { |
|||
if (!row) { |
|||
return '' |
|||
} |
|||
if (columnProp === 'customizedForMasAls') { |
|||
return this.isBlankValue(row.customizedForMasAls) ? '' : String(row.customizedForMasAls) |
|||
} |
|||
return this.formatCostAmount(row[columnProp]) |
|||
}, |
|||
normalizeCostDraft (columnProp, rawValue) { |
|||
if (columnProp === 'customizedForMasAls') { |
|||
const text = rawValue == null ? '' : String(rawValue).trim() |
|||
if (!text) { |
|||
return { value: null, error: '' } |
|||
} |
|||
if (text.length > 100) { |
|||
return { value: null, error: 'Customized for MAS/ALS不能超过100个字符' } |
|||
} |
|||
return { value: text, error: '' } |
|||
} |
|||
const text = rawValue == null ? '' : String(rawValue).trim() |
|||
if (!text) { |
|||
return { value: null, error: '' } |
|||
} |
|||
if (!/^\d+(\.\d+)?$/.test(text)) { |
|||
return { value: null, error: '请输入不小于0的数字' } |
|||
} |
|||
const number = Number(text) |
|||
if (!Number.isFinite(number) || number >= 1000000000000) { |
|||
return { value: null, error: '数值超出可保存范围' } |
|||
} |
|||
return { value: this.roundCost(number), error: '' } |
|||
}, |
|||
isSameCostDraft (columnProp, normalizedValue, originalDisplay) { |
|||
if (columnProp === 'customizedForMasAls') { |
|||
const left = normalizedValue == null ? '' : String(normalizedValue).trim() |
|||
const right = originalDisplay == null ? '' : String(originalDisplay).trim() |
|||
return left === right |
|||
} |
|||
return this.formatCostAmount(normalizedValue) === this.formatCostAmount(originalDisplay) |
|||
}, |
|||
sumPreviewCost (left, right) { |
|||
if (left == null && right == null) { |
|||
return null |
|||
} |
|||
return this.roundCost((left || 0) + (right || 0)) |
|||
}, |
|||
// 列表默认显示已保存结果。只有正在改的那个数字,才按当天汇率预览受影响的计算列。
|
|||
getCostCalculatedValue (row, columnProp) { |
|||
if (!row) { |
|||
return null |
|||
} |
|||
if (!this.isCostEditingRow(row)) { |
|||
return row[columnProp] |
|||
} |
|||
const editingProp = this.costEditingKey.slice(this.costEditingKey.indexOf(':') + 1) |
|||
const preview = this.previewEditedCost(row, editingProp) |
|||
if (preview && Object.prototype.hasOwnProperty.call(preview, columnProp)) { |
|||
return preview[columnProp] |
|||
} |
|||
return row[columnProp] |
|||
}, |
|||
previewEditedCost (row, editingProp) { |
|||
const normalized = this.normalizeCostDraft(editingProp, this.costEditDraft) |
|||
if (normalized.error) { |
|||
return null |
|||
} |
|||
const rate = this.getCostRateNumber() |
|||
if (editingProp === 'tpKctUsd') { |
|||
const qty = this.getRowSampleQty(row) |
|||
const sampleCostUsd = normalized.value == null || qty == null |
|||
? null |
|||
: this.roundCost(normalized.value * qty / 1000) |
|||
return { |
|||
sampleCostUsd: sampleCostUsd, |
|||
sampleAndToolingCostUsd: this.sumPreviewCost(sampleCostUsd, this.toCostNumber(row.toolingCostUsd)) |
|||
} |
|||
} |
|||
if (editingProp === 'toolingCostCn') { |
|||
const toolingCostUsd = normalized.value == null || rate == null |
|||
? null |
|||
: this.roundCost(normalized.value / rate) |
|||
return { |
|||
toolingCostUsd: toolingCostUsd, |
|||
sampleAndToolingCostUsd: this.sumPreviewCost(this.toCostNumber(row.sampleCostUsd), toolingCostUsd) |
|||
} |
|||
} |
|||
if (editingProp === 'sampleCostFromFnCn') { |
|||
return { |
|||
sampleCostFromFnUsd: normalized.value == null || rate == null |
|||
? null |
|||
: this.roundCost(normalized.value / rate) |
|||
} |
|||
} |
|||
return null |
|||
}, |
|||
getCostCalculatedTitle (row, columnProp) { |
|||
const rate = this.formatCostDisplay(this.usdCnyExchangeRate) |
|||
const rateText = rate ? `汇率 ${rate}` : '未设置汇率,不能折算' |
|||
if (columnProp === 'sampleCostUsd') { |
|||
return '修改 TP 时按 TP(KCT/USD) × Sample Qty / 1000 计算' |
|||
} |
|||
if (columnProp === 'toolingCostUsd') { |
|||
return `修改 Tooling cost/CN 时按人民币 / ${rateText}` |
|||
} |
|||
if (columnProp === 'sampleAndToolingCostUsd') { |
|||
return 'Sample Cost/USD + Tooling Cost/USD。点“按汇率重算”会用当前汇率重算全部自动计算列' |
|||
} |
|||
if (columnProp === 'sampleCostFromFnUsd') { |
|||
return `修改 Sample Cost from FN/CN 时按人民币 / ${rateText}` |
|||
} |
|||
return '' |
|||
}, |
|||
normalizeExchangeRateDraft (rawValue) { |
|||
const text = rawValue == null ? '' : String(rawValue).trim() |
|||
if (!text) { |
|||
return { value: null, error: '' } |
|||
} |
|||
if (!/^\d+(\.\d{1,6})?$/.test(text)) { |
|||
return { value: null, error: '汇率请输入大于0的数字,最多6位小数' } |
|||
} |
|||
const number = Number(text) |
|||
if (!Number.isFinite(number) || number <= 0 || number >= 1000) { |
|||
return { value: null, error: '汇率必须大于0且小于1000' } |
|||
} |
|||
return { value: Math.round((number + Number.EPSILON) * 1000000) / 1000000, error: '' } |
|||
}, |
|||
isSameExchangeRate (left, right) { |
|||
if (left == null || right == null) { |
|||
return left == null && right == null |
|||
} |
|||
return Math.abs(Number(left) - Number(right)) < 0.0000005 |
|||
}, |
|||
// 汇率写在 siteid=2。空值允许保存,但之后不能把人民币折成美元。
|
|||
saveExchangeRate () { |
|||
const normalized = this.normalizeExchangeRateDraft(this.usdCnyExchangeRateDraft) |
|||
if (normalized.error) { |
|||
this.$message.warning(normalized.error) |
|||
return Promise.resolve(false) |
|||
} |
|||
if (this.isSameExchangeRate(normalized.value, this.toCostNumber(this.usdCnyExchangeRate))) { |
|||
return Promise.resolve(true) |
|||
} |
|||
if (this._exchangeRateSavePromise) { |
|||
return this._exchangeRateSavePromise |
|||
} |
|||
this.costRateSaving = true |
|||
this._exchangeRateSavePromise = saveProofTrackingExchangeRate({ |
|||
usdCnyRate: normalized.value, |
|||
updateBy: this.$store.state.user.name |
|||
}).then(({ data }) => { |
|||
if (!data || data.code !== 0) { |
|||
this.$message.error((data && data.msg) || '汇率保存失败') |
|||
return false |
|||
} |
|||
this.usdCnyExchangeRate = data.usdCnyExchangeRate == null ? null : data.usdCnyExchangeRate |
|||
this.usdCnyExchangeRateDraft = this.usdCnyExchangeRate == null ? '' : this.formatCostDisplay(this.usdCnyExchangeRate) |
|||
return true |
|||
}).catch(() => { |
|||
this.$message.error('汇率保存失败') |
|||
return false |
|||
}).finally(() => { |
|||
this.costRateSaving = false |
|||
this._exchangeRateSavePromise = null |
|||
}) |
|||
return this._exchangeRateSavePromise |
|||
}, |
|||
recalculateCostByRate () { |
|||
const normalized = this.normalizeExchangeRateDraft(this.usdCnyExchangeRateDraft) |
|||
if (normalized.error) { |
|||
this.$message.warning(normalized.error) |
|||
return |
|||
} |
|||
if (normalized.value == null) { |
|||
this.$message.warning('未设置汇率,无法计算') |
|||
return |
|||
} |
|||
this.$confirm('将按当前汇率重算全部自动计算的费用列并保存,是否继续?', '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
this.costRateRecalcLoading = true |
|||
return this.saveExchangeRate() |
|||
}).then(saved => { |
|||
if (saved !== true) { |
|||
return null |
|||
} |
|||
return refreshProofTrackingCostByRate({ updateBy: this.$store.state.user.name }) |
|||
}).then(response => { |
|||
if (!response) { |
|||
return |
|||
} |
|||
const data = response.data |
|||
if (data && data.code === 0) { |
|||
this.$message.success(data.msg || '费用已按汇率重算') |
|||
this.getDataList() |
|||
return |
|||
} |
|||
this.$message.error((data && data.msg) || '按汇率重算失败') |
|||
}).catch(error => { |
|||
if (error === 'cancel' || error === 'close') { |
|||
return |
|||
} |
|||
this.$message.error('按汇率重算失败') |
|||
}).finally(() => { |
|||
this.costRateRecalcLoading = false |
|||
}) |
|||
}, |
|||
resolveCostEditor () { |
|||
let editor = this.$refs.costEditor |
|||
if (Array.isArray(editor)) { |
|||
editor = editor.filter(item => item)[0] |
|||
} |
|||
return editor || null |
|||
}, |
|||
focusCostEditor (retried) { |
|||
const editor = this.resolveCostEditor() |
|||
if (!editor) { |
|||
if (!retried) { |
|||
this.$nextTick(() => { |
|||
this.focusCostEditor(true) |
|||
}) |
|||
} |
|||
return |
|||
} |
|||
if (typeof editor.focus === 'function') { |
|||
editor.focus() |
|||
} |
|||
if (typeof editor.toggleMenu === 'function' && !editor.visible) { |
|||
editor.toggleMenu() |
|||
} |
|||
const input = editor.$refs && editor.$refs.input |
|||
if (input && typeof input.select === 'function' && typeof editor.toggleMenu !== 'function') { |
|||
input.select() |
|||
} |
|||
}, |
|||
findCostEditingTarget () { |
|||
if (!this.costEditingKey) { |
|||
return null |
|||
} |
|||
const splitIndex = this.costEditingKey.indexOf(':') |
|||
if (splitIndex < 0) { |
|||
return null |
|||
} |
|||
const trackingId = this.costEditingKey.slice(0, splitIndex) |
|||
const columnProp = this.costEditingKey.slice(splitIndex + 1) |
|||
const row = (this.dataList || []).find(item => item && String(item.trackingId) === String(trackingId)) |
|||
if (!row) { |
|||
return null |
|||
} |
|||
return { row: row, columnProp: columnProp } |
|||
}, |
|||
exitCostEdit () { |
|||
this.costEditingKey = '' |
|||
this.costEditDraft = '' |
|||
this.costEditOriginal = '' |
|||
this.costSelectReady = false |
|||
}, |
|||
cancelCostEdit (row) { |
|||
if (row && !this.isCostEditingRow(row)) { |
|||
return |
|||
} |
|||
this.exitCostEdit() |
|||
}, |
|||
startCostEdit (row, columnProp) { |
|||
if (!row || !row.trackingId || !this.isCostManualColumn(columnProp)) { |
|||
return |
|||
} |
|||
const nextKey = `${row.trackingId}:${columnProp}` |
|||
if (this.costEditingKey === nextKey) { |
|||
return |
|||
} |
|||
if (this.costEditingKey) { |
|||
const editing = this.findCostEditingTarget() |
|||
if (editing) { |
|||
this.saveCostEdit(editing.row, editing.columnProp) |
|||
} else { |
|||
this.exitCostEdit() |
|||
} |
|||
} |
|||
this.costEditingKey = nextKey |
|||
this.costEditOriginal = this.getCostManualDisplay(row, columnProp) |
|||
this.costEditDraft = this.costEditOriginal |
|||
this.costSelectReady = false |
|||
this.$nextTick(() => { |
|||
this.focusCostEditor() |
|||
// 下拉刚挂上时会先关一次面板,这段时间不把关闭当成保存。
|
|||
setTimeout(() => { |
|||
if (this.costEditingKey === nextKey) { |
|||
this.costSelectReady = true |
|||
} |
|||
}, 200) |
|||
}) |
|||
}, |
|||
handleCostSelectVisible (visible, row, columnProp) { |
|||
if (visible || !this.isCostEditing(row, columnProp) || !this.costSelectReady) { |
|||
return |
|||
} |
|||
const editor = this.resolveCostEditor() |
|||
const typed = editor && editor.query != null ? String(editor.query).trim() : '' |
|||
if (typed && typed !== String(this.costEditDraft || '').trim()) { |
|||
this.costEditDraft = typed |
|||
} |
|||
this.saveCostEdit(row, columnProp) |
|||
}, |
|||
saveCostEdit (row, columnProp) { |
|||
if (!this.isCostEditing(row, columnProp)) { |
|||
return |
|||
} |
|||
const normalized = this.normalizeCostDraft(columnProp, this.costEditDraft) |
|||
if (normalized.error) { |
|||
this.$message.warning(normalized.error) |
|||
return |
|||
} |
|||
if (this.isSameCostDraft(columnProp, normalized.value, this.costEditOriginal)) { |
|||
this.exitCostEdit() |
|||
return |
|||
} |
|||
const version = (row._costSaveVersion || 0) + 1 |
|||
this.$set(row, '_costSaveVersion', version) |
|||
this.$set(row, columnProp, normalized.value) |
|||
const payload = { |
|||
trackingId: row.trackingId, |
|||
customizedForMasAls: this.isBlankValue(row.customizedForMasAls) ? null : String(row.customizedForMasAls).trim(), |
|||
tpKctUsd: this.toCostNumber(row.tpKctUsd), |
|||
toolingCostCn: this.toCostNumber(row.toolingCostCn), |
|||
sampleCostFromFnCn: this.toCostNumber(row.sampleCostFromFnCn), |
|||
updateBy: this.$store.state.user.name |
|||
} |
|||
this.exitCostEdit() |
|||
updateProofTrackingCost(payload).then(({ data }) => { |
|||
const current = (this.dataList || []).find(item => item && item.trackingId === row.trackingId) |
|||
if (!current || (current._costSaveVersion != null && current._costSaveVersion !== version)) { |
|||
return |
|||
} |
|||
if (data && data.code === 0) { |
|||
this.applySavedCost(current, data.row || {}) |
|||
if (data.msg && String(data.msg).indexOf('未设置汇率') > -1) { |
|||
this.$message.warning(data.msg) |
|||
} |
|||
return |
|||
} |
|||
this.$message.error((data && data.msg) || '费用保存失败') |
|||
this.getDataList() |
|||
}).catch(() => { |
|||
const current = (this.dataList || []).find(item => item && item.trackingId === row.trackingId) |
|||
if (!current || (current._costSaveVersion != null && current._costSaveVersion !== version)) { |
|||
return |
|||
} |
|||
this.$message.error('费用保存异常') |
|||
this.getDataList() |
|||
}) |
|||
}, |
|||
applySavedCost (row, saved) { |
|||
const fields = [ |
|||
'customizedForMasAls', |
|||
'tpKctUsd', |
|||
'toolingCostCn', |
|||
'sampleCostFromFnCn', |
|||
'sampleCostUsd', |
|||
'toolingCostUsd', |
|||
'sampleAndToolingCostUsd', |
|||
'sampleCostFromFnUsd' |
|||
] |
|||
fields.forEach(field => { |
|||
if (saved && Object.prototype.hasOwnProperty.call(saved, field)) { |
|||
this.$set(row, field, saved[field]) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,180 @@ |
|||
// 打样跟踪页 mixin:批量同步项目物料/打样到 NPI
|
|||
import { batchSyncProofTracking, batchSyncProjectPartTracking } from '@/api/sampleTracking/sampleTracking' |
|||
|
|||
export default { |
|||
methods: { |
|||
collectSyncToNpiMissingLabels (row) { |
|||
const projectPartId = this.getTrackingProjectPartId(row) |
|||
const missingLabels = [] |
|||
if (this.isBlankValue(row && row.site)) { |
|||
missingLabels.push('工厂') |
|||
} |
|||
if (this.isBlankValue(row && row.buNo)) { |
|||
missingLabels.push('BU') |
|||
} |
|||
if (!row || !row.projectId) { |
|||
missingLabels.push('项目ID') |
|||
} |
|||
if (this.isBlankValue(row && row.projectNo)) { |
|||
missingLabels.push('项目编码') |
|||
} |
|||
if (this.isBlankValue(row && row.projectName) && this.isBlankValue(row && row.projectDesc)) { |
|||
missingLabels.push('项目名称') |
|||
} |
|||
if (!projectPartId) { |
|||
missingLabels.push('项目物料ID') |
|||
} |
|||
if (this.isBlankValue(row && row.testPartNo)) { |
|||
missingLabels.push('项目料号') |
|||
} |
|||
if (this.isBlankValue(row && row.partDesc)) { |
|||
missingLabels.push('料号描述') |
|||
} |
|||
return missingLabels |
|||
}, |
|||
getSelectedRowsForBatchSync (actionLabel) { |
|||
const rows = this.selectionRows && this.selectionRows.length > 0 ? this.selectionRows : [] |
|||
if (rows.length === 0) { |
|||
this.$message.warning(`请先勾选需要${actionLabel}的记录`) |
|||
} |
|||
return rows |
|||
}, |
|||
syncBatchProjectPartToNpi () { |
|||
const selectedRows = this.getSelectedRowsForBatchSync('同步项目物料到NPI') |
|||
if (selectedRows.length === 0) { |
|||
return |
|||
} |
|||
const idMap = {} |
|||
const projectPartIds = [] |
|||
const invalidRows = [] |
|||
selectedRows.forEach(row => { |
|||
const projectPartId = this.getTrackingProjectPartId(row) |
|||
const missingLabels = this.collectSyncToNpiMissingLabels(row) |
|||
if (!projectPartId || missingLabels.length > 0) { |
|||
invalidRows.push({ |
|||
projectNo: row && row.projectNo ? row.projectNo : '-', |
|||
testPartNo: row && row.testPartNo ? row.testPartNo : '-', |
|||
missingLabels: missingLabels.length > 0 ? missingLabels : ['项目物料ID'] |
|||
}) |
|||
return |
|||
} |
|||
const idKey = String(projectPartId) |
|||
if (idMap[idKey]) { |
|||
return |
|||
} |
|||
idMap[idKey] = true |
|||
projectPartIds.push(projectPartId) |
|||
}) |
|||
if (projectPartIds.length === 0) { |
|||
this.$message.warning('勾选记录未包含可同步的项目物料') |
|||
return |
|||
} |
|||
const invalidHint = invalidRows.length > 0 |
|||
? `<br/>其中${invalidRows.length}条记录不满足同步条件,已自动跳过` |
|||
: '' |
|||
const confirmMsg = `确认批量同步项目物料到NPI吗?<br/>已勾选${selectedRows.length}条,可同步${projectPartIds.length}条${invalidHint}` |
|||
this.$confirm(confirmMsg, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning', |
|||
dangerouslyUseHTMLString: true |
|||
}).then(() => { |
|||
const operator = this.$store.state.user.name |
|||
this.syncBatchNpiLoading = true |
|||
batchSyncProjectPartTracking({ |
|||
projectPartIds: projectPartIds, |
|||
updateBy: operator, |
|||
createBy: operator, |
|||
userName: operator |
|||
}).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
const syncedCount = data.syncedCount || projectPartIds.length |
|||
this.$message.success(`批量同步成功,共${syncedCount}条项目物料`) |
|||
this.getDataList() |
|||
} else { |
|||
const failMsg = (data && data.msg) || '批量同步项目物料到NPI失败' |
|||
if (failMsg.indexOf('缺少以下必填项') > -1) { |
|||
this.$alert(failMsg, '同步校验未通过', { |
|||
confirmButtonText: '确定' |
|||
}) |
|||
} else { |
|||
this.$message.error(failMsg) |
|||
} |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error('批量同步项目物料到NPI异常') |
|||
}).finally(() => { |
|||
this.syncBatchNpiLoading = false |
|||
}) |
|||
}).catch(() => {}) |
|||
}, |
|||
syncBatchProofToNpi () { |
|||
const selectedRows = this.getSelectedRowsForBatchSync('同步打样到NPI') |
|||
if (selectedRows.length === 0) { |
|||
return |
|||
} |
|||
const idMap = {} |
|||
const trackingIds = [] |
|||
const invalidRows = [] |
|||
selectedRows.forEach(row => { |
|||
const trackingId = row && row.trackingId |
|||
if (!trackingId) { |
|||
invalidRows.push({ |
|||
projectNo: row && row.projectNo ? row.projectNo : '-', |
|||
testPartNo: row && row.testPartNo ? row.testPartNo : '-', |
|||
proofingNo: row && row.proofingNo ? row.proofingNo : '-' |
|||
}) |
|||
return |
|||
} |
|||
const idKey = String(trackingId) |
|||
if (idMap[idKey]) { |
|||
return |
|||
} |
|||
idMap[idKey] = true |
|||
trackingIds.push(trackingId) |
|||
}) |
|||
if (trackingIds.length === 0) { |
|||
this.$message.warning('勾选记录未包含可同步的打样单') |
|||
return |
|||
} |
|||
const invalidHint = invalidRows.length > 0 |
|||
? `<br/>其中${invalidRows.length}条记录缺少打样ID,已自动跳过` |
|||
: '' |
|||
const confirmMsg = `确认批量同步打样到NPI吗?<br/>已勾选${selectedRows.length}条,可同步${trackingIds.length}条${invalidHint}` |
|||
this.$confirm(confirmMsg, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning', |
|||
dangerouslyUseHTMLString: true |
|||
}).then(() => { |
|||
const operator = this.$store.state.user.name |
|||
this.syncBatchProofLoading = true |
|||
batchSyncProofTracking({ |
|||
trackingIds: trackingIds, |
|||
updateBy: operator, |
|||
createBy: operator, |
|||
userName: operator |
|||
}).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
const syncedCount = data.syncedCount || trackingIds.length |
|||
this.$message.success(`批量同步成功,共${syncedCount}条打样记录`) |
|||
this.getDataList() |
|||
} else { |
|||
const failMsg = (data && data.msg) || '批量同步打样到NPI失败' |
|||
if (failMsg.indexOf('缺少以下必填项') > -1 || failMsg.indexOf('请先同步项目') > -1 || failMsg.indexOf('请先同步项目物料') > -1) { |
|||
this.$alert(failMsg, '同步校验未通过', { |
|||
confirmButtonText: '确定' |
|||
}) |
|||
} else { |
|||
this.$message.error(failMsg) |
|||
} |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error('批量同步打样到NPI异常') |
|||
}).finally(() => { |
|||
this.syncBatchProofLoading = false |
|||
}) |
|||
}).catch(() => {}) |
|||
} |
|||
} |
|||
} |
|||
1065
src/views/modules/sampleTracking/projectProofTracking/mixins/oneKeyDialog.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,688 @@ |
|||
// 打样跟踪页 mixin:BU 列表、工序列定义、工序分类映射、查询区客户/BU 辅助
|
|||
import { |
|||
queryProofTrackingProcessColumns, |
|||
queryProofTrackingProcessCategories, |
|||
queryProofTrackingCustomerOptions |
|||
} from '@/api/sampleTracking/sampleTracking' |
|||
import { getSiteAndBuByUserName } from '@/api/eam/eam.js' |
|||
import { |
|||
DEFAULT_PROCESS_COLUMNS, |
|||
cloneDefaultProcessColumns, |
|||
buildProcessCodeLabelMapByRows |
|||
} from '../constants' |
|||
|
|||
export default { |
|||
methods: { |
|||
getSearchBuOptionList () { |
|||
return this.userBuList |
|||
.map(item => this.normalizeBuNo(item && item.buNo ? item.buNo : '', this.searchData.site)) |
|||
.filter(item => !!item) |
|||
}, |
|||
ensureSearchBuNoSelected () { |
|||
const buOptionList = this.getSearchBuOptionList() |
|||
if (buOptionList.length === 0) { |
|||
this.searchData.buNo = '' |
|||
return '' |
|||
} |
|||
const currentBuNo = this.normalizeBuNo(this.searchData.buNo, this.searchData.site) |
|||
if (currentBuNo && buOptionList.indexOf(currentBuNo) > -1) { |
|||
this.searchData.buNo = currentBuNo |
|||
return currentBuNo |
|||
} |
|||
// 需求要求查询BU必须有值:为空或无效时默认回退到首个可用BU。
|
|||
this.searchData.buNo = buOptionList[0] |
|||
return this.searchData.buNo |
|||
}, |
|||
loadUserBuList () { |
|||
if (this.userBuList.length > 0) { |
|||
this.ensureSearchBuNoSelected() |
|||
this.ensureBuProcessConfigRows() |
|||
return Promise.resolve(this.userBuList) |
|||
} |
|||
const params = { username: this.$store.state.user.name } |
|||
return getSiteAndBuByUserName(params).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
const excludedBuNoList = ['3_02-Hardtag', '4_04-MHM', '5_05-Alpha'] |
|||
this.userBuList = (data.rows || []).filter(item => { |
|||
const buNo = item && item.buNo ? String(item.buNo).trim() : '' |
|||
return excludedBuNoList.indexOf(buNo) === -1 |
|||
}) |
|||
this.ensureSearchBuNoSelected() |
|||
this.ensureBuProcessConfigRows() |
|||
} |
|||
return this.userBuList |
|||
}).catch(() => { |
|||
this.userBuList = [] |
|||
this.ensureSearchBuNoSelected() |
|||
this.ensureBuProcessConfigRows() |
|||
return [] |
|||
}) |
|||
}, |
|||
queryProcessColumns () { |
|||
const selectedBuNo = this.getSelectedSearchBuNo() |
|||
const queryBuNo = selectedBuNo || '*' |
|||
// 列顺序来源规则:
|
|||
// 1) 未选择查询 BU:固定按 bu='*' 读取默认工序顺序;
|
|||
// 2) 已选择查询 BU:按该 BU 读取;若无配置由后端回退到 bu='*'。
|
|||
const inData = { |
|||
site: this.$store.state.user.site, |
|||
userName: this.$store.state.user.name, |
|||
buNo: queryBuNo |
|||
} |
|||
return queryProofTrackingProcessColumns(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '加载工序列配置失败,已使用默认配置') |
|||
this.processColumns = cloneDefaultProcessColumns() |
|||
this.mergeProcessCodeLabelMapByRows(this.processColumns) |
|||
this.ensureBuProcessConfigRows() |
|||
this.refreshTrackingTableLayout() |
|||
return this.processColumns |
|||
} |
|||
const rows = Array.isArray(data.rows) ? data.rows : [] |
|||
// 防御性排序:即使后端 SQL 已 ORDER BY sort_no,前端仍按 sortNo 二次排序,确保展示稳定。
|
|||
const sortedRows = rows |
|||
.map((item, index) => { |
|||
const parsedSortNo = parseInt(item && item.sortNo, 10) |
|||
return { |
|||
item: item, |
|||
sourceIndex: index, |
|||
sortNo: Number.isNaN(parsedSortNo) ? Number.MAX_SAFE_INTEGER : parsedSortNo |
|||
} |
|||
}) |
|||
.sort((a, b) => { |
|||
if (a.sortNo !== b.sortNo) { |
|||
return a.sortNo - b.sortNo |
|||
} |
|||
return a.sourceIndex - b.sourceIndex |
|||
}) |
|||
const nextColumns = [] |
|||
const usedCodeMap = {} |
|||
sortedRows.forEach(({ item, sortNo }) => { |
|||
if (!item) { |
|||
return |
|||
} |
|||
const code = item.code == null ? '' : String(item.code).trim() |
|||
const label = item.label == null ? '' : String(item.label).trim() |
|||
const planField = item.planField == null ? '' : String(item.planField).trim() |
|||
const actualField = item.actualField == null ? '' : String(item.actualField).trim() |
|||
const statusField = item.statusField == null ? '' : String(item.statusField).trim() |
|||
const processCategoryCode = item.processCategoryCode == null ? '' : String(item.processCategoryCode).trim() |
|||
const processCategoryName = item.processCategoryName == null ? '' : String(item.processCategoryName).trim() |
|||
if (!code || !label || !planField || !actualField || !statusField || usedCodeMap[code]) { |
|||
return |
|||
} |
|||
usedCodeMap[code] = true |
|||
nextColumns.push({ |
|||
label: label, |
|||
code: code, |
|||
planField: planField, |
|||
actualField: actualField, |
|||
statusField: statusField, |
|||
processCategoryCode: processCategoryCode, |
|||
processCategoryName: processCategoryName, |
|||
sortNo: sortNo === Number.MAX_SAFE_INTEGER ? null : sortNo |
|||
}) |
|||
}) |
|||
// 保障切换期可用性:当表里无有效配置时继续使用前端兜底工序定义。
|
|||
this.processColumns = nextColumns.length > 0 ? nextColumns : cloneDefaultProcessColumns() |
|||
this.mergeProcessCodeLabelMapByRows(this.processColumns) |
|||
this.syncDataListProcessValues() |
|||
this.ensureBuProcessConfigRows() |
|||
this.refreshTrackingTableLayout() |
|||
return this.processColumns |
|||
}).catch(() => { |
|||
this.$message.error('加载工序列配置异常,已使用默认配置') |
|||
this.processColumns = cloneDefaultProcessColumns() |
|||
this.mergeProcessCodeLabelMapByRows(this.processColumns) |
|||
this.syncDataListProcessValues() |
|||
this.ensureBuProcessConfigRows() |
|||
this.refreshTrackingTableLayout() |
|||
return this.processColumns |
|||
}) |
|||
}, |
|||
getRowProcessValue (row, processCode) { |
|||
if (!row || !processCode) { |
|||
return null |
|||
} |
|||
const processMap = row.processValueMap && typeof row.processValueMap === 'object' |
|||
? row.processValueMap |
|||
: null |
|||
if (!processMap) { |
|||
return null |
|||
} |
|||
return processMap[processCode] || null |
|||
}, |
|||
applyProcessValuesToRow (row) { |
|||
if (!row || !this.processColumns || this.processColumns.length === 0) { |
|||
return |
|||
} |
|||
this.processColumns.forEach(item => { |
|||
if (!item) { |
|||
return |
|||
} |
|||
const processValue = this.getRowProcessValue(row, item.code) |
|||
const planDate = processValue ? this.formatDate(processValue.planDate) : '' |
|||
const actualDate = processValue ? this.formatDate(processValue.actualDate) : '' |
|||
const status = processValue && processValue.status ? String(processValue.status).trim() : '' |
|||
this.$set(row, item.planField, planDate) |
|||
this.$set(row, item.actualField, actualDate) |
|||
this.$set(row, item.statusField, status) |
|||
}) |
|||
}, |
|||
syncDataListProcessValues () { |
|||
if (!Array.isArray(this.dataList) || this.dataList.length === 0) { |
|||
return |
|||
} |
|||
this.dataList.forEach(row => { |
|||
this.applyProcessValuesToRow(row) |
|||
}) |
|||
}, |
|||
updateRowProcessValue (row, processCol, status, actualDate) { |
|||
if (!row || !processCol) { |
|||
return |
|||
} |
|||
if (!row.processValueMap || typeof row.processValueMap !== 'object') { |
|||
this.$set(row, 'processValueMap', {}) |
|||
} |
|||
const prevValue = this.getRowProcessValue(row, processCol.code) || {} |
|||
this.$set(row.processValueMap, processCol.code, Object.assign({}, prevValue, { |
|||
processCode: processCol.code, |
|||
status: status, |
|||
actualDate: actualDate || null |
|||
})) |
|||
this.$set(row, processCol.statusField, status) |
|||
this.$set(row, processCol.actualField, actualDate) |
|||
if (processCol.code === 'deliveryPackage') { |
|||
// Delivery&Package 工序日期与打样预计完成日期使用同一口径,前端先行回写避免用户感知延迟。
|
|||
this.$set(row, 'requiredDeliveryDate', actualDate || '') |
|||
// baseline 仅在首次维护 Delivery&Package 日期时自动带入,后续允许独立维护。
|
|||
if (!this.formatDate(row.baseline) && actualDate) { |
|||
this.$set(row, 'baseline', actualDate) |
|||
} |
|||
} |
|||
}, |
|||
getAllProcessCodes () { |
|||
return this.processColumns.map(item => item.code) |
|||
}, |
|||
mergeProcessCodeLabelMapByRows (rows) { |
|||
if (!Array.isArray(rows) || rows.length === 0) { |
|||
return |
|||
} |
|||
const nextMap = Object.assign({}, this.processCodeLabelMap || {}) |
|||
const rowLabelMap = buildProcessCodeLabelMapByRows(rows) |
|||
Object.keys(rowLabelMap).forEach(code => { |
|||
nextMap[code] = rowLabelMap[code] |
|||
}) |
|||
this.processCodeLabelMap = nextMap |
|||
}, |
|||
mergeProcessCodeLabelMapByObject (labelMap) { |
|||
if (!labelMap || typeof labelMap !== 'object') { |
|||
return |
|||
} |
|||
const nextMap = Object.assign({}, this.processCodeLabelMap || {}) |
|||
Object.keys(labelMap).forEach(rawCode => { |
|||
const code = rawCode == null ? '' : String(rawCode).trim() |
|||
const label = labelMap[rawCode] == null ? '' : String(labelMap[rawCode]).trim() |
|||
if (!code || !label) { |
|||
return |
|||
} |
|||
// 兼容后端已保存大小写不一致的编码。
|
|||
nextMap[code] = label |
|||
nextMap[code.toLowerCase()] = label |
|||
}) |
|||
this.processCodeLabelMap = nextMap |
|||
}, |
|||
buildProcessCategoryOptionsByRows (rows) { |
|||
const sourceRows = Array.isArray(rows) ? rows : [] |
|||
const nextOptions = [] |
|||
const usedCodeMap = {} |
|||
sourceRows.forEach((item, index) => { |
|||
const categoryCode = item && item.categoryCode != null ? String(item.categoryCode).trim() : '' |
|||
const categoryName = item && item.categoryName != null ? String(item.categoryName).trim() : '' |
|||
if (!categoryCode || !categoryName) { |
|||
return |
|||
} |
|||
const codeKey = categoryCode.toLowerCase() |
|||
if (usedCodeMap[codeKey]) { |
|||
return |
|||
} |
|||
usedCodeMap[codeKey] = true |
|||
const parsedSortNo = parseInt(item && item.sortNo, 10) |
|||
nextOptions.push({ |
|||
categoryCode: categoryCode, |
|||
categoryName: categoryName, |
|||
sortNo: Number.isNaN(parsedSortNo) ? (index + 1) * 10 : parsedSortNo |
|||
}) |
|||
}) |
|||
nextOptions.sort((a, b) => { |
|||
if (a.sortNo !== b.sortNo) { |
|||
return a.sortNo - b.sortNo |
|||
} |
|||
return String(a.categoryCode).localeCompare(String(b.categoryCode)) |
|||
}) |
|||
return nextOptions |
|||
}, |
|||
getProcessCategoryOptionsByBuNo (buNo) { |
|||
const normalizedBuNo = this.normalizeBuNo(buNo, this.$store.state.user.site) |
|||
if (!normalizedBuNo) { |
|||
return [] |
|||
} |
|||
const optionMap = this.buProcessCategoryOptionsMap || {} |
|||
return Array.isArray(optionMap[normalizedBuNo]) ? optionMap[normalizedBuNo] : [] |
|||
}, |
|||
getBuProcessCategoryNameByCode (buNo, categoryCode) { |
|||
if (!categoryCode) { |
|||
return '' |
|||
} |
|||
const normalizedCategoryCode = String(categoryCode).trim() |
|||
if (!normalizedCategoryCode) { |
|||
return '' |
|||
} |
|||
const lowerCategoryCode = normalizedCategoryCode.toLowerCase() |
|||
const configEntry = this.getBuProcessConfigEntry(buNo, this.$store.state.user.site) |
|||
const categoryNameMap = configEntry && configEntry.config && configEntry.config.processCategoryNameMap |
|||
? configEntry.config.processCategoryNameMap |
|||
: {} |
|||
if (categoryNameMap && typeof categoryNameMap === 'object') { |
|||
if (categoryNameMap[normalizedCategoryCode]) { |
|||
return categoryNameMap[normalizedCategoryCode] |
|||
} |
|||
if (categoryNameMap[lowerCategoryCode]) { |
|||
return categoryNameMap[lowerCategoryCode] |
|||
} |
|||
const matchedNameCode = Object.keys(categoryNameMap).find(code => { |
|||
return String(code).trim().toLowerCase() === lowerCategoryCode |
|||
}) |
|||
if (matchedNameCode) { |
|||
return categoryNameMap[matchedNameCode] || '' |
|||
} |
|||
} |
|||
const options = this.getProcessCategoryOptionsByBuNo(buNo) |
|||
const matched = options.find(item => { |
|||
if (!item || !item.categoryCode) { |
|||
return false |
|||
} |
|||
return String(item.categoryCode).trim().toLowerCase() === lowerCategoryCode |
|||
}) |
|||
return matched && matched.categoryName ? matched.categoryName : '' |
|||
}, |
|||
getBuProcessCategoryCodeByProcessCode (buNo, processCode) { |
|||
const configEntry = this.getBuProcessConfigEntry(buNo, this.$store.state.user.site) |
|||
const config = configEntry ? configEntry.config : null |
|||
if (!config || !config.processCategoryMap || typeof config.processCategoryMap !== 'object' || !processCode) { |
|||
return '' |
|||
} |
|||
const sourceMap = config.processCategoryMap |
|||
const normalizedProcessCode = String(processCode).trim() |
|||
if (!normalizedProcessCode) { |
|||
return '' |
|||
} |
|||
if (sourceMap[normalizedProcessCode] != null) { |
|||
return String(sourceMap[normalizedProcessCode]).trim() |
|||
} |
|||
const lowerProcessCode = normalizedProcessCode.toLowerCase() |
|||
const matchedKey = Object.keys(sourceMap).find(code => { |
|||
return String(code).trim().toLowerCase() === lowerProcessCode |
|||
}) |
|||
return matchedKey ? String(sourceMap[matchedKey] || '').trim() : '' |
|||
}, |
|||
getBuProcessCategoryCode (row, processCode) { |
|||
if (!row || !processCode) { |
|||
return '' |
|||
} |
|||
const map = row.processCategoryMap && typeof row.processCategoryMap === 'object' |
|||
? row.processCategoryMap |
|||
: {} |
|||
const directValue = map[processCode] |
|||
if (directValue != null) { |
|||
return String(directValue).trim() |
|||
} |
|||
const normalizedCode = String(processCode).trim().toLowerCase() |
|||
const matchedKey = Object.keys(map).find(code => String(code).trim().toLowerCase() === normalizedCode) |
|||
if (!matchedKey) { |
|||
return '' |
|||
} |
|||
const matchedValue = map[matchedKey] |
|||
return matchedValue == null ? '' : String(matchedValue).trim() |
|||
}, |
|||
normalizeProcessCategoryMapForRow (row) { |
|||
const resultMap = {} |
|||
if (!row) { |
|||
return resultMap |
|||
} |
|||
const validOrderCodes = this.getValidProcessOrderCodes(row.processOrderCodes) |
|||
validOrderCodes.forEach(code => { |
|||
const categoryCode = this.getBuProcessCategoryCode(row, code) |
|||
resultMap[code] = categoryCode || '' |
|||
}) |
|||
return resultMap |
|||
}, |
|||
handleBuProcessCategoryChange (row, processCode, categoryCode) { |
|||
if (!row || !processCode) { |
|||
return |
|||
} |
|||
const normalizedCode = String(processCode).trim() |
|||
if (!normalizedCode) { |
|||
return |
|||
} |
|||
if (!row.processCategoryMap || typeof row.processCategoryMap !== 'object') { |
|||
this.$set(row, 'processCategoryMap', {}) |
|||
} |
|||
const categoryCodeVal = categoryCode == null ? '' : String(categoryCode).trim() |
|||
this.$set(row.processCategoryMap, normalizedCode, categoryCodeVal) |
|||
}, |
|||
loadBuProcessCategoryOptionsByBuNo (buNo, silent = true) { |
|||
const normalizedBuNo = this.normalizeBuNo(buNo, this.$store.state.user.site) |
|||
if (!normalizedBuNo) { |
|||
return Promise.resolve([]) |
|||
} |
|||
const inData = { |
|||
site: this.$store.state.user.site, |
|||
buNo: normalizedBuNo, |
|||
userName: this.$store.state.user.name |
|||
} |
|||
return queryProofTrackingProcessCategories(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
if (!silent) { |
|||
this.$message.error((data && data.msg) || `加载事业部【${normalizedBuNo}】工序分类失败`) |
|||
} |
|||
this.$set(this.buProcessCategoryOptionsMap, normalizedBuNo, []) |
|||
if (this.buProcessConfigMap && this.buProcessConfigMap[normalizedBuNo]) { |
|||
this.$set(this.buProcessConfigMap, normalizedBuNo, Object.assign({}, this.buProcessConfigMap[normalizedBuNo], { |
|||
processCategoryNameMap: {} |
|||
})) |
|||
} |
|||
return [] |
|||
} |
|||
const options = this.buildProcessCategoryOptionsByRows(data.rows || []) |
|||
this.$set(this.buProcessCategoryOptionsMap, normalizedBuNo, options) |
|||
if (this.buProcessConfigMap && this.buProcessConfigMap[normalizedBuNo]) { |
|||
const processCategoryNameMap = {} |
|||
options.forEach(item => { |
|||
const categoryCode = item && item.categoryCode ? String(item.categoryCode).trim() : '' |
|||
const categoryName = item && item.categoryName ? String(item.categoryName).trim() : '' |
|||
if (!categoryCode || !categoryName) { |
|||
return |
|||
} |
|||
processCategoryNameMap[categoryCode] = categoryName |
|||
processCategoryNameMap[categoryCode.toLowerCase()] = categoryName |
|||
}) |
|||
this.$set(this.buProcessConfigMap, normalizedBuNo, Object.assign({}, this.buProcessConfigMap[normalizedBuNo], { |
|||
processCategoryNameMap: processCategoryNameMap |
|||
})) |
|||
} |
|||
return options |
|||
}).catch(() => { |
|||
if (!silent) { |
|||
this.$message.error(`加载事业部【${normalizedBuNo}】工序分类异常`) |
|||
} |
|||
this.$set(this.buProcessCategoryOptionsMap, normalizedBuNo, []) |
|||
if (this.buProcessConfigMap && this.buProcessConfigMap[normalizedBuNo]) { |
|||
this.$set(this.buProcessConfigMap, normalizedBuNo, Object.assign({}, this.buProcessConfigMap[normalizedBuNo], { |
|||
processCategoryNameMap: {} |
|||
})) |
|||
} |
|||
return [] |
|||
}) |
|||
}, |
|||
loadAllBuProcessCategoryOptions (sourceRows, silent = true) { |
|||
const rows = Array.isArray(sourceRows) ? sourceRows : [] |
|||
const requestBuNos = [] |
|||
const usedBuMap = {} |
|||
rows.forEach(item => { |
|||
const buNo = this.normalizeBuNo(item && item.buNo ? item.buNo : '', this.$store.state.user.site) |
|||
if (!buNo || usedBuMap[buNo]) { |
|||
return |
|||
} |
|||
usedBuMap[buNo] = true |
|||
requestBuNos.push(buNo) |
|||
}) |
|||
if (requestBuNos.length === 0) { |
|||
return Promise.resolve([]) |
|||
} |
|||
return Promise.all(requestBuNos.map(buNo => this.loadBuProcessCategoryOptionsByBuNo(buNo, silent))) |
|||
}, |
|||
getProcessLabelByCode (processCode) { |
|||
if (!processCode) { |
|||
return '' |
|||
} |
|||
const normalizedCode = String(processCode).trim() |
|||
const lowerCode = normalizedCode.toLowerCase() |
|||
const matched = this.processColumns.find(item => item && item.code === normalizedCode) |
|||
if (matched && matched.label) { |
|||
return matched.label |
|||
} |
|||
const caseInsensitiveMatched = this.processColumns.find(item => { |
|||
if (!item || !item.code) { |
|||
return false |
|||
} |
|||
return String(item.code).trim().toLowerCase() === lowerCode |
|||
}) |
|||
if (caseInsensitiveMatched && caseInsensitiveMatched.label) { |
|||
return caseInsensitiveMatched.label |
|||
} |
|||
const codeLabelMap = this.processCodeLabelMap || {} |
|||
if (codeLabelMap[normalizedCode]) { |
|||
return codeLabelMap[normalizedCode] |
|||
} |
|||
if (codeLabelMap[lowerCode]) { |
|||
return codeLabelMap[lowerCode] |
|||
} |
|||
const defaultMatched = DEFAULT_PROCESS_COLUMNS.find(item => { |
|||
if (!item || !item.code) { |
|||
return false |
|||
} |
|||
return item.code.toLowerCase() === lowerCode |
|||
}) |
|||
return defaultMatched && defaultMatched.label ? defaultMatched.label : normalizedCode |
|||
}, |
|||
getValidProcessOrderCodes (codes) { |
|||
// 顺序列表不能因为“当前 BU 不可见”而丢项:先保留后端返回顺序,再补齐当前已知工序。
|
|||
const orderedCodes = [] |
|||
if (Array.isArray(codes)) { |
|||
codes.forEach(code => { |
|||
const codeVal = code == null ? '' : String(code).trim() |
|||
if (!codeVal || orderedCodes.indexOf(codeVal) > -1) { |
|||
return |
|||
} |
|||
orderedCodes.push(codeVal) |
|||
}) |
|||
} |
|||
const allCodes = this.getAllProcessCodes() |
|||
allCodes.forEach(code => { |
|||
if (orderedCodes.indexOf(code) === -1) { |
|||
orderedCodes.push(code) |
|||
} |
|||
}) |
|||
return orderedCodes |
|||
}, |
|||
normalizeBuNo (buNo, site) { |
|||
const rawBuNo = buNo == null ? '' : String(buNo).trim() |
|||
if (!rawBuNo) { |
|||
return '' |
|||
} |
|||
const splitIdx = rawBuNo.indexOf('_') |
|||
if (splitIdx < 1 || splitIdx >= rawBuNo.length - 1) { |
|||
return rawBuNo |
|||
} |
|||
// BU统一按“去掉site前缀”展示与保存,例如 2_01-Label -> 01-Label。
|
|||
return rawBuNo.substring(splitIdx + 1) |
|||
}, |
|||
isRfidBuNo (buNo) { |
|||
const normalizedBuNo = this.normalizeBuNo(buNo, this.$store.state.user.site) |
|||
return normalizedBuNo.toUpperCase() === '03-RFID' |
|||
}, |
|||
getValidProcessCodes (codes, allowedCodes) { |
|||
if (!Array.isArray(codes) || codes.length === 0) { |
|||
return [] |
|||
} |
|||
const allCodes = Array.isArray(allowedCodes) && allowedCodes.length > 0 |
|||
? allowedCodes |
|||
.map(code => (code == null ? '' : String(code).trim())) |
|||
.filter(code => !!code) |
|||
: this.getAllProcessCodes() |
|||
const normalizedCodes = [] |
|||
codes.forEach(code => { |
|||
const codeVal = code == null ? '' : String(code).trim() |
|||
if (!codeVal || allCodes.indexOf(codeVal) === -1) { |
|||
return |
|||
} |
|||
if (normalizedCodes.indexOf(codeVal) === -1) { |
|||
normalizedCodes.push(codeVal) |
|||
} |
|||
}) |
|||
return normalizedCodes |
|||
}, |
|||
getBuProcessConfigEntry (buNo, site) { |
|||
const normalizedBuNo = this.normalizeBuNo(buNo, site) |
|||
if (!normalizedBuNo) { |
|||
return null |
|||
} |
|||
const config = this.buProcessConfigMap[normalizedBuNo] |
|||
if (config) { |
|||
return { key: normalizedBuNo, config: config } |
|||
} |
|||
return null |
|||
}, |
|||
getSelectedSearchBuNo () { |
|||
return this.normalizeBuNo(this.searchData.buNo, this.searchData.site) |
|||
}, |
|||
normalizeSearchProofingStatusList (statusList) { |
|||
if (!Array.isArray(statusList) || statusList.length === 0) { |
|||
return [] |
|||
} |
|||
const normalizedStatusList = [] |
|||
statusList.forEach(item => { |
|||
const status = this.isBlankValue(item) ? '' : String(item).trim() |
|||
if (!status || normalizedStatusList.indexOf(status) > -1) { |
|||
return |
|||
} |
|||
normalizedStatusList.push(status) |
|||
}) |
|||
return normalizedStatusList |
|||
}, |
|||
getSearchCustomerOptionLabel (item) { |
|||
const customerNo = item && !this.isBlankValue(item.customerNo) |
|||
? String(item.customerNo).trim() |
|||
: '' |
|||
const customerDesc = item && !this.isBlankValue(item.customerDesc) |
|||
? String(item.customerDesc).trim() |
|||
: '' |
|||
if (!customerNo) { |
|||
return customerDesc |
|||
} |
|||
return customerDesc |
|||
}, |
|||
resetSearchCustomerOptions () { |
|||
// 查询 BU 变化后,客户下拉需重置,避免沿用旧 BU 缓存导致筛选项不准确。
|
|||
this.searchCustomerQueryToken += 1 |
|||
this.searchCustomerOptionLoading = false |
|||
this.searchCustomerOptionInitialized = false |
|||
this.searchCustomerOptions = [] |
|||
}, |
|||
handleSearchCustomerVisibleChange (visible) { |
|||
if (!visible || this.searchCustomerOptionInitialized) { |
|||
return |
|||
} |
|||
this.querySearchCustomerOptions('') |
|||
}, |
|||
handleSearchCustomerRemote (keyword) { |
|||
this.querySearchCustomerOptions(keyword) |
|||
}, |
|||
querySearchCustomerOptions (keyword) { |
|||
const normalizedKeyword = this.isBlankValue(keyword) ? '' : String(keyword).trim() |
|||
const queryToken = this.searchCustomerQueryToken + 1 |
|||
this.searchCustomerQueryToken = queryToken |
|||
this.searchCustomerOptionLoading = true |
|||
return queryProofTrackingCustomerOptions({ |
|||
site: this.$store.state.user.site, |
|||
userName: this.$store.state.user.name, |
|||
buNo: this.getSelectedSearchBuNo(), |
|||
customerNo: normalizedKeyword |
|||
}).then(({ data }) => { |
|||
if (queryToken !== this.searchCustomerQueryToken) { |
|||
return [] |
|||
} |
|||
if (!(data && data.code === 0)) { |
|||
throw new Error((data && data.msg) || '查询客户下拉异常') |
|||
} |
|||
const rows = Array.isArray(data.rows) ? data.rows : [] |
|||
const normalizedRows = rows.map(item => ({ |
|||
customerNo: this.isBlankValue(item && item.customerNo) ? '' : String(item.customerNo).trim(), |
|||
customerDesc: this.isBlankValue(item && item.customerDesc) ? '' : String(item.customerDesc).trim() |
|||
})).filter(item => !!item.customerNo) |
|||
this.searchCustomerOptions = normalizedRows |
|||
if (!normalizedKeyword) { |
|||
this.searchCustomerOptionInitialized = true |
|||
} |
|||
return normalizedRows |
|||
}).catch((e) => { |
|||
if (queryToken === this.searchCustomerQueryToken) { |
|||
this.searchCustomerOptions = [] |
|||
this.$message.error((e && e.message) || '查询客户下拉异常') |
|||
} |
|||
return [] |
|||
}).finally(() => { |
|||
if (queryToken === this.searchCustomerQueryToken) { |
|||
this.searchCustomerOptionLoading = false |
|||
} |
|||
}) |
|||
}, |
|||
handleSearchBuChange () { |
|||
this.ensureSearchBuNoSelected() |
|||
this.resetSearchCustomerOptions() |
|||
// 分类列仅 RFID 可见,切走时清空避免隐藏条件继续过滤。
|
|||
if (!this.isRfidBuNo(this.searchData.buNo)) { |
|||
this.searchData.dryWetType = '' |
|||
} |
|||
this.refreshTrackingTableLayout() |
|||
// BU筛选变化后立即重新查询,并回到第一页。
|
|||
this.queryProcessColumns().then(() => { |
|||
this.getDataList('Y') |
|||
}) |
|||
}, |
|||
getProcessVisibleCodesByBuNo (buNo, site) { |
|||
const configEntry = this.getBuProcessConfigEntry(buNo, site) |
|||
const config = configEntry ? configEntry.config : null |
|||
// 没有配置或配置为全部显示时,返回 null 表示该 BU 工序列不过滤。
|
|||
if (!config || config.showAll !== false) { |
|||
return null |
|||
} |
|||
const validCodes = this.getValidProcessCodes(config.processCodes) |
|||
if (validCodes.length === 0 || validCodes.length >= this.processColumns.length) { |
|||
return null |
|||
} |
|||
return validCodes |
|||
}, |
|||
getProcessColumnWidth (item) { |
|||
const rows = this.dataList.filter(row => |
|||
this.isProcessColumnVisibleForRow(row, item) |
|||
) |
|||
// 没有数据
|
|||
if (rows.length === 0) { |
|||
return 118 |
|||
} |
|||
// 放大字号后为日期输入和完成按钮留足宽度,避免完整日期被截断。
|
|||
// 有任何一个未完成
|
|||
if (rows.some(row => !this.isProcessStatusComplete(row, item))) { |
|||
return 140 |
|||
} |
|||
// 全部完成
|
|||
return 118 |
|||
}, |
|||
isProcessColumnVisibleForRow (row, processCol) { |
|||
if (!row || !processCol) { |
|||
return true |
|||
} |
|||
// 已指定查询BU时,列集合已经按查询BU过滤,不再按行二次隐藏。
|
|||
if (this.getSelectedSearchBuNo()) { |
|||
return true |
|||
} |
|||
const visibleCodes = this.getProcessVisibleCodesByBuNo(row.buNo, row.site) |
|||
if (!visibleCodes) { |
|||
return true |
|||
} |
|||
return visibleCodes.indexOf(processCol.code) > -1 |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,912 @@ |
|||
// 打样跟踪页 mixin:事业部进度设置、默认进度设置、工序分类配置弹窗及工序拖拽排序
|
|||
import { |
|||
queryProofTrackingBuProcessConfig, |
|||
queryProofTrackingProcessCategories, |
|||
deleteProofTrackingProcessColumnsManage, |
|||
queryProofTrackingProcessColumnsManage, |
|||
saveProofTrackingBuProcessConfig, |
|||
saveProofTrackingProcessCategoriesManage, |
|||
saveProofTrackingProcessColumnsManage |
|||
} from '@/api/sampleTracking/sampleTracking' |
|||
import Sortable from 'sortablejs' |
|||
import { DEFAULT_PROCESS_COLUMNS } from '../constants' |
|||
|
|||
export default { |
|||
methods: { |
|||
queryBuProcessConfig () { |
|||
const inData = { |
|||
site: this.$store.state.user.site, |
|||
userName: this.$store.state.user.name |
|||
} |
|||
return queryProofTrackingBuProcessConfig(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '加载事业部进度展示配置失败') |
|||
return |
|||
} |
|||
const rows = data.rows || [] |
|||
const nextMap = {} |
|||
const processLabelMap = {} |
|||
rows.forEach(item => { |
|||
if (item && item.processLabelMap && typeof item.processLabelMap === 'object') { |
|||
Object.keys(item.processLabelMap).forEach(rawCode => { |
|||
const code = rawCode == null ? '' : String(rawCode).trim() |
|||
const label = item.processLabelMap[rawCode] == null ? '' : String(item.processLabelMap[rawCode]).trim() |
|||
if (!code || !label) { |
|||
return |
|||
} |
|||
processLabelMap[code] = label |
|||
}) |
|||
} |
|||
const buNo = this.normalizeBuNo(item && item.buNo ? item.buNo : '', this.$store.state.user.site) |
|||
if (!buNo) { |
|||
return |
|||
} |
|||
const processOrderCodes = this.getValidProcessOrderCodes(item.processOrderCodes) |
|||
const processCodes = this.getValidProcessCodes(item.processCodes, processOrderCodes) |
|||
const showAll = item && item.showAll === true |
|||
? true |
|||
: processCodes.length >= processOrderCodes.length |
|||
const selectedCodeMap = {} |
|||
processCodes.forEach(code => { |
|||
selectedCodeMap[code] = true |
|||
}) |
|||
const processCategoryMap = {} |
|||
const sourceCategoryMap = item && item.processCategoryMap && typeof item.processCategoryMap === 'object' |
|||
? item.processCategoryMap |
|||
: {} |
|||
const processCategoryNameMap = {} |
|||
const sourceCategoryNameMap = item && item.processCategoryNameMap && typeof item.processCategoryNameMap === 'object' |
|||
? item.processCategoryNameMap |
|||
: {} |
|||
Object.keys(sourceCategoryNameMap).forEach(rawCategoryCode => { |
|||
const categoryCode = rawCategoryCode == null ? '' : String(rawCategoryCode).trim() |
|||
const categoryName = sourceCategoryNameMap[rawCategoryCode] == null |
|||
? '' |
|||
: String(sourceCategoryNameMap[rawCategoryCode]).trim() |
|||
if (!categoryCode || !categoryName) { |
|||
return |
|||
} |
|||
processCategoryNameMap[categoryCode] = categoryName |
|||
processCategoryNameMap[categoryCode.toLowerCase()] = categoryName |
|||
}) |
|||
processOrderCodes.forEach(code => { |
|||
if (!code) { |
|||
return |
|||
} |
|||
const directVal = sourceCategoryMap[code] |
|||
if (directVal != null) { |
|||
processCategoryMap[code] = String(directVal).trim() |
|||
return |
|||
} |
|||
const lowerCode = String(code).trim().toLowerCase() |
|||
const matchedKey = Object.keys(sourceCategoryMap).find(rawCode => { |
|||
return String(rawCode).trim().toLowerCase() === lowerCode |
|||
}) |
|||
processCategoryMap[code] = matchedKey ? String(sourceCategoryMap[matchedKey] || '').trim() : '' |
|||
}) |
|||
nextMap[buNo] = { |
|||
showAll: showAll, |
|||
processOrderCodes: processOrderCodes, |
|||
processCodes: showAll ? processOrderCodes.slice() : processOrderCodes.filter(code => selectedCodeMap[code]), |
|||
processCategoryMap: processCategoryMap, |
|||
processCategoryNameMap: processCategoryNameMap |
|||
} |
|||
}) |
|||
this.mergeProcessCodeLabelMapByObject(processLabelMap) |
|||
this.buProcessConfigMap = nextMap |
|||
this.ensureBuProcessConfigRows() |
|||
this.loadAllBuProcessCategoryOptions(this.buProcessConfigRows, true) |
|||
this.refreshTrackingTableLayout() |
|||
}).catch(() => { |
|||
this.$message.error('加载事业部进度展示配置异常') |
|||
}) |
|||
}, |
|||
ensureBuProcessConfigRows () { |
|||
const allCodes = this.getAllProcessCodes() |
|||
const builtinCodeMap = {} |
|||
DEFAULT_PROCESS_COLUMNS.forEach(item => { |
|||
if (item && item.code) { |
|||
builtinCodeMap[item.code] = true |
|||
} |
|||
}) |
|||
const defaultSelectedCodes = allCodes.filter(code => !!builtinCodeMap[code]) |
|||
const rows = [] |
|||
const usedBuMap = {} |
|||
const appendRow = (buNo, buDesc, site) => { |
|||
const key = this.normalizeBuNo(buNo, site || this.$store.state.user.site) |
|||
if (!key || usedBuMap[key]) { |
|||
return |
|||
} |
|||
usedBuMap[key] = true |
|||
const cfg = this.buProcessConfigMap[key] |
|||
const row = { |
|||
buNo: key, |
|||
buDesc: buDesc || key, |
|||
processOrderCodes: allCodes.slice(), |
|||
// 新增默认工序默认不勾选:仅预勾选系统内置工序,自定义新增项需事业部手工勾选。
|
|||
processCodes: (defaultSelectedCodes.length > 0 ? defaultSelectedCodes : allCodes).slice(), |
|||
processCategoryMap: {} |
|||
} |
|||
if (cfg) { |
|||
const validOrderCodes = this.getValidProcessOrderCodes(cfg.processOrderCodes) |
|||
row.processOrderCodes = validOrderCodes |
|||
const validCodes = this.getValidProcessCodes(cfg.processCodes, validOrderCodes) |
|||
if (validCodes.length > 0) { |
|||
const selectedCodeMap = {} |
|||
validCodes.forEach(code => { |
|||
selectedCodeMap[code] = true |
|||
}) |
|||
row.processCodes = validOrderCodes.filter(code => selectedCodeMap[code]) |
|||
} else { |
|||
const defaultSelectedCodeMap = {} |
|||
row.processCodes.forEach(code => { |
|||
defaultSelectedCodeMap[code] = true |
|||
}) |
|||
row.processCodes = validOrderCodes.filter(code => defaultSelectedCodeMap[code]) |
|||
} |
|||
row.processCategoryMap = cfg.processCategoryMap && typeof cfg.processCategoryMap === 'object' |
|||
? Object.assign({}, cfg.processCategoryMap) |
|||
: {} |
|||
} |
|||
row.processCategoryMap = this.normalizeProcessCategoryMapForRow(row) |
|||
rows.push(row) |
|||
} |
|||
this.userBuList.forEach(item => { |
|||
if (!item || !item.buNo) { |
|||
return |
|||
} |
|||
appendRow(item.buNo, item.buDesc || this.normalizeBuNo(item.buNo, this.$store.state.user.site), this.$store.state.user.site) |
|||
}) |
|||
Object.keys(this.buProcessConfigMap).forEach(buNo => { |
|||
appendRow(buNo, buNo, this.$store.state.user.site) |
|||
}) |
|||
this.buProcessConfigRows = rows |
|||
}, |
|||
openBuProcessConfigDialog () { |
|||
if (this.buProcessConfigLoading) { |
|||
return |
|||
} |
|||
this.buProcessConfigLoading = true |
|||
this.processOrderDragState = { |
|||
buNo: '', |
|||
fromIndex: -1 |
|||
} |
|||
// 每次打开都强制拉取后端最新配置,避免必须整页刷新才能看到变更。
|
|||
Promise.all([ |
|||
this.queryProcessColumns(), |
|||
this.queryBuProcessConfig() |
|||
]).finally(() => { |
|||
this.ensureBuProcessConfigRows() |
|||
this.buProcessConfigDialogVisible = true |
|||
this.loadAllBuProcessCategoryOptions(this.buProcessConfigRows, false).finally(() => { |
|||
this.buProcessConfigLoading = false |
|||
}) |
|||
}) |
|||
}, |
|||
buildDefaultProcessConfigRow (item) { |
|||
const parsedSortNo = parseInt(item && item.sortNo, 10) |
|||
const activeFlag = item && item.activeFlag ? String(item.activeFlag).trim().toUpperCase() : 'Y' |
|||
const code = item && item.code ? String(item.code).trim() : '' |
|||
return { |
|||
_rowKey: `default_process_${Date.now()}_${this.defaultProcessConfigRowSeed++}`, |
|||
// 记录后端原始编码,删除时可避免“修改了编码但尚未保存”导致删不到原记录。
|
|||
_persistedCode: code, |
|||
sortNo: Number.isNaN(parsedSortNo) || parsedSortNo <= 0 ? this.getNextDefaultProcessSortNo() : parsedSortNo, |
|||
code: code, |
|||
label: item && item.label ? String(item.label).trim() : '', |
|||
activeFlag: activeFlag === 'N' ? 'N' : 'Y' |
|||
} |
|||
}, |
|||
getNextDefaultProcessSortNo () { |
|||
if (!Array.isArray(this.defaultProcessConfigRows) || this.defaultProcessConfigRows.length === 0) { |
|||
return 10 |
|||
} |
|||
let maxSortNo = 0 |
|||
this.defaultProcessConfigRows.forEach(row => { |
|||
const parsedSortNo = parseInt(row && row.sortNo, 10) |
|||
if (!Number.isNaN(parsedSortNo) && parsedSortNo > maxSortNo) { |
|||
maxSortNo = parsedSortNo |
|||
} |
|||
}) |
|||
return maxSortNo > 0 ? maxSortNo + 10 : (this.defaultProcessConfigRows.length + 1) * 10 |
|||
}, |
|||
resetDefaultProcessConfigSortNoByOrder () { |
|||
if (!Array.isArray(this.defaultProcessConfigRows)) { |
|||
return |
|||
} |
|||
this.defaultProcessConfigRows.forEach((row, index) => { |
|||
if (!row) { |
|||
return |
|||
} |
|||
this.$set(row, 'sortNo', (index + 1) * 10) |
|||
}) |
|||
}, |
|||
clearDefaultProcessConfigSelection () { |
|||
this.defaultProcessConfigSelectionRows = [] |
|||
this.$nextTick(() => { |
|||
const tableRef = this.$refs.defaultProcessConfigTable |
|||
if (tableRef && tableRef.clearSelection) { |
|||
tableRef.clearSelection() |
|||
} |
|||
}) |
|||
}, |
|||
destroyDefaultProcessConfigSortable () { |
|||
if (this.defaultProcessConfigSortable && typeof this.defaultProcessConfigSortable.destroy === 'function') { |
|||
this.defaultProcessConfigSortable.destroy() |
|||
} |
|||
this.defaultProcessConfigSortable = null |
|||
}, |
|||
initDefaultProcessConfigSortable () { |
|||
this.$nextTick(() => { |
|||
this.destroyDefaultProcessConfigSortable() |
|||
if (!this.defaultProcessConfigDialogVisible || !Array.isArray(this.defaultProcessConfigRows) || this.defaultProcessConfigRows.length === 0) { |
|||
return |
|||
} |
|||
const tableRef = this.$refs.defaultProcessConfigTable |
|||
const tableBody = tableRef && tableRef.$el |
|||
? tableRef.$el.querySelector('.el-table__body-wrapper tbody') |
|||
: null |
|||
if (!tableBody) { |
|||
return |
|||
} |
|||
this.defaultProcessConfigSortable = Sortable.create(tableBody, { |
|||
animation: 150, |
|||
// 整行可拖拽,避免必须精确悬浮到小图标才能排序。
|
|||
handle: 'tr', |
|||
draggable: 'tr', |
|||
ghostClass: 'default-process-sortable-ghost', |
|||
chosenClass: 'default-process-sortable-chosen', |
|||
dragClass: 'default-process-sortable-drag', |
|||
onEnd: (evt) => { |
|||
const oldIndex = evt && typeof evt.oldIndex === 'number' ? evt.oldIndex : -1 |
|||
const newIndex = evt && typeof evt.newIndex === 'number' ? evt.newIndex : -1 |
|||
if (oldIndex < 0 || newIndex < 0 || oldIndex === newIndex) { |
|||
return |
|||
} |
|||
const movedRow = this.defaultProcessConfigRows.splice(oldIndex, 1)[0] |
|||
this.defaultProcessConfigRows.splice(newIndex, 0, movedRow) |
|||
this.resetDefaultProcessConfigSortNoByOrder() |
|||
this.clearDefaultProcessConfigSelection() |
|||
} |
|||
}) |
|||
}) |
|||
}, |
|||
handleDefaultProcessConfigDialogClosed () { |
|||
this.defaultProcessConfigDeleteLoading = false |
|||
this.clearDefaultProcessConfigSelection() |
|||
this.destroyDefaultProcessConfigSortable() |
|||
}, |
|||
handleDefaultProcessConfigSelectionChange (rows) { |
|||
this.defaultProcessConfigSelectionRows = Array.isArray(rows) ? rows : [] |
|||
}, |
|||
normalizeDefaultProcessFieldBaseByCode (code) { |
|||
const rawCode = code == null ? '' : String(code).trim() |
|||
if (!rawCode) { |
|||
return '' |
|||
} |
|||
if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(rawCode)) { |
|||
return rawCode |
|||
} |
|||
const parts = rawCode.split(/[^A-Za-z0-9]+/).filter(item => !!item) |
|||
if (parts.length === 0) { |
|||
return '' |
|||
} |
|||
const firstPart = parts[0].toLowerCase() |
|||
const remained = parts.slice(1).map(item => { |
|||
const lower = item.toLowerCase() |
|||
return `${lower.charAt(0).toUpperCase()}${lower.substring(1)}` |
|||
}).join('') |
|||
let fieldBase = `${firstPart}${remained}` |
|||
if (/^[0-9]/.test(fieldBase)) { |
|||
fieldBase = `p${fieldBase}` |
|||
} |
|||
return fieldBase |
|||
}, |
|||
buildDefaultProcessFieldsByCode (code) { |
|||
const fieldBase = this.normalizeDefaultProcessFieldBaseByCode(code) |
|||
if (!fieldBase) { |
|||
return { |
|||
planField: '', |
|||
actualField: '', |
|||
statusField: '' |
|||
} |
|||
} |
|||
return { |
|||
planField: `${fieldBase}PlanDate`, |
|||
actualField: `${fieldBase}ActualDate`, |
|||
statusField: `${fieldBase}Status` |
|||
} |
|||
}, |
|||
queryDefaultProcessConfig () { |
|||
const inData = { |
|||
site: '*', |
|||
buNo: '*', |
|||
userName: this.$store.state.user.name |
|||
} |
|||
return queryProofTrackingProcessColumnsManage(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '加载默认工序配置失败') |
|||
this.defaultProcessConfigRows = [] |
|||
this.defaultProcessConfigSelectionRows = [] |
|||
return [] |
|||
} |
|||
const rows = Array.isArray(data.rows) ? data.rows : [] |
|||
const sortedRows = rows |
|||
.map((item, index) => { |
|||
const parsedSortNo = parseInt(item && item.sortNo, 10) |
|||
return { |
|||
sourceIndex: index, |
|||
sortNo: Number.isNaN(parsedSortNo) ? Number.MAX_SAFE_INTEGER : parsedSortNo, |
|||
item: item |
|||
} |
|||
}) |
|||
.sort((a, b) => { |
|||
if (a.sortNo !== b.sortNo) { |
|||
return a.sortNo - b.sortNo |
|||
} |
|||
return a.sourceIndex - b.sourceIndex |
|||
}) |
|||
this.defaultProcessConfigRows = sortedRows.map(({ item }) => this.buildDefaultProcessConfigRow(item)) |
|||
this.resetDefaultProcessConfigSortNoByOrder() |
|||
this.clearDefaultProcessConfigSelection() |
|||
this.initDefaultProcessConfigSortable() |
|||
return this.defaultProcessConfigRows |
|||
}).catch(() => { |
|||
this.$message.error('加载默认工序配置异常') |
|||
this.defaultProcessConfigRows = [] |
|||
this.defaultProcessConfigSelectionRows = [] |
|||
this.destroyDefaultProcessConfigSortable() |
|||
return [] |
|||
}) |
|||
}, |
|||
openDefaultProcessConfigDialog () { |
|||
this.defaultProcessConfigDeleteLoading = false |
|||
this.defaultProcessConfigDialogVisible = true |
|||
this.queryDefaultProcessConfig() |
|||
}, |
|||
buildProcessCategoryRow (item) { |
|||
const parsedSortNo = parseInt(item && item.sortNo, 10) |
|||
const categoryCode = item && item.categoryCode ? String(item.categoryCode).trim() : '' |
|||
return { |
|||
_rowKey: `process_category_${Date.now()}_${this.processCategoryRowSeed++}`, |
|||
_persistedCode: categoryCode, |
|||
sortNo: Number.isNaN(parsedSortNo) || parsedSortNo <= 0 ? (this.processCategoryRows.length + 1) * 10 : parsedSortNo, |
|||
categoryCode: categoryCode, |
|||
categoryName: item && item.categoryName ? String(item.categoryName).trim() : '' |
|||
} |
|||
}, |
|||
queryProcessCategoryConfig (buNo, silent = false) { |
|||
const normalizedBuNo = this.normalizeBuNo(buNo, this.$store.state.user.site) |
|||
if (!normalizedBuNo) { |
|||
return Promise.resolve([]) |
|||
} |
|||
const inData = { |
|||
site: this.$store.state.user.site, |
|||
buNo: normalizedBuNo, |
|||
userName: this.$store.state.user.name |
|||
} |
|||
return queryProofTrackingProcessCategories(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
if (!silent) { |
|||
this.$message.error((data && data.msg) || '加载工序分类失败') |
|||
} |
|||
this.processCategoryRows = [] |
|||
this.processCategorySelectionRows = [] |
|||
this.$set(this.buProcessCategoryOptionsMap, normalizedBuNo, []) |
|||
if (this.buProcessConfigMap && this.buProcessConfigMap[normalizedBuNo]) { |
|||
this.$set(this.buProcessConfigMap, normalizedBuNo, Object.assign({}, this.buProcessConfigMap[normalizedBuNo], { |
|||
processCategoryNameMap: {} |
|||
})) |
|||
} |
|||
return [] |
|||
} |
|||
const rows = Array.isArray(data.rows) ? data.rows : [] |
|||
const categoryOptions = this.buildProcessCategoryOptionsByRows(rows) |
|||
this.$set(this.buProcessCategoryOptionsMap, normalizedBuNo, categoryOptions) |
|||
if (this.buProcessConfigMap && this.buProcessConfigMap[normalizedBuNo]) { |
|||
const processCategoryNameMap = {} |
|||
categoryOptions.forEach(item => { |
|||
const categoryCode = item && item.categoryCode ? String(item.categoryCode).trim() : '' |
|||
const categoryName = item && item.categoryName ? String(item.categoryName).trim() : '' |
|||
if (!categoryCode || !categoryName) { |
|||
return |
|||
} |
|||
processCategoryNameMap[categoryCode] = categoryName |
|||
processCategoryNameMap[categoryCode.toLowerCase()] = categoryName |
|||
}) |
|||
this.$set(this.buProcessConfigMap, normalizedBuNo, Object.assign({}, this.buProcessConfigMap[normalizedBuNo], { |
|||
processCategoryNameMap: processCategoryNameMap |
|||
})) |
|||
} |
|||
const sortedRows = rows |
|||
.map((item, index) => { |
|||
const parsedSortNo = parseInt(item && item.sortNo, 10) |
|||
return { |
|||
sourceIndex: index, |
|||
sortNo: Number.isNaN(parsedSortNo) ? Number.MAX_SAFE_INTEGER : parsedSortNo, |
|||
item: item |
|||
} |
|||
}) |
|||
.sort((a, b) => { |
|||
if (a.sortNo !== b.sortNo) { |
|||
return a.sortNo - b.sortNo |
|||
} |
|||
return a.sourceIndex - b.sourceIndex |
|||
}) |
|||
this.processCategoryRows = sortedRows.map(({ item }) => this.buildProcessCategoryRow(item)) |
|||
this.processCategorySelectionRows = [] |
|||
return this.processCategoryRows |
|||
}).catch(() => { |
|||
if (!silent) { |
|||
this.$message.error('加载工序分类异常') |
|||
} |
|||
this.processCategoryRows = [] |
|||
this.processCategorySelectionRows = [] |
|||
this.$set(this.buProcessCategoryOptionsMap, normalizedBuNo, []) |
|||
if (this.buProcessConfigMap && this.buProcessConfigMap[normalizedBuNo]) { |
|||
this.$set(this.buProcessConfigMap, normalizedBuNo, Object.assign({}, this.buProcessConfigMap[normalizedBuNo], { |
|||
processCategoryNameMap: {} |
|||
})) |
|||
} |
|||
return [] |
|||
}) |
|||
}, |
|||
openProcessCategoryDialog (row) { |
|||
const buNo = this.normalizeBuNo(row && row.buNo ? row.buNo : '', this.$store.state.user.site) |
|||
if (!buNo) { |
|||
this.$message.warning('请在事业部进度设置中指定事业部后再维护分类') |
|||
return |
|||
} |
|||
this.processCategoryDialogBuNo = buNo |
|||
this.processCategoryDialogBuDesc = row && row.buDesc ? row.buDesc : buNo |
|||
this.processCategoryDialogVisible = true |
|||
this.processCategorySaveLoading = false |
|||
this.queryProcessCategoryConfig(buNo) |
|||
}, |
|||
handleProcessCategoryDialogClosed () { |
|||
this.processCategoryRows = [] |
|||
this.processCategorySelectionRows = [] |
|||
this.processCategoryDialogBuNo = '' |
|||
this.processCategoryDialogBuDesc = '' |
|||
this.processCategorySaveLoading = false |
|||
}, |
|||
handleProcessCategorySelectionChange (rows) { |
|||
this.processCategorySelectionRows = Array.isArray(rows) ? rows : [] |
|||
}, |
|||
addProcessCategoryRow () { |
|||
this.processCategoryRows.push(this.buildProcessCategoryRow({ |
|||
sortNo: (this.processCategoryRows.length + 1) * 10 |
|||
})) |
|||
}, |
|||
deleteProcessCategoryRows () { |
|||
if (!Array.isArray(this.processCategorySelectionRows) || this.processCategorySelectionRows.length === 0) { |
|||
this.$message.warning('请先勾选要删除的分类') |
|||
return |
|||
} |
|||
const selectedRows = this.processCategorySelectionRows.slice() |
|||
this.$confirm(`确认删除选中的 ${selectedRows.length} 条分类吗?`, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
const selectedKeyMap = {} |
|||
selectedRows.forEach(item => { |
|||
if (item && item._rowKey) { |
|||
selectedKeyMap[item._rowKey] = true |
|||
} |
|||
}) |
|||
const nextRows = this.processCategoryRows.filter(item => !(item && selectedKeyMap[item._rowKey])) |
|||
const submitRows = this.normalizeProcessCategoryRowsForSave(nextRows) |
|||
if (!submitRows) { |
|||
return |
|||
} |
|||
const inData = { |
|||
site: this.$store.state.user.site, |
|||
buNo: this.processCategoryDialogBuNo, |
|||
updateBy: this.$store.state.user.name, |
|||
rows: submitRows |
|||
} |
|||
this.processCategorySaveLoading = true |
|||
saveProofTrackingProcessCategoriesManage(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '删除工序分类失败') |
|||
return |
|||
} |
|||
this.handleProcessCategoryConfigSaved(data.msg || '删除成功') |
|||
}).catch(() => { |
|||
this.$message.error('删除工序分类异常') |
|||
}).finally(() => { |
|||
this.processCategorySaveLoading = false |
|||
}) |
|||
}).catch(() => { |
|||
// 用户取消删除时无需额外提示。
|
|||
}) |
|||
}, |
|||
normalizeProcessCategoryRowsForSave (sourceRowsInput) { |
|||
const sourceRows = Array.isArray(sourceRowsInput) |
|||
? sourceRowsInput |
|||
: (Array.isArray(this.processCategoryRows) ? this.processCategoryRows : []) |
|||
const normalizedRows = [] |
|||
const usedNameMap = {} |
|||
for (let i = 0; i < sourceRows.length; i++) { |
|||
const row = sourceRows[i] || {} |
|||
const rowNo = i + 1 |
|||
const categoryCode = row.categoryCode == null ? '' : String(row.categoryCode).trim() |
|||
const categoryName = row.categoryName == null ? '' : String(row.categoryName).trim() |
|||
if (!categoryName) { |
|||
this.$message.warning(`第${rowNo}行的分类名称不能为空`) |
|||
return null |
|||
} |
|||
const nameKey = categoryName.toLowerCase() |
|||
if (usedNameMap[nameKey]) { |
|||
this.$message.warning(`分类名称【${categoryName}】重复,请检查`) |
|||
return null |
|||
} |
|||
usedNameMap[nameKey] = true |
|||
normalizedRows.push({ |
|||
// 旧分类携带隐藏编码回传,便于后端识别“保留/新增/删除”并做使用校验。
|
|||
categoryCode: categoryCode || null, |
|||
categoryName: categoryName, |
|||
sortNo: rowNo * 10 |
|||
}) |
|||
} |
|||
return normalizedRows |
|||
}, |
|||
handleProcessCategoryConfigSaved (successMsg) { |
|||
this.$message.success(successMsg || '工序分类已保存') |
|||
this.queryProcessCategoryConfig(this.processCategoryDialogBuNo, true).then(() => { |
|||
const buNo = this.processCategoryDialogBuNo |
|||
const validCategoryCodeMap = {} |
|||
this.getProcessCategoryOptionsByBuNo(buNo).forEach(item => { |
|||
if (item && item.categoryCode) { |
|||
validCategoryCodeMap[String(item.categoryCode).trim()] = true |
|||
} |
|||
}) |
|||
this.buProcessConfigRows.forEach(configRow => { |
|||
const rowBuNo = this.normalizeBuNo(configRow && configRow.buNo ? configRow.buNo : '', this.$store.state.user.site) |
|||
if (!rowBuNo || rowBuNo !== buNo) { |
|||
return |
|||
} |
|||
const nextCategoryMap = this.normalizeProcessCategoryMapForRow(configRow) |
|||
Object.keys(nextCategoryMap).forEach(processCode => { |
|||
const categoryCode = nextCategoryMap[processCode] |
|||
if (!categoryCode || validCategoryCodeMap[categoryCode]) { |
|||
return |
|||
} |
|||
nextCategoryMap[processCode] = '' |
|||
}) |
|||
this.$set(configRow, 'processCategoryMap', nextCategoryMap) |
|||
}) |
|||
this.queryProcessColumns().then(() => { |
|||
this.refreshTrackingTableLayout() |
|||
}) |
|||
}) |
|||
}, |
|||
saveProcessCategoryConfig () { |
|||
const submitRows = this.normalizeProcessCategoryRowsForSave() |
|||
if (!submitRows) { |
|||
return |
|||
} |
|||
const inData = { |
|||
site: this.$store.state.user.site, |
|||
buNo: this.processCategoryDialogBuNo, |
|||
updateBy: this.$store.state.user.name, |
|||
rows: submitRows |
|||
} |
|||
this.processCategorySaveLoading = true |
|||
saveProofTrackingProcessCategoriesManage(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '工序分类保存失败') |
|||
return |
|||
} |
|||
this.handleProcessCategoryConfigSaved(data.msg || '工序分类已保存') |
|||
}).catch(() => { |
|||
this.$message.error('工序分类保存异常') |
|||
}).finally(() => { |
|||
this.processCategorySaveLoading = false |
|||
}) |
|||
}, |
|||
addDefaultProcessConfigRow () { |
|||
this.defaultProcessConfigRows.push(this.buildDefaultProcessConfigRow({ |
|||
sortNo: this.getNextDefaultProcessSortNo(), |
|||
activeFlag: 'Y' |
|||
})) |
|||
this.resetDefaultProcessConfigSortNoByOrder() |
|||
this.initDefaultProcessConfigSortable() |
|||
}, |
|||
deleteDefaultProcessConfigRow () { |
|||
if (!this.defaultProcessConfigSelectionRows || this.defaultProcessConfigSelectionRows.length === 0) { |
|||
this.$message.warning('请先勾选要删除的行') |
|||
return |
|||
} |
|||
const selectedRows = this.defaultProcessConfigSelectionRows.slice() |
|||
this.$confirm(`确认删除选中的 ${selectedRows.length} 条默认工序吗?`, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
const selectedKeyMap = {} |
|||
const persistedCodeMap = {} |
|||
selectedRows.forEach(item => { |
|||
if (item && item._rowKey) { |
|||
selectedKeyMap[item._rowKey] = true |
|||
} |
|||
const persistedCode = item && item._persistedCode ? String(item._persistedCode).trim() : '' |
|||
const persistedCodeKey = persistedCode.toLowerCase() |
|||
if (persistedCode && !persistedCodeMap[persistedCodeKey]) { |
|||
persistedCodeMap[persistedCodeKey] = persistedCode |
|||
} |
|||
}) |
|||
const nextRows = this.defaultProcessConfigRows.filter(row => { |
|||
return !(row && row._rowKey && selectedKeyMap[row._rowKey]) |
|||
}) |
|||
const applyDeletedRowsToUi = () => { |
|||
this.defaultProcessConfigRows = nextRows |
|||
this.resetDefaultProcessConfigSortNoByOrder() |
|||
this.clearDefaultProcessConfigSelection() |
|||
this.initDefaultProcessConfigSortable() |
|||
} |
|||
const persistedCodes = Object.keys(persistedCodeMap).map(key => persistedCodeMap[key]) |
|||
if (persistedCodes.length === 0) { |
|||
applyDeletedRowsToUi() |
|||
this.$message.success('删除成功') |
|||
return |
|||
} |
|||
const inData = { |
|||
site: '*', |
|||
buNo: '*', |
|||
updateBy: this.$store.state.user.name, |
|||
processCodes: persistedCodes |
|||
} |
|||
this.defaultProcessConfigDeleteLoading = true |
|||
deleteProofTrackingProcessColumnsManage(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '删除默认工序失败') |
|||
return |
|||
} |
|||
applyDeletedRowsToUi() |
|||
this.$message.success(data.msg || '删除成功') |
|||
// 删除动作实时落库后立即刷新主列表列定义,避免页面继续展示已删工序。
|
|||
this.queryProcessColumns().then(() => { |
|||
this.queryBuProcessConfig() |
|||
this.getDataList() |
|||
this.refreshTrackingTableLayout() |
|||
}) |
|||
}).catch(() => { |
|||
this.$message.error('删除默认工序异常') |
|||
}).finally(() => { |
|||
this.defaultProcessConfigDeleteLoading = false |
|||
}) |
|||
}).catch(() => { |
|||
// 用户取消删除时无需额外提示。
|
|||
}) |
|||
}, |
|||
normalizeDefaultProcessConfigRowsForSave () { |
|||
const sourceRows = Array.isArray(this.defaultProcessConfigRows) ? this.defaultProcessConfigRows : [] |
|||
const normalizedRows = [] |
|||
const usedCodeMap = {} |
|||
for (let i = 0; i < sourceRows.length; i++) { |
|||
const row = sourceRows[i] || {} |
|||
const rowNo = i + 1 |
|||
const code = row.code == null ? '' : String(row.code).trim() |
|||
const codeKey = code.toLowerCase() |
|||
const label = row.label == null ? '' : String(row.label).trim() |
|||
if (!code) { |
|||
this.$message.warning(`第${rowNo}行的工序编码不能为空`) |
|||
return null |
|||
} |
|||
if (usedCodeMap[codeKey]) { |
|||
this.$message.warning(`工序编码【${code}】重复,请检查`) |
|||
return null |
|||
} |
|||
if (!label) { |
|||
this.$message.warning(`第${rowNo}行的工序名称不能为空`) |
|||
return null |
|||
} |
|||
const fieldData = this.buildDefaultProcessFieldsByCode(code) |
|||
if (!fieldData.planField || !fieldData.actualField || !fieldData.statusField) { |
|||
this.$message.warning(`第${rowNo}行的工序编码格式无法生成字段,请调整编码`) |
|||
return null |
|||
} |
|||
usedCodeMap[codeKey] = true |
|||
normalizedRows.push({ |
|||
code: code, |
|||
label: label, |
|||
planField: fieldData.planField, |
|||
actualField: fieldData.actualField, |
|||
statusField: fieldData.statusField, |
|||
// 用户要求:默认进度设置不维护工序分类。
|
|||
processCategoryCode: null, |
|||
sortNo: rowNo * 10, |
|||
activeFlag: String(row.activeFlag || 'Y').toUpperCase() === 'N' ? 'N' : 'Y' |
|||
}) |
|||
} |
|||
return normalizedRows |
|||
}, |
|||
saveDefaultProcessConfig () { |
|||
const submitRows = this.normalizeDefaultProcessConfigRowsForSave() |
|||
if (!submitRows) { |
|||
return |
|||
} |
|||
const executeSave = () => { |
|||
const inData = { |
|||
site: '*', |
|||
buNo: '*', |
|||
updateBy: this.$store.state.user.name, |
|||
rows: submitRows |
|||
} |
|||
saveProofTrackingProcessColumnsManage(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '默认工序配置保存失败') |
|||
return |
|||
} |
|||
this.$message.success(data.msg || '默认工序配置已保存') |
|||
this.queryDefaultProcessConfig() |
|||
// 保存后刷新页面列定义,确保新增/删除工序立即反映到主表列。
|
|||
this.queryProcessColumns().then(() => { |
|||
this.queryBuProcessConfig() |
|||
this.getDataList() |
|||
this.refreshTrackingTableLayout() |
|||
}) |
|||
}).catch(() => { |
|||
this.$message.error('默认工序配置保存异常') |
|||
}) |
|||
} |
|||
if (submitRows.length === 0) { |
|||
this.$confirm('当前将清空默认工序配置,保存后页面会回退到系统兜底配置,是否继续?', '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
executeSave() |
|||
}).catch(() => { |
|||
// 用户取消清空时无需额外提示。
|
|||
}) |
|||
return |
|||
} |
|||
executeSave() |
|||
}, |
|||
handleBuProcessCodesChange (row) { |
|||
if (!row) { |
|||
return |
|||
} |
|||
const validOrderCodes = this.getValidProcessOrderCodes(row.processOrderCodes) |
|||
const validCodes = this.getValidProcessCodes(row.processCodes, validOrderCodes) |
|||
const selectedCodeMap = {} |
|||
validCodes.forEach(code => { |
|||
selectedCodeMap[code] = true |
|||
}) |
|||
row.processOrderCodes = validOrderCodes |
|||
row.processCodes = validOrderCodes.filter(code => selectedCodeMap[code]) |
|||
row.processCategoryMap = this.normalizeProcessCategoryMapForRow(row) |
|||
}, |
|||
isProcessOrderDraggingItem (row, index) { |
|||
if (!row || index == null) { |
|||
return false |
|||
} |
|||
return this.processOrderDragState.buNo === row.buNo && this.processOrderDragState.fromIndex === index |
|||
}, |
|||
handleProcessOrderDragStart (row, index, event) { |
|||
if (!row || index == null || index < 0) { |
|||
return |
|||
} |
|||
this.processOrderDragState = { |
|||
buNo: row.buNo || '', |
|||
fromIndex: index |
|||
} |
|||
if (event && event.dataTransfer) { |
|||
event.dataTransfer.effectAllowed = 'move' |
|||
} |
|||
}, |
|||
handleProcessOrderDrop (row, targetIndex, event) { |
|||
if (event && event.dataTransfer) { |
|||
event.dataTransfer.dropEffect = 'move' |
|||
} |
|||
if (!row || targetIndex == null || targetIndex < 0) { |
|||
this.handleProcessOrderDragEnd() |
|||
return |
|||
} |
|||
const dragBuNo = this.processOrderDragState.buNo |
|||
const fromIndex = Number(this.processOrderDragState.fromIndex) |
|||
if (!dragBuNo || dragBuNo !== row.buNo || Number.isNaN(fromIndex) || fromIndex < 0) { |
|||
this.handleProcessOrderDragEnd() |
|||
return |
|||
} |
|||
const validOrderCodes = this.getValidProcessOrderCodes(row.processOrderCodes) |
|||
if (fromIndex >= validOrderCodes.length || targetIndex >= validOrderCodes.length) { |
|||
this.handleProcessOrderDragEnd() |
|||
return |
|||
} |
|||
if (fromIndex === targetIndex) { |
|||
this.handleProcessOrderDragEnd() |
|||
return |
|||
} |
|||
const movedCode = validOrderCodes.splice(fromIndex, 1)[0] |
|||
const insertIndex = targetIndex |
|||
validOrderCodes.splice(insertIndex, 0, movedCode) |
|||
row.processOrderCodes = validOrderCodes |
|||
this.handleBuProcessCodesChange(row) |
|||
this.handleProcessOrderDragEnd() |
|||
}, |
|||
handleProcessOrderDragEnd () { |
|||
this.processOrderDragState = { |
|||
buNo: '', |
|||
fromIndex: -1 |
|||
} |
|||
}, |
|||
saveBuProcessConfig () { |
|||
if (!this.buProcessConfigRows || this.buProcessConfigRows.length === 0) { |
|||
this.$message.warning('暂无可配置的事业部') |
|||
return |
|||
} |
|||
const nextMap = {} |
|||
const submitRows = [] |
|||
for (let i = 0; i < this.buProcessConfigRows.length; i++) { |
|||
const row = this.buProcessConfigRows[i] |
|||
const buNo = this.normalizeBuNo(row && row.buNo ? row.buNo : '', this.$store.state.user.site) |
|||
if (!buNo) { |
|||
continue |
|||
} |
|||
const validOrderCodes = this.getValidProcessOrderCodes(row.processOrderCodes) |
|||
const selectedCodeMap = {} |
|||
this.getValidProcessCodes(row.processCodes, validOrderCodes).forEach(code => { |
|||
selectedCodeMap[code] = true |
|||
}) |
|||
const validCodes = validOrderCodes.filter(code => selectedCodeMap[code]) |
|||
if (validCodes.length === 0) { |
|||
this.$message.warning(`事业部【${row.buDesc || buNo}】至少需要选择一个可见进度`) |
|||
return |
|||
} |
|||
const processCategoryMap = this.normalizeProcessCategoryMapForRow(Object.assign({}, row, { |
|||
processOrderCodes: validOrderCodes |
|||
})) |
|||
const processCategoryNameMap = {} |
|||
this.getProcessCategoryOptionsByBuNo(buNo).forEach(item => { |
|||
const categoryCode = item && item.categoryCode ? String(item.categoryCode).trim() : '' |
|||
const categoryName = item && item.categoryName ? String(item.categoryName).trim() : '' |
|||
if (!categoryCode || !categoryName) { |
|||
return |
|||
} |
|||
processCategoryNameMap[categoryCode] = categoryName |
|||
processCategoryNameMap[categoryCode.toLowerCase()] = categoryName |
|||
}) |
|||
const showAll = validCodes.length >= validOrderCodes.length |
|||
nextMap[buNo] = { |
|||
showAll: showAll, |
|||
processOrderCodes: validOrderCodes, |
|||
processCodes: showAll ? validOrderCodes.slice() : validCodes, |
|||
processCategoryMap: processCategoryMap, |
|||
processCategoryNameMap: processCategoryNameMap |
|||
} |
|||
submitRows.push({ |
|||
buNo: buNo, |
|||
showAll: showAll, |
|||
processCodes: validCodes, |
|||
processOrderCodes: validOrderCodes, |
|||
processCategoryMap: processCategoryMap |
|||
}) |
|||
} |
|||
const inData = { |
|||
site: this.$store.state.user.site, |
|||
updateBy: this.$store.state.user.name, |
|||
rows: submitRows |
|||
} |
|||
saveProofTrackingBuProcessConfig(inData).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
this.$message.error((data && data.msg) || '事业部进度展示设置保存失败') |
|||
return |
|||
} |
|||
this.buProcessConfigMap = nextMap |
|||
this.ensureBuProcessConfigRows() |
|||
this.$message.success(data.msg || '事业部进度展示设置已保存') |
|||
// 保存后重新拉取工序列和列表,确保页面立即按最新可见性与顺序刷新。
|
|||
this.queryProcessColumns().then(() => { |
|||
this.getDataList() |
|||
this.refreshTrackingTableLayout() |
|||
}) |
|||
}).catch(() => { |
|||
this.$message.error('事业部进度展示设置保存异常') |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,407 @@ |
|||
// 打样跟踪页 mixin:工序日期编辑、完成/回退、更新工序、完成打样、打样状态、删除
|
|||
import { deleteProofTrackingBatch, finishProofTracking, updateProofTrackingProcess } from '@/api/sampleTracking/sampleTracking' |
|||
|
|||
export default { |
|||
methods: { |
|||
isProcessDateEditing (row, processCol) { |
|||
const editingKey = this.processDateEditingKey |
|||
if (!editingKey) { |
|||
return false |
|||
} |
|||
return this.getProcessCacheKey(row, processCol) === editingKey |
|||
}, |
|||
clearProcessDateEditClickTimer () { |
|||
if (this._processDateEditClickTimer) { |
|||
clearTimeout(this._processDateEditClickTimer) |
|||
this._processDateEditClickTimer = null |
|||
} |
|||
}, |
|||
exitProcessDateEdit () { |
|||
this.processDateEditingKey = '' |
|||
}, |
|||
openProcessDateEditPicker (retried) { |
|||
let picker = this.$refs.processDateEditPicker |
|||
// 工序列是 v-for,Vue2 即使用 v-if 只挂一个,ref 仍可能是数组。
|
|||
if (Array.isArray(picker)) { |
|||
picker = picker.filter(item => item)[0] |
|||
} |
|||
if (!picker) { |
|||
if (!retried) { |
|||
this.$nextTick(() => { |
|||
this.openProcessDateEditPicker(true) |
|||
}) |
|||
} |
|||
return |
|||
} |
|||
if (typeof picker.focus === 'function') { |
|||
picker.focus() |
|||
} |
|||
// 表格单元格内仅 focus 不一定弹出面板,显式打开保证单击即可选日期。
|
|||
picker.pickerVisible = true |
|||
}, |
|||
startProcessDateEdit (row, processCol) { |
|||
if (!row || !processCol || this.isTrackingRowProcessReadonly(row)) { |
|||
return |
|||
} |
|||
const nextKey = this.getProcessCacheKey(row, processCol) |
|||
if (!nextKey) { |
|||
return |
|||
} |
|||
this.hideProcessTooltip() |
|||
this.processDateEditingKey = nextKey |
|||
this.$nextTick(() => { |
|||
this.openProcessDateEditPicker() |
|||
}) |
|||
}, |
|||
handleProcessDateDisplayClick (row, processCol) { |
|||
if (!row || !processCol || this.isTrackingRowProcessReadonly(row)) { |
|||
return |
|||
} |
|||
this.clearProcessDateEditClickTimer() |
|||
// 已完成格才延迟:既要单击改日期,又要双击回退,不能先把日期组件挂上去。
|
|||
if (this.isProcessStatusComplete(row, processCol)) { |
|||
this._processDateEditClickTimer = setTimeout(() => { |
|||
this._processDateEditClickTimer = null |
|||
this.startProcessDateEdit(row, processCol) |
|||
}, 250) |
|||
return |
|||
} |
|||
this.startProcessDateEdit(row, processCol) |
|||
}, |
|||
handleProcessDateDisplayDblClick (row, processCol) { |
|||
this.clearProcessDateEditClickTimer() |
|||
if (this.isProcessStatusComplete(row, processCol)) { |
|||
this.handleProcessDateDoubleClick(row, processCol) |
|||
return |
|||
} |
|||
this.startProcessDateEdit(row, processCol) |
|||
}, |
|||
handleProcessDatePickerBlur () { |
|||
// pickerVisible 变为 false 时才会 blur,日历点选过程中不会把组件卸掉。
|
|||
this.exitProcessDateEdit() |
|||
}, |
|||
handleProcessDateChange (row, processCol, dateVal) { |
|||
if (!row || !processCol) { |
|||
return |
|||
} |
|||
if (this.isTrackingRowProcessReadonly(row)) { |
|||
return |
|||
} |
|||
const actualDate = this.formatDate(dateVal) |
|||
// 业务要求:表格选择日期仅更新日期,不自动改变工序状态(状态由“√”动作控制)。
|
|||
const currentStatus = row[processCol.statusField] ? String(row[processCol.statusField]).trim() : '' |
|||
const nextStatus = currentStatus || '未完成' |
|||
// 只改日期时当前行已回写,不再整表刷新,避免滚动位置和日期编辑态被列表重查清掉。
|
|||
this.updateProcessFromTable(row, processCol, { |
|||
status: nextStatus, |
|||
actualDate: actualDate, |
|||
remark: actualDate ? '表格直接修改实际完成日期(状态不变)' : '表格清空实际完成日期(状态不变)' |
|||
}, true, '', true) |
|||
}, |
|||
markProcessComplete (row, processCol) { |
|||
if (!row || !processCol || this.isProcessStatusComplete(row, processCol)) { |
|||
return |
|||
} |
|||
if (this.isTrackingRowProcessReadonly(row)) { |
|||
return |
|||
} |
|||
// 若用户已手工选择日期,打勾仅改状态,不覆盖已选日期;无日期时才补当天。
|
|||
const currentActualDate = this.formatDate(row[processCol.actualField]) |
|||
const nextActualDate = currentActualDate || this.formatDate(new Date()) |
|||
this.updateProcessFromTable(row, processCol, { |
|||
status: '已完成', |
|||
actualDate: nextActualDate, |
|||
remark: '表格一键完成' |
|||
}, false, '工序已标记为完成') |
|||
}, |
|||
handleProcessDateDoubleClick (row, processCol) { |
|||
if (!row || !processCol || !this.isProcessStatusComplete(row, processCol)) { |
|||
return |
|||
} |
|||
if (this.isTrackingRowProcessReadonly(row) && !this.canRollbackProofingComplete(row, processCol)) { |
|||
return |
|||
} |
|||
// 按页面交互约定:已完成工序允许双击日期输入框进行回退。
|
|||
this.rollbackProcessComplete(row, processCol) |
|||
}, |
|||
rollbackProcessComplete (row, processCol) { |
|||
if (!row || !processCol || !this.isProcessStatusComplete(row, processCol)) { |
|||
return |
|||
} |
|||
const rollbackProofingComplete = this.canRollbackProofingComplete(row, processCol) |
|||
if (this.isTrackingRowProcessReadonly(row) && !rollbackProofingComplete) { |
|||
return |
|||
} |
|||
const currentActualDate = this.formatDate(row[processCol.actualField]) |
|||
const proofingNoText = this.getRollbackProofingNoDisplay(row) |
|||
// Delivery&Package 在“打样完成”状态下的撤回需要同时回退整单状态,提示语单独说明影响范围。
|
|||
const rollbackTip = rollbackProofingComplete |
|||
? `确定撤回打样单(${proofingNoText})的Delivery&Package已完成状态吗?撤回后打样状态恢复为“进行中”。` |
|||
: `确定回退该工序状态为“未完成”吗?打样单号:${proofingNoText}` |
|||
this.$confirm(rollbackTip, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
const rollbackRemark = rollbackProofingComplete |
|||
? '撤回Delivery&Package已完成并回退打样状态' |
|||
: '表格一键回退为未完成' |
|||
const rollbackSuccessMsg = rollbackProofingComplete |
|||
? 'Delivery&Package已撤回,打样状态恢复为进行中' |
|||
: '工序状态已回退为未完成' |
|||
// 仅回退状态,保留当前实际完成日期,避免误回退时丢失用户已维护的日期信息。
|
|||
this.updateProcessFromTable(row, processCol, { |
|||
status: '未完成', |
|||
actualDate: currentActualDate, |
|||
remark: rollbackRemark |
|||
}, false, rollbackSuccessMsg) |
|||
}).catch(() => {}) |
|||
}, |
|||
isDeliveryPackageProcess (processCol) { |
|||
if (!processCol || processCol.code == null) { |
|||
return false |
|||
} |
|||
return String(processCol.code).trim().toLowerCase() === 'deliverypackage' |
|||
}, |
|||
canRollbackProofingComplete (row, processCol) { |
|||
if (!row || !processCol) { |
|||
return false |
|||
} |
|||
if (!this.isProofingFinishedForTrackingStatus(row)) { |
|||
return false |
|||
} |
|||
if (!this.isDeliveryPackageProcess(processCol)) { |
|||
return false |
|||
} |
|||
return this.isProcessStatusComplete(row, processCol) |
|||
}, |
|||
getRollbackProofingNoDisplay (row) { |
|||
if (!row) { |
|||
return '-' |
|||
} |
|||
const proofingNo = row.proofingNo == null ? '' : String(row.proofingNo).trim() |
|||
if (proofingNo) { |
|||
return proofingNo |
|||
} |
|||
if (row.trackingId != null && row.trackingId !== '') { |
|||
return `TrackingID:${row.trackingId}` |
|||
} |
|||
return '-' |
|||
}, |
|||
updateProcessFromTable (row, processCol, processData, silentSuccess, successMsg, skipListRefresh) { |
|||
if (!row || !processCol || !row.trackingId) { |
|||
this.$message.error('工序参数缺失') |
|||
return |
|||
} |
|||
const status = processData && processData.status ? String(processData.status).trim() : '' |
|||
if (!status) { |
|||
this.$message.error('工序状态不能为空') |
|||
return |
|||
} |
|||
const actualDate = processData && processData.actualDate ? this.formatDate(processData.actualDate) : '' |
|||
const inData = { |
|||
trackingId: row.trackingId, |
|||
processCode: processCol.code, |
|||
processName: processCol.label, |
|||
status: status, |
|||
actualDate: actualDate || null, |
|||
remark: processData && processData.remark ? processData.remark : '', |
|||
updateBy: this.$store.state.user.name |
|||
} |
|||
updateProofTrackingProcess(inData).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.updateRowProcessValue(row, processCol, status, actualDate) |
|||
const cacheKey = `${row.trackingId}_${processCol.code}` |
|||
if (this.processHistoryMap[cacheKey]) { |
|||
this.$delete(this.processHistoryMap, cacheKey) |
|||
} |
|||
if (!silentSuccess) { |
|||
this.$message.success(successMsg || '工序更新成功') |
|||
} |
|||
// 改日期只更新当前单元格。打勾、回退仍回查列表,因为状态变化会影响打样状态和派生列。
|
|||
if (!skipListRefresh) { |
|||
this.getDataList() |
|||
} |
|||
} else { |
|||
this.$message.error(data.msg || '工序更新失败') |
|||
this.getDataList() |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error('工序更新异常') |
|||
this.getDataList() |
|||
}) |
|||
}, |
|||
finishProof (row) { |
|||
const current = row || this.currentRow |
|||
if (!current || !current.trackingId) { |
|||
this.$message.warning('请先选择记录') |
|||
return |
|||
} |
|||
this.finishForm = { |
|||
trackingId: current.trackingId, |
|||
actualityDeliveryDate: current.actualityDeliveryDate || this.formatDate(new Date()) |
|||
} |
|||
this.finishDialogVisible = true |
|||
}, |
|||
getNormalizedProofingStatus (row) { |
|||
if (!row || this.isBlankValue(row.proofingStatus)) { |
|||
return '' |
|||
} |
|||
return String(row.proofingStatus).trim() |
|||
}, |
|||
getProofingStatusColor (row) { |
|||
const proofingStatus = this.getNormalizedProofingStatus(row) |
|||
if (proofingStatus === '打样完成') { |
|||
return '#67c23a' |
|||
} |
|||
// 终止/取消/报废不再按进行中的蓝色展示,避免看起来还能继续推进。
|
|||
if (this.proofingStatusChangeOptions.indexOf(proofingStatus) > -1) { |
|||
return '#909399' |
|||
} |
|||
return '#046e97' |
|||
}, |
|||
isProofingClosedStatus (row) { |
|||
return this.isClosedProofingStatusValue(this.getNormalizedProofingStatus(row)) |
|||
}, |
|||
isClosedProofingStatusValue (status) { |
|||
const normalizedStatus = status ? String(status).trim() : '' |
|||
return this.proofingStatusChangeOptions.indexOf(normalizedStatus) > -1 |
|||
}, |
|||
isAllowedOneKeyProofingStatusChange (previousStatus, nextStatus) { |
|||
const previous = previousStatus ? String(previousStatus).trim() : '' |
|||
const next = nextStatus ? String(nextStatus).trim() : '' |
|||
if (!next || next === previous) { |
|||
return true |
|||
} |
|||
if (this.proofingStatusChangeOptions.indexOf(next) > -1) { |
|||
return true |
|||
} |
|||
// 重新打开只允许从终止/取消/报废回到进行中,避免草稿等状态被改成进行中。
|
|||
return next === '进行中' && this.isClosedProofingStatusValue(previous) |
|||
}, |
|||
canDeleteProofStatus (row) { |
|||
return this.deletableProofingStatuses.indexOf(this.getNormalizedProofingStatus(row)) > -1 |
|||
}, |
|||
getProofDeleteRowLabel (row) { |
|||
const proofingNo = row && !this.isBlankValue(row.proofingNo) ? String(row.proofingNo).trim() : '' |
|||
if (proofingNo) { |
|||
return proofingNo |
|||
} |
|||
if (row && row.trackingId) { |
|||
return `ID:${row.trackingId}` |
|||
} |
|||
return '-' |
|||
}, |
|||
showTrackingActionError (message, title) { |
|||
const failMsg = message || '操作失败' |
|||
if (failMsg.indexOf('请先同步') > -1 || failMsg.indexOf('缺少') > -1 || failMsg.length > 80) { |
|||
this.$alert(failMsg, title || '操作未完成', { |
|||
confirmButtonText: '确定' |
|||
}) |
|||
return |
|||
} |
|||
this.$message.error(failMsg) |
|||
}, |
|||
deleteSelectedProofs () { |
|||
if (this.deleteProofLoading) { |
|||
return |
|||
} |
|||
const selectedRows = Array.isArray(this.selectionRows) ? this.selectionRows : [] |
|||
if (selectedRows.length === 0) { |
|||
this.$message.warning('请先勾选要删除的打样记录') |
|||
return |
|||
} |
|||
const invalidRows = [] |
|||
const trackingIdMap = {} |
|||
const trackingIds = [] |
|||
selectedRows.forEach(row => { |
|||
if (!this.canDeleteProofStatus(row)) { |
|||
invalidRows.push(row) |
|||
return |
|||
} |
|||
if (!row || !row.trackingId || trackingIdMap[row.trackingId]) { |
|||
return |
|||
} |
|||
trackingIdMap[row.trackingId] = true |
|||
trackingIds.push(row.trackingId) |
|||
}) |
|||
if (invalidRows.length > 0) { |
|||
const preview = invalidRows.slice(0, 8).map(row => { |
|||
const statusText = this.getNormalizedProofingStatus(row) || '空' |
|||
return `${this.getProofDeleteRowLabel(row)}(${statusText})` |
|||
}).join('、') |
|||
const moreText = invalidRows.length > 8 ? `等${invalidRows.length}条` : '' |
|||
this.$alert( |
|||
`仅草稿、终止、取消、报废状态可以删除。<br/>不允许删除:${preview}${moreText}`, |
|||
'无法删除', |
|||
{ |
|||
confirmButtonText: '确定', |
|||
dangerouslyUseHTMLString: true |
|||
} |
|||
) |
|||
return |
|||
} |
|||
if (trackingIds.length === 0) { |
|||
this.$message.warning('勾选记录缺少打样跟踪ID,无法删除') |
|||
return |
|||
} |
|||
this.$confirm( |
|||
`确认删除选中的 ${trackingIds.length} 条打样记录吗?<br/>删除后不可恢复,且不会删除项目和项目物料。`, |
|||
'提示', |
|||
{ |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning', |
|||
dangerouslyUseHTMLString: true |
|||
} |
|||
).then(() => { |
|||
this.deleteProofLoading = true |
|||
deleteProofTrackingBatch({ |
|||
trackingIds: trackingIds, |
|||
updateBy: this.$store.state.user.name |
|||
}).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.$message.success('打样记录删除成功') |
|||
this.processHistoryMap = {} |
|||
this.resetProcessTooltip() |
|||
this.getDataList() |
|||
return |
|||
} |
|||
this.$message.error((data && data.msg) || '删除打样记录失败') |
|||
}).catch(() => { |
|||
this.$message.error('删除打样记录异常') |
|||
}).finally(() => { |
|||
this.deleteProofLoading = false |
|||
}) |
|||
}).catch(() => {}) |
|||
}, |
|||
submitFinishProof () { |
|||
if (!this.finishForm.trackingId) { |
|||
this.$message.warning('跟踪记录ID不能为空') |
|||
return |
|||
} |
|||
if (!this.finishForm.actualityDeliveryDate) { |
|||
this.$message.warning('请选择实际完成日期') |
|||
return |
|||
} |
|||
this.finishSaveLoading = true |
|||
finishProofTracking({ |
|||
trackingId: this.finishForm.trackingId, |
|||
actualityDeliveryDate: this.finishForm.actualityDeliveryDate, |
|||
updateBy: this.$store.state.user.name |
|||
}).then(({ data }) => { |
|||
this.finishSaveLoading = false |
|||
if (data && data.code === 0) { |
|||
this.$message.success('打样完成成功') |
|||
this.finishDialogVisible = false |
|||
this.getDataList() |
|||
} else { |
|||
this.$message.error(data.msg || '打样完成失败') |
|||
} |
|||
}).catch(() => { |
|||
this.finishSaveLoading = false |
|||
this.$message.error('打样完成异常') |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,373 @@ |
|||
// 打样跟踪页 mixin:工序悬浮提示/历史、工序完成判断、Tracking Status 计算
|
|||
import { queryProofTrackingProcessHistory } from '@/api/sampleTracking/sampleTracking' |
|||
import { DEFAULT_PROCESS_COLUMNS } from '../constants' |
|||
|
|||
export default { |
|||
methods: { |
|||
getProcessCacheKey (row, processCol) { |
|||
if (!row || !processCol || !row.trackingId) { |
|||
return '' |
|||
} |
|||
return `${row.trackingId}_${processCol.code}` |
|||
}, |
|||
resetProcessTooltip () { |
|||
this.processTooltipHoverKey = '' |
|||
this.processTooltip.visible = false |
|||
this.processTooltip.content = '' |
|||
}, |
|||
hideProcessTooltip () { |
|||
this.processTooltip.visible = false |
|||
this.processTooltip.content = '' |
|||
}, |
|||
updateProcessTooltipPosition (event) { |
|||
if (!event) { |
|||
return |
|||
} |
|||
const offsetX = 12 |
|||
const offsetY = 16 |
|||
let left = event.clientX + offsetX |
|||
let top = event.clientY + offsetY |
|||
const maxWidth = 220 |
|||
const maxHeight = 120 |
|||
if (left + maxWidth > window.innerWidth - 8) { |
|||
left = window.innerWidth - maxWidth - 8 |
|||
} |
|||
if (top + maxHeight > window.innerHeight - 8) { |
|||
top = event.clientY - maxHeight - 8 |
|||
} |
|||
this.processTooltip.left = Math.max(8, left) |
|||
this.processTooltip.top = Math.max(8, top) |
|||
}, |
|||
handleProcessTooltipMouseMove (event) { |
|||
if (!this.processTooltip.visible) { |
|||
return |
|||
} |
|||
this.updateProcessTooltipPosition(event) |
|||
}, |
|||
handleProcessTooltipMouseLeave () { |
|||
this.processTooltipHoverKey = '' |
|||
this.hideProcessTooltip() |
|||
}, |
|||
handleProcessTooltipMouseEnter (row, processCol, event) { |
|||
const cacheKey = this.getProcessCacheKey(row, processCol) |
|||
if (!cacheKey) { |
|||
return |
|||
} |
|||
this.processTooltipHoverKey = cacheKey |
|||
this.updateProcessTooltipPosition(event) |
|||
const showTooltip = () => { |
|||
if (this.processTooltipHoverKey !== cacheKey) { |
|||
return |
|||
} |
|||
if (!this.hasProcessHistory(row, processCol)) { |
|||
this.hideProcessTooltip() |
|||
return |
|||
} |
|||
const content = this.getProcessTooltip(row, processCol) |
|||
if (!content) { |
|||
this.hideProcessTooltip() |
|||
return |
|||
} |
|||
this.processTooltip.content = content |
|||
this.processTooltip.visible = true |
|||
} |
|||
if (Object.prototype.hasOwnProperty.call(this.processHistoryMap, cacheKey)) { |
|||
showTooltip() |
|||
return |
|||
} |
|||
this.loadProcessHistory(row, processCol).then(() => { |
|||
showTooltip() |
|||
}) |
|||
}, |
|||
loadProcessHistory (row, processCol) { |
|||
if (!row || !row.trackingId) { |
|||
return Promise.resolve([]) |
|||
} |
|||
const cacheKey = this.getProcessCacheKey(row, processCol) |
|||
if (Object.prototype.hasOwnProperty.call(this.processHistoryMap, cacheKey)) { |
|||
return Promise.resolve(this.processHistoryMap[cacheKey] || []) |
|||
} |
|||
return queryProofTrackingProcessHistory({ |
|||
trackingId: row.trackingId, |
|||
processCode: processCol.code |
|||
}).then(({ data }) => { |
|||
let rows = [] |
|||
if (data && data.code === 0) { |
|||
rows = data.rows || [] |
|||
// Vue2 对对象新增 key 需要使用 $set 才能触发视图更新(tooltip 才会刷新历史列表)
|
|||
this.$set(this.processHistoryMap, cacheKey, rows) |
|||
} |
|||
return rows |
|||
}).catch(() => { |
|||
this.$set(this.processHistoryMap, cacheKey, []) |
|||
return [] |
|||
}) |
|||
}, |
|||
hasProcessHistory (row, processCol) { |
|||
if (!row || !processCol || !row.trackingId) { |
|||
return false |
|||
} |
|||
const cacheKey = `${row.trackingId}_${processCol.code}` |
|||
const rows = this.processHistoryMap[cacheKey] || [] |
|||
return rows.length > 0 |
|||
}, |
|||
getProcessTooltip (row, processCol) { |
|||
if (!row || !processCol) { |
|||
return '' |
|||
} |
|||
const cacheKey = row.trackingId ? `${row.trackingId}_${processCol.code}` : '' |
|||
const rows = this.processHistoryMap[cacheKey] || [] |
|||
|
|||
const dateList = [] |
|||
const pushDate = (dateVal) => { |
|||
const formatted = this.formatDate(dateVal) |
|||
if (!formatted) { |
|||
return |
|||
} |
|||
if (dateList.indexOf(formatted) === -1) { |
|||
dateList.push(formatted) |
|||
} |
|||
} |
|||
|
|||
// 先放当前实际完成日期,再放历史变更日期(实际)
|
|||
pushDate(row[processCol.actualField]) |
|||
rows.forEach(item => { |
|||
pushDate(item.newActualDate) |
|||
pushDate(item.oldActualDate) |
|||
}) |
|||
|
|||
if (dateList.length <= 1) { |
|||
return '' |
|||
} |
|||
// tooltip 只展示历史日期,不展示最近一次日期(当前值)以避免重复。
|
|||
const latestDate = dateList.reduce((max, currentDate) => { |
|||
if (!max || currentDate > max) { |
|||
return currentDate |
|||
} |
|||
return max |
|||
}, '') |
|||
const historyDateList = dateList.filter(item => item !== latestDate) |
|||
if (historyDateList.length === 0) { |
|||
return '' |
|||
} |
|||
return historyDateList.join('\n') |
|||
}, |
|||
isProcessStatusComplete (row, processCol) { |
|||
if (!row || !processCol) { |
|||
return false |
|||
} |
|||
const statusVal = row[processCol.statusField] |
|||
const status = statusVal ? String(statusVal).trim() : '' |
|||
if (!status || status === '未完成' || status === '进行中') { |
|||
return false |
|||
} |
|||
if (status === '已完成' || status === '打样完成') { |
|||
return true |
|||
} |
|||
return status.indexOf('完成') > -1 && status.indexOf('未') === -1 |
|||
}, |
|||
isProcessComplete (row, processCol) { |
|||
if (!row || !processCol) { |
|||
return false |
|||
} |
|||
const statusVal = row[processCol.statusField] |
|||
const status = statusVal ? String(statusVal).trim() : '' |
|||
|
|||
if (!status) { |
|||
// 兼容历史数据:若没有状态但有实际完成日期,也按完成处理
|
|||
return !!this.formatDate(row[processCol.actualField]) |
|||
} |
|||
if (status === '未完成' || status === '进行中') { |
|||
return false |
|||
} |
|||
if (status === '已完成' || status === '打样完成') { |
|||
return true |
|||
} |
|||
return status.indexOf('完成') > -1 && status.indexOf('未') === -1 |
|||
}, |
|||
getTrackingProcessColumnsByRow (row) { |
|||
if (!row) { |
|||
return [] |
|||
} |
|||
const processColumnMap = {} |
|||
const appendProcessColumn = (processCol) => { |
|||
if (!processCol || !processCol.code || processColumnMap[processCol.code]) { |
|||
return |
|||
} |
|||
processColumnMap[processCol.code] = processCol |
|||
} |
|||
this.processColumns.forEach(item => { |
|||
appendProcessColumn(item) |
|||
}) |
|||
// 兜底补齐默认工序元信息,避免配置变化导致状态字段找不到。
|
|||
DEFAULT_PROCESS_COLUMNS.forEach(item => { |
|||
appendProcessColumn(item) |
|||
}) |
|||
|
|||
let orderedCodes = [] |
|||
if (this.getSelectedSearchBuNo()) { |
|||
orderedCodes = this.visibleProcessColumns.map(item => item.code) |
|||
} else { |
|||
const configEntry = this.getBuProcessConfigEntry(row.buNo, row.site) |
|||
const config = configEntry ? configEntry.config : null |
|||
orderedCodes = config && Array.isArray(config.processOrderCodes) && config.processOrderCodes.length > 0 |
|||
? this.getValidProcessOrderCodes(config.processOrderCodes) |
|||
: this.getAllProcessCodes() |
|||
const visibleCodes = this.getProcessVisibleCodesByBuNo(row.buNo, row.site) |
|||
if (visibleCodes) { |
|||
const visibleCodeMap = {} |
|||
visibleCodes.forEach(code => { |
|||
visibleCodeMap[code] = true |
|||
}) |
|||
orderedCodes = orderedCodes.filter(code => visibleCodeMap[code]) |
|||
} |
|||
} |
|||
|
|||
const result = [] |
|||
const usedCodeMap = {} |
|||
orderedCodes.forEach(code => { |
|||
const codeVal = code == null ? '' : String(code).trim() |
|||
if (!codeVal || usedCodeMap[codeVal]) { |
|||
return |
|||
} |
|||
const processCol = processColumnMap[codeVal] |
|||
if (!processCol) { |
|||
return |
|||
} |
|||
usedCodeMap[codeVal] = true |
|||
result.push(processCol) |
|||
}) |
|||
return result |
|||
}, |
|||
getTrackingStatusProcessLabel (row, processCol) { |
|||
if (!row || !processCol) { |
|||
return '' |
|||
} |
|||
const processCategoryName = processCol.processCategoryName == null |
|||
? '' |
|||
: String(processCol.processCategoryName).trim() |
|||
if (processCategoryName) { |
|||
return processCategoryName |
|||
} |
|||
const processCategoryCode = this.getBuProcessCategoryCodeByProcessCode(row.buNo, processCol.code) |
|||
const buCategoryName = this.getBuProcessCategoryNameByCode(row.buNo, processCategoryCode) |
|||
if (buCategoryName) { |
|||
return buCategoryName |
|||
} |
|||
return processCol.label || processCol.code |
|||
}, |
|||
getPendingProcessColumnForTrackingStatus (row) { |
|||
const processColumns = this.getTrackingProcessColumnsByRow(row) |
|||
let firstPendingWithDate = null |
|||
let firstPendingDate = '' |
|||
let firstPendingWithoutDate = null |
|||
for (let i = 0; i < processColumns.length; i += 1) { |
|||
const processCol = processColumns[i] |
|||
if (this.isProcessComplete(row, processCol)) { |
|||
continue |
|||
} |
|||
const actualDate = this.formatDate(row[processCol.actualField]) |
|||
if (!actualDate) { |
|||
// 无日期的未完成工序仅作为兜底:优先展示“有日期的未完成工序”。
|
|||
if (!firstPendingWithoutDate) { |
|||
firstPendingWithoutDate = processCol |
|||
} |
|||
continue |
|||
} |
|||
// 同日期按工序顺序兜底:仅在日期更小时替换,日期相同保留先命中的工序。
|
|||
if (!firstPendingWithDate || actualDate < firstPendingDate) { |
|||
firstPendingWithDate = processCol |
|||
firstPendingDate = actualDate |
|||
} |
|||
} |
|||
return firstPendingWithDate || firstPendingWithoutDate |
|||
}, |
|||
getFirstPendingProcessLabel (row) { |
|||
const processCol = this.getPendingProcessColumnForTrackingStatus(row) |
|||
if (!processCol) { |
|||
return '已全部完成' |
|||
} |
|||
return this.getTrackingStatusProcessLabel(row, processCol) |
|||
}, |
|||
getTrackingPackageDate (row) { |
|||
if (!row) { |
|||
return '' |
|||
} |
|||
const requiredDeliveryDate = this.formatDate(row.requiredDeliveryDate) |
|||
if (requiredDeliveryDate) { |
|||
return requiredDeliveryDate |
|||
} |
|||
// requiredDeliveryDate 与 Delivery&Package 工序日期同一口径,主字段缺失时回退工序实际日期。
|
|||
return this.formatDate(row.deliveryPackageActualDate) |
|||
}, |
|||
getTrackingStatusType (row) { |
|||
if (!row) { |
|||
return '' |
|||
} |
|||
const packageDate = this.getTrackingPackageDate(row) |
|||
// 尚未生成打样单且 Delivery&Package 有值时,才显示准备阶段。
|
|||
if (this.isBlankValue(row.proofingNo) && packageDate) { |
|||
return 'trialPrepare' |
|||
} |
|||
const baseline = this.formatDate(row.baseline) |
|||
// 缺少 package 或 baseline 时无法判定延期,保持空状态由文案函数显示 '-'。
|
|||
if (!packageDate || !baseline) { |
|||
return '' |
|||
} |
|||
// Delay 按 Delivery&Package 相对原计划判定:package 晚于 baseline 即延期,
|
|||
// 不再用“今天 vs 预计完成日期”,避免计划已改期后仍显示 On schedule。
|
|||
if (packageDate > baseline) { |
|||
return 'delay' |
|||
} |
|||
return 'onSchedule' |
|||
}, |
|||
isProofingFinishedForTrackingStatus (row) { |
|||
if (!row || this.isBlankValue(row.proofingStatus)) { |
|||
return false |
|||
} |
|||
const proofingStatus = String(row.proofingStatus).trim() |
|||
// 打样已结束时,Tracking Status 统一收敛为灰色 Complete,避免继续显示进度预警。
|
|||
return proofingStatus === '打样完成' |
|||
}, |
|||
isTrackingRowProcessReadonly (row) { |
|||
// 打样完成,以及终止/取消/报废,都不再允许改工序,避免关闭后仍推进进度。
|
|||
return this.isProofingFinishedForTrackingStatus(row) || this.isProofingClosedStatus(row) |
|||
}, |
|||
getTrackingStatusText (row) { |
|||
if (this.isProofingClosedStatus(row)) { |
|||
return this.getNormalizedProofingStatus(row) |
|||
} |
|||
const statusType = this.getTrackingStatusType(row) |
|||
if (statusType === 'trialPrepare') { |
|||
return 'Trial prepare' |
|||
} |
|||
if (this.isProofingFinishedForTrackingStatus(row)) { |
|||
return 'Complete' |
|||
} |
|||
if (!statusType) { |
|||
return '-' |
|||
} |
|||
const statusPrefix = statusType === 'onSchedule' ? 'On schedule' : 'Delay' |
|||
return `${statusPrefix}-${this.getFirstPendingProcessLabel(row)}` |
|||
}, |
|||
getTrackingStatusClass (row) { |
|||
if (this.isProofingClosedStatus(row)) { |
|||
return 'tracking-status tracking-status--complete' |
|||
} |
|||
const statusType = this.getTrackingStatusType(row) |
|||
if (statusType === 'trialPrepare') { |
|||
return 'tracking-status tracking-status--delay' |
|||
} |
|||
if (this.isProofingFinishedForTrackingStatus(row)) { |
|||
return 'tracking-status tracking-status--complete' |
|||
} |
|||
if (statusType === 'onSchedule') { |
|||
return 'tracking-status tracking-status--on-schedule' |
|||
} |
|||
if (statusType === 'delay') { |
|||
return 'tracking-status tracking-status--delay' |
|||
} |
|||
return 'tracking-status tracking-status--unknown' |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,233 @@ |
|||
// 打样跟踪页 mixin:新增打样弹窗
|
|||
import { createProofTrackingRecord } from '@/api/sampleTracking/sampleTracking' |
|||
|
|||
export default { |
|||
methods: { |
|||
getDefaultProofDialogData () { |
|||
return { |
|||
trackingId: null, |
|||
site: this.$store.state.user.site, |
|||
projectId: null, |
|||
projectNo: '', |
|||
projectDesc: '', |
|||
buNo: '', |
|||
customerNo: '', |
|||
customerDesc: '', |
|||
projectPartId: null, |
|||
testPartNo: '', |
|||
partDesc: '', |
|||
projectCategory: '', |
|||
cProjectTypeDb: '', |
|||
projectPhase: '', |
|||
projectManager: '', |
|||
projectOwner: '', |
|||
engineer: '', |
|||
priorityLevel: '', |
|||
proofingNo: '', |
|||
proofingNumber: '', |
|||
planStartDate: '', |
|||
requiredDeliveryDate: '', |
|||
baseline: '', |
|||
actualityDeliveryDate: '', |
|||
pmInqueryTime: '', |
|||
importance: 'N', |
|||
proofingStatus: '草稿', |
|||
remark: '', |
|||
createBy: this.$store.state.user.name, |
|||
updateBy: this.$store.state.user.name |
|||
} |
|||
}, |
|||
handleProofDialogProofingNoChange (proofingNo) { |
|||
const selectedNo = this.isBlankValue(proofingNo) ? '' : String(proofingNo).trim() |
|||
if (!selectedNo) { |
|||
this.proofDialogData.requiredDeliveryDate = '' |
|||
this.proofDialogData.baseline = '' |
|||
this.proofDialogData.planStartDate = '' |
|||
return |
|||
} |
|||
const matched = this.proofDialogApplyOptions.find(item => item && item.applyNo === selectedNo) |
|||
if (!matched) { |
|||
return |
|||
} |
|||
this.proofDialogData.proofingNo = matched.applyNo |
|||
// 新增打样不带试验单预计完成日期。预计完成日期和 baseline 保持空白,保存时也就不会生成 Delivery&Package。
|
|||
// 打样开始日期仍取工程实验单创建日期;清空打样单时同步清空,避免残留旧单日期。
|
|||
this.proofDialogData.planStartDate = matched.createTime || '' |
|||
}, |
|||
handleProofDialogRequiredDeliveryDateChange (dateVal) { |
|||
this.syncProofDialogBaselineByRequiredDeliveryDate(dateVal, false) |
|||
}, |
|||
syncProofDialogBaselineByRequiredDeliveryDate (requiredDeliveryDate, forceSync) { |
|||
const normalizedRequiredDate = this.formatDate(requiredDeliveryDate) |
|||
if (!normalizedRequiredDate) { |
|||
return |
|||
} |
|||
const normalizedBaseline = this.formatDate(this.proofDialogData.baseline) |
|||
if (forceSync || !normalizedBaseline) { |
|||
// 新增打样时 baseline 首次默认跟随预计完成日期,后续允许用户改写。
|
|||
this.proofDialogData.baseline = normalizedRequiredDate |
|||
} |
|||
}, |
|||
loadProofDialogApplyOptions (projectNo) { |
|||
const normalizedProjectNo = this.normalizeProjectNo(projectNo) |
|||
const queryToken = this.proofDialogApplyQueryToken + 1 |
|||
this.proofDialogApplyQueryToken = queryToken |
|||
if (!normalizedProjectNo) { |
|||
this.proofDialogApplyLoading = false |
|||
this.proofDialogApplyOptions = [] |
|||
this.proofDialogData.proofingNo = '' |
|||
this.proofDialogData.requiredDeliveryDate = '' |
|||
this.proofDialogData.baseline = '' |
|||
this.proofDialogData.planStartDate = '' |
|||
return Promise.resolve([]) |
|||
} |
|||
this.proofDialogApplyLoading = true |
|||
return this.queryApplyOptionsByProjectNo(normalizedProjectNo).then(optionRows => { |
|||
if (queryToken !== this.proofDialogApplyQueryToken) { |
|||
return optionRows |
|||
} |
|||
this.proofDialogApplyOptions = optionRows |
|||
const currentProofingNo = this.isBlankValue(this.proofDialogData.proofingNo) |
|||
? '' |
|||
: String(this.proofDialogData.proofingNo).trim() |
|||
if (currentProofingNo) { |
|||
this.handleProofDialogProofingNoChange(currentProofingNo) |
|||
} |
|||
return optionRows |
|||
}).catch((e) => { |
|||
if (queryToken === this.proofDialogApplyQueryToken) { |
|||
this.proofDialogApplyOptions = [] |
|||
this.$message.error((e && e.message) || '查询试验单异常') |
|||
} |
|||
return [] |
|||
}).finally(() => { |
|||
if (queryToken === this.proofDialogApplyQueryToken) { |
|||
this.proofDialogApplyLoading = false |
|||
} |
|||
}) |
|||
}, |
|||
openCreateProofDialog (row) { |
|||
const current = this.getActionRow(row) |
|||
if (!current) { |
|||
this.$message.warning('请先选择一条记录') |
|||
return |
|||
} |
|||
this.currentRow = current |
|||
const projectPartId = this.getTrackingProjectPartId(current) || current.id |
|||
const projectCategory = this.getProjectCategoryValue(current) |
|||
this.proofDialogApplyQueryToken += 1 |
|||
this.proofDialogApplyLoading = false |
|||
this.proofDialogApplyOptions = [] |
|||
this.proofDialogData = Object.assign(this.getDefaultProofDialogData(), { |
|||
trackingId: null, |
|||
site: current.site || this.$store.state.user.site, |
|||
projectId: current.projectId, |
|||
projectNo: current.projectNo, |
|||
projectDesc: current.projectDesc, |
|||
buNo: current.buNo, |
|||
customerNo: current.customerNo, |
|||
customerDesc: current.customerDesc, |
|||
projectPartId: projectPartId, |
|||
testPartNo: current.testPartNo, |
|||
partDesc: current.partDesc, |
|||
projectCategory: projectCategory, |
|||
cProjectTypeDb: projectCategory, |
|||
projectManager: current.projectManager, |
|||
projectOwner: current.projectOwner, |
|||
engineer: current.engineer, |
|||
priorityLevel: current.priority, |
|||
proofingNo: '', |
|||
proofingNumber: '', |
|||
planStartDate: '', |
|||
requiredDeliveryDate: '', |
|||
baseline: '', |
|||
actualityDeliveryDate: '', |
|||
pmInqueryTime: '', |
|||
importance: 'N', |
|||
proofingStatus: '草稿', |
|||
remark: '', |
|||
createBy: this.$store.state.user.name, |
|||
updateBy: this.$store.state.user.name |
|||
}) |
|||
this.proofDialogVisible = true |
|||
this.loadProofDialogApplyOptions(this.proofDialogData.projectNo) |
|||
}, |
|||
validateProofDialogData () { |
|||
// 新增打样挂在已选物料上,缺少项目或物料主键时无法落跟踪记录。
|
|||
if (!this.proofDialogData.projectId || !this.proofDialogData.projectPartId) { |
|||
this.$message.warning('项目或项目料号信息不完整') |
|||
return false |
|||
} |
|||
if (this.isBlankValue(this.proofDialogData.projectPhase)) { |
|||
this.$message.warning('项目阶段不能为空') |
|||
return false |
|||
} |
|||
// 数量允许留空;一旦填写仍必须是正整数,避免把 0、小数或文本写入打样数量。
|
|||
const proofingNumber = this.proofDialogData.proofingNumber |
|||
if (!this.isBlankValue(proofingNumber) && !/^[1-9]\d*$/.test(String(proofingNumber).trim())) { |
|||
this.$alert('数量必需是大于等于0的正整数', '提示', { |
|||
confirmButtonText: '确定' |
|||
}) |
|||
return false |
|||
} |
|||
return true |
|||
}, |
|||
resolveProofDialogBaseline () { |
|||
const baseline = this.formatDate(this.proofDialogData.baseline) |
|||
if (baseline) { |
|||
return baseline |
|||
} |
|||
// 用户未填 baseline 时,按预计完成日期初始化,与一键创建口径一致。
|
|||
const requiredDeliveryDate = this.formatDate(this.proofDialogData.requiredDeliveryDate) |
|||
return requiredDeliveryDate || null |
|||
}, |
|||
buildProofPayload () { |
|||
return { |
|||
site: this.proofDialogData.site, |
|||
projectId: this.proofDialogData.projectId, |
|||
projectPartId: this.proofDialogData.projectPartId, |
|||
projectNo: this.proofDialogData.projectNo, |
|||
testPartNo: this.proofDialogData.testPartNo, |
|||
customerNo: this.proofDialogData.customerNo, |
|||
buNo: this.proofDialogData.buNo, |
|||
projectCategory: this.isBlankValue(this.proofDialogData.cProjectTypeDb) ? null : this.proofDialogData.cProjectTypeDb, |
|||
projectPhase: this.proofDialogData.projectPhase, |
|||
proofingNo: this.isBlankValue(this.proofDialogData.proofingNo) ? null : String(this.proofDialogData.proofingNo).trim(), |
|||
proofingNumber: this.isBlankValue(this.proofDialogData.proofingNumber) ? null : Number(String(this.proofDialogData.proofingNumber).trim()), |
|||
planStartDate: this.isBlankValue(this.proofDialogData.planStartDate) ? null : this.proofDialogData.planStartDate, |
|||
requiredDeliveryDate: this.isBlankValue(this.proofDialogData.requiredDeliveryDate) ? null : this.proofDialogData.requiredDeliveryDate, |
|||
baseline: this.resolveProofDialogBaseline(), |
|||
actualityDeliveryDate: this.proofDialogData.actualityDeliveryDate || null, |
|||
pmInqueryTime: this.isBlankValue(this.proofDialogData.pmInqueryTime) ? null : this.proofDialogData.pmInqueryTime, |
|||
importance: this.normalizeImportanceValue(this.proofDialogData.importance), |
|||
proofingStatus: this.isBlankValue(this.proofDialogData.proofingStatus) ? null : this.proofDialogData.proofingStatus, |
|||
remark: this.proofDialogData.remark, |
|||
tracker: this.proofDialogData.projectOwner, |
|||
engineer: this.proofDialogData.engineer, |
|||
priorityLevel: this.proofDialogData.priorityLevel, |
|||
createBy: this.$store.state.user.name, |
|||
updateBy: this.$store.state.user.name |
|||
} |
|||
}, |
|||
saveProofRecord () { |
|||
if (!this.validateProofDialogData()) { |
|||
return |
|||
} |
|||
const payload = this.buildProofPayload() |
|||
this.proofSaveLoading = true |
|||
createProofTrackingRecord(payload).then(({ data }) => { |
|||
this.proofSaveLoading = false |
|||
if (data && data.code === 0) { |
|||
this.$message.success(data.msg || '新增打样成功') |
|||
this.proofDialogVisible = false |
|||
this.getDataList() |
|||
} else { |
|||
this.$alert(data && data.msg ? data.msg : '新增打样失败', '错误', { confirmButtonText: '确定' }) |
|||
} |
|||
}).catch(() => { |
|||
this.proofSaveLoading = false |
|||
this.$message.error('新增打样异常') |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,236 @@ |
|||
// 打样跟踪页 mixin:角色选择弹窗、Chooselist 回填、新客户
|
|||
import { getCustomerNo, saveNewCustomer } from '@/api/eam/eamProject.js' |
|||
import { searchBusinessInfo, searchBusinessInfo1, searchBusinessInfo2, searchBusinessInfo3, searchBusinessInfo4, searchBusinessInfo5, searchBusinessInfo6, searchBusinessInfo7, searchBusinessInfo8 } from '@/api/factory/site.js' |
|||
import { queryCustomerList } from '@/api/customer/customer' |
|||
|
|||
export default { |
|||
methods: { |
|||
getRoleApi (apiKey) { |
|||
const apiMap = { |
|||
0: searchBusinessInfo, |
|||
1: searchBusinessInfo1, |
|||
2: searchBusinessInfo2, |
|||
3: searchBusinessInfo3, |
|||
4: searchBusinessInfo4, |
|||
5: searchBusinessInfo5, |
|||
6: searchBusinessInfo6, |
|||
7: searchBusinessInfo7, |
|||
8: searchBusinessInfo8 |
|||
} |
|||
return apiMap[apiKey] |
|||
}, |
|||
fetchRoleListByApiKey (apiKey, queryData) { |
|||
const apiFn = this.getRoleApi(apiKey) |
|||
if (!apiFn) { |
|||
return Promise.resolve([]) |
|||
} |
|||
const params = { |
|||
site: this.$store.state.user.site, |
|||
username: queryData && queryData.username ? queryData.username : '', |
|||
userDisplay: queryData && queryData.userDisplay ? queryData.userDisplay : '', |
|||
roleDesc: '', |
|||
active: queryData && queryData.active ? queryData.active : '', |
|||
page: 1, |
|||
limit: queryData && queryData.limit ? queryData.limit : 200 |
|||
} |
|||
return apiFn(params).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
return (data.rows || []).map(item => { |
|||
return { |
|||
username: item.username, |
|||
userDisplay: item.userDisplay || item.user_display || '', |
|||
active: item.active |
|||
} |
|||
}) |
|||
} |
|||
return [] |
|||
}) |
|||
}, |
|||
getOneKeyCustomerFields (scope) { |
|||
return scope === 'part' |
|||
? { no: 'partCustomerNo', desc: 'partCustomerDesc' } |
|||
: { no: 'customerNo', desc: 'customerDesc' } |
|||
}, |
|||
newCustomer (scope) { |
|||
this.newCustomerScope = scope === 'part' ? 'part' : 'project' |
|||
this.newCustomerData.customerDesc = '' |
|||
this.newCustomerFlag = true |
|||
}, |
|||
getBaseList (val, scope) { |
|||
this.tagNo = val |
|||
this.customerChooserScope = scope === 'part' ? 'part' : 'project' |
|||
this.$nextTick(() => { |
|||
const fields = this.getOneKeyCustomerFields(this.customerChooserScope) |
|||
const strVal = val === 509 ? (this.oneKeyForm[fields.no] || '') : '' |
|||
this.$refs.baseList.init(val, strVal, '') |
|||
}) |
|||
}, |
|||
getRoleFieldByTagNo (tagNo) { |
|||
const numericTag = Number(tagNo) |
|||
const fieldKeys = Object.keys(this.roleConfig || {}) |
|||
for (let i = 0; i < fieldKeys.length; i++) { |
|||
const fieldKey = fieldKeys[i] |
|||
if (Number(this.roleConfig[fieldKey].tagNo) === numericTag) { |
|||
return fieldKey |
|||
} |
|||
} |
|||
return '' |
|||
}, |
|||
buildRoleValueFromChooserRow (row) { |
|||
if (!row) { |
|||
return '' |
|||
} |
|||
const username = row.username || row.user_name || '' |
|||
const userDisplay = row.user_display || row.userDisplay || '' |
|||
if (!username && !userDisplay) { |
|||
return '' |
|||
} |
|||
return username + '-' + userDisplay |
|||
}, |
|||
getBaseData (val) { |
|||
if (this.tagNo === 509) { |
|||
const fields = this.getOneKeyCustomerFields(this.customerChooserScope) |
|||
this.oneKeyForm[fields.no] = val.customer_no |
|||
this.oneKeyForm[fields.desc] = val.customer_desc |
|||
return |
|||
} |
|||
// IQC/SQE/FQC2/IPQC-Hardtag/前道工程师与 NPI 项目页共用 Chooselist 回填规则。
|
|||
const roleField = this.getRoleFieldByTagNo(this.tagNo) |
|||
if (!roleField) { |
|||
return |
|||
} |
|||
this.setOneKeyRoleFieldValue(roleField, this.buildRoleValueFromChooserRow(val)) |
|||
}, |
|||
customerNoBlur (scope) { |
|||
const fields = this.getOneKeyCustomerFields(scope) |
|||
const form = this.oneKeyForm |
|||
const customerNo = form[fields.no] |
|||
if (!customerNo) { |
|||
form[fields.desc] = '' |
|||
return |
|||
} |
|||
const params = { |
|||
customerNo, |
|||
createBy: this.$store.state.user.name |
|||
} |
|||
return queryCustomerList(params).then(({ data }) => { |
|||
// 异步查询返回时只回填原字段,且不覆盖用户后来选择的客户。
|
|||
if (this.oneKeyForm !== form || form[fields.no] !== customerNo) { |
|||
return |
|||
} |
|||
form[fields.desc] = data && data.code === 0 && data.rows && data.rows.length === 1 |
|||
? data.rows[0].customerDesc : '' |
|||
}) |
|||
}, |
|||
saveNewCustomer () { |
|||
if (!this.newCustomerData.customerDesc) { |
|||
this.$message.warning('请输入客户名称!') |
|||
return |
|||
} |
|||
const form = this.oneKeyForm |
|||
const fields = this.getOneKeyCustomerFields(this.newCustomerScope) |
|||
const customerDesc = this.newCustomerData.customerDesc |
|||
return this.generateNextCustomerNo().then(customerNo => { |
|||
if (!customerNo) { |
|||
this.$alert('该客户已存在,请重新输入客户名称!', '提示', { |
|||
confirmButtonText: '确定', |
|||
type: 'warning' |
|||
}) |
|||
return |
|||
} |
|||
const params = { |
|||
site: this.$store.state.user.site, |
|||
customerNo: customerNo, |
|||
customerDesc, |
|||
createBy: this.$store.state.user.name |
|||
} |
|||
return saveNewCustomer(params).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
if (this.oneKeyForm === form) { |
|||
form[fields.no] = customerNo |
|||
form[fields.desc] = customerDesc |
|||
} |
|||
this.newCustomerFlag = false |
|||
this.$message.success(data.msg || '新增客户成功') |
|||
} else { |
|||
this.$alert(data && data.msg ? data.msg : '新增客户失败', '提示', { |
|||
confirmButtonText: '确定', |
|||
type: 'warning' |
|||
}) |
|||
} |
|||
}) |
|||
}) |
|||
}, |
|||
generateNextCustomerNo () { |
|||
const params = { |
|||
site: this.$store.state.user.site, |
|||
customerDesc: this.newCustomerData.customerDesc, |
|||
createBy: this.$store.state.user.name |
|||
} |
|||
return new Promise(resolve => { |
|||
getCustomerNo(params).then(({ data }) => { |
|||
if (!(data && data.code === 0)) { |
|||
resolve(false) |
|||
return |
|||
} |
|||
if (!data.data || !data.data.customerNo || data.data === '0') { |
|||
resolve('C0001') |
|||
return |
|||
} |
|||
const lastCustomerNo = parseInt(String(data.data.customerNo).substring(1), 10) || 0 |
|||
const nextCustomerNo = lastCustomerNo + 1 |
|||
if (nextCustomerNo < 10) { |
|||
resolve('C000' + nextCustomerNo) |
|||
} else if (nextCustomerNo < 100) { |
|||
resolve('C00' + nextCustomerNo) |
|||
} else if (nextCustomerNo < 1000) { |
|||
resolve('C0' + nextCustomerNo) |
|||
} else { |
|||
resolve('C' + nextCustomerNo) |
|||
} |
|||
}).catch(() => { |
|||
resolve(false) |
|||
}) |
|||
}) |
|||
}, |
|||
closeNewCustomer () { |
|||
this.newCustomerData.customerDesc = '' |
|||
this.newCustomerFlag = false |
|||
}, |
|||
openRoleDialog (field) { |
|||
const roleCfg = this.roleConfig[field] |
|||
if (!roleCfg) { |
|||
return |
|||
} |
|||
if (roleCfg.tagNo) { |
|||
this.getBaseList(roleCfg.tagNo) |
|||
return |
|||
} |
|||
this.roleDialogField = field |
|||
this.roleDialogApiKey = roleCfg.apiKey |
|||
this.roleDialogTitle = roleCfg.title |
|||
this.roleSearchData = { |
|||
site: this.$store.state.user.site, |
|||
username: '', |
|||
userDisplay: '', |
|||
active: '', |
|||
page: 1, |
|||
limit: 50 |
|||
} |
|||
this.roleDialogVisible = true |
|||
this.queryRoleDialogList() |
|||
}, |
|||
queryRoleDialogList () { |
|||
this.fetchRoleListByApiKey(this.roleDialogApiKey, this.roleSearchData).then(rows => { |
|||
this.roleDialogList = rows |
|||
}) |
|||
}, |
|||
pickRole (row) { |
|||
if (!this.roleDialogField) { |
|||
return |
|||
} |
|||
this.setOneKeyRoleFieldValue(this.roleDialogField, this.buildRoleValueFromChooserRow(row)) |
|||
this.roleDialogVisible = false |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,301 @@ |
|||
// 打样跟踪页 mixin:列表列配置、列宽保存、单元格显示值与 NPI 跳转。
|
|||
import { getTableUserListLanguage, updateColumnSize, saveTableUser } from '@/api/table.js' |
|||
import { cloneDefaultTrackingColumns } from '../constants' |
|||
|
|||
export default { |
|||
methods: { |
|||
getTrackingColumnFunctionId () { |
|||
return this.$route && this.$route.meta && this.$route.meta.menuId |
|||
? this.$route.meta.menuId |
|||
: '' |
|||
}, |
|||
getTrackingColumnTableId () { |
|||
const functionId = this.getTrackingColumnFunctionId() |
|||
return functionId ? `${functionId}table1` : 'projectProofTrackingTable1' |
|||
}, |
|||
buildDefaultTrackingColumns () { |
|||
const functionId = this.getTrackingColumnFunctionId() |
|||
const tableId = this.getTrackingColumnTableId() |
|||
const userId = this.$store.state.user.name |
|||
return cloneDefaultTrackingColumns().map(item => Object.assign({}, item, { |
|||
userId: userId, |
|||
functionId: functionId, |
|||
tableId: tableId, |
|||
tableName: '项目打样跟踪' |
|||
})) |
|||
}, |
|||
normalizeTrackingColumnWidth (value, fallbackValue) { |
|||
const parsedValue = parseInt(value, 10) |
|||
if (!Number.isNaN(parsedValue) && parsedValue > 0) { |
|||
return parsedValue |
|||
} |
|||
const parsedFallback = parseInt(fallbackValue, 10) |
|||
return !Number.isNaN(parsedFallback) && parsedFallback > 0 ? parsedFallback : 120 |
|||
}, |
|||
normalizeTrackingColumnBoolean (value, fallbackValue) { |
|||
if (value === undefined || value === null || value === '') { |
|||
return fallbackValue |
|||
} |
|||
if (typeof value === 'boolean') { |
|||
return value |
|||
} |
|||
if (typeof value === 'number') { |
|||
return value !== 0 |
|||
} |
|||
const normalizedValue = String(value).trim().toLowerCase() |
|||
if (normalizedValue === 'true' || normalizedValue === '1' || normalizedValue === 'y' || normalizedValue === 'yes') { |
|||
return true |
|||
} |
|||
if (normalizedValue === 'false' || normalizedValue === '0' || normalizedValue === 'n' || normalizedValue === 'no') { |
|||
return false |
|||
} |
|||
return fallbackValue |
|||
}, |
|||
normalizeTrackingColumnItem (item, fallbackItem) { |
|||
const defaultItem = fallbackItem || {} |
|||
const mergedItem = Object.assign({}, defaultItem, item || {}) |
|||
const rawColumnProp = mergedItem.columnProp == null ? '' : String(mergedItem.columnProp).trim() |
|||
const columnProp = rawColumnProp.toLowerCase() === 'pic' ? 'pic' : rawColumnProp |
|||
const normalizedLabel = mergedItem.columnLabel == null ? '' : String(mergedItem.columnLabel).trim() |
|||
return Object.assign({}, mergedItem, { |
|||
columnProp: columnProp, |
|||
columnLabel: normalizedLabel || defaultItem.columnLabel || columnProp, |
|||
headerAlign: mergedItem.headerAlign || defaultItem.headerAlign || 'center', |
|||
align: mergedItem.align || defaultItem.align || 'left', |
|||
fixed: mergedItem.fixed == null ? (defaultItem.fixed || '') : mergedItem.fixed, |
|||
columnWidth: this.normalizeTrackingColumnWidth(mergedItem.columnWidth, defaultItem.columnWidth), |
|||
showOverflowTooltip: this.normalizeTrackingColumnBoolean(mergedItem.showOverflowTooltip, defaultItem.showOverflowTooltip !== false), |
|||
status: this.normalizeTrackingColumnBoolean(mergedItem.status, true), |
|||
columnHidden: this.normalizeTrackingColumnBoolean(mergedItem.columnHidden, false) |
|||
}) |
|||
}, |
|||
normalizeTrackingColumns (rows) { |
|||
const defaultColumns = this.buildDefaultTrackingColumns() |
|||
const defaultColumnMap = {} |
|||
defaultColumns.forEach(item => { |
|||
defaultColumnMap[item.columnProp] = item |
|||
}) |
|||
const mergedRows = [] |
|||
const usedColumnPropMap = {} |
|||
if (!Array.isArray(rows)) { |
|||
return mergedRows |
|||
} |
|||
// 只规范化用户已保存的列,不再把代码默认列补回去。
|
|||
// 否则用户隐藏的列(动态列里 status=false)会被默认列重新插回并继续显示。
|
|||
rows.forEach(item => { |
|||
const columnProp = item && item.columnProp != null ? String(item.columnProp).trim() : '' |
|||
if (!columnProp || usedColumnPropMap[columnProp]) { |
|||
return |
|||
} |
|||
usedColumnPropMap[columnProp] = true |
|||
mergedRows.push(this.normalizeTrackingColumnItem(item, defaultColumnMap[columnProp])) |
|||
}) |
|||
return mergedRows |
|||
}, |
|||
loadTrackingColumns () { |
|||
this.trackingColumnsLoaded = false |
|||
const queryTableUser = { |
|||
userId: this.$store.state.user.name, |
|||
functionId: this.getTrackingColumnFunctionId(), |
|||
tableId: this.getTrackingColumnTableId(), |
|||
languageCode: this.$i18n && this.$i18n.locale ? this.$i18n.locale : '' |
|||
} |
|||
return getTableUserListLanguage(queryTableUser).then(({ data }) => { |
|||
if (!data || data.code !== 0 || !Array.isArray(data.rows)) { |
|||
throw new Error('加载用户动态列失败') |
|||
} |
|||
const rows = data.rows |
|||
this.trackingColumnsLoaded = true |
|||
this.trackingColumnsPersisted = rows.length > 0 |
|||
// 不按 status 过滤:隐藏列也要读回来,才能按用户设置真正不展示。
|
|||
// 用户完全没有动态列配置时,才回退到本页代码里的默认列。
|
|||
this.trackingColumnList = rows.length > 0 |
|||
? this.normalizeTrackingColumns(rows) |
|||
: this.buildDefaultTrackingColumns() |
|||
this.refreshTrackingTableLayout() |
|||
return this.trackingColumnList |
|||
}).catch(() => { |
|||
this.trackingColumnList = this.buildDefaultTrackingColumns() |
|||
this.refreshTrackingTableLayout() |
|||
return this.trackingColumnList |
|||
}) |
|||
}, |
|||
handleTrackingColumnResize (newWidth, oldWidth, column) { |
|||
// 工序、Comments、操作等非用户动态列不调用此配置接口。
|
|||
const item = column && this.trackingColumnList.find(row => row.columnProp === column.property) |
|||
const width = Math.round(Number(newWidth)) |
|||
if (!item || !Number.isFinite(width) || width <= 0 || newWidth === oldWidth) { |
|||
return Promise.resolve() |
|||
} |
|||
const userId = this.$store.state.user.name |
|||
const functionId = this.getTrackingColumnFunctionId() |
|||
const tableId = this.getTrackingColumnTableId() |
|||
if (!this.trackingColumnsLoaded || this.isBlankValue(userId) || this.isBlankValue(functionId) || this.isBlankValue(tableId)) { |
|||
this.$message.warning('动态列配置尚未加载成功,列宽未保存,请刷新后重试') |
|||
return Promise.resolve() |
|||
} |
|||
this.$set(item, 'columnWidth', width) |
|||
// 仅提交身份字段和宽度,避免覆盖显隐、顺序、固定位置等其他用户配置。
|
|||
const payload = { userId, functionId, tableId, columnProp: item.columnProp, columnWidth: width } |
|||
// 串行保存,连续拖动时最后一次宽度不会被先发后到的请求覆盖。
|
|||
const queue = this._trackingColumnWidthSaveQueue || Promise.resolve() |
|||
this._trackingColumnWidthSaveQueue = queue.then(async () => { |
|||
let response |
|||
if (!this.trackingColumnsPersisted) { |
|||
// 后端没有默认列配置时,本页使用代码默认列;首次拖动初始化整组,不能只写一列。
|
|||
const columns = this.trackingColumnList.map((row, index) => Object.assign({}, row, { |
|||
userId, |
|||
functionId, |
|||
tableId, |
|||
sortLv: row.sortLv == null ? index + 1 : row.sortLv |
|||
})) |
|||
response = await saveTableUser(columns) |
|||
} else { |
|||
response = await updateColumnSize(payload) |
|||
} |
|||
if (!response || !response.data || response.data.code !== 0) { |
|||
throw new Error('列宽保存失败') |
|||
} |
|||
this.trackingColumnsPersisted = true |
|||
}).catch(() => { |
|||
this.$message.warning('列宽保存失败,当前宽度仅临时生效,请重新拖动以重试') |
|||
}) |
|||
return this._trackingColumnWidthSaveQueue |
|||
}, |
|||
isTrackingColumnVisible (column) { |
|||
if (!column) { |
|||
return false |
|||
} |
|||
if (this.normalizeTrackingColumnBoolean(column.status, true) === false) { |
|||
return false |
|||
} |
|||
if (this.normalizeTrackingColumnBoolean(column.columnHidden, false) !== false) { |
|||
return false |
|||
} |
|||
// 分类列只服务 RFID;其他 BU 或未选 BU 时即使用户列配置勾选了也不展示。
|
|||
if (column.columnProp === 'dryWetType' && !this.isRfidBuNo(this.getSelectedSearchBuNo())) { |
|||
return false |
|||
} |
|||
return true |
|||
}, |
|||
// 同步图标只展示在项目编码、项目物料与打样单号三列,避免整列变色影响可读性。
|
|||
isSyncIconTrackingColumn (columnProp) { |
|||
return ['projectNo', 'testPartNo', 'proofingNo'].indexOf(columnProp) > -1 |
|||
}, |
|||
// 仅已同步到 NPI 的项目编码/项目物料可跳转,避免临时 tracking 主键误进正式库页面。
|
|||
canOpenNpiFromTracking (row, columnProp) { |
|||
if (!row || this.isBlankValue(this.getTrackingColumnDisplayValue(row, columnProp))) { |
|||
return false |
|||
} |
|||
if (columnProp === 'projectNo') { |
|||
return this.isSyncedByIdRule(row.projectId || row.project_id) |
|||
} |
|||
if (columnProp === 'testPartNo') { |
|||
return this.isSyncedByIdRule(this.getTrackingProjectPartId(row)) |
|||
} |
|||
return false |
|||
}, |
|||
openNpiFromTracking (columnProp, row) { |
|||
if (!this.canOpenNpiFromTracking(row, columnProp)) { |
|||
return |
|||
} |
|||
if (columnProp === 'projectNo') { |
|||
this.openNpiTab('eam-eamProjectInfo', { |
|||
projectNo: this.getTrackingColumnDisplayValue(row, 'projectNo') |
|||
}) |
|||
return |
|||
} |
|||
this.openNpiTab('eam-eamProjectPartInfo', { |
|||
projectNo: this.getTrackingColumnDisplayValue(row, 'projectNo'), |
|||
testPartNo: this.getTrackingColumnDisplayValue(row, 'testPartNo') |
|||
}) |
|||
}, |
|||
// 跳转时同步更新已打开页签上的 query,否则再次点页签会带回第一次进入时的旧查询条件。
|
|||
openNpiTab (routeName, query) { |
|||
const tabs = this.$store.state.common.mainTabs || [] |
|||
const existingTab = tabs.find(item => item && item.name === routeName) |
|||
if (existingTab) { |
|||
this.$store.commit('common/updateMainTabs', tabs.map(item => { |
|||
if (!item || item.name !== routeName) { |
|||
return item |
|||
} |
|||
return Object.assign({}, item, { query: query }) |
|||
})) |
|||
} |
|||
this.$router.push({ name: routeName, query: query }).catch((err) => { |
|||
if (err && err.name === 'NavigationDuplicated') { |
|||
return |
|||
} |
|||
this.$message.error('未找到对应NPI页面,请确认是否有菜单权限') |
|||
}) |
|||
}, |
|||
isImportanceChecked (value) { |
|||
if (value === true || value === 1) { |
|||
return true |
|||
} |
|||
const text = value == null ? '' : String(value).trim().toUpperCase() |
|||
return text === 'Y' || text === 'YES' || text === 'TRUE' || text === '1' || text === '√' |
|||
}, |
|||
normalizeImportanceValue (value) { |
|||
return this.isImportanceChecked(value) ? 'Y' : 'N' |
|||
}, |
|||
normalizeImportanceFilter (value) { |
|||
const text = value == null ? '' : String(value).trim().toUpperCase() |
|||
if (text === 'Y') { |
|||
return 'Y' |
|||
} |
|||
if (text === 'N') { |
|||
return 'N' |
|||
} |
|||
return '' |
|||
}, |
|||
formatImportanceDisplay (value) { |
|||
return this.isImportanceChecked(value) ? '❗️' : '' |
|||
}, |
|||
getTrackingColumnDisplayValue (row, columnProp) { |
|||
if (!row || !columnProp) { |
|||
return '' |
|||
} |
|||
const value = row[columnProp] |
|||
if (columnProp === 'importance') { |
|||
return this.formatImportanceDisplay(value) |
|||
} |
|||
if (columnProp === 'pmInqueryTime') { |
|||
return this.formatDate(value) |
|||
} |
|||
if (columnProp === 'sampleMakingMonth' && !this.isBlankValue(value)) { |
|||
const month = Number(value) |
|||
if (!Number.isNaN(month)) { |
|||
return String(month).padStart(2, '0') |
|||
} |
|||
} |
|||
return this.isBlankValue(value) ? '' : String(value) |
|||
}, |
|||
isDeliveryVarianceAlert (row) { |
|||
// Delivery Variance = Baseline - Delivery&Package 实际日期;-8/-9 这类小于 -7 的值表示延误超过 7 天,需要标红。
|
|||
if (!row || this.isBlankValue(row.deliveryVariance)) { |
|||
return false |
|||
} |
|||
const variance = Number(row.deliveryVariance) |
|||
if (Number.isNaN(variance)) { |
|||
return false |
|||
} |
|||
return variance < -7 |
|||
}, |
|||
getTrackingRoleDisplayValue (row, nameField, valueField) { |
|||
if (!row) { |
|||
return '' |
|||
} |
|||
const roleNameValue = row[nameField] |
|||
if (!this.isBlankValue(roleNameValue)) { |
|||
return String(roleNameValue) |
|||
} |
|||
const roleValue = row[valueField] |
|||
if (this.isBlankValue(roleValue)) { |
|||
return '' |
|||
} |
|||
const displayName = this.getRoleDisplayName(roleValue) |
|||
return this.isBlankValue(displayName) ? '' : displayName |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,594 @@ |
|||
// 打样跟踪页 mixin:查询/列表加载/导出/表格高度布局/LT 平均值汇总/排序分页/同步标识/日期格式化
|
|||
import { exportProofTracking, exportProofTrackingPdf, exportProofTrackingImage, searchProofTracking } from '@/api/sampleTracking/sampleTracking' |
|||
|
|||
export default { |
|||
methods: { |
|||
refreshTrackingTableLayout () { |
|||
this.$nextTick(() => { |
|||
const tableRef = this.$refs.trackingTable |
|||
if (tableRef && tableRef.doLayout) { |
|||
tableRef.doLayout() |
|||
} |
|||
}) |
|||
}, |
|||
bindTrackingTableResize () { |
|||
if (this._onTrackingTableResize) { |
|||
return |
|||
} |
|||
this._onTrackingTableResize = () => { |
|||
this.scheduleTrackingTableHeightUpdate() |
|||
} |
|||
window.addEventListener('resize', this._onTrackingTableResize) |
|||
}, |
|||
unbindTrackingTableResize () { |
|||
if (this._onTrackingTableResize) { |
|||
window.removeEventListener('resize', this._onTrackingTableResize) |
|||
this._onTrackingTableResize = null |
|||
} |
|||
this.trackingTableHeightUpdateToken += 1 |
|||
}, |
|||
toggleSearchExpand () { |
|||
this.searchExpanded = !this.searchExpanded |
|||
}, |
|||
scheduleTrackingTableHeightUpdate () { |
|||
const token = ++this.trackingTableHeightUpdateToken |
|||
this.$nextTick(() => { |
|||
if (token !== this.trackingTableHeightUpdateToken) { |
|||
return |
|||
} |
|||
this.updateTrackingTableHeight() |
|||
}) |
|||
}, |
|||
updateTrackingTableHeight () { |
|||
const tableRef = this.$refs.trackingTable |
|||
const tableEl = tableRef && tableRef.$el ? tableRef.$el : null |
|||
if (!tableEl || typeof tableEl.getBoundingClientRect !== 'function') { |
|||
return |
|||
} |
|||
const tableRect = tableEl.getBoundingClientRect() |
|||
// keep-alive 页签隐藏时不使用零尺寸覆盖正常布局。
|
|||
if (!tableRect.width) { |
|||
return |
|||
} |
|||
const tableTop = tableRect.top |
|||
const paginationRef = this.$refs.trackingPagination |
|||
const paginationEl = paginationRef && paginationRef.$el ? paginationRef.$el : null |
|||
const paginationHeight = paginationEl ? paginationEl.offsetHeight : 32 |
|||
const paginationMargin = 12 |
|||
// 卡片 padding 5px + 页签内容区 padding 5px,再留 6px,一次算准高度,避免二次收缩触发表格重排。
|
|||
const bottomReserve = 16 |
|||
const nextHeight = Math.max(240, Math.floor(window.innerHeight - tableTop - paginationHeight - paginationMargin - bottomReserve)) |
|||
if (this.trackingTableHeight === nextHeight) { |
|||
return |
|||
} |
|||
this.trackingTableHeight = nextHeight |
|||
}, |
|||
normalizeSearchInteger (value) { |
|||
if (this.isBlankValue(value)) { |
|||
return null |
|||
} |
|||
const parsedValue = parseInt(value, 10) |
|||
return Number.isNaN(parsedValue) ? null : parsedValue |
|||
}, |
|||
applyProofTrackingSearchFilters (inData) { |
|||
if (!inData) { |
|||
return inData |
|||
} |
|||
inData.sampleQty = this.normalizeSearchInteger(inData.sampleQty) |
|||
// 日期范围按“实际完成日期优先,为空取预计完成日期”筛选,列表与导出共用。
|
|||
inData.sampleMakingDateStart = this.isBlankValue(inData.sampleMakingDateStart) ? null : inData.sampleMakingDateStart |
|||
inData.sampleMakingDateEnd = this.isBlankValue(inData.sampleMakingDateEnd) ? null : inData.sampleMakingDateEnd |
|||
delete inData.sampleMakingYear |
|||
delete inData.sampleMakingMonth |
|||
inData.pmInqueryTimeStart = this.isBlankValue(inData.pmInqueryTimeStart) ? null : inData.pmInqueryTimeStart |
|||
inData.pmInqueryTimeEnd = this.isBlankValue(inData.pmInqueryTimeEnd) ? null : inData.pmInqueryTimeEnd |
|||
inData.importance = this.isBlankValue(inData.importance) ? '' : this.normalizeImportanceFilter(inData.importance) |
|||
// 非 RFID 查询不带分类条件,避免筛选项隐藏后仍按旧值过滤。
|
|||
if (!this.isRfidBuNo(inData.buNo || this.searchData.buNo)) { |
|||
inData.dryWetType = '' |
|||
} |
|||
return inData |
|||
}, |
|||
validateSampleMakingDateRange () { |
|||
const start = this.searchData.sampleMakingDateStart |
|||
const end = this.searchData.sampleMakingDateEnd |
|||
if (start && end && start > end) { |
|||
this.$message.warning('Sample making Date 开始日期不能晚于结束日期') |
|||
return false |
|||
} |
|||
return true |
|||
}, |
|||
getDataList (flag) { |
|||
if (!this.validateSampleMakingDateRange()) { |
|||
return |
|||
} |
|||
if (flag === 'Y') { |
|||
this.pageIndex = 1 |
|||
} |
|||
this.searchData.site = this.$store.state.user.site |
|||
this.searchData.userName = this.$store.state.user.name |
|||
const normalizedProofingStatusList = this.normalizeSearchProofingStatusList(this.searchData.proofingStatusList) |
|||
this.searchData.proofingStatusList = normalizedProofingStatusList |
|||
const inData = Object.assign({}, this.searchData, { |
|||
page: this.pageIndex, |
|||
limit: this.pageSize |
|||
}) |
|||
inData.buNo = this.normalizeBuNo(inData.buNo, inData.site) |
|||
inData.proofingStatusList = normalizedProofingStatusList |
|||
this.applyProofTrackingSearchFilters(inData) |
|||
this.dataListLoading = true |
|||
// 列表会整表换行数据,未提交的工序日期编辑态不能带到新行上。
|
|||
this.clearProcessDateEditClickTimer() |
|||
this.exitProcessDateEdit() |
|||
this.exitCostEdit() |
|||
searchProofTracking(inData).then(({ data }) => { |
|||
this.dataListLoading = false |
|||
this.resetProcessTooltip() |
|||
if (data && data.code === 0) { |
|||
this.usdCnyExchangeRate = data.usdCnyExchangeRate == null ? null : data.usdCnyExchangeRate |
|||
this.usdCnyExchangeRateDraft = this.usdCnyExchangeRate == null ? '' : this.formatCostDisplay(this.usdCnyExchangeRate) |
|||
this.dataList = (data.page && data.page.list) || [] |
|||
this.syncDataListProcessValues() |
|||
this.resetDataListPageOrderIndexes() |
|||
this.applyTrackingTableSort() |
|||
this.totalPage = (data.page && data.page.totalCount) || 0 |
|||
if (this.commentsEditingTrackingId) { |
|||
const hasEditingRow = this.dataList.some(item => item.trackingId === this.commentsEditingTrackingId) |
|||
if (!hasEditingRow) { |
|||
this.cancelCommentsEdit() |
|||
} |
|||
} |
|||
const manualSelectedId = this.manualSelectedTrackingId |
|||
const previousCurrentId = this.currentRow && this.currentRow.trackingId |
|||
let nextCurrentRow = null |
|||
if (manualSelectedId != null) { |
|||
// 只要用户没有手动点新行,刷新后始终尝试回选上次手动选中的那一行
|
|||
nextCurrentRow = this.dataList.find(item => item && item.trackingId === manualSelectedId) || null |
|||
} else if (previousCurrentId != null) { |
|||
nextCurrentRow = this.dataList.find(item => item && item.trackingId === previousCurrentId) || null |
|||
} |
|||
if (!nextCurrentRow && manualSelectedId == null && this.dataList.length > 0) { |
|||
nextCurrentRow = this.dataList[0] |
|||
} |
|||
this.currentRow = nextCurrentRow |
|||
this.$nextTick(() => { |
|||
if (this.$refs.trackingTable && typeof this.$refs.trackingTable.setCurrentRow === 'function') { |
|||
this.$refs.trackingTable.setCurrentRow(this.currentRow || null) |
|||
} |
|||
}) |
|||
} else { |
|||
this.dataList = [] |
|||
this.totalPage = 0 |
|||
this.currentRow = null |
|||
this.$nextTick(() => { |
|||
if (this.$refs.trackingTable && typeof this.$refs.trackingTable.setCurrentRow === 'function') { |
|||
this.$refs.trackingTable.setCurrentRow(null) |
|||
} |
|||
}) |
|||
this.$message.error(data.msg || '查询失败') |
|||
} |
|||
}).catch(() => { |
|||
this.dataListLoading = false |
|||
this.resetProcessTooltip() |
|||
this.$message.error('查询异常') |
|||
}) |
|||
}, |
|||
async downloadTrackingExport (exportType) { |
|||
if (!this.validateSampleMakingDateRange()) { |
|||
return |
|||
} |
|||
if (this.exportLoading || this.exportPdfLoading || this.exportImageLoading) { |
|||
return |
|||
} |
|||
const exportTaskMap = { |
|||
excel: { loadingKey: 'exportLoading', failMessage: '导出失败', extension: 'xlsx', request: exportProofTracking }, |
|||
pdf: { loadingKey: 'exportPdfLoading', failMessage: '导出PDF失败', extension: 'pdf', request: exportProofTrackingPdf }, |
|||
image: { loadingKey: 'exportImageLoading', failMessage: '导出图片失败', extension: 'png', request: exportProofTrackingImage } |
|||
} |
|||
const exportTask = exportTaskMap[exportType] || exportTaskMap.excel |
|||
this.searchData.site = this.$store.state.user.site |
|||
this.searchData.userName = this.$store.state.user.name |
|||
const exportTrackingColumns = this.visibleTrackingColumns.map(item => ({ |
|||
columnProp: item.columnProp, |
|||
columnLabel: item.columnLabel |
|||
})) |
|||
const exportProcessColumns = this.visibleProcessColumns.map(item => ({ |
|||
code: item.code, |
|||
label: item.label, |
|||
planField: item.planField, |
|||
actualField: item.actualField, |
|||
statusField: item.statusField, |
|||
processCategoryCode: item.processCategoryCode, |
|||
processCategoryName: item.processCategoryName |
|||
})) |
|||
if (exportTrackingColumns.length === 0 && exportProcessColumns.length === 0) { |
|||
this.$message.warning('当前没有可导出的列') |
|||
return |
|||
} |
|||
const normalizedProofingStatusList = this.normalizeSearchProofingStatusList(this.searchData.proofingStatusList) |
|||
this.searchData.proofingStatusList = normalizedProofingStatusList |
|||
const inData = Object.assign({}, this.searchData, { |
|||
buNo: this.normalizeBuNo(this.searchData.buNo, this.searchData.site), |
|||
exportTrackingColumns: exportTrackingColumns, |
|||
exportProcessColumns: exportProcessColumns, |
|||
exportCommentsColumn: true |
|||
}) |
|||
inData.proofingStatusList = normalizedProofingStatusList |
|||
this.applyProofTrackingSearchFilters(inData) |
|||
const loadingKey = exportTask.loadingKey |
|||
const failMessage = exportTask.failMessage |
|||
this[loadingKey] = true |
|||
try { |
|||
const response = await exportTask.request(inData) |
|||
const blob = response && response.data ? response.data : null |
|||
if (!blob) { |
|||
this.$message.error(failMessage) |
|||
return |
|||
} |
|||
if (blob.type && blob.type.indexOf('application/json') > -1) { |
|||
const errorText = await blob.text() |
|||
let errorMsg = failMessage |
|||
try { |
|||
const errorObj = JSON.parse(errorText) |
|||
if (errorObj && errorObj.msg) { |
|||
errorMsg = errorObj.msg |
|||
} |
|||
} catch (e) { |
|||
} |
|||
this.$message.error(errorMsg) |
|||
return |
|||
} |
|||
const fileName = this.resolveProofTrackingExportFileName(response, exportTask.extension) |
|||
const url = window.URL.createObjectURL(blob) |
|||
const link = document.createElement('a') |
|||
link.href = url |
|||
link.setAttribute('download', fileName) |
|||
document.body.appendChild(link) |
|||
link.click() |
|||
link.remove() |
|||
window.URL.revokeObjectURL(url) |
|||
} catch (e) { |
|||
this.$message.error(failMessage) |
|||
} finally { |
|||
this[loadingKey] = false |
|||
} |
|||
}, |
|||
resolveProofTrackingExportFileName (response, extension) { |
|||
const defaultFileName = `项目打样跟踪_${this.getExportTimestamp()}.${extension || 'xlsx'}` |
|||
const disposition = response && response.headers |
|||
? (response.headers['content-disposition'] || response.headers['Content-Disposition'] || '') |
|||
: '' |
|||
if (!disposition) { |
|||
return defaultFileName |
|||
} |
|||
const utf8Match = disposition.match(/filename\*=utf-8''([^;]+)/i) |
|||
if (utf8Match && utf8Match[1]) { |
|||
try { |
|||
return decodeURIComponent(utf8Match[1]) |
|||
} catch (e) { |
|||
return utf8Match[1] |
|||
} |
|||
} |
|||
const normalMatch = disposition.match(/filename="?([^";]+)"?/i) |
|||
if (normalMatch && normalMatch[1]) { |
|||
return normalMatch[1] |
|||
} |
|||
return defaultFileName |
|||
}, |
|||
getExportTimestamp () { |
|||
const now = new Date() |
|||
const pad = num => String(num).padStart(2, '0') |
|||
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}` |
|||
}, |
|||
resetSearch () { |
|||
this.searchData.projectNo = '' |
|||
this.searchData.projectDesc = '' |
|||
this.searchData.testPartNo = '' |
|||
this.searchData.partDesc = '' |
|||
this.searchData.dryWetType = '' |
|||
this.searchData.customerNo = '' |
|||
this.searchData.proofingNo = '' |
|||
this.searchData.cProjectRegion = '' |
|||
this.searchData.engineer = '' |
|||
this.searchData.projectManager = '' |
|||
this.searchData.pic = '' |
|||
this.searchData.projectPartSyncFlag = '' |
|||
this.searchData.proofSyncFlag = '' |
|||
this.searchData.proofingStatusList = [] |
|||
this.searchData.sampleQty = '' |
|||
this.searchData.sampleMakingDateStart = '' |
|||
this.searchData.sampleMakingDateEnd = '' |
|||
this.searchData.pmInqueryTimeStart = '' |
|||
this.searchData.pmInqueryTimeEnd = '' |
|||
this.searchData.importance = '' |
|||
this.ensureSearchBuNoSelected() |
|||
this.queryProcessColumns().then(() => { |
|||
this.getDataList('Y') |
|||
}) |
|||
}, |
|||
normalizeSearchRoleOptions (rows) { |
|||
const optionMap = {} |
|||
const options = [] |
|||
;(Array.isArray(rows) ? rows : []).forEach(item => { |
|||
if (!item || this.isBlankValue(item.username)) { |
|||
return |
|||
} |
|||
const username = String(item.username).trim() |
|||
const userDisplay = this.isBlankValue(item.userDisplay) ? '' : String(item.userDisplay).trim() |
|||
const value = userDisplay ? (username + '-' + userDisplay) : username |
|||
if (optionMap[value]) { |
|||
return |
|||
} |
|||
optionMap[value] = true |
|||
options.push({ |
|||
value: value, |
|||
label: userDisplay || username, |
|||
username: username, |
|||
userDisplay: userDisplay |
|||
}) |
|||
}) |
|||
return options.sort((left, right) => String(left.label).localeCompare(String(right.label))) |
|||
}, |
|||
loadSearchRoleOptions () { |
|||
// 与一键创建人员弹窗同源:Engineer / PM/Sales / PIC(PjM) 分别对应角色接口 6 / 0 / 1。
|
|||
const roleQuery = { active: 'Y', limit: 1000 } |
|||
return Promise.all([ |
|||
this.fetchRoleListByApiKey('6', roleQuery), |
|||
this.fetchRoleListByApiKey('0', roleQuery), |
|||
this.fetchRoleListByApiKey('1', roleQuery) |
|||
]).then(([engineerRows, projectManagerRows, picRows]) => { |
|||
this.searchEngineerOptions = this.normalizeSearchRoleOptions(engineerRows) |
|||
this.searchProjectManagerOptions = this.normalizeSearchRoleOptions(projectManagerRows) |
|||
this.searchPicOptions = this.normalizeSearchRoleOptions(picRows) |
|||
}).catch(() => { |
|||
this.searchEngineerOptions = [] |
|||
this.searchProjectManagerOptions = [] |
|||
this.searchPicOptions = [] |
|||
}) |
|||
}, |
|||
selectionChange (rows) { |
|||
this.selectionRows = rows || [] |
|||
// 汇总行常驻 DOM,勾选变化后必须重算数值并补一次列宽/滚动同步。
|
|||
this.refreshTrackingLtSummary() |
|||
}, |
|||
refreshTrackingLtSummary () { |
|||
this.$nextTick(() => { |
|||
const tableRef = this.$refs.trackingTable |
|||
if (!tableRef) { |
|||
return |
|||
} |
|||
if (typeof tableRef.$forceUpdate === 'function') { |
|||
tableRef.$forceUpdate() |
|||
} |
|||
// forceUpdate 会重建 footer 的 col,必须等下一帧再同步宽度,否则数字要拖滚动条才出现。
|
|||
this.$nextTick(() => { |
|||
this.syncTrackingLtSummaryLayout() |
|||
}) |
|||
}) |
|||
}, |
|||
syncTrackingLtSummaryLayout () { |
|||
const tableRef = this.$refs.trackingTable |
|||
if (!tableRef) { |
|||
return |
|||
} |
|||
if (typeof tableRef.doLayout === 'function') { |
|||
tableRef.doLayout() |
|||
} |
|||
if (tableRef.layout && typeof tableRef.layout.notifyObservers === 'function') { |
|||
tableRef.layout.notifyObservers('columns') |
|||
tableRef.layout.notifyObservers('scrollable') |
|||
} |
|||
const bodyWrapper = tableRef.bodyWrapper || (tableRef.$refs && tableRef.$refs.bodyWrapper) |
|||
const footerWrapper = tableRef.$refs && tableRef.$refs.footerWrapper |
|||
if (bodyWrapper && footerWrapper) { |
|||
footerWrapper.scrollLeft = bodyWrapper.scrollLeft |
|||
} |
|||
}, |
|||
parseTrackingLtNumber (value) { |
|||
// 空值(含空白字符串)不参与平均,0 是有效天数需要保留。
|
|||
if (this.isBlankValue(value)) { |
|||
return null |
|||
} |
|||
const number = Number(value) |
|||
if (Number.isNaN(number)) { |
|||
return null |
|||
} |
|||
return number |
|||
}, |
|||
calcTrackingLtAverage (rows, columnProp) { |
|||
if (!Array.isArray(rows) || rows.length === 0 || !columnProp) { |
|||
return '' |
|||
} |
|||
let sum = 0 |
|||
let count = 0 |
|||
rows.forEach(row => { |
|||
const number = this.parseTrackingLtNumber(row && row[columnProp]) |
|||
if (number == null) { |
|||
return |
|||
} |
|||
sum += number |
|||
count += 1 |
|||
}) |
|||
if (count === 0) { |
|||
return '' |
|||
} |
|||
const rounded = Math.round(sum / count * 10) / 10 |
|||
return String(rounded) |
|||
}, |
|||
getTrackingLtSummaries ({ columns }) { |
|||
// 平均值行仅在勾选后展示,两列各自跳过空值,互不影响。
|
|||
const sourceRows = Array.isArray(this.selectionRows) ? this.selectionRows : [] |
|||
let averageLabelWritten = false |
|||
return (columns || []).map(column => { |
|||
const columnProp = column && column.property |
|||
if (columnProp === 'sampleLt' || columnProp === 'sampleLtInquery') { |
|||
return this.calcTrackingLtAverage(sourceRows, columnProp) |
|||
} |
|||
if (averageLabelWritten || !column || column.type === 'selection') { |
|||
return '' |
|||
} |
|||
averageLabelWritten = true |
|||
return '平均值' |
|||
}) |
|||
}, |
|||
handleTrackingTableSortChange (sortData) { |
|||
this.trackingTableSortProp = sortData && sortData.prop ? String(sortData.prop) : '' |
|||
this.trackingTableSortOrder = sortData && sortData.order ? String(sortData.order) : '' |
|||
this.applyTrackingTableSort() |
|||
this.refreshTrackingTableLayout() |
|||
}, |
|||
resolveTrackingTableSortValue (row, prop) { |
|||
if (!row || !prop) { |
|||
return '' |
|||
} |
|||
const rawValue = row[prop] |
|||
const formattedValue = this.formatDate(rawValue) |
|||
if (formattedValue) { |
|||
return formattedValue |
|||
} |
|||
return rawValue == null ? '' : String(rawValue).trim() |
|||
}, |
|||
compareDataListOrderIndex (a, b) { |
|||
const aOrderIndex = Number(a && a._pageOrderIndex != null ? a._pageOrderIndex : Number.MAX_SAFE_INTEGER) |
|||
const bOrderIndex = Number(b && b._pageOrderIndex != null ? b._pageOrderIndex : Number.MAX_SAFE_INTEGER) |
|||
return aOrderIndex - bOrderIndex |
|||
}, |
|||
resetDataListPageOrderIndexes () { |
|||
if (!Array.isArray(this.dataList) || this.dataList.length === 0) { |
|||
return |
|||
} |
|||
this.dataList.forEach((row, index) => { |
|||
if (!row) { |
|||
return |
|||
} |
|||
this.$set(row, '_pageOrderIndex', index) |
|||
}) |
|||
}, |
|||
restoreDataListPageOrder () { |
|||
if (!Array.isArray(this.dataList) || this.dataList.length <= 1) { |
|||
return |
|||
} |
|||
this.dataList = this.dataList.slice().sort((a, b) => this.compareDataListOrderIndex(a, b)) |
|||
}, |
|||
applyTrackingTableSort () { |
|||
if (!Array.isArray(this.dataList) || this.dataList.length <= 1) { |
|||
return |
|||
} |
|||
const sortProp = this.trackingTableSortProp |
|||
const sortOrder = this.trackingTableSortOrder |
|||
if (!sortProp || !sortOrder) { |
|||
this.restoreDataListPageOrder() |
|||
return |
|||
} |
|||
const isAscending = sortOrder === 'ascending' |
|||
this.dataList = this.dataList.slice().sort((a, b) => { |
|||
const aValue = this.resolveTrackingTableSortValue(a, sortProp) |
|||
const bValue = this.resolveTrackingTableSortValue(b, sortProp) |
|||
const aEmpty = !aValue |
|||
const bEmpty = !bValue |
|||
if (aEmpty && bEmpty) { |
|||
return this.compareDataListOrderIndex(a, b) |
|||
} |
|||
if (aEmpty) { |
|||
return 1 |
|||
} |
|||
if (bEmpty) { |
|||
return -1 |
|||
} |
|||
if (aValue === bValue) { |
|||
return this.compareDataListOrderIndex(a, b) |
|||
} |
|||
if (isAscending) { |
|||
return aValue > bValue ? 1 : -1 |
|||
} |
|||
return aValue < bValue ? 1 : -1 |
|||
}) |
|||
}, |
|||
rowClick (row) { |
|||
this.currentRow = row |
|||
this.manualSelectedTrackingId = row && row.trackingId ? row.trackingId : null |
|||
}, |
|||
sizeChangeHandle (val) { |
|||
this.pageSize = val |
|||
this.pageIndex = 1 |
|||
this.getDataList() |
|||
}, |
|||
currentChangeHandle (val) { |
|||
this.pageIndex = val |
|||
this.getDataList() |
|||
}, |
|||
getActionRow (row) { |
|||
return row || this.currentRow || (this.selectionRows.length > 0 ? this.selectionRows[0] : null) |
|||
}, |
|||
getTrackingProjectPartId (row) { |
|||
if (!row) { |
|||
return null |
|||
} |
|||
return row.projectPartId || row.project_part_id || null |
|||
}, |
|||
isSyncedByIdRule (idValue) { |
|||
if (idValue == null || String(idValue).trim() === '') { |
|||
return false |
|||
} |
|||
// 约定:NPI 正式库主键 < 100000,tracking 临时主键 >= 100000。
|
|||
const numericId = Number(idValue) |
|||
return Number.isFinite(numericId) && numericId > 0 && numericId < 100000 |
|||
}, |
|||
isProjectPartSynced (row) { |
|||
if (!row) { |
|||
return false |
|||
} |
|||
const projectId = row.projectId || row.project_id || null |
|||
const projectPartId = this.getTrackingProjectPartId(row) |
|||
return this.isSyncedByIdRule(projectId) && this.isSyncedByIdRule(projectPartId) |
|||
}, |
|||
isProofSynced (row) { |
|||
if (!row) { |
|||
return false |
|||
} |
|||
const proofingId = row.proofingId || row.proofing_id || row.trackingId || null |
|||
return this.isSyncedByIdRule(proofingId) |
|||
}, |
|||
isTrackingColumnSynced (row, columnProp) { |
|||
if (columnProp === 'proofingNo') { |
|||
return this.isProofSynced(row) |
|||
} |
|||
return this.isProjectPartSynced(row) |
|||
}, |
|||
formatDate (val) { |
|||
if (!val) { |
|||
return '' |
|||
} |
|||
if (typeof val === 'string') { |
|||
return val.length > 10 ? val.substring(0, 10) : val |
|||
} |
|||
const date = new Date(val) |
|||
if (isNaN(date.getTime())) { |
|||
return '' |
|||
} |
|||
const y = date.getFullYear() |
|||
const m = `${date.getMonth() + 1}`.padStart(2, '0') |
|||
const d = `${date.getDate()}`.padStart(2, '0') |
|||
return `${y}-${m}-${d}` |
|||
}, |
|||
formatDateTime (val) { |
|||
if (!val) { |
|||
return '' |
|||
} |
|||
if (typeof val === 'string') { |
|||
return val.length > 19 ? val.substring(0, 19) : val |
|||
} |
|||
const date = new Date(val) |
|||
if (isNaN(date.getTime())) { |
|||
return '' |
|||
} |
|||
const y = date.getFullYear() |
|||
const m = `${date.getMonth() + 1}`.padStart(2, '0') |
|||
const d = `${date.getDate()}`.padStart(2, '0') |
|||
const hh = `${date.getHours()}`.padStart(2, '0') |
|||
const mm = `${date.getMinutes()}`.padStart(2, '0') |
|||
const ss = `${date.getSeconds()}`.padStart(2, '0') |
|||
return `${y}-${m}-${d} ${hh}:${mm}:${ss}` |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,759 @@ |
|||
/* 仅打样跟踪主表使用深灰色网格,不覆盖其他页面或弹窗中的表格。 */ |
|||
.el-table.proof-tracking-table.el-table--border { |
|||
border-color: #808080; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table th, |
|||
.el-table.proof-tracking-table .el-table__body td { |
|||
border-right: 1px solid #808080; |
|||
border-bottom: 1px solid #808080; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table::before, |
|||
.el-table.proof-tracking-table.el-table--border::after, |
|||
.el-table.proof-tracking-table .el-table__fixed::before, |
|||
.el-table.proof-tracking-table .el-table__fixed-right::before { |
|||
background-color: #808080; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .el-table__fixed-right-patch { |
|||
border-bottom: 1px solid #808080; |
|||
} |
|||
|
|||
/* show-summary 常驻时固定列外层会覆盖滚动条;透明空白透传鼠标,内容区保持可交互。 */ |
|||
.el-table.proof-tracking-table > .el-table__fixed, |
|||
.el-table.proof-tracking-table > .el-table__fixed-right, |
|||
.el-table.proof-tracking-table > .el-table__fixed::before, |
|||
.el-table.proof-tracking-table > .el-table__fixed-right::before { |
|||
pointer-events: none; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table > .el-table__fixed > .el-table__fixed-header-wrapper, |
|||
.el-table.proof-tracking-table > .el-table__fixed > .el-table__fixed-body-wrapper, |
|||
.el-table.proof-tracking-table > .el-table__fixed > .el-table__fixed-footer-wrapper, |
|||
.el-table.proof-tracking-table > .el-table__fixed-right > .el-table__fixed-header-wrapper, |
|||
.el-table.proof-tracking-table > .el-table__fixed-right > .el-table__fixed-body-wrapper, |
|||
.el-table.proof-tracking-table > .el-table__fixed-right > .el-table__fixed-footer-wrapper { |
|||
pointer-events: auto; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table.is-tracking-lt-summary-hidden .el-table__footer-wrapper, |
|||
.el-table.proof-tracking-table.is-tracking-lt-summary-hidden .el-table__fixed-footer-wrapper, |
|||
.el-table.proof-tracking-table.is-tracking-lt-summary-hidden .el-table__fixed-right-footer-wrapper { |
|||
display: none; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .el-table__footer-wrapper, |
|||
.el-table.proof-tracking-table .el-table__fixed-footer-wrapper, |
|||
.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper { |
|||
background: transparent; |
|||
/* 平均值行不要再套一层顶部分隔线,避免和末行数据底边叠成双线。 */ |
|||
border-top: none; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .el-table__footer-wrapper tbody td, |
|||
.el-table.proof-tracking-table .el-table__footer-wrapper tbody td.el-table__cell, |
|||
.el-table.proof-tracking-table .el-table__fixed-footer-wrapper tbody td, |
|||
.el-table.proof-tracking-table .el-table__fixed-footer-wrapper tbody td.el-table__cell, |
|||
.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper tbody td, |
|||
.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper tbody td.el-table__cell, |
|||
.el-table.proof-tracking-table .el-table__footer-wrapper tbody td .cell, |
|||
.el-table.proof-tracking-table .el-table__fixed-footer-wrapper tbody td .cell, |
|||
.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper tbody td .cell { |
|||
background: transparent; |
|||
background-color: transparent; |
|||
border: none; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .el-table__footer-wrapper td, |
|||
.el-table.proof-tracking-table .el-table__fixed-footer-wrapper td, |
|||
.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper td { |
|||
height: 23px; |
|||
padding-top: 3px; |
|||
padding-bottom: 3px; |
|||
/* 平均值行只展示汇总数字,去掉单元格网格以免空列出现一排空框。 */ |
|||
border: none; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .el-table__footer-wrapper td .cell, |
|||
.el-table.proof-tracking-table .el-table__fixed-footer-wrapper td .cell, |
|||
.el-table.proof-tracking-table .el-table__fixed-right-footer-wrapper td .cell { |
|||
height: 17px; |
|||
line-height: 17px; |
|||
font-weight: 700; |
|||
} |
|||
.el-table.el-table--medium.data-table th, |
|||
.el-table.data-table th { |
|||
height: 26px; |
|||
padding-top: 0; |
|||
padding-bottom: 0; |
|||
} |
|||
|
|||
.el-table.data-table th .cell { |
|||
height: 26px; |
|||
line-height: 26px; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
.el-table.data-table td .cell { |
|||
height: 28px; |
|||
line-height: 28px; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
/* 仅加粗当前主表的工序内容和物料描述,保留各自现有字号。 */ |
|||
.el-table.proof-tracking-table .proof-process-column .cell, |
|||
.el-table.proof-tracking-table .proof-process-date-picker .el-input__inner, |
|||
.el-table.proof-tracking-table .process-date-display, |
|||
.el-table.proof-tracking-table .proof-part-description-column .cell { |
|||
font-weight: 700; |
|||
} |
|||
|
|||
/* 仅放大工序日期,其他单元格、表头和按钮保持原字号。 */ |
|||
.el-table.proof-tracking-table .proof-process-date-picker .el-input__inner, |
|||
.el-table.proof-tracking-table .process-date-display { |
|||
font-size: 14px; |
|||
} |
|||
|
|||
/* 仅移除工序日期框的前缀图标;右侧清空按钮和日期选择功能保留。 */ |
|||
.el-table.proof-tracking-table .proof-process-date-picker .el-input__prefix { |
|||
display: none; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .proof-process-date-picker { |
|||
min-width: 100px; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .proof-process-date-picker .el-input__inner { |
|||
padding-left: 6px; |
|||
padding-right: 20px; |
|||
} |
|||
|
|||
.search-form { |
|||
margin-bottom: 0; |
|||
padding-top: 8px; |
|||
} |
|||
|
|||
.mod-config .search-toolbar { |
|||
display: flex; |
|||
align-items: center; |
|||
min-width: 0; |
|||
flex-wrap: wrap; |
|||
padding: 0 8px 0 0; |
|||
border-bottom: 1px solid #ebeef5; |
|||
} |
|||
|
|||
.mod-config .search-bu-field { |
|||
display: flex; |
|||
align-items: center; |
|||
flex: 0 0 auto; |
|||
height: 24px; |
|||
line-height: 24px; |
|||
margin-right: 16px; |
|||
} |
|||
|
|||
.mod-config .search-bu-label { |
|||
display: inline-flex; |
|||
align-items: center; |
|||
height: 24px; |
|||
line-height: 24px; |
|||
margin-right: 8px; |
|||
padding: 0; |
|||
font-size: 12px; |
|||
font-weight: 400; |
|||
color: #606266; |
|||
} |
|||
|
|||
.mod-config .search-bu-select { |
|||
width: 80px; |
|||
} |
|||
|
|||
.mod-config .search-bu-select .el-input__inner { |
|||
height: 24px; |
|||
line-height: 24px; |
|||
} |
|||
|
|||
.mod-config .search-collapse-label { |
|||
display: flex; |
|||
align-items: center; |
|||
flex: 0 0 auto; |
|||
margin-right: 8px; |
|||
cursor: pointer; |
|||
user-select: none; |
|||
font-size: 13px; |
|||
color: #303133; |
|||
font-weight: 500; |
|||
} |
|||
|
|||
.mod-config .search-collapse-label span { |
|||
margin-left: 8px; |
|||
font-weight: 500; |
|||
} |
|||
|
|||
.mod-config .search-header-actions { |
|||
display: flex; |
|||
align-items: center; |
|||
flex-wrap: wrap; |
|||
margin-left: 0; |
|||
margin-right: 8px; |
|||
min-width: 0; |
|||
row-gap: 6px; |
|||
} |
|||
|
|||
.mod-config .search-header-actions .tracking-export-dropdown { |
|||
margin: 0 10px; |
|||
} |
|||
|
|||
.search-proofing-status-select .el-select__tags { |
|||
flex-wrap: nowrap; |
|||
overflow-x: auto; |
|||
overflow-y: hidden; |
|||
} |
|||
|
|||
.search-proofing-status-select .el-select__tags > span { |
|||
display: inline-flex; |
|||
flex-wrap: nowrap; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-order-list { |
|||
display: grid; |
|||
grid-template-columns: repeat(3, minmax(220px, 1fr)); |
|||
column-gap: 12px; |
|||
row-gap: 8px; |
|||
align-items: center; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-list-column .cell { |
|||
white-space: normal !important; |
|||
height: auto !important; |
|||
line-height: 20px; |
|||
padding-top: 6px; |
|||
padding-bottom: 6px; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-list-column { |
|||
vertical-align: top; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-order-item { |
|||
display: flex; |
|||
align-items: center; |
|||
gap: 6px; |
|||
min-height: 28px; |
|||
padding: 2px 6px; |
|||
border: 1px solid transparent; |
|||
border-radius: 4px; |
|||
cursor: move; |
|||
transition: border-color .2s ease, background-color .2s ease; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-order-item:hover { |
|||
border-color: #7cc4ff; |
|||
background: #f5fbff; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-order-item.is-dragging { |
|||
opacity: .55; |
|||
border-color: #409eff; |
|||
background: #ecf5ff; |
|||
} |
|||
|
|||
.bu-process-config-dialog .process-order-index { |
|||
width: 22px; |
|||
color: #606266; |
|||
font-size: 12px; |
|||
text-align: right; |
|||
margin-right: 4px; |
|||
flex-shrink: 0; |
|||
} |
|||
|
|||
.bu-process-config-dialog .process-order-handle { |
|||
margin-right: 6px; |
|||
color: #909399; |
|||
font-size: 14px; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-order-item .el-checkbox, |
|||
.bu-process-config-dialog .bu-process-order-item .el-checkbox + .el-checkbox { |
|||
width: 100%; |
|||
margin: 0 !important; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-order-item .el-checkbox__label { |
|||
white-space: nowrap; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-order-item .el-checkbox { |
|||
flex: 1; |
|||
min-width: 0; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-category-select { |
|||
width: 100px; |
|||
flex-shrink: 0; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-config-tip { |
|||
display: flex; |
|||
align-items: center; |
|||
gap: 6px; |
|||
margin-bottom: 8px; |
|||
padding: 6px 10px; |
|||
border-radius: 4px; |
|||
background: #f4f8ff; |
|||
color: #5f6b7a; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
.bu-process-config-dialog .bu-process-config-tip i { |
|||
color: #409eff; |
|||
} |
|||
|
|||
.default-process-config-dialog .default-process-config-actions { |
|||
margin-bottom: 8px; |
|||
} |
|||
|
|||
.default-process-config-dialog .bu-process-config-tip { |
|||
display: flex; |
|||
align-items: center; |
|||
gap: 6px; |
|||
margin-bottom: 8px; |
|||
padding: 6px 10px; |
|||
border-radius: 4px; |
|||
background: #f4f8ff; |
|||
color: #5f6b7a; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
.default-process-config-dialog .bu-process-config-tip i { |
|||
color: #409eff; |
|||
} |
|||
|
|||
.default-process-config-dialog .default-process-config-empty { |
|||
margin: 12px 0; |
|||
padding: 12px; |
|||
border: 1px dashed #dcdfe6; |
|||
border-radius: 4px; |
|||
color: #909399; |
|||
text-align: center; |
|||
} |
|||
|
|||
.default-process-config-dialog .default-process-drag-handle { |
|||
color: #909399; |
|||
cursor: move; |
|||
font-size: 15px; |
|||
margin-right: 6px; |
|||
} |
|||
|
|||
.default-process-config-dialog .default-process-order-index { |
|||
color: #606266; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
.default-process-config-dialog .el-table__body-wrapper tbody tr { |
|||
cursor: move; |
|||
} |
|||
|
|||
.default-process-config-dialog .el-table__body-wrapper tbody tr .el-input__inner { |
|||
cursor: text; |
|||
} |
|||
|
|||
.default-process-config-dialog .el-table__body-wrapper tbody tr .el-checkbox__inner, |
|||
.default-process-config-dialog .el-table__body-wrapper tbody tr .el-select .el-input__inner { |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.process-category-config-dialog .default-process-config-actions { |
|||
margin-bottom: 8px; |
|||
} |
|||
|
|||
.process-category-config-dialog .el-table__body-wrapper tbody tr .el-input__inner { |
|||
cursor: text; |
|||
} |
|||
|
|||
.default-process-sortable-ghost > td { |
|||
background: #f0f9ff !important; |
|||
} |
|||
|
|||
.default-process-sortable-chosen > td { |
|||
background: #ecf5ff !important; |
|||
} |
|||
|
|||
.button-col { |
|||
margin-bottom: 8px; |
|||
} |
|||
|
|||
.button-col .el-button { |
|||
width: 100%; |
|||
} |
|||
|
|||
.one-key-grid-form { |
|||
padding: 0 8px; |
|||
} |
|||
|
|||
.one-key-grid-form .el-form-item { |
|||
margin-bottom: 10px; |
|||
} |
|||
|
|||
.one-key-suggest-main { |
|||
color: #303133; |
|||
font-size: 12px; |
|||
line-height: 18px; |
|||
} |
|||
|
|||
.one-key-suggest-sub { |
|||
color: #909399; |
|||
font-size: 12px; |
|||
line-height: 16px; |
|||
} |
|||
|
|||
.proof-grid-form { |
|||
padding: 0 8px; |
|||
} |
|||
|
|||
.proof-grid-form .el-form-item { |
|||
margin-bottom: 10px; |
|||
} |
|||
|
|||
/* 独立占位,避免被固定高度的表单项内容区挤出后盖住下一行。 */ |
|||
.apply-qty-reference { |
|||
padding: 2px 8px; |
|||
border-radius: 4px; |
|||
background: #ecf5ff; |
|||
color: #3d77b1; |
|||
font-size: 12px; |
|||
line-height: 18px; |
|||
box-sizing: border-box; |
|||
word-break: break-word; |
|||
} |
|||
|
|||
.big-label a { |
|||
color: #35b4b4; |
|||
} |
|||
|
|||
.project-part-sync-text { |
|||
display: inline-flex; |
|||
align-items: center; |
|||
} |
|||
|
|||
.npi-jump-link { |
|||
color: #0c4dbb; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
|
|||
.npi-jump-link:hover { |
|||
text-decoration: underline; |
|||
} |
|||
|
|||
.project-part-sync-icon { |
|||
margin-left: -4px; |
|||
margin-right: 2px; |
|||
color: #1f7a35; |
|||
font-size: 10px; |
|||
transform: translateY(-1px); |
|||
} |
|||
|
|||
.tracking-status { |
|||
width: 100%; |
|||
min-height: 26px; |
|||
padding: 4px 6px; |
|||
box-sizing: border-box; |
|||
border: 1px solid #dcdfe6; |
|||
border-radius: 4px; |
|||
background: #fff; |
|||
color: #303133; |
|||
font-weight: 500; |
|||
line-height: 18px; |
|||
text-align: left; |
|||
overflow: hidden; |
|||
text-overflow: ellipsis; |
|||
white-space: nowrap; |
|||
} |
|||
|
|||
.tracking-status--on-schedule { |
|||
background: #e8f5e9; |
|||
} |
|||
|
|||
.tracking-status--delay { |
|||
background: #fde2e2; |
|||
} |
|||
|
|||
.delivery-variance-alert { |
|||
color: #f56c6c; |
|||
font-weight: 700; |
|||
} |
|||
|
|||
.tracking-status--unknown { |
|||
background: #f4f4f5; |
|||
} |
|||
|
|||
.tracking-status--complete { |
|||
background: #f4f4f5; |
|||
color: #909399; |
|||
} |
|||
|
|||
.process-cell { |
|||
background: #fff; |
|||
min-height: 44px; |
|||
padding: 4px 2px; |
|||
} |
|||
|
|||
.process-cell.is-complete { |
|||
background: #ececec; |
|||
} |
|||
|
|||
.process-cell.is-complete .el-input__inner { |
|||
background: #ececec; |
|||
border-color: #d5d7de; |
|||
color: #8c8c8c; |
|||
} |
|||
|
|||
.process-cell.is-complete .el-input.is-disabled .el-input__inner { |
|||
background: #ececec; |
|||
color: #8c8c8c; |
|||
} |
|||
|
|||
.process-cell.is-complete .process-date-display { |
|||
color: #8c8c8c; |
|||
} |
|||
|
|||
.process-cell.is-complete .process-date-display--editable:hover { |
|||
background: #ececec; |
|||
border-color: #d5d7de; |
|||
} |
|||
|
|||
.process-cell.is-complete .link-date { |
|||
color: #8c8c8c; |
|||
} |
|||
|
|||
.process-cell.is-complete .link-date:hover, |
|||
.process-cell.is-complete .link-date:focus { |
|||
color: #8c8c8c; |
|||
} |
|||
|
|||
.process-cell--masked { |
|||
background: transparent !important; |
|||
} |
|||
|
|||
.process-content { |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: center; |
|||
gap: 4px; |
|||
text-align: center; |
|||
line-height: 18px; |
|||
} |
|||
|
|||
.process-readonly-content { |
|||
position: relative; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: center; |
|||
width: 100%; |
|||
} |
|||
|
|||
.process-date-display { |
|||
display: inline-block; |
|||
min-width: 74px; |
|||
text-align: center; |
|||
color: #606266; |
|||
margin-right: 26px; |
|||
} |
|||
|
|||
.process-date-display--editable { |
|||
min-width: 100px; |
|||
min-height: 24px; |
|||
line-height: 24px; |
|||
margin-right: 0; |
|||
padding: 0 6px; |
|||
border: 1px solid transparent; |
|||
border-radius: 4px; |
|||
cursor: pointer; |
|||
user-select: none; |
|||
box-sizing: border-box; |
|||
} |
|||
|
|||
.process-date-display--editable:hover { |
|||
border-color: #dcdfe6; |
|||
background: #fff; |
|||
} |
|||
|
|||
.process-complete-btn { |
|||
padding: 4px 8px; |
|||
min-width: 12px; |
|||
} |
|||
|
|||
.process-rollback-btn { |
|||
padding: 4px 6px; |
|||
min-width: 12px; |
|||
} |
|||
|
|||
.process-rollback-btn--readonly { |
|||
position: absolute; |
|||
right: 0; |
|||
top: 50%; |
|||
transform: translateY(-50%); |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .comments-cell { |
|||
display: flex; |
|||
align-items: center; |
|||
gap: 4px; |
|||
height: 28px; |
|||
min-width: 0; |
|||
} |
|||
|
|||
.comments-edit-input { |
|||
flex: 1; |
|||
} |
|||
|
|||
.comments-save-btn { |
|||
padding: 4px 7px; |
|||
min-width: 28px; |
|||
} |
|||
|
|||
.cost-rate-tip { |
|||
display: inline-flex; |
|||
align-items: center; |
|||
margin-left: 10px; |
|||
color: #606266; |
|||
font-size: 12px; |
|||
line-height: 18px; |
|||
white-space: nowrap; |
|||
} |
|||
|
|||
.cost-rate-input { |
|||
width: 120px; |
|||
margin-left: 6px; |
|||
} |
|||
|
|||
.cost-cell { |
|||
min-height: 24px; |
|||
} |
|||
|
|||
.cost-display--editable { |
|||
display: inline-block; |
|||
width: 100%; |
|||
min-height: 24px; |
|||
line-height: 24px; |
|||
padding: 0 4px; |
|||
border: 1px solid transparent; |
|||
border-radius: 4px; |
|||
cursor: pointer; |
|||
box-sizing: border-box; |
|||
} |
|||
|
|||
.cost-display--editable:hover { |
|||
border-color: #dcdfe6; |
|||
background: #fff; |
|||
} |
|||
|
|||
.el-table.proof-tracking-table .cost-editor { |
|||
width: 100%; |
|||
} |
|||
|
|||
.cost-calculated-text { |
|||
color: #606266; |
|||
} |
|||
|
|||
/* Comments 两行共 28px,与原单元格内容高度一致,不撑高整行 */ |
|||
.el-table.proof-tracking-table .comments-text { |
|||
display: -webkit-box; |
|||
-webkit-box-orient: vertical; |
|||
-webkit-line-clamp: 2; |
|||
width: 100%; |
|||
min-width: 0; |
|||
max-height: 28px; |
|||
font-size: 11px; |
|||
line-height: 14px; |
|||
overflow: hidden; |
|||
text-overflow: ellipsis; |
|||
white-space: pre-wrap; |
|||
word-break: break-word; |
|||
overflow-wrap: anywhere; |
|||
} |
|||
|
|||
.process-date-tooltip { |
|||
white-space: pre-line; |
|||
} |
|||
|
|||
.process-history-tooltip { |
|||
position: fixed; |
|||
z-index: 3000; |
|||
max-width: 220px; |
|||
padding: 10px 12px; |
|||
border-radius: 4px; |
|||
background: rgba(48, 49, 51, 0.95); |
|||
color: #fff; |
|||
font-size: 12px; |
|||
line-height: 1.5; |
|||
white-space: pre-line; |
|||
pointer-events: none; |
|||
} |
|||
|
|||
.link-date { |
|||
color: #0c4dbb; |
|||
text-decoration: none; |
|||
} |
|||
|
|||
.link-date:hover, |
|||
.link-date:focus { |
|||
text-decoration: none; |
|||
} |
|||
|
|||
.actual-date { |
|||
margin-top: 2px; |
|||
color: #666; |
|||
} |
|||
|
|||
.finish-dialog-tip { |
|||
display: flex; |
|||
align-items: center; |
|||
gap: 8px; |
|||
margin-bottom: 10px; |
|||
padding: 8px 10px; |
|||
border-radius: 4px; |
|||
background: #f4f8ff; |
|||
color: #3a4b5f; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
.finish-dialog-tip i { |
|||
color: #409eff; |
|||
} |
|||
|
|||
.finish-tip-highlight { |
|||
font-size: 13px; |
|||
font-weight: 700; |
|||
color: #1f2d3d; |
|||
} |
|||
|
|||
.finish-proof-dialog .el-dialog__body { |
|||
padding-bottom: 8px; |
|||
} |
|||
|
|||
.finish-form .el-form-item { |
|||
margin-bottom: 14px; |
|||
} |
|||
|
|||
.action-link { |
|||
color: #0c4dbb; |
|||
margin: 0 4px; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.edit-link { |
|||
color: #e6a23c; |
|||
} |
|||
|
|||
.end-link { |
|||
color: #a303ff; |
|||
} |
|||
|
|||
.zxClass .cell { |
|||
line-height: 24px; |
|||
font-size: 12px; |
|||
height: 24px; |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue