Quellcode durchsuchen

完成pushobject组件

chauncey vor 1 Jahr
Ursprung
Commit
50dafb84aa

+ 34 - 6
src/views/message/components/PushObject.vue

@@ -5,7 +5,7 @@
       prop="recipientType"
       :rules="[{ required: true, message: '请选择推送对象' }]"
     >
-      <el-radio-group v-model="ruleForm.recipientType">
+      <el-radio-group v-model="ruleForm.recipientType" :disabled="disabled">
         <el-radio
           v-for="item in recipientTypeName"
           :key="item.value"
@@ -25,6 +25,7 @@
           multiple
           placeholder="请选择分组"
           style="width: 300px"
+          :disabled="disabled"
         >
           <el-option
             v-for="item in options"
@@ -54,6 +55,7 @@
           placeholder="请选择人员"
           style="width: 300px"
           @click="userInfo = true"
+          :disabled="disabled"
         >
           <el-option v-for="user in selectedUser" :key="user.id" :label="user.name" :value="user">
           </el-option>
@@ -147,6 +149,21 @@ import { GroupData } from '../persongroup/type';
 const ruleFormRef = ref<FormInstance>();
 const groupInfo = ref<boolean>(false);
 const userInfo = ref<boolean>(false);
+const disabled = ref<boolean>(false);
+interface customUserList {
+  userId: number;
+  userLoginName: string;
+  userNickname: string;
+  userNumber: string;
+}
+interface userGroupVOList {
+  userGroupId: number;
+  total: number;
+  operatorName: string;
+  operationTime: string;
+  name: string;
+  description: string;
+}
 interface UserList {
   id: string;
   name: string;
@@ -164,8 +181,9 @@ const ruleForm = reactive<RuleForm>({
 });
 const props = defineProps<{
   recipientType?: number;
-  userGroupList?: number[];
-  customUserList?: UserList[];
+  userGroupList?: userGroupVOList[];
+  customUserList?: customUserList[];
+  disabled?: boolean;
 }>();
 interface Options {
   userGroupId?: number;
@@ -203,6 +221,13 @@ const handleSubmit = (selectedData: UserList[]) => {
   ruleForm.customUserList = selectedUser.value;
   userInfo.value = false;
 };
+const formatCustomUserList = (customList: customUserList[]): UserList[] => {
+  return customList.map((item) => ({
+    id: `u${item.userId}`,
+    userId: item.userId,
+    name: `${item.userLoginName}-${item.userNickname}`,
+  }));
+};
 defineExpose({
   submitForm,
   getChildValue,
@@ -217,11 +242,14 @@ watchEffect(() => {
     ruleForm.recipientType = props.recipientType;
   }
   if (props.userGroupList) {
-    ruleForm.userGroupList = props.userGroupList;
+    ruleForm.userGroupList = props.userGroupList.map((item) => item.userGroupId);
   }
   if (props.customUserList) {
-    ruleForm.customUserList = props.customUserList;
-    selectedUser.value = props.customUserList;
+    ruleForm.customUserList = formatCustomUserList(props.customUserList);
+    selectedUser.value = formatCustomUserList(props.customUserList);
+  }
+  if (props.disabled) {
+    disabled.value = props.disabled;
   }
 });
 watch(

+ 16 - 4
src/views/message/sysnotion-config/SysnotionConfig.vue

@@ -164,13 +164,22 @@ const useUser = useUserStore();
 const { info } = storeToRefs(useUser);
 const labelPosition = ref<FormProps['labelPosition']>('left');
 interface UserList {
-  id: string;
-  name: string;
   userId: number;
+  userLoginName:string;
+  userNickname:string;
+  userNumber:string;
+}
+interface GroupList {
+  userGroupId:number;
+  total:number;
+  operatorName:string;
+  operationTime:string;
+  name:string;
+  description:string;
 }
 interface ObjectFrom {
   recipientType?: number;
-  userGroupList?: number[];
+  userGroupList?: GroupList[];
   customUserList?: UserList[];
 }
 interface RuleForm {
@@ -184,7 +193,10 @@ const ruleForm = reactive<RuleForm>({
   title: '',
   content: '',
   channel: [],
-  object: {},
+  object: {
+    recipientType:2,
+    userGroupList:[{description:"",name:"Test2",operationTime:"2024-09-12 11:23:52",operatorName:"admin",total:36,userGroupId:39},{description:"",name:"Test",operationTime:"2024-09-12 10:34:30",operatorName:"admin",total:39,userGroupId:38}]
+  },
   operator: info.value.nickname,
 });
 const activeName = ref('platform');