feat:【antd】【erp 系统】finance/receipt 的迁移 1/4(初始化)
This commit is contained in:
194
apps/web-antd/src/views/erp/finance/receipt/modules/form.vue
Normal file
194
apps/web-antd/src/views/erp/finance/receipt/modules/form.vue
Normal file
@@ -0,0 +1,194 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ErpFinanceReceiptApi } from '#/api/erp/finance/receipt';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getAccountSimpleList } from '#/api/erp/finance/account';
|
||||
import {
|
||||
createFinanceReceipt,
|
||||
getFinanceReceipt,
|
||||
updateFinanceReceipt,
|
||||
} from '#/api/erp/finance/receipt';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import ItemForm from './item-form.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<
|
||||
ErpFinanceReceiptApi.FinanceReceipt & {
|
||||
fileUrl?: string;
|
||||
}
|
||||
>({
|
||||
id: undefined,
|
||||
no: undefined,
|
||||
customerId: undefined,
|
||||
accountId: undefined,
|
||||
financeUserId: undefined,
|
||||
receiptTime: undefined,
|
||||
remark: undefined,
|
||||
fileUrl: undefined,
|
||||
totalPrice: 0,
|
||||
discountPrice: 0,
|
||||
receiptPrice: 0,
|
||||
items: [],
|
||||
});
|
||||
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
/* eslint-disable unicorn/no-nested-ternary */
|
||||
const getTitle = computed(() =>
|
||||
formType.value === 'create'
|
||||
? $t('ui.actionTitle.create', ['收款单'])
|
||||
: formType.value === 'edit'
|
||||
? $t('ui.actionTitle.edit', ['收款单'])
|
||||
: '收款单详情',
|
||||
);
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
labelWidth: 120,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'vertical',
|
||||
schema: useFormSchema(formType.value),
|
||||
showDefaultActions: false,
|
||||
handleValuesChange: (values, changedFields) => {
|
||||
if (formData.value) {
|
||||
if (changedFields.includes('customerId')) {
|
||||
formData.value.customerId = values.customerId;
|
||||
}
|
||||
// 目的:同步到 item-form 组件,触发整体的价格计算
|
||||
if (changedFields.includes('discountPrice')) {
|
||||
formData.value.discountPrice = values.discountPrice;
|
||||
formData.value.receiptPrice =
|
||||
formData.value.totalPrice - values.discountPrice;
|
||||
formApi.setValues({
|
||||
receiptPrice: formData.value.receiptPrice,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/** 更新收款项 */
|
||||
const handleUpdateItems = (
|
||||
items: ErpFinanceReceiptApi.FinanceReceiptItem[],
|
||||
) => {
|
||||
formData.value.items = items;
|
||||
formApi.setValues({
|
||||
items,
|
||||
});
|
||||
};
|
||||
|
||||
/** 更新总金额 */
|
||||
const handleUpdateTotalPrice = (totalPrice: number) => {
|
||||
formData.value.totalPrice = totalPrice;
|
||||
formApi.setValues({
|
||||
totalPrice: formData.value.totalPrice,
|
||||
});
|
||||
};
|
||||
|
||||
/** 更新收款金额 */
|
||||
const handleUpdateReceiptPrice = (receiptPrice: number) => {
|
||||
formData.value.receiptPrice = receiptPrice;
|
||||
formApi.setValues({
|
||||
receiptPrice: formData.value.receiptPrice,
|
||||
});
|
||||
};
|
||||
|
||||
/** 创建或更新收款单 */
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
const itemFormInstance = Array.isArray(itemFormRef.value)
|
||||
? itemFormRef.value[0]
|
||||
: itemFormRef.value;
|
||||
try {
|
||||
itemFormInstance.validate();
|
||||
} catch (error: any) {
|
||||
message.error(error.message || '子表单验证失败');
|
||||
return;
|
||||
}
|
||||
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data =
|
||||
(await formApi.getValues()) as ErpFinanceReceiptApi.FinanceReceipt;
|
||||
try {
|
||||
await (formType.value === 'create'
|
||||
? createFinanceReceipt(data)
|
||||
: updateFinanceReceipt(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<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
// 新增时,默认选中账户
|
||||
const accountList = await getAccountSimpleList();
|
||||
const defaultAccount = accountList.find((item) => item.defaultStatus);
|
||||
if (defaultAccount) {
|
||||
await formApi.setValues({ accountId: defaultAccount.id });
|
||||
}
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getFinanceReceipt(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value, false);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
:title="getTitle"
|
||||
class="w-3/4"
|
||||
:show-confirm-button="formType !== 'detail'"
|
||||
>
|
||||
<Form class="mx-3">
|
||||
<template #items>
|
||||
<ItemForm
|
||||
ref="itemFormRef"
|
||||
:items="formData?.items ?? []"
|
||||
:customer-id="formData?.customerId"
|
||||
:disabled="formType === 'detail'"
|
||||
:discount-price="formData?.discountPrice ?? 0"
|
||||
@update:items="handleUpdateItems"
|
||||
@update:total-price="handleUpdateTotalPrice"
|
||||
@update:receipt-price="handleUpdateReceiptPrice"
|
||||
/>
|
||||
</template>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,295 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ErpFinanceReceiptApi } from '#/api/erp/finance/receipt';
|
||||
import type { ErpSaleOutApi } from '#/api/erp/sale/out';
|
||||
import type { ErpSaleReturnApi } from '#/api/erp/sale/return';
|
||||
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
|
||||
import { ErpBizType } from '@vben/constants';
|
||||
import { erpPriceInputFormatter } from '@vben/utils';
|
||||
|
||||
import { Input, InputNumber, message } from 'ant-design-vue';
|
||||
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
|
||||
import { useFormItemColumns } from '../data';
|
||||
import SaleOutSelect from './sale-out-select.vue';
|
||||
import SaleReturnSelect from './sale-return-select.vue';
|
||||
|
||||
interface Props {
|
||||
items?: ErpFinanceReceiptApi.FinanceReceiptItem[];
|
||||
customerId?: number;
|
||||
disabled?: boolean;
|
||||
discountPrice?: number;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
items: () => [],
|
||||
customerId: undefined,
|
||||
disabled: false,
|
||||
discountPrice: 0,
|
||||
});
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:items',
|
||||
'update:total-price',
|
||||
'update:receipt-price',
|
||||
]);
|
||||
|
||||
const tableData = ref<ErpFinanceReceiptApi.FinanceReceiptItem[]>([]); // 表格数据
|
||||
|
||||
/** 获取表格合计数据 */
|
||||
const summaries = computed(() => {
|
||||
return {
|
||||
totalPrice: tableData.value.reduce(
|
||||
(sum, item) => sum + (item.totalPrice || 0),
|
||||
0,
|
||||
),
|
||||
receiptedPrice: tableData.value.reduce(
|
||||
(sum, item) => sum + (item.receiptedPrice || 0),
|
||||
0,
|
||||
),
|
||||
receiptPrice: tableData.value.reduce(
|
||||
(sum, item) => sum + (item.receiptPrice || 0),
|
||||
0,
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(tableData.value),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
border: true,
|
||||
rowConfig: {
|
||||
keyField: 'row_id',
|
||||
isHover: true,
|
||||
},
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/** 监听外部传入的列数据 */
|
||||
watch(
|
||||
() => props.items,
|
||||
async (items) => {
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
tableData.value = [...items];
|
||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||
await gridApi.grid.reloadData(tableData.value);
|
||||
// 更新表格列配置
|
||||
const columns = useFormItemColumns(tableData.value);
|
||||
await gridApi.grid.reloadColumn(columns);
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
},
|
||||
);
|
||||
|
||||
/** 计算 totalPrice、receiptPrice 价格 */
|
||||
watch(
|
||||
() => [tableData.value, props.discountPrice],
|
||||
() => {
|
||||
if (!tableData.value || tableData.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
const totalPrice = tableData.value.reduce(
|
||||
(prev, curr) => prev + (curr.totalPrice || 0),
|
||||
0,
|
||||
);
|
||||
const receiptPrice = tableData.value.reduce(
|
||||
(prev, curr) => prev + (curr.receiptPrice || 0),
|
||||
0,
|
||||
);
|
||||
const finalReceiptPrice = receiptPrice - (props.discountPrice || 0);
|
||||
// 通知父组件更新
|
||||
emit('update:total-price', totalPrice);
|
||||
emit('update:receipt-price', finalReceiptPrice);
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
/** 添加销售出库单 */
|
||||
const saleOutSelectRef = ref();
|
||||
const handleOpenSaleOut = () => {
|
||||
if (!props.customerId) {
|
||||
message.error('请选择客户');
|
||||
return;
|
||||
}
|
||||
saleOutSelectRef.value?.open(props.customerId);
|
||||
};
|
||||
|
||||
const handleAddSaleOut = (rows: ErpSaleOutApi.SaleOut[]) => {
|
||||
rows.forEach((row) => {
|
||||
const newItem: ErpFinanceReceiptApi.FinanceReceiptItem = {
|
||||
bizId: row.id,
|
||||
bizType: ErpBizType.SALE_OUT,
|
||||
bizNo: row.no,
|
||||
totalPrice: row.totalPrice,
|
||||
receiptedPrice: row.receiptPrice,
|
||||
receiptPrice: row.totalPrice - row.receiptPrice,
|
||||
remark: undefined,
|
||||
};
|
||||
tableData.value.push(newItem);
|
||||
});
|
||||
emit('update:items', [...tableData.value]);
|
||||
};
|
||||
|
||||
/** 添加销售退货单 */
|
||||
const saleReturnSelectRef = ref();
|
||||
const handleOpenSaleReturn = () => {
|
||||
if (!props.customerId) {
|
||||
message.error('请选择客户');
|
||||
return;
|
||||
}
|
||||
saleReturnSelectRef.value?.open(props.customerId);
|
||||
};
|
||||
|
||||
const handleAddSaleReturn = (rows: ErpSaleReturnApi.SaleReturn[]) => {
|
||||
rows.forEach((row) => {
|
||||
const newItem: ErpFinanceReceiptApi.FinanceReceiptItem = {
|
||||
bizId: row.id,
|
||||
bizType: ErpBizType.SALE_RETURN,
|
||||
bizNo: row.no,
|
||||
totalPrice: -row.totalPrice,
|
||||
receiptedPrice: -row.refundPrice,
|
||||
receiptPrice: -row.totalPrice + row.refundPrice,
|
||||
remark: undefined,
|
||||
};
|
||||
tableData.value.push(newItem);
|
||||
});
|
||||
emit('update:items', [...tableData.value]);
|
||||
};
|
||||
|
||||
/** 删除行 */
|
||||
const handleDelete = async (row: any) => {
|
||||
const index = tableData.value.findIndex(
|
||||
(item) => item.bizId === row.bizId && item.bizType === row.bizType,
|
||||
);
|
||||
if (index !== -1) {
|
||||
tableData.value.splice(index, 1);
|
||||
}
|
||||
// 通知父组件更新
|
||||
emit('update:items', [...tableData.value]);
|
||||
};
|
||||
|
||||
/** 处理行数据变更 */
|
||||
const handleRowChange = (row: any) => {
|
||||
const index = tableData.value.findIndex(
|
||||
(item) => item.bizId === row.bizId && item.bizType === row.bizType,
|
||||
);
|
||||
if (index === -1) {
|
||||
tableData.value.push(row);
|
||||
} else {
|
||||
tableData.value[index] = row;
|
||||
}
|
||||
emit('update:items', [...tableData.value]);
|
||||
};
|
||||
|
||||
/** 表单校验 */
|
||||
const validate = () => {
|
||||
// 检查是否有明细
|
||||
if (tableData.value.length === 0) {
|
||||
throw new Error('请添加收款明细');
|
||||
}
|
||||
// 检查每行的收款金额
|
||||
for (let i = 0; i < tableData.value.length; i++) {
|
||||
const item = tableData.value[i];
|
||||
if (!item.receiptPrice || item.receiptPrice <= 0) {
|
||||
throw new Error(`第 ${i + 1} 行:本次收款必须大于0`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
defineExpose({ validate });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Grid class="w-full">
|
||||
<template #receiptPrice="{ row }">
|
||||
<InputNumber
|
||||
v-model:value="row.receiptPrice"
|
||||
:precision="2"
|
||||
:disabled="disabled"
|
||||
:formatter="erpPriceInputFormatter"
|
||||
placeholder="请输入本次收款"
|
||||
@change="handleRowChange(row)"
|
||||
/>
|
||||
</template>
|
||||
<template #remark="{ row }">
|
||||
<Input
|
||||
v-model:value="row.remark"
|
||||
:disabled="disabled"
|
||||
placeholder="请输入备注"
|
||||
@change="handleRowChange(row)"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该收款明细吗?',
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #bottom>
|
||||
<div class="border-border bg-muted mt-2 rounded border p-2">
|
||||
<div class="text-muted-foreground flex justify-between text-sm">
|
||||
<span class="text-foreground font-medium">合计:</span>
|
||||
<div class="flex space-x-4">
|
||||
<span>
|
||||
合计收款:{{ erpPriceInputFormatter(summaries.totalPrice) }}
|
||||
</span>
|
||||
<span>
|
||||
已收金额:{{ erpPriceInputFormatter(summaries.receiptedPrice) }}
|
||||
</span>
|
||||
<span>
|
||||
本次收款:
|
||||
{{ erpPriceInputFormatter(summaries.receiptPrice) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
class="mt-2 flex justify-center"
|
||||
:actions="[
|
||||
{
|
||||
label: '添加销售出库单',
|
||||
type: 'default',
|
||||
onClick: handleOpenSaleOut,
|
||||
},
|
||||
{
|
||||
label: '添加销售退货单',
|
||||
type: 'default',
|
||||
onClick: handleOpenSaleReturn,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 销售出库单选择组件 -->
|
||||
<SaleOutSelect ref="saleOutSelectRef" @success="handleAddSaleOut" />
|
||||
<!-- 销售退货单选择组件 -->
|
||||
<SaleReturnSelect ref="saleReturnSelectRef" @success="handleAddSaleReturn" />
|
||||
</template>
|
||||
@@ -0,0 +1,108 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { ErpSaleOutApi } from '#/api/erp/sale/out';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getSaleOutPage } from '#/api/erp/sale/out';
|
||||
|
||||
import { useSaleOutGridColumns, useSaleOutGridFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{
|
||||
success: [rows: ErpSaleOutApi.SaleOut[]];
|
||||
}>();
|
||||
|
||||
const customerId = ref<number>(); // 客户ID
|
||||
const open = ref<boolean>(false); // 弹窗是否打开
|
||||
const selectedRows = ref<ErpSaleOutApi.SaleOut[]>([]); // 选中的行
|
||||
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useSaleOutGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useSaleOutGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSaleOutPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
customerId: customerId.value,
|
||||
receiptEnable: true, // 只查询可收款的
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
range: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<ErpSaleOutApi.SaleOut>,
|
||||
gridEvents: {
|
||||
checkboxChange: ({
|
||||
records,
|
||||
}: {
|
||||
records: ErpSaleOutApi.SaleOut[];
|
||||
}) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
checkboxAll: ({ records }: { records: ErpSaleOutApi.SaleOut[] }) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/** 打开弹窗 */
|
||||
const openModal = (id: number) => {
|
||||
// 重置数据
|
||||
customerId.value = id;
|
||||
open.value = true;
|
||||
selectedRows.value = [];
|
||||
// 查询列表
|
||||
gridApi.formApi?.resetForm();
|
||||
gridApi.formApi?.setValues({ customerId: id });
|
||||
gridApi.query();
|
||||
};
|
||||
|
||||
/** 确认选择销售出库单 */
|
||||
const handleOk = () => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
message.warning('请选择要添加的销售出库单');
|
||||
return;
|
||||
}
|
||||
emit('success', selectedRows.value);
|
||||
open.value = false;
|
||||
};
|
||||
|
||||
defineExpose({ open: openModal });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
class="!w-[50vw]"
|
||||
v-model:open="open"
|
||||
title="选择销售出库单"
|
||||
@ok="handleOk"
|
||||
>
|
||||
<Grid
|
||||
class="max-h-[600px]"
|
||||
table-title="销售出库单列表(仅展示可收款的单据)"
|
||||
/>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,108 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { ErpSaleReturnApi } from '#/api/erp/sale/return';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getSaleReturnPage } from '#/api/erp/sale/return';
|
||||
|
||||
import { useSaleReturnGridColumns, useSaleReturnGridFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{
|
||||
success: [rows: ErpSaleReturnApi.SaleReturn[]];
|
||||
}>();
|
||||
|
||||
const customerId = ref<number>(); // 客户ID
|
||||
const open = ref<boolean>(false); // 弹窗是否打开
|
||||
const selectedRows = ref<ErpSaleReturnApi.SaleReturn[]>([]); // 选中的行
|
||||
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useSaleReturnGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useSaleReturnGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSaleReturnPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
customerId: customerId.value,
|
||||
refundEnable: true, // 只查询可退款的
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
range: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<ErpSaleReturnApi.SaleReturn>,
|
||||
gridEvents: {
|
||||
checkboxChange: ({
|
||||
records,
|
||||
}: {
|
||||
records: ErpSaleReturnApi.SaleReturn[];
|
||||
}) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
checkboxAll: ({ records }: { records: ErpSaleReturnApi.SaleReturn[] }) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/** 打开弹窗 */
|
||||
const openModal = (id: number) => {
|
||||
// 重置数据
|
||||
customerId.value = id;
|
||||
open.value = true;
|
||||
selectedRows.value = [];
|
||||
// 查询列表
|
||||
gridApi.formApi?.resetForm();
|
||||
gridApi.formApi?.setValues({ customerId: id });
|
||||
gridApi.query();
|
||||
};
|
||||
|
||||
/** 确认选择销售退货单 */
|
||||
const handleOk = () => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
message.warning('请选择要添加的销售退货单');
|
||||
return;
|
||||
}
|
||||
emit('success', selectedRows.value);
|
||||
open.value = false;
|
||||
};
|
||||
|
||||
defineExpose({ open: openModal });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
class="!w-[50vw]"
|
||||
v-model:open="open"
|
||||
title="选择销售退货单"
|
||||
@ok="handleOk"
|
||||
>
|
||||
<Grid
|
||||
class="max-h-[600px]"
|
||||
table-title="销售退货单列表(仅展示可退款的单据)"
|
||||
/>
|
||||
</Modal>
|
||||
</template>
|
||||
Reference in New Issue
Block a user