loulijun2021
2024-04-29 094bff4f727d2fd2c6cf5a923d76782aa3f8010a
pages/scgl/scbg.vue
@@ -11,7 +11,7 @@
      </view>
      <view v-show="topContent.length!==0">
         <view class="mainContent" :style="{maxHeight:'1200rpx',overflow: 'scroll'}">
         <view class="mainContent" :style="{maxHeight:'1260rpx',overflow: 'scroll'}">
            <!-- 报工信息 -->
            <u-gap height="15" bgColor="#eff0f1"></u-gap>
@@ -104,8 +104,8 @@
                  </view>
                  <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;"
                     v-if="reckway==='个人'">
                  <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
                     <!-- v-if="reckway==='个人'" -->
                     <view style="display: flex;" class="titleFont">
                        <view style="color: red;margin-right: 6rpx;">*</view> 报工人员:
                     </view>
@@ -139,7 +139,8 @@
                  <view class="flex_center titleFont" style="margin: 0rpx 20rpx 10rpx;line-height: 56rpx;">
                     <view style="color: red;margin-right: 6rpx;">*</view> 报工数量:
                     <view class='inputClass'>
                        <u--input placeholder="请输入" border="surround" type='number' v-model="reportqty">
                        <u--input placeholder="请输入" :adjustPosition='false' border="surround" type='number'
                           v-model="reportqty">
                        </u--input>
                     </view>
                  </view>
@@ -147,8 +148,8 @@
                  <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>
                        <u--input placeholder="请输入" border="surround" :adjustPosition='false'
                           @change='ngqtyChange' type='number' v-model="ngqty"></u--input>
                     </view>
                  </view>
                  <view class="flex_center" style="margin: 0rpx 20rpx 10rpx;line-height: 76rpx;">
@@ -193,13 +194,13 @@
            </view>
            <!-- 报工人员信息 -->
            <u-gap height="15" v-if="reckway==='班组'" bgColor="#eff0f1"></u-gap>
            <!--          <u-gap height="15" v-if="reckway==='班组'" bgColor="#eff0f1"></u-gap>
            <view class="head marginLeft10 marginRight10" v-if="reckway==='班组'">
               <view class="head_block">
                  <view class="head_left">
                     <view class="head_bar"></view>
                     <view class="head_title">
                        报工人员信息
                        不良原因明细
                     </view>
                  </view>
               </view>
@@ -240,7 +241,7 @@
            </view>
            </view> -->
         </view>
@@ -250,17 +251,12 @@
            @click="submit" text="报工">
         </u-button>
         <!--          <u-action-sheet :actions="userGroupSheetList" :safeAreaInsetBottom='true' :closeOnClickOverlay="true"
            :closeOnClickAction="true" @close="userGroupSheetShow=false" :show="userGroupSheetShow"
            @select='userGroupSheetSelect'>
         </u-action-sheet> -->
         <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-action-sheet :actions="eqpSheetList" :safeAreaInsetBottom='true' :closeOnClickOverlay="true"
            :closeOnClickAction="true" @close="eqpSheetShow=false" :show="eqpSheetShow" @select='eqpSheetSelect'>
         </u-action-sheet> -->
         <u-picker v-if="topContent.length!==0" :show="eqpSheetShow" :columns="eqpColumns" :itemHeight='55'
            :closeOnClickOverlay='true' @close='eqpSheetShow=false' @confirm='eqpPickerConfirm'
            @cancel='eqpSheetShow=false'>
@@ -275,8 +271,8 @@
               <u-checkbox-group @change="checkboxChange" size='20px' v-model="checkBoxValue" iconPlacement="right"
                  placement="column">
                  <view v-for="(item,index) in badSelectArr">
                     <u-checkbox activeColor="rgb(0, 102, 255)" labelSize='18' :key="item.code" :name='item.name'
                        :label="item.name">
                     <u-checkbox activeColor="rgb(0, 102, 255)" labelSize='18' :key="item.code+index"
                        :name='item.name' :label="item.name">
                     </u-checkbox>
                     <u-divider :key="item.code"></u-divider>
                  </view>
