Houjie
2025-05-15 1833dd6d7cac01c35840af52fadc1199821e5805
pages/ToDoList/ToDoListCheckSure/ToDoListCheckSure.vue
@@ -5,11 +5,23 @@
         <block slot="content">{{title}}</block>
      </cu-custom>
      <view class="container">
         <template>
            <!-- 浮窗遮罩层 -->
            <view v-if="showPreview" class="overlay" @tap.stop="closePreview">
               <view class="modal">
                  <!-- 关闭按钮 -->
                  <text class="close-btn" @tap.stop="showPreview = false">&times;</text>
                  <!-- 图片展示 -->
                  <image :src="previewImageSrc" mode="aspectFit" class="preview-image" />
               </view>
            </view>
         </template>
         <uni-forms ref="form" :modelValue="formData" validate-trigger="bind" err-show-type="undertext">
            <uni-group top="1">
               <view class="text-gray margin-bottom-lg">—————————— 基本信息 ——————————</view>
               <view class="divider"><text>基本信息</text></view>
               <!-- <view class="text-gray margin-bottom-lg">—————————— 基本信息 ——————————</view> -->
               <uni-forms-item :label-width="80" name="num" label="工单号:">
                  <uni-easyinput v-model="formData.orderNum" :disabled="true" />
               </uni-forms-item>
@@ -25,24 +37,18 @@
                  <uni-easyinput v-model="formData.operator" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item :label-width="80" name="outNum" label="点检图片:">
                  <view class="grid col-4 grid-square flex-sub">
                     <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage"
                        :data-url="imgList[index]">
                        <image :src="imgList[index]" mode="aspectFill"></image>
                        <view class="cu-tag bg-red radius" @tap.stop="DelImg" :data-index="index">
                           <text class='cuIcon-close'></text>
                        </view>
                     </view>
                     <view class="solids" v-if="imgList.length<1">
                        <text class='cuIcon-cameraadd'></text>
                     </view>
                  </view>
                  <uni-file-picker limit="9" :value="fileLists" :image-styles="imageStyles"
                     :sourceType="sourceType" @select="select" @progress="progress" @success="success"
                     @fail="fail" @delete="deletea" :readonly="readonly" />
               </uni-forms-item>
               <uni-forms-item name="outNum" :label-width="80" label="作业指导:">
                  <button class="cu-btn  bg-blue" @tap="showPreview = true">查看</button>
               </uni-forms-item>
            </uni-group>
         </uni-forms>
         <view class="text-gray margin-bottom-lg">—————————— 保养项信息 ——————————</view>
         <!-- <view class="text-gray margin-bottom-lg">—————————— 保养项信息 ——————————</view> -->
         <view class="divider"><text>保养项信息</text></view>
         <uni-collapse>
            <uni-collapse-item :show-animation="true" :accordion="true" title="查看保养项" :border="false"
               title-border="none">
@@ -63,13 +69,24 @@
                  <view class="flex">
                     <view class="flex-sub text-light bg-white  padding-xs margin-xs radius">保养要求:</view>
                     <view class="flex-sub bg-white padding-xs margin-xs radius text-right"
                     <view class="flex-sub bg-white padding-xs margin-xs radius text-right">
                        {{item.itemDemand}}
                     </view>
                     <!-- <view class="flex-sub bg-white padding-xs margin-xs radius text-right"
                        v-if="item.itemDemand!=null && item.itemDemand.length>10">
                        {{(item.itemDemand).toString().substr(0,10)+'...'}}
                     </view>
                     <view class="flex-sub bg-white padding-xs margin-xs radius text-right" v-else>
                        {{item.itemDemand}}
                     </view> -->
                  </view>
                  <view class="flex">
                     <view class="flex-sub text-light bg-white  padding-xs margin-xs radius">点检结果:</view>
                     <view class="flex-sub bg-white padding-xs     text-right margin-xs radius">
                        <uni-data-select :localdata="item.restle" v-model="item.inspectionResult"
                           @change="handleCode($event, index)" :disabled="item.istrue" />
                     </view>
                  </view>
                  <view class="flex">
