Bläddra i källkod

增加消息群发 及 编辑回显群发的逻辑

wenmenghao 2 år sedan
förälder
incheckning
c96da96a94
1 ändrade filer med 28 tillägg och 12 borttagningar
  1. 28 12
      src/views/msgManage/sendingMsg.vue

+ 28 - 12
src/views/msgManage/sendingMsg.vue

@@ -6,10 +6,10 @@
         convertlab用户分组同步
         <Button type="primary" size="small" @click="refreshed" style="margin-left: 40px">刷新分组</Button>
         <div v-show="groupData.length" style="border-bottom: 1px solid #e9e9e9;padding-bottom:6px;margin-bottom:6px;">
-            <!-- <Checkbox
+            <Checkbox
                 :indeterminate="indeterminate"
                 :value="checkAll"
-                @click.prevent.native="handleCheckAll">全选</Checkbox> -->
+                @click.prevent.native="handleCheckAll">全部用户</Checkbox>
         </div>
         <CheckboxGroup v-model="send.userGroupName" @on-change="checkGroup" v-show="groupData.length">
           <Checkbox v-for="item in groupData" :key="item.id" :label="item.name">
@@ -96,10 +96,6 @@ export default {
   },
   created() {
     this.refreshed()
-    let rout = this.$route.query.id
-    if (rout) {
-      this.msgBack()
-    }
   },
   methods: {
     msgBack() {
@@ -110,8 +106,21 @@ export default {
           Object.keys(this.send).forEach(key => {
             this.send[key] = res.data[key]
           })
-          this.send.userGroupId = res.data.send_usergroup_id?res.data.send_usergroup_id.split(','):[]
-          this.send.userGroupName = res.data.send_usergroup_name?res.data.send_usergroup_name.split(','):[]
+          if(res.data.send_usergroup_id === 'all_user'){ //全选
+            this.checkAll = true
+            let arrs = [], arrs1 = []
+            this.groupData.forEach(v => {
+              arrs.push(v.name)
+              arrs1.push(v.id)
+            })
+            this.send.userGroupId = arrs1
+            this.send.userGroupName = arrs
+          } else {
+            this.indeterminate = true
+            this.send.userGroupId = res.data.send_usergroup_id?res.data.send_usergroup_id.split(','):[]
+            this.send.userGroupName = res.data.send_usergroup_name?res.data.send_usergroup_name.split(','):[]
+          }
+          
           this.send.msgType = this.msgPro1[res.data.msg_type - 1].v
           this.send.sendMode = String(res.data.send_mode)
           this.send.sendTime = res.data.send_time
@@ -122,6 +131,8 @@ export default {
     inited() {
       this.$refs.sigleRef3.initd()
       this.isDis = false
+      this.checkAll = false
+      this.indeterminate = false
       Object.keys(this.send).forEach( key => {
         if (key == 'userGroupName') {
           this.send[key] = []
@@ -134,6 +145,9 @@ export default {
       this.$request('/message/getGroup').data().success((res) => {
         if (res.status == 'success') {
           this.groupData = res.data
+          if (this.$route.query.id) {
+            this.msgBack()
+          }
         }
       }).get()
     },
@@ -158,6 +172,7 @@ export default {
           this.send.userGroupName = []
         }
         this.$refs.send.validateField('userGroupName')
+        
     },
     checkGroup(data) {
       const arrs = []
@@ -179,6 +194,7 @@ export default {
           this.indeterminate = false
           this.checkAll = false
       }
+     
     },
     sendDate(val) {
       this.send.sendTime = val
@@ -187,8 +203,8 @@ export default {
       let rout = this.$route.query.id
       let obj = {
         id: rout ? rout : '',
-        userGroupId: String(this.send.userGroupId),
-        userGroupName: String(this.send.userGroupName),
+        userGroupId: this.checkAll ? 'all_user' : String(this.send.userGroupId),
+        userGroupName:this.checkAll ? '全部用户' : String(this.send.userGroupName),
         msgType: Number(this.send.msgType),
         title: this.send.title,
         content: this.send.content,
@@ -256,8 +272,8 @@ export default {
         {v: '6', n: '分析报告'},
         {v: '7', n: '系统通知'}
       ],
-      indeterminate: false,
-      checkAll: false,
+      indeterminate: false, //半选
+      checkAll: false, // 全选
       groupData: [],
       send: {
         userGroupId: [],