loulijun2021
2024-05-13 2c324f759cca1c6ef8542e22797891d9b32a664b
pages/scgl/scbg.vue
@@ -14,7 +14,7 @@
         <view class="mainContent" :style="{maxHeight:'1260rpx',overflow: 'scroll'}">
            <!-- 报工信息 -->
            <u-gap height="15" bgColor="#eff0f1"></u-gap>
            <u-gap height="5" bgColor="#eff0f1"></u-gap>
            <view class="head" style="padding-bottom: 10rpx;">
               <view class="head_block">
                  <view class="head_left">
@@ -64,7 +64,7 @@
            </view>
            <!-- 报工操作 -->
            <u-gap height="15" bgColor="#eff0f1"></u-gap>
            <u-gap height="10" bgColor="#eff0f1"></u-gap>
            <view class="head  marginLeft10 marginRight10" style="padding-bottom: 20rpx;">
               <view class="head_block">
                  <view class="head_left">
@@ -81,7 +81,7 @@
                     <view style="display: flex;" class="titleFont">
                        <view style="color: red;margin-right: 6rpx;">*</view> 计件方式:
                     </view>
                     <u-radio-group v-model="reckway">
                     <u-radio-group v-model="reckway" @change='radioGroupChange'>
                        <u-radio shape="circle" label="班组" name="班组" labelSize="16"></u-radio>
                        <u-radio shape="circle" label="个人" style="margin-left: 20rpx;" name="个人" labelSize="16">
                        </u-radio>
@@ -145,7 +145,7 @@
                     </view>
                  </view>
                  <view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
                  <!--                <view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
                     <view style="color: #fff;margin-right: 6rpx;">*</view> 不良数量:
                     <view class='inputClass'>
                        <u--input placeholder="请输入" border="surround" :adjustPosition='false'
@@ -163,29 +163,7 @@
                        </view>
                        <u-icon :name="!badSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                     </view>
                  </view>
                  <!--       <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                     <view style="display: flex;">
                        <view style="color: red;margin-right: 6rpx;">*</view> 操作人员:
                     </view>
                     <view @click='operSheetClick' class="custominputClass">
                        <view v-show='operSheetValue===""' style="color: rgb(192, 196, 204);">请选择</view>
                        <view v-show='operSheetValue!==""' class="ellipsis" style="width: 390rpx;">
                           {{operSheetValue}}
                        </view>
                        <u-icon :name="!operSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                     </view>
                  </view> -->
                  <!-- 可能上拉显示 要换成下拉显示 -->
                  <!--       <uni-section style="width: 100%;" title=''>
                     <uni-data-select v-model="operSheetValue" :clear='false' emptyText :localdata="operSheetList">
                     </uni-data-select>
                  </uni-section>
                   -->