@@ -79,13 +96,7 @@
                           :disabled="item.istrue" />
                     </view>
                  </view>
                  <view class="flex">
                     <view class="flex-sub text-light bg-white  padding-xs margin-xs radius">点检结果:</view>
                     <view class="flex-sub bg-white padding-xs     text-right margin-xs radius">
                        <uni-data-select :localdata="item.restle" v-model="item.inspectionResult"
                           @change="handleCode($event, index)" :disabled="item.istrue" />
                     </view>
                  </view>
                  <view class="flex">
                     <view class="flex-sub text-light bg-white  padding-xs margin-xs radius">异常描述:</view>
@@ -98,9 +109,11 @@
         </uni-collapse>
         <uni-forms  v-show="isShowTeam" ref="form" :modelValue="ScanData" validate-trigger="bind" err-show-type="undertext">
         <uni-forms v-show="isShowTeam" ref="form" :modelValue="ScanData" validate-trigger="bind"
            err-show-type="undertext">
            <uni-group top="1">
               <view class="text-gray margin-bottom-lg">—————————— 班组长确认信息 ——————————</view>
               <view class="divider"><text>班组长确认信息</text></view>
               <!-- <view class="text-gray margin-bottom-lg">————————班组长确认信息——————————</view> -->
               <uni-forms-item :label-width="80" required name="typeName" label="处理类型:">
                  <uni-data-select v-model="ScanData.typeName" :localdata="ScanData.handlingType"
                     @change="changehandlingType" placeholder="请选择" :disabled="isTouch" />
