1、租赁订单
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
dev_ljl 2025-07-04 17:58:09 +08:00
parent e28ddabf57
commit 0d5b964596
3 changed files with 94 additions and 205 deletions

View File

@ -149,170 +149,29 @@ export const columns: VxeGridProps['columns'] = [
}, },
]; ];
export const modalSchema: FormSchemaGetter = () => [ export const planInfoColumns: VxeGridProps['columns'] = [
{ {
label: '主键', title: '序号',
fieldName: 'id', field: 'id',
component: 'Input', width: 100,
dependencies: { align: 'center'
show: () => false,
triggerFields: [''],
},
}, },
{ {
label: '客户名称', title: '产品名称',
fieldName: 'customerName', field: 'plantName',
component: 'Input', minWidth: 100,
rules: 'required', align: 'center'
}, },
{ {
label: '客户类型', title: '产品租金',
fieldName: 'customerType', field: 'rent',
component: 'Select', minWidth: 100,
componentProps: { align: 'center'
options: getDictOptions('wy_khlx')
},
rules: 'selectRequired',
}, },
{ {
label: '租赁周期', title: '产品数量',
fieldName: 'rentalPeriod', field: 'inventory',
component: 'Select', minWidth: 100,
componentProps: { align: 'center'
options: getDictOptions('wy_time_unit')
},
rules: 'selectRequired',
}, },
{ ]
label: '租赁时间',
fieldName: 'rentalTime',
component: 'RangePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
},
rules: 'selectRequired',
},
{
label: '租赁方式',
fieldName: 'rentalType',
component: 'Select',
componentProps: {
options: getDictOptions('wy_zlfs')
},
rules: 'selectRequired',
formItemClass: 'col-span-2'
},
{
label: '租赁方案',
fieldName: 'planId',
component: 'Select',
dependencies: {
// 仅当 租赁方式 为 2套餐 时显示
show: (formValues) => formValues.rentalType === '2',
triggerFields: ['rentalType'],
},
rules: 'selectRequired',
formItemClass: 'col-span-2'
},
{
label: '方案详情',
fieldName: 'planInfo',
component: 'Input',
dependencies: {
// 仅当 租赁方式 为 2套餐 时显示
show: (formValues) => formValues.rentalType === '2' && formValues.planId != null,
triggerFields: ['rentalType'],
},
formItemClass: 'col-span-2'
},
{
label: '绿植产品',
fieldName: 'productId',
component: 'Select',
dependencies: {
// 仅当 租赁方式 为 1单点 时显示
show: (formValues) => formValues.rentalType === '1',
triggerFields: ['rentalType'],
},
rules: 'selectRequired',
formItemClass: 'col-span-2'
},
{
label: '租赁数量',
fieldName: 'productNum',
component: 'InputNumber',
componentProps: {
min: 1,
precision: 0,
step: 1,
placeholder:'租赁数量不可超出绿植产品库存数量'
},
dependencies: {
// 仅当 租赁方式 为 1单点 时显示
show: (formValues) => formValues.rentalType === '1',
triggerFields: ['rentalType', 'productId'],
},
rules: 'required',
},
// {
// label: '应付总额',
// fieldName: 'totalAmount',
// component: 'Input',
// rules: 'required',
// },
// {
// label: '支付状态',
// fieldName: 'paymentStatus',
// component: 'Select',
// componentProps: {
// options: getDictOptions('pro_charging_status'),
// },
// rules: 'selectRequired',
// },
// {
// label: '是否续租',
// fieldName: 'isRelet',
// component: 'RadioGroup',
// componentProps: {
// buttonStyle: 'solid',
// optionType: 'button',
// options: getDictOptions('wy_sf'),
// },
// },
{
label: '合同状态',
fieldName: 'contractStatus',
component: 'Select',
componentProps: {
options: getDictOptions('wy_htzt'),
},
rules: 'selectRequired'
},
{
label: '合同编号',
fieldName: 'contractCode',
component: 'Input',
dependencies: {
show: (formValues) => formValues.contractStatus != null && formValues.contractStatus != 1,
triggerFields: ['contractStatus'],
},
rules: 'required'
},
{
label: '签署时间',
fieldName: 'signTime',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
},
dependencies: {
show: (formValues) => formValues.contractStatus != null && formValues.contractStatus != 1,
triggerFields: ['contractStatus'],
},
rules: 'required'
},
];

