feat: 绿植租赁方案对接完成

This commit is contained in:
fyy 2025-07-02 14:42:17 +08:00
parent f84c4037fb
commit d3033eb12d
7 changed files with 58 additions and 52 deletions

View File

@ -35,14 +35,17 @@ export interface RentalPlanVO {
*
*/
remarks: string;
/**
* 绿
*/
productList: any[];
}
export interface RentalPlanForm extends BaseEntity {
/**
*
*/
id?: string | number;
id?: string | number | undefined;
/**
*

View File

@ -31,6 +31,7 @@ const detailSchema = [
fieldName: 'name',
component: 'ApiSelect',
componentProps: {
disabled: isView,
api: async () => {
const res = await cleanList({stater:1});
cleanListData = res.rows || [];
@ -64,6 +65,7 @@ const detailSchema = [
component: 'InputNumber',
rules: 'required',
componentProps: {
disabled: isView,
onChange: async (value: number) => {
const formValues = await formApi.getValues();
if (formValues.peices && value) {
@ -182,8 +184,7 @@ const [BasicModal, modalApi] = useVbenModal({
if(!data || Object.keys(data).length === 0){
//modalApi.getData()
isAdd.value = true;
}else if(detailIndex.value == undefined || detailIndex.value == null){
//detailIndex.value
}else if(data.readonly){
isView.value = true;
}else{
//
@ -203,22 +204,21 @@ async function handleConfirm() {
if (!valid) {
return;
}
const data = cloneDeep(await formApi.getValues());
console.log(data);
let data = cloneDeep(await formApi.getValues());
//
const selectedService = cleanListData.find(item => item.id === data.name);
if (selectedService) {
data.name = selectedService.name;
data.id = selectedService.id
}
//index>=0
if (detailIndex.value! >= 0) {
if (isUpdate.value) {
data.index = detailIndex.value;
emit('editReload', data);
}else if(isAdd.value){
emit('reload', data);
}
handleClosed()
await markInitialized();
emit('reload', data);
modalApi.close();
} catch (error) {
console.error(error);

View File

@ -275,11 +275,16 @@ function handleAddDetail() {
}
//
function handleDetailReload(data: any) {
console.log(data,'afawed');
detailTable.value.push(data);
}
//
function handleEditDetailReload(data: any) {
console.log(data,'1203342423');
detailTable.value[data.index] = data;
}
//
function handleDeleteDetail(record: any, index: number) {

View File

@ -54,6 +54,9 @@ export const columns: VxeGridProps['columns'] = [
{
title: '租赁周期',
field: 'rentalPeriod',
slots: {
default: 'rentalPeriod'
},
},
{
title: '适用场景',
@ -124,16 +127,7 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Select',
componentProps: {
// 可选从DictEnum中获取 DictEnum.WY_KG 便于维护
options: [
{
label: '待支付',
value: 0,
},
{
label: '已支付',
value: 1,
},
],
options: getDictOptions('wy_kg'),
},
rules: 'selectRequired',
},

View File

@ -103,7 +103,7 @@ async function handleDelete(row: Required<RentalPlanForm>) {
await tableApi.query();
}
async function handleView(row: Required<RentalPlanForm>) {
modalApi.setData({ id: row.id, readonly: true,ab:"wegqw" });
modalApi.setData({ id: row.id, readonly: true,});
modalApi.open();
}
function handleMultiDelete() {
@ -156,10 +156,14 @@ function handleDownloadExcel() {
</a-button>
</Space>
</template>
<template #rentalPeriod="{ row }">
<div>
{{ row.rentalPeriod == 0?'月':row.rentalPeriod == 1 ? '季度':'年' }}
</div>
</template>
<template #state="{ row }">
<Tag v-if="row.state === 0" color="error">禁用</Tag>
<Tag v-else-if="row.state === 1" color="success">启用</Tag>
<Tag v-else color="default">未审核</Tag>
<Tag v-if="row.state == 0" color="error">禁用</Tag>
<Tag v-else-if="row.state == 1" color="success">启用</Tag>
</template>
<template #action="{ row }">
<Space>

View File

@ -6,7 +6,7 @@ import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { plantsProductList } from '#/api/property/productManagement';
import { getDictOptions } from '#/utils/dict';
const emit = defineEmits<{ reload: [data: any], editReload: [data: any] }>();
const isUpdate = ref(false);
@ -31,6 +31,7 @@ const detailSchema = [
fieldName: 'plantName',
component: 'ApiSelect',
componentProps: {
disabled: isView,
api: async () => {
const res = await plantsProductList({inventory:0});
plantListData = res.rows || [];
@ -40,12 +41,8 @@ const detailSchema = [
labelField: 'plantName',
valueField: 'id',
onChange: async (value: string) => {
console.log(value);
//
const selectedService = plantListData.find(item => item.id === value);
console.log(selectedService,'1203');
if (selectedService) {
//
await formApi.setValues({
@ -74,11 +71,11 @@ const detailSchema = [
{
label: '产品分类',
fieldName: 'plantType',
component: 'Input',
component: 'Select',
componentProps: {
disabled: true,
options: getDictOptions('pro_product_classification'),
},
rules: 'required',
},
{
label: '图片',
@ -114,8 +111,8 @@ const detailSchema = [
componentProps: {
disabled: true,
options: [
{ label: '上架', value: 1 },
{ label: '下架', value: 0 },
{ label: '上架', value: '1' },
{ label: '下架', value: '0' },
],
},
rules: 'required',
@ -162,7 +159,7 @@ const [BasicModal, modalApi] = useVbenModal({
if(!data || Object.keys(data).length === 0){
//modalApi.getData()
isAdd.value = true;
}else if(detailIndex.value == undefined || detailIndex.value == null){
}else if(data.readonly){
//detailIndex.value
isView.value = true;
}else{
@ -184,24 +181,20 @@ async function handleConfirm() {
return;
}
const data = cloneDeep(await formApi.getValues());
console.log(data);
//
const selectedService = plantListData.find(item => item.id === data.plantName);
console.log(selectedService,'selectedService');
if (selectedService) {
data.plantName = selectedService.plantName;
data.id = selectedService.id
}
//index>=0
if (detailIndex.value! >= 0) {
if (isUpdate.value) {
data.index = detailIndex.value;
emit('editReload', data);
}else if(isAdd.value){
emit('reload', data);
}
handleClosed()
await markInitialized();
console.log(data);
emit('reload', data);
modalApi.close();
} catch (error) {
console.error(error);

View File

@ -11,6 +11,8 @@ import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
import productDetailModal from './rentalPlan-detial-modal.vue';
import { getDictOptions } from '#/utils/dict';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
@ -18,7 +20,7 @@ const isReadonly = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : isReadonly.value ? '详情' : $t('pages.common.add');
});
const editId = ref<string | number | undefined>('')
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
//
@ -54,12 +56,9 @@ const [BasicModal, modalApi] = useVbenModal({
if (!isOpen) {
return null;
}
console.log(isOpen);
modalApi.modalLoading(true);
console.log(modalApi.getData(),'====================');
const { id, readonly } = modalApi.getData() as { id?: number | string, readonly?: boolean; };
editId.value = id || '';
isReadonly.value = !!readonly;
if(isReadonly.value){
isUpdate.value = false;
@ -69,6 +68,8 @@ const [BasicModal, modalApi] = useVbenModal({
//
if ((isUpdate.value || isReadonly.value) && id) {
const record = await rentalPlanInfo(id);
// 绿
detailTable.value = record.productList.map((item:any) => item.product);
await formApi.setValues(record);
}
await markInitialized();
@ -87,11 +88,8 @@ async function handleConfirm() {
}
// getValuesreadonly
const data = cloneDeep(await formApi.getValues());
console.log(data);
console.log(detailTable.value);
data.productIds = detailTable.value.map((item:any) => item.id);
await (isUpdate.value ? rentalPlanUpdate(data) : rentalPlanAdd(data));
await (isUpdate.value ? rentalPlanUpdate({...data,id:editId.value}) : rentalPlanAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
@ -168,6 +166,12 @@ function handleEditDetail(record: any, index: number) {
detailModalApi.setData({ ...record, index, readonly: false });
detailModalApi.open();
}
//
function getPlantTypeLabel(value: string | number) {
const opts = getDictOptions('pro_product_classification');
const found = opts.find(opt => opt.value == value);
return found ? found.label : value;
}
</script>
<template>
@ -190,9 +194,12 @@ function handleEditDetail(record: any, index: number) {
<template v-if="column.key === 'index'">
{{ index + 1 }}
</template>
<template v-else-if="column.key === 'plantType'">
<div>{{getPlantTypeLabel(record.plantType)}}</div>
</template>
<template v-else-if="column.key === 'action'">
<template v-if="isReadonly">
<Button @click="handleViewDetail(record)">查看</Button>
<Button type="primary" size="small" style="margin-right: 5px;" @click="handleViewDetail(record)">查看</Button>
</template>
<template v-else >
<Button type="primary" size="small" style="margin-right: 5px;" @click="handleViewDetail(record)">查看</Button>