Mr.Zhang
2023-09-05 64a7f738aadbf552bfb1ce24c46b1924767bf526
minipro_standard/pages_adjust/pages/workOrderReporting/workOrderReporting.vue
@@ -1,7 +1,7 @@
<template>
   <view>
      <view class="tips-label">当前任务需要质检;产出后,请耐心等待质检员检验,并根据检验结果调整产出数据后再报工。</view>
      <workOrderInfo :orederMessage="{proUserList:[]}" />
      <workOrderInfo :orederMessage="info" />
      <!-- <u-tabs :list="tab" lineColor="#305ED5" :activeStyle="{color:'#305ED5'}" lineWidth="50%" :itemStyle="{width: '50%', boxSizing: 'border-box', height: '88rpx'}" @click="click"></u-tabs> -->
      <view class="bg_cate">
         <view @click="clickIten(index)" :class="typeView == index ? 'bg_cate_item active' : 'bg_cate_item'"
@@ -14,7 +14,9 @@
                  <div class="bg_list_item_top_left_x bg_m"></div>
                  <span>投料明细</span>
               </div>
               <div class="bg_list_item_top_right" @click="jumpTL">
               <!-- proxy.$auth('h5:workorderinput:create') &&  -->
               <div class="bg_list_item_top_right" @click="jumpTL"
                  v-if="info.bomType !== 1 || info.bomType == 0 || !info.bomType">
                  <!-- v-if="proxy.$auth('h5:workorderinput:create') && (info.bomType !== 1 || info.bomType == 0 || !info.bomType)" -->
                  <!-- <img src="@/assets/icon/gongdan_ic_shoudong@2x.png" alt="" /> -->
                  <!-- <img src="@/static/gongdan_ic_shoudong@2x.ong" alt="" /> -->
@@ -174,7 +176,8 @@
      </div>
      <div class="details_dj" v-if="typeView === 1">
         <div class="details_dj_list">
         <div class="details_dj_list">
            <u-swipe-action>
               <u-swipe-action-item v-for="(item, index) in djData" :key="index" :options="options"
                  @click="dele(item.id)">
@@ -205,11 +208,10 @@
            <view class="c2 b tc">不良项</view>
            <view class="content bl_list">
               <div class="bl_list_item" v-for="(item, i) in cateList" :key="i" @click="changeChecked(i)">
                  <div class="bl_list_item_left">
                     <u-checkbox-group>
                        <u-checkbox  :key="index" :checked="item.active" :label="item.name"
                           :name="item.name">
                        </u-checkbox>
                  <div class="bl_list_item_left">
                     <u-checkbox-group @change="changeChecked(i)">
                        <u-checkbox :key="index" :checked="item.active" :label="item.name" :name="item.name">
                        </u-checkbox>
                     </u-checkbox-group>
                  </div>
                  <div class="bl_list_item_right">
