feat:策略
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace WmsWarehouseStrategyApi {
|
||||
/** 出入库策略信息 */
|
||||
export interface WarehouseStrategy {
|
||||
sectionCode?: string; // 库区编码
|
||||
strategy?: string; // 规则
|
||||
strategyType: string; // 策略类型
|
||||
description: string; // 描述
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询出入库策略分页 */
|
||||
export function getWarehouseStrategyPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<WmsWarehouseStrategyApi.WarehouseStrategy>>(
|
||||
'/wms/warehouse-strategy/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询出入库策略详情 */
|
||||
export function getWarehouseStrategy(id: number) {
|
||||
return requestClient.get<WmsWarehouseStrategyApi.WarehouseStrategy>(
|
||||
`/wms/warehouse-strategy/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增出入库策略 */
|
||||
export function createWarehouseStrategy(data: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
return requestClient.post('/wms/warehouse-strategy/create', data);
|
||||
}
|
||||
|
||||
/** 修改出入库策略 */
|
||||
export function updateWarehouseStrategy(data: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
return requestClient.put('/wms/warehouse-strategy/update', data);
|
||||
}
|
||||
|
||||
/** 删除出入库策略 */
|
||||
export function deleteWarehouseStrategy(id: number) {
|
||||
return requestClient.delete(`/wms/warehouse-strategy/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除出入库策略 */
|
||||
export function deleteWarehouseStrategyList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/wms/warehouse-strategy/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出出入库策略 */
|
||||
export function exportWarehouseStrategy(params: any) {
|
||||
return requestClient.download('/wms/warehouse-strategy/export-excel', { params });
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace WmsWarehouseStrategyConfigApi {
|
||||
/** 仓储策略配置信息 */
|
||||
export interface WarehouseStrategyConfig {
|
||||
id?: string;
|
||||
strategyCode?: string; // 策略编码
|
||||
strategyName?: string; // 策略名称
|
||||
strategyType?: string; // 策略类型
|
||||
classType?: string; // 类处理类型
|
||||
param?: string; // 处理类
|
||||
remark: string; // 描述
|
||||
isUsed: boolean; // 是否启用
|
||||
ban: boolean; // 禁止操作
|
||||
formData: string; // 限定参数
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询仓储策略配置分页 */
|
||||
export function getWarehouseStrategyConfigPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>>(
|
||||
'/wms/warehouse-strategy-config/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询仓储策略配置详情 */
|
||||
export function getWarehouseStrategyConfig(id: number) {
|
||||
return requestClient.get<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>(
|
||||
`/wms/warehouse-strategy-config/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增仓储策略配置 */
|
||||
export function createWarehouseStrategyConfig(data: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
return requestClient.post('/wms/warehouse-strategy-config/create', data);
|
||||
}
|
||||
|
||||
/** 修改仓储策略配置 */
|
||||
export function updateWarehouseStrategyConfig(data: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
return requestClient.put('/wms/warehouse-strategy-config/update', data);
|
||||
}
|
||||
|
||||
/** 删除仓储策略配置 */
|
||||
export function deleteWarehouseStrategyConfig(id: number) {
|
||||
return requestClient.delete(`/wms/warehouse-strategy-config/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除仓储策略配置 */
|
||||
export function deleteWarehouseStrategyConfigList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/wms/warehouse-strategy-config/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出仓储策略配置 */
|
||||
export function exportWarehouseStrategyConfig(params: any) {
|
||||
return requestClient.download('/wms/warehouse-strategy-config/export-excel', { params });
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsWarehouseStrategyApi } from '#/api/wms/warehousestrategy';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import {getDictOptions} from "@vben/hooks";
|
||||
import {DICT_TYPE} from "@vben/constants";
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sectionCode',
|
||||
label: '库区编码',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入库区编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.WMS_OUT_IN_STRATEGY_TYPE),
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategy',
|
||||
label: '规则',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规则',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'description',
|
||||
label: '描述',
|
||||
component: 'TextArea',
|
||||
componentProps: {
|
||||
placeholder: '请输入描述',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'sectionCode',
|
||||
label: '库区编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入库区编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategy',
|
||||
label: '规则',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入规则',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.WMS_STRATEGY_TYPE),
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<WmsWarehouseStrategyApi.WarehouseStrategy>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'sectionCode',
|
||||
title: '库区编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategy',
|
||||
title: '规则',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategyType',
|
||||
title: '策略类型',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
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 { WmsWarehouseStrategyApi } from '#/api/wms/warehousestrategy';
|
||||
|
||||
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 {
|
||||
deleteWarehouseStrategy,
|
||||
deleteWarehouseStrategyList,
|
||||
exportWarehouseStrategy,
|
||||
getWarehouseStrategyPage,
|
||||
} from '#/api/wms/warehousestrategy';
|
||||
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: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除出入库策略 */
|
||||
async function handleDelete(row: WmsWarehouseStrategyApi.WarehouseStrategy) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteWarehouseStrategy(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 deleteWarehouseStrategyList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: WmsWarehouseStrategyApi.WarehouseStrategy[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportWarehouseStrategy(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 getWarehouseStrategyPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<WmsWarehouseStrategyApi.WarehouseStrategy>,
|
||||
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:warehouse-strategy:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['wms:warehouse-strategy:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['wms:warehouse-strategy:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WmsWarehouseStrategyApi } from '#/api/wms/warehousestrategy';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createWarehouseStrategy, getWarehouseStrategy, updateWarehouseStrategy } from '#/api/wms/warehousestrategy';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsWarehouseStrategyApi.WarehouseStrategy>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['出入库策略'])
|
||||
: $t('ui.actionTitle.create', ['出入库策略']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as WmsWarehouseStrategyApi.WarehouseStrategy;
|
||||
try {
|
||||
await (formData.value?.id ? updateWarehouseStrategy(data) : createWarehouseStrategy(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<WmsWarehouseStrategyApi.WarehouseStrategy>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getWarehouseStrategy(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,282 @@
|
||||
import {type VbenFormSchema, z} from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsWarehouseStrategyConfigApi } from '#/api/wms/warehousestrategyconfig';
|
||||
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import {CommonStatusEnum, DICT_TYPE} from "@vben/constants";
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
const strategyTypeOptions = getDictOptions(DICT_TYPE.WMS_STRATEGY_TYPE, 'string');
|
||||
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyCode',
|
||||
label: '策略编码',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入策略编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyName',
|
||||
label: '策略名称',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入策略名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
rules: 'required',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: strategyTypeOptions,
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
defaultValue: strategyTypeOptions[0]?.value,
|
||||
},
|
||||
{
|
||||
fieldName: 'classType',
|
||||
label: '类处理类型',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请选择类处理类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'param',
|
||||
label: '参数',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入参数',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入描述',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'isUsed',
|
||||
label: '是否启用',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
{
|
||||
fieldName: 'ban',
|
||||
label: '禁止操作',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.DISABLE),
|
||||
},
|
||||
{
|
||||
fieldName: 'formData',
|
||||
label: '限定参数',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入限定参数',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'strategyCode',
|
||||
label: '策略编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入策略编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyName',
|
||||
label: '策略名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入策略名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'strategyType',
|
||||
label: '策略类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.WMS_STRATEGY_TYPE),
|
||||
placeholder: '请选择策略类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'classType',
|
||||
label: '类处理类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择类处理类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'param',
|
||||
label: '处理类',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入处理类',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入描述',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'isUsed',
|
||||
label: '是否启用',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择是否启用',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'strategyCode',
|
||||
title: '策略编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategyName',
|
||||
title: '策略名称',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'strategyType',
|
||||
title: '策略类型',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.WMS_STRATEGY_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'classType',
|
||||
title: '类处理类型',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'param',
|
||||
title: '处理类',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '描述',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'isUsed',
|
||||
title: '是否启用',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_TRUE_FALSE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'ban',
|
||||
title: '是否禁止操作',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_TRUE_FALSE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'formData',
|
||||
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 { WmsWarehouseStrategyConfigApi } from '#/api/wms/warehousestrategyconfig';
|
||||
|
||||
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 {
|
||||
deleteWarehouseStrategyConfig,
|
||||
deleteWarehouseStrategyConfigList,
|
||||
exportWarehouseStrategyConfig,
|
||||
getWarehouseStrategyConfigPage,
|
||||
} from '#/api/wms/warehousestrategyconfig';
|
||||
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: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除仓储策略配置 */
|
||||
async function handleDelete(row: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteWarehouseStrategyConfig(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 deleteWarehouseStrategyConfigList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportWarehouseStrategyConfig(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 getWarehouseStrategyConfigPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>,
|
||||
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:warehouse-strategy-config:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['wms:warehouse-strategy-config:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy-config:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['wms:warehouse-strategy-config:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:warehouse-strategy-config:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WmsWarehouseStrategyConfigApi } from '#/api/wms/warehousestrategyconfig';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createWarehouseStrategyConfig, getWarehouseStrategyConfig, updateWarehouseStrategyConfig } from '#/api/wms/warehousestrategyconfig';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['仓储策略配置'])
|
||||
: $t('ui.actionTitle.create', ['仓储策略配置']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig;
|
||||
try {
|
||||
await (formData.value?.id ? updateWarehouseStrategyConfig(data) : createWarehouseStrategyConfig(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<WmsWarehouseStrategyConfigApi.WarehouseStrategyConfig>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getWarehouseStrategyConfig(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
Reference in New Issue
Block a user