Jelajahi Sumber

fix: 删除报警推送的[全员]选项

sunhongyao341504 1 tahun lalu
induk
melakukan
d22a890945

+ 13 - 43
src/views/message/alarm-config/AlarmConfig.vue

@@ -23,24 +23,12 @@
               placeholder="请选择违规类型"
               :disabled="disableType"
             >
-              <el-option
-                v-for="item in AlarmTypes"
-                :key="item.id"
-                :label="item.name"
-                :value="item.id"
+              <el-option v-for="item in AlarmTypes" :key="item.id" :label="item.name" :value="item.id"
             /></el-select>
           </el-form-item>
           <el-form-item label="违规等级:" prop="violationLevel">
-            <el-select
-              class="alarm-config-input"
-              v-model="alarmConfigForm.violationLevel"
-              placeholder="请选择违规等级"
-            >
-              <el-option
-                v-for="item in ALARMLEVEL_LIST"
-                :key="item.value"
-                :label="item.label"
-                :value="item.value"
+            <el-select class="alarm-config-input" v-model="alarmConfigForm.violationLevel" placeholder="请选择违规等级">
+              <el-option v-for="item in ALARMLEVEL_LIST" :key="item.value" :label="item.label" :value="item.value"
             /></el-select>
           </el-form-item>
           <el-form-item label="推送渠道:" prop="pushChannel">
@@ -50,36 +38,25 @@
                 :key="channel.value"
                 :label="channel.label"
                 :value="channel.value"
-              >
-              </el-checkbox>
+              />
             </el-checkbox-group>
           </el-form-item>
           <el-form-item ref="pushOccasionsRef" label="推送阶段:" prop="pushOccasions">
             <div>
               <div v-for="phase in ALARMPHASE_LIST" :key="phase.value">
-                <div
-                  v-if="
-                    (phase.value !== AlarmPhase.effects || isDevMode) &&
-                    alarmConfigForm.pushOccasions
-                  "
-                >
+                <div v-if="(phase.value !== AlarmPhase.effects || isDevMode) && alarmConfigForm.pushOccasions">
                   <el-checkbox
                     v-if="hasInit || route.query.operationType === '1'"
                     :label="phase.label"
                     :checked="alarmConfigForm.pushOccasions.includes(phase.value)"
                     @change="handlePhaseChange(phase.value, $event)"
-                  >
-                  </el-checkbox>
+                  />
                   <div style="display: inline-block; margin-left: 5px; color: #8c8c8c">
                     <el-tooltip :content="ALARMPHASE_TIPS[phase.value - 1]" placement="top-start">
                       <el-icon size="16px"><InfoFilled /></el-icon>
                     </el-tooltip>
                   </div>
-                  <div
-                    v-if="
-                      alarmConfigForm.pushPhaseVOList.some((it) => it.pushPhase === phase.value)
-                    "
-                  >
+                  <div v-if="alarmConfigForm.pushPhaseVOList.some((it) => it.pushPhase === phase.value)">
                     <div class="push-occasions-card">
                       <div style="margin-bottom: 10px">
                         <PushObject
@@ -90,9 +67,7 @@
                           :disabled="disableAll"
                           @submit-with-form="
                             handlePhaseSubmit(
-                              submitConfigForm.pushPhaseVOList.find(
-                                (it) => it.pushPhase === phase.value,
-                              )!,
+                              submitConfigForm.pushPhaseVOList.find((it) => it.pushPhase === phase.value)!,
                               $event,
                             )
                           "
@@ -125,9 +100,7 @@
         </el-form>
         <div style="text-align: right; margin-right: 32px">
           <el-button :disabled="disableAll" @click="router.back()"> 取 消 </el-button>
-          <el-button :disabled="disableAll" type="primary" @click="debSubmitForm(formRef)">
-            确 定
-          </el-button>
+          <el-button :disabled="disableAll" type="primary" @click="debSubmitForm(formRef)"> 确 定 </el-button>
         </div>
       </div>
       <div class="alarm-config-example">
@@ -225,10 +198,8 @@
       if (!isDevMode.value) {
         const result = res.pushPhaseVOList.find((it) => it.pushPhase === AlarmPhase.effects);
         if (result) {
-          if (result.customUserList)
-            result.customUserList = result.customUserList.map((it) => it.userId);
-          if (result.userGroupList)
-            result.userGroupList = result.userGroupList.map((it) => it.userGroupId);
+          if (result.customUserList) result.customUserList = result.customUserList.map((it) => it.userId);
+          if (result.userGroupList) result.userGroupList = result.userGroupList.map((it) => it.userGroupId);
         }
       }
 