@@ -227,6 +229,26 @@
<script>
   import workOrderInfo from '@/components/workOrderInfo.vue'
   import {
      getBarcodeContent,
      queryById,
      getOrocessRecord,
      deleteCT,
      updateById,
      comfirmDone,
      comfirmDoneStandard,
      getListByCondition,
      allForStandard,
      pageDJ,
      deletedj,
      dealWorkorderRecordStandard,
      getWorkorderRecordListStandard
   } from '@/util/api/WorkOrderAPI'
   import {
      categoryExtList,
      queryOne,
      queryList
   } from '@/util/api/PlanningAPI'
   export default {
      components: {
         workOrderInfo
@@ -252,18 +274,22 @@
            TimeShow: false,
            badShow: false,
            typeView: 0,
            feedingData: [{
               id: 0,
               materialName: '墙体砖',
               procedureName: '压制',
               qualityType: 1,
               locationName: 'CP-01',
               batch: '20230713',
               num: 2,
               maxNum: 10,
               unitAttribute: 1,
               unitName: '块'
            }],
            workorderId: '',
            info: {},
            feedingData: [
               // {
               //    id: 0,
               //    materialName: '墙体砖',
               //    procedureName: '压制',
               //    qualityType: 1,
               //    locationName: 'CP-01',
               //    batch: '20230713',
               //    num: 2,
               //    maxNum: 10,
               //    unitAttribute: 1,
               //    unitName: '块'
               // },
            ],
            options: [{
               text: '删除',
               style: {
@@ -286,7 +312,7 @@
               qualifiedId: '',
               qualified: '', // 合格
               undesirableId: '',
               undesirable: 5 // 不良
               undesirable: '' // 不良
            },
            djData: [{
               attrName: '出水时间',
@@ -294,12 +320,25 @@
               userName: '张三 ',
               createTime: '2022-05-28 16:32:'
            }],
            cateList: [{
               active: false,
               name: '毛刺',
               num: 0
            }]
            cateList: [
               // {
               //    active: false,
               //    name: '毛刺',
               //    num: 0
               // },
            ],
            pages: {
               capacity: 10,
               page: 1,
               total: 0
            }
         };
      },
      onLoad(obj) {
         this.workorderId = obj.id
         this.queryByIds()
         this.getOrocessRecords()
         this.getData()
      },
      computed: {
         expectedSalary() {
@@ -320,10 +359,10 @@
               return (Number(h) * (this.arrType[this.form.index].salary / 10 / 10)).toFixed(2) || 0
            }
         },
         complianceRate() {
            if (this.arrType.length === 0) return 0;
            if (!this.produceFrom.qualified && !this.produceFrom.undesirable) return 0;
            if (!this.form.duration) return 0;
         complianceRate() {
            if (this.arrType.length === 0) return 0;
            if (!this.produceFrom.qualified && !this.produceFrom.undesirable) return 0;
            if (!this.form.duration) return 0;
            if (!this.arrType[this.form.index].num) return 0;
            // 按件计算
            // if (infoBox.value.type == 0) {
@@ -334,15 +373,64 @@
               return ((Number(a) / Number(b)) * 100).toFixed(2)
               // let total = (Number(from.qualified) + Number(from.undesirable)) / ((from.duration * 60 * 60) * infoBox.value.num / )
               // return total * infoBox.value.salary;
            } else {
            } else {
               let a = (this.produceFrom.qualified / (this.form.duration / 3600)).toFixed(2)
               let b = (this.arrType[this.form.index].num / (this.arrType[this.form.index].times / 3600)).toFixed(2)
               let b = (this.arrType[this.form.index].num / (this.arrType[this.form.index].times / 3600)).toFixed(2)
               return ((Number(a) / Number(b)) * 100).toFixed(2)
               // return Number(from.qualified) * infoBox.value.salary;
            }
         }
      },
      methods: {
         queryByIds() {
            queryById(this.workorderId)
               .then(res => {
                  this.info = res.data
                  queryList({
                     deleted: 0,
                     departId: res.data.factoryId,
                     materialId: res.data.materialId,
                     procedureId: res.data.procedureId
                  }).then(result => {
                     if (result.code === 200) {
                        if (result.data && result.data.length > 0) {
                           result.data.forEach((item, index) => {
                              item.name = item.type == 0 ? '计件' : '计时'
                              item.id = item.type
                              item.active = index == 0
                           })
                           this.arrType = result.data
                        } else {
                           this.arrType = []
                        }
                     }
                  })
               })
         },
         getOrocessRecords() {
            this.feedingData = []
            allForStandard({
               workorderId: this.workorderId,
               type: 0
            }).then(res => {
               if (res.code === 200) {
                  this.feedingData = res.data
               }
            })
         },
         getData() {
            categoryExtList({
               cateType: "3"
            }).then(res => {
               if (res.code === 200) {
                  res.data.forEach(item => {
                     item.active = false
                     item.num = ''
                  })
                  this.cateList = res.data
               }
            })
         },
         click() {
         },
@@ -410,12 +498,42 @@
            //   }
            // })
         },
         changeCC(downType, num, recordId) {
            if (!num) return
            console.log(Number(this.produceFrom.qualified) + Number(this.produceFrom.undesirable))
            if ((Number(this.produceFrom.qualified) + Number(this.produceFrom.undesirable)) > this.info.planNum) {
               uni.showToast({ title:'产出数量不能大于计划数量', duration: 2000, icon:'none' })
               return
            }
            if (num >= 0) {
               this.form.defective = []
               this.form.defectiveName = ''
               // dealWorkorderRecordStandard({
               //     downType, num, recordId, workorderId: route.query.id
               // }).then(res => {
               //     if (res.code === 200) {
               //         getOrocessRecordCC()
               //     }
               // })
            } else {
               if (downType == 0) {
                  this.produceFrom.qualified = 0
               } else {
                  this.produceFrom.undesirable = 0
               }
               uni.showToast({ title:'产出数量不能小于', duration: 2000, icon:'none' })
            }
         },
         clickPerformanceType(item, index) {
            this.form.index = index
            this.form.type = item.type
         },
         submit() {},
         jumpdj() {},
         jumpdj() {
            uni.navigateTo({
               url: `/pages_adjust/pages/spotCheck/spotCheck?id=${this.workorderId}`
            })
         },
         pageDJs() {},
         dele(id) {
            // deletedj(id)
@@ -429,12 +547,48 @@
            //       }
            //     })
         },
         confirm() {
            // console.log('confirm');
         confirm() {
            console.log('confirm', this.cateList);
            let isOpen = false
            this.cateList.forEach((item, index) => {
               if (item.active) {
                  isOpen = true
               }
            })
            if (!isOpen) {
               uni.showToast({ title:'请选择不良项', duration: 2000, icon:'none' })
               return
            }
            let arr = []
            let total = 0
            let name = ''
            this.cateList.forEach((item, index) => {
               if (item.active) {
                  if (item.num <= 0) {
                     uni.showToast({ title:'不良数量必须大于0', duration: 2000, icon:'none' })
                     return
                  }
                  total = total += item.num
                  arr.push(item)
                  name += item.name + item.num + ';'
               }
            })
            if (total != Number(this.produceFrom.undesirable)) {
               uni.showToast({ title:'不良数必须等于产出不良数', duration: 2000, icon:'none' })
               return
            }
            this.form.defective = arr
            this.form.defectiveName = name
            this.badShow = false
         },
         changeChecked(i) {
            this.cateList[i].active = !this.cateList[i].active
         },
         jumpTL() {
            uni.navigateTo({
               // url: ''
               url: `/pages_adjust/pages/manualFeed/manualFeed?id=${this.workorderId}`
            })
         }
      }
   }