智慧保安互联网APP
shuishen
2021-10-11 b48a5f64fe196bee6f1c7eb0be1b78c9ebec0860
pages/dispatch/imgissue.vue
@@ -1,20 +1,47 @@
<template>
   <view class="container">
      <view class='initiae-box'>
      <view class="group-chat-box">
         <u-form :model="form" ref="uForm">
            <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='158' 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-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='184' label="指令相关图片" class='imgissue-upload'>
@@ -24,13 +51,19 @@
            </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>
@@ -48,7 +81,7 @@
            form: {
               content: '',
               recipient: '',
               recipientText: ''
               recipientData: []
            },
            rules: {
@@ -58,11 +91,7 @@
                  message: '指令内容不能少于5个字',
                  trigger: ['change', 'blur'],
               }],
               recipientText: [{
                  required: true,
                  message: '请选择接收人',
                  trigger: ['change', 'blur'],
               }],
            },
            imgs: [],
         };
@@ -78,39 +107,33 @@
      methods: {
         recipientClick() {
            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) {
                  res.data.data.forEach(item => {
                     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 +145,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,11 +175,11 @@
                     },
                     success: (res) => {
                        if (res.data.msg == "操作成功") {
                        if (res.data.msg.indexOf('成功') != -1) {
                           this.$refs.uToast.show({
                              title: '指令下发成功',
                              type: 'success',
                              url: '/pages/home/home'
                              url: '/pages/dispatch/dispatch'
                           })
                        }
                     }
@@ -206,13 +245,57 @@
               }
            });
         },
         checkboxGroupChange(e) {
            this.form.recipientData = e
         },
      }
   };
</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>