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;
|
||||
|
||||
/**
|
||||
* 绿植产品包
|
||||
*/
|
||||
productList: any[];
|
||||
}
|
||||
|
||||
export interface RentalPlanForm extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: string | number;
|
||||
id?: string | number | undefined;
|
||||
|
||||
/**
|
||||
* 方案名称
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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',
|
||||
},
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
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>
|
||||
|
Loading…
Reference in New Issue
Block a user