重构原材料卡片剩余数量计算逻辑,替换配置属性为服务调用以增强灵活性。新增匹配仓库配置的接口和视图,优化库区管理功能,确保数据展示的准确性和一致性。同时,更新相关文档以反映配置变更。

This commit is contained in:
geht
2026-05-15 11:47:31 +08:00
parent 5d7335d1a7
commit 10c5d29dc1
13 changed files with 561 additions and 82 deletions

View File

@@ -15,6 +15,7 @@ enum Api {
importExcel = '/xslmes/mesXslWarehouseArea/importExcel',
exportXls = '/xslmes/mesXslWarehouseArea/exportXls',
batchAdd = '/xslmes/mesXslWarehouseArea/batchAdd',
capacityMatchConfig = '/xslmes/mesXslWarehouseArea/capacityMatchConfig',
}
export const getExportUrl = Api.exportXls;
@@ -60,6 +61,12 @@ export const saveOrUpdate = (params, isUpdate) => {
return defHttp.post({ url, params });
};
/** 实际存放量:匹配仓库配置 */
export const getCapacityMatchConfig = () => defHttp.get({ url: Api.capacityMatchConfig });
export const saveCapacityMatchConfig = (params: Record<string, unknown>) =>
defHttp.post({ url: Api.capacityMatchConfig, params });
/** 批量添加库区(同一仓库下一次性创建多条) */
export const batchAddAreas = (params: any[]) => defHttp.post({ url: Api.batchAdd, params });

View File

@@ -2,6 +2,9 @@
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="default" v-auth="'xslmes:mes_xsl_warehouse_area:capacityMatch'" preIcon="ant-design:link-outlined" @click="openCapacityMatch">
匹配仓库
</a-button>
<a-button type="primary" v-auth="'xslmes:mes_xsl_warehouse_area:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" v-auth="'xslmes:mes_xsl_warehouse_area:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" v-auth="'xslmes:mes_xsl_warehouse_area:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
@@ -26,6 +29,7 @@
</template>
</BasicTable>
<MesXslWarehouseAreaModal @register="registerModal" @success="handleSuccess" />
<MesXslWarehouseAreaCapacityMatchModal @register="registerCapacityMatchModal" @success="handleSuccess" />
</div>
</template>
@@ -35,12 +39,14 @@
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import MesXslWarehouseAreaModal from './components/MesXslWarehouseAreaModal.vue';
import MesXslWarehouseAreaCapacityMatchModal from './components/MesXslWarehouseAreaCapacityMatchModal.vue';
import { columns, searchFormSchema, superQuerySchema } from './MesXslWarehouseArea.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, updateStatus } from './MesXslWarehouseArea.api';
import Icon from '/@/components/Icon';
import type { Recordable } from '/@/types/global';
const [registerModal, { openModal }] = useModal();
const [registerCapacityMatchModal, { openModal: openCapacityMatchModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
@@ -71,6 +77,10 @@
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
const superQueryConfig = reactive(superQuerySchema);
function openCapacityMatch() {
openCapacityMatchModal(true, {});
}
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true, record: {} });
}

View File

@@ -0,0 +1,109 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroy-on-close title="匹配仓库(实际存放量)" width="720" @ok="handleSubmit">
<a-alert v-if="bootstrapHint" type="info" show-icon style="margin-bottom: 14px" :message="bootstrapHint" />
<BasicForm @register="registerForm">
<template #categoryIdsSlot="{ model, field }">
<JCategorySelect
v-model:value="model[field]"
pcode="XSLMES_WH"
placeholder="请选择仓库分类(可多选)"
:multiple="true"
/>
</template>
</BasicForm>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm, JCategorySelect } from '/@/components/Form';
import type { FormSchema } from '/@/components/Form';
import { useMessage } from '/@/hooks/web/useMessage';
import { getCapacityMatchConfig, saveCapacityMatchConfig } from '../MesXslWarehouseArea.api';
const emit = defineEmits(['register', 'success']);
const { createMessage } = useMessage();
const bootstrapHint = ref<string>('');
const capacityMatchSchemas: FormSchema[] = [
{
field: 'enabled',
label: '启用回填',
component: 'Switch',
defaultValue: true,
componentProps: {
checkedChildren: '开',
unCheckedChildren: '关',
},
},
{
field: 'warehouseCategoryIds',
label: '仓库分类',
component: 'Input',
slot: 'categoryIdsSlot',
helpMessage: '与列表中库区「仓库分类」一致时才按原材料卡片剩余数量汇总显示实际存放量',
},
{
field: 'warehouseCategoryCodes',
label: '补充分类编码',
component: 'InputTextArea',
componentProps: {
rows: 2,
placeholder: '可选,逗号分隔,例如 XSLMES_WH_F1_YCL会与上面所选分类一并生效',
},
},
{
field: 'remark',
label: '备注',
component: 'InputTextArea',
componentProps: { rows: 2, placeholder: '选填,仅作说明' },
},
];
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
labelWidth: 128,
schemas: capacityMatchSchemas,
showActionButtonGroup: false,
baseColProps: { span: 24 },
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async () => {
bootstrapHint.value = '';
await resetFields();
setModalProps({ confirmLoading: true });
try {
const data = await getCapacityMatchConfig();
bootstrapHint.value = data?.configSource === 'yaml' && data?.bootstrapHint ? data.bootstrapHint : '';
await setFieldsValue({
enabled: data?.enabled !== false,
warehouseCategoryIds: data?.warehouseCategoryIds || '',
warehouseCategoryCodes: data?.warehouseCategoryCodes || '',
remark: data?.remark || '',
});
} catch {
createMessage.warning('加载配置失败');
} finally {
setModalProps({ confirmLoading: false });
}
});
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveCapacityMatchConfig({
enabled: values.enabled === true || values.enabled === 'true' || values.enabled === 1,
warehouseCategoryIds: values.warehouseCategoryIds,
warehouseCategoryCodes: values.warehouseCategoryCodes,
remark: values.remark,
});
createMessage.success('保存成功');
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>