Explorar el Código

feat: 人员筛选回填

wyf hace 1 año
padre
commit
7b22aa4809

+ 211 - 188
src/views/message/reportmessage/class.ts

@@ -1,220 +1,243 @@
 import { reactive, computed } from 'vue';
 
 export enum type {
-    violationAlarm = 1,
-    platformStatistics = 2,
-    personnelStatistics = 3,
-  }
+  violationAlarm = 1,
+  platformStatistics = 2,
+  personnelStatistics = 3,
+}
 
 export enum StatisticType {
-    none = 0,
-    week = 1,
-    month = 2,
-    year = 4,
-    custom = 5,
-  }
+  none = 0,
+  week = 1,
+  month = 2,
+  year = 4,
+  custom = 5,
+}
 
 export interface finalReportMessage {
-    configIdList: [] | null,
-    type: number;
-    statisticType: StatisticType;
-    dayOfWeek: number
-    monthList: [string];
-    dayOfMonthList: [string];
-    pushTimeList: [string];
-    pushChannel: [];
-    userGroupList: [];
-    designatedUserList: [];
-    customUserList: [];
-    recipientType: number;
-    customPushConfigList: finalCustom[];
-}  
+  configIdList: [] | null;
+  type: number;
+  statisticType: StatisticType;
+  dayOfWeek: number;
+  monthList: [string];
+  dayOfMonthList: [string];
+  pushTimeList: [string];
+  pushChannel: [];
+  userGroupList: [];
+  designatedUserList: [];
+  customUserList: [];
+  recipientType: number;
+  customPushConfigList: finalCustom[];
+}
 
 export interface reportMessage {
-    configIdList: [] | null,
-    type: number;
-    statisticType: StatisticType;
-    dayOfWeek: number
-    monthList: [string];
-    monthAndDayList: [string, string] | any,
-    dayOfMonthList: [string];
-    pushTimeList: [string];
-    pushChannel: [];
-    userGroupList: any[];
-    designatedUserList: any;
-    customUserList: any;
-    recipientType: number|undefined;
-    customPushConfigList: computeCustom[]|any;
+  configIdList: [] | null;
+  type: number;
+  statisticType: StatisticType;
+  dayOfWeek: number;
+  monthList: [string];
+  monthAndDayList: [string, string] | any;
+  dayOfMonthList: [string];
+  pushTimeList: [string];
+  pushChannel: [];
+  userGroupList: any[];
+  designatedUserList: any;
+  customUserList: any;
+  recipientType: number | undefined;
+  customPushConfigList: computeCustom[] | any;
 }
 