@@ -285,9 +281,26 @@
         </u-action-sheet>
         <!--       <u-action-sheet :actions="operSheetList" :safeAreaInsetBottom='true' :closeOnClickOverlay="true"
            :closeOnClickAction="true" @close="operSheetShow=false" :show="operSheetShow" @select='operSheetSelect'>
         </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'>
            <view style="min-height: 100rpx;padding: 20rpx 20rpx 30rpx 20rpx;">
               <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>
                     <u-divider :key="item.code"></u-divider>
                  </view>
               </u-checkbox-group>
            </view>
         </u-action-sheet>
         <u-picker v-if="topContent.length!==0" :show="operSheetShow" :columns="operColumns" :itemHeight='55'
            :closeOnClickOverlay='true' @close='operSheetShow=false' @confirm='operPickerConfirm'
            @cancel='operSheetShow=false'>
@@ -296,13 +309,36 @@
         <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'>
            @confirm="modalConfirm" title="不良明细" :content='modalContent'>
            <uni-section style="width: 100%;" title=''>
            <!--       <uni-section style="width: 100%;" title=''>
               <uni-data-select v-model="userSelectValue" :clear='false' emptyText :localdata="userSelectArr"
                  @change="userChange">
               </uni-data-select>
            </uni-section>
            </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>
