This commit is contained in:
@@ -28,7 +28,7 @@ const planList = ref<RentalPlanVO[]>([]);
|
||||
const plantsList = ref<PropertyVO[]>([]);
|
||||
const planProducts = ref<any[]>([]);
|
||||
const totalAmount = ref(0);
|
||||
const singleAmount = ref(0);
|
||||
const singleAmount = ref('0');
|
||||
const plantInfo = ref<PropertyVO>();
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
@@ -141,7 +141,7 @@ const modalSchema = [
|
||||
formItemClass: 'col-span-2',
|
||||
componentProps: {
|
||||
api: async () => {
|
||||
const res = await plantsProductList({pageNum: 1, pageSize: 1000, inventory: 1});
|
||||
const res = await plantsProductList({pageNum: 1, pageSize: 1000, inventory: 0});
|
||||
plantsList.value = res.rows || [];
|
||||
return plantsList.value.map(item => ({
|
||||
label: item.plantName + '-' + item.plantCode + '\xa0\xa0租金(元):' + item.rent + '\xa0\xa0库存数量:' + item.inventory,
|
||||
@@ -151,10 +151,20 @@ const modalSchema = [
|
||||
onChange: async (value: string) => {
|
||||
plantInfo.value = plantsList.value.find(item => item.id === value);
|
||||
if (plantInfo.value) {
|
||||
const formValues = await formApi.getValues();
|
||||
if (formValues.productNum) {
|
||||
singleAmount.value = (plantInfo.value.rent * formValues.productNum).toFixed(2);
|
||||
}
|
||||
formApi.updateSchema([{
|
||||
componentProps: () => ({
|
||||
min: 1,
|
||||
max: plantInfo.value?.inventory,
|
||||
precision: 0,
|
||||
onChange:async ()=>{
|
||||
const formValues = await formApi.getValues();
|
||||
if (formValues.productNum&&plantInfo.value?.rent) {
|
||||
singleAmount.value = (plantInfo.value.rent * formValues.productNum).toFixed(2);
|
||||
}
|
||||
},
|
||||
}),
|
||||
fieldName: 'productNum',
|
||||
}])
|
||||
}
|
||||
},
|
||||
showSearch: true,
|
||||
@@ -172,6 +182,7 @@ const modalSchema = [
|
||||
step: 1,
|
||||
placeholder: '租赁数量不可超出绿植产品库存数量',
|
||||
onChange: async (value: number) => {
|
||||
console.log(value,'================vvvv')
|
||||
if (plantInfo.value) {
|
||||
singleAmount.value = (plantInfo.value.rent * value).toFixed(2);
|
||||
}
|
||||
@@ -313,7 +324,7 @@ async function handleConfirm() {
|
||||
data.startTime = data.rentalTime[0];
|
||||
data.endTime = data.rentalTime[1];
|
||||
}
|
||||
|
||||
data.paymentStatus=0
|
||||
await (isUpdate.value ? rentalOrderUpdate(data) : rentalOrderAdd(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
@@ -329,16 +340,6 @@ async function handleConfirm() {
|
||||
async function getPlanProducts(id: string) {
|
||||
const res = await rentalPlanInfo(id)
|
||||
plantsList.value=res.productList;
|
||||
// planProducts.value = [{
|
||||
// plantName: '发财树',
|
||||
// inventory: 3,
|
||||
// rent: 10,
|
||||
// }, {
|
||||
// plantName: '绿萝',
|
||||
// inventory: 5,
|
||||
// rent: 3,
|
||||
// }
|
||||
// ]
|
||||
totalAmount.value = planProducts.value?.reduce((sum, item: any) => sum + (item.rent * item.inventory), 0).toFixed(2)
|
||||
|
||||
}
|
||||
@@ -354,7 +355,7 @@ async function handleClosed() {
|
||||
<BasicModal :title="title">
|
||||
<BasicForm>
|
||||
<template #planInfo="slotProps">
|
||||
<div v-if="planProducts.length" style="width: 100%">
|
||||
<div v-if="planProducts.length" style="width: 100%" v-bind="slotProps">
|
||||
<Table :dataSource="planProducts" :columns="planInfoColumns" :pagination="false"
|
||||
bordered size="small">
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
@@ -375,7 +376,7 @@ async function handleClosed() {
|
||||
</div>
|
||||
</template>
|
||||
<template #totalAmount="slotProps">
|
||||
<div>{{ singleAmount }}</div>
|
||||
<div v-bind="slotProps">{{ singleAmount }}</div>
|
||||
</template>
|
||||
</BasicForm>
|
||||
</BasicModal>
|
||||
|
Reference in New Issue
Block a user