View File

@ -89,10 +89,10 @@ function handleAdd() {
modalApi.open(); modalApi.open();
} }
async function handleEdit(row: Required<RentalOrderForm>) { // async function handleEdit(row: Required<RentalOrderForm>) {
modalApi.setData({ id: row.id }); // modalApi.setData({ id: row.id });
modalApi.open(); // modalApi.open();
} // }
async function handleDelete(row: Required<RentalOrderForm>) { async function handleDelete(row: Required<RentalOrderForm>) {
await rentalOrderRemove(row.id); await rentalOrderRemove(row.id);

View File

@ -18,12 +18,18 @@ import {rentalPlanInfo, rentalPlanList} from "#/api/property/rentalPlan";
import {getDictOptions} from "#/utils/dict"; import {getDictOptions} from "#/utils/dict";
import type {PropertyVO} from "#/api/property/productManagement/model"; import type {PropertyVO} from "#/api/property/productManagement/model";
import type {RentalPlanVO} from "#/api/property/rentalPlan/model"; import type {RentalPlanVO} from "#/api/property/rentalPlan/model";
import {planInfoColumns} from './data';
import {Table} from "ant-design-vue";
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false); const isUpdate = ref(false);
const planList = ref<RentalPlanVO[]>([]); const planList = ref<RentalPlanVO[]>([]);
const plantsList = ref<PropertyVO[]>([]); const plantsList = ref<PropertyVO[]>([]);
const planProducts = ref<any[]>([]);
const totalAmount = ref(0);
const singleAmount = ref(0);
const plantInfo = ref<PropertyVO>();
const title = computed(() => { const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add'); return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
}); });
@ -104,7 +110,6 @@ const modalSchema = [
}, },
onChange: async (value: string) => { onChange: async (value: string) => {
await getPlanProducts(value) await getPlanProducts(value)
// const plan= planList.value.find(item => item.id === value);
}, },
showSearch: true, showSearch: true,
filterOption: (input: any, option: any) => filterOption: (input: any, option: any) =>
@ -114,7 +119,8 @@ const modalSchema = [
{ {
label: '方案详情', label: '方案详情',
fieldName: 'planInfo', fieldName: 'planInfo',
component: 'Text', component: 'Input',
slots: {default: 'planInfo'},
dependencies: { dependencies: {
// 2 // 2
show: (formValues: any) => formValues.rentalType === '2' && formValues.planId != null, show: (formValues: any) => formValues.rentalType === '2' && formValues.planId != null,
@ -143,22 +149,12 @@ const modalSchema = [
})); }));
}, },
onChange: async (value: string) => { onChange: async (value: string) => {
const plants = plantsList.value.find(item => item.id === value); plantInfo.value = plantsList.value.find(item => item.id === value);
if (plants) { if (plantInfo.value) {
formApi.updateSchema([{ const formValues = await formApi.getValues();
componentProps: () => ({ if (formValues.productNum) {
min: 1, singleAmount.value = (plantInfo.value.rent * formValues.productNum).toFixed(2);
max: plants.inventory, }
precision: 0,
}),
fieldName: 'productNum',
}])
}
const formValues = await formApi.getValues();
if(formValues.productNum){
await formApi.setValues({
totalAmount: plants.rent*formValues.productNum,
});
} }
}, },
showSearch: true, showSearch: true,
@ -174,7 +170,12 @@ const modalSchema = [
min: 1, min: 1,
precision: 0, precision: 0,
step: 1, step: 1,
placeholder: '租赁数量不可超出绿植产品库存数量' placeholder: '租赁数量不可超出绿植产品库存数量',
onChange: async (value: number) => {
if (plantInfo.value) {
singleAmount.value = (plantInfo.value.rent * value).toFixed(2);
}
},
}, },
dependencies: { dependencies: {
// 1 // 1
@ -184,20 +185,17 @@ const modalSchema = [
rules: 'required', rules: 'required',
}, },
{ {
label: '应付总额', label: '(元)',
fieldName: 'totalAmount', fieldName: 'totalAmount',
component: 'InputNumber', component: 'InputNumber',
slots: {default: 'totalAmount'},
dependencies: { dependencies: {
// 1 // 1
show: (formValues: any) => formValues.totalAmount, show: (formValues: any) => formValues.productNum&&formValues.productId&&formValues.rentalType === '1',
triggerFields: ['totalAmount'], triggerFields: ['productNum','rentalType'],
disabled:true, disabled: true,
},
componentProps: {
addonAfter: '元',
precision: 2,
stringMode: true,
}, },
labelWidth: 110
}, },
{ {
label: '是否续租', label: '是否续租',
@ -304,14 +302,18 @@ async function handleConfirm() {
const data = cloneDeep(await formApi.getValues()); const data = cloneDeep(await formApi.getValues());
if (data.rentalType == 1) { if (data.rentalType == 1) {
data.planId = undefined; data.planId = undefined;
data.totalAmount = singleAmount.value
} else { } else {
data.productId = undefined; data.productId = undefined;
data.productNum = undefined; data.productNum = undefined;
data.productList = plantsList.value
data.totalAmount = totalAmount.value
} }
if(data.rentalTime){ if (data.rentalTime) {
data.startTime=data.rentalTime[0]; data.startTime = data.rentalTime[0];
data.endTime=data.rentalTime[1]; data.endTime = data.rentalTime[1];
} }
await (isUpdate.value ? rentalOrderUpdate(data) : rentalOrderAdd(data)); await (isUpdate.value ? rentalOrderUpdate(data) : rentalOrderAdd(data));
resetInitialized(); resetInitialized();
emit('reload'); emit('reload');
@ -326,16 +328,19 @@ async function handleConfirm() {
//绿 //绿
async function getPlanProducts(id: string) { async function getPlanProducts(id: string) {
const res = await rentalPlanInfo(id) const res = await rentalPlanInfo(id)
if (res.productList) { plantsList.value=res.productList;
} // planProducts.value = [{
formApi.updateSchema([{ // plantName: '',
fieldName: 'planInfo', // inventory: 3,
componentProps: { // rent: 10,
isHtml: true, // }, {
value: '<div>222222222222222222</div>' // plantName: '绿',
}, // inventory: 5,
}, // rent: 3,
]); // }
// ]
totalAmount.value = planProducts.value?.reduce((sum, item: any) => sum + (item.rent * item.inventory), 0).toFixed(2)
} }
async function handleClosed() { async function handleClosed() {
@ -347,7 +352,32 @@ async function handleClosed() {
<template> <template>
<BasicModal :title="title"> <BasicModal :title="title">
<BasicForm/> <BasicForm>
<template #planInfo="slotProps">
<div v-if="planProducts.length" style="width: 100%">
<Table :dataSource="planProducts" :columns="planInfoColumns" :pagination="false"
bordered size="small">
<template #bodyCell="{ column, record, index }">
<template v-if="column.field === 'id'">
{{ index + 1 }}
</template>
<template v-else>
{{ record[column.field] }}
</template>
</template>
<template #footer>
<div style="text-align: right;margin-right: 20px">
<b>总金额</b>
{{ totalAmount }}
</div>
</template>
</Table>
</div>
</template>
<template #totalAmount="slotProps">
<div>{{ singleAmount }}</div>
</template>
</BasicForm>
</BasicModal> </BasicModal>
</template> </template>