| | |
| | | <template> |
| | | <div class="inner"> |
| | | <a-alert |
| | | message="管理员身份无法进行短信群发操作" |
| | | banner |
| | | closable |
| | | v-if="userInfo.role.id === 1" |
| | | type="error" |
| | | style="margin-bottom: 12px" |
| | | /> |
| | | <h2>预警信息发布</h2> |
| | | <a-form-model ref="ruleForm" :model="form" :rules="rules" :wrapper-col="wrapperCol"> |
| | | <div class="left"> |
| | |
| | | </a-form-model-item> |
| | | </a-col> |
| | | <a-col :span="12"> |
| | | <div> |
| | | <div style="display:flex;justify-content: space-between;align-items: center;"> |
| | | <b>平级接收人选择:</b> |
| | | <a-checkbox :checked="checkSlAll" @change="checkSlChange"> |
| | | 全选 |
| | | </a-checkbox> |
| | | </div> |
| | | <a-form-model-item prop="recipient"> |
| | | <a-form-model-item> |
| | | <a-select mode="multiple" placeholder="选择平级接收单位" v-model="form.recipient" @change="handle"> |
| | | <a-select-option v-for="item in filteredOptions" :key="item.id" :value="item.id"> |
| | | {{ item.recipientName }} |
| | | {{ item.recipientName }}({{item.company}} {{item.phone}}) |
| | | </a-select-option> |
| | | </a-select> |
| | | </a-form-model-item> |
| | |
| | | <!-- </a-select>--> |
| | | <!-- </div>--> |
| | | <div style="display: flex;justify-content: right"> |
| | | <a-button type="primary" style="width: 250px;" @click="confirmSend()"> |
| | | <a-button type="primary" style="width: 250px;" @click="confirmSend()" :disabled="userInfo.role.id==1?true:false"> |
| | | 确认发送 |
| | | </a-button> |
| | | </div> |
| | |
| | | <h2>短信预览</h2> |
| | | <div class="mobile"> |
| | | <div class="mesg"> |
| | | <P>{{form.content}}发布单位:{{form.publishingUnit}}</P> |
| | | <P>【自然灾害风险预警提示】{{form.content}}发布单位:{{form.publishingUnit}}</P> |
| | | </div> |
| | | |
| | | </div> |
| | |
| | | name: "massSend", |
| | | data() { |
| | | return { |
| | | userInfo: {}, |
| | | userInfo: getUserInfo(), |
| | | department: '自治区自然灾害综合监测预警中心', |
| | | filteredOptions:[], |
| | | wrapperCol: { span: 24 }, |
| | |
| | | horizontalRecipient: [] |
| | | }, |
| | | checkAll: false, |
| | | checkSlAll: false, |
| | | areaUsers: [], |
| | | replaceFields: { |
| | | children:'children', |
| | |
| | | warningLevel: [{ required: true, message: '请选择预警级别', trigger: 'change'}], |
| | | content: [{ required: true, message: '请输入信息内容', trigger: 'blur'}], |
| | | receiver: [{ required: true, message: '请选择接收单位', trigger: 'change'}], |
| | | recipient: [{ required: true, message: '请选择平级接收人', trigger: 'change'}] |
| | | // recipient: [{ required: true, message: '请选择平级接收人', trigger: 'change'}] |
| | | // verticalRecipient: [{ required: true, message: '请选择接收单位', trigger: 'change'}], |
| | | // horizontalRecipient: [{ required: true, message: '请选择平级接收人', trigger: 'change'}] |
| | | } |
| | |
| | | components: {}, |
| | | created() { |
| | | const t = this |
| | | t.userInfo = getUserInfo() |
| | | t.form.publishingUnit = t.userInfo.company |
| | | t.getSameLevel() |
| | | t.getAreaUsers() |
| | |
| | | if(res.data.data){ |
| | | t.filteredOptions = res.data.data |
| | | }else{ |
| | | this.$message.warning('暂无数据'); |
| | | console.log('暂无数据') |
| | | } |
| | | }else{ |
| | | this.$message.warning(res.data.msg); |
| | |
| | | treeD.push(t.findNodeById(res.data.data,t.userInfo.districtId)) |
| | | t.areaUsers = treeD |
| | | }else{ |
| | | this.$message.warning('暂无数据'); |
| | | console.log('暂无数据') |
| | | } |
| | | }else{ |
| | | this.$message.warning(res.data.msg); |
| | |
| | | } |
| | | }, |
| | | |
| | | //选择平级部门部分 |
| | | handle(selectedItems) { |
| | | const t = this |
| | | if(t.form.recipient.length == t.filteredOptions.length){ |
| | | t.checkSlAll = true |
| | | }else{ |
| | | t.checkSlAll = false |
| | | } |
| | | }, |
| | | |
| | | checkSlChange(e) { |
| | | const t = this |
| | | t.checkSlAll = !t.checkSlAll |
| | | if(t.checkSlAll == true){ |
| | | t.form.recipient = t.filteredOptions.map(i=>i.id) |
| | | }else{ |
| | | t.form.recipient = [] |
| | | } |
| | | }, |
| | | |
| | | confirmSend(){ |
| | | this.$refs.ruleForm.validate(valid => { |
| | | if (valid) { |
| | | this.form.verticalRecipient = [] |
| | | this.form.horizontalRecipient = [] |
| | | const aList = this.form.receiver.map(item=>this.findNodeById(this.areaUsers,item.value)?.users) |
| | | if(aList.includes(null)){ |
| | | this.$message.error('选择接收单位时存在无用户的单位') |
| | | return |
| | | } |
| | | const newAList = [].concat(...aList) |
| | | for(let i of newAList){ |
| | | const {realName,...data} = i |
| | | const {realName,id,roleId,...data} = i |
| | | const {company: recipientUnit,...rest} = data |
| | | const obj = {recipientUnit,recipientType:1,...rest} |
| | | this.form.verticalRecipient.push(obj) |
| | | } |
| | | const bList = this.form.recipient.map(item => this.filteredOptions.find(i=>i.id == item)) |
| | | for(let i of bList){ |
| | | const {recipientName: name, company: recipientUnit,...rest} = i |
| | | const obj = {name,recipientUnit,recipientType:2,...rest} |
| | | this.form.horizontalRecipient.push(obj) |
| | | if(this.form.recipient.length>0){ |
| | | const bList = this.form.recipient.map(item => this.filteredOptions.find(i=>i.id == item)) |
| | | for(let i of bList){ |
| | | const {recipientName: name, company: recipientUnit,...rest} = i |
| | | const obj = {name,recipientUnit,recipientType:2,...rest} |
| | | const {id,...noId} = obj |
| | | this.form.horizontalRecipient.push(noId) |
| | | } |
| | | } |
| | | const {receiver,recipient,...data} = this.form |
| | | massSend(data).then( res =>{ |
| | |
| | | this.$message.success('信息群发成功') |
| | | this.$refs.ruleForm.clearValidate() |
| | | this.$refs.ruleForm.resetFields() |
| | | this.form.recipient = [] |
| | | |
| | | }else{ |
| | | this.$message.error(res.data.msg) |
| | | this.$refs.ruleForm.clearValidate() |
| | |
| | | handleLevel(selectedItems) { |
| | | // this.selectedItems = selectedItems; |
| | | }, |
| | | handle(selectedItems) { |
| | | // this.selectedItems = selectedItems; |
| | | }, |
| | | onChange(){ |
| | | console.log(this.value) |
| | | }, |
| | |
| | | traverseTree(treeData) { |
| | | let result = []; |
| | | function traverse(node) { |
| | | result.push({ label: node.name, value: node.id }); |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | traverse(child); |
| | | if(node.users && node.users.length>0){ |
| | | result.push({ label: node.name, value: node.id }); |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | traverse(child); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | userTitTree(treeData) { |
| | | for(const node of treeData){ |
| | | if(node.users){ |
| | | node.name = node.name + '('+node.users.map(i=>i.name +' '+ i.phone).join(',')+')' |
| | | node.name = node.name + '('+node.users.map(i=>i.realName +' '+ i.phone).join(',')+')' |
| | | } |
| | | if(node.children){ |
| | | this.userTitTree(node.children) |