|
@@ -2,14 +2,16 @@
|
|
|
import { ref, watch, nextTick, h, onMounted, reactive } from 'vue';
|
|
import { ref, watch, nextTick, h, onMounted, reactive } from 'vue';
|
|
|
import { type VxeTablePropTypes, type VxeTableEvents, VxeUI } from 'vxe-table';
|
|
import { type VxeTablePropTypes, type VxeTableEvents, VxeUI } from 'vxe-table';
|
|
|
import { getDictionaryMethod } from '@/request/api/dictionary.api';
|
|
import { getDictionaryMethod } from '@/request/api/dictionary.api';
|
|
|
-import { getConditioningDeviceDetailMethod, updateConditioningSchemeMethod, getConditioningSchemeItemsMethod } from '@/request/api/care.api';
|
|
|
|
|
|
|
+import { getConditioningDeviceDetailMethod, updateConditioningSchemeMethod } from '@/request/api/care.api';
|
|
|
import type { ConditioningSchemeModel } from '@/model/care.model';
|
|
import type { ConditioningSchemeModel } from '@/model/care.model';
|
|
|
import { useRequest } from 'alova/client';
|
|
import { useRequest } from 'alova/client';
|
|
|
-import { notification } from 'ant-design-vue';
|
|
|
|
|
|
|
+import { message, notification } from 'ant-design-vue';
|
|
|
import { MenuUnfoldOutlined } from '@ant-design/icons-vue';
|
|
import { MenuUnfoldOutlined } from '@ant-design/icons-vue';
|
|
|
import CustomConfiguration from '@/service/CustomConfiguration.vue';
|
|
import CustomConfiguration from '@/service/CustomConfiguration.vue';
|
|
|
type ConditioningModel = Partial<ConditioningSchemeModel>;
|
|
type ConditioningModel = Partial<ConditioningSchemeModel>;
|
|
|
-
|
|
|
|
|
|
|
+ (notification.config as any)({
|
|
|
|
|
+ zIndex: 10000, // 直接设置层级
|
|
|
|
|
+});
|
|
|
// 定义表格行数据类型
|
|
// 定义表格行数据类型
|
|
|
interface TableRowData {
|
|
interface TableRowData {
|
|
|
isCustomize: boolean;
|
|
isCustomize: boolean;
|
|
@@ -21,8 +23,8 @@ interface TableRowData {
|
|
|
selectedCpIds?: string[];
|
|
selectedCpIds?: string[];
|
|
|
isShowForInfer: string;
|
|
isShowForInfer: string;
|
|
|
isNewRow?: boolean; // 用于标识是否是新添加的行
|
|
isNewRow?: boolean; // 用于标识是否是新添加的行
|
|
|
- showListIcon?: boolean; // 是否显示列表图标
|
|
|
|
|
- previousChecked?: boolean; // 上一次的勾选状态,用于判断状态变化
|
|
|
|
|
|
|
+ previousChecked?: boolean; // 上一次“确认后”的勾选状态
|
|
|
|
|
+ backupSelectedCpIds?: string[]; // 打开弹窗前的已选项目快照(用于取消还原)
|
|
|
}
|
|
}
|
|
|
const emits = defineEmits<{
|
|
const emits = defineEmits<{
|
|
|
submit: [success: boolean, data?: Array<TableRowData>];
|
|
submit: [success: boolean, data?: Array<TableRowData>];
|
|
@@ -96,7 +98,6 @@ const deleteRow = (row: any) => {
|
|
|
|
|
|
|
|
// 保存
|
|
// 保存
|
|
|
const saveData = async () => {
|
|
const saveData = async () => {
|
|
|
- console.log(tableData.value, '保存数据');
|
|
|
|
|
// 数据验证和格式化
|
|
// 数据验证和格式化
|
|
|
formattedData = tableData.value.map((row) => ({
|
|
formattedData = tableData.value.map((row) => ({
|
|
|
...row,
|
|
...row,
|
|
@@ -169,6 +170,7 @@ const organizationName = ref('');
|
|
|
const insName = ref('');
|
|
const insName = ref('');
|
|
|
const insId = ref<number>(0);
|
|
const insId = ref<number>(0);
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
|
|
+ console.log(props.data, 'props.onMounted');
|
|
|
getConditioningProgramType();
|
|
getConditioningProgramType();
|
|
|
const res: any = await getConditioningDeviceDetailMethod(props.data);
|
|
const res: any = await getConditioningDeviceDetailMethod(props.data);
|
|
|
organizationName.value = res.orgName ?? '';
|
|
organizationName.value = res.orgName ?? '';
|
|
@@ -183,13 +185,14 @@ onMounted(async () => {
|
|
|
} else if (row.isHaveForInfer === 'Y') {
|
|
} else if (row.isHaveForInfer === 'Y') {
|
|
|
// 是定制项目且展示
|
|
// 是定制项目且展示
|
|
|
row.isCustomize = true;
|
|
row.isCustomize = true;
|
|
|
- row.showListIcon = true; // 已勾选,显示列表图标
|
|
|
|
|
|
|
+ // row.showListIcon = true; // 已勾选,显示列表图标
|
|
|
} else if (row.isHaveForInfer === 'N') {
|
|
} else if (row.isHaveForInfer === 'N') {
|
|
|
// 是定制项目但不展示
|
|
// 是定制项目但不展示
|
|
|
row.isCustomize = true;
|
|
row.isCustomize = true;
|
|
|
- row.showListIcon = false; // 未勾选,隐藏列表图标
|
|
|
|
|
|
|
+ // row.showListIcon = false; // 未勾选,隐藏列表图标
|
|
|
}
|
|
}
|
|
|
- row.showListIcon = row.previousChecked = row.isChecked = row.isShowForInfer == 'Y' ? true : false;
|
|
|
|
|
|
|
+ // row.showListIcon =
|
|
|
|
|
+ row.isChecked = row.previousChecked = row.selectedCpIds && row.selectedCpIds.length > 0 ? true : false;
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -376,31 +379,15 @@ const handleItemLimitPaste = (params: any) => {
|
|
|
};
|
|
};
|
|
|
// 处理复选框变化
|
|
// 处理复选框变化
|
|
|
function handleCheckboxChange(row: TableRowData) {
|
|
function handleCheckboxChange(row: TableRowData) {
|
|
|
- const wasChecked = row.previousChecked ?? false;
|
|
|
|
|
- const isChecked = row.isChecked;
|
|
|
|
|
-
|
|
|
|
|
- // 更新 previousChecked
|
|
|
|
|
- row.previousChecked = isChecked;
|
|
|
|
|
-
|
|
|
|
|
- // 从不勾选到勾选:显示列表图标并自动打开详情编辑
|
|
|
|
|
- if (!wasChecked && isChecked) {
|
|
|
|
|
- row.showListIcon = true;
|
|
|
|
|
- row.isChecked = true;
|
|
|
|
|
- row.isShowForInfer = 'Y';
|
|
|
|
|
- // 延迟一下,确保UI更新后再打开弹窗
|
|
|
|
|
- nextTick(() => {
|
|
|
|
|
- handleCustomProjectTrue(row);
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- // 从勾选到不勾选:隐藏列表图标
|
|
|
|
|
- else if (wasChecked && !isChecked) {
|
|
|
|
|
- row.showListIcon = false;
|
|
|
|
|
- row.isChecked = false;
|
|
|
|
|
- row.isShowForInfer = 'N';
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 无论是勾选还是取消,都弹出定制项目弹窗;
|
|
|
|
|
+ // 真正的状态变更在弹窗“确认”时生效,“取消”会还原到打开前的项目选择
|
|
|
|
|
+ handleCustomProjectTrue(row);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleCustomProjectTrue = (row: any) => {
|
|
const handleCustomProjectTrue = (row: any) => {
|
|
|
|
|
+ // 打开弹窗前先对项目选择做一份快照,供取消时还原
|
|
|
|
|
+ row.backupSelectedCpIds = row.selectedCpIds ? [...row.selectedCpIds] : [];
|
|
|
|
|
+
|
|
|
VxeUI.modal.open({
|
|
VxeUI.modal.open({
|
|
|
title: '定制项目',
|
|
title: '定制项目',
|
|
|
width: 1100,
|
|
width: 1100,
|
|
@@ -418,8 +405,27 @@ const handleCustomProjectTrue = (row: any) => {
|
|
|
item.selectedCpIds = data.selectedProjects.map((item: any) => item.projectId) as string[];
|
|
item.selectedCpIds = data.selectedProjects.map((item: any) => item.projectId) as string[];
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ // 根据是否有选中项目决定是否展示
|
|
|
|
|
+ const hasSelected = row.selectedCpIds && row.selectedCpIds.length > 0;
|
|
|
|
|
+ row.isChecked = !!hasSelected;
|
|
|
|
|
+ row.isShowForInfer = hasSelected ? 'Y' : 'N';
|
|
|
|
|
+
|
|
|
|
|
+ // 确认后更新“上一次确认”的状态和快照
|
|
|
|
|
+ row.previousChecked = row.isChecked;
|
|
|
|
|
+ row.backupSelectedCpIds = row.selectedCpIds ? [...row.selectedCpIds] : [];
|
|
|
|
|
+ VxeUI.modal.close('custom-configuration-modal');
|
|
|
|
|
+ },
|
|
|
|
|
+ onClose: () => {
|
|
|
|
|
+ // 取消时还原到打开弹窗前的项目选择
|
|
|
|
|
+ row.selectedCpIds = row.backupSelectedCpIds ? [...row.backupSelectedCpIds] : [];
|
|
|
|
|
+
|
|
|
|
|
+ // 根据还原后的已选项目恢复展示状态(是否显示仅由是否有选中项目决定)
|
|
|
|
|
+ const hasSelected = row.selectedCpIds && row.selectedCpIds.length > 0;
|
|
|
|
|
+ row.isChecked = !!hasSelected;
|
|
|
|
|
+ row.isShowForInfer = hasSelected ? 'Y' : 'N';
|
|
|
VxeUI.modal.close('custom-configuration-modal');
|
|
VxeUI.modal.close('custom-configuration-modal');
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -431,8 +437,8 @@ const handleCustomProjectTrue = (row: any) => {
|
|
|
<div class="edit-configured">
|
|
<div class="edit-configured">
|
|
|
<!-- 组织名称 -->
|
|
<!-- 组织名称 -->
|
|
|
<div class="flex">
|
|
<div class="flex">
|
|
|
- <div class="organization-name mr-15" v-if="organizationName">组织名称:{{ organizationName }}</div>
|
|
|
|
|
- <div class="organization-name" v-if="insName">机构名称:{{ insName }}</div>
|
|
|
|
|
|
|
+ <div class="organization-name mr-15" v-if="organizationName">组织名称:{{ organizationName }}</div>
|
|
|
|
|
+ <div class="organization-name" v-if="insName">机构名称:{{ insName }}</div>
|
|
|
</div>
|
|
</div>
|
|
|
<!-- 表格 -->
|
|
<!-- 表格 -->
|
|
|
<vxe-table
|
|
<vxe-table
|
|
@@ -474,7 +480,7 @@ const handleCustomProjectTrue = (row: any) => {
|
|
|
<div class="custom-project-indicator">
|
|
<div class="custom-project-indicator">
|
|
|
<div v-if="row.isCustomize" class="custom-project-true-container">
|
|
<div v-if="row.isCustomize" class="custom-project-true-container">
|
|
|
<a-checkbox v-model:checked="row.isChecked" @change="handleCheckboxChange(row)"> 展示 </a-checkbox>
|
|
<a-checkbox v-model:checked="row.isChecked" @change="handleCheckboxChange(row)"> 展示 </a-checkbox>
|
|
|
- <div v-if="row.showListIcon" class="flex items-center custom-project-true" @click="handleCustomProjectTrue(row)">
|
|
|
|
|
|
|
+ <div v-if="row.isChecked" class="flex items-center custom-project-true" @click="handleCustomProjectTrue(row)">
|
|
|
<MenuUnfoldOutlined />
|
|
<MenuUnfoldOutlined />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|