@@ -375,9 +346,8 @@
             submitConfigForm.value.violationLevel = alarmConfigForm.value.violationLevel;
             submitConfigForm.value.pushChannel = alarmConfigForm.value.pushChannel;
             alarmConfigForm.value.pushPhaseVOList.forEach((vo) => {
-              submitConfigForm.value.pushPhaseVOList.find(
-                (it) => it.pushPhase === vo.pushPhase,
-              )!.content = vo.content || REMARK_PLACEHOLDER;
+              submitConfigForm.value.pushPhaseVOList.find((it) => it.pushPhase === vo.pushPhase)!.content =
+                vo.content || REMARK_PLACEHOLDER;
             });
             switch (route.query.operationType) {
               case '1':

+ 8 - 2
src/views/message/components/PushObject.vue

@@ -2,7 +2,12 @@
   <el-form :model="ruleForm" ref="ruleFormRef">
     <el-form-item label="推送对象" prop="recipientType" :rules="[{ required: true, message: '请选择推送对象' }]">
       <el-radio-group v-model="ruleForm.recipientType" :disabled="disabled">
-        <el-radio v-for="item in recipientTypeName" :key="item.value" :value="item.value" :label="item.label" />
+        <el-radio
+          v-for="item in getRecipientTypeName(props.hasAll)"
+          :key="item.value"
+          :value="item.value"
+          :label="item.label"
+        />
       </el-radio-group>
     </el-form-item>
     <div class="userGroupList" v-if="ruleForm.recipientType === 2">
@@ -73,7 +78,7 @@
   import { SelectedFilterPersonInfo } from '@/api/message/person-group';
   import PersonFilterSelection from '@/views/message/components/PersonFilterSelection.vue';
   import Group from './Group.vue';
-  import { recipientTypeName } from '../constant';
+  import { getRecipientTypeName } from '../constant';
   import { ToPushObjectqueryUserGroupList, queryUserGroupDetail } from '@/api/message/person-group';
   import type { FormInstance } from 'element-plus';
   import { GroupData } from '../persongroup/type';
@@ -119,6 +124,7 @@
     userGroupList?: userGroupVOList[];
     customUserList?: customUserList[];
     disabled?: boolean;
+    hasAll?: boolean;
   }>();
   const emit = defineEmits(['submitWithForm']);
   interface Options {

+ 16 - 7
src/views/message/constant.ts

@@ -32,21 +32,30 @@ export const recipientTypeName = [
   { value: 3, label: '自定义' },
 ];
 
+export const getRecipientTypeName = (hasAll?: boolean) => {
+  if (hasAll) {
+    return recipientTypeName;
+  } else {
+    return recipientTypeName.filter((x) => x.value !== 1);
+  }
+};
+
 export const statusName = [
   { value: 0, label: '已推送' },
   { value: 1, label: '未推送' },
 ];
 
 export const messageTypeOptions = [
-  {value: 1, label: 'Banner样式'},
-  {value: 2, label: '文本样式'},
-]
+  { value: 1, label: 'Banner样式' },
+  { value: 2, label: '文本样式' },
+];
 
 export const contentTypeOptinos = [
-  {value: 1, label: '富文本'},
-  {value: 2, label: '链接跳转'},
-]
+  { value: 1, label: '富文本' },
+  { value: 2, label: '链接跳转' },
+];
 
 export const title = '本系统进行了重大升级,请查看详细内容';
 
-export const content = '尊敬的用户:\n    我们计划于2024年9月5日进行平台系统升级,以提升服务性能和用户体验,升级期间,平台将暂时不可用,预计停机时间为4小时,从上午2:00至6:00。请您提前做好相关安排,以避免不便,感谢您的理解与支持。如有疑问,请联系客服支持团队。\n敬请留意。\n天眼团队';
+export const content =
+  '尊敬的用户:\n    我们计划于2024年9月5日进行平台系统升级,以提升服务性能和用户体验,升级期间,平台将暂时不可用,预计停机时间为4小时,从上午2:00至6:00。请您提前做好相关安排,以避免不便,感谢您的理解与支持。如有疑问,请联系客服支持团队。\n敬请留意。\n天眼团队';

+ 31 - 32
src/views/message/sysnotion-config/compontents/BasicInfo.vue

@@ -28,11 +28,7 @@
           :disabled="!pageScopedDisabled"
         />
       </el-form-item>