@@ -334,7 +370,9 @@
      EqpPermissionsPlus,
      GroupsPermissions,
      GroupsPersonPermissions,
      DefectPermissions
      DefectPermissions,
      SavaMesOrderStepReport,
      LabelBarCode
   } from '../../config/api.js';
   // import scanCode from '@/components/scan-code/scan-code.vue'
   export default {
@@ -421,7 +459,10 @@
            userGroupColumns: [], //
            eqpColumns: [], //
            operColumns: [], //
            isAsyncChange: false
            isAsyncChange: false,
            userCheckBoxValue: [],
            userSheetShow: false
         }
      },
      created() {
@@ -431,17 +472,26 @@
         this.init()
         this.getMesOrderStepStart('SGPO20231110_1;101')
         this.getGroupsPermissions() //获取生产班组
         this.getEqpPermissionsPlus() //获取设备名称
         this.getDefectPermissions() //获取缺陷下拉
         this.getPersonPermissions() //获取操作人员
         // this.getGroupsPersonPermissions('BZ001') //根据班组获取人员
         // this.getMesOrderStepStart('SGPO20231110_1;101')
         this.getSellectAllApi()
      },
      methods: {
         init() {
            uni.stopPullDownRefresh();
         },
         async getSellectAllApi() {
            await this.getGroupsPermissions() //获取生产班组
            await this.getEqpPermissionsPlus() //获取设备名称
            await this.getDefectPermissions() //获取缺陷下拉
            await this.getPersonPermissions() //获取操作人员
         },
         //获取生产班组
         async getGroupsPermissions(wkshopcode) {
@@ -475,7 +525,7 @@
               this.badSelectArr = res.data
            }
         },
         // 获取操作人员
         // 获取报工人员
         async getPersonPermissions() {
            const res = await PersonPermissions()
            if (res.code === '200') {
@@ -492,26 +542,46 @@
            }
         },
         // 根据生产班组获取人员
         async getGroupsPersonPermissions(usergroupcode) {
            const res = await GroupsPersonPermissions()
            if (res.code === '200') {
               this.userArr = res.data
               this.calculatedValue()
            }
         },
         // 计算分配比例的值
         calculatedValue() {
            const total = 100;
            let value = 0
            this.userArr.forEach(item => {
               item.ratio = parseFloat((100 / this.userArr.length).toFixed(2))
               value += item.ratio
         async getGroupsPersonPermissions(groupcode) {
            const res = await GroupsPersonPermissions({
               groupcode
            })
            if (Math.round(value * 100) / 100 !== total) {
               this.userArr[this.userArr.length - 1].ratio = parseFloat((this.userArr[this.userArr.length - 1].ratio +
                  (total - value)).toFixed(2))
            if (res.code === '200') {
               this.userCheckBoxValue = []
               if (res.data[0].usercode_list && res.data[0].usercode_list.length > 0) {
                  this.userSelectArrAll.forEach(i => {
                     if (res.data[0].usercode_list.split(',').includes(i.code)) {
                        this.userCheckBoxValue.push(i.name)
                     }
                  })
               }
               this.operSheetValue = this.userCheckBoxValue.join(',')
            }
         },
         userSheetSelect() {
         },
         userCheckboxChange(val) {
            this.userCheckBoxValue = val.join(',')
            // this.userCheckBoxValue = ['001']
            // this.$forceUpdate()
            // console.log(this.userCheckBoxValue);
         },
         //获取开工信息
         async getMesOrderStepStart(orderstepqrcode) {
@@ -579,6 +649,7 @@
         },
         async submit() {
            // 下午写生产报工提交
            if (this.reckway === '班组' && this.userGroupSheetValue === "") {
               return uni.$u.toast('生产班组不能为空!')
@@ -593,38 +664,18 @@
               return uni.$u.toast('报工数量不能为空!')
            }
            if (this.reckway === '班组' && this.userArr.length === 0) {
            if (parseFloat(this.reportqty) + parseFloat(this.ngqty) > parseFloat(this.topContent[0].noreportqty)) {
               return uni.$u.toast('报工数量加不良数量不能大于未报数量!')
            }
            if (this.reckway === '班组' && this.operSheetValue.length === 0) {
               return uni.$u.toast('报工人员信息不能为空!')
            }
            if (this.reckway === '班组') {
               let sum = 0
               this.userArr.forEach(item => {
                  console.log(item.ratio, 'item.ratio')
                  sum += parseFloat(item.ratio)
               })
               sum = parseFloat(sum)
               console.log(sum, 'sum44')
               if (Math.round(sum * 100) / 100 !== 100) {
                  return uni.$u.toast('分配比例总和必须为100!')
               }
            }
            const header = {
               // 'Content-Type': 'multipart/form-data',
               'Content-Type': 'application/x-www-form-urlencoded',
               'rediskey': uni.getStorageSync('rediskey'),
               'admin': uni.getStorageSync('usercode'),
               'username': encodeURIComponent(uni.getStorageSync('username')),
               'navTabId': uni.getStorageSync('usercode'),
               'userid': uni.getStorageSync('userid'),
               'guid': uni.getStorageSync('guid'),
               'usertype': 'APP'
            }
            let badcode = []
            if (this.badSheetValue.length > 0) {
               this.badSelectArr.forEach(i => {
@@ -642,84 +693,95 @@
            let reportuser = ''
            let reportuser = []
            // if (this.$company === 'A') {
            //    reportuser = this.reckway === '班组' ? JSON.stringify(this.userArr) : JSON.stringify([{
            //       usercode: this.operSheetValue,
            //       ratio: 100
            //    }])
            // } else {
            reportuser = this.userArr.map(i => i.usercode).join(';') //报工人员
            // }
            if (this.operSheetValue.length > 0) {
               this.userSelectArrAll.forEach(i => {
                  if (this.operSheetValue.split(',').includes(i.name)) {
                     reportuser.push(i.code)
                  }
               })
            }
            console.log(this.userSelectValue);
            // reportuser = this.userArr.map(i => i.usercode).join(';') //报工人员
            const D = {
               rightcode: '0601',
               partcode: this.topContent[0].partnumber,
               qty: parseFloat(this.reportqty),
               onelabqty: parseFloat(this.reportqty)
            }
            const {
               data: R
            } = await LabelBarCode(D)
            const data = {
               admin: uni.getStorageSync('usercode'),
               mesordercode: this.formData.wo_code, // 工单编号
               partcode: this.formData.partnumber, // 产品编码
               stepseq: this.formData.seq, // 工序序号
               stepcode: this.formData.stepcode, // 工序编码
               eqpcode: this.eqpSheetList.find(i => i.name === this.eqpSheetValue).code, // 设备编码
               taskqty: this.formData.planqty, // 任务数量
               startqty: this.formData.reportqty, // 开工数量
               mesordercode: this.topContent[0].wo_code,
               partcode: this.topContent[0].partnumber,
               stepseq: this.topContent[0].seq,
               stepcode: this.topContent[0].stepcode,
               stepprice: this.topContent[0].stepprice,
               eqpcode: this.eqpSheetList.find(i => i.name === this.eqpSheetValue).code,
               reckway: this.reckway === '班组' ? 'group' : 'person',
               usergroupcode: this.userGroupSheetValue ? this.userGroupSheetList.find(i => i.name === this
                  .userGroupSheetValue).code : '', // 班组编码
               reportqty: parseFloat(this.reportqty), // 报工数量
               // reportuser: this.userArr.map(i => i.usercode).join(';'), //报工人员
               reportuser,
               //报工人员
               remarks: '', // 备注
               reckway: this.reckway === '班组' ? 'group' : 'person', //
               ngqty: this.ngqty === '' ? 0 : this.ngqty, //不良数量
               badcode: badcode.join(';'), //不良原因
               inbarcode: '', //扫码入库
               reportuser: this.reckway === '班组' ? reportuser.join(',') : this.userSelectArrAll.find(i => i
                  .name === this.operSheetValue).code,
               taskqty: this.topContent[0].planqty,
               startqty: parseFloat(this.reportqty),
               reportqty: parseFloat(this.reportqty),
               inbarcode: R[0].labcode, //入库条码
               defectlist: badcode.length > 0 ? [{
                  defect_code: badcode.join(','),
                  badqty: this.ngqty
               }] : [],
               remarks: ''
            }
            console.log(data, 7777)
            console.log(JSON.parse(JSON.stringify(data)), 7777)
            this.isDisabledSubmitButton = true
            uni.uploadFile({
               url: this.$baseUrl + '/AppProductionManagement/SavaMesOrderStepReport',
               files: [{
                  "uri": "/"
               }],
               header: header,
               formData: data,
               success: (res) => {
                  uni.$u.toast('报工成功!')
                  this.topContent = []
                  this.formData = {}
                  this.reportqty = ''
                  this.ngqty = ''
                  this.reckway = '个人'
                  this.userGroupSheetValue = ''
                  this.eqpSheetValue = ''
                  this.userGroupSheetList = []
                  this.eqpSheetList = []
                  this.badSelectArr = []
                  this.badSheetValue = []
                  this.checkBoxValue = []
                  this.operSheetValue = ''
                  this.operSheetList = []
                  this.userArr = []
                  this.userSelectValue = ''
                  this.userSelectArrAll = []
                  this.userSelectArr = []
                  this.userGroupColumns = []
                  this.eqpColumns = []
                  this.operColumns = []
            const res = await SavaMesOrderStepReport(data)
            if (res.code === '200') {
               uni.$u.toast('报工成功!')
               this.topContent = []
               this.formData = {}
               this.reportqty = ''
               this.ngqty = ''
               this.reckway = '个人'
               this.userGroupSheetValue = ''
               this.eqpSheetValue = ''
               // this.userGroupSheetList = []
               // this.eqpSheetList = []
               // this.badSelectArr = []
               this.badSheetValue = []
               this.checkBoxValue = []
               this.operSheetValue = ''
               // this.operSheetList = []
               // this.userArr = []
               this.userSelectValue = ''
               // this.userSelectArrAll = []
               // this.userSelectArr = []
               // this.userGroupColumns = []
               // this.eqpColumns = []
               // this.operColumns = []
               this.userCheckBoxValue = []
               this.userSheetShow = false
                  this.isDisabledSubmitButton = false
               },
               fail(res) {
                  uni.$u.toast('报工失败!')
                  this.isDisabledSubmitButton = false
               },
            })
               this.isDisabledSubmitButton = false
            }
         },
         userGroupSheetSelect(val) {
@@ -750,7 +812,16 @@
            console.log(this.badSheetValue, 5);
         },
         operSheetClick() {
            this.operSheetShow = true
            if (this.reckway === '个人') {
               this.operSheetShow = true
            }
            if (this.reckway === '班组') {
               this.userSheetShow = true
            }
         },
         operSheetSelect(val) {
            this.operSheetValue = val.name
@@ -773,7 +844,7 @@
         // 删除人员按钮
         deleteUser(item) {
            this.userArr = this.userArr.filter(i => i.usercode !== item.usercode)
            this.calculatedValue()
         },
         // 模态框取消按钮
         modalCancel() {
@@ -792,7 +863,7 @@
               uni.$u.toast('请选择报工人员!')
            }
            this.modalShow = false
            this.calculatedValue()
         },
         userChange(val) {
            this.userSelectValue = val