@@ -128,9 +141,19 @@
      mixins: [MescrollMixin], // 使用mixin
      data() {
         return {
            isShowTeam:false,
            showPreview: false,
            readonly: false,
            // 图片回显
            fileLists: [],
            // 上传图片的样式
            imageStyles: {
               width: 90,
               height: 90,
            },
            sourceType: ['album', 'camera'],
            isShowTeam: false,
            isShowBtn: true,
            title: '班组长确认',
            title: '',
            isTouch: false,
            scrollLeft: 0,
            searchValue: '',
@@ -165,7 +188,7 @@
            url: {
               upload: "/eam/sysFiles/batch_upload",
               stallList: "/eam/eamInspectionOrder/queryById",
               // getEquipmentList: "eam/equipment/asyncLoadEquipment",
               getStandardFile: "eam/maintenanceStandard/queryById",
               getEquipmentList: 'eam/equipment/list',
               BaoList: 'eam/eamInspectionOrderDetail/queryList',
               approval: 'eam/eamInspectionOrder/approval'
@@ -196,7 +219,10 @@
            msg2Count: 0,
            msg1Title: "",
            procInstId: '',
            values: ''
            values: '',
            flag: '',
            standardId: '',
            previewImageSrc: ''
         }
@@ -214,11 +240,13 @@
      },
      onLoad(options) {
         const annItem = JSON.parse(decodeURIComponent(options.item));
         this.id = annItem.dataId,
            this.taskId = annItem.id,
            this.procInstId = annItem.procInstId,
            this.values = annItem.values,
            this.assignee = annItem.assignee
         this.flag = options.flag
         console.log(this.flag)
         this.id = annItem.dataId
         this.taskId = annItem.id
         this.procInstId = annItem.procInstId
         this.values = annItem.values
         this.assignee = annItem.assignee
      },
      created() {
@@ -231,27 +259,39 @@
         changehandlingType(e) {
            this.ScanData.typeName = e;
         },
         closePreview() {
            this.showPreview = false;
         },
         ProductionTask() {
            if (this.hasInspectionDateArrived()) {
               if (this.ScanData.typeName == undefined || this.ScanData.typeName == null || this.ScanData.typeName ==
                  '') {
               if (this.formData.inspectionStatus == 'WAIT_CONFIRM' && this.flag != 'task') {
                  if (this.ScanData.typeName == undefined || this.ScanData.typeName == null || this.ScanData
                     .typeName ==
                     '') {
                  uni.showToast({
                     icon: 'none',
                     title: '处理类型不能为空'
                  });
                  return false;
               }
               if (this.ScanData.handlingSuggestion == undefined || this.ScanData.handlingSuggestion == null || this
                  .ScanData.handlingSuggestion ==
                  '') {
                     uni.showToast({
                        icon: 'none',
                        title: '处理类型不能为空'
                     });
                     return false;
                  }
                  if (this.ScanData.handlingSuggestion == undefined || this.ScanData.handlingSuggestion == null ||
                     this
                     .ScanData.handlingSuggestion ==
                     '') {
                  uni.showToast({
                     icon: 'none',
                     title: '处理意见不能为空'
                  });
                  return false;
                     uni.showToast({
                        icon: 'none',
                        title: '处理意见不能为空'
                     });
                     return false;
                  }
               }
               uni.showLoading({
                  mask: true,
                  title: "加载中....",
               })
               this.$http.post(this.url.approval, {
                  /**
                   * 确认意见
@@ -269,8 +309,7 @@
                  userId: this.assignee,
                  values: this.values
               }).then(res => {
                  console.log(res)
                  this.$tip.loaded();
                  uni.hideLoading();
                  if (res.data.success) {
                     uni.showToast({
                        icon: "success",
@@ -342,23 +381,6 @@
               this.$tip.error("联网失败")
            })
         },
         // getEquipment() {
         //    this.$http.get(this.url.getEquipmentList).then(res => {
         //       //设置列表数据
         //       if (res.data.success) {
         //          this.equipmentList = res.data.result
         //       } else {
         //          uni.showToast({
         //             icon: "error",
         //             title: res.data.message,
         //             duration: 2000
         //          });
         //       }
         //    }).catch(() => {
         //       this.$tip.error("联网失败")
         //    })
         // },
         getList() {
            this.$http.get(this.url.BaoList, {
               params: {
@@ -399,76 +421,37 @@
               //联网失败, 结束加载
            })
         },
         ChooseImage() {
            var that = this;
            uni.chooseImage({
               count: 4,
               sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
               sourceType: ['album'], // 从相册选择
               success: (res) => {
                  // 存储选择的图片路径
                  that.imgList = res.tempFilePaths;
                  // 初始化 formData.avatar 为空字符串
                  // 初始化 formData.avatar 为空字符串
                  that.formData.avatar = [];
                  // 创建上传任务的 Promise 数组
                  const uploadPromises = res.tempFilePaths.map((filePath, index) => {
                     return new Promise((resolve, reject) => {
                        that.$http.upload(that.url.upload, {
                              filePath: filePath,
                              name: 'file'
                           })
                           .then(uploadRes => {
                              // 假设服务器返回的结果中包含文件路径
                              const filePath = uploadRes.data.result[0];
                              this.formData.avatar.push(filePath);
                              console.log(this.formData.avatar)
                              resolve(filePath);
                           })
                           .catch(err => {
                              console.error('图片' + index + '上传失败:', err);
                              reject(err);
                           });
                     });
                  });
                  // 并发执行所有上传任务
                  Promise.all(uploadPromises)
                     .then((uploadedFilePaths) => {
                        console.log('所有图片上传成功:', that.formData.avatar);
                     })
                     .catch((err) => {
                        console.error('图片上传失败:', err);
                        that.$tip.error('图片上传失败');
                     });
         getStandardFile() {
            this.$http.get(this.url.getStandardFile, {
               params: {
                  id: this.standardId
               }
            });
         },
         ViewImage(e) {
            uni.previewImage({
               urls: this.imgList,
               current: e.currentTarget.dataset.url
            });
         },
         DelImg(e) {
            uni.showModal({
               title: '提示',
               content: '确定要删除这段回忆吗?',
               cancelText: '再看看',
               confirmText: '再见',
               success: res => {
                  if (res.confirm) {
                     this.imgList.splice(e.currentTarget.dataset.index, 1)
            }).then(res => {
               if (res.data.success) {
                  console.log("res", res.data.result);
                  const referenceFileStr = res.data.result.referenceFile;
                  // 判断是否存在 referenceFile 并进行解析
                  if (referenceFileStr) {
                     try {
                        const referenceFileObj = JSON.parse(referenceFileStr);
                        const filePath = `${this.ipAndPort}${referenceFileObj.filePath}`;
                        this.previewImageSrc = filePath;
                        console.log('previewImageSrc:', this.previewImageSrc);
                     } catch (e) {
                        console.error("referenceFile 解析失败", e);
                        this.previewImageSrc = '';
                     }
                  } else {
                     console.warn("referenceFile 不存在");
                     this.previewImageSrc = '';
                  }
               }
            })
            }).catch(err => {
               console.error("网络请求失败", err);
               // 联网失败, 结束加载
            });
         },
         upCallback() {
            this.$http.get(this.url.stallList, {
               params: {
@@ -489,17 +472,39 @@
                  this.ScanData.typeName = this.announcement1.confirmDealType
                  this.formData.confirmComment = this.announcement1.confirmDealType_dictText
                  this.ScanData.handlingSuggestion = this.announcement1.confirmComment
                  if (this.announcement1.standardId !== null) {
                     this.standardId = this.announcement1.standardId
                     this.getStandardFile()
                  }
                  if (this.formData.inspectionStatus == 'COMPLETE') {
                     this.title = '详情'
                     this.isTouch = true
                     this.isShowTeam=true
                     this.isShowBtn = false
                     if (this.flag == 'task') {
                        this.title = '班组长确认'
                        this.isTouch = true
                        this.readonly = true
                        this.isShowTeam = true
                        this.isShowBtn = false
                     }
                  } else if (this.formData.inspectionStatus == 'WAIT_CONFIRM') {
                     this.title = '点检开始';
                     this.isShowTeam=true
                     this.isTouch=true
                     this.isShowBtn=false
                     if (this.flag == 'task') {
                        this.title = '点检执行';
                        this.readonly = true
                        this.isShowTeam = true
                        this.isTouch = true
                        this.isShowBtn = false
                     } else {
                        this.title = '点检开始';
                        this.isShowTeam = true
                        this.isTouch = false
                        this.readonly = true
                        this.isShowBtn = true
                     }
                  } else if (this.formData.inspectionStatus == 'UNDER_INSPECTION') {
                     if (this.flag == 'task') {
                        this.title = '点检开始';
                        this.isShowBtn = false;
                     }
                  }
                  this.formData.avatar = this.announcement1.imageFiles
                  this.imageFilesList = JSON.parse(this.formData.avatar)
@@ -507,6 +512,13 @@
                  this.imgList = imageObjects.map(imageObj => {
                     return `${this.ipAndPort}${imageObj.filePath}`;
                  });
                  // 根据 imgList 构造 fileLists
                  this.fileLists = this.imgList.map(url => ({
                     url: url,
                     extname: 'png',
                     name: 'eam'
                  }));
                  this.hasInspectionDateArrived();
               }
            }).catch(() => {
@@ -594,4 +606,66 @@
      margin-top: 85px;
      height: auto;
   }
   .divider {
      display: flex;
      align-items: center;
      text-align: center;
      color: gray;
      /* 文字颜色 */
      margin: 20px 0;
      /* 上下间距 */
   }
   .divider::before,
   .divider::after {
      content: '';
      flex: 1;
      border-bottom: 1px solid gray;
      /* 横线颜色 */
      margin: 0 16px;
      /* 横线与文字之间的间距 */
   }
   .divider text {
      white-space: nowrap;
      /* 防止文字换行 */
   }
   .overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.7);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 999;
   }
   .modal {
      position: relative;
      width: 90%;
      max-width: 600px;
      background: #fff;
      border-radius: 12rpx;
      padding: 20rpx;
      box-sizing: border-box;
   }
   .preview-image {
      width: 100%;
      max-height: 80vh;
      object-fit: contain;
   }
   .close-btn {
      position: absolute;
      top: 10rpx;
      right: 20rpx;
      font-size: 40rpx;
      color: #333;
   }
</style>