Mr.Shi
2023-09-07 17e1ae4795b1be3d4bfd7005fb1bb559d5e30115
minipro_standard/pages_adjust/pages/reportingForWork/reportingForWork.vue
@@ -66,8 +66,8 @@
                                 <text class="green" v-if="item.qualityType == 0">合格&nbsp;/&nbsp;</text>
                                 <text class="yellow" v-if="item.qualityType == 1">不良&nbsp;/&nbsp;</text>
                                 <text class="red" v-if="item.qualityType == 2">报废&nbsp;/&nbsp;</text>
                                 <text>{{ item.locationName }}&nbsp;/&nbsp;</text>
                                 <text>{{ item.batch }}</text>
                                 <text>{{ item.locationName || '-' }}&nbsp;/&nbsp;</text>
                                 <text>{{ item.batch || '-' }}</text>
                              </view>
                           </view>
                           <view class="bg_list_item_num_item_sr">
@@ -75,7 +75,7 @@
                                  placeholder="请输入"
                                  border="surround"
                                 type="number"
                                 :customStyle="{width: '180rpx'}"
                                 :customStyle="{width: '100%'}"
                                  v-model="item.num"
                                 @input="inputwl(index)"
                                ></u--input>
@@ -213,11 +213,11 @@
      <!-- 生产人员 -->
      <user :show="userShow" @close="userShow = false" @value="onConfirm1" />
      <!-- 生产设备 -->
      <u-picker :show="deviceShow" :columns="deviceList" keyName="name" @confirm="onConfirm" @cancel="onCancel"></u-picker>
      <u-picker :show="deviceShow" :columns="deviceList" keyName="name" @confirm="onConfirm" @cancel="deviceShow = false"></u-picker>
      <!-- 时间 -->
      <u-picker :show="TimeShow" :columns="columns" @confirm="onConfirm2" @cancel="TimeShow = false"></u-picker>
      <!-- 物料 -->
      <selectMaterial ref="selectMaterial" @selectAction="getValue" />
      <MaterialSelect ref="MaterialSelect" :plansId="String(plansId)" :selected="ids" :deviceId="String(deviceId)" @value="getValue" />
      <!-- 不良项 -->
      <u-popup :show="show" @close="show = false" :round="8" closeable zIndex="20000">
         <view class="rp p40 contanir">
@@ -225,7 +225,7 @@
            <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-group @change="poorSelection(item.active, i)">
                        <u-checkbox :checked="item.active" :label="item.name" :name="item.name"></u-checkbox>
                     </u-checkbox-group>
                  </div>
