diff --git a/apps/web-antd/src/views/erp/sale/out/data.ts b/apps/web-antd/src/views/erp/sale/out/data.ts index b345974a6..8d9bda1e5 100644 --- a/apps/web-antd/src/views/erp/sale/out/data.ts +++ b/apps/web-antd/src/views/erp/sale/out/data.ts @@ -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' }, }, diff --git a/apps/web-antd/src/views/erp/sale/out/index.vue b/apps/web-antd/src/views/erp/sale/out/index.vue index feb8a6cdf..693a5ead8 100644 --- a/apps/web-antd/src/views/erp/sale/out/index.vue +++ b/apps/web-antd/src/views/erp/sale/out/index.vue @@ -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([]); 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/" /> - +