feat:【antd】【erp 系统】purchase/in 重构 4/4

This commit is contained in:
YunaiV
2025-10-04 20:37:30 +08:00
parent f7c0b41199
commit ff2f176917
5 changed files with 86 additions and 70 deletions

View File

@@ -189,7 +189,6 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
component: 'ApiSelect', component: 'ApiSelect',
componentProps: { componentProps: {
placeholder: '请选择结算账户', placeholder: '请选择结算账户',
disabled: true,
allowClear: true, allowClear: true,
showSearch: true, showSearch: true,
api: getAccountSimpleList, api: getAccountSimpleList,
@@ -414,6 +413,21 @@ export function useGridFormSchema(): VbenFormSchema[] {
allowClear: true, allowClear: true,
}, },
}, },
{
fieldName: 'accountId',
label: '结算账户',
component: 'ApiSelect',
componentProps: {
placeholder: '请选择结算账户',
allowClear: true,
showSearch: true,
api: getAccountSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
},
},
{ {
fieldName: 'paymentStatus', fieldName: 'paymentStatus',
label: '付款状态', label: '付款状态',

View File

@@ -66,7 +66,10 @@ async function handleDelete(ids: number[]) {
} }
/** 审批/反审批操作 */ /** 审批/反审批操作 */
async function handleUpdateStatus(row: ErpPurchaseInApi.PurchaseIn, status: number) { async function handleUpdateStatus(
row: ErpPurchaseInApi.PurchaseIn,
status: number,
) {
const hideLoading = message.loading({ const hideLoading = message.loading({
content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`, content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`,
duration: 0, duration: 0,

View File

@@ -10,6 +10,7 @@ import { $t } from '@vben/locales';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { import {
createPurchaseIn, createPurchaseIn,
getPurchaseIn, getPurchaseIn,
@@ -178,6 +179,12 @@ const [Modal, modalApi] = useVbenModal({
formApi.setDisabled(formType.value === 'detail'); formApi.setDisabled(formType.value === 'detail');
formApi.updateSchema(useFormSchema(formType.value)); formApi.updateSchema(useFormSchema(formType.value));
if (!data || !data.id) { if (!data || !data.id) {
// 新增时,默认选中账户
const accountList = await getAccountSimpleList();
const defaultAccount = accountList.find((item) => item.defaultStatus);
if (defaultAccount) {
await formApi.setValues({ accountId: defaultAccount.id });
}
return; return;
} }
modalApi.lock(); modalApi.lock();

View File

@@ -1,55 +0,0 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getPurchaseOrderPage } from '#/api/erp/purchase/order';
import { useOrderGridColumns, useOrderGridFormSchema } from '../data';
const emit = defineEmits(['selectRow']);
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: useOrderGridFormSchema(),
},
gridOptions: {
columns: useOrderGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getPurchaseOrderPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
inEnable: true,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
radioConfig: {
trigger: 'row',
highlight: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<ErpPurchaseOrderApi.PurchaseOrder>,
gridEvents: {
radioChange: ({ row }: { row: ErpPurchaseOrderApi.PurchaseOrder }) => {
emit('selectRow', row);
},
},
});
</script>
<template>
<Grid class="max-h-[600px]" table-title="采购订单列表(仅展示可入库)" />
</template>

View File

@@ -1,4 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order'; import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
import { ref } from 'vue'; import { ref } from 'vue';
@@ -7,9 +8,12 @@ import { IconifyIcon } from '@vben/icons';
import { Input, message, Modal } from 'ant-design-vue'; import { Input, message, Modal } from 'ant-design-vue';
import SelectPurchaseOrderGrid from './purchase-order-select-grid.vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getPurchaseOrderPage } from '#/api/erp/purchase/order';
const props = defineProps({ import { useOrderGridColumns, useOrderGridFormSchema } from '../data';
defineProps({
orderNo: { orderNo: {
type: String, type: String,
default: () => undefined, default: () => undefined,
@@ -19,16 +23,61 @@ const props = defineProps({
default: false, default: false,
}, },
}); });
const emit = defineEmits<{ const emit = defineEmits<{
'update:order': [order: ErpPurchaseOrderApi.PurchaseOrder]; 'update:order': [order: ErpPurchaseOrderApi.PurchaseOrder];
}>(); }>();
const order = ref<ErpPurchaseOrderApi.PurchaseOrder>();
const open = ref<boolean>(false);
const handleSelectOrder = (selectOrder: ErpPurchaseOrderApi.PurchaseOrder) => { const order = ref<ErpPurchaseOrderApi.PurchaseOrder>(); // 选择的采购订单
const open = ref<boolean>(false); // 选择采购订单弹窗是否打开
/** 表格配置 */
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: useOrderGridFormSchema(),
},
gridOptions: {
columns: useOrderGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getPurchaseOrderPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
returnEnable: true,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
radioConfig: {
trigger: 'row',
highlight: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<ErpPurchaseOrderApi.PurchaseOrder>,
gridEvents: {
radioChange: ({ row }: { row: ErpPurchaseOrderApi.PurchaseOrder }) => {
handleSelectOrder(row);
},
},
});
/** 选择采购订单 */
function handleSelectOrder(selectOrder: ErpPurchaseOrderApi.PurchaseOrder) {
order.value = selectOrder; order.value = selectOrder;
}; }
/** 确认选择采购订单 */
const handleOk = () => { const handleOk = () => {
if (!order.value) { if (!order.value) {
message.warning('请选择一个采购订单'); message.warning('请选择一个采购订单');
@@ -41,7 +90,6 @@ const handleOk = () => {
<template> <template>
<Input <Input
v-bind="$attrs"
readonly readonly
:value="orderNo" :value="orderNo"
:disabled="disabled" :disabled="disabled"
@@ -52,19 +100,18 @@ const handleOk = () => {
<IconifyIcon <IconifyIcon
class="h-full w-6 cursor-pointer" class="h-full w-6 cursor-pointer"
icon="ant-design:setting-outlined" icon="ant-design:setting-outlined"
:style="{ cursor: props.disabled ? 'not-allowed' : 'pointer' }" :style="{ cursor: disabled ? 'not-allowed' : 'pointer' }"
@click="() => !props.disabled && (open = true)" @click="() => !disabled && (open = true)"
/> />
</div> </div>
</template> </template>
</Input> </Input>
<Modal <Modal
class="!w-[50vw]"
v-model:open="open" v-model:open="open"
title="选择关联订单" title="选择关联订单"
class="!w-[50vw]"
:show-confirm-button="true"
@ok="handleOk" @ok="handleOk"
> >
<SelectPurchaseOrderGrid @select-row="handleSelectOrder" /> <Grid class="max-h-[600px]" table-title="采购订单列表(仅展示可退货)" />
</Modal> </Modal>
</template> </template>