| | |
| | | import { |
| | | buildLocDialogModel, |
| | | createLocFormState, |
| | | filterLocAreaOptionsByWarehouse, |
| | | getLocBinaryOptions, |
| | | getLocStatusOptions, |
| | | getLocUseStatusOptions |
| | |
| | | const isEdit = computed(() => props.dialogType === 'edit') |
| | | const dialogTitle = computed(() => (isEdit.value ? '编辑库位' : '新增库位')) |
| | | |
| | | const filteredAreaOptions = computed(() => { |
| | | if (!form.warehouseId) { |
| | | return props.areaOptions |
| | | const filteredAreaOptions = computed(() => |
| | | filterLocAreaOptionsByWarehouse(props.areaOptions || [], form.warehouseId) |
| | | ) |
| | | |
| | | function createInputFormItem(label, key, placeholder, extraProps = {}, extraConfig = {}) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'input', |
| | | props: { |
| | | placeholder, |
| | | clearable: true, |
| | | ...extraProps |
| | | }, |
| | | ...extraConfig |
| | | } |
| | | return (props.areaOptions || []).filter((item) => { |
| | | if (item?.warehouseId === undefined || item?.warehouseId === null) { |
| | | return true |
| | | } |
| | | return Number(item.warehouseId) === Number(form.warehouseId) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | function createNumberFormItem(label, key, placeholder, extraProps = {}, extraConfig = {}) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder, |
| | | ...extraProps |
| | | }, |
| | | ...extraConfig |
| | | } |
| | | } |
| | | |
| | | function createSelectFormItem(label, key, placeholder, options, extraProps = {}, extraConfig = {}) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'select', |
| | | props: { |
| | | placeholder, |
| | | clearable: true, |
| | | options, |
| | | ...extraProps |
| | | }, |
| | | ...extraConfig |
| | | } |
| | | } |
| | | |
| | | const rules = computed(() => ({ |
| | | warehouseId: [{ required: true, message: '请选择仓库', trigger: 'change' }], |
| | |
| | | })) |
| | | |
| | | const formItems = computed(() => [ |
| | | { |
| | | label: '仓库', |
| | | key: 'warehouseId', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择仓库', |
| | | clearable: true, |
| | | filterable: true, |
| | | options: props.warehouseOptions |
| | | } |
| | | }, |
| | | { |
| | | label: '库区', |
| | | key: 'areaId', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择库区', |
| | | clearable: true, |
| | | filterable: true, |
| | | options: filteredAreaOptions.value |
| | | } |
| | | }, |
| | | { |
| | | label: '库位号', |
| | | key: 'code', |
| | | type: 'input', |
| | | props: { |
| | | placeholder: '请输入库位号', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '库位类型', |
| | | key: 'typeIds', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择库位类型', |
| | | clearable: true, |
| | | multiple: true, |
| | | collapseTags: true, |
| | | filterable: true, |
| | | options: props.locTypeOptions |
| | | } |
| | | }, |
| | | { |
| | | label: '使用状态', |
| | | key: 'useStatus', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择使用状态', |
| | | clearable: true, |
| | | filterable: true, |
| | | options: getLocUseStatusOptions() |
| | | } |
| | | }, |
| | | { |
| | | label: '状态', |
| | | key: 'status', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择状态', |
| | | clearable: true, |
| | | options: getLocStatusOptions() |
| | | } |
| | | }, |
| | | { |
| | | label: '排', |
| | | key: 'row', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入排' |
| | | } |
| | | }, |
| | | { |
| | | label: '列', |
| | | key: 'col', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入列' |
| | | } |
| | | }, |
| | | { |
| | | label: '层', |
| | | key: 'lev', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入层' |
| | | } |
| | | }, |
| | | { |
| | | label: '巷道', |
| | | key: 'channel', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入巷道' |
| | | } |
| | | }, |
| | | { |
| | | label: '容器编码', |
| | | key: 'barcode', |
| | | type: 'input', |
| | | props: { |
| | | placeholder: '请输入容器编码', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '存放单位', |
| | | key: 'unit', |
| | | type: 'input', |
| | | props: { |
| | | placeholder: '请输入存放单位', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '虚拟库位', |
| | | key: 'flagLogic', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择虚拟库位', |
| | | clearable: true, |
| | | options: getLocBinaryOptions() |
| | | } |
| | | }, |
| | | { |
| | | label: '标签管理', |
| | | key: 'flagLabelMange', |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择标签管理', |
| | | clearable: true, |
| | | options: getLocBinaryOptions() |
| | | } |
| | | }, |
| | | { |
| | | label: '长', |
| | | key: 'length', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | step: 0.01, |
| | | precision: 2, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入长' |
| | | } |
| | | }, |
| | | { |
| | | label: '宽', |
| | | key: 'width', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | step: 0.01, |
| | | precision: 2, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入宽' |
| | | } |
| | | }, |
| | | { |
| | | label: '高', |
| | | key: 'height', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | step: 0.01, |
| | | precision: 2, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入高' |
| | | } |
| | | }, |
| | | { |
| | | label: '最大零件数', |
| | | key: 'maxParts', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入最大零件数' |
| | | } |
| | | }, |
| | | { |
| | | label: '最大包装数', |
| | | key: 'maxPack', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入最大包装数' |
| | | } |
| | | }, |
| | | { |
| | | label: '功能属性', |
| | | key: 'fucAtrrs', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入功能属性', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '属性', |
| | | key: 'locAttrs', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入属性', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '备注', |
| | | key: 'memo', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | type: 'textarea', |
| | | rows: 3, |
| | | placeholder: '请输入备注', |
| | | clearable: true |
| | | } |
| | | } |
| | | createSelectFormItem('仓库', 'warehouseId', '请选择仓库', props.warehouseOptions, { filterable: true }), |
| | | createSelectFormItem('库区', 'areaId', '请选择库区', filteredAreaOptions.value, { filterable: true }), |
| | | createInputFormItem('库位号', 'code', '请输入库位号'), |
| | | createSelectFormItem('库位类型', 'typeIds', '请选择库位类型', props.locTypeOptions, { |
| | | multiple: true, |
| | | collapseTags: true, |
| | | filterable: true |
| | | }), |
| | | createSelectFormItem('使用状态', 'useStatus', '请选择使用状态', getLocUseStatusOptions(), { filterable: true }), |
| | | createSelectFormItem('状态', 'status', '请选择状态', getLocStatusOptions()), |
| | | createNumberFormItem('排', 'row', '请输入排'), |
| | | createNumberFormItem('列', 'col', '请输入列'), |
| | | createNumberFormItem('层', 'lev', '请输入层'), |
| | | createNumberFormItem('巷道', 'channel', '请输入巷道'), |
| | | createInputFormItem('容器编码', 'barcode', '请输入容器编码'), |
| | | createInputFormItem('存放单位', 'unit', '请输入存放单位'), |
| | | createSelectFormItem('虚拟库位', 'flagLogic', '请选择虚拟库位', getLocBinaryOptions()), |
| | | createSelectFormItem('标签管理', 'flagLabelMange', '请选择标签管理', getLocBinaryOptions()), |
| | | createNumberFormItem('长', 'length', '请输入长', { step: 0.01, precision: 2 }), |
| | | createNumberFormItem('宽', 'width', '请输入宽', { step: 0.01, precision: 2 }), |
| | | createNumberFormItem('高', 'height', '请输入高', { step: 0.01, precision: 2 }), |
| | | createNumberFormItem('最大零件数', 'maxParts', '请输入最大零件数'), |
| | | createNumberFormItem('最大包装数', 'maxPack', '请输入最大包装数'), |
| | | createInputFormItem('功能属性', 'fucAtrrs', '请输入功能属性', {}, { span: 24 }), |
| | | createInputFormItem('属性', 'locAttrs', '请输入属性', {}, { span: 24 }), |
| | | createInputFormItem( |
| | | '备注', |
| | | 'memo', |
| | | '请输入备注', |
| | | { type: 'textarea', rows: 3 }, |
| | | { span: 24 } |
| | | ) |
| | | ]) |
| | | |
| | | const loadFormData = () => { |