-export interface finalCustom {  // 最终返回给接口的自定义报告类
-    configId: number | null;
-    customStartTime: string;
-    customEndTime: string;
-    customUserList: [];
-    pushTime: string;
-    recipientType: string;
-    userGroupList: [];
-    isDeleted: number;
+export interface finalCustom {
+  // 最终返回给接口的自定义报告类
+  configId: number | null;
+  customStartTime: string;
+  customEndTime: string;
+  customUserList: [];
+  pushTime: string;
+  recipientType: string;
+  userGroupList: [];
+  isDeleted: number;
 }
 
 export interface computeCustom {
-    configId: number | null;  // 临时自定义报告类,daterange用于给customStartTime和customEndTime提供计算值,pushDay和pushTime用于给finalPushTime提供计算值
-    daterange: null;
-    customStartTime: any;
-    customEndTime: any;
-    pushDay: null;
-    pushTime: null;
-    finalPushTime: any;
-    recipientType: string;
-    userGroupList: [];
-    customUserList: [];
-    isDeleted: number;
+  configId: number | null; // 临时自定义报告类,daterange用于给customStartTime和customEndTime提供计算值,pushDay和pushTime用于给finalPushTime提供计算值
+  daterange: null;
+  customStartTime: any;
+  customEndTime: any;
+  pushDay: null;
+  pushTime: null;
+  finalPushTime: any;
+  recipientType: string;
+  userGroupList: [];
+  customUserList: [];
+  isDeleted: number;
 }
 
 interface UserList {
-    id: string;
-    userNickname: string;
-    userLoginName: string;
-    userId: number;
-  }
+  id: string;
+  userNickname: string;
+  userLoginName: string;
+  userId: number;
+}
 
 export const createCustomReport = () => {
-    const newCustomReport = reactive<computeCustom>({
-        configId: null,
-        daterange: null,
-        customStartTime: computed(() => newCustomReport.daterange === null? null : newCustomReport.daterange[0]),
-        customEndTime: computed(() => newCustomReport.daterange === null? null : newCustomReport.daterange[1]),
-        pushDay: null,
-        pushTime: null,
-        finalPushTime: computed(() => {
-            return (newCustomReport.pushDay === null) || (newCustomReport.pushTime === null)? null :newCustomReport.pushDay + ' ' + newCustomReport.pushTime;
-        }),
-        recipientType: '',
-        userGroupList: [],
-        customUserList: [],
-        isDeleted: 0,
-    })
-    return newCustomReport
+  const newCustomReport = reactive<computeCustom>({
+    configId: null,
+    daterange: null,
+    customStartTime: computed(() =>
+      newCustomReport.daterange === null ? null : newCustomReport.daterange[0],
+    ),
+    customEndTime: computed(() =>
+      newCustomReport.daterange === null ? null : newCustomReport.daterange[1],
+    ),
+    pushDay: null,
+    pushTime: null,
+    finalPushTime: computed(() => {
+      return newCustomReport.pushDay === null || newCustomReport.pushTime === null
+        ? null
+        : newCustomReport.pushDay + ' ' + newCustomReport.pushTime;
+    }),
+    recipientType: '',
+    userGroupList: [],
+    customUserList: [],
+    isDeleted: 0,
+  });
+  return newCustomReport;
 };
 
 export const toReportMessage = (form: reportMessage, receivedData: finalReportMessage) => {
-    form.configIdList = receivedData.configIdList
-    form.type = receivedData.type
-    form.statisticType = receivedData.statisticType
-    form.dayOfWeek = receivedData.dayOfWeek
-    form.monthList = receivedData.monthList
-    form.dayOfMonthList = receivedData.dayOfMonthList
-    form.pushTimeList = receivedData.pushTimeList
-    form.pushChannel = receivedData.pushChannel
-    form.userGroupList = receivedData.userGroupList?.map((user:any) => user.id)
-    form.designatedUserList.value = receivedData.designatedUserList
-    form.customUserList.value = receivedData.customUserList
-    form.recipientType = receivedData.recipientType
-    form.customPushConfigList = []
-    
-    if(form.customUserList.value.length > 0){
-        form.customUserList.value = form.customUserList.value.map((user) => {
-            return {"id": `u${user.userId}`, "name": user.userLoginName + '-' + user.userNickname, "userId": user.userId}
-        })
-    }
-    if(form.designatedUserList.value.length > 0){
-        form.designatedUserList.value = form.designatedUserList.value.map((user) => {
-            return {"id": `u${user.userId}`, "name": user.userLoginName + '-' + user.userNickname, "userId": user.userId}
-        })
-    }
-    if(receivedData.statisticType === 2){
-        form.dayOfMonthList[0] = receivedData.dayOfMonthList[0].toString()
-    }
-    if(receivedData.statisticType === 4){
-        form.monthAndDayList.length = 0
-        form.monthAndDayList?.push(receivedData.monthList[0].toString())
-        form.monthAndDayList?.push(receivedData.dayOfMonthList[0].toString())
+  form.configIdList = receivedData.configIdList;
+  form.type = receivedData.type;
+  form.statisticType = receivedData.statisticType;
+  form.dayOfWeek = receivedData.dayOfWeek;
+  form.monthList = receivedData.monthList;
+  form.dayOfMonthList = receivedData.dayOfMonthList;
+  form.pushTimeList = receivedData.pushTimeList;
+  form.pushChannel = receivedData.pushChannel;
+  form.userGroupList = receivedData.userGroupList?.map((user: any) => user.id);
+  form.designatedUserList.value = receivedData.designatedUserList;
+  form.customUserList.value = receivedData.customUserList;
+  form.recipientType = receivedData.recipientType;
+  form.customPushConfigList = [];
+
+  //   if (form.customUserList.value.length > 0) {
+  //     form.customUserList.value = form.customUserList.value.map((user) => {
+  //       return {
+  //         id: `u${user.userId}`,
+  //         name: user.userLoginName + '-' + user.userNickname,
+  //         userId: user.userId,
+  //       };
+  //     });
+  //   }
+  //   if (form.designatedUserList.value.length > 0) {
+  //     form.designatedUserList.value = form.designatedUserList.value.map((user) => {
+  //       return {
+  //         id: `u${user.userId}`,
+  //         name: user.userLoginName + '-' + user.userNickname,
+  //         userId: user.userId,
+  //       };
+  //     });
+  //   }
+  if (receivedData.statisticType === 2) {
+    form.dayOfMonthList[0] = receivedData.dayOfMonthList[0].toString();
+  }
+  if (receivedData.statisticType === 4) {
+    form.monthAndDayList.length = 0;
+    form.monthAndDayList?.push(receivedData.monthList[0].toString());
+    form.monthAndDayList?.push(receivedData.dayOfMonthList[0].toString());
+  }
+  if (receivedData.statisticType === 5) {
+    let tempconfig = {};
+    let customPushConfigList: any[] = [];
+    for (let config of receivedData.customPushConfigList) {
+      tempconfig['configId'] = config.configId;
+      tempconfig['isDeleted'] = 0;
+      tempconfig['daterange'] = [
+        config.customStartTime.split(' ')[0],
+        config.customEndTime.split(' ')[0],
+      ];
+      // const customStartTime = computed(() => tempconfig['daterange'][0])
+      // const customEndTime = computed(() => tempconfig['daterange'][1])
+      // let _ = customStartTime.value
+      // let __ = customEndTime.value
+      // console.log("customStartTime", customStartTime.value);  // 不使customStartTime.value用会报错,离谱,后续再研究
+      // console.log("customEndTime", customEndTime.value);
+      // tempconfig['customEndTime'] = tempconfig['daterange'][1]
+      // tempconfig['customStartTime'] = customStartTime
+      // tempconfig['customEndTime'] = customEndTime
+      tempconfig['pushDay'] = config.pushTime.split(' ')[0];
+      tempconfig['pushTime'] = config.pushTime.split(' ')[1];
+      tempconfig['recipientType'] = config.recipientType.toString();
+      tempconfig['userGroupList'] = config.userGroupList;
+      tempconfig['customUserList'] = config.customUserList.map((user: UserList) => {
+        return {
+          id: `u${user.userId}`,
+          name: user.userLoginName + '-' + user.userNickname,
+          userId: user.userId,
+        };
+      });
+      tempconfig['userGroupList'] = config.userGroupList?.map((user: any) => user.id);
+      customPushConfigList.push(tempconfig);
+      tempconfig = {};
     }
-    if(receivedData.statisticType === 5){
-        let tempconfig = {}
-        let customPushConfigList: any[] = []
-        for (let config of receivedData.customPushConfigList) {
-            tempconfig['configId'] = config.configId
-            tempconfig['isDeleted'] = 0
-            tempconfig['daterange'] = [config.customStartTime.split(" ")[0], config.customEndTime.split(" ")[0]]
-            // const customStartTime = computed(() => tempconfig['daterange'][0])
-            // const customEndTime = computed(() => tempconfig['daterange'][1])
-            // let _ = customStartTime.value
-            // let __ = customEndTime.value
-            // console.log("customStartTime", customStartTime.value);  // 不使customStartTime.value用会报错,离谱,后续再研究
-            // console.log("customEndTime", customEndTime.value);
-            // tempconfig['customEndTime'] = tempconfig['daterange'][1]
-            // tempconfig['customStartTime'] = customStartTime
-            // tempconfig['customEndTime'] = customEndTime
-            tempconfig['pushDay'] = config.pushTime.split(" ")[0]
-            tempconfig['pushTime'] = config.pushTime.split(" ")[1]
-            tempconfig['recipientType'] = config.recipientType.toString()
-            tempconfig['userGroupList'] = config.userGroupList
-            tempconfig['customUserList'] = config.customUserList.map((user:UserList) => {
-                return {"id": `u${user.userId}`, "name": user.userLoginName + '-' + user.userNickname, "userId": user.userId}
-            })
-            tempconfig['userGroupList'] = config.userGroupList?.map((user:any) => user.id)
-            customPushConfigList.push(tempconfig)
-            tempconfig = {}
-        }
 
-        form.customPushConfigList = customPushConfigList
+    form.customPushConfigList = customPushConfigList;
 
-        for (let customConfig of form.customPushConfigList){
-            const finalPushTime = computed(() => customConfig['pushDay'] + ' ' + customConfig['pushTime'])
-            customConfig['finalPushTime'] = finalPushTime
+    for (let customConfig of form.customPushConfigList) {
+      const finalPushTime = computed(
+        () => customConfig['pushDay'] + ' ' + customConfig['pushTime'],
+      );
+      customConfig['finalPushTime'] = finalPushTime;
 
-            const customStartTime = computed(() => customConfig['daterange'][0])
-            const customEndTime = computed(() => customConfig['daterange'][1])
-            customConfig['customStartTime'] = customStartTime
-            customConfig['customEndTime'] = customEndTime
-        }
+      const customStartTime = computed(() => customConfig['daterange'][0]);
+      const customEndTime = computed(() => customConfig['daterange'][1]);
+      customConfig['customStartTime'] = customStartTime;
+      customConfig['customEndTime'] = customEndTime;
     }
+  }
 };
 
-export const reportMessageToFinal = (form) => {  // 临时表单转为只存在后端需要字段的表单
-    let tempCustom = {}
-    let customPushConfigList: any[] = []
-    if (form.customPushConfigList.length > 0){
-        if (!form.customPushConfigList[0].daterange){  // 如果有值则表示用户填了自定义的表单
-            return
-        }
-        else{
-            for (let config of form.customPushConfigList) {
-                for(let key in config){
-                    if (key === 'daterange' || key === 'pushDay' || key === 'pushTime') {
-                        continue   
-                    }
-                    else if(key === 'finalPushTime'){
-                        tempCustom['pushTime'] = config[key]
-                    }
-                    else if(key === 'customUserList'){
-                        tempCustom['customUserList'] = config[key].map((user) => user.userId)
-                    }
-                    else{
-                        tempCustom[key] = config[key]
-                    }
-                }
-                customPushConfigList.push(tempCustom)
-                tempCustom = {}
-            }
+export const reportMessageToFinal = (form) => {
+  // 临时表单转为只存在后端需要字段的表单
+
+  let tempCustom = {};
+  let customPushConfigList: any[] = [];
+  if (form.customPushConfigList.length > 0) {
+    if (!form.customPushConfigList[0].daterange) {
+      // 如果有值则表示用户填了自定义的表单
+      return;
+    } else {
+      for (let config of form.customPushConfigList) {
+        for (let key in config) {
+          if (key === 'daterange' || key === 'pushDay' || key === 'pushTime') {
+            continue;
+          } else if (key === 'finalPushTime') {
+            tempCustom['pushTime'] = config[key];
+          } else if (key === 'customUserList') {
+            tempCustom['customUserList'] = config[key].map((user) => user.id);
+          } else {
+            tempCustom[key] = config[key];
+          }
         }
+        customPushConfigList.push(tempCustom);
+        tempCustom = {};
+      }
     }
-    
-    return {
-        "configIdList": form.configIdList,
-        "type": form.type,
-        "statisticType": form.statisticType,
-        "dayOfWeek": form.dayOfWeek,
-        "monthList": form.monthList,
-        "dayOfMonthList": form.dayOfMonthList,
-        "pushTimeList": form.pushTimeList,
-        "pushChannel": form.pushChannel,
-        "userGroupList": form.userGroupList?.map((userOrId) => userOrId.id? userOrId.id :userOrId),  // 用户对象和id可能会同时存在列表中
-        "recipientType": form.recipientType,
-        "customPushConfigList": customPushConfigList,
-        "designatedUserList": form.designatedUserList.value?.map((user) => user.userId),  // 只取出id
-        "customUserList": form.customUserList.value?.map((user) => user.userId)
-    }
+  }
+
+  return {
+    configIdList: form.configIdList,
+    type: form.type,
+    statisticType: form.statisticType,
+    dayOfWeek: form.dayOfWeek,
+    monthList: form.monthList,
+    dayOfMonthList: form.dayOfMonthList,
+    pushTimeList: form.pushTimeList,
+    pushChannel: form.pushChannel,
+    userGroupList: form.userGroupList?.map((userOrId) => (userOrId.id ? userOrId.id : userOrId)), // 用户对象和id可能会同时存在列表中
+    recipientType: form.recipientType,
+    customPushConfigList: customPushConfigList,
+    designatedUserList: form.designatedUserList.value?.map((user) => user.id), // 只取出id
+    customUserList: form.customUserList.value?.map((user) => user.id),
+  };
 };

+ 8 - 2
src/views/message/reportmessage/components/DesignatedPersonSelection.vue

@@ -4,7 +4,7 @@
       v-model="prop.form.designatedUserList.value"
       value-key="id"
       multiple
-      placeholder="请选择人员"
+      placeholder="请选择人员vbbnnb"
       @click="dialogVisible = !disableType.contentDisable"
       :disabled="disableType.contentDisable"
     >
@@ -70,7 +70,13 @@
 
   onBeforeUpdate(() => {
     if (prop.form.designatedUserList?.value?.length > 0) {
-      selectedUser.value = prop.form.designatedUserList.value;
+      selectedUser.value = prop.form.designatedUserList.value.map((item) => {
+        return {
+          id: item.userId,
+          nickname: item.userNickname,
+          staffNo: item.userLoginName,
+        };
+      });
     }
   });
 </script>