loulijun2021
2023-11-14 98d719a0d913edc6b438e58959a5fe6435faf440
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>
@@ -270,8 +270,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>
@@ -288,8 +288,8 @@
               <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" :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>
@@ -369,7 +369,9 @@
      EqpPermissionsPlus,
      GroupsPermissions,
      GroupsPersonPermissions,
      DefectPermissions
      DefectPermissions,
      SavaMesOrderStepReport,
      LabelBarCode
   } from '../../config/api.js';
   // import scanCode from '@/components/scan-code/scan-code.vue'
   export default {
@@ -469,7 +471,7 @@
         this.init()
         this.getMesOrderStepStart('SGPO20231110_1;101')
         // this.getMesOrderStepStart('SGPO20231110_1;101')
@@ -646,6 +648,7 @@
         },
         async submit() {
            // 下午写生产报工提交
            if (this.reckway === '班组' && this.userGroupSheetValue === "") {
               return uni.$u.toast('生产班组不能为空!')
@@ -660,38 +663,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 => {
@@ -709,84 +692,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) {