7751a735c5
发货模板、运输计划、运单与总单调度从计量单位取 unitName;修复调度提交顶层单位为空,并取消计划开始/结束日期必填。 Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
1.0 KiB
JavaScript
28 lines
1.0 KiB
JavaScript
import { getList as getMeasurementUnitList } from '@/api/base/measurement-unit';
|
|
|
|
/**
|
|
* 加载启用状态的计量单位选项,展示/取值均为「计量单位」字段(unitName)。
|
|
* @returns {Promise<Array<{ label: string, value: string, dimension: string, id: string|number }>>}
|
|
*/
|
|
export const loadMeasurementUnitOptions = () => {
|
|
return getMeasurementUnitList(1, 9999, { status: 1 }).then(res => {
|
|
const data = res?.data?.data || res?.data || {};
|
|
const records = Array.isArray(data) ? data : data.records || [];
|
|
const names = new Set();
|
|
return records
|
|
.filter(item => item.status === undefined || item.status === null || Number(item.status) === 1)
|
|
.map(item => {
|
|
const name = String(item.unitName || '').trim();
|
|
if (!name || names.has(name)) return null;
|
|
names.add(name);
|
|
return {
|
|
id: item.id,
|
|
label: name,
|
|
value: name,
|
|
dimension: String(item.dimension || '').trim(),
|
|
};
|
|
})
|
|
.filter(Boolean);
|
|
});
|
|
};
|