feat:组盘PC
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace WmsGroupPlateApi {
|
||||
/** 组盘记录信息 */
|
||||
export interface GroupPlate {
|
||||
groupId: string;
|
||||
vehicleCode: string; // 载具编码
|
||||
status?: string; // 状态
|
||||
materialId: string; // 物料id
|
||||
pcsn?: string; // 批次
|
||||
qty?: number; // 组盘数量
|
||||
frozenQty: number; // 冻结数量
|
||||
qtyUnitId: string; // 计量单位标识
|
||||
qtyUnitName: string; // 计量单位名称
|
||||
remark: string; // 备注
|
||||
extCode: string; // 来源单据号
|
||||
extType: string; // 来源单据类型
|
||||
extDtlCode: string; // 来源单据明细号
|
||||
md5: string; // md5
|
||||
materialCode?: string; // 物料编码
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询组盘记录分页 */
|
||||
export function getGroupPlatePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<WmsGroupPlateApi.GroupPlate>>(
|
||||
'/wms/group-plate/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询组盘记录详情 */
|
||||
export function getGroupPlate(id: number) {
|
||||
return requestClient.get<WmsGroupPlateApi.GroupPlate>(
|
||||
`/wms/group-plate/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增组盘记录 */
|
||||
export function createGroupPlate(data: WmsGroupPlateApi.GroupPlate) {
|
||||
return requestClient.post('/wms/group-plate/create', data);
|
||||
}
|
||||
|
||||
/** 修改组盘记录 */
|
||||
export function updateGroupPlate(data: WmsGroupPlateApi.GroupPlate) {
|
||||
return requestClient.put('/wms/group-plate/update', data);
|
||||
}
|
||||
|
||||
/** 删除组盘记录 */
|
||||
export function deleteGroupPlate(id: number) {
|
||||
return requestClient.delete(`/wms/group-plate/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除组盘记录 */
|
||||
export function deleteGroupPlateList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/wms/group-plate/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出组盘记录 */
|
||||
export function exportGroupPlate(params: any) {
|
||||
return requestClient.download('/wms/group-plate/export-excel', { params });
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ export namespace WmsWarehouseStrategyConfigApi {
|
||||
export interface WarehouseStrategyConfigSimple {
|
||||
strategyCode: string; // 策略编码
|
||||
strategyName: string; // 策略名称
|
||||
classType?: string; // 类处理类型
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { handleTree } from '@vben/utils';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getMaterialBasePage } from '#/api/base/materialbase';
|
||||
import { getClassStandardListByCode } from '#/api/base/classstandard';
|
||||
|
||||
const emit = defineEmits(['select']);
|
||||
|
||||
/** 物料分类树形下拉 */
|
||||
async function loadMaterialTypeTree() {
|
||||
const data = await getClassStandardListByCode('0001');
|
||||
if (!data || data.length === 0) return [];
|
||||
return handleTree(data, 'classId', 'parentClassId');
|
||||
}
|
||||
|
||||
const selectedRows = ref<any[]>([]);
|
||||
const isMultiple = ref(false);
|
||||
|
||||
function handleRadioChange({ row }: { row: any }) {
|
||||
selectedRows.value = row ? [row] : [];
|
||||
}
|
||||
|
||||
function handleCheckboxChange({ records }: { records: any[] }) {
|
||||
selectedRows.value = records;
|
||||
}
|
||||
|
||||
const baseColumns = [
|
||||
{ field: 'materialCode', title: '物料编码', minWidth: 120 },
|
||||
{ field: 'materialName', title: '物料名称', minWidth: 200 },
|
||||
{ field: 'materialSpec', title: '规格', minWidth: 120 },
|
||||
{ field: 'materialModel', title: '型号', minWidth: 120 },
|
||||
];
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: [
|
||||
{
|
||||
fieldName: 'materialCode',
|
||||
label: '物料编码',
|
||||
component: 'Input',
|
||||
componentProps: { allowClear: true, placeholder: '请输入物料编码' },
|
||||
},
|
||||
{
|
||||
fieldName: 'materialName',
|
||||
label: '物料名称',
|
||||
component: 'Input',
|
||||
componentProps: { allowClear: true, placeholder: '请输入物料名称' },
|
||||
},
|
||||
{
|
||||
fieldName: 'materialTypeId',
|
||||
label: '物料分类',
|
||||
component: 'ApiTreeSelect',
|
||||
componentProps: {
|
||||
api: loadMaterialTypeTree,
|
||||
childrenField: 'children',
|
||||
labelField: 'className',
|
||||
placeholder: '请选择物料分类',
|
||||
valueField: 'classId',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
gridOptions: {
|
||||
columns: [{ type: 'radio', width: 40 }, ...baseColumns],
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getMaterialBasePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'materialId',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<any>,
|
||||
gridEvents: {
|
||||
radioChange: handleRadioChange,
|
||||
checkboxAll: handleCheckboxChange,
|
||||
checkboxChange: handleCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
message.warning('请至少选择一条物料信息');
|
||||
return;
|
||||
}
|
||||
emit('select', selectedRows.value);
|
||||
modalApi.close();
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
selectedRows.value = [];
|
||||
return;
|
||||
}
|
||||
const data = modalApi.getData<{ multiple: boolean }>();
|
||||
const multiple = data?.multiple ?? false;
|
||||
isMultiple.value = multiple;
|
||||
// 动态切换单选/多选列类型
|
||||
gridApi.setGridOptions({
|
||||
columns: [
|
||||
{ type: multiple ? 'checkbox' : 'radio', width: 40 },
|
||||
...baseColumns,
|
||||
],
|
||||
});
|
||||
selectedRows.value = [];
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="选择物料" class="w-[1000px]">
|
||||
<Grid />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,113 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getMeasureUnitPage } from '#/api/base/measureunit';
|
||||
|
||||
const emit = defineEmits(['select']);
|
||||
|
||||
const selectedRows = ref<any[]>([]);
|
||||
const isMultiple = ref(false);
|
||||
|
||||
function handleRadioChange({ row }: { row: any }) {
|
||||
selectedRows.value = row ? [row] : [];
|
||||
}
|
||||
|
||||
function handleCheckboxChange({ records }: { records: any[] }) {
|
||||
selectedRows.value = records;
|
||||
}
|
||||
|
||||
const baseColumns = [
|
||||
{ field: 'unitCode', title: '编码', minWidth: 120 },
|
||||
{ field: 'unitName', title: '名称', minWidth: 150 },
|
||||
{ field: 'qtyPrecision', title: '数据精度', minWidth: 100 },
|
||||
];
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: [
|
||||
{
|
||||
fieldName: 'unitCode',
|
||||
label: '编码',
|
||||
component: 'Input',
|
||||
componentProps: { allowClear: true, placeholder: '请输入编码' },
|
||||
},
|
||||
{
|
||||
fieldName: 'unitName',
|
||||
label: '名称',
|
||||
component: 'Input',
|
||||
componentProps: { allowClear: true, placeholder: '请输入名称' },
|
||||
},
|
||||
],
|
||||
},
|
||||
gridOptions: {
|
||||
columns: [{ type: 'radio', width: 40 }, ...baseColumns],
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getMeasureUnitPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
isUsed: '1',
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'measureUnitId',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<any>,
|
||||
gridEvents: {
|
||||
radioChange: handleRadioChange,
|
||||
checkboxAll: handleCheckboxChange,
|
||||
checkboxChange: handleCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
message.warning('请至少选择一条计量单位');
|
||||
return;
|
||||
}
|
||||
emit('select', selectedRows.value);
|
||||
modalApi.close();
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
selectedRows.value = [];
|
||||
return;
|
||||
}
|
||||
const data = modalApi.getData<{ multiple: boolean }>();
|
||||
const multiple = data?.multiple ?? false;
|
||||
isMultiple.value = multiple;
|
||||
gridApi.setGridOptions({
|
||||
columns: [
|
||||
{ type: multiple ? 'checkbox' : 'radio', width: 40 },
|
||||
...baseColumns,
|
||||
],
|
||||
});
|
||||
selectedRows.value = [];
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="选择计量单位" class="w-[700px]">
|
||||
<Grid />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,356 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsGroupPlateApi } from '#/api/wms/groupplate';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import {getDictOptions} from "@vben/hooks";
|
||||
import {DICT_TYPE} from "@vben/constants";
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'groupId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'vehicleCode',
|
||||
label: '载具编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入载具编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
rules: 'required',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.WMS_GROUP_PLATE_STATUS),
|
||||
placeholder: '请选择状态',
|
||||
},
|
||||
defaultValue: '00'
|
||||
},
|
||||
{
|
||||
fieldName: 'materialId',
|
||||
label: '物料id',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入物料id',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
fieldName: 'materialCode',
|
||||
label: '物料编码',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入物料编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'pcsn',
|
||||
label: '批次',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qty',
|
||||
label: '组盘数量',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入组盘数量',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'frozenQty',
|
||||
label: '冻结数量',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入冻结数量',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qtyUnitId',
|
||||
label: '计量单位标识',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qtyUnitName',
|
||||
label: '计量单位',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入计量单位名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'extCode',
|
||||
label: '来源单据号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入来源单据号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'extType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [],
|
||||
placeholder: '请选择来源单据类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'extDtlCode',
|
||||
label: '来源单据明细号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入来源单据明细号',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'vehicleCode',
|
||||
label: '载具编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入载具编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.WMS_GROUP_PLATE_STATUS),
|
||||
placeholder: '请选择状态',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialId',
|
||||
label: '物料id',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入物料id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialCode',
|
||||
label: '物料编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入物料编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'pcsn',
|
||||
label: '批次',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入批次',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qty',
|
||||
label: '组盘数量',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入组盘数量',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'frozenQty',
|
||||
label: '冻结数量',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入冻结数量',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qtyUnitName',
|
||||
label: '计量单位',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入计量单位',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'extCode',
|
||||
label: '来源单据号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入来源单据号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'extType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择来源单据类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'extDtlCode',
|
||||
label: '来源单据明细号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入来源单据明细号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
defaultValue: [
|
||||
dayjs().subtract(30, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
||||
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss'),
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<WmsGroupPlateApi.GroupPlate>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'vehicleCode',
|
||||
title: '载具编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'materialId',
|
||||
title: '物料id',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'pcsn',
|
||||
title: '批次',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'qty',
|
||||
title: '组盘数量',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'frozenQty',
|
||||
title: '冻结数量',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'qtyUnitName',
|
||||
title: '计量单位名称',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'extCode',
|
||||
title: '来源单据号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'extType',
|
||||
title: '来源单据类型',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'extDtlCode',
|
||||
title: '来源单据明细号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'materialCode',
|
||||
title: '物料编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'creator',
|
||||
title: '创建者',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'updater',
|
||||
title: '更新者',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsGroupPlateApi } from '#/api/wms/groupplate';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteGroupPlate,
|
||||
deleteGroupPlateList,
|
||||
exportGroupPlate,
|
||||
getGroupPlatePage,
|
||||
} from '#/api/wms/groupplate';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建组盘记录 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑组盘记录 */
|
||||
function handleEdit(row: WmsGroupPlateApi.GroupPlate) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除组盘记录 */
|
||||
async function handleDelete(row: WmsGroupPlateApi.GroupPlate) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteGroupPlate(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除组盘记录 */
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deletingBatch'),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteGroupPlateList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: WmsGroupPlateApi.GroupPlate[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportGroupPlate(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '组盘记录.xls', source: data });
|
||||
}
|
||||
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getGroupPlatePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<WmsGroupPlateApi.GroupPlate>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleRowCheckboxChange,
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="组盘记录列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['组盘记录']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['wms:group-plate:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['wms:group-plate:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:group-plate:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['wms:group-plate:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:group-plate:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,155 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WmsGroupPlateApi } from '#/api/wms/groupplate';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createGroupPlate, getGroupPlate, updateGroupPlate } from '#/api/wms/groupplate';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import MaterialSelectModalComponent from '../../../base/materialbase/components/MaterialSelectModal.vue';
|
||||
import MeasureUnitSelectModalComponent from '../../../base/measureunit/components/MeasureUnitSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsGroupPlateApi.GroupPlate>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.groupId
|
||||
? $t('ui.actionTitle.edit', ['组盘记录'])
|
||||
: $t('ui.actionTitle.create', ['组盘记录']);
|
||||
});
|
||||
|
||||
/** 物料选择弹窗 */
|
||||
const [MaterialSelectModal, materialSelectModalApi] = useVbenModal({
|
||||
connectedComponent: MaterialSelectModalComponent,
|
||||
});
|
||||
|
||||
function openMaterialSelect() {
|
||||
materialSelectModalApi.setData({ multiple: false }).open();
|
||||
}
|
||||
|
||||
function handleMaterialSelect(rows: any[]) {
|
||||
if (rows.length > 0) {
|
||||
const row = rows[0];
|
||||
const currentValues = formApi.getValues();
|
||||
formApi.setValues({
|
||||
...currentValues,
|
||||
materialId: row.materialId,
|
||||
materialCode: row.materialCode,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** 计量单位选择弹窗 */
|
||||
const [MeasureUnitSelectModal, measureUnitSelectModalApi] = useVbenModal({
|
||||
connectedComponent: MeasureUnitSelectModalComponent,
|
||||
});
|
||||
|
||||
function openMeasureUnitSelect() {
|
||||
measureUnitSelectModalApi.setData({ multiple: false }).open();
|
||||
}
|
||||
|
||||
function handleMeasureUnitSelect(rows: any[]) {
|
||||
if (rows.length > 0) {
|
||||
const row = rows[0];
|
||||
const currentValues = formApi.getValues();
|
||||
formApi.setValues({
|
||||
...currentValues,
|
||||
qtyUnitId: row.measureUnitId,
|
||||
qtyUnitName: row.unitName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 覆盖物料编码和计量单位字段:只读,点击弹出选择窗
|
||||
const schema = useFormSchema().map((field) => {
|
||||
if (field.fieldName === 'materialCode') {
|
||||
return {
|
||||
...field,
|
||||
componentProps: {
|
||||
placeholder: '请选择物料编码',
|
||||
readonly: true,
|
||||
style: 'cursor: pointer',
|
||||
onClick: openMaterialSelect,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (field.fieldName === 'qtyUnitName') {
|
||||
return {
|
||||
...field,
|
||||
componentProps: {
|
||||
placeholder: '请选择计量单位',
|
||||
readonly: true,
|
||||
style: 'cursor: pointer',
|
||||
onClick: openMeasureUnitSelect,
|
||||
},
|
||||
};
|
||||
}
|
||||
return field;
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema,
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as WmsGroupPlateApi.GroupPlate;
|
||||
try {
|
||||
await (formData.value?.id ? updateGroupPlate(data) : createGroupPlate(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<WmsGroupPlateApi.GroupPlate>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getGroupPlate(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
<MaterialSelectModal @select="handleMaterialSelect" />
|
||||
<MeasureUnitSelectModal @select="handleMeasureUnitSelect" />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -9,11 +9,30 @@ import {getDictOptions} from "@vben/hooks";
|
||||
import {DICT_TYPE} from "@vben/constants";
|
||||
|
||||
/** 策略配置选项(供表单多选和列表显示使用) */
|
||||
export const strategyConfigOptions = ref<{ label: string; value: string }[]>([]);
|
||||
export const strategyConfigOptions = ref<{ label: string; value: string; classType?: string; disabled?: boolean }[]>([]);
|
||||
|
||||
/** 策略编码 -> 名称的映射 */
|
||||
export const strategyNameMap = ref<Record<string, string>>({});
|
||||
|
||||
/** classType 值 -> 显示文本的映射 */
|
||||
const classTypeLabelMap: Record<string, string> = {};
|
||||
function getClassTypeLabel(classType?: string): string {
|
||||
if (!classType) return '';
|
||||
if (!classTypeLabelMap[classType]) {
|
||||
const dictOptions = getDictOptions(DICT_TYPE.WMS_STRATEGY_CLASS_TYPE);
|
||||
for (const opt of dictOptions) {
|
||||
classTypeLabelMap[opt.value] = opt.label;
|
||||
}
|
||||
}
|
||||
return classTypeLabelMap[classType] || classType;
|
||||
}
|
||||
|
||||
/** 构建规则选项的显示标签:名称(编码)-classTypeLabel */
|
||||
export function buildStrategyLabel(item: { strategyCode: string; strategyName: string; classType?: string }): string {
|
||||
const ctLabel = getClassTypeLabel(item.classType);
|
||||
return ctLabel ? `${item.strategyName}(${item.strategyCode})-${ctLabel}` : `${item.strategyName}(${item.strategyCode})`;
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -48,10 +67,17 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
label: '规则',
|
||||
rules: 'required',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
mode: 'multiple',
|
||||
options: strategyConfigOptions,
|
||||
placeholder: '请选择规则',
|
||||
componentProps: (values) => {
|
||||
const selected = values.strategy;
|
||||
const noSelection = !selected || (Array.isArray(selected) && selected.length === 0);
|
||||
return {
|
||||
mode: 'multiple',
|
||||
options: strategyConfigOptions.value.map((opt) => ({
|
||||
...opt,
|
||||
disabled: noSelection && opt.classType === '2',
|
||||
})),
|
||||
placeholder: '请选择规则',
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import { getWarehouseStrategyConfigSimpleList } from '#/api/wms/warehousestrategyconfig';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { strategyConfigOptions, strategyNameMap, useGridColumns, useGridFormSchema } from './data';
|
||||
import { buildStrategyLabel, strategyConfigOptions, strategyNameMap, useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
@@ -44,8 +44,9 @@ onMounted(async () => {
|
||||
try {
|
||||
const configList = await getWarehouseStrategyConfigSimpleList();
|
||||
strategyConfigOptions.value = configList.map((item) => ({
|
||||
label: `${item.strategyName}(${item.strategyCode})`,
|
||||
label: buildStrategyLabel(item),
|
||||
value: item.strategyCode,
|
||||
classType: item.classType,
|
||||
}));
|
||||
const map: Record<string, string> = {};
|
||||
configList.forEach((item) => {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { createWarehouseStrategy, getWarehouseStrategy, updateWarehouseStrategy
|
||||
import { getWarehouseStrategyConfigSimpleList } from '#/api/wms/warehousestrategyconfig';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { strategyConfigOptions, strategyNameMap, useFormSchema } from '../data';
|
||||
import { buildStrategyLabel, strategyConfigOptions, strategyNameMap, useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsWarehouseStrategyApi.WarehouseStrategy>();
|
||||
@@ -83,8 +83,9 @@ const [Modal, modalApi] = useVbenModal({
|
||||
try {
|
||||
const configList = await getWarehouseStrategyConfigSimpleList();
|
||||
strategyConfigOptions.value = configList.map((item) => ({
|
||||
label: `${item.strategyName}(${item.strategyCode})`,
|
||||
label: buildStrategyLabel(item),
|
||||
value: item.strategyCode,
|
||||
classType: item.classType,
|
||||
}));
|
||||
// 构建编码 -> 名称映射
|
||||
const map: Record<string, string> = {};
|
||||
|
||||
@@ -53,8 +53,9 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
fieldName: 'classType',
|
||||
label: '类处理类型',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.WMS_STRATEGY_CLASS_TYPE),
|
||||
placeholder: '请选择类处理类型',
|
||||
},
|
||||
},
|
||||
@@ -144,7 +145,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
options: getDictOptions(DICT_TYPE.WMS_STRATEGY_CLASS_TYPE),
|
||||
placeholder: '请选择类处理类型',
|
||||
},
|
||||
},
|
||||
@@ -215,6 +216,10 @@ export function useGridColumns(): VxeTableGridOptions<WmsWarehouseStrategyConfig
|
||||
field: 'classType',
|
||||
title: '类处理类型',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.WMS_STRATEGY_CLASS_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'param',
|
||||
|
||||
@@ -283,6 +283,8 @@ const WMS_DICT = {
|
||||
WMS_STRATEGY_TYPE: 'wms_strategy_type', // WMS策略类型
|
||||
WMS_OUT_IN_STRATEGY_TYPE: 'wms_out_in_strategy_type', // WMS出入库策略类型
|
||||
WMS_LOCK_TYPE: 'wms_lock_type', // WMS 锁定类型
|
||||
WMS_STRATEGY_CLASS_TYPE: 'wms_strategy_class_type', // WMS 处理类类型
|
||||
WMS_GROUP_PLATE_STATUS: 'wms_group_plate_status', // 组盘记录
|
||||
} as const;
|
||||
|
||||
/** ========== TASK - 任务管理模块 ========== */
|
||||
|
||||
Reference in New Issue
Block a user