@@ -193,70 +171,96 @@
               </view>
            </view>
            <!-- 报工人员信息 -->
            <!--          <u-gap height="15" v-if="reckway==='班组'" bgColor="#eff0f1"></u-gap>
            <view class="head marginLeft10 marginRight10" v-if="reckway==='班组'">
            <u-gap height="10" bgColor="#eff0f1"></u-gap>
            <view class="head  marginLeft10 marginRight10" style="padding-bottom: 20rpx;">
               <view class="head_block">
                  <view class="head_left">
                     <view class="head_bar"></view>
                     <view class="head_title">
                        不良原因明细
                        不良统计
                     </view>
                  </view>
               </view>
               <u-button type="primary" icon='plus-circle' plain
                  style="height: 100rpx;width: 98%;margin-top: 10rpx;" @click="addUser" class='addClass'
                  text="添加">
               </u-button>
               <view class="flex_between titleFont" style="margin: 20rpx 40rpx 30rpx;">
                  <view>序号</view>
                  <view :style="{width:'200rpx'}">人员名称</view>
                  <view style="width: 184rpx;">分配比例(%)</view>
                  <view>操作</view>
               </view>
               <view class="flex_column ">
               <view class="flex_column marginLeft20 marginRight20" :key="item.usercode"
                  v-for="(item,index) in userArr">
                  <view class="flex_between marginLeft20 marginRight20 contentFont">
                     <view style="width: 60rpx;text-align: center;">{{(index+1)}}</view>
                     <view style="width: 200rpx;text-align: center;">{{item.username}}</view>
                     <view style="width: 240rpx; text-align: center;color: rgb(41, 121, 255);">
                        <u-number-box @focus='isAsyncChange=true' @blur='isAsyncChange=false'
                           :key="item.usercode" :asyncChange='isAsyncChange' step="0.01" :name='item.usercode'
                           @change='numberBoxChange' decimal-length="2" :value="item.ratio" inputWidth='110'>
                        </u-number-box>
                  <u-button type="primary" :plain="true" icon='plus-circle' text="添加"
                     style="width: 90%;margin: 20rpx auto;" @click="add"></u-button>
                  <!-- ngqtyArr -->
                  <view v-for='(item,index) in ngqtyArr' class="badSheetClass" :key="item.uid">
                     <!-- {{item.uid}} -->
                     <view class="badNumber">{{index+1}}</view>
                     <u-icon name="trash" size="20" class="trash" @click="trashDelete(index)"
                        color="rgb(0, 102, 255)"></u-icon>
                     <view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
                        <view style="color: #fff;margin-right: 6rpx;">*</view> 不良数量:
                        <view class='inputClass'>
                           <u--input placeholder="请输入" border="surround" :adjustPosition='false' type='number'
                              v-model="item.ngqty"></u--input>
                        </view>
                        <!-- @change='ngqtyChange(item)' -->
                     </view>
                     <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                        <view style="display: flex;" class="titleFont">
                           <view style="color: #fff;margin-right: 6rpx;">*</view> 不良原因:
                        </view>
                        <view @click='badSheetClick(item)' class="custominputClass">
                           <view v-show='item.badSheetValue.length===0' style="color: rgb(192, 196, 204);">请选择
                           </view>
                           <view v-show='item.badSheetValue.length!==0' class="ellipsis"
                              style="width: 390rpx;">
                              {{item.badSheetValue}}
                           </view>
                           <u-icon :name="item.arrowDown?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                        </view>
                     </view>
                     <u-icon @click="deleteUser(item)" style="width: 50rpx;text-align: center;" name="trash"
                        min='0' max='100' color="#2979ff" size="24">
                     </u-icon>
                     <u-divider></u-divider>
                  </view>
                  <u-divider></u-divider>
                  <!--
                  <u-button type="primary" :plain="true" icon='plus-circle' text="添加"
                     style="width: 90%;margin: 20rpx auto;" @click="add"></u-button> -->
               </view>
            </view>
            </view> -->
         </view>
         <u-gap height="20" bgColor="#eff0f1"></u-gap>
         <u-gap height="10" bgColor="#eff0f1"></u-gap>
         <u-button size="large" :loading="isDisabledSubmitButton" loadingText="正在提交,请稍等..." type="primary"
            @click="submit" text="报工">
         </u-button>
         <!-- 生产班组 -->
         <u-picker v-if="topContent.length!==0" :show="userGroupSheetShow" :columns="userGroupColumns"
            :itemHeight='55' :closeOnClickOverlay='true' @close='userGroupSheetShow=false'
            @confirm='userGroupPickerConfirm' @cancel='userGroupSheetShow=false'>
         </u-picker>
         <!--  设备名称 -->
         <u-picker v-if="topContent.length!==0" :show="eqpSheetShow" :columns="eqpColumns" :itemHeight='55'
            :closeOnClickOverlay='true' @close='eqpSheetShow=false' @confirm='eqpPickerConfirm'
            @cancel='eqpSheetShow=false'>
@@ -264,8 +268,9 @@
         <!-- 不良原因 -->
         <u-action-sheet v-if="topContent.length!==0" :actions="badSelectArr" :safeAreaInsetBottom='true'
            :closeOnClickOverlay="true" :closeOnClickAction="true" @close="badSheetShow=false" :show="badSheetShow"
            :closeOnClickOverlay="true" :closeOnClickAction="true" @close="badSelectClose" :show="badSheetShow"
            @select='badSheetSelect'>
            <view style="min-height: 100rpx;">
               <u-checkbox-group @change="checkboxChange" size='20px' v-model="checkBoxValue" iconPlacement="right"
@@ -280,7 +285,7 @@
         </u-action-sheet>
         <!--  报工人员 -->
         <u-action-sheet v-if="topContent.length!==0" :actions="userSelectArrAll" :safeAreaInsetBottom='true'
            :closeOnClickOverlay="true" :closeOnClickAction="true" @close="userSheetShow=false"
            :show="userSheetShow" @select='userSheetSelect'>
