zhouwenxuan
2024-02-06 6efbb509b876e5e4ec634efa8820bd7b288c2283
src/views/Admin/notice.vue
@@ -78,7 +78,7 @@
                  </a-form-model-item>
               </a-col>
            </a-row>
            <span><b>发布单位:</b>{{form.publishingUnit}}</span>
<!--            <span><b>发布单位:</b>{{form.publishingUnit}}</span>-->
            <br /><br />
            <!-- 子单位-->
            <a-row :gutter="24">
@@ -110,12 +110,22 @@
                     </a-checkbox>
                  </div>
                  <a-form-model-item prop="recipient">
                     <a-select mode="multiple" placeholder="选择平级接收单位" v-model="form.recipient" @change="handle"
                        :maxTagCount="3">
                        <a-select-option v-for="item in filteredOptions" :key="item.id" :value="item.id">
                           {{ item.recipientName }}({{item.company}} {{item.phone}})
                        </a-select-option>
                     </a-select>
<!--                     <a-select mode="multiple" placeholder="选择平级接收单位" v-model="form.recipient" @change="handle"-->
<!--                        :maxTagCount="3">-->
<!--                        <a-select-option v-for="item in filteredOptions" :key="item.id" :value="item.id">-->
<!--                           {{ item.recipientName }}({{item.company}} {{item.phone}})-->
<!--                        </a-select-option>-->
<!--                     </a-select>-->
              <a-tree-select
                  v-model="form.recipient"
                  style="width: 100%"
                  :tree-data="treeData"
                  tree-checkable
                  placeholder="选择平级接收单位"
                  :show-checked-strategy="SHOW_PARENT"
                  search-placeholder="Please select"
                  @change="handle"
              />
                  </a-form-model-item>
               </a-col>
            </a-row>
@@ -130,7 +140,7 @@
                  </a-form-model-item>
               </a-col>
               <a-col :span="12" style="text-align: right">
                  <a-button type="primary" style="width: 250px;" @click="confirmSend()"
                  <a-button type="primary" style="width: 250px;" @click="confirmSend()" v-preventReClick="1500"
                     :disabled="userInfo.role.id==1?true:false">
                     确认并提交审核
                  </a-button>
@@ -141,7 +151,7 @@
            <h2>短信预览</h2>
            <div class="mobile">
               <div class="mesg">
                  <P>【自然灾害风险预警提示】{{form.content}}<br>发布单位:{{form.publishingUnit}}</P>
                  <P>【自然灾害风险预警提示】{{form.content}}</P>
               </div>
            </div>
         </div>
@@ -166,10 +176,16 @@
   import {
      deleteFile
   } from "@/api/list";
  import { TreeSelect } from 'ant-design-vue';
  const SHOW_PARENT = TreeSelect.SHOW_PARENT;
  const treeData = [];
   export default {
      name: "notice",
      data() {
         return {
        value: [],
        SHOW_PARENT,
        treeData,
            userInfo: {},
            unittype: null,
            wrapperCol: {
@@ -211,15 +227,11 @@
                  value: 1
               },
               {
                  name: '洪涝',
                  value: 2
               },
               {
                  name: '气象',
                  value: 3
               },
               {
                  name: '泥石流',
                  name: '地质灾害',
                  value: 4
               },
               {
@@ -305,6 +317,8 @@
      components: {},
      created() {
         const t = this
      t.getAreaUsers()
      t.areaUsers = JSON.parse(localStorage.getItem('areaUsers'))
         const {
            baseUrl
         } = require('../../../config/env.' + process.env.NODE_ENV)
@@ -314,7 +328,6 @@
         t.form.districtId = t.userInfo.districtId
         t.form.publishingUnit = t.userInfo.company
         t.getSameLevel()
         t.getAreaUsers()
         t.getLeaders()
      },
      computed: {},
@@ -325,7 +338,25 @@
            let res = await getPeerRecipient()
            if (res.data.code == 100) {
               if (res.data.data) {
                  t.filteredOptions = res.data.data
                  // t.filteredOptions = res.data.data
            for (const resKey in res.data.data) {
              t.filteredOptions = t.filteredOptions.concat(...res.data.data[resKey]);
              console.log('t.filteredOptions',t.filteredOptions)
              const obj = {
                  title: resKey,
                  value: resKey,
                  key: resKey,
                  children: res.data.data[resKey].map(item => {
                    return {
                      title: item.recipientName + '(' +item.company +item.phone+ ')',
                      value: item.id,
                      key: item.id,
                    }
                  })
              }
              t.treeData.push(obj);
            }
               } else {
                  console.log('暂无数据')
               }
@@ -340,11 +371,9 @@
            let res = await getAreaWithUserIfo()
            if (res.data.code == 100) {
               if (res.data.data) {
                  // const treeD = []
                  t.userTitTree(res.data.data)
                  // treeD.push(t.findNodeById(res.data.data,t.userInfo.districtId))
                  const treeD = t.findNodeById(res.data.data, t.userInfo.districtId)
                  t.areaUsers = treeD.children
                  // t.areaUsers = treeD.children
                  t.unittype = treeD.type
               } else {
                  console.log('暂无数据')
@@ -389,18 +418,25 @@
         //选择平级部门部分
         handle(selectedItems) {
            const t = this
            if (t.form.recipient.length == t.filteredOptions.length) {
               t.checkSlAll = true
            } else {
               t.checkSlAll = false
            }
            // if (t.form.recipient.length == t.filteredOptions.length) {
            //    t.checkSlAll = true
            // } else {
            //    t.checkSlAll = false
            // }
        const group = t.treeData.map(item => item.value)
        if (group.length === t.form.recipient.length && group.every((v,i) => v === t.form.recipient[i])) {
          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)
               // t.form.recipient = t.filteredOptions.map(i => i.id)
          t.form.recipient = t.treeData.map(item => item.value)
            } else {
               t.form.recipient = []
            }
@@ -483,7 +519,6 @@
               if (valid) {
                  this.form.acceptingUnitIds = []
                  this.form.peerRecipientIds = []
                  const aList = this.form.receiver.map(item => this.findNodeById(this.areaUsers, item.value)
                     ?.users)
                  if (aList.includes(null)) {
@@ -499,6 +534,7 @@
                        phone: recipienterPhone,
                        company: receiveUnit,
                        realName: recipienterRealName,
                registrationId: registrationId,
                        ...rest
                     } = i
                     const obj = {
@@ -507,6 +543,7 @@
                        recipienterRealName,
                        recipienterPhone,
                        receiveUnit,
                registrationId,
                        ...rest
                     }
                     this.form.acceptingUnitIds.push(obj)
@@ -543,6 +580,7 @@
                     ...data
                  } = this.form
                  msgSend(data).then(res => {
                     if (res.data.code == 100) {
                        this.deleteFile()
                        this.$message.success('信息已提交审核')
@@ -687,4 +725,4 @@
      }
   }
</style>
</style>