小程序:
1.要求开始生产退出后,在进入不弹框 2.时间显示错误纠正 3.计算错误纠正
This commit is contained in:
		
							parent
							
								
									68c24314f5
								
							
						
					
					
						commit
						c2d538f532
					
				@ -11,28 +11,30 @@ const dictInfo = userStore?.dictInfo || []
 | 
				
			|||||||
const unitDictData = dictInfo.filter(e => e.dictType == 'heli_material_unit') || []
 | 
					const unitDictData = dictInfo.filter(e => e.dictType == 'heli_material_unit') || []
 | 
				
			||||||
const userId = userStore.userInfo.userId
 | 
					const userId = userStore.userInfo.userId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isShowStart = computed(() => {
 | 
					const isShowStart = ref(false)
 | 
				
			||||||
  let flag = true
 | 
					const isShowEnd = ref(false)
 | 
				
			||||||
  if (historyList.value.length) {
 | 
					// const isShowStart = computed(() => {
 | 
				
			||||||
    const obj = historyList.value[0]
 | 
					//   let flag = true
 | 
				
			||||||
    if (!obj?.endTime) {
 | 
					//   if (historyList.value.length) {
 | 
				
			||||||
      flag = false
 | 
					//     const obj = historyList.value[0]
 | 
				
			||||||
    }
 | 
					//     if (!obj?.endTime) {
 | 
				
			||||||
  }
 | 
					//       flag = false
 | 
				
			||||||
  return flag
 | 
					//     }
 | 
				
			||||||
})
 | 
					//   }
 | 
				
			||||||
const isShowEnd = computed(() => {
 | 
					//   return flag
 | 
				
			||||||
  let flag = true
 | 
					// })
 | 
				
			||||||
  if (historyList.value.length) {
 | 
					// const isShowEnd = computed(() => {
 | 
				
			||||||
    const obj = historyList.value[0]
 | 
					//   let flag = true
 | 
				
			||||||
    if (obj?.endTime) {
 | 
					//   if (historyList.value.length) {
 | 
				
			||||||
      flag = false
 | 
					//     const obj = historyList.value[0]
 | 
				
			||||||
    }
 | 
					//     if (obj?.endTime) {
 | 
				
			||||||
  } else {
 | 
					//       flag = false
 | 
				
			||||||
    flag = false
 | 
					//     }
 | 
				
			||||||
  }
 | 
					//   } else {
 | 
				
			||||||
  return flag
 | 
					//     flag = false
 | 
				
			||||||
})
 | 
					//   }
 | 
				
			||||||
 | 
					//   return flag
 | 
				
			||||||
 | 
					// })
 | 
				
			||||||
const amount = ref(null)
 | 
					const amount = ref(null)
 | 
				
			||||||
const workTime = ref(null)
 | 
					const workTime = ref(null)
 | 
				
			||||||
// 详情数据
 | 
					// 详情数据
 | 
				
			||||||
