|
@@ -328,6 +328,8 @@
|
|
|
deleteAreaCheckPlanDetail,
|
|
deleteAreaCheckPlanDetail,
|
|
|
queryAreaCheckRecord,
|
|
queryAreaCheckRecord,
|
|
|
mapAreaCheckPlanApiRecordToUi,
|
|
mapAreaCheckPlanApiRecordToUi,
|
|
|
|
|
+ queryCheckListTemplateNameList,
|
|
|
|
|
+ type ChecklistTemplate,
|
|
|
} from '@/api/production-safety-system';
|
|
} from '@/api/production-safety-system';
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
@@ -343,7 +345,7 @@
|
|
|
const AREA_CHECK_PLAN_FORM_DATA = AREA_CHECK_PLAN_FORM_DATA_IMPORT ?? {};
|
|
const AREA_CHECK_PLAN_FORM_DATA = AREA_CHECK_PLAN_FORM_DATA_IMPORT ?? {};
|
|
|
const AREA_CHECK_PLAN_FORM_RULES = AREA_CHECK_PLAN_FORM_RULES_IMPORT ?? {};
|
|
const AREA_CHECK_PLAN_FORM_RULES = AREA_CHECK_PLAN_FORM_RULES_IMPORT ?? {};
|
|
|
const CHECK_FREQUENCY_OPTIONS = CHECK_FREQUENCY_OPTIONS_IMPORT ?? [];
|
|
const CHECK_FREQUENCY_OPTIONS = CHECK_FREQUENCY_OPTIONS_IMPORT ?? [];
|
|
|
- const checklistCategoryOptionsSource = Array.isArray(CHECKLIST_CATEGORY_OPTIONS_IMPORT)
|
|
|
|
|
|
|
+ const CHECKLIST_CATEGORY_OPTIONS = Array.isArray(CHECKLIST_CATEGORY_OPTIONS_IMPORT)
|
|
|
? CHECKLIST_CATEGORY_OPTIONS_IMPORT
|
|
? CHECKLIST_CATEGORY_OPTIONS_IMPORT
|
|
|
: [];
|
|
: [];
|
|
|
|
|
|
|
@@ -402,9 +404,38 @@
|
|
|
setDeptNameFromCascader(hospitalLeaderDeptCascaderRef.value, 'hospitalLeaderDeptName');
|
|
setDeptNameFromCascader(hospitalLeaderDeptCascaderRef.value, 'hospitalLeaderDeptName');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 检查单模版选项(检查单模版类别与模版名称选项一致)
|
|
|
|
|
- const checklistCategoryOptions = ref<Array<{ label: string; value: string }>>(checklistCategoryOptionsSource);
|
|
|
|
|
- const checklistTemplateOptions = ref<Array<{ label: string; value: string }>>([...checklistCategoryOptionsSource]);
|
|
|
|
|
|
|
+ // 检查单模版类别:使用 form 静态选项,不请求接口
|
|
|
|
|
+ // 检查单模版名称:来自接口,可按类别筛选
|
|
|
|
|
+ const checklistTemplateOptions = ref<Array<{ label: string; value: string }>>([]);
|
|
|
|
|
+ const allChecklistTemplates = ref<ChecklistTemplate[]>([]);
|
|
|
|
|
+
|
|
|
|
|
+ /** 根据类别名称(form 静态选项的 value)筛选模版下拉 */
|
|
|
|
|
+ const updateChecklistTemplateOptionsByCategory = (categoryName?: string) => {
|
|
|
|
|
+ const list = allChecklistTemplates.value || [];
|
|
|
|
|
+ const filtered = categoryName
|
|
|
|
|
+ ? list.filter((item) => (item.categoryName as string) === categoryName)
|
|
|
|
|
+ : list;
|
|
|
|
|
+ checklistTemplateOptions.value = filtered
|
|
|
|
|
+ .filter((item) => !!item.templateName)
|
|
|
|
|
+ .map((item) => ({
|
|
|
|
|
+ label: item.templateName as string,
|
|
|
|
|
+ value: item.templateName as string,
|
|
|
|
|
+ }));
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ /** 加载检查单模版名称列表(仅模版名称下拉用,类别用 form 静态数据) */
|
|
|
|
|
+ const loadChecklistTemplateOptions = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await queryCheckListTemplateNameList();
|
|
|
|
|
+ const list = ((res as { data?: ChecklistTemplate[] })?.data ?? (res as ChecklistTemplate[] | undefined)) || [];
|
|
|
|
|
+ allChecklistTemplates.value = list;
|
|
|
|
|
+ const currentCategoryName = ruleFormData.checklistCategoryName as string | undefined;
|
|
|
|
|
+ updateChecklistTemplateOptionsByCategory(currentCategoryName);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('获取检查单模版名称列表失败:', e);
|
|
|
|
|
+ checklistTemplateOptions.value = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
const viewFormConfig = ref(
|
|
const viewFormConfig = ref(
|
|
|
AREA_CHECK_PLAN_FORM_CONFIG.map((item) => ({
|
|
AREA_CHECK_PLAN_FORM_CONFIG.map((item) => ({
|
|
@@ -420,10 +451,28 @@
|
|
|
const base = isViewMode.value ? viewFormConfig.value : cloneDeep(AREA_CHECK_PLAN_FORM_CONFIG);
|
|
const base = isViewMode.value ? viewFormConfig.value : cloneDeep(AREA_CHECK_PLAN_FORM_CONFIG);
|
|
|
return base.map((item) => {
|
|
return base.map((item) => {
|
|
|
if (item.prop === 'checklistCategoryName') {
|
|
if (item.prop === 'checklistCategoryName') {
|
|
|
- return { ...item, selectOptions: checklistCategoryOptions.value };
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ selectOptions: CHECKLIST_CATEGORY_OPTIONS,
|
|
|
|
|
+ componentProps: {
|
|
|
|
|
+ ...(item.componentProps || {}),
|
|
|
|
|
+ onChange: (val: string) => {
|
|
|
|
|
+ ruleFormData.checklistCategoryName = val;
|
|
|
|
|
+ (ruleFormData as Record<string, unknown>).checklistCategoryCode = val;
|
|
|
|
|
+ ruleFormData.checklistTemplateName = '';
|
|
|
|
|
+ updateChecklistTemplateOptionsByCategory(val);
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
if (item.prop === 'checklistTemplateName') {
|
|
if (item.prop === 'checklistTemplateName') {
|
|
|
- return { ...item, selectOptions: checklistTemplateOptions.value };
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ selectOptions: checklistTemplateOptions.value,
|
|
|
|
|
+ componentProps: {
|
|
|
|
|
+ ...(item.componentProps || {}),
|
|
|
|
|
+ },
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
return item;
|
|
return item;
|
|
|
});
|
|
});
|
|
@@ -636,9 +685,11 @@
|
|
|
ruleFormData.hospitalLeaderDeptName = detail.hospitalLeaderDeptName ?? '';
|
|
ruleFormData.hospitalLeaderDeptName = detail.hospitalLeaderDeptName ?? '';
|
|
|
ruleFormData.hospitalLeaderDeptId = findDeptIdByName(deptTree.value, ruleFormData.hospitalLeaderDeptName as string) ?? null;
|
|
ruleFormData.hospitalLeaderDeptId = findDeptIdByName(deptTree.value, ruleFormData.hospitalLeaderDeptName as string) ?? null;
|
|
|
ruleFormData.hospitalLeaderCheckFrequency = detail.hospitalLeaderCheckFrequency ?? '';
|
|
ruleFormData.hospitalLeaderCheckFrequency = detail.hospitalLeaderCheckFrequency ?? '';
|
|
|
|
|
+ (ruleFormData as Record<string, unknown>).checklistCategoryCode = detail.checklistCategoryCode ?? '';
|
|
|
ruleFormData.checklistCategoryName = detail.checklistCategoryName ?? '';
|
|
ruleFormData.checklistCategoryName = detail.checklistCategoryName ?? '';
|
|
|
ruleFormData.checklistTemplateName = detail.checklistTemplateName ?? '';
|
|
ruleFormData.checklistTemplateName = detail.checklistTemplateName ?? '';
|
|
|
ruleFormData.checkKeyContent = detail.checkKeyContent ?? '';
|
|
ruleFormData.checkKeyContent = detail.checkKeyContent ?? '';
|
|
|
|
|
+ updateChecklistTemplateOptionsByCategory(ruleFormData.checklistCategoryName as string | undefined);
|
|
|
cloneRuleFormData();
|
|
cloneRuleFormData();
|
|
|
if (isViewMode.value) {
|
|
if (isViewMode.value) {
|
|
|
loadRecordList();
|
|
loadRecordList();
|
|
@@ -669,6 +720,7 @@
|
|
|
cloneRuleFormData();
|
|
cloneRuleFormData();
|
|
|
beforeRouteLeave();
|
|
beforeRouteLeave();
|
|
|
await getDeptTreeData();
|
|
await getDeptTreeData();
|
|
|
|
|
+ await loadChecklistTemplateOptions();
|
|
|
if (isEditMode.value || isViewMode.value) {
|
|
if (isEditMode.value || isViewMode.value) {
|
|
|
getDetail();
|
|
getDetail();
|
|
|
}
|
|
}
|