feat:【antd】【erp 系统】sale/out 部分重构(列表 ok)

This commit is contained in:
YunaiV
2025-10-04 09:15:01 +08:00
parent d5712f2640
commit e073a40153
4 changed files with 111 additions and 139 deletions

View File

@@ -11,30 +11,31 @@ import { getProductSimpleList } from '#/api/erp/product/product';
import { getCustomerSimpleList } from '#/api/erp/sale/customer';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
/** 表单的配置项 */
export function useFormSchema(formType: string): VbenFormSchema[] {
return [
{
component: 'Input',
componentProps: {
style: { display: 'none' },
},
fieldName: 'id',
label: 'ID',
hideLabel: true,
formItemClass: 'hidden',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'no',
label: '出库单号',
component: 'Input',
componentProps: {
placeholder: '系统自动生成',
disabled: true,
},
fieldName: 'no',
label: '出库单号',
},
{
fieldName: 'customerId',
label: '客户',
component: 'ApiSelect',
componentProps: {
disabled: true,
@@ -47,8 +48,6 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
value: 'id',
},
},
fieldName: 'customerId',
label: '客户',
rules: 'required',
},
{
@@ -63,6 +62,8 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
},
},
{
fieldName: 'outTime',
label: '出库时间',
component: 'DatePicker',
componentProps: {
disabled: formType === 'detail',
@@ -70,28 +71,25 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
style: { width: '100%' },
},
fieldName: 'outTime',
label: '出库时间',
rules: 'required',
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
disabled: formType === 'detail',
autoSize: { minRows: 1, maxRows: 1 },
class: 'w-full',
disabled: formType === 'detail',
},
fieldName: 'remark',
formItemClass: 'col-span-2',
label: '备注',
},
{
fieldName: 'fileUrl',
label: '附件',
component: 'FileUpload',
componentProps: {
disabled: formType === 'detail',
maxNumber: 1,
maxSize: 10,
accept: [
@@ -105,69 +103,65 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
'jpeg',
'png',
],
showDescription: true,
showDescription: formType !== 'detail',
disabled: formType === 'detail',
},
fieldName: 'fileUrl',
label: '附件',
formItemClass: 'col-span-3',
},
{
fieldName: 'product',
fieldName: 'items',
label: '产品清单',
component: 'Input',
formItemClass: 'col-span-3',
},
{
component: 'InputNumber',
fieldName: 'discountPercent',
label: '优惠率(%)',
component: 'InputNumber',
componentProps: {
placeholder: '优惠率',
placeholder: '请输入优惠率',
min: 0,
max: 100,
disabled: true,
precision: 2,
style: { width: '100%' },
},
label: '优惠率(%)',
rules: z.number().min(0).optional(),
},
{
fieldName: 'discountPrice',
label: '付款优惠',
component: 'InputNumber',
componentProps: {
placeholder: '付款优惠',
precision: 2,
formatter: erpPriceInputFormatter,
disabled: true,
style: { width: '100%' },
},
fieldName: 'discountPrice',
label: '付款优惠',
},
{
fieldName: 'discountedPrice',
label: '优惠后金额',
component: 'InputNumber',
componentProps: {
placeholder: '优惠后金额',
precision: 2,
formatter: erpPriceInputFormatter,
disabled: true,
style: { width: '100%' },
},
fieldName: 'discountedPrice',
label: '优惠后金额',
},
{
fieldName: 'otherPrice',
label: '其他费用',
component: 'InputNumber',
componentProps: {
disabled: formType === 'detail',
placeholder: '请输入其他费用',
precision: 2,
formatter: erpPriceInputFormatter,
style: { width: '100%' },
},
fieldName: 'otherPrice',
label: '其他费用',
},
{
fieldName: 'accountId',
label: '结算账户',
component: 'ApiSelect',
componentProps: {
placeholder: '请选择结算账户',
@@ -180,26 +174,22 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
value: 'id',
},
},
fieldName: 'accountId',
label: '结算账户',
},
{
fieldName: 'totalPrice',
label: '应收金额',
component: 'InputNumber',
componentProps: {
precision: 2,
style: { width: '100%' },
disabled: true,
min: 0,
},
fieldName: 'totalPrice',
label: '应收金额',
rules: z.number().min(0).optional(),
},
];
}
/** 采购订单项表格列定义 */
export function useSaleOutItemTableColumns(): VxeTableGridOptions['columns'] {
/** 表单的明细表格列 */
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
return [
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
{
@@ -216,7 +206,7 @@ export function useSaleOutItemTableColumns(): VxeTableGridOptions['columns'] {
},
{
field: 'stockCount',
title: '仓库库存',
title: '库存',
minWidth: 80,
},
{
@@ -315,10 +305,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '出库时间',
component: 'RangePicker',
componentProps: {
placeholder: ['开始时间', '结束时间'],
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
...getRangePickerDefaultProps(),
allowClear: true,
},
},
{
@@ -390,12 +378,12 @@ export function useGridFormSchema(): VbenFormSchema[] {
},
{
fieldName: 'status',
label: '状态',
label: '审批状态',
component: 'Select',
componentProps: {
placeholder: '请选择状态',
allowClear: true,
options: getDictOptions(DICT_TYPE.ERP_AUDIT_STATUS, 'number'),
placeholder: '请选择审批状态',
allowClear: true,
},
},
{
@@ -473,7 +461,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
},
{
field: 'status',
title: '状态',
title: '审批状态',
minWidth: 120,
cellRender: {
name: 'CellDict',
@@ -482,7 +470,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
},
{
title: '操作',
minWidth: 250,
width: 220,
fixed: 'right',
slots: { default: 'actions' },
},

View File

@@ -19,7 +19,7 @@ import {
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import SaleOutForm from './modules/sale-out-form.vue';
import SaleOutForm from './modules/form.vue';
/** ERP 销售出库列表 */
defineOptions({ name: 'ErpSaleOut' });
@@ -30,11 +30,56 @@ const [FormModal, formModalApi] = useVbenModal({
});
/** 刷新表格 */
function onRefresh() {
function handleRefresh() {
gridApi.query();
}
// TODO @Xuzhiqiang批量删除待实现
/** 导出表格 */
async function handleExport() {
const data = await exportSaleOut(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '销售出库.xls', source: data });
}
/** 新增销售出库 */
function handleCreate() {
formModalApi.setData({ type: 'create' }).open();
}
/** 编辑销售出库 */
function handleEdit(row: ErpSaleOutApi.SaleOut) {
formModalApi.setData({ type: 'edit', id: row.id }).open();
}
/** 删除销售出库 */
async function handleDelete(ids: number[]) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting'),
duration: 0,
});
try {
await deleteSaleOut(ids);
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
}
/** 审批/反审批操作 */
async function handleUpdateStatus(row: ErpSaleOutApi.SaleOut, status: number) {
const hideLoading = message.loading({
content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`,
duration: 0,
});
try {
await updateSaleOutStatus(row.id!, status);
message.success(`${status === 20 ? '审批' : '反审批'}成功`);
handleRefresh();
} finally {
hideLoading();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
@@ -44,69 +89,11 @@ function handleRowCheckboxChange({
checkedIds.value = records.map((item) => item.id!);
}
/** 详情 */
/** 查看详情 */
function handleDetail(row: ErpSaleOutApi.SaleOut) {
formModalApi.setData({ type: 'detail', id: row.id }).open();
}
/** 新增 */
function handleCreate() {
formModalApi.setData({ type: 'create' }).open();
}
/** 编辑 */
function handleEdit(row: ErpSaleOutApi.SaleOut) {
formModalApi.setData({ type: 'update', id: row.id }).open();
}
/** 删除 */
async function handleDelete(ids: number[]) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting'),
duration: 0,
key: 'action_process_msg',
});
try {
await deleteSaleOut(ids);
message.success({
content: $t('ui.actionMessage.deleteSuccess'),
key: 'action_process_msg',
});
onRefresh();
} finally {
hideLoading();
}
}
/** 审批/反审批操作 */
function handleUpdateStatus(row: ErpSaleOutApi.SaleOut, status: number) {
const hideLoading = message.loading({
content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`,
duration: 0,
key: 'action_process_msg',
});
updateSaleOutStatus({ id: row.id!, status })
.then(() => {
message.success({
content: `${status === 20 ? '审批' : '反审批'}成功`,
key: 'action_process_msg',
});
onRefresh();
})
.catch(() => {
// 处理错误
})
.finally(() => {
hideLoading();
});
}
/** 导出 */
async function handleExport() {
const data = await exportSaleOut(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '销售出库.xls', source: data });
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -150,8 +137,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
url="https://doc.iocoder.cn/erp/sale/"
/>
</template>
<FormModal @success="onRefresh" />
<FormModal @success="handleRefresh" />
<Grid table-title="销售出库列表">
<template #toolbar-tools>
<TableAction
@@ -178,11 +165,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
icon: ACTION_ICON.DELETE,
auth: ['erp:sale-out:delete'],
popConfirm: {
disabled: isEmpty(checkedIds),
title: `是否删除所选中数据?`,
confirm: () => {
handleDelete(checkedIds);
},
confirm: handleDelete.bind(null, checkedIds),
},
},
]"
@@ -227,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
auth: ['erp:sale-out:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
confirm: () => handleDelete([row.id!]),
confirm: handleDelete.bind(null, [row.id!]),
},
},
]"

