Explorar el Código

Merge branch 'dev-wyf' into 'dev'

fix: 应急演练的表单添加返回校验

See merge request product-group-fe/sfy-safety-group/sfy-safety!214
ai0197 hace 7 meses
padre
commit
ac141df262

+ 14 - 5
src/views/emergency/emergency-drill/PageDrillPlanList.vue

@@ -84,6 +84,7 @@
   import { DrillPlanListSearch, DrillPlanItem } from './types';
   import { EMERGENCY_DRILL_STATUS_DICT } from './constants';
   import { useEmergencyDrillHook } from './hook';
+  import { QueryPageRequest } from '@/types/basic-query';
 
   const router = useRouter();
 
@@ -96,14 +97,22 @@
   // 搜索栏
   const searchData = reactive<DrillPlanListSearch>({});
   function handleSearch() {
-    tableQuery.value.queryParam = searchData;
+    tableQuery.queryParam = {};
+    if (searchData.daterange) {
+      tableQuery.queryParam.dueCompleteTimeStart = searchData.daterange[0];
+      tableQuery.queryParam.dueCompleteTimeEnd = searchData.daterange[1];
+    }
+    if (searchData.drillScope) tableQuery.queryParam.drillScope = searchData.drillScope;
+    if (searchData.drillContent) tableQuery.queryParam.drillContent = searchData.drillContent;
+    if (searchData.responsibleDept) tableQuery.queryParam.responsibleDept = searchData.responsibleDept;
+    if (searchData.status) tableQuery.queryParam.status = searchData.status;
     getTableData();
   }
 
   // 表格
   const { tableConfig, pagination } = useTableConfig(DRILL_PLAN_LIST_TABLE_COLUMNS, TABLE_OPTIONS);
 
-  const tableQuery = ref({
+  const tableQuery = reactive<QueryPageRequest<DrillPlanListSearch>>({
     pageNumber: pagination.pageNumber,
     pageSize: pagination.pageSize,
     queryParam: {},
@@ -113,12 +122,12 @@
 
   const handleSizeChange = (value: number) => {
     pagination.pageSize = value;
-    tableQuery.value.pageSize = value;
+    tableQuery.pageSize = value;
     getTableData();
   };
   const handleCurrentChange = (value: number) => {
     pagination.pageNumber = value;
-    tableQuery.value.pageSize = value;
+    tableQuery.pageSize = value;
     getTableData();
   };
 
@@ -134,7 +143,7 @@
 
   async function getTableData() {
     tableConfig.loading = true;
-    const res = await queryEnergencyDrillPlanList(tableQuery.value);
+    const res = await queryEnergencyDrillPlanList(tableQuery);
     res.records.forEach((item) => {
       item.responsibleDeptNameList = item.responsibleDeptNameList.replace(/^\[|\]$/g, '');
       item.coordinateDeptNameList = item.coordinateDeptNameList?.replace(/^\[|\]$/g, '');

+ 2 - 0
src/views/emergency/emergency-drill/components/DrillPlanCreateItem.vue

@@ -117,6 +117,8 @@
   const { drillScopeDice, getDrillScopeDict } = useEmergencyDrillHook();
 
   onMounted(() => {
+    cloneRuleFormData();
+    beforeRouteLeave();
     getDrillScopeDict();
     loadDeptTreeData();
     loadAllPlans();

+ 3 - 0
src/views/emergency/emergency-drill/components/DrillPlanExecuteForm.vue

@@ -104,6 +104,7 @@
   const deptTree = ref<DeptTree[]>();
   const loadDeptTreeData = async () => {
     const result = await getAllDepartments();
+    cloneRuleFormData();
     deptTree.value = result[0].children;
   };
 
@@ -124,6 +125,7 @@
   };
 
   onMounted(() => {
+    beforeRouteLeave();
     loadDeptTreeData();
   });
 
@@ -139,6 +141,7 @@
   };
 
   function getFormData() {
+    cloneRuleFormData();
     return ruleFormData;
   }
 

+ 4 - 1
src/views/emergency/emergency-drill/components/DrillPlanRecordForm.vue

@@ -57,13 +57,15 @@
     const approvalId = Number(route.query.approvalId);
     try {
       approvalInfo.value = await queryDrillApproval(approvalId, planId);
+      cloneRuleFormData();
       // console.log(approvalInfo.value);
     } catch (e) {
       console.log(e);
     }
   }
 
-  onMounted(async () => {
+  onMounted(() => {
+    beforeRouteLeave();
     getApprovalInfo();
   });
 
@@ -97,6 +99,7 @@
   };
 
   function getFormData() {
+    cloneRuleFormData();
     return ruleFormData;
   }