Houjie
2025-04-25 1d18ff904468e4a864312bdcf6d7c6a7c0477721
pages/TaskManager/TaskManagerDeils/TaskManagerDeils.vue
@@ -2,7 +2,7 @@
   <view class="container">
      <cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="productionTask">
         <block slot="backText">返回</block>
         <block slot="content">已办详情</block>
         <block slot="content">详情</block>
      </cu-custom>
      <view class="container">
@@ -11,28 +11,20 @@
            <uni-group top="1">
               <view class="text-gray margin-bottom-lg">—————————— 基本信息 ——————————</view>
               <uni-forms-item name="num" label="工单号:">
                  <uni-easyinput v-model="formData.equipmentCode" :disabled="true" />
                  <uni-easyinput v-model="formData.orderNum" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item required name="num" label="设备编码:">
                  <uni-easyinput v-model="formData.equipmentCode" :disabled="true" />
               <uni-forms-item required name="num" label="设备编号:">
                  <uni-data-select v-model="formData.num" :localdata="equipmentList" @change="changeEquipmentList"
                     placeholder="请选择" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item name="remark" label="标准名称:">
                  <uni-easyinput v-model="formData.equipmentName" :disabled="true" />
               <uni-forms-item name="remark" label="点检日期:">
                  <uni-easyinput v-model="formData.inspectionDate" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item name="remark" label="保养日期:">
                  <uni-easyinput v-model="formData.equipmentModel" :disabled="true" />
               <uni-forms-item name="outNum" label="点检人:">
                  <uni-easyinput v-model="formData.operator" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item name="outNum" label="保养人:">
                  <uni-easyinput v-model="formData.equipmentSpecification" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item name="outNum" label="保养周期:">
                  <uni-easyinput v-model="formData.equipmentSpecification" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item name="outNum" label="备注:">
                  <uni-easyinput v-model="formData.equipmentSpecification" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item name="outNum" label="保养图片:">
               <uni-forms-item 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]">
@@ -41,22 +33,12 @@
                           <text class='cuIcon-close'></text>
                        </view>
                     </view>
                     <view class="solids" @tap="ChooseImage" v-if="imgList.length<1">
                     <view class="solids" v-if="imgList.length<1">
                        <text class='cuIcon-cameraadd'></text>
                     </view>
                  </view>
               </uni-forms-item>
               <view class="text-gray margin-bottom-lg">—————————— 班组长确认 ——————————</view>
               <uni-forms-item name="outNum" required label="确认类型:">
                  <uni-data-select :localdata="formData.msListCategory" popup-title="请选择" @change="changeType"
                     :clear="false">
                  </uni-data-select>
               </uni-forms-item>
               <uni-forms-item name="outNum" required label="确认意见:">
                  <uni-easyinput type="textarea" v-model="formData.ttitle" placeholder="请输入内容"></uni-easyinput>
               </uni-forms-item>
            </uni-group>
         </uni-forms>
         <view class="text-gray margin-bottom-lg">—————————— 保养项信息 ——————————</view>
