| | |
| | | </view> --> |
| | | |
| | | <view class="bottom-btn"> |
| | | <button v-if="hform.HIsTimeFlag==0" class="btn-a" size="mini" @tap="beginWork()">开工</button> |
| | | <button v-if="btnType == 0 && !isEdit" class="btn-a" size="mini" @tap="submit">提交</button> |
| | | <button v-if="btnType != 0 && !isEdit" class="btn-a" size="mini" @tap="ifEdit">修改</button> |
| | | <button v-if="btnType != 0 && isEdit" class="btn-a" size="mini" @tap="submit">提交</button> |
| | |
| | | }) { |
| | | console.log(detail.value[0]) |
| | | this.hform.HIsTimeFlag = detail.value[0] || 0 |
| | | if(detail.value[0]){ |
| | | this.getNewHRelBeginDate() |
| | | this.hform.HRelEndTime = getDateTime.dateTimeStr('y-m-d h:i'); |
| | | }else{ |
| | | this.hform.HWorkTimes = 0; |
| | | } |
| | | |
| | | }, |
| | | //通过登录用户获取默认值 |
| | | getDefValByUser() { |
| | |
| | | }else{ |
| | | //设置主序列 |
| | | this.setMainHSEQ(); |
| | | //设置默认工序号 |
| | | if(this.hform.HProcNo!=""&&this.hform.HProcNo!=null){ |
| | | this.getHProcNoData2(this.hform.HBarCode,this.hform.HProcNo,this.hform.HSEQNumber) |
| | | } |
| | | } |
| | | } else { |
| | | uni.showToast({ |
| | |
| | | if(CommonUtils.isEmpty(this.hform.HQty) == true){ |
| | | return {pass: false, message: '提交失败: 报废数量为空'} |
| | | } |
| | | if(this.hform.HIsTimeFlag == 1 && CommonUtils.isEmpty(this.hform.HWorkTimes, true, true)) { |
| | | return {pass: false, message: '提交失败: 开启计时,但工时为0或空'} |
| | | } |
| | | // if(this.hform.HIsTimeFlag == 1 && CommonUtils.isEmpty(this.hform.HWorkTimes, true, true)) { |
| | | // return {pass: false, message: '提交失败: 开启计时,但工时为0或空'} |
| | | // } |
| | | return {pass: true, message: ''} |
| | | }, |
| | | //编辑 |
| | |
| | | } else if (barNo1 == 'GXLX' && data.工序号) { |
| | | this.hform.HProcNo = data.工序号 |
| | | } |
| | | //视图获取当前最新的工序号 |
| | | }else if(data.工序汇报当前工序号!=null && data.工序汇报当前工序号!=""){ |
| | | this.hform.HProcNo = data.工序汇报当前工序号 |
| | | } |
| | | this.hform.HICMOInterID = data.hicmointerid |
| | | this.hform.HICMOBillNo = data.任务单号 |
| | |
| | | this.hform.HNotReportQty = data['未报工数量'] |
| | | this.hform.HProcNumber = data['工序代码'] |
| | | this.hform.HIsTimeFlag = data['是否计时'] ? 1 : 0 |
| | | if(data['是否计时']){ |
| | | this.hform.HRelEndTime = getDateTime.dateTimeStr('y-m-d h:i'); |
| | | this.getNewHRelBeginDate(); |
| | | } |
| | | |
| | | this.hform.HSEQName = data.序列名称 |
| | | // this.hform.HStyleNumber = data['款号'] |
| | | // this.hform.HQty = data.合格数量 |
| | |
| | | }); |
| | | }, |
| | | //获取最新的报工日期 |
| | | getNewHRelBeginDate(){ |
| | | uni.request({ |
| | | url: this.serverUrl + '/Cj_StationOutBill/get_Display', |
| | | data:{ |
| | | sWhere: ` and HEmpID = N'${this.hform.HEmpID}'`, |
| | | user: uni.getStorageSync('HUserName'), |
| | | HBillSubType:'', |
| | | }, |
| | | success: (res) => { |
| | | if(res.data.count == 1){ |
| | | //获取列表数据 |
| | | const listData = res.data.data |
| | | // 获取当前日期(去掉时间部分) |
| | | const today = new Date(); |
| | | today.setHours(0, 0, 0, 0); |
| | | if(listData.length==0){ |
| | | this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i'); |
| | | this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime); |
| | | }else{ |
| | | // 从对象数组中提取所有日期字段并找到最大值 |
| | | const maxDate = listData.reduce((max, obj) => { |
| | | const date = new Date(obj.出站时间); |
| | | return date > max ? date : max; |
| | | }, new Date(0)); // 初始值为最小日期 |
| | | // 比较最大日期和今天的日期部分(不比较时间) |
| | | const maxDateDateOnly = new Date(maxDate); |
| | | maxDateDateOnly.setHours(0, 0, 0, 0); |
| | | // 比较最大日期和今天 |
| | | if (maxDateDateOnly.getTime() !== today.getTime()) { |
| | | // 如果不是今天,返回当前日期 |
| | | this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i'); |
| | | this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime); |
| | | }else{ |
| | | this.hform.HRelBeginTime = getDateTime.formatDate(maxDate); |
| | | this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime); |
| | | } |
| | | } |
| | | }else{ |
| | | uni.showToast({ |
| | | title:res.data.Message, |
| | | icon:'none' |
| | | }) |
| | | } |
| | | }, |
| | | fail: (res) => { |
| | | console.log(res); |
| | | uni.showToast({ |
| | | title:'接口请求失败', |
| | | icon:'none' |
| | | }) |
| | | }, |
| | | }); |
| | | }, |
| | | // getNewHRelBeginDate(){ |
| | | // uni.request({ |
| | | // url: this.serverUrl + '/Cj_StationOutBill/get_Display', |
| | | // data:{ |
| | | // sWhere: ` and HEmpID = N'${this.hform.HEmpID}'`, |
| | | // user: uni.getStorageSync('HUserName'), |
| | | // HBillSubType:'', |
| | | // }, |
| | | // success: (res) => { |
| | | // if(res.data.count == 1){ |
| | | // //获取列表数据 |
| | | // const listData = res.data.data |
| | | // // 获取当前日期(去掉时间部分) |
| | | // const today = new Date(); |
| | | // today.setHours(0, 0, 0, 0); |
| | | // if(listData.length==0){ |
| | | // this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i'); |
| | | // this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime); |
| | | // }else{ |
| | | // // 从对象数组中提取所有日期字段并找到最大值 |
| | | // const maxDate = listData.reduce((max, obj) => { |
| | | // const date = new Date(obj.出站时间); |
| | | // return date > max ? date : max; |
| | | // }, new Date(0)); // 初始值为最小日期 |
| | | // // 比较最大日期和今天的日期部分(不比较时间) |
| | | // const maxDateDateOnly = new Date(maxDate); |
| | | // maxDateDateOnly.setHours(0, 0, 0, 0); |
| | | // // 比较最大日期和今天 |
| | | // if (maxDateDateOnly.getTime() !== today.getTime()) { |
| | | // // 如果不是今天,返回当前日期 |
| | | // this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i'); |
| | | // this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime); |
| | | // }else{ |
| | | // this.hform.HRelBeginTime = getDateTime.formatDate(maxDate); |
| | | // this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime); |
| | | // } |
| | | // } |
| | | // }else{ |
| | | // uni.showToast({ |
| | | // title:res.data.Message, |
| | | // icon:'none' |
| | | // }) |
| | | // } |
| | | // }, |
| | | // fail: (res) => { |
| | | // console.log(res); |
| | | // uni.showToast({ |
| | | // title:'接口请求失败', |
| | | // icon:'none' |
| | | // }) |
| | | // }, |
| | | // }); |
| | | // }, |
| | | //新增 |
| | | getNewData() { |
| | | |
| | |
| | | } |
| | | }); |
| | | }, |
| | | //开工按钮 |
| | | beginWork(){ |
| | | if(this.hform.lngBillKey==''||this.hform.lngBillKey==0||this.hform.lngBillSubKey==''||this.hform.lngBillSubKey==0){ |
| | | |
| | | CommonUtils.showTips({ |
| | | title: "开工失败", |
| | | message: `开工失败请扫描流转卡并选择工序`, |
| | | }); |
| | | return ; |
| | | } |
| | | uni.request({ |
| | | url: this.serverUrl + '/Cj_StationOutBill/startTranslating', |
| | | method: 'GET', |
| | | data: { |
| | | HProcExchInterID: this.hform.lngBillKey, |
| | | HProcExchEntryID:this.hform.lngBillSubKey, |
| | | HOrgID:this.hform.HPRDOrgID, |
| | | HProcNo:this.hform.HProcNo, |
| | | user:uni.getStorageSync('HUserName') |
| | | }, |
| | | success: (res) => { |
| | | uni.hideLoading(); |
| | | if (res.data.count == 1) { |
| | | uni.showToast({ title: '开工成功', icon: 'none' }); |
| | | |
| | | } else { |
| | | CommonUtils.showTips({ |
| | | title: "开工失败", |
| | | message: `${res.data.Message}`, |
| | | }); |
| | | } |
| | | }, |
| | | fail: () => { |
| | | uni.hideLoading(); |
| | | uni.showToast({ title: '接口请求失败', icon: 'none' }); |
| | | }, |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | </script> |