Merge branch 'master' of http://47.109.37.87:3000/by2025/admin-vben5
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
commit
4bf741f63d
@ -35,14 +35,17 @@ export interface RentalPlanVO {
|
|||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
remarks: string;
|
remarks: string;
|
||||||
|
/**
|
||||||
|
* 绿植产品包
|
||||||
|
*/
|
||||||
|
productList: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RentalPlanForm extends BaseEntity {
|
export interface RentalPlanForm extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
id?: string | number;
|
id?: string | number | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 方案名称
|
* 方案名称
|
||||||
|
@ -31,6 +31,7 @@ const detailSchema = [
|
|||||||
fieldName: 'name',
|
fieldName: 'name',
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
disabled: isView,
|
||||||
api: async () => {
|
api: async () => {
|
||||||
const res = await cleanList({stater:1});
|
const res = await cleanList({stater:1});
|
||||||
cleanListData = res.rows || [];
|
cleanListData = res.rows || [];
|
||||||
@ -64,6 +65,7 @@ const detailSchema = [
|
|||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
disabled: isView,
|
||||||
onChange: async (value: number) => {
|
onChange: async (value: number) => {
|
||||||
const formValues = await formApi.getValues();
|
const formValues = await formApi.getValues();
|
||||||
if (formValues.peices && value) {
|
if (formValues.peices && value) {
|
||||||
@ -182,8 +184,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
if(!data || Object.keys(data).length === 0){
|
if(!data || Object.keys(data).length === 0){
|
||||||
//modalApi.getData()为空时表示添加
|
//modalApi.getData()为空时表示添加
|
||||||
isAdd.value = true;
|
isAdd.value = true;
|
||||||
}else if(detailIndex.value == undefined || detailIndex.value == null){
|
}else if(data.readonly){
|
||||||
//不存在detailIndex.value时表示查看
|
|
||||||
isView.value = true;
|
isView.value = true;
|
||||||
}else{
|
}else{
|
||||||
//表示编辑
|
//表示编辑
|
||||||
@ -203,22 +204,21 @@ async function handleConfirm() {
|
|||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = cloneDeep(await formApi.getValues());
|
let data = cloneDeep(await formApi.getValues());
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
// 获取选中的服务名称
|
// 获取选中的服务名称
|
||||||
const selectedService = cleanListData.find(item => item.id === data.name);
|
const selectedService = cleanListData.find(item => item.id === data.name);
|
||||||
if (selectedService) {
|
if (selectedService) {
|
||||||
data.name = selectedService.name;
|
data.name = selectedService.name;
|
||||||
data.id = selectedService.id
|
data.id = selectedService.id
|
||||||
}
|
}
|
||||||
//index>=0时表示编辑
|
if (isUpdate.value) {
|
||||||
if (detailIndex.value! >= 0) {
|
data.index = detailIndex.value;
|
||||||
emit('editReload', data);
|
emit('editReload', data);
|
||||||
|
}else if(isAdd.value){
|
||||||
|
emit('reload', data);
|
||||||
}
|
}
|
||||||
handleClosed()
|
handleClosed()
|
||||||
await markInitialized();
|
await markInitialized();
|
||||||
emit('reload', data);
|
|
||||||
modalApi.close();
|
modalApi.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -275,11 +275,16 @@ function handleAddDetail() {
|
|||||||
}
|
}
|
||||||
// 添加订单服务详情
|
// 添加订单服务详情
|
||||||
function handleDetailReload(data: any) {
|
function handleDetailReload(data: any) {
|
||||||
|
console.log(data,'afawed');
|
||||||
|
|
||||||
detailTable.value.push(data);
|
detailTable.value.push(data);
|
||||||
}
|
}
|
||||||
// 编辑订单服务详情
|
// 编辑订单服务详情
|
||||||
function handleEditDetailReload(data: any) {
|
function handleEditDetailReload(data: any) {
|
||||||
|
console.log(data,'1203342423');
|
||||||
|
|
||||||
detailTable.value[data.index] = data;
|
detailTable.value[data.index] = data;
|
||||||
|
|
||||||
}
|
}
|
||||||
// 删除订单服务详情
|
// 删除订单服务详情
|
||||||
function handleDeleteDetail(record: any, index: number) {
|
function handleDeleteDetail(record: any, index: number) {
|
||||||
|
@ -54,6 +54,9 @@ export const columns: VxeGridProps['columns'] = [
|
|||||||
{
|
{
|
||||||
title: '租赁周期',
|
title: '租赁周期',
|
||||||
field: 'rentalPeriod',
|
field: 'rentalPeriod',
|
||||||
|
slots: {
|
||||||
|
default: 'rentalPeriod'
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '适用场景',
|
title: '适用场景',
|
||||||
@ -124,16 +127,7 @@ export const modalSchema: FormSchemaGetter = () => [
|
|||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
// 可选从DictEnum中获取 DictEnum.WY_KG 便于维护
|
// 可选从DictEnum中获取 DictEnum.WY_KG 便于维护
|
||||||
options: [
|
options: getDictOptions('wy_kg'),
|
||||||
{
|
|
||||||
label: '待支付',
|
|
||||||
value: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '已支付',
|
|
||||||
value: 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
rules: 'selectRequired',
|
rules: 'selectRequired',
|
||||||
},
|
},
|
||||||
|
@ -103,7 +103,7 @@ async function handleDelete(row: Required<RentalPlanForm>) {
|
|||||||
await tableApi.query();
|
await tableApi.query();
|
||||||
}
|
}
|
||||||
async function handleView(row: Required<RentalPlanForm>) {
|
async function handleView(row: Required<RentalPlanForm>) {
|
||||||
modalApi.setData({ id: row.id, readonly: true,ab:"wegqw" });
|
modalApi.setData({ id: row.id, readonly: true,});
|
||||||
modalApi.open();
|
modalApi.open();
|
||||||
}
|
}
|
||||||
function handleMultiDelete() {
|
function handleMultiDelete() {
|
||||||
@ -156,10 +156,14 @@ function handleDownloadExcel() {
|
|||||||
</a-button>
|
</a-button>
|
||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
|
<template #rentalPeriod="{ row }">
|
||||||
|
<div>
|
||||||
|
{{ row.rentalPeriod == 0?'月':row.rentalPeriod == 1 ? '季度':'年' }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<template #state="{ row }">
|
<template #state="{ row }">
|
||||||
<Tag v-if="row.state === 0" color="error">禁用</Tag>
|
<Tag v-if="row.state == 0" color="error">禁用</Tag>
|
||||||
<Tag v-else-if="row.state === 1" color="success">启用</Tag>
|
<Tag v-else-if="row.state == 1" color="success">启用</Tag>
|
||||||
<Tag v-else color="default">未审核</Tag>
|
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<Space>
|
<Space>
|
||||||
|
@ -6,7 +6,7 @@ import { cloneDeep } from '@vben/utils';
|
|||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
||||||
import { plantsProductList } from '#/api/property/productManagement';
|
import { plantsProductList } from '#/api/property/productManagement';
|
||||||
|
import { getDictOptions } from '#/utils/dict';
|
||||||
const emit = defineEmits<{ reload: [data: any], editReload: [data: any] }>();
|
const emit = defineEmits<{ reload: [data: any], editReload: [data: any] }>();
|
||||||
|
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
@ -31,6 +31,7 @@ const detailSchema = [
|
|||||||
fieldName: 'plantName',
|
fieldName: 'plantName',
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
disabled: isView,
|
||||||
api: async () => {
|
api: async () => {
|
||||||
const res = await plantsProductList({inventory:0});
|
const res = await plantsProductList({inventory:0});
|
||||||
plantListData = res.rows || [];
|
plantListData = res.rows || [];
|
||||||
@ -40,12 +41,8 @@ const detailSchema = [
|
|||||||
labelField: 'plantName',
|
labelField: 'plantName',
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
onChange: async (value: string) => {
|
onChange: async (value: string) => {
|
||||||
console.log(value);
|
|
||||||
|
|
||||||
// 找到选中的服务数据
|
// 找到选中的服务数据
|
||||||
const selectedService = plantListData.find(item => item.id === value);
|
const selectedService = plantListData.find(item => item.id === value);
|
||||||
console.log(selectedService,'1203');
|
|
||||||
|
|
||||||
if (selectedService) {
|
if (selectedService) {
|
||||||
// 自动填充其他字段
|
// 自动填充其他字段
|
||||||
await formApi.setValues({
|
await formApi.setValues({
|
||||||
@ -74,11 +71,11 @@ const detailSchema = [
|
|||||||
{
|
{
|
||||||
label: '产品分类',
|
label: '产品分类',
|
||||||
fieldName: 'plantType',
|
fieldName: 'plantType',
|
||||||
component: 'Input',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
|
options: getDictOptions('pro_product_classification'),
|
||||||
},
|
},
|
||||||
rules: 'required',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '图片',
|
label: '图片',
|
||||||
@ -114,8 +111,8 @@ const detailSchema = [
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
options: [
|
options: [
|
||||||
{ label: '上架', value: 1 },
|
{ label: '上架', value: '1' },
|
||||||
{ label: '下架', value: 0 },
|
{ label: '下架', value: '0' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
@ -162,7 +159,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
if(!data || Object.keys(data).length === 0){
|
if(!data || Object.keys(data).length === 0){
|
||||||
//modalApi.getData()为空时表示添加
|
//modalApi.getData()为空时表示添加
|
||||||
isAdd.value = true;
|
isAdd.value = true;
|
||||||
}else if(detailIndex.value == undefined || detailIndex.value == null){
|
}else if(data.readonly){
|
||||||
//不存在detailIndex.value时表示查看
|
//不存在detailIndex.value时表示查看
|
||||||
isView.value = true;
|
isView.value = true;
|
||||||
}else{
|
}else{
|
||||||
@ -184,24 +181,20 @@ async function handleConfirm() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = cloneDeep(await formApi.getValues());
|
const data = cloneDeep(await formApi.getValues());
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
// 获取选中的产品
|
// 获取选中的产品
|
||||||
const selectedService = plantListData.find(item => item.id === data.plantName);
|
const selectedService = plantListData.find(item => item.id === data.plantName);
|
||||||
console.log(selectedService,'selectedService');
|
|
||||||
if (selectedService) {
|
if (selectedService) {
|
||||||
data.plantName = selectedService.plantName;
|
data.plantName = selectedService.plantName;
|
||||||
data.id = selectedService.id
|
data.id = selectedService.id
|
||||||
}
|
}
|
||||||
//index>=0时表示编辑
|
if (isUpdate.value) {
|
||||||
if (detailIndex.value! >= 0) {
|
data.index = detailIndex.value;
|
||||||
emit('editReload', data);
|
emit('editReload', data);
|
||||||
|
}else if(isAdd.value){
|
||||||
|
emit('reload', data);
|
||||||
}
|
}
|
||||||
handleClosed()
|
handleClosed()
|
||||||
await markInitialized();
|
await markInitialized();
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
emit('reload', data);
|
|
||||||
modalApi.close();
|
modalApi.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -11,6 +11,8 @@ import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
|||||||
|
|
||||||
import { modalSchema } from './data';
|
import { modalSchema } from './data';
|
||||||
import productDetailModal from './rentalPlan-detial-modal.vue';
|
import productDetailModal from './rentalPlan-detial-modal.vue';
|
||||||
|
import { getDictOptions } from '#/utils/dict';
|
||||||
|
|
||||||
const emit = defineEmits<{ reload: [] }>();
|
const emit = defineEmits<{ reload: [] }>();
|
||||||
|
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
@ -18,7 +20,7 @@ const isReadonly = ref(false);
|
|||||||
const title = computed(() => {
|
const title = computed(() => {
|
||||||
return isUpdate.value ? $t('pages.common.edit') : isReadonly.value ? '详情' : $t('pages.common.add');
|
return isUpdate.value ? $t('pages.common.edit') : isReadonly.value ? '详情' : $t('pages.common.add');
|
||||||
});
|
});
|
||||||
|
const editId = ref<string | number | undefined>('')
|
||||||
const [BasicForm, formApi] = useVbenForm({
|
const [BasicForm, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
// 默认占满两列
|
// 默认占满两列
|
||||||
@ -54,12 +56,9 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
console.log(isOpen);
|
|
||||||
|
|
||||||
modalApi.modalLoading(true);
|
modalApi.modalLoading(true);
|
||||||
console.log(modalApi.getData(),'====================');
|
|
||||||
|
|
||||||
const { id, readonly } = modalApi.getData() as { id?: number | string, readonly?: boolean; };
|
const { id, readonly } = modalApi.getData() as { id?: number | string, readonly?: boolean; };
|
||||||
|
editId.value = id || '';
|
||||||
isReadonly.value = !!readonly;
|
isReadonly.value = !!readonly;
|
||||||
if(isReadonly.value){
|
if(isReadonly.value){
|
||||||
isUpdate.value = false;
|
isUpdate.value = false;
|
||||||
@ -69,6 +68,8 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
// 查看与编辑时需要获取详情
|
// 查看与编辑时需要获取详情
|
||||||
if ((isUpdate.value || isReadonly.value) && id) {
|
if ((isUpdate.value || isReadonly.value) && id) {
|
||||||
const record = await rentalPlanInfo(id);
|
const record = await rentalPlanInfo(id);
|
||||||
|
// 后端返回绿植产品包列表结构处理
|
||||||
|
detailTable.value = record.productList.map((item:any) => item.product);
|
||||||
await formApi.setValues(record);
|
await formApi.setValues(record);
|
||||||
}
|
}
|
||||||
await markInitialized();
|
await markInitialized();
|
||||||
@ -87,11 +88,8 @@ async function handleConfirm() {
|
|||||||
}
|
}
|
||||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||||
const data = cloneDeep(await formApi.getValues());
|
const data = cloneDeep(await formApi.getValues());
|
||||||
console.log(data);
|
|
||||||
console.log(detailTable.value);
|
|
||||||
|
|
||||||
data.productIds = detailTable.value.map((item:any) => item.id);
|
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();
|
resetInitialized();
|
||||||
emit('reload');
|
emit('reload');
|
||||||
modalApi.close();
|
modalApi.close();
|
||||||
@ -168,6 +166,12 @@ function handleEditDetail(record: any, index: number) {
|
|||||||
detailModalApi.setData({ ...record, index, readonly: false });
|
detailModalApi.setData({ ...record, index, readonly: false });
|
||||||
detailModalApi.open();
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -190,9 +194,12 @@ function handleEditDetail(record: any, index: number) {
|
|||||||
<template v-if="column.key === 'index'">
|
<template v-if="column.key === 'index'">
|
||||||
{{ index + 1 }}
|
{{ index + 1 }}
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="column.key === 'plantType'">
|
||||||
|
<div>{{getPlantTypeLabel(record.plantType)}}</div>
|
||||||
|
</template>
|
||||||
<template v-else-if="column.key === 'action'">
|
<template v-else-if="column.key === 'action'">
|
||||||
<template v-if="isReadonly">
|
<template v-if="isReadonly">
|
||||||
<Button @click="handleViewDetail(record)">查看</Button>
|
<Button type="primary" size="small" style="margin-right: 5px;" @click="handleViewDetail(record)">查看</Button>
|
||||||
</template>
|
</template>
|
||||||
<template v-else >
|
<template v-else >
|
||||||
<Button type="primary" size="small" style="margin-right: 5px;" @click="handleViewDetail(record)">查看</Button>
|
<Button type="primary" size="small" style="margin-right: 5px;" @click="handleViewDetail(record)">查看</Button>
|
||||||
|
Loading…
Reference in New Issue
Block a user