-      <el-form-item
-        label="Banner图片: "
-        prop="bannerUrl"
-        v-if="ruleForm.messageType === MessageTypeEnum.BANNER"
-      >
+      <el-form-item label="Banner图片: " prop="bannerUrl" v-if="ruleForm.messageType === MessageTypeEnum.BANNER">
         <el-upload
           ref="upload"
           v-model:file-list="fileList"
@@ -81,6 +77,7 @@
         :userGroupList="ruleForm.userGroupList"
         :customUserList="ruleForm.customUserList"
         :disabled="!pageScopedDisabled"
+        :has-all="true"
       />
     </el-form>
   </CardLayout>
@@ -90,9 +87,17 @@
 </template>
 
 <script setup lang="ts">
-import { ref, watch, computed, unref } from 'vue'
-  import { useRoute } from 'vue-router'
-  import type { FormInstance, FormProps, FormRules, UploadProps, UploadUserFile, UploadInstance, UploadRawFile } from 'element-plus';
+  import { ref, watch, computed, unref } from 'vue';
+  import { useRoute } from 'vue-router';
+  import type {
+    FormInstance,
+    FormProps,
+    FormRules,
+    UploadProps,
+    UploadUserFile,
+    UploadInstance,
+    UploadRawFile,
+  } from 'element-plus';
   import { ElMessage, genFileId } from 'element-plus';
   import { Plus } from '@element-plus/icons-vue';
   import PushObject from '../../components/PushObject.vue';
@@ -110,8 +115,8 @@ import { ref, watch, computed, unref } from 'vue'
     isDisabled: boolean;
   }
   const props = defineProps<Props>();
-  const route = useRoute(); 
-  const pageScopedDisabled = computed(() => props.isDisabled === false || route.query.viewModel === 'edit')
+  const route = useRoute();
+  const pageScopedDisabled = computed(() => props.isDisabled === false || route.query.viewModel === 'edit');
   const labelPosition = ref<FormProps['labelPosition']>('left');
   const childFromRef = ref<InstanceType<typeof PushObject>>();
   const actionUrl = computed(() => {
@@ -121,10 +126,7 @@ import { ref, watch, computed, unref } from 'vue'
   /**
    * 表单相关操作
    */
-  type Rule = Omit<
-    RuleFormView,
-    'introduction' | 'contentType' | 'content' | 'contentUrl' | 'operator'
-  >;
+  type Rule = Omit<RuleFormView, 'introduction' | 'contentType' | 'content' | 'contentUrl' | 'operator'>;
   const formRules: FormRules<Rule> = {
     messageType: [{ required: true, trigger: 'change', message: '请选择消息样式' }],
     title: [{ required: true, trigger: 'change', message: '请输入消息标题' }],
@@ -153,9 +155,9 @@ import { ref, watch, computed, unref } from 'vue'
           fileList.value = [
             {
               name: '',
-              url:  value.bannerUrl
+              url: value.bannerUrl,
             },
-          ]
+          ];
         }
       }
     },
@@ -178,12 +180,9 @@ import { ref, watch, computed, unref } from 'vue'
     }
   };
 
-
   const handleAvatarSuccess: UploadProps['onSuccess'] = (response) => {
     // 注意,这里 response 是 没有被拦截处理
     ruleForm.value.bannerUrl = response.data.url;
-    
-
   };
 
   // 上传前限制
@@ -199,20 +198,20 @@ import { ref, watch, computed, unref } from 'vue'
   };
 
   // 图片预览
-  const dialogImageUrl = ref('')
-  const dialogVisible = ref(false)
+  const dialogImageUrl = ref('');
+  const dialogVisible = ref(false);
   const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
-    dialogImageUrl.value = uploadFile.url!
-    dialogVisible.value = true
-  }
+    dialogImageUrl.value = uploadFile.url!;
+    dialogVisible.value = true;
+  };
 
-  const upload = ref<UploadInstance>()
+  const upload = ref<UploadInstance>();
   const handleExceed: UploadProps['onExceed'] = (files) => {
-    upload.value!.clearFiles()
-    const file = files[0] as UploadRawFile
-    file.uid = genFileId()
-    upload.value!.handleStart(file)
-  }
+    upload.value!.clearFiles();
+    const file = files[0] as UploadRawFile;
+    file.uid = genFileId();
+    upload.value!.handleStart(file);
+  };
 
   const buildFromData = () => {
     const childValue = childFromRef.value!.getChildValue();
@@ -230,8 +229,8 @@ import { ref, watch, computed, unref } from 'vue'
   };
 
   const disabledDate = (time: Date) => {
-    return time.getTime() < Date.now()
-  }
+    return time.getTime() < Date.now();
+  };
 
   defineExpose({ validate, buildFromData });
 </script>