MrShi
2024-12-01 d3830805113d4303dcc5aaad671b5167e9b2e188
h5/pages/operation/device.vue
@@ -5,7 +5,7 @@
            <view class="la"><text class="red">*</text>选择设备</view>
            <view class="line">
               <view class="sel_wrap" @click="showModal = true">
                  <view class="left" :class="param.name ? '' : 'placeholder9'">{{ param.name ? param.name : '请选择设备' }}</view>
                  <view class="left" :class="param.deviceName ? '' : 'placeholder9'">{{ param.deviceName ? param.deviceName : '请选择设备' }}</view>
                  <u-icon name="arrow-right" color="#999999" size="17"></u-icon>
               </view>
               <image class="icon" src="@/static/side/scan.png" mode=""></image>
@@ -28,9 +28,9 @@
                  <u-icon name="plus" color="rgb(153, 153, 153)" size="28"></u-icon>
                  <view class="mt6">图片/视频</view>
               </view>
               <view class="upload_file" v-for="(item, i) in dealFileList" :key="i">
               <view class="upload_file" v-for="(item, i) in fileList" :key="i">
                  <u-icon class="close" size="20" name="close-circle-fill" color="red"
                     @click="fileDel('dealBeforeFileList', i)"></u-icon>
                     @click="fileDel('fileList', i)"></u-icon>
                  <image v-if="item.type == 0" :src="item.fileurlFull" mode="widthFix"></image>
                  <video v-if="item.type == 1" :src="item.fileurlFull" :controls="false"></video>
               </view>
@@ -39,13 +39,11 @@
         <view class="item">
            <view class="la">运维备注</view>
            <view class="line">
               <textarea v-model="param.checkInfo" placeholder="请输入" placeholder-class="placeholder9" />
               <textarea v-model="param.content" placeholder="请输入" placeholder-class="placeholder9" />
            </view>
         </view>
      </view>
      <view class="sub_btn">
         提交
      </view>
      <view class="sub_btn" @click="onSubmit">提交</view>
      <!--  -->
      <u-popup :show="showUpload" @close="showUpload = false" closeOnClickOverlay>
         <view class="sel_upload_wrap">
@@ -62,14 +60,12 @@
               <input v-model="searchValue" @confirm="getDevice()" type="text" placeholder="搜索设备名称/编号" placeholder-class="placeholder9" />
            </view>
            <view class="modal_list">
               <view class="item">
                  <view class="name">设备name</view>
                  <image src="@/static/radioed.png" mode=""></image>
               <view class="item" v-for="item,i in deviceList" @click="deviceClick(item)">
                  <view class="name">{{ item.name }}</view>
                  <image v-if="activeDevice.id == item.id" src="@/static/radioed.png" mode=""></image>
               </view>
            </view>
            <view class="sub_btn">
               确定选择
            </view>
            <view class="sub_btn" @click="handleDevice">确定选择</view>
         </view>
      </u-popup>
   </view>
@@ -77,7 +73,9 @@
<script>
   import {
      uploadUrl
      uploadUrl,
      ywDevicePost,
      ywDeviceCreate
   } from '@/api'
   import dayjs from 'dayjs';
   export default {
@@ -86,16 +84,52 @@
            param: {status: 0},
            showUpload: false,
            showModal: false,
            dealFileList: [],
            fileList: [],
            
            searchValue: '',
            deviceList: [],
            activeDevice: {}
         };
      },
      onLoad() {
         this.getDevice()
      },
      methods: {
         getDevice(){
         onSubmit() {
            const { param, fileList } = this
            
            if(!param.deviceId) return this.showToast('请先选择要维护的设备')
            ywDeviceCreate({
               ...param,
               userId: uni.getStorageSync('userInfo').id,
               dealDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
               multifileList: fileList
            }).then(res => {
               this.showToast('提交成功')
               // uni.navigateBack()
            })
         },
         getDevice(){
            ywDevicePost({
               capacity: 9999,
               page: 1,
               model: {
                  name: this.searchValue
               }
            }).then(res => {
               this.deviceList = res.data.records || []
            })
         },
         handleDevice() {
            const { activeDevice } = this
            if(!activeDevice.id) return this.showToast('请先选择设备')
            this.$set(this.param, 'deviceId', activeDevice.id)
            this.$set(this.param, 'deviceName', activeDevice.name)
            this.showModal = false
         },
         deviceClick(item) {
            this.activeDevice = item
            this.$forceUpdate()
         },
         statusChange(val){
            this.param.status = val
@@ -125,7 +159,7 @@
                     files: imgs,
                     name: 'file',
                     formData: {
                        folder: 'HIDDEN_DANGER_FILE'
                        folder: 'YW_DEVICE'
                     },
                     header: {
                        Dm_user_token: token
@@ -137,7 +171,7 @@
                              i.type = 0;
                              i.fileurl = i.imgaddr;
                              i.fileurlFull = i.url;
                              this.submitFileList.push(i);
                              this.fileList.push(i);
                           });
                        }
                     },
@@ -171,7 +205,7 @@
                     },
                     name: 'file',
                     formData: {
                        folder: 'HIDDEN_DANGER_FILE'
                        folder: 'YW_DEVICE'
                     },
                     success: uploadFileRes => {
                        let res = JSON.parse(uploadFileRes.data);
@@ -180,7 +214,7 @@
                              i.type = 1;
                              i.fileurl = i.imgaddr;
                              i.fileurlFull = i.url;
                              this.submitFileList.push(i);
                              this.fileList.push(i);
                           });
                        }
                     },