|
|
|
@ -296,7 +296,7 @@ |
|
|
|
@query="handleSearch" /> |
|
|
|
|
|
|
|
<!-- 新增 PO 订单(主记录 + 明细暂存) --> |
|
|
|
<el-dialog title="新增 PO 订单" :visible.sync="addDialogVisible" width="1180px" top="4vh" |
|
|
|
<el-dialog title="新增 PO 订单" v-drag :visible.sync="addDialogVisible" width="1180px" top="4vh" |
|
|
|
:close-on-click-modal="false" append-to-body> |
|
|
|
<div class="po-add-form-wrap"> |
|
|
|
<el-form ref="addMasterFormRef" :model="addForm" label-position="top" size="small"> |
|
|
|
@ -353,20 +353,21 @@ |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
<div class="po-add-detail-toolbar"> |
|
|
|
<span class="po-add-detail-title">明细暂存列表</span> |
|
|
|
<div> |
|
|
|
<el-button type="primary" size="mini" @click="openAddDetailDialog">新增</el-button> |
|
|
|
<el-button size="mini" :disabled="!hasSelectedAddDetailRow" @click="openEditAddDetailDialog">修改</el-button> |
|
|
|
<el-button size="mini" :disabled="!hasSelectedAddDetailRow" @click="removeAddDetailRow">删除</el-button> |
|
|
|
<el-button size="mini" :disabled="!hasSelectedAddDetailRow" @click="openCopyAddDetailDialog">复制</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<el-form :inline="true" label-position="top" style="text-align: right;margin-top:0px "> |
|
|
|
<el-form-item style="text-align: right;"> |
|
|
|
<el-button type="primary" @click="openAddDetailDialog">新增</el-button> |
|
|
|
<el-button :disabled="!hasSelectedAddDetailRow" @click="openCopyAddDetailDialog">复制</el-button> |
|
|
|
<el-button :disabled="!hasSelectedAddDetailRow" @click="openEditAddDetailDialog">修改</el-button> |
|
|
|
<el-button :disabled="!hasSelectedAddDetailRow" @click="removeAddDetailRow">删除</el-button> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
|
|
|
|
<el-table |
|
|
|
ref="addDetailTable" |
|
|
|
:data="addDetailRows" |
|
|
|
:height="320" |
|
|
|
:height="280" |
|
|
|
border |
|
|
|
stripe |
|
|
|
highlight-current-row |
|
|
|
@ -374,14 +375,18 @@ |
|
|
|
@current-change="onAddDetailCurrentChange" |
|
|
|
@row-click="onAddDetailRowClick"> |
|
|
|
<el-table-column type="index" label="#" width="50" header-align="center" align="center" /> |
|
|
|
<el-table-column prop="partNo" :label="getAddTableColumnLabel('part_no', '产品编码')" min-width="150" header-align="center" align="center" /> |
|
|
|
<el-table-column prop="item" :label="getAddTableColumnLabel('item', 'Item')" min-width="120" header-align="center" align="center" /> |
|
|
|
<el-table-column prop="sku" :label="getAddTableColumnLabel('sku', 'SKU')" min-width="120" header-align="center" align="center" /> |
|
|
|
<el-table-column prop="qty" :label="getAddTableColumnLabel('qty', 'PO Qty')" min-width="110" header-align="center" align="right" /> |
|
|
|
<el-table-column prop="price" :label="getAddTableColumnLabel('price', 'Unit Price')" min-width="120" header-align="center" align="right" /> |
|
|
|
<el-table-column prop="value" :label="getAddTableColumnLabel('value', 'PO Value')" min-width="120" header-align="center" align="right" /> |
|
|
|
<el-table-column prop="wantReceiveDate" :label="getAddTableColumnLabel('want_receive_date', 'Promise Date')" min-width="130" header-align="center" align="center" /> |
|
|
|
<el-table-column prop="remark" :label="getAddTableColumnLabel('remark', 'Comments')" min-width="220" header-align="center" align="left" show-overflow-tooltip /> |
|
|
|
<el-table-column |
|
|
|
v-for="field in addDetailTableFields" |
|
|
|
:key="`detail-col-${field.fieldCode}`" |
|
|
|
:label="field.fieldLabel" |
|
|
|
:min-width="getAddDetailTableColumnWidth(field)" |
|
|
|
header-align="center" |
|
|
|
:align="getAddDetailTableColumnAlign(field)" |
|
|
|
show-overflow-tooltip> |
|
|
|
<template slot-scope="{ row }"> |
|
|
|
{{ getAddDetailTableCellDisplay(row, field) }} |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
<div slot="footer" class="dialog-footer"> |
|
|
|
@ -392,6 +397,7 @@ |
|
|
|
|
|
|
|
<!-- 新增明细弹窗 --> |
|
|
|
<el-dialog |
|
|
|
v-drag |
|
|
|
:title="addDetailDialogTitle" |
|
|
|
:visible.sync="addDetailDialogVisible" |
|
|
|
width="1000px" |
|
|
|
@ -627,7 +633,9 @@ export default { |
|
|
|
|
|
|
|
addDialogVisible: false, |
|
|
|
addFormSaving: false, |
|
|
|
addDialogSchemaLoading: false, |
|
|
|
addFormSchemaFields: [], |
|
|
|
addDictSelectOptionsMap: {}, |
|
|
|
pickContext: '', |
|
|
|
eamTagNo: '', |
|
|
|
eamPickField: '', |
|
|
|
@ -1710,7 +1718,7 @@ export default { |
|
|
|
return [] |
|
|
|
} |
|
|
|
const sortedFields = this.addFormSchemaFields |
|
|
|
.filter(f => f && f.visibleFlag === 'Y' && !this.isExtSchemaField(f)) |
|
|
|
.filter(f => f && f.visibleFlag === 'Y' && !this.isExtSchemaField(f) && this.getAddFieldCode(f) !== 'crd_ori') |
|
|
|
.slice() |
|
|
|
.sort((a, b) => { |
|
|
|
const sa = Number(a && a.sortNo) |
|
|
|
@ -1736,6 +1744,27 @@ export default { |
|
|
|
addDetailBaseFields () { |
|
|
|
return this.addBaseFields.filter(field => !this.isAddMasterField(field)) |
|
|
|
}, |
|
|
|
addDetailTableFields () { |
|
|
|
const merged = [] |
|
|
|
const seen = new Set() |
|
|
|
const pushField = (field) => { |
|
|
|
if (!field) { |
|
|
|
return |
|
|
|
} |
|
|
|
const code = this.getAddFieldCode(field) |
|
|
|
if (!code || seen.has(code)) { |
|
|
|
return |
|
|
|
} |
|
|
|
seen.add(code) |
|
|
|
merged.push({ |
|
|
|
...field, |
|
|
|
fieldLabel: field.fieldLabel || this.getAddTableColumnLabel(code, code) |
|
|
|
}) |
|
|
|
} |
|
|
|
this.addDetailBaseFields.forEach(pushField) |
|
|
|
this.addDetailExtFields.forEach(pushField) |
|
|
|
return merged |
|
|
|
}, |
|
|
|
hasSelectedAddDetailRow () { |
|
|
|
if (!this.addDetailCurrentDraftId) { |
|
|
|
return false |
|
|
|
@ -1916,7 +1945,24 @@ export default { |
|
|
|
return false |
|
|
|
} |
|
|
|
const mandatoryFlag = String((field && field.mandatoryFlag) || '').trim().toUpperCase() |
|
|
|
return mandatoryFlag === 'Y' |
|
|
|
if (mandatoryFlag === 'Y') { |
|
|
|
return true |
|
|
|
} |
|
|
|
// 与 PO_No 同口径:优先走字段元数据分层,不做单字段特判。 |
|
|
|
const bizLevel = String((field && field.bizLevel) || '').trim().toUpperCase() |
|
|
|
if (bizLevel === 'HEADER') { |
|
|
|
return true |
|
|
|
} |
|
|
|
// VIRTUAL 中位于 Part No 之前的字段(如供应商简称)归入主记录区。 |
|
|
|
if (bizLevel === 'VIRTUAL') { |
|
|
|
const virtualSortNo = Number(field && field.sortNo) |
|
|
|
const partField = this.getSchemaFieldByCode('part_no') |
|
|
|
const partSortNo = Number(partField && partField.sortNo) |
|
|
|
if (Number.isFinite(virtualSortNo) && Number.isFinite(partSortNo) && virtualSortNo < partSortNo) { |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
}, |
|
|
|
getSchemaFieldByCode (fieldCode) { |
|
|
|
const normalizedCode = String(fieldCode || '').trim().toLowerCase() |
|
|
|
@ -1929,6 +1975,62 @@ export default { |
|
|
|
const field = this.getSchemaFieldByCode(fieldCode) |
|
|
|
return (field && field.fieldLabel) || fallback || fieldCode |
|
|
|
}, |
|
|
|
getAddDetailTableColumnAlign (field) { |
|
|
|
if (this.isAddNumberField(field)) { |
|
|
|
return 'right' |
|
|
|
} |
|
|
|
if (this.isAddDateField(field)) { |
|
|
|
return 'center' |
|
|
|
} |
|
|
|
return 'left' |
|
|
|
}, |
|
|
|
getAddDetailTableColumnWidth (field) { |
|
|
|
const code = this.getAddFieldCode(field) |
|
|
|
if (ADD_FULL_ROW_FIELD_CODES.has(code)) { |
|
|
|
return 220 |
|
|
|
} |
|
|
|
if (this.isAddDateField(field)) { |
|
|
|
return 140 |
|
|
|
} |
|
|
|
if (this.isAddNumberField(field)) { |
|
|
|
return 120 |
|
|
|
} |
|
|
|
if (code === 'part_no') { |
|
|
|
return 150 |
|
|
|
} |
|
|
|
return 140 |
|
|
|
}, |
|
|
|
getAddDetailTableCellDisplay (row, field) { |
|
|
|
if (!row || !field) { |
|
|
|
return '' |
|
|
|
} |
|
|
|
const code = this.getAddFieldCode(field) |
|
|
|
let value = '' |
|
|
|
if (this.isExtSchemaField(field)) { |
|
|
|
value = this.getFormExtValue(row, code) |
|
|
|
} else { |
|
|
|
const prop = this.getAddFieldProp(field) |
|
|
|
value = prop ? row[prop] : '' |
|
|
|
} |
|
|
|
if (value === null || value === undefined || value === '') { |
|
|
|
return '' |
|
|
|
} |
|
|
|
if (this.isAddDateField(field)) { |
|
|
|
if (value instanceof Date) { |
|
|
|
const pad = (num) => String(num).padStart(2, '0') |
|
|
|
return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}` |
|
|
|
} |
|
|
|
const text = String(value) |
|
|
|
return text.length >= 10 ? text.substring(0, 10) : text |
|
|
|
} |
|
|
|
if (this.isAddNumberField(field)) { |
|
|
|
const normalized = this.normalizeAddNumericValue(value) |
|
|
|
if (normalized !== '') { |
|
|
|
return normalized |
|
|
|
} |
|
|
|
} |
|
|
|
return value |
|
|
|
}, |
|
|
|
snakeToCamel (text) { |
|
|
|
return String(text || '').replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase()) |
|
|
|
}, |
|
|
|
@ -1964,19 +2066,29 @@ export default { |
|
|
|
getAddFieldSelectOptions (field) { |
|
|
|
const code = this.getAddFieldCode(field) |
|
|
|
const optionsKey = ADD_SELECT_OPTIONS_FIELD_CODE_MAP[code] |
|
|
|
if (!optionsKey) { |
|
|
|
return [] |
|
|
|
} |
|
|
|
if (Array.isArray(this[optionsKey])) { |
|
|
|
return this[optionsKey] |
|
|
|
if (optionsKey) { |
|
|
|
if (Array.isArray(this[optionsKey])) { |
|
|
|
return this[optionsKey] |
|
|
|
} |
|
|
|
if (this.columnSelectOptions && Array.isArray(this.columnSelectOptions[optionsKey])) { |
|
|
|
return this.columnSelectOptions[optionsKey] |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.columnSelectOptions && Array.isArray(this.columnSelectOptions[optionsKey])) { |
|
|
|
return this.columnSelectOptions[optionsKey] |
|
|
|
if (this.isAddDictSelectField(field)) { |
|
|
|
const dictType = String((field && field.dictType) || '').trim() |
|
|
|
if (!dictType) { |
|
|
|
return [] |
|
|
|
} |
|
|
|
return this.addDictSelectOptionsMap[dictType] || [] |
|
|
|
} |
|
|
|
return [] |
|
|
|
}, |
|
|
|
isAddDictSelectField (field) { |
|
|
|
const editorType = String((field && field.editorType) || '').trim().toLowerCase() |
|
|
|
return editorType === 'dict-select' || editorType === 'dict_select' |
|
|
|
}, |
|
|
|
isAddSelectField (field) { |
|
|
|
return this.getAddFieldSelectOptions(field).length > 0 |
|
|
|
return this.isAddDictSelectField(field) || this.getAddFieldSelectOptions(field).length > 0 |
|
|
|
}, |
|
|
|
isAddFilterableSelectField (field) { |
|
|
|
return ADD_FILTERABLE_SELECT_FIELD_CODES.has(this.getAddFieldCode(field)) |
|
|
|
@ -2317,6 +2429,53 @@ export default { |
|
|
|
this.dictSelectOptionsMap = nextMap |
|
|
|
}) |
|
|
|
}, |
|
|
|
preloadAddDictSelectOptions (schemaFields) { |
|
|
|
const site = this.searchData.site || this.$store.state.user.site |
|
|
|
if (!site || !Array.isArray(schemaFields) || schemaFields.length === 0) { |
|
|
|
this.addDictSelectOptionsMap = {} |
|
|
|
return Promise.resolve() |
|
|
|
} |
|
|
|
const dictTypeSet = new Set() |
|
|
|
schemaFields.forEach(field => { |
|
|
|
if (!this.isAddDictSelectField(field)) { |
|
|
|
return |
|
|
|
} |
|
|
|
const dictType = String((field && field.dictType) || '').trim() |
|
|
|
if (dictType) { |
|
|
|
dictTypeSet.add(dictType) |
|
|
|
} |
|
|
|
}) |
|
|
|
const dictTypes = Array.from(dictTypeSet) |
|
|
|
if (dictTypes.length === 0) { |
|
|
|
this.addDictSelectOptionsMap = {} |
|
|
|
return Promise.resolve() |
|
|
|
} |
|
|
|
const nextMap = {} |
|
|
|
const loaders = dictTypes.map(dictType => { |
|
|
|
return selectDictDataList({ |
|
|
|
site, |
|
|
|
dictType, |
|
|
|
dictTypeList: [], |
|
|
|
status: 'Y' |
|
|
|
}).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
nextMap[dictType] = (data.rows || []).map(item => ({ |
|
|
|
label: item.dictLabel || item.dictValue, |
|
|
|
value: item.dictValue |
|
|
|
})) |
|
|
|
} else { |
|
|
|
nextMap[dictType] = [] |
|
|
|
this.$message.error((data && data.msg) || `字典加载失败: ${dictType}`) |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
nextMap[dictType] = [] |
|
|
|
this.$message.error(`字典加载失败: ${dictType}`) |
|
|
|
}) |
|
|
|
}) |
|
|
|
return Promise.all(loaders).then(() => { |
|
|
|
this.addDictSelectOptionsMap = nextMap |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
buildQueryRequest() { |
|
|
|
return buildPoOrderQueryParams({ |
|
|
|
@ -2331,6 +2490,7 @@ export default { |
|
|
|
this.searchData.customer = customer |
|
|
|
this.selectedCustomerScope = customerOption || null |
|
|
|
this.dictSelectOptionsMap = {} |
|
|
|
this.advancedQueryData.rows = [] |
|
|
|
this.getBuyerOptions(customer) |
|
|
|
this.pageIndex = 1 |
|
|
|
this.masterRows = [] |
|
|
|
@ -2339,6 +2499,7 @@ export default { |
|
|
|
if (!customer) { |
|
|
|
this.selectedCustomerScope = null |
|
|
|
this.fieldSchemaFields = [] |
|
|
|
this.advancedQueryData.rows = [] |
|
|
|
this.poBuyerOptions = [] |
|
|
|
this.columnSelectOptions.poBuyerOptions = [] |
|
|
|
this.refreshTableLayout() |
|
|
|
@ -2363,12 +2524,14 @@ export default { |
|
|
|
return this.preloadDictSelectOptions(this.fieldSchemaFields) |
|
|
|
} else { |
|
|
|
this.fieldSchemaFields = [] |
|
|
|
this.advancedQueryData.rows = [] |
|
|
|
this.$message.error((data && data.msg) || '加载字段权限失败') |
|
|
|
} |
|
|
|
}).then(() => { |
|
|
|
this.refreshTableLayout() |
|
|
|
}).catch(() => { |
|
|
|
this.fieldSchemaFields = [] |
|
|
|
this.advancedQueryData.rows = [] |
|
|
|
this.$message.error('加载字段权限失败') |
|
|
|
this.refreshTableLayout() |
|
|
|
}) |
|
|
|
@ -3248,6 +3411,9 @@ export default { |
|
|
|
this.$message.warning('请选择customer') |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.addDialogSchemaLoading) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.addPriceLookupTimer) { |
|
|
|
clearTimeout(this.addPriceLookupTimer) |
|
|
|
this.addPriceLookupTimer = null |
|
|
|
@ -3255,14 +3421,25 @@ export default { |
|
|
|
this.addPriceLookupSeq += 1 |
|
|
|
this.addForm = this.createEmptyAddForm(this.resolveAddOrderTypeByCustomer()) |
|
|
|
this.addForm.customer = this.searchData.customer |
|
|
|
this.addFormSchemaFields = [] |
|
|
|
this.addDictSelectOptionsMap = {} |
|
|
|
this.addDetailRows = [] |
|
|
|
this.addDetailCurrentDraftId = '' |
|
|
|
this.addDetailDialogMode = 'create' |
|
|
|
this.addDetailDialogVisible = false |
|
|
|
this.addDetailEditingDraftId = '' |
|
|
|
this.addDetailForm = this.createEmptyAddDetailForm() |
|
|
|
this.addDialogVisible = true |
|
|
|
this.loadAddFieldSchema(this.searchData.customer) |
|
|
|
this.addDetailForm = this.createEmptyAddForm(this.addForm.orderType || this.resolveAddOrderTypeByCustomer()) |
|
|
|
this.addDialogVisible = false |
|
|
|
this.addDialogSchemaLoading = true |
|
|
|
this.loadAddFieldSchema(this.searchData.customer).then(success => { |
|
|
|
if (!success) { |
|
|
|
return |
|
|
|
} |
|
|
|
this.addDetailForm = this.createEmptyAddDetailForm() |
|
|
|
this.addDialogVisible = true |
|
|
|
}).finally(() => { |
|
|
|
this.addDialogSchemaLoading = false |
|
|
|
}) |
|
|
|
if (!this.poPartNoOptions.length) { |
|
|
|
this.getPartNoOptions() |
|
|
|
} |
|
|
|
@ -3281,12 +3458,18 @@ export default { |
|
|
|
if (data && data.code === 0 && data.data) { |
|
|
|
this.addFormSchemaFields = data.data.fields || [] |
|
|
|
this.applyAddDefaultDateBySchema() |
|
|
|
this.addDetailForm = this.createEmptyAddDetailForm() |
|
|
|
return this.preloadAddDictSelectOptions(this.addFormSchemaFields).then(() => true) |
|
|
|
} else { |
|
|
|
this.addFormSchemaFields = [] |
|
|
|
this.addDictSelectOptionsMap = {} |
|
|
|
this.$message.error((data && data.msg) || '加载新增字段权限失败') |
|
|
|
return false |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
this.addFormSchemaFields = [] |
|
|
|
this.addDictSelectOptionsMap = {} |
|
|
|
this.$message.error('加载新增字段权限失败') |
|
|
|
return false |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
@ -3422,6 +3605,7 @@ export default { |
|
|
|
|
|
|
|
buildAddDetailRowFromForm () { |
|
|
|
const row = this.cloneAddDraftRow(this.addDetailForm) |
|
|
|
this.removeAddMasterFieldValuesFromDetailRow(row) |
|
|
|
if (!row._draftId) { |
|
|
|
this.addDetailDraftSeq += 1 |
|
|
|
row._draftId = `DRAFT_${Date.now()}_${this.addDetailDraftSeq}` |
|
|
|
@ -3430,6 +3614,21 @@ export default { |
|
|
|
return row |
|
|
|
}, |
|
|
|
|
|
|
|
removeAddMasterFieldValuesFromDetailRow (row) { |
|
|
|
if (!row || typeof row !== 'object') { |
|
|
|
return |
|
|
|
} |
|
|
|
this.addMasterBaseFields.forEach(field => { |
|
|
|
const prop = this.getAddFieldProp(field) |
|
|
|
if (!prop) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (Object.prototype.hasOwnProperty.call(row, prop)) { |
|
|
|
delete row[prop] |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
getSelectedAddDetailRow () { |
|
|
|
if (!this.addDetailCurrentDraftId) { |
|
|
|
return null |
|
|
|
@ -3759,19 +3958,11 @@ export default { |
|
|
|
<style scoped lang="scss"> |
|
|
|
.po-add-form-wrap { |
|
|
|
max-height: calc(100vh - 210px); |
|
|
|
overflow-y: scroll; |
|
|
|
overflow-y: auto; |
|
|
|
overflow-x: hidden; |
|
|
|
padding: 0 12px 8px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 预留滚动槽位,避免滚动条出现/消失导致表单宽度抖动 */ |
|
|
|
@supports (scrollbar-gutter: stable) { |
|
|
|
.po-add-form-wrap { |
|
|
|
overflow-y: auto; |
|
|
|
scrollbar-gutter: stable both-edges; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* 防止滚动条切换时标签换行,进一步降低布局抖动 */ |
|
|
|
.po-add-form-wrap /deep/ .el-form--label-top .el-form-item__label { |
|
|
|
white-space: nowrap; |
|
|
|
|