@@ -296,49 +301,30 @@
            </view>
         </u-action-sheet>
         <!-- <u-popup :show="userSheetShow" @close="userSheetShow=false" customStyle='customPopupStyle'
            :safeAreaInsetTop='true' @open="open">
            <u-checkbox-group @change="userCheckboxChange" size='20px' v-model="userCheckBoxValue"
               iconPlacement="right" placement="column">
               <view v-for="(item,index) in userSelectArrAll">
                  <u-checkbox activeColor="rgb(0, 102, 255)" labelSize='18' :key="item.code+index"
                     :name='item.name' :label="item.name">
                  </u-checkbox>
               </view>
            </u-checkbox-group>
         </u-popup> -->
         <!-- 报工人员 -->
         <u-picker v-if="topContent.length!==0" :show="operSheetShow" :columns="operColumns" :itemHeight='55'
            :closeOnClickOverlay='true' @close='operSheetShow=false' @confirm='operPickerConfirm'
            @cancel='operSheetShow=false'>
         </u-picker>
         <u-modal v-if="topContent.length!==0" :show="modalShow" :showCancelButton='true' cancelText='取消'
            @close="modalShow=false" :closeOnClickOverlay="true" style=" " @cancel="modalCancel"
            @confirm="modalConfirm" title="不良明细" :content='modalContent'>
            <!--       <uni-section style="width: 100%;" title=''>
               <uni-data-select v-model="userSelectValue" :clear='false' emptyText :localdata="userSelectArr"
                  @change="userChange">
               </uni-data-select>
            </uni-section> -->
            <!--    <view style="display: flex;flex-direction: column;">
               <view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
                  <view style="color: #fff;margin-right: 6rpx;">*</view> 数量:
                  <view class='inputClass'>
                     <u--input placeholder="请输入" border="surround" @change='ngqtyChange' type='number'
                        v-model="ngqty"></u--input>
                  </view>
               </view>
               <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                  <view style="display: flex;" class="titleFont">
                     <view style="color: #fff;margin-right: 6rpx;">*</view> 原因:
                  </view>
                  <view @click='badSheetClick' class="custominputClass">
                     <view v-show='badSheetValue.length===0' style="color: rgb(192, 196, 204);">请选择</view>
                     <view v-show='badSheetValue.length!==0' class="ellipsis" style="width: 390rpx;">
                        {{badSheetValue}}
                     </view>
                     <u-icon :name="!badSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                  </view>
               </view>
            </view> -->
         </u-modal>
      </view>
@@ -351,7 +337,7 @@
      <!-- 悬浮球 -->
      <!--    <view
         v-show="topContent.length!==0&&!modalShow&&!userGroupSheetShow&&!eqpSheetShow&&!operSheetShow&&!badSheetShow"
         v-show="topContent.length!==0&&!userGroupSheetShow&&!eqpSheetShow&&!operSheetShow&&!badSheetShow"
         @click="topScanClick">
         <drag-ball :x='$DeviceInformation.screenWidth*0.8' :y="$DeviceInformation.screenHeight*0.7"></drag-ball>
      </view> -->
@@ -435,7 +421,25 @@
            ],
            reportqty: '', //报工数量
            ngqty: '', //不良数量
            ngqtyArr: [{
                  uid: new Date().getTime(),
                  ngqty: '',
                  badSheetValue: '',
                  arrowDown: true //向下箭头
               },
               // {
               //    ngqty: '',
               //    badSheetValue: '',
               //    arrowDown: true //向下箭头
               // },
            ], //不良数量、不良原因数组
            badSelectArr: [], //不良原因下拉数组
            badSheetValue: '', //不良原因选中值
            badSheetShow: false,
@@ -444,8 +448,8 @@
            operSheetShow: false,
            operSheetList: [], //操作人员数组
            userArr: [], //报工人员信息数组
            modalShow: false,
            modalContent: '', //模态框数
            userSelectValue: '', //下拉选项值
            userSelectArrAll: [], //所有人员下拉数组
            userSelectArr: [
@@ -656,9 +660,9 @@
               return uni.$u.toast('报工数量不能为空!')
            }
            if (parseFloat(this.reportqty) + parseFloat(this.ngqty) > parseFloat(this.topContent[0].noreportqty)) {
               return uni.$u.toast('报工数量加不良数量不能大于未报数量!')
            }
            // if (parseFloat(this.reportqty) + parseFloat(this.ngqty) > parseFloat(this.topContent[0].noreportqty)) {
            //    return uni.$u.toast('报工数量加不良数量不能大于未报数量!')
            // }
            if (this.reckway === '班组' && this.operSheetValue.length === 0) {
@@ -677,11 +681,11 @@
               })
            }
            if (this.ngqty !== '') {
               if (badcode.length === 0) {
                  return uni.$u.toast('不良原因未选择!')
               }
            }
            // if (this.ngqty !== '') {
            //    if (badcode.length === 0) {
            //       return uni.$u.toast('不良原因未选择!')
            //    }
            // }