@ -56,28 +58,42 @@ const getData = async () => {
 | 
				
			|||||||
    e.endTimeStr = e.endTime && formatDate(e.endTime, 'YYYY-MM-DD HH:mm')
 | 
					    e.endTimeStr = e.endTime && formatDate(e.endTime, 'YYYY-MM-DD HH:mm')
 | 
				
			||||||
 	    // e.endTimeStr =  '2025-01-13 00:00'
 | 
					 	    // e.endTimeStr =  '2025-01-13 00:00'
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 //  if (data.list[0]) {
 | 
					 if (data.list[0]) {
 | 
				
			||||||
 //    formObj.value = data.list[0]
 | 
					   // 将字符串转换为Date对象
 | 
				
			||||||
 //    const time = formObj.value.endTime - formObj.value.startTime //时间差秒
 | 
					   formObj.value = data.list[0]
 | 
				
			||||||
 	// console.log(time)
 | 
					   const endTime= new Date(formObj.value.endTimeStr);
 | 
				
			||||||
 //    const leave1 = time % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
 | 
					   const startTime = new Date(formObj.value.startTimeStr);
 | 
				
			||||||
 //    workTime.value = Math.floor(leave1 / (3600 * 1000))
 | 
					   // 计算两个日期之间的毫秒差
 | 
				
			||||||
 //  }
 | 
					   const timeDifferenceInMs = endTime - startTime;
 | 
				
			||||||
 // if (data.list[0]) {
 | 
					
 | 
				
			||||||
 //     // 将字符串转换为Date对象
 | 
					   // 将毫秒差转换为小时
 | 
				
			||||||
 // 	 formObj.value = data.list[0]
 | 
					   const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
 | 
				
			||||||
 //     const endTime= new Date(formObj.value.endTimeStr);
 | 
					   const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
 | 
				
			||||||
 //     const startTime = new Date(formObj.value.startTimeStr);
 | 
					   if ("Y"==detailInfo.value.isOutsourcing){
 | 
				
			||||||
 
 | 
					
 | 
				
			||||||
 //     // 计算两个日期之间的毫秒差
 | 
					   }else {
 | 
				
			||||||
 //     const timeDifferenceInMs = endTime - startTime;
 | 
					     workTime.value = roundedTimeDifference;
 | 
				
			||||||
 
 | 
					   }
 | 
				
			||||||
 //     // 将毫秒差转换为小时
 | 
					
 | 
				
			||||||
 //     const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
 | 
					 }
 | 
				
			||||||
 // 	 const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
 | 
					 | 
				
			||||||
 // 	 workTime.value = roundedTimeDifference;
 | 
					 | 
				
			||||||
 // }
 | 
					 | 
				
			||||||
  historyList.value = data.list
 | 
					  historyList.value = data.list
 | 
				
			||||||
 | 
					  isShowEnd.value = true;
 | 
				
			||||||
 | 
					  isShowStart.value = true
 | 
				
			||||||
 | 
					  if (historyList.value.length) {
 | 
				
			||||||
 | 
					    const obj = historyList.value[0]
 | 
				
			||||||
 | 
						console.log('s')
 | 
				
			||||||
 | 
					    if (!obj?.amount) {
 | 
				
			||||||
 | 
					      isShowStart.value= false
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
						  if (historyList.value.length) {
 | 
				
			||||||
 | 
						    const obj = historyList.value[0]
 | 
				
			||||||
 | 
						    if (obj?.amount) {
 | 
				
			||||||
 | 
						      isShowEnd.value = false
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						  } else {
 | 
				
			||||||
 | 
						    isShowEnd.value = false
 | 
				
			||||||
 | 
						  }
 | 
				
			||||||
  if(historyList.value!=null&&historyList.value.length>0){
 | 
					  if(historyList.value!=null&&historyList.value.length>0){
 | 
				
			||||||
  	  var totalAmount = detailInfo.value.amount;
 | 
					  	  var totalAmount = detailInfo.value.amount;
 | 
				
			||||||
  	  var beforeAmount = detailInfo.value.totalReportAmount
 | 
					  	  var beforeAmount = detailInfo.value.totalReportAmount
 | 
				
			||||||
@ -88,6 +104,7 @@ const getData = async () => {
 | 
				
			|||||||
 	  }
 | 
					 	  }
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  isLoading.value = false
 | 
					  isLoading.value = false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -107,27 +124,28 @@ const getDetailData = async (id) => {
 | 
				
			|||||||
	data.startTime = formatDate(data.startTime, 'YYYY-MM-DD HH:mm');
 | 
						data.startTime = formatDate(data.startTime, 'YYYY-MM-DD HH:mm');
 | 
				
			||||||
	data.endTime = formatDate(data.endTime, 'YYYY-MM-DD HH:mm'); // 去掉了末尾的空格
 | 
						data.endTime = formatDate(data.endTime, 'YYYY-MM-DD HH:mm'); // 去掉了末尾的空格
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const endTime = new Date(data.endTime);
 | 
						// const endTime = new Date(data.endTime);
 | 
				
			||||||
	const startTime = new Date(data.startTime);
 | 
						// const startTime = new Date(data.startTime);
 | 
				
			||||||
	// // 计算两个日期之间的毫秒差
 | 
						// // // 计算两个日期之间的毫秒差
 | 
				
			||||||
	const timeDifferenceInMs = endTime - startTime;
 | 
						// const timeDifferenceInMs = endTime - startTime;
 | 
				
			||||||
	// // 将毫秒差转换为小时
 | 
						// // // 将毫秒差转换为小时
 | 
				
			||||||
	const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
 | 
						// const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
 | 
				
			||||||
	const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
 | 
						// const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
 | 
				
			||||||
	workTime.value = roundedTimeDifference;
 | 
						// workTime.value = roundedTimeDifference;
 | 
				
			||||||
  // 单位枚举
 | 
					  // 单位枚举
 | 
				
			||||||
  const lineObj = unitDictData.find((q) => q.value == data.unit) || {}
 | 
					  const lineObj = unitDictData.find((q) => q.value == data.unit) || {}
 | 
				
			||||||
  data.unit = lineObj.label
 | 
					  data.unit = lineObj.label
 | 
				
			||||||
  detailInfo.value = data || {}
 | 
					  detailInfo.value = data || {}
 | 
				
			||||||
  isLoading.value = false
 | 
					  isLoading.value = false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					const popupShow = ref(false)
 | 
				
			||||||
onLoad(async (options: any) => {
 | 
					onLoad(async (options: any) => {
 | 
				
			||||||
  await getDetailData(options.id)
 | 
					  await getDetailData(options.id)
 | 
				
			||||||
  await getData()
 | 
					  await getData()
 | 
				
			||||||
  const obj = historyList.value[0]
 | 
					  const obj = historyList.value[0]
 | 
				
			||||||
    // 最新的报工是否完成
 | 
					    // 最新的报工是否完成
 | 
				
			||||||
  if (obj && obj?.workTime == null && obj.endTime) {
 | 
					  if (obj && obj?.workTime == null && obj.endTime) {
 | 
				
			||||||
    popup.value?.open()
 | 
					       popupShow.value = true
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -151,6 +169,7 @@ const handleComplate = async () => {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
// 提交报工
 | 
					// 提交报工
 | 
				
			||||||
const handleOk = async (active) => {
 | 
					const handleOk = async (active) => {
 | 
				
			||||||
 | 
					console.log(amount.value)
 | 
				
			||||||
  const params = {
 | 
					  const params = {
 | 
				
			||||||
    id: detailInfo.value?.id,
 | 
					    id: detailInfo.value?.id,
 | 
				
			||||||
    active: 'SUBMIT',
 | 
					    active: 'SUBMIT',
 | 
				
			||||||
@ -182,10 +201,11 @@ const handleStop = async () => {
 | 
				
			|||||||
    active: 'END',
 | 
					    active: 'END',
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  const data = await postOperateAPI(params)
 | 
					  const data = await postOperateAPI(params)
 | 
				
			||||||
  const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
 | 
					  await getData()
 | 
				
			||||||
  uni.redirectTo({
 | 
					  // const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
 | 
				
			||||||
    url,
 | 
					  // uni.redirectTo({
 | 
				
			||||||
  })
 | 
					  //   url,
 | 
				
			||||||
 | 
					  // })
 | 
				
			||||||
  popup.value?.open()
 | 
					  popup.value?.open()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
@ -260,8 +280,8 @@ const handleStop = async () => {
 | 
				
			|||||||
        </view>
 | 
					        </view>
 | 
				
			||||||
      </view>
 | 
					      </view>
 | 
				
			||||||
      <view class="action" v-if="detailInfo.procedureStatus !== 2">
 | 
					      <view class="action" v-if="detailInfo.procedureStatus !== 2">
 | 
				
			||||||
        <view class="action-item start" v-if="isShowStart" @click="handleStart">开始生产</view>
 | 
							  <view class="action-item start" v-if="isShowStart" @click="handleStart">开始生产</view>
 | 
				
			||||||
        <view class="action-item stop" v-if="isShowEnd" @click="handleStop">结束生产</view>
 | 
							    <view class="action-item stop" v-if="isShowEnd" @click="handleStop">结束生产</view>
 | 
				
			||||||
        <!-- <view class="action-item finish" v-if="isShowFinish" @click="handleComplate">生产完成</view> -->
 | 
					        <!-- <view class="action-item finish" v-if="isShowFinish" @click="handleComplate">生产完成</view> -->
 | 
				
			||||||
      </view>
 | 
					      </view>
 | 
				
			||||||
    </template>
 | 
					    </template>
 | 
				
			||||||
@ -274,20 +294,20 @@ const handleStop = async () => {
 | 
				
			|||||||
      <view class="cont">
 | 
					      <view class="cont">
 | 
				
			||||||
        <view class="item">
 | 
					        <view class="item">
 | 
				
			||||||
          <view class="label">开始生产时间:</view>
 | 
					          <view class="label">开始生产时间:</view>
 | 
				
			||||||
          <view class="val">{{ detailInfo.startTime }}</view>
 | 
					          <view class="val">{{ formObj.startTimeStr }}</view>
 | 
				
			||||||
        </view>
 | 
					        </view>
 | 
				
			||||||
        <view class="item">
 | 
					        <view class="item">
 | 
				
			||||||
          <view class="label">结束生产时间:</view>
 | 
					          <view class="label">结束生产时间:</view>
 | 
				
			||||||
          <view class="val">{{ detailInfo.endTime }}</view>
 | 
					          <view class="val">{{ formObj.endTimeStr }}</view>
 | 
				
			||||||
        </view>
 | 
					        </view>
 | 
				
			||||||
        <view class="item">
 | 
					        <view class="item">
 | 
				
			||||||
          <view class="label"><span class="star">*</span>本次报工工时:</view>
 | 
					          <view class="label"><span class="star">*</span>本次报工工时:</view>
 | 
				
			||||||
          <uni-easyinput class="val" type="digit" v-model="amount" placeholder="请输入本次报工工时"></uni-easyinput>
 | 
					          <uni-easyinput class="val" type="digit" v-model="workTime" placeholder="请输入本次报工工时"></uni-easyinput>
 | 
				
			||||||
          <view class="unit">时</view>
 | 
					          <view class="unit">时</view>
 | 
				
			||||||
        </view>
 | 
					        </view>
 | 
				
			||||||
        <view class="item">
 | 
					        <view class="item">
 | 
				
			||||||
          <view class="label"><span class="star">*</span>本次报工数量:</view>
 | 
					          <view class="label"><span class="star">*</span>本次报工数量:</view>
 | 
				
			||||||
          <uni-easyinput class="val" type="number" v-model="workTime" placeholder="请输入本次报工数量"></uni-easyinput>
 | 
					          <uni-easyinput class="val" type="number" v-model="amount" placeholder="请输入本次报工数量"></uni-easyinput>
 | 
				
			||||||
          <view class="unit"> {{ detailInfo.unit }}</view>
 | 
					          <view class="unit"> {{ detailInfo.unit }}</view>
 | 
				
			||||||
        </view>
 | 
					        </view>
 | 
				
			||||||
      </view>
 | 
					      </view>
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user