feat:【antd】【erp 系统】sale/order 部分代码优化(form 基本完善)
This commit is contained in:
@@ -330,7 +330,15 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
// TODO @AI:备注缺少;/Users/yunai/Java/yudao-ui-admin-vue3/src/views/erp/sale/order/index.vue
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'outStatus',
|
||||
label: '出库状态',
|
||||
|
||||
@@ -66,20 +66,21 @@ async function handleDelete(ids: number[]) {
|
||||
}
|
||||
|
||||
/** 审批/反审批操作 */
|
||||
function handleUpdateStatus(row: ErpSaleOrderApi.SaleOrder, status: number) {
|
||||
async function handleUpdateStatus(
|
||||
row: ErpSaleOrderApi.SaleOrder,
|
||||
status: number,
|
||||
) {
|
||||
const hideLoading = message.loading({
|
||||
content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`,
|
||||
duration: 0,
|
||||
});
|
||||
// TODO @AI:改成 await 写法
|
||||
updateSaleOrderStatus(row.id!, status)
|
||||
.then(() => {
|
||||
message.success(`${status === 20 ? '审批' : '反审批'}成功`);
|
||||
handleRefresh();
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoading();
|
||||
});
|
||||
try {
|
||||
await updateSaleOrderStatus(row.id!, status);
|
||||
message.success(`${status === 20 ? '审批' : '反审批'}成功`);
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
|
||||
@@ -17,6 +17,7 @@ import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import ItemForm from './item-form.vue';
|
||||
import {getAccountSimpleList} from '#/api/erp/finance/account';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<ErpSaleOrderApi.SaleOrder>();
|
||||
@@ -38,7 +39,6 @@ const [Form, formApi] = useVbenForm({
|
||||
class: 'w-full',
|
||||
},
|
||||
labelWidth: 120,
|
||||
// disabled: !['create', 'edit'].includes(formType.value), // TODO @芋艿:这里晚点处理下;
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'vertical',
|
||||
@@ -116,7 +116,14 @@ const [Modal, modalApi] = useVbenModal({
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
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();
|
||||
@@ -124,7 +131,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
formData.value = await getSaleOrder(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
// TODO @AI:默认账户;缺少;
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
@@ -134,19 +140,14 @@ const [Modal, modalApi] = useVbenModal({
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
v-bind="$attrs"
|
||||
:title="getTitle"
|
||||
class="w-3/4"
|
||||
:closable="true"
|
||||
:mask-closable="true"
|
||||
:show-confirm-button="formType !== 'detail'"
|
||||
>
|
||||
<Form class="mx-3">
|
||||
<template #items="slotProps">
|
||||
<template #items>
|
||||
<ItemForm
|
||||
v-bind="slotProps"
|
||||
ref="itemFormRef"
|
||||
class="w-full"
|
||||
:items="formData?.items ?? []"
|
||||
:disabled="formType === 'detail'"
|
||||
:discount-percent="formData?.discountPercent ?? 0"
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
import type { ErpProductApi } from '#/api/erp/product/product';
|
||||
import type { ErpSaleOrderApi } from '#/api/erp/sale/order';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { erpPriceMultiply } from '@vben/utils';
|
||||
import {
|
||||
erpCountInputFormatter,
|
||||
erpPriceInputFormatter,
|
||||
erpPriceMultiply,
|
||||
} from '@vben/utils';
|
||||
|
||||
import { Input, InputNumber, Select } from 'ant-design-vue';
|
||||
|
||||
@@ -84,6 +88,7 @@ watch(
|
||||
}
|
||||
items.forEach((item) => initRow(item));
|
||||
tableData.value = [...items];
|
||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||
await gridApi.grid.reloadData(tableData.value);
|
||||
},
|
||||
{
|
||||
@@ -274,10 +279,14 @@ onMounted(async () => {
|
||||
<div class="text-muted-foreground flex justify-between text-sm">
|
||||
<span class="text-foreground font-medium">合计:</span>
|
||||
<div class="flex space-x-4">
|
||||
<span>数量:{{ summaries.count }}</span>
|
||||
<span>金额:{{ summaries.totalProductPrice }}</span>
|
||||
<span>税额:{{ summaries.taxPrice }}</span>
|
||||
<span>税额合计:{{ summaries.totalPrice }}</span>
|
||||
<span>数量:{{ erpCountInputFormatter(summaries.count) }}</span>
|
||||
<span>
|
||||
金额:{{ erpPriceInputFormatter(summaries.totalProductPrice) }}
|
||||
</span>
|
||||
<span>税额:{{ erpPriceInputFormatter(summaries.taxPrice) }}</span>
|
||||
<span>
|
||||
税额合计:{{ erpPriceInputFormatter(summaries.totalPrice) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user