feat: 更新业务需求

This commit is contained in:
fyy
2025-09-12 19:27:04 +08:00
parent d072976e6d
commit f1baed0332
8 changed files with 320 additions and 125 deletions

View File

@@ -1,13 +1,21 @@
<script setup lang="ts">
import {computed, reactive, ref} from 'vue';
import { computed, reactive, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { orderChargeAdd, orderChargeInfo, orderChargeUpdate } from '#/api/property/chargeManagement';
import {
orderChargeAdd,
orderChargeInfo,
orderChargeUpdate,
} from '#/api/property/chargeManagement';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
import QueryUserList from "#/views/property/greenPlantRentalManagement/chargeManagement/query-user-list.vue";
// import { modalSchema } from './data';
import QueryUserList from '#/views/property/greenPlantRentalManagement/chargeManagement/query-user-list.vue';
import { resident_unitList } from '#/api/property/resident/unit';
import type { FormSchemaGetter } from '#/adapter/form';
import { rentalNotSelectList } from '#/api/property/rentalOrder';
import { getDictOptions } from '#/utils/dict';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
@@ -15,16 +23,167 @@ const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : '添加收费';
});
const modalSchema = [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '订单号',
fieldName: 'orderId',
component: 'ApiSelect',
componentProps: {
api: rentalNotSelectList,
resultField: 'rows',
labelField: 'orderNo',
valueField: 'id',
onChange: async (value: string, option: any) => {
await formApi.setValues({
residentUnitId: option.residentUnitId, // 假设订单数据中有 residentUnitId 字段
// 其他需要自动填充的字段
});
},
},
disabled: isUpdate.value ? true : false,
rules: 'required',
},
{
component: 'ApiSelect',
fieldName: 'residentUnitId',
label: '租赁单位',
componentProps: () => ({
api: getUnitList,
resultField: 'data',
labelField: 'label',
valueField: 'value',
immediate: true,
debounceTime: 500,
allowClear: true,
placeholder: '',
filterOption: true,
}),
rules: 'selectRequired',
disabled: true,
},
{
label: '租赁人',
fieldName: 'userName',
component: 'Select',
rules: 'selectRequired',
},
{
label: '租金',
fieldName: 'rent',
component: 'InputNumber',
rules: 'required',
componentProps: {
precision: 2,
},
},
{
label: '押金',
fieldName: 'deposit',
component: 'InputNumber',
rules: 'required',
componentProps: {
precision: 2,
},
},
{
label: '违约金',
fieldName: 'penalty',
component: 'InputNumber',
rules: 'required',
componentProps: {
precision: 2,
},
},
// {
// label: '总金额',
// fieldName: 'totalAmount',
// component: 'Input',
// rules: 'required',
// },
{
label: '开票状态',
fieldName: 'invoiceStatus',
component: 'Select',
componentProps: {
options: getDictOptions('pro_invoice_status'),
},
rules: 'selectRequired',
},
{
label: '发票类型',
fieldName: 'invoiceType',
component: 'Select',
componentProps: {
options: getDictOptions('pro_invoice_type'),
},
rules: 'selectRequired',
},
{
label: '收费状态',
fieldName: 'chargeStatus',
component: 'Select',
componentProps: {
options: getDictOptions('pro_charging_status'),
},
rules: 'selectRequired',
},
{
label: '支付方式',
fieldName: 'paymentMethod',
component: 'Select',
componentProps: {
options: getDictOptions('pro_payment_method'),
},
rules: 'selectRequired',
},
{
label: '收费日期',
fieldName: 'chargeDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
];
async function getUnitList() {
const queryParam = {
pageNum: 1,
pageSize: 1000,
};
const res = await resident_unitList(queryParam);
const data: { value: number; label: string }[] = [];
res.rows.forEach((r: any) => {
data.push({
value: r.id,
label: r.name,
});
});
return data;
}
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
formItemClass: 'col-span-1',
labelWidth: 80,
componentProps: {
class: 'w-full',
}
},
},
schema: modalSchema(),
schema: modalSchema,
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
@@ -55,6 +214,8 @@ const [BasicModal, modalApi] = useVbenModal({
record.paymentMethod = record.paymentMethod?.toString();
record.invoiceType = record.invoiceType?.toString();
record.invoiceStatus = record.invoiceStatus?.toString();
record.orderId = record.orderId;
record.residentUnitId = record.residentUnitId;
await formApi.setValues(record);
}
await markInitialized();
@@ -71,8 +232,8 @@ async function handleConfirm() {
}
const data = cloneDeep(await formApi.getValues());
if (userInfo) {
data.userId = userInfo.userId
data.userName = userInfo.userName
data.userId = userInfo.userId;
data.userName = userInfo.userName;
}
await (isUpdate.value ? orderChargeUpdate(data) : orderChargeAdd(data));
resetInitialized();
@@ -102,9 +263,13 @@ async function handleClosed() {
<BasicModal :title="title">
<BasicForm>
<template #userName="slotProps">
<QueryUserList @update:userInfo="getUserInfo" v-bind="slotProps" :isUpdate="isUpdate" :userName="userName"/>
<QueryUserList
@update:userInfo="getUserInfo"
v-bind="slotProps"
:isUpdate="isUpdate"
:userName="userName"
/>
</template>
</BasicForm>
</BasicModal>
</template>