新增MES库区管理功能,包含免密接口、数据处理逻辑及相关控制器、服务和实体的实现。支持库区的增删改查操作,优化用户体验并增强系统的实时数据同步能力。
This commit is contained in:
@@ -63,4 +63,14 @@ export const formSchema: FormSchema[] = [
|
||||
required: true,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '分类编码',
|
||||
field: 'code',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
// 新增时:留空则后端按 FillRule 自动生成(如 A01.A02);
|
||||
// 编辑时:保留原值,避免缺字段提交导致编码被清空。
|
||||
placeholder: '留空将按规则自动生成(如 A01.A02)',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -7,13 +7,13 @@ export const columns: BasicColumn[] = [
|
||||
title: '条码',
|
||||
align: 'center',
|
||||
dataIndex: 'barcode',
|
||||
width: 160,
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '批次号',
|
||||
align: 'center',
|
||||
dataIndex: 'batchNo',
|
||||
width: 160,
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '入场日期',
|
||||
|
||||
@@ -123,12 +123,14 @@
|
||||
}
|
||||
|
||||
async function handlePriorityChange(record, checked: boolean) {
|
||||
const newVal = checked ? '1' : '0';
|
||||
const oldVal = record.priorityPickup;
|
||||
record.priorityPickup = newVal;
|
||||
try {
|
||||
await updatePriority(record.id, checked ? '1' : '0');
|
||||
record.priorityPickup = checked ? '1' : '0';
|
||||
createMessage.success('优先出库设置已更新');
|
||||
await updatePriority(record.id, newVal);
|
||||
} catch {
|
||||
createMessage.error('更新失败,请重试');
|
||||
record.priorityPickup = oldVal;
|
||||
createMessage.error('优先出库更新失败,请重试');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ enum Api {
|
||||
edit = '/xslmes/mesXslRawMaterialEntry/edit',
|
||||
deleteOne = '/xslmes/mesXslRawMaterialEntry/delete',
|
||||
deleteBatch = '/xslmes/mesXslRawMaterialEntry/deleteBatch',
|
||||
batchStockIn = '/xslmes/mesXslRawMaterialEntry/batchStockIn',
|
||||
importExcel = '/xslmes/mesXslRawMaterialEntry/importExcel',
|
||||
exportXls = '/xslmes/mesXslRawMaterialEntry/exportXls',
|
||||
}
|
||||
@@ -39,6 +40,9 @@ export const batchDelete = (params, handleSuccess) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const batchStockIn = (ids: string) =>
|
||||
defHttp.put({ url: Api.batchStockIn, params: { ids } }, { joinParamsToUrl: true });
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params });
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '条码', align: 'center', dataIndex: 'barcode', width: 160 },
|
||||
{ title: '批次号', align: 'center', dataIndex: 'batchNo', width: 140 },
|
||||
{ title: '条码', align: 'center', dataIndex: 'barcode', width: 200 },
|
||||
{ title: '批次号', align: 'center', dataIndex: 'batchNo', width: 180 },
|
||||
{
|
||||
title: '入场时间',
|
||||
align: 'center',
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<a-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_entry:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_entry:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||
<j-upload-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_entry:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||
<a-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_entry:stockIn'" preIcon="ant-design:check-circle-outlined" @click="handleStockIn"> 结存入库</a-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
@@ -30,13 +31,15 @@
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslRawMaterialEntry" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import MesXslRawMaterialEntryModal from './components/MesXslRawMaterialEntryModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema } from './MesXslRawMaterialEntry.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './MesXslRawMaterialEntry.api';
|
||||
import { list, deleteOne, batchDelete, batchStockIn, getImportUrl, getExportUrl } from './MesXslRawMaterialEntry.api';
|
||||
|
||||
const { createConfirm, createMessage } = useMessage();
|
||||
const queryParam = reactive<any>({});
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
@@ -55,7 +58,7 @@
|
||||
],
|
||||
},
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
@@ -103,6 +106,25 @@
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleStockIn() {
|
||||
if (!selectedRowKeys.value.length) {
|
||||
createMessage.warning('请先勾选要结存入库的记录');
|
||||
return;
|
||||
}
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '结存入库',
|
||||
content: `是否将选中的 ${selectedRowKeys.value.length} 条记录结存入库`,
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
await batchStockIn(selectedRowKeys.value.join(','));
|
||||
createMessage.success('结存入库成功!');
|
||||
handleSuccess();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
</div>
|
||||
<MesXslWarehouseModal @register="registerModal" @success="handleSuccess" />
|
||||
<MesXslWarehouseSysCategoryModal @register="registerCategoryModal" @success="onCategorySuccess" />
|
||||
<MesXslWarehouseAreaBatchAddModal @register="registerBatchAreaModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -106,6 +107,7 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import MesXslWarehouseModal from './components/MesXslWarehouseModal.vue';
|
||||
import MesXslWarehouseSysCategoryModal from './components/MesXslWarehouseSysCategoryModal.vue';
|
||||
import MesXslWarehouseAreaBatchAddModal from './components/MesXslWarehouseAreaBatchAddModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema, WH_CATEGORY_CUSTOMER_CODE, WH_CATEGORY_SUPPLIER_CODE } from './MesXslWarehouse.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, updateStatus } from './MesXslWarehouse.api';
|
||||
import { loadTreeData as loadCategoryTreeRoot } from '/@/views/system/category/category.api';
|
||||
@@ -310,6 +312,7 @@
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
|
||||
const [registerBatchAreaModal, { openModal: openBatchAreaModal }] = useModal();
|
||||
|
||||
function handleAddCategory() {
|
||||
const rootId = warehouseCategoryRootId.value;
|
||||
@@ -507,8 +510,15 @@
|
||||
];
|
||||
}
|
||||
|
||||
function handleBatchAddArea(record: Recordable) {
|
||||
openBatchAreaModal(true, { record });
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [{ label: '详情', onClick: handleDetail.bind(null, record) }];
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{ label: '批量添加库区', onClick: handleBatchAddArea.bind(null, record) },
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
@register="registerModal"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
:width="700"
|
||||
:confirmLoading="submitting"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<div style="margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center">
|
||||
<span style="color: #666; font-size: 13px">共 {{ rows.length }} 条</span>
|
||||
<a-button type="primary" size="small" preIcon="ant-design:plus-outlined" @click="addRow">新增行</a-button>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
:columns="tableColumns"
|
||||
:data-source="rows"
|
||||
:pagination="false"
|
||||
size="small"
|
||||
bordered
|
||||
row-key="__key"
|
||||
:scroll="{ y: 380 }"
|
||||
>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'seq'">
|
||||
{{ index + 1 }}
|
||||
</template>
|
||||
|
||||
<template v-else-if="column.key === 'areaCode'">
|
||||
<a-input
|
||||
v-model:value="record.areaCode"
|
||||
placeholder="库区编码(必填)"
|
||||
size="small"
|
||||
:status="record.__codeError ? 'error' : ''"
|
||||
@change="onAreaCodeChange(record)"
|
||||
@blur="validateCode(record)"
|
||||
/>
|
||||
<div v-if="record.__codeError" style="color: #ff4d4f; font-size: 12px; margin-top: 2px">
|
||||
{{ record.__codeError }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="column.key === 'areaName'">
|
||||
<a-input v-model:value="record.areaName" placeholder="默认同库区编码" size="small" />
|
||||
</template>
|
||||
|
||||
<template v-else-if="column.key === 'maxCapacity'">
|
||||
<a-input-number
|
||||
v-model:value="record.maxCapacity"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
placeholder="最大存放量"
|
||||
size="small"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-button danger type="link" size="small" @click="removeRow(index)">删除</a-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<div v-if="rows.length === 0" style="text-align: center; color: #999; padding: 24px 0; font-size: 13px">
|
||||
暂无库区明细,点击「新增行」添加
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { batchAddAreas } from '/@/views/xslmes/mesXslWarehouseArea/MesXslWarehouseArea.api';
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
|
||||
const warehouseId = ref('');
|
||||
const warehouseName = ref('');
|
||||
const warehouseCategory = ref<string | undefined>(undefined);
|
||||
const tenantId = ref<number | undefined>(undefined);
|
||||
const submitting = ref(false);
|
||||
|
||||
let _rowKey = 0;
|
||||
|
||||
interface AreaRow {
|
||||
__key: number;
|
||||
__codeError: string;
|
||||
__prevCode: string;
|
||||
areaCode: string;
|
||||
areaName: string;
|
||||
maxCapacity: number | undefined;
|
||||
}
|
||||
|
||||
const rows = ref<AreaRow[]>([]);
|
||||
|
||||
const title = computed(() =>
|
||||
warehouseName.value ? `批量添加库区 — ${warehouseName.value}` : '批量添加库区'
|
||||
);
|
||||
|
||||
const tableColumns = [
|
||||
{ title: '序号', key: 'seq', width: 52, align: 'center' },
|
||||
{ title: '库区编码 *', key: 'areaCode', width: 180 },
|
||||
{ title: '库区名称', key: 'areaName', width: 180 },
|
||||
{ title: '最大存放量', key: 'maxCapacity', width: 130 },
|
||||
{ title: '操作', key: 'action', width: 60, align: 'center' },
|
||||
];
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner((data) => {
|
||||
rows.value = [];
|
||||
_rowKey = 0;
|
||||
warehouseId.value = data?.record?.id ?? '';
|
||||
warehouseName.value = data?.record?.warehouseName ?? '';
|
||||
warehouseCategory.value = data?.record?.warehouseCategory ?? undefined;
|
||||
tenantId.value = data?.record?.tenantId ?? undefined;
|
||||
addRow();
|
||||
});
|
||||
|
||||
function addRow() {
|
||||
rows.value.push({
|
||||
__key: _rowKey++,
|
||||
__codeError: '',
|
||||
__prevCode: '',
|
||||
areaCode: '',
|
||||
areaName: '',
|
||||
maxCapacity: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
function removeRow(index: number) {
|
||||
rows.value.splice(index, 1);
|
||||
}
|
||||
|
||||
function onAreaCodeChange(record: AreaRow) {
|
||||
if (!record.areaName || record.areaName === record.__prevCode) {
|
||||
record.areaName = record.areaCode;
|
||||
}
|
||||
record.__prevCode = record.areaCode;
|
||||
record.__codeError = '';
|
||||
}
|
||||
|
||||
function validateCode(record: AreaRow) {
|
||||
if (!record.areaCode || !record.areaCode.trim()) {
|
||||
record.__codeError = '库区编码不能为空';
|
||||
} else {
|
||||
record.__codeError = '';
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (rows.value.length === 0) {
|
||||
createMessage.warning('请至少添加一条库区记录');
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate all rows
|
||||
let hasError = false;
|
||||
const codeSet = new Set<string>();
|
||||
for (const row of rows.value) {
|
||||
const code = (row.areaCode || '').trim();
|
||||
if (!code) {
|
||||
row.__codeError = '库区编码不能为空';
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
if (codeSet.has(code)) {
|
||||
row.__codeError = '库区编码重复';
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
codeSet.add(code);
|
||||
row.__codeError = '';
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
createMessage.error('请修正红色标记的错误后再提交');
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = rows.value.map((row) => ({
|
||||
areaCode: row.areaCode.trim(),
|
||||
areaName: (row.areaName || row.areaCode).trim() || row.areaCode.trim(),
|
||||
maxCapacity: row.maxCapacity ?? undefined,
|
||||
warehouseId: warehouseId.value,
|
||||
warehouseName: warehouseName.value,
|
||||
warehouseCategory: warehouseCategory.value,
|
||||
tenantId: tenantId.value,
|
||||
status: '0',
|
||||
}));
|
||||
|
||||
try {
|
||||
submitting.value = true;
|
||||
setModalProps({ confirmLoading: true });
|
||||
await batchAddAreas(payload);
|
||||
createMessage.success(`批量添加成功,共创建 ${payload.length} 个库区!`);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} catch {
|
||||
// error handled by global interceptor
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,71 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslWarehouseArea/list',
|
||||
checkAreaCode = '/xslmes/mesXslWarehouseArea/checkAreaCode',
|
||||
queryById = '/xslmes/mesXslWarehouseArea/queryById',
|
||||
save = '/xslmes/mesXslWarehouseArea/add',
|
||||
edit = '/xslmes/mesXslWarehouseArea/edit',
|
||||
updateStatus = '/xslmes/mesXslWarehouseArea/updateStatus',
|
||||
deleteOne = '/xslmes/mesXslWarehouseArea/delete',
|
||||
deleteBatch = '/xslmes/mesXslWarehouseArea/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslWarehouseArea/importExcel',
|
||||
exportXls = '/xslmes/mesXslWarehouseArea/exportXls',
|
||||
batchAdd = '/xslmes/mesXslWarehouseArea/batchAdd',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
|
||||
|
||||
/** 库区编码唯一性校验(同租户;编辑传 dataId) */
|
||||
export const checkAreaCode = (params: { areaCode: string; dataId?: string }) =>
|
||||
defHttp.get(
|
||||
{ url: Api.checkAreaCode, params },
|
||||
{
|
||||
successMessageMode: 'none',
|
||||
errorMessageMode: 'none',
|
||||
}
|
||||
);
|
||||
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
};
|
||||
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
const url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url, params });
|
||||
};
|
||||
|
||||
/** 批量添加库区(同一仓库下一次性创建多条) */
|
||||
export const batchAddAreas = (params: any[]) => defHttp.post({ url: Api.batchAdd, params });
|
||||
|
||||
/** 启用/停用:status 0 启用 1 停用(字典 xslmes_unit_status) */
|
||||
export const updateStatus = (params: { id: string; status: string }, handleSuccess?: () => void) => {
|
||||
return defHttp.post({ url: Api.updateStatus, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess?.();
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,131 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { checkAreaCode } from './MesXslWarehouseArea.api';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: 'ID', align: 'center', dataIndex: 'id', width: 280, ellipsis: true, defaultHidden: true },
|
||||
{ title: '库区编码', align: 'center', dataIndex: 'areaCode', width: 120 },
|
||||
{ title: '库区名称', align: 'center', dataIndex: 'areaName', width: 160 },
|
||||
{ title: '所属仓库', align: 'center', dataIndex: 'warehouseName', width: 160 },
|
||||
{ title: '仓库分类', align: 'center', dataIndex: 'warehouseCategory_dictText', width: 140 },
|
||||
{ title: '最大存放量', align: 'center', dataIndex: 'maxCapacity', width: 110 },
|
||||
{ title: '实际存放量', align: 'center', dataIndex: 'actualCapacity', width: 110 },
|
||||
{ title: '状态', align: 'center', dataIndex: 'status_dictText', width: 90 },
|
||||
{ title: '备注', align: 'center', dataIndex: 'remark', width: 200, ellipsis: true },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
dataIndex: 'createTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '库区编码', field: 'areaCode', component: 'JInput', colProps: { span: 6 } },
|
||||
{ label: '库区名称', field: 'areaName', component: 'JInput', colProps: { span: 6 } },
|
||||
{
|
||||
label: '所属仓库',
|
||||
field: 'warehouseId',
|
||||
component: 'JSearchSelect',
|
||||
componentProps: { dict: 'mes_xsl_warehouse,warehouse_name,id', async: true, placeholder: '请搜索仓库' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_unit_status' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'warehouseName', component: 'Input', show: false },
|
||||
{
|
||||
label: '库区编码',
|
||||
field: 'areaCode',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '同租户内唯一,不可与已有库区重复' },
|
||||
dynamicRules: ({ model }) => [
|
||||
{ required: true, message: '请输入库区编码' },
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) return Promise.resolve();
|
||||
try {
|
||||
await checkAreaCode({ areaCode: v, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
const msg = e?.response?.data?.message || e?.message || '该库区编码已存在';
|
||||
return Promise.reject(msg);
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '库区名称',
|
||||
field: 'areaName',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '请输入库区名称' },
|
||||
},
|
||||
{
|
||||
label: '所属仓库',
|
||||
field: 'warehouseId',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
slot: 'warehousePicker',
|
||||
},
|
||||
{
|
||||
label: '仓库分类',
|
||||
field: 'warehouseCategory',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'sys_category,name,id', disabled: true, placeholder: '选择仓库后自动带出' },
|
||||
},
|
||||
{
|
||||
label: '最大存放量',
|
||||
field: 'maxCapacity',
|
||||
component: 'InputNumber',
|
||||
componentProps: { placeholder: '请输入最大存放量', style: { width: '100%' }, min: 0 },
|
||||
},
|
||||
{
|
||||
label: '实际存放量',
|
||||
field: 'actualCapacity',
|
||||
component: 'InputNumber',
|
||||
componentProps: { placeholder: '请输入实际存放量', style: { width: '100%' }, min: 0 },
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
field: 'remark',
|
||||
component: 'InputTextArea',
|
||||
componentProps: { placeholder: '请输入备注', rows: 3 },
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_unit_status', placeholder: '请选择状态' },
|
||||
},
|
||||
{
|
||||
label: '租户ID',
|
||||
field: 'tenantId',
|
||||
component: 'InputNumber',
|
||||
componentProps: { placeholder: '租户ID,可空', style: { width: '100%' } },
|
||||
},
|
||||
];
|
||||
|
||||
export const superQuerySchema = {
|
||||
areaCode: { title: '库区编码', order: 0, view: 'text' },
|
||||
areaName: { title: '库区名称', order: 1, view: 'text' },
|
||||
warehouseName: { title: '所属仓库', order: 2, view: 'text' },
|
||||
warehouseCategory: { title: '仓库分类', order: 3, view: 'list', dictCode: 'sys_category,name,id' },
|
||||
status: { title: '状态', order: 4, view: 'list', dictCode: 'xslmes_unit_status' },
|
||||
maxCapacity: { title: '最大存放量', order: 5, view: 'number' },
|
||||
actualCapacity: { title: '实际存放量', order: 6, view: 'number' },
|
||||
};
|
||||
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<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>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button v-auth="'xslmes:mes_xsl_warehouse_area:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslWarehouseAreaModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslWarehouseArea" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import MesXslWarehouseAreaModal from './components/MesXslWarehouseAreaModal.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 { tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '库区管理',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '库区管理',
|
||||
url: getExportUrl,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, { isUpdate: false, showFooter: true, record: {} });
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||
}
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||
}
|
||||
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
function isRecordEnabled(record: Recordable) {
|
||||
return record.status === '0' || record.status === 0;
|
||||
}
|
||||
|
||||
async function handleToggleStatus(record: Recordable, status: string) {
|
||||
await updateStatus({ id: record.id, status }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
selectedRowKeys.value = [];
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.assign({}, params);
|
||||
reload();
|
||||
}
|
||||
|
||||
function getTableAction(record) {
|
||||
const enabled = isRecordEnabled(record);
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'xslmes:mes_xsl_warehouse_area:edit',
|
||||
},
|
||||
{
|
||||
label: '启用',
|
||||
ifShow: !enabled,
|
||||
onClick: handleToggleStatus.bind(null, record, '0'),
|
||||
auth: 'xslmes:mes_xsl_warehouse_area:updateStatus',
|
||||
},
|
||||
{
|
||||
label: '停用',
|
||||
ifShow: enabled,
|
||||
onClick: handleToggleStatus.bind(null, record, '1'),
|
||||
auth: 'xslmes:mes_xsl_warehouse_area:updateStatus',
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
auth: 'xslmes:mes_xsl_warehouse_area:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [{ label: '详情', onClick: handleDetail.bind(null, record) }];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="680" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm">
|
||||
<template #warehousePicker="{ model, field }">
|
||||
<JSearchSelect
|
||||
v-model:value="model[field]"
|
||||
dict="mes_xsl_warehouse,warehouse_name,id"
|
||||
:async="true"
|
||||
placeholder="请搜索并选择仓库"
|
||||
:disabled="isDetail"
|
||||
@change="(v) => onWarehouseChange(model, v)"
|
||||
/>
|
||||
</template>
|
||||
</BasicForm>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm, JSearchSelect } from '/@/components/Form';
|
||||
import { formSchema } from '../MesXslWarehouseArea.data';
|
||||
import { saveOrUpdate } from '../MesXslWarehouseArea.api';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
const [registerForm, { setProps, resetFields, setFieldsValue, validate, scrollToField }] = useForm({
|
||||
labelWidth: 120,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
await setFieldsValue({ ...data.record });
|
||||
} else {
|
||||
await setFieldsValue({ status: '0' });
|
||||
}
|
||||
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
|
||||
const title = computed(() => (!unref(isUpdate) ? '新增库区' : unref(isDetail) ? '库区详情' : '编辑库区'));
|
||||
|
||||
async function onWarehouseChange(model: any, val: unknown) {
|
||||
const id = val != null && val !== '' ? String(val) : '';
|
||||
if (!id) {
|
||||
model.warehouseName = '';
|
||||
await setFieldsValue({ warehouseName: '', warehouseCategory: undefined });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const wh = await defHttp.get({ url: '/xslmes/mesXslWarehouse/queryById', params: { id } });
|
||||
if (wh) {
|
||||
await setFieldsValue({
|
||||
warehouseName: wh.warehouseName || '',
|
||||
warehouseCategory: wh.warehouseCategory || undefined,
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate(values, unref(isUpdate));
|
||||
closeModal();
|
||||
emit('success');
|
||||
} catch (e: any) {
|
||||
if (e?.errorFields) {
|
||||
const firstField = e.errorFields[0];
|
||||
if (firstField) {
|
||||
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
return Promise.reject(e);
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -18,6 +18,19 @@ export const columns: BasicColumn[] = [
|
||||
{ title: '毛重(KG)', align: 'center', dataIndex: 'grossWeight', width: 100 },
|
||||
{ title: '皮重(KG)', align: 'center', dataIndex: 'tareWeight', width: 100 },
|
||||
{ title: '净重(KG)', align: 'center', dataIndex: 'netWeight', width: 100 },
|
||||
{
|
||||
title: '已入场重量(KG)',
|
||||
align: 'center',
|
||||
dataIndex: 'enteredWeight',
|
||||
width: 120,
|
||||
customRender: ({ text }) => {
|
||||
// 后端实时计算返回,未匹配到入场记录时为 0
|
||||
if (text === null || text === undefined || text === '') return '0';
|
||||
const n = Number(text);
|
||||
if (Number.isNaN(n)) return String(text);
|
||||
return Number.isInteger(n) ? String(n) : n.toFixed(2);
|
||||
},
|
||||
},
|
||||
{ title: '司机', align: 'center', dataIndex: 'driverName', width: 90 },
|
||||
{ title: '手机号', align: 'center', dataIndex: 'driverPhone', width: 120 },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user