智慧保安互联网APP
zengh
2022-06-21 4efeb31d5b4921d7e851c256009486ad86bc70e2
pages/dispatch/imgissue.vue
@@ -1,36 +1,72 @@
<template>
   <view class="container">
      <view class='initiae-box'>
      <view class="group-chat-box">
         <u-form :model="form" ref="uForm">
            <u-form-item label-width='180' prop="content" label="指令内容" :required="true">
            <u-form-item label-width='132' prop="content" label="指令内容" :required="true">
               <u-input type='textarea' v-model="form.content" placeholder="请输入指令内容" />
            </u-form-item>
            <u-form-item label-width='180' prop="recipientText" label="指令接收人" :required="true">
               <u-input v-model="form.recipientText" type="select" placeholder="请选择接收人" :border="false"
                  @click="recipientClick" />
               <u-select v-model="recipientShow" mode="mutil-column-auto" :list="recipientList"
                  @confirm="recipientConfirm">
               </u-select>
            <u-form-item label-width='158' prop="recipientText" label="指令接收人" :required="true">
               <u-input type='textarea' v-model="form.recipientPeople" placeholder="请选择指令接收人"
                  @click="recipientClick" autoHeight  />
               <!-- <u-button slot="right" type="success" size="mini" @click="recipientClick">选择接收人</u-button> -->
               <u-popup :closeable="true" v-model="recipientShow" mode="bottom" height="50%" border-radius="14">
                  <view>
                     <u-checkbox-group v-show="recipientList.length > 0" @change="checkboxGroupChange"
                        :wrap='true' :size="40">
                        <u-checkbox v-model="item.checked" v-for="(item, index) in recipientList" :key="index"
                           :name="item.id" shape="circle"
                           style="padding: 0 40rpx; height: 92rpx; position: relative; box-sizing: border-box;">
                           <view style="margin-left: 22rpx">
                              {{item.real_name}}
                           </view>
                        </u-checkbox>
                     </u-checkbox-group>
                     <view style=" height: 92rpx; padding: 0 40rpx;" v-show="recipientList.length == 0">
                        暂无数据
                     </view>
                  </view>
               </u-popup>
            </u-form-item>
            <u-form-item label-width='180' label="指令相关图片" class='imgissue-upload'>
            <u-form-item label-width='184' label="指令相关图片" class='imgissue-upload'>
               <seeImgs :imgs="imgs" :videos="[]" @del="delImg" :type="'imgs'"></seeImgs>
               <image style="width: 4rem; height: 4rem; display: block;" @tap="takePhoto"
                  src="../../static/images/upload.png" mode=""></image>
            </u-form-item>
         </u-form>
         <view>
            <u-button type="primary" @click="initiateClick" style="margin-top: 4%; width: 60%;">发送</u-button>
         </view>
         <view>
            <u-toast ref="uToast" />
         </view>
      </view>
      <view class="establish-box">
         <u-button class="submit" type="primary" @click="initiateClick">发送</u-button>
      </view>
      <view>
         <u-toast ref="uToast" />
      </view>
   </view>
</template>
@@ -44,11 +80,11 @@
         return {
            recipientShow: false,
            recipientList: [],
            form: {
               content: '',
               recipient: '',
               recipientText: ''
               recipientData: [],
               recipientPeople: ''
            },
            rules: {
@@ -58,11 +94,7 @@
                  message: '指令内容不能少于5个字',
                  trigger: ['change', 'blur'],
               }],
               recipientText: [{
                  required: true,
                  message: '请选择接收人',
                  trigger: ['change', 'blur'],
               }],
            },
            imgs: [],
         };
@@ -77,40 +109,48 @@
      },
      methods: {
         recipientClick() {
            if (this.recipientList.length > 0) {
               this.recipientShow = true;
               return;
            }
            uni.request({
               url: this.$store.state.piAPI + "/blade-system/dept/lazy-tree-user-app?userId=" + this.$store
                  .state
                  .UserData.user_id,
               url: this.$store.state.piAPI + "/blade-user/seleL",
               method: "get",
               data: {
                  type: 1,
                  jurisdiction: this.$store.state
                     .UserData.jurisdiction,
               },
               success: (res) => {
                  this.recipientList = []
                  res.data.forEach(item => {
                     if (item.hasChildren) {
                        this.recipientList.push(item)
                  res.data.data.forEach(item => {
                     var flag = true
                     if (this.recipientList.length > 0) {
                        this.recipientList.forEach(it => {
                           if (item.id == it.id) flag = false
                        })
                     }
                     if (flag == true) {
                        if (item.id != this.$store.state
                           .UserData.user_id
                        ) {
                           item.checked = false;
                           this.recipientList.push(item)
                        }
                     }
                  })
                  this.recipientShow = true;
               }
            });
         },
         recipientConfirm(e) {
            if (e.length == 1) {
               this.form.recipient = e[0].value
               this.form.recipientText = e[0].label
            } else if (e.length == 2) {
               this.form.recipient = e[1].value
               this.form.recipientText = e[1].label
            } else if (e.length == 3) {
               this.form.recipient = e[2].value
               this.form.recipientText = e[2].label
            }
         },
         initiateClick() {
            var imgurl = '';
            this.imgs.forEach((item, index) => {
@@ -122,12 +162,28 @@
            })
            this.$refs.uForm.validate(valid => {
               if (valid) {
                  if (this.form.recipientData.length == 0) {
                     this.$refs.uToast.show({
                        title: '请最少选择一个接收人',
                     })
                     return
                  }
                  var str = '';
                  this.form.recipientData.forEach(item => {
                     str += item + ','
                  })
                  str = str.substr(0, str.length - 1);
                  uni.request({
                     url: this.$store.state.piAPI + "/directive/saveDirectiveAndFile",
                     method: "post",
                     data: {
                        // 接收
                        receiveDirectiveIds: this.form.recipient,
                        receiveDirectiveIds: str,
                        // 发送
                        sendDirectiveId: this.$store.state
                           .UserData.user_id,
@@ -136,7 +192,7 @@
                     },
                     success: (res) => {
                        if (res.data.msg == "操作成功") {
                        if (res.data.msg.indexOf('成功') != -1) {
                           this.$refs.uToast.show({
                              title: '指令下发成功',
                              type: 'success',
@@ -206,13 +262,78 @@
               }
            });
         },
         checkboxGroupChange(e) {
            var that = this
            this.form.recipientData = e
            var str = ""
            var num = 0
            that.form.recipientData.forEach((item, index) => {
               that.recipientList.forEach((it, index) => {
                  if (item == it.id) {
                     if (num > 0) {
                        str += '、';
                        str += it.real_name;
                     } else {
                        str += it.real_name
                     }
                     num += 1
                     return
                  }
               })
            })
            this.form.recipientPeople = str
         },
      }
   };
</script>
<style lang="scss">
   .initiae-box {
      padding: 0 30rpx;
   .submit {
      border: none;
      width: 94%;
      height: 86rpx;
      line-height: 86rpx;
      box-sizing: border-box;
      border-radius: 15rpx;
      color: #ffffff;
      font-size: 38rpx;
   }
   .container {
      height: 100%;
      .group-chat-box {
         height: calc(100% - 116rpx);
         padding: 0 36rpx;
         box-sizing: border-box;
         overflow-y: auto;
      }
      .establish-box {
         position: relative;
         height: 116rpx;
         background: #fff;
         text-align: center;
         uni-button {
            margin: 0;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
         }
      }
   }
</style>