jiangping
2023-10-26 ea87c908fb6cdfc3e227a584a53e6730efb8262a
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="" /> -->
@@ -170,24 +172,24 @@
               </div>
            </div>
         </div>
      </div>
      <div class="details_dj" v-if="typeView === 1">
         <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)">
                  <div class="details_dj_list_item">
                     <span>{{ item.attrName }}:{{ item.val }}</span>
                     <span>{{ item.userName }} {{ item.createTime }}</span>
                  </div>
               </u-swipe-action-item>
            </u-swipe-action>
            <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="getLists">
               <u-swipe-action v-for="(item, index) in djData" :key="index">
                  <u-swipe-action-item :options="options" @click="dele(item.id)">
                     <div class="details_dj_list_item">
                        <span>{{ item.attrName }}:{{ item.val }}</span>
                        <span>{{ item.userName }} {{ item.createTime }}</span>
                     </div>
                  </u-swipe-action-item>
               </u-swipe-action>
            </scroll-view>
         </div>
      </div>
      <!-- v-if="info.status === 2 || info.procedureNeedcheck === 1" -->
      <template>
      <template v-if="info.status === 2 || info.procedureNeedcheck === 1">
         <div class="bh_zw"></div>
         <div class="bg_footer bg_f7">
            <div class="bg_footer_submit bg_m" v-if="typeView == 0" @click="submit">确认报工</div>
@@ -205,11 +207,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 +228,29 @@
<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'
   import {
      REGULAR
   } from '@/util/utils'
   export default {
      components: {
         workOrderInfo
@@ -242,7 +266,7 @@
            ],
            form: {
               time: '',
               efective: [],
               defective: [],
               defectiveName: '',
               durationName: '0小时0分钟',
               duration: 0,
@@ -252,54 +276,48 @@
            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: [],
            options: [{
               text: '删除',
               style: {
                  backgroundColor: 'red',
               }
            }],
            arrType: [{
                  name: '计时',
                  type: 1,
                  salary: 1000,
               },
               {
                  name: '计件',
                  type: 0,
                  salary: 100
               },
            ],
            arrType: [],
            // 产出合格/不良
            produceFrom: {
               qualifiedId: '',
               qualified: '', // 合格
               undesirableId: '',
               undesirable: 5 // 不良
               undesirable: '' // 不良
            },
            djData: [{
               attrName: '出水时间',
               val: '2022-05-28 16:3',
               userName: '张三 ',
               createTime: '2022-05-28 16:32:'
            }],
            cateList: [{
               active: false,
               name: '毛刺',
               num: 0
            }]
            triggered: false,
            finished: true,
            djData: [],
            cateList: [],
            pages: {
               capacity: 10,
               page: 1,
               total: 0
            }
         };
      },
      onLoad(obj) {
         this.workorderId = obj.id
         this.queryByIds()
         this.getOrocessRecords()
         this.getData()
         uni.$on('spotAdd', () => {
            if (this.typeView == 1) {
               this.pages.page = 1
               this.pageDJs()
            }
         })
         uni.$on('addMaterial', () => {
            this.getOrocessRecords()
         })
      },
      computed: {
         expectedSalary() {
@@ -343,11 +361,64 @@
         }
      },
      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() {
         },
         clickIten(index) {
            this.typeView = index
            if (this.typeView == 1) {
               this.pages.page = 1
               this.pageDJs()
            }
         },
         timeConfirm({
            value
@@ -410,31 +481,194 @@
            //   }
            // })
         },
         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() {},
         pageDJs() {},
         dele(id) {
            // deletedj(id)
            //     .then(res => {
            //       if (res.code === 200) {
            //         djData.value = []
            //         finished.value = false
            //         page.page = 1
            //         djData.value = []
            //         pageDJs()
            //       }
            //     })
         submit() {
            let createUnqualifiedDTOList = this.form.defective.map((item) => {
               return {
                  categoryId: item.id,
                  unQualifiedNum: item.num
               }
            })
            let createWorkorderRecordDTO = {
               workorderId: this.workorderId,
               duration: this.form.duration ? this.form.duration : 0,
               qualifiedNum: this.produceFrom.qualified ? this.produceFrom.qualified : 0,
               unQualifiedNum: this.produceFrom.undesirable ? this.produceFrom.undesirable : 0
            }
            // id: route.query.id
            comfirmDoneStandard({
               createUnqualifiedDTOList,
               createWorkorderRecordDTO
            }).then(res => {
               if (res.code === 200) {
                  uni.$u.toast('报工成功')
                  setTimeout(() => {
                     uni.navigateBack({
                        data: 2
                     })
                  }, 2000)
               }
            })
         },
         confirm() {
            // console.log('confirm');
         jumpdj() {
            uni.navigateTo({
               url: `/pages_adjust/pages/spotCheck/spotCheck?id=${this.workorderId}`
            })
         },
         getLists() {
            if (!this.finished) {
               return
            }
            this.finished = false
            this.pages.page += 1
            this.pageDJs()
         },
         pageDJs() {
            pageDJ({
                  capacity: this.pages.capacity,
                  page: this.pages.page,
                  model: {
                     workorderId: this.workorderId
                  }
               }).then(res => {
                  let {
                     data
                  } = res
                  if (data.page == 1) {
                     this.djData = []
                  }
                  this.djData.push(...data.records)
                  // loading.value = false
               }).catch(err => {
                  // loading.value = false
                  // finished.value = true
               })
               .finally(() => {
                  this.finished = true
               })
         },
         dele(id) {
            deletedj(id)
               .then(res => {
                  if (res.code === 200) {
                     this.finished = true
                     this.pages.page = 1
                     this.pageDJs()
                  }
               })
         },
         confirm() {
            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}`
            })
         },
         deleItem(id, type) {
            uni.showModal({
               title: '提示',
               content: '确定删除此条记录吗?',
               success: (res) => {
                  if (res.confirm) {
                     console.log('用户点击确定');
                     deleteCT(id)
                        .then(res => {
                           this.getOrocessRecords()
                           // if (type === 'C') {
                           //    this.getOrocessRecordCC()
                           // } else if (type === 'T') {
                           //    this.getOrocessRecords()
                           // }
                        })
                        .catch(err => {})
                  }
               }
            })
         }
      }
   }