@@ -71,64 +53,65 @@
            <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 text-bold radius text-right">
                  {{item.title}}
                  {{item.itemName}}
               </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 margin-xs radius text-right"
                  v-if="item.small!=null && item.small.length>10">
                  {{(item.small).toString().substr(0,10)+'...'}}
               </view>
               <view class="flex-sub bg-white padding-xs margin-xs radius text-right" v-else>
                  {{item.small}}
               </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 margin-xs radius text-right"
                  v-if="item.yaoqiu!=null && item.yaoqiu.length>10">
                  {{(item.yaoqiu).toString().substr(0,10)+'...'}}
                  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.yaoqiu}}
                  {{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" :clear="true" />
               <view class="flex-sub text-light bg-white  padding-xs margin-xs radius">点检结果:</view>
               <uni-data-select :localdata="restle" v-model="item.inspectionResult" @change="handleCode()"
                  :clear="true" :disabled="true" />
               </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-easyinput v-model="item.desc" :disabled="true" />
                  <uni-easyinput v-model="item.exceptionDescription" :disabled="true" />
               </view>
            </view>
            <view class="flex">
               <view class="flex-sub text-light bg-white  padding-xs margin-xs radius">是否报修:</view>
               <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.type" />
                  <uni-data-select :localdata="item.type" v-model="item.reportFlag" :disabled="true" />
               </view>
            </view>
         </uni-card>
         <uni-forms v-if="isDisplayConfirm == 'WAIT_CONFIRM' || isDisplayConfirm == 'COMPLETE'" ref="form"
            :modelValue="ScanData" validate-trigger="bind" err-show-type="undertext">
            <uni-group top="1">
               <view class="text-gray margin-bottom-lg">—————————— 班组长确认 ——————————</view>
               <uni-forms-item required name="typeName" label="处理类型:">
                  <uni-data-select v-model="ScanData.typeName" :localdata="ScanData.handlingType"
                     @change="changehandlingType" placeholder="请选择" :disabled="true" />
               </uni-forms-item>
               <uni-forms-item required name="handlingSuggestion" label="处理意见:">
                  <uni-easyinput type="textarea" v-model="ScanData.handlingSuggestion" :disabled="true" />
               </uni-forms-item>
            </uni-group>
         </uni-forms>
      </view>
   </view>
</template>
<script>
   import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
   import configService from '@/common/service/config.service.js';
   export default {
      mixins: [MescrollMixin], // 使用mixin
      data() {
@@ -136,28 +119,42 @@
            scrollLeft: 0,
            searchValue: '',
            imgList: [],
            equipmentList: [],
            uploadUrl: "/sys/common/upload",
            formData: {},
            partTakeAdviceDetailList: [{
               title: "机床空气过滤",
               small: "外壳及管路",
               yaoqiu: "过滤网,过滤棉完好,无油",
               restle: [{
                     text: "正常",
                     value: 0
            ScanData: {
               typeName: '',
               handlingType: [{
                     text: "通过",
                     value: "1"
                  },
                  {
                     text: "异常",
                     value: 1
                     text: "驳回",
                     value: "2"
                  }
               ]
            }],
               ],
               handlingSuggestion: ''
            },
            formData: {
               num: '',
               avatar: '',
               orderNum: '',
               inspectionDate: '',
               operator: ''
            },
            istrue: true,
            partTakeAdviceDetailList: [],
            NavBarColor: this.NavBarColor,
            url: {
               stallList: "/eam/equipment/queryById"
               upload: "/eam/sysFiles/batch_upload",
               stallList: "/eam/eamInspectionOrder/queryById",
               // getEquipmentList: "eam/equipment/asyncLoadEquipment",
               getEquipmentList:'eam/equipment/list',
               BaoList: 'eam/eamInspectionOrderDetail/queryList',
               approval: 'eam/eamInspectionOrder/approval'
            },
            id: '',
            taskId: '',
            inspectionResult: '',
            upOption: {
               page: {
                  num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
@@ -178,7 +175,10 @@
            },
            msg1Count: 0,
            msg2Count: 0,
            msg1Title: ""
            msg1Title: "",
            procInstId: '',
            values: '',
            isDisplayConfirm: false
         }
      },
      computed: {
@@ -192,38 +192,237 @@
            return style
         },
      },
      onLoad(options) {
         const annItem = JSON.parse(decodeURIComponent(options.item));
      onShow() {
      },
      onLoad: function(option) {
         const annItem = JSON.parse(decodeURIComponent(option.item));
         this.id = annItem.id
         this.id = annItem.dataId
         this.taskId = annItem.id
         this.procInstId = annItem.procInstId
         this.values = annItem.values
         this.assignee = annItem.assignee
         const imageFiles = annItem.imageFiles
         this.ipAndPort = configService.staticURL
         // const ipAndPort = 'https://192.168.1.42:9999/jeecg-boot/sys/common/static' + '/'
         if (imageFiles) {
            const fileArray = imageFiles.split(',');
            this.imgList = fileArray.map(file => {
               return ipAndPort + file.trim();
            });
         }
      },
      created() {
         this.upCallback()
         this.getEquipment();
         this.getList();
         this.upCallback();
      },
      methods: {
         changehandlingType(e) {
            this.ScanData.typeName = e;
         },
         ProductionTask() {
            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;
            }
            this.$http.post(this.url.approval, {
               /**
                * 确认意见
                */
               confirmComment: this.ScanData.handlingSuggestion,
               /**
                * 确认类型 1 通过  2 驳回
                */
               confirmDealType: this.ScanData.typeName,
               dataId: this.id,
               fileList: this.formData.avatar, // 包含上传后的图片路径,,
               instanceId: this.procInstId,
               tableDetailList: this.partTakeAdviceDetailList,
               taskId: this.taskId,
               userId: this.assignee,
               values: this.values
            }).then(res => {
               console.log(res)
               this.$tip.loaded();
               if (res.data.success) {
                  uni.showToast({
                     icon: "success",
                     title: '提交成功',
                     duration: 2000
                  });
                  this.$Router.replace({
                     name: 'ToDoList'
                  })
               }
            }).catch(() => {
               this.$tip.loaded();
               uni.showToast({
                  icon: "error",
                  title: '提交失败',
                  duration: 2000
               });
            });
         },
         changeEquipmentList(e) {
            this.formData.num = e;
         },
         handleCode(e, index) {
            console.log(index);
            // 根据 e 的值来判断是否需要更新 isTrue 的状态
            if (e === 2) {
               this.partTakeAdviceDetailList[index].istrue = false;
            } else {
               this.partTakeAdviceDetailList[index].istrue = true;
            }
         },
         // 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("联网失败")
         //    })
         // },
            getEquipment() {
                     this.$http.get(this.url.getEquipmentList, {
                        params: {
                           pageNo: 1,
                           pageSize: 9999,
                           order: 'desc',
                           column: 'createTime'
                        },
                     }).then(res => {
                        //设置列表数据
                        if (res.data.success) {
                           this.equipmentList = res.data.result.records
                        } else {
                           uni.showToast({
                              icon: "error",
                              title: res.data.message,
                              duration: 2000
                           });
                        }
                     }).catch(() => {
                        this.$tip.error("联网失败")
                     })
                  },
         getList() {
            this.$http.get(this.url.BaoList, {
               params: {
                  orderId: this.id
               },
            }).then(res => {
               this.partTakeAdviceDetailList = res.data.result;
               const restle = [];
               this.partTakeAdviceDetailList.forEach(item => {
                  item.restle = [{
                        text: "正常",
                        value: 1
                     },
                     {
                        text: "异常",
                        value: 2
                     }
                  ]; // 新字段,值为一个空数组
                  item.type = [{
                        text: "否",
                        value: 0
                     },
                     {
                        text: "是",
                        value: 1
                     }
                  ]; // 新字段,值为一个空数组
                  item.istrue = true;
               });
               console.log("url", res)
               //设置列表数据
               if (res.data.success) {
                  console.log("res", res.data.result)
               }
            }).catch(() => {
               //联网失败, 结束加载
            })
         },
         ChooseImage() {
            var that = this;
            uni.chooseImage({
               count: 4, //默认9
               sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
               sourceType: ['album'], //从相册选择
               count: 4,
               sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
               sourceType: ['album'], // 从相册选择
               success: (res) => {
                  that.$http.upload(that.uploadUrl, {
                        filePath: res.tempFilePaths[0],
                        name: 'file'
                     })
                     .then(res => {
                        that.myFormData.avatar = res.data.message;
                     })
                     .catch(err => {
                        that.$tip.error(err.data.message)
                  // 存储选择的图片路径
                  that.imgList = res.tempFilePaths;
                  // 初始化 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].filePath;
                              // 追加到 formData.avatar 中,并用逗号分隔
                              if (that.formData.avatar) {
                                 that.formData.avatar += ',' + filePath;
                              } else {
                                 that.formData.avatar = filePath;
                              }
                              console.log('图片' + index + '上传完成:', filePath);
                              resolve(filePath);
                           })
                           .catch(err => {
                              console.error('图片' + index + '上传失败:', err);
                              reject(err);
                           });
                     });
                  this.imgList = res.tempFilePaths
                  });
                  // 并发执行所有上传任务
                  Promise.all(uploadPromises)
                     .then((uploadedFilePaths) => {
                        console.log('所有图片上传成功:', that.formData.avatar);
                     })
                     .catch((err) => {
                        console.error('图片上传失败:', err);
                        that.$tip.error('图片上传失败');
                     });
               }
            });
         },
@@ -250,12 +449,7 @@
         upCallback() {
            this.$http.get(this.url.stallList, {
               params: {
                  pageNo: 999,
                  pageSize: 1,
                  order: 'asc',
                  column: 'createTime',
                  id: this.id
               },
            }).then(res => {
@@ -264,7 +458,19 @@
               //设置列表数据
               if (res.data.success) {
                  console.log("res", res.data.result.equipmentCode)
                  this.formData = this.announcement1
                  this.formData.num = this.announcement1.equipmentId,
                     this.formData.orderNum = this.announcement1.orderNum,
                     this.formData.operator = this.announcement1.operator,
                     this.formData.inspectionDate = this.announcement1.inspectionDate,
                     this.formData.avatar = this.announcement1.imageFiles,
                     this.ScanData.handlingSuggestion = this.announcement1.confirmComment,
                     this.ScanData.typeName = this.announcement1.confirmDealType
                  this.isDisplayConfirm = this.announcement1.inspectionStatus
                  if (this.announcement1.inspectionStatus == 'WAIT_CONFIRM' || this.announcement1
                     .inspectionStatus == 'COMPLETE') {
                     thihs.isDisplayConfirm = true
                  }
               }
            }).catch(() => {
               //联网失败, 结束加载