@@ -244,11 +244,13 @@
<script>
   import user from '../../components/user.vue'
   import selectMaterial from '@/components/selectMaterial.vue'
   import MaterialSelect from '../../components/MaterialSelect.vue'
   import { mapState } from 'vuex'
   import { getDeviceByCondition, getFindAll, queryOne, queryList, autoWorkReport, getIdPlansExt, categoryExtList } from '@/util/api/PlanningAPI'
   export default {
      components: {
         user,
         selectMaterial
         MaterialSelect
      },
      data() {
         return {
@@ -295,21 +297,22 @@
         };
      },
      computed: {
         ...mapState(['userInfo']),
         // 预计工资
         expectedSalary() {
            if (this.arrType.length === 0) return 0;
            if (this.arrType[from.index].type == 0) {
            if (this.arrType[this.from.index].type == 0) {
               if (!this.from.qualified) return 0
               if (this.arrType[from.index].unqualified == 1) {   // 是否计入不良品
               if (this.arrType[this.from.index].unqualified == 1) {   // 是否计入不良品
                  let total = Number(this.from.qualified) + Number(this.from.undesirable)
                  return (total * (this.arrType[from.index].salary / 10 / 10)).toFixed(2)
               } else {
                  return (Number(this.from.qualified) * (this.arrType[from.index].salary / 10 / 10)).toFixed(2)
                  return (Number(this.from.qualified) * (this.arrType[this.from.index].salary / 10 / 10)).toFixed(2)
               }
            } else {
               if (!this.from.duration) return 0;
               let h = (this.from.duration / 60 / 60).toFixed(2)
               return (Number(h) * (this.arrType[from.index].salary / 10 / 10)).toFixed(2)
               return (Number(h) * (this.arrType[this.from.index].salary / 10 / 10)).toFixed(2)
            }
         },
         // 达标率
@@ -317,32 +320,99 @@
            if (this.arrType.length === 0) return 0;
            if (!this.from.qualified && !this.from.undesirable) return 0;
            if (!this.from.duration) return 0;
            if (!this.arrType[from.index].num) return 0;
            if (this.arrType[from.index].unqualified == 1) {   // 是否计入不良品
            if (!this.arrType[this.from.index].num) return 0;
            if (this.arrType[this.from.index].unqualified == 1) {   // 是否计入不良品
               let a = ((Number(this.from.qualified) + Number(this.from.undesirable)) / (this.from.duration / 3600)).toFixed(2)
               let b = (this.arrType[from.index].num / (this.arrType[from.index].times / 3600)).toFixed(2)
               let b = (this.arrType[this.from.index].num / (this.arrType[this.from.index].times / 3600)).toFixed(2)
               return ((Number(a) / Number(b)) * 100).toFixed(2)
            } else {
               let a = (this.from.qualified / (this.from.duration / 3600)).toFixed(2)
               let b = (this.arrType[from.index].num / (this.arrType[from.index].times / 3600)).toFixed(2)
               let b = (this.arrType[this.from.index].num / (this.arrType[this.from.index].times / 3600)).toFixed(2)
               return ((Number(a) / Number(b)) * 100).toFixed(2)
            }
         }
      },
      onReady() {
         this.from.userId = this.userInfo.id
         this.form.userName = this.userInfo.realname
      },
      onLoad() {
         let arr = []
         for(let i = 0; i < 60; i++) {
            arr.push(i)
         }
         this.getData()
         this.columns = [arr, arr]
         // 接收计划
         uni.$on('update', (data) => {
            this.from.processPlan = data.obj
            this.plansId = data.obj.id
            this.from.deviceId = ''
            this.from.deviceName = ''
            this.deviceId = ''
            this.total = data.obj.num - data.obj.workorderDistributNum
            this.wuList = []
            this.from.defective = []
            this.from.defectiveName = ''
            this.from.userName = ''
            this.from.userId = ''
            // 获取设备
            getDeviceByCondition({ procedureId: data.obj.procedureId })
               .then(res1 => {
                  if (res1.code === 200) {
                     if (res1.data && res1.data.length > 0) {
                        this.deviceId = res1.data[0].id
                        this.from.deviceId = res1.data[0].id
                        this.from.deviceName = res1.data[0].name
                        this.deviceList = [res1.data]
                     }
                  }
               })
            // 获取类型
            getIdPlansExt(data.obj.id)
               .then(res2 => {
                  if (res2.code === 200) {
                     this.bomType = res2.data.bomType
                     this.hasBom = res2.data.hasBom
                  }
               })
            // 获取工资绩效数据
            queryList({
               deleted: 0,
               departId: data.obj.factoryId,
               materialId: data.obj.materialId,
               procedureId: data.obj.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
                     console.log(this.arrType)
                  } else {
                     this.arrType = []
                  }
               }
            })
         })
      },
      methods: {
         poorSelection(val, i) {
            this.cateList.forEach((item, index) => {
               if (i === index) {
                  item.active = !item.active
               }
            })
         },
         // 切换绩效类型
         clickPerformanceType(i) {
            this.from.index = i
            this.arrType.forEach((item, index) => {
               if (i === index) {
                  from.type = item.id
                  this.from.type = item.id
               }
               item.active = index === i
            })
@@ -353,7 +423,7 @@
            obj.total = val.num
            this.wuList.unshift(obj)
            let arr = this.wuList.map(item => item.id)
            this.ids = arr.join(',')
            this.ids = arr
         },
         // 获取不良项目
         getData() {
@@ -371,9 +441,9 @@
         },
         // 选择设备
         onConfirm(e) {
            this.from.deviceId = e.id
            this.from.deviceName = e.name
            this.deviceId = e.id
            this.from.deviceId = e.value[0].id
            this.from.deviceName = e.value[0].name
            this.deviceId = e.value[0].id
            this.from.userId = ''
            this.from.userName = ''
            // getFindAll({
@@ -403,15 +473,15 @@
            let name = ''
            for (let i = 0; i < this.cateList.length; i++) {
               if (this.cateList[i].active) {
                  if (this.cateList[i].num <= 0) {
                  if (Number(this.cateList[i].num) <= 0) {
                     return uni.showToast({ title: '不良数量必须大于0', icon: 'none', duration: 2000 });
                  }
                  total = total += this.cateList[i].num
                  total = total += Number(this.cateList[i].num)
                  arr.push(this.cateList[i])
                  name += this.cateList[i].name + this.cateList[i].num + ';'
               }
            }
            if (total !== this.from.undesirable) return uni.showToast({ title: '不良数必须等于产出不良数', icon: 'none', duration: 2000 });
            if (total !== Number(this.from.undesirable)) return uni.showToast({ title: '不良数必须等于产出不良数', icon: 'none', duration: 2000 });
            this.from.defective = arr
            this.from.defectiveName = name
            this.show = false
@@ -450,7 +520,7 @@
         openMaterial() {
            if (!this.plansId) return uni.showToast({ title: '请先选择工序生产计划', icon: 'none', duration: 2000 });
            if (!this.deviceId) return uni.showToast({ title: '请先选择生产设备', icon: 'none', duration: 2000 });
            this.$refs.selectMaterial.open({})
            this.$refs.MaterialSelect.open()
         },
         inputwl(i) {
            if (this.wuList[i].num > this.wuList[i].total) {
@@ -543,6 +613,7 @@
            }).then(res => {
               if (res.code === 200) {
                  uni.showToast({ title: '报工成功!', icon: 'success', duration: 2000 });
                  this.arrType = []
                  this.from.processPlan = null
                  this.from.deviceId = ''
                  this.from.deviceName = ''
@@ -830,7 +901,7 @@
                        }
                     }
                     .bg_list_item_num_item_wl {
                        flex-shrink: 0;
                        flex: 1;
                        display: flex;
                        flex-direction: column;
                        text {
@@ -888,6 +959,8 @@
                     }
                     .bg_list_item_num_item_sr {
                        // flex: 1;
                        flex-shrink: 0;
                        width: 230rpx;
                        display: flex;
                        align-items: center;
                        justify-content: flex-end;
@@ -911,6 +984,7 @@
                           font-weight: 400;
                           color: #333333;
                           padding: 0 30rpx;
                           margin-right: 20rpx;
                        }
                        .wulll {
                           width: 400rpx;
@@ -1042,7 +1116,8 @@
                  }
               }
               .bl_list_item_right {
                  flex: 1;
                  width: 200rpx;
                  flex-shrink: 0;
                  height: 50rpx;
                  text-align: right;
                  input {
@@ -1067,5 +1142,77 @@
            }
         }
      }
      .bl_list {
         width: 100%;
         height: calc(100% - 168rpx);
         overflow-y: scroll;
         margin-top: 30rpx;
         .bl_list_item {
            width: 100%;
            height: 96rpx;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1rPX solid #E5E5E5;
            &:last-child {
               border: none !important;
            }
            .bl_list_item_left {
               flex: 1;
               display: flex;
               align-items: center;
               input {
                  width: 30rpx;
                  height: 30rpx;
                  border: 1rpX solid #CCCCCC;
                  margin: 0 !important;
               }
               span {
                  font-size: 30rpx;
                  color: #222222;
                  margin-left: 10rpx;
               }
            }
            .bl_list_item_right {
               width: 200rpx;
               flex-shrink: 0;
               height: 50rpx;
               text-align: right;
               input {
                  padding-left: 5rpx;
                  width: 180rpx;
                  height: 60rpx;
                  border-radius: 8rpx;
                  border: 1rpx solid #CCCCCC;
                  padding: 0 30rpx;
                  box-sizing: border-box;
                  text-align: right;
                  font-size: 28rpx;
                  color: #333333;
                  border-radius: 10rpx;
                  border: 1rPX solid #CCCCCC;
                  &::-webkit-input-placeholder {
                     font-size: 28rpx;
                     font-family: PingFangSC-Regular, PingFang SC;
                     font-weight: 400;
                     color: #999999;
                  }
               }
            }
         }
      }
      .bottom-view {
         left: 40rpx;
         right: 40rpx;
         bottom: 0
      }
   }
</style>