View File

@@ -12,7 +12,7 @@ import { useVbenForm } from '#/adapter/form';
import { createSaleOut, getSaleOut, updateSaleOut } from '#/api/erp/sale/out';
import { useFormSchema } from '../data';
import SaleOutItemForm from './sale-out-item-form.vue';
import ItemForm from './item-form.vue';
import SelectSaleOrderForm from './select-sale-order-form.vue';
const emit = defineEmits(['success']);
@@ -42,8 +42,8 @@ const formData = ref<
discountedPrice: 0,
items: [],
});
const formType = ref('');
const itemFormRef = ref();
const formType = ref(''); // 'create' | 'edit' | 'detail'
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
const getTitle = computed(() => {
if (formType.value === 'create') return '添加销售出库';
@@ -74,7 +74,7 @@ const [Form, formApi] = useVbenForm({
},
});
//
/** 更新销售出库项 */
const handleUpdateItems = async (items: ErpSaleOutApi.SaleOutItem[]) => {
if (formData.value) {
const data = await formApi.getValues();
@@ -83,7 +83,7 @@ const handleUpdateItems = async (items: ErpSaleOutApi.SaleOutItem[]) => {
}
};
//
/** 选择销售订单 */
const handleUpdateOrder = (order: ErpSaleOrderApi.SaleOrder) => {
formData.value = {
...formData.value,
@@ -95,7 +95,7 @@ const handleUpdateOrder = (order: ErpSaleOrderApi.SaleOrder) => {
discountPercent: order.discountPercent!,
fileUrl: order.fileUrl!,
};
//
//
order.items!.forEach((item: any) => {
item.totalCount = item.count;
item.count = item.totalCount - item.outCount;
@@ -286,8 +286,8 @@ defineExpose({ modalApi });
:show-confirm-button="formType !== 'detail'"
>
<Form class="mx-3">
<template #product="slotProps">
<SaleOutItemForm
<template #items="slotProps">
<ItemForm
v-bind="slotProps"
ref="itemFormRef"
class="w-full"

View File

@@ -12,7 +12,12 @@ import { getProductSimpleList } from '#/api/erp/product/product';
import { getWarehouseStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { useSaleOutItemTableColumns } from '../data';
import { useFormItemColumns } from '../data';
interface Props {
items?: ErpSaleOutApi.SaleOutItem[];
disabled?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
items: () => [],
@@ -21,11 +26,6 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits(['update:items', 'update:totalPrice']);
interface Props {
items?: ErpSaleOutApi.SaleOutItem[];
disabled?: boolean;
}
const tableData = ref<ErpSaleOutApi.SaleOutItem[]>([]);
const productOptions = ref<any[]>([]);
const warehouseOptions = ref<any[]>([]);
@@ -37,7 +37,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
trigger: 'click',
mode: 'cell',
},
columns: useSaleOutItemTableColumns(),
columns: useFormItemColumns(),
data: tableData.value,
border: true,
showOverflow: true,