@@ -697,6 +701,27 @@
            console.log(this.userSelectValue);
            // reportuser = this.userArr.map(i => i.usercode).join(';') //报工人员
            // 不良原因
            const defectlist = []
            this.ngqtyArr.forEach(i => {
               if (i.badSheetValue.toString().length > 0) {
                  let codeArr = []
                  i.badSheetValue.split(',').forEach(j => {
                     codeArr.push(this.badSelectArr.find(i => i.name === j).code)
                  })
                  defectlist.push({
                     badqty: i.ngqty,
                     defect_code: codeArr.join(',')
                  })
               }
            })
@@ -730,10 +755,11 @@
               startqty: parseFloat(this.reportqty),
               reportqty: parseFloat(this.reportqty),
               inbarcode: R[0].labcode, //入库条码
               defectlist: badcode.length > 0 ? [{
                  defect_code: badcode.join(','),
                  badqty: this.ngqty
               }] : [],
               defectlist,
               // defectlist: badcode.length > 0 ? [{
               //    defect_code: badcode.join(','),
               //    badqty: this.ngqty
               // }] : [],
               remarks: ''
            }
@@ -745,10 +771,19 @@
               this.topContent = []
               this.formData = {}
               this.reportqty = ''
               this.ngqty = ''
               // this.ngqty = ''
               this.reckway = '个人'
               this.userGroupSheetValue = ''
               this.eqpSheetValue = ''
               this.ngqtyArr = [{
                  uid: new Date().getTime(),
                  ngqty: '',
                  badSheetValue: '',
                  arrowDown: true //向下箭头
               }]
               // this.userGroupSheetList = []
               // this.eqpSheetList = []
               // this.badSelectArr = []
@@ -793,12 +828,31 @@
         badSheetSelect(val) {
            // console.log(val,9999999)
         },
         badSheetClick() {
            if (!this.ngqty) {
         badSheetClick(item) {
            // console.log(item, 1)
            if (!item.ngqty) {
               return uni.$u.toast('请先填写不良数量!')
            }
            item.arrowDown = !item.arrowDown
            this.checkBoxValue = item.badSheetValue.split(',')
            this.badSheetShow = true
         },
         badSelectClose() {
            let index = this.ngqtyArr.findIndex(i => !i.arrowDown)
            this.ngqtyArr[index].badSheetValue = this.checkBoxValue.join(',')
            this.ngqtyArr[index].arrowDown = true
            this.checkBoxValue = []
            this.badSheetShow = false
         },
         checkboxChange(val) {
            this.badSheetValue = val.join(',')
            console.log(this.badSheetValue, 5);
@@ -811,52 +865,37 @@
            if (this.reckway === '班组') {
               this.userSheetShow = true
            }
         },
         operSheetSelect(val) {
            this.operSheetValue = val.name
            this.operSheetShow = false
         //单选框值改变时
         radioGroupChange(val) {
            this.userGroupSheetValue = ''
            this.operSheetValue = ''
         },
         // 添加人员按钮
         addUser() {
            this.userSelectArr = []
            this.userSelectArrAll.forEach(i => {
               if (!this.userArr.map(j => j.usercode).includes(i.code)) {
                  this.userSelectArr.push({
                     value: i.code,
                     text: i.name
                  })
               }
            })
            this.modalShow = true
         },
         // 删除人员按钮
         deleteUser(item) {
            this.userArr = this.userArr.filter(i => i.usercode !== item.usercode)
         // 添加
         add() {
         },
         // 模态框取消按钮
         modalCancel() {
            this.modalShow = false
            this.userSelectValue = ''
         },
         // 模态框确认按钮
         modalConfirm() {
            if (this.userSelectValue) {
               this.userArr.unshift({
                  usercode: this.userSelectValue,
                  username: this.userSelectArrAll.find(i => i.code === this.userSelectValue).name
               })
               this.userSelectValue = ''
            } else {
               uni.$u.toast('请选择报工人员!')
            if (this.ngqtyArr.find(i => i.badSheetValue === '')) {
               return uni.$u.toast('请先完善前面不良选项!')
            }
            this.modalShow = false
            this.ngqtyArr.unshift({
               uid: new Date().getTime(),
               ngqty: '',
               badSheetValue: '',
               arrowDown: true //向下箭头
            })
         },
         //删除
         trashDelete(index) {
            console.log(index)
            this.ngqtyArr.splice(index, 1)
         },
         userChange(val) {
            this.userSelectValue = val
         },
@@ -948,4 +987,25 @@
      padding: 30rpx;
      border-bottom: 1rpx solid #eee;
   }
   .badSheetClass {
      position: relative;
   }
   .badNumber {
      position: absolute;
      top: 20rpx;
      left: 20rpx;
      font-size: 26rpx;
      color: rgb(0, 102, 255)
   }
   .trash {
      position: absolute;
      top: 20rpx;
      right: 30rpx;
      font-size: 26rpx;
   }
</style>