| | |
| | | export function createTransferSearchState() { |
| | | return { |
| | | condition: '', |
| | | timeStart: '', |
| | | timeEnd: '', |
| | | code: '', |
| | | type: '', |
| | | source: '', |
| | | exceStatus: '', |
| | | orgWareId: '', |
| | | orgWareName: '', |
| | | tarWareId: '', |
| | | tarWareName: '', |
| | | orgAreaId: '', |
| | | orgAreaName: '', |
| | | tarAreaId: '', |
| | | tarAreaName: '', |
| | | memo: '', |
| | | status: '', |
| | | timeStart: '', |
| | | timeEnd: '' |
| | | orderBy: 'create_time desc' |
| | | } |
| | | } |
| | | |
| | |
| | | export function buildTransferDialogModel(record = {}) { |
| | | return { |
| | | ...createTransferFormState(), |
| | | ...(record.id !== undefined && record.id !== null && record.id !== '' ? { id: Number(record.id) } : {}), |
| | | ...(record.id !== undefined && record.id !== null && record.id !== '' |
| | | ? { id: Number(record.id) } |
| | | : {}), |
| | | code: normalizeText(record.code || ''), |
| | | type: record.type !== undefined && record.type !== null && record.type !== '' ? Number(record.type) : '', |
| | | source: record.source !== undefined && record.source !== null && record.source !== '' ? Number(record.source) : 2, |
| | | type: |
| | | record.type !== undefined && record.type !== null && record.type !== '' |
| | | ? Number(record.type) |
| | | : '', |
| | | source: |
| | | record.source !== undefined && record.source !== null && record.source !== '' |
| | | ? Number(record.source) |
| | | : 2, |
| | | exceStatus: |
| | | record.exceStatus !== undefined && record.exceStatus !== null && record.exceStatus !== '' |
| | | ? Number(record.exceStatus) |
| | |
| | | : void 0, |
| | | status: record.status !== undefined && record.status !== null ? Number(record.status) : 1, |
| | | memo: normalizeText(record.memo || '') |
| | | } |
| | | } |
| | | |
| | | function createTransferItemRowKey(record = {}) { |
| | | const keySeed = [ |
| | | record.id ?? 'new', |
| | | record.transferId ?? 'transfer', |
| | | record.matnrId ?? 'matnr', |
| | | record.batch ?? '', |
| | | record.fieldsIndex ?? '' |
| | | ] |
| | | return keySeed.join('-') |
| | | } |
| | | |
| | | function resolveDynamicFieldValues(record = {}, fieldDefinitions = []) { |
| | | return Object.fromEntries( |
| | | (Array.isArray(fieldDefinitions) ? fieldDefinitions : []).map((item) => [ |
| | | item.fields, |
| | | record[item.fields] ?? record.extendFields?.[item.fields] ?? '' |
| | | ]) |
| | | ) |
| | | } |
| | | |
| | | export function buildTransferManageDialogModel(record = {}, fieldDefinitions = []) { |
| | | const transferRecord = record?.transfer || record || {} |
| | | const itemRecords = Array.isArray(record?.items) ? record.items : [] |
| | | return { |
| | | transfer: buildTransferDialogModel(transferRecord), |
| | | items: itemRecords.map((item) => buildTransferEditableItem(item, fieldDefinitions)) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | export function buildTransferSearchParams(params = {}) { |
| | | const result = {} |
| | | ;['condition', 'code', 'orgWareName', 'tarWareName', 'orgAreaName', 'tarAreaName', 'memo'].forEach((key) => { |
| | | ;[ |
| | | 'condition', |
| | | 'code', |
| | | 'orgWareName', |
| | | 'tarWareName', |
| | | 'orgAreaName', |
| | | 'tarAreaName', |
| | | 'memo' |
| | | ].forEach((key) => { |
| | | const value = normalizeText(params[key]) |
| | | if (value) result[key] = value |
| | | }) |
| | | ;['type', 'source', 'exceStatus', 'status', 'orgWareId', 'tarWareId', 'orgAreaId', 'tarAreaId'].forEach((key) => { |
| | | ;[ |
| | | 'type', |
| | | 'source', |
| | | 'exceStatus', |
| | | 'status', |
| | | 'orgWareId', |
| | | 'tarWareId', |
| | | 'orgAreaId', |
| | | 'tarAreaId' |
| | | ].forEach((key) => { |
| | | if (params[key] !== '' && params[key] !== undefined && params[key] !== null) { |
| | | result[key] = normalizeNumber(params[key]) |
| | | } |
| | |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | orderBy: normalizeText(params.orderBy) || 'create_time desc', |
| | | ...buildTransferSearchParams(params) |
| | | } |
| | | } |
| | | |
| | | export function buildTransferDetailOrderQueryParams(params = {}) { |
| | | return { |
| | | ...(normalizeNumber(params.id, void 0) !== void 0 |
| | | ? { id: normalizeNumber(params.id, void 0) } |
| | | : {}), |
| | | condition: normalizeText(params.code || params.condition), |
| | | code: normalizeText(params.code || params.condition), |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20 |
| | | pageSize: params.pageSize || params.size || 20, |
| | | orderBy: normalizeText(params.orderBy) || 'create_time desc' |
| | | } |
| | | } |
| | | |
| | |
| | | const tarAreaId = normalizeNumber(formData.tarAreaId, void 0) |
| | | const orgArea = optionMap.get(orgAreaId) || {} |
| | | const tarArea = optionMap.get(tarAreaId) || {} |
| | | const orgWareId = normalizeNumber(orgArea.warehouseId ?? orgArea.warehouse_id ?? orgArea.warehouseIdValue, void 0) |
| | | const tarWareId = normalizeNumber(tarArea.warehouseId ?? tarArea.warehouse_id ?? tarArea.warehouseIdValue, void 0) |
| | | const orgWareId = normalizeNumber( |
| | | orgArea.warehouseId ?? orgArea.warehouse_id ?? orgArea.warehouseIdValue, |
| | | void 0 |
| | | ) |
| | | const tarWareId = normalizeNumber( |
| | | tarArea.warehouseId ?? tarArea.warehouse_id ?? tarArea.warehouseIdValue, |
| | | void 0 |
| | | ) |
| | | |
| | | return { |
| | | ...(formData.id !== undefined && formData.id !== null && formData.id !== '' |
| | |
| | | ...(formData.source !== undefined && formData.source !== null && formData.source !== '' |
| | | ? { source: normalizeNumber(formData.source) } |
| | | : {}), |
| | | ...(formData.exceStatus !== undefined && formData.exceStatus !== null && formData.exceStatus !== '' |
| | | ...(formData.exceStatus !== undefined && |
| | | formData.exceStatus !== null && |
| | | formData.exceStatus !== '' |
| | | ? { exceStatus: normalizeNumber(formData.exceStatus) } |
| | | : {}), |
| | | ...(orgAreaId !== void 0 ? { orgAreaId } : {}), |
| | | ...(tarAreaId !== void 0 ? { tarAreaId } : {}), |
| | | ...(orgWareId !== void 0 ? { orgWareId } : {}), |
| | | ...(tarWareId !== void 0 ? { tarWareId } : {}), |
| | | ...(normalizeText(orgArea.name || orgArea.areaName) ? { orgAreaName: normalizeText(orgArea.name || orgArea.areaName) } : {}), |
| | | ...(normalizeText(tarArea.name || tarArea.areaName) ? { tarAreaName: normalizeText(tarArea.name || tarArea.areaName) } : {}), |
| | | ...(normalizeText(orgArea.warehouseId$ || orgArea.warehouseName) ? { orgWareName: normalizeText(orgArea.warehouseId$ || orgArea.warehouseName) } : {}), |
| | | ...(normalizeText(tarArea.warehouseId$ || tarArea.warehouseName) ? { tarWareName: normalizeText(tarArea.warehouseId$ || tarArea.warehouseName) } : {}), |
| | | ...(normalizeText(orgArea.name || orgArea.areaName) |
| | | ? { orgAreaName: normalizeText(orgArea.name || orgArea.areaName) } |
| | | : {}), |
| | | ...(normalizeText(tarArea.name || tarArea.areaName) |
| | | ? { tarAreaName: normalizeText(tarArea.name || tarArea.areaName) } |
| | | : {}), |
| | | ...(normalizeText(orgArea.warehouseId$ || orgArea.warehouseName) |
| | | ? { orgWareName: normalizeText(orgArea.warehouseId$ || orgArea.warehouseName) } |
| | | : {}), |
| | | ...(normalizeText(tarArea.warehouseId$ || tarArea.warehouseName) |
| | | ? { tarWareName: normalizeText(tarArea.warehouseId$ || tarArea.warehouseName) } |
| | | : {}), |
| | | ...(formData.status !== undefined && formData.status !== null && formData.status !== '' |
| | | ? { status: normalizeNumber(formData.status) } |
| | | : { status: 1 }), |
| | |
| | | } |
| | | |
| | | function resolveAreaText(record = {}, key) { |
| | | return normalizeText(record[`${key}AreaName$`] || record[`${key}AreaName`] || record[`${key}AreaId$`] || record[`${key}AreaId`]) |
| | | return normalizeText( |
| | | record[`${key}AreaName$`] || |
| | | record[`${key}AreaName`] || |
| | | record[`${key}AreaId$`] || |
| | | record[`${key}AreaId`] |
| | | ) |
| | | } |
| | | |
| | | function resolveWarehouseText(record = {}, key) { |
| | | return normalizeText(record[`${key}WareName$`] || record[`${key}WareName`] || record[`${key}WareId$`] || record[`${key}WareId`]) |
| | | return normalizeText( |
| | | record[`${key}WareName$`] || |
| | | record[`${key}WareName`] || |
| | | record[`${key}WareId$`] || |
| | | record[`${key}WareId`] |
| | | ) |
| | | } |
| | | |
| | | export function normalizeTransferRow(record = {}, t = $t) { |
| | | const statusMeta = metaByValue(record.statusBool ?? record.status, getTransferStatusMetaMap(t), t('common.status.unknown')) |
| | | const exceStatusMeta = metaByValue(record.exceStatus, getTransferExceStatusMetaMap(t), record.exceStatusText) |
| | | const statusMeta = metaByValue( |
| | | record.statusBool ?? record.status, |
| | | getTransferStatusMetaMap(t), |
| | | t('common.status.unknown') |
| | | ) |
| | | const exceStatusMeta = metaByValue( |
| | | record.exceStatus, |
| | | getTransferExceStatusMetaMap(t), |
| | | record.exceStatusText |
| | | ) |
| | | const sourceMeta = metaByValue(record.source, getTransferSourceMetaMap(t), record.sourceText) |
| | | return { |
| | | ...record, |
| | |
| | | typeLabel: normalizeText(record['type$'] || record.type) || '--', |
| | | sourceText: sourceMeta.text, |
| | | sourceTagType: sourceMeta.type, |
| | | exceStatusText: normalizeText(record['exceStatus$'] || record.exceStatusText) || exceStatusMeta.text, |
| | | exceStatusText: |
| | | normalizeText(record['exceStatus$'] || record.exceStatusText) || exceStatusMeta.text, |
| | | exceStatusTagType: exceStatusMeta.type, |
| | | orgWareName: resolveWarehouseText(record, 'org') || '--', |
| | | tarWareName: resolveWarehouseText(record, 'tar') || '--', |
| | |
| | | statusType: statusMeta.type, |
| | | statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool, |
| | | createByText: normalizeText(record['createBy$'] || record.createByText) || '--', |
| | | createTimeText: normalizeText(record['createTime$'] || record.createTimeText || record.createTime) || '--', |
| | | createTimeText: |
| | | normalizeText(record['createTime$'] || record.createTimeText || record.createTime) || '--', |
| | | updateByText: normalizeText(record['updateBy$'] || record.updateByText) || '--', |
| | | updateTimeText: normalizeText(record['updateTime$'] || record.updateTimeText || record.updateTime) || '--', |
| | | updateTimeText: |
| | | normalizeText(record['updateTime$'] || record.updateTimeText || record.updateTime) || '--', |
| | | memo: normalizeText(record.memo) || '--' |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | export function normalizeTransferOrderRow(record = {}, t = $t) { |
| | | const statusMeta = metaByValue(record.statusBool ?? record.status, getTransferStatusMetaMap(t), t('common.status.unknown')) |
| | | const exceStatusMeta = metaByValue(record.exceStatus, getTransferExceStatusMetaMap(t), record.exceStatusText) |
| | | const statusMeta = metaByValue( |
| | | record.statusBool ?? record.status, |
| | | getTransferStatusMetaMap(t), |
| | | t('common.status.unknown') |
| | | ) |
| | | const exceStatusMeta = metaByValue( |
| | | record.exceStatus, |
| | | getTransferExceStatusMetaMap(t), |
| | | record.exceStatusText |
| | | ) |
| | | return { |
| | | ...record, |
| | | id: record.id ?? null, |
| | |
| | | poCode: normalizeText(record.poCode) || '--', |
| | | typeLabel: normalizeText(record['type$'] || record.type) || '--', |
| | | wkTypeLabel: normalizeText(record['wkType$'] || record.wkType) || '--', |
| | | exceStatusText: normalizeText(record['exceStatus$'] || record.exceStatusText) || exceStatusMeta.text, |
| | | exceStatusText: |
| | | normalizeText(record['exceStatus$'] || record.exceStatusText) || exceStatusMeta.text, |
| | | exceStatusTagType: exceStatusMeta.type, |
| | | statusText: statusMeta.text, |
| | | statusType: statusMeta.type, |
| | |
| | | workQty: record.workQty ?? '--', |
| | | qty: record.qty ?? '--', |
| | | stationId: normalizeText(record.stationId) || '--', |
| | | businessTimeText: normalizeText(record['businessTime$'] || record.businessTimeText || record.businessTime) || '--', |
| | | businessTimeText: |
| | | normalizeText(record['businessTime$'] || record.businessTimeText || record.businessTime) || |
| | | '--', |
| | | createByText: normalizeText(record['createBy$'] || record.createByText) || '--', |
| | | createTimeText: normalizeText(record['createTime$'] || record.createTimeText || record.createTime) || '--', |
| | | createTimeText: |
| | | normalizeText(record['createTime$'] || record.createTimeText || record.createTime) || '--', |
| | | updateByText: normalizeText(record['updateBy$'] || record.updateByText) || '--', |
| | | updateTimeText: normalizeText(record['updateTime$'] || record.updateTimeText || record.updateTime) || '--', |
| | | updateTimeText: |
| | | normalizeText(record['updateTime$'] || record.updateTimeText || record.updateTime) || '--', |
| | | memo: normalizeText(record.memo) || '--' |
| | | } |
| | | } |
| | | |
| | | export function buildTransferEditableItem(record = {}, fieldDefinitions = []) { |
| | | return { |
| | | __rowKey: createTransferItemRowKey(record), |
| | | id: normalizeNumber(record.id, void 0), |
| | | transferId: normalizeNumber(record.transferId, void 0), |
| | | transferCode: normalizeText(record.transferCode || ''), |
| | | matnrId: normalizeNumber(record.matnrId, void 0), |
| | | maktx: normalizeText(record.maktx || ''), |
| | | matnrCode: normalizeText(record.matnrCode || ''), |
| | | anfme: normalizeNumber(record.anfme, 0) ?? 0, |
| | | splrCode: normalizeText(record.splrCode || ''), |
| | | splrName: normalizeText(record.splrName || ''), |
| | | batch: normalizeText(record.batch || ''), |
| | | unit: normalizeText(record.unit || record.stockUnit || ''), |
| | | stockUnit: normalizeText(record.stockUnit || record.unit || ''), |
| | | spec: normalizeText(record.spec || ''), |
| | | model: normalizeText(record.model || ''), |
| | | fieldsIndex: normalizeText(record.fieldsIndex || ''), |
| | | platItemId: normalizeText(record.platItemId || ''), |
| | | platOrderCode: normalizeText(record.platOrderCode || ''), |
| | | platWorkCode: normalizeText(record.platWorkCode || ''), |
| | | projectCode: normalizeText(record.projectCode || ''), |
| | | status: normalizeNumber(record.status, 1) ?? 1, |
| | | memo: normalizeText(record.memo || ''), |
| | | ...resolveDynamicFieldValues(record, fieldDefinitions) |
| | | } |
| | | } |
| | | |
| | | export function createTransferEditableItemFromMaterial(record = {}, fieldDefinitions = []) { |
| | | return { |
| | | __rowKey: createTransferItemRowKey({ |
| | | ...record, |
| | | id: void 0, |
| | | matnrId: record.matnrId ?? record.id |
| | | }), |
| | | id: void 0, |
| | | transferId: void 0, |
| | | transferCode: '', |
| | | matnrId: normalizeNumber(record.matnrId ?? record.id, void 0), |
| | | maktx: normalizeText(record.maktx || ''), |
| | | matnrCode: normalizeText(record.matnrCode || ''), |
| | | anfme: normalizeNumber(record.anfme, 0) ?? 0, |
| | | splrCode: '', |
| | | splrName: '', |
| | | batch: normalizeText(record.batch || ''), |
| | | unit: normalizeText(record.unit || record.stockUnit || ''), |
| | | stockUnit: normalizeText(record.stockUnit || record.unit || ''), |
| | | spec: normalizeText(record.spec || ''), |
| | | model: normalizeText(record.model || ''), |
| | | fieldsIndex: normalizeText(record.fieldsIndex || ''), |
| | | platItemId: '', |
| | | platOrderCode: '', |
| | | platWorkCode: '', |
| | | projectCode: '', |
| | | status: 1, |
| | | memo: '', |
| | | ...resolveDynamicFieldValues(record, fieldDefinitions) |
| | | } |
| | | } |
| | | |
| | | export function buildTransferItemsSavePayload( |
| | | formData = {}, |
| | | areaOptions = [], |
| | | fieldDefinitions = [] |
| | | ) { |
| | | const transfer = buildTransferSavePayload(formData.transfer || formData, areaOptions) |
| | | const rows = Array.isArray(formData.items) ? formData.items : [] |
| | | return { |
| | | transfer, |
| | | items: rows.map((item) => { |
| | | const payload = { |
| | | ...(item.id !== undefined && item.id !== null && item.id !== '' |
| | | ? { id: normalizeNumber(item.id, void 0) } |
| | | : {}), |
| | | ...(item.transferId !== undefined && item.transferId !== null && item.transferId !== '' |
| | | ? { transferId: normalizeNumber(item.transferId, void 0) } |
| | | : {}), |
| | | ...(normalizeText(item.transferCode) |
| | | ? { transferCode: normalizeText(item.transferCode) } |
| | | : {}), |
| | | ...(item.matnrId !== undefined && item.matnrId !== null && item.matnrId !== '' |
| | | ? { matnrId: normalizeNumber(item.matnrId, void 0) } |
| | | : {}), |
| | | ...(normalizeText(item.maktx) ? { maktx: normalizeText(item.maktx) } : {}), |
| | | ...(normalizeText(item.matnrCode) ? { matnrCode: normalizeText(item.matnrCode) } : {}), |
| | | ...(item.anfme !== undefined && item.anfme !== null && item.anfme !== '' |
| | | ? { anfme: normalizeNumber(item.anfme, 0) } |
| | | : {}), |
| | | ...(normalizeText(item.splrCode) ? { splrCode: normalizeText(item.splrCode) } : {}), |
| | | ...(normalizeText(item.splrName) ? { splrName: normalizeText(item.splrName) } : {}), |
| | | ...(normalizeText(item.batch) ? { batch: normalizeText(item.batch) } : {}), |
| | | ...(normalizeText(item.unit || item.stockUnit) |
| | | ? { |
| | | unit: normalizeText(item.unit || item.stockUnit), |
| | | stockUnit: normalizeText(item.stockUnit || item.unit) |
| | | } |
| | | : {}), |
| | | ...(normalizeText(item.spec) ? { spec: normalizeText(item.spec) } : {}), |
| | | ...(normalizeText(item.model) ? { model: normalizeText(item.model) } : {}), |
| | | ...(normalizeText(item.fieldsIndex) |
| | | ? { fieldsIndex: normalizeText(item.fieldsIndex) } |
| | | : {}), |
| | | ...(normalizeText(item.platItemId) ? { platItemId: normalizeText(item.platItemId) } : {}), |
| | | ...(normalizeText(item.platOrderCode) |
| | | ? { platOrderCode: normalizeText(item.platOrderCode) } |
| | | : {}), |
| | | ...(normalizeText(item.platWorkCode) |
| | | ? { platWorkCode: normalizeText(item.platWorkCode) } |
| | | : {}), |
| | | ...(normalizeText(item.projectCode) |
| | | ? { projectCode: normalizeText(item.projectCode) } |
| | | : {}), |
| | | ...(item.status !== undefined && item.status !== null && item.status !== '' |
| | | ? { status: normalizeNumber(item.status, 1) } |
| | | : { status: 1 }), |
| | | memo: normalizeText(item.memo || '') |
| | | } |
| | | |
| | | fieldDefinitions.forEach((field) => { |
| | | const value = item[field.fields] |
| | | if (value !== undefined && value !== null && String(value).trim() !== '') { |
| | | payload[field.fields] = value |
| | | } |
| | | }) |
| | | |
| | | return payload |
| | | }) |
| | | } |
| | | } |
| | | |
| | | export function createTransferMaterialSearchState() { |
| | | return { |
| | | maktx: '', |
| | | matnrCode: '' |
| | | } |
| | | } |
| | | |
| | |
| | | { key: 'edit', label: $t('pages.orders.transfer.actions.edit'), icon: 'ri:pencil-line' } |
| | | ] |
| | | if (Number(normalizedRow.exceStatus) === 0) { |
| | | actions.push({ key: 'publish', label: $t('pages.orders.transfer.actions.publish'), icon: 'ri:send-plane-line' }) |
| | | actions.push({ key: 'delete', label: $t('pages.orders.transfer.actions.delete'), icon: 'ri:delete-bin-5-line', color: 'var(--art-error)' }) |
| | | actions.push({ |
| | | key: 'publish', |
| | | label: $t('pages.orders.transfer.actions.publish'), |
| | | icon: 'ri:send-plane-line' |
| | | }) |
| | | actions.push({ |
| | | key: 'delete', |
| | | label: $t('pages.orders.transfer.actions.delete'), |
| | | icon: 'ri:delete-bin-5-line', |
| | | color: 'var(--art-error)' |
| | | }) |
| | | } |
| | | return actions |
| | | } |
| | |
| | | if (value === void 0) return null |
| | | return { |
| | | value, |
| | | label: normalizeText(item.name || item.areaName || item.code || item.warehouseId$ || item.warehouseName || `${$t('menu.warehouseAreas')} ${value}`), |
| | | label: normalizeText( |
| | | item.name || |
| | | item.areaName || |
| | | item.code || |
| | | item.warehouseId$ || |
| | | item.warehouseName || |
| | | `${$t('menu.warehouseAreas')} ${value}` |
| | | ), |
| | | raw: item |
| | | } |
| | | }) |
| | |
| | | if (value === void 0) return null |
| | | return { |
| | | value, |
| | | label: normalizeText(item.label || item.name || item.dictLabel || `${$t('pages.orders.transfer.dialog.type')} ${value}`) |
| | | label: normalizeText( |
| | | item.label || |
| | | item.name || |
| | | item.dictLabel || |
| | | `${$t('pages.orders.transfer.dialog.type')} ${value}` |
| | | ) |
| | | } |
| | | }) |
| | | .filter(Boolean) |