小程序:

1.要求开始生产退出后,在进入不弹框
2.时间显示错误纠正
3.计算错误纠正
This commit is contained in:
Ledo 2025-05-17 15:44:49 +08:00
parent 68c24314f5
commit c2d538f532
2 changed files with 685 additions and 630 deletions

View File

@ -11,28 +11,30 @@ const dictInfo = userStore?.dictInfo || []
const unitDictData = dictInfo.filter(e => e.dictType == 'heli_material_unit') || []
const userId = userStore.userInfo.userId
const isShowStart = computed(() => {
let flag = true
if (historyList.value.length) {
const obj = historyList.value[0]
if (!obj?.endTime) {
flag = false
}
}
return flag
})
const isShowEnd = computed(() => {
let flag = true
if (historyList.value.length) {
const obj = historyList.value[0]
if (obj?.endTime) {
flag = false
}
} else {
flag = false
}
return flag
})
const isShowStart = ref(false)
const isShowEnd = ref(false)
// const isShowStart = computed(() => {
// let flag = true
// if (historyList.value.length) {
// const obj = historyList.value[0]
// if (!obj?.endTime) {
// flag = false
// }
// }
// return flag
// })
// const isShowEnd = computed(() => {
// let flag = true
// if (historyList.value.length) {
// const obj = historyList.value[0]
// if (obj?.endTime) {
// flag = false
// }
// } else {
// flag = false
// }
// return flag
// })
const amount = 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 = '2025-01-13 00:00'
})
// if (data.list[0]) {
// formObj.value = data.list[0]
// const time = formObj.value.endTime - formObj.value.startTime //
// console.log(time)
// const leave1 = time % (24 * 3600 * 1000) //
// workTime.value = Math.floor(leave1 / (3600 * 1000))
// }
// if (data.list[0]) {
// // Date
// formObj.value = data.list[0]
// const endTime= new Date(formObj.value.endTimeStr);
// const startTime = new Date(formObj.value.startTimeStr);
if (data.list[0]) {
// Date
formObj.value = data.list[0]
const endTime= new Date(formObj.value.endTimeStr);
const startTime = new Date(formObj.value.startTimeStr);
//
const timeDifferenceInMs = endTime - startTime;
// //
// const timeDifferenceInMs = endTime - startTime;
//
const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
if ("Y"==detailInfo.value.isOutsourcing){
// //
// const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
// const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
// workTime.value = roundedTimeDifference;
// }
}else {
workTime.value = roundedTimeDifference;
}
}
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){
var totalAmount = detailInfo.value.amount;
var beforeAmount = detailInfo.value.totalReportAmount
@ -89,6 +105,7 @@ const getData = async () => {
}
isLoading.value = false
}
//
@ -107,27 +124,28 @@ const getDetailData = async (id) => {
data.startTime = formatDate(data.startTime, 'YYYY-MM-DD HH:mm');
data.endTime = formatDate(data.endTime, 'YYYY-MM-DD HH:mm'); //
const endTime = new Date(data.endTime);
const startTime = new Date(data.startTime);
// //
const timeDifferenceInMs = endTime - startTime;
// //
const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
workTime.value = roundedTimeDifference;
// const endTime = new Date(data.endTime);
// const startTime = new Date(data.startTime);
// // //
// const timeDifferenceInMs = endTime - startTime;
// // //
// const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
// const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
// workTime.value = roundedTimeDifference;
//
const lineObj = unitDictData.find((q) => q.value == data.unit) || {}
data.unit = lineObj.label
detailInfo.value = data || {}
isLoading.value = false
}
const popupShow = ref(false)
onLoad(async (options: any) => {
await getDetailData(options.id)
await getData()
const obj = historyList.value[0]
//
if (obj && obj?.workTime == null && obj.endTime) {
popup.value?.open()
popupShow.value = true
}
})
@ -151,6 +169,7 @@ const handleComplate = async () => {
}
//
const handleOk = async (active) => {
console.log(amount.value)
const params = {
id: detailInfo.value?.id,
active: 'SUBMIT',
@ -182,10 +201,11 @@ const handleStop = async () => {
active: 'END',
}
const data = await postOperateAPI(params)
const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
uni.redirectTo({
url,
})
await getData()
// const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
// uni.redirectTo({
// url,
// })
popup.value?.open()
}
</script>
@ -274,20 +294,20 @@ const handleStop = async () => {
<view class="cont">
<view class="item">
<view class="label">开始生产时间</view>
<view class="val">{{ detailInfo.startTime }}</view>
<view class="val">{{ formObj.startTimeStr }}</view>
</view>
<view class="item">
<view class="label">结束生产时间</view>
<view class="val">{{ detailInfo.endTime }}</view>
<view class="val">{{ formObj.endTimeStr }}</view>
</view>
<view class="item">
<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>
<view class="item">
<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>
</view>

View File

@ -10,32 +10,34 @@ const dictInfo = userStore?.dictInfo || []
const unitDictData = dictInfo.filter(e => e.dictType == 'heli_material_unit') || []
const userId = userStore.userInfo.userId
const isShowStart = computed(() => {
let flag = true
if (historyList.value.length) {
const obj = historyList.value[0]
if (!obj?.endTime) {
flag = false
}
}
// //
// if (detailInfo.value.amount == detailInfo.value.totalReportAmount) {
const isShowStart = ref(false)
const isShowEnd = ref(false)
// const isShowStart = computed(() => {
// let flag = true
// if (historyList.value.length) {
// const obj = historyList.value[0]
// if (!obj?.endTime) {
// flag = false
// }
return flag
})
const isShowEnd = computed(() => {
let flag = true
if (historyList.value.length) {
const obj = historyList.value[0]
if (obj?.endTime) {
flag = false
}
} else {
flag = false
}
return flag
})
// }
// // //
// // if (detailInfo.value.amount == detailInfo.value.totalReportAmount) {
// // flag = false
// // }
// return flag
// })
// const isShowEnd = computed(() => {
// let flag = true
// if (historyList.value.length) {
// const obj = historyList.value[0]
// if (obj?.endTime) {
// flag = false
// }
// } else {
// flag = false
// }
// return flag
// })
const amount = ref('')
const workTime = ref('')
//
@ -59,13 +61,6 @@ const getData = async () => {
e.endTimeStr = e.endTime && formatDate(e.endTime, 'YYYY-MM-DD HH:mm')
// e.endTimeStr = '2025-01-13 00:00'
})
// if (data.list[0]) {
// formObj.value = data.list[0]
// const time = formObj.value.endTime - formObj.value.startTime //
// console.log(time)
// const leave1 = time % (24 * 3600 * 1000) //
// workTime.value = Math.floor(leave1 / (3600 * 1000))
// }
if (data.list[0]) {
// Date
formObj.value = data.list[0]
@ -85,6 +80,24 @@ const getData = async () => {
}
historyList.value = data.list
isShowEnd.value = true;
isShowStart.value = true
if (historyList.value.length) {
const obj = historyList.value[0]
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
}
console.log(isShowEnd.value);
console.log(isShowStart.value)
if (historyList.value != null && historyList.value.length > 0) {
var totalAmount = detailInfo.value.amount;
var beforeAmount = detailInfo.value.totalReportAmount
@ -125,7 +138,7 @@ onLoad(async (options: any) => {
const obj = historyList.value[0]
//
if (obj && obj?.workTime == null && obj.endTime) {
popup.value?.open()
popupShow.value = true
}
})
@ -176,6 +189,7 @@ const handleStart = async () => {
url,
})
}
const popupShow = ref(false)
const productionTitle = ref('开始生产')
//
const handleStop = async () => {
@ -185,11 +199,11 @@ const handleStop = async () => {
}
console.log(detailInfo.value)
const data = await postOperateAPI(params)
const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
uni.redirectTo({
url,
})
await getData()
// const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
// uni.redirectTo({
// url,
// })
popup.value?.open()
}
</script>
@ -199,11 +213,14 @@ const handleStop = async () => {
<template v-if="!isLoading">
<view class="module">
<view class="module-info">
<view class="product-item product-name">项目{{ detailInfo.projectCode }} {{ detailInfo.projectName }}</view>
<image src="/static/images/productionReport-page.png" class="product-img" mode="scaleToFill"></image>
<view class="product-item product-name">项目{{ detailInfo.projectCode }}
{{ detailInfo.projectName }}</view>
<image src="/static/images/productionReport-page.png" class="product-img" mode="scaleToFill">
</image>
<view :class="[detailInfo.procedureStatus == 2 ? 'had' : 'unhad', 'product-status']">{{
detailInfo.procedureStatus == 2 ? '已完成' : '未完成' }}</view>
<view class="product-item">子项目{{ detailInfo.projectSubCode || '' }} {{' ' + detailInfo.projectSubName }}
<view class="product-item">子项目{{ detailInfo.projectSubCode || '' }}
{{' ' + detailInfo.projectSubName }}
</view>
<view class="product-row">
<view class="row-item">
@ -234,9 +251,11 @@ const handleStop = async () => {
</view>
</view>
<view class="product-item">预计生产日期{{ detailInfo.startTime }} {{ detailInfo.endTime }}</view>
<view class="finish" v-if="isShowStart && detailInfo.procedureStatus !== 2 && detailInfo.totalWorkTime"
<view class="finish"
v-if="isShowStart && detailInfo.procedureStatus !== 2 && detailInfo.totalWorkTime"
@click="handleComplate">
<image class="complate-img" src="/static/images/productionReport-detail-complate.png" mode="scaleToFill" />
<image class="complate-img" src="/static/images/productionReport-detail-complate.png"
mode="scaleToFill" />
生产完成
</view>
</view>
@ -263,7 +282,8 @@ const handleStop = async () => {
</view>
</view>
<view class="tip-index">
<image src="/static/images/productionReport-detail-index.png" class="icon-status" mode="scaleToFit">
<image src="/static/images/productionReport-detail-index.png" class="icon-status"
mode="scaleToFit">
</image>
<view class="text">{{historyList.length - index}}</view>
</view>
@ -273,7 +293,7 @@ const handleStop = async () => {
</view>
</view>
<view class="action" v-if="detailInfo.procedureStatus !== 2">
<view class="action-item start" v-if="isShowStart" @click="handleStart">{{productionTitle}}</view>
<view class="action-item start" v-if="isShowStart" @click="handleStart">开始生产</view>
<view class="action-item stop" v-if="isShowEnd" @click="handleStop">结束生产</view>
</view>
</template>
@ -294,12 +314,14 @@ const handleStop = async () => {
</view>
<view class="item">
<view class="label"><span class="star">*</span>本次报工工时</view>
<uni-easyinput class="val" type="digit" v-model="workTime" placeholder="请输入本次报工工时"></uni-easyinput>
<uni-easyinput class="val" type="digit" v-model="workTime"
placeholder="请输入本次报工工时"></uni-easyinput>
<view class="unit">{{ detailInfo.isOutsourcing=='Y'?"元":"小时" }}</view>
</view>
<view class="item">
<view class="label"><span class="star">*</span>本次报工数量</view>
<uni-easyinput class="val" type="number" v-model="amount" placeholder="请输入本次报工数量"></uni-easyinput>
<uni-easyinput class="val" type="number" v-model="amount"
placeholder="请输入本次报工数量"></uni-easyinput>
<view class="unit"> {{ detailInfo.unit }}</view>
</view>
</view>
@ -346,10 +368,12 @@ const handleStop = async () => {
border-raduis: 10rpx;
text-align: center;
padding: 8rpx 12rpx;
&.had {
background: #E8FFEA;
color: #00B42A;
}
&.unhad {
background: #FFF7E8;
color: #FF7D00;
@ -387,6 +411,7 @@ const handleStop = async () => {
}
}
.finish {
position: absolute;
right: 40rpx;
@ -400,6 +425,7 @@ const handleStop = async () => {
display: flex;
align-items: center;
justify-content: center;
.complate-img {
width: 30rpx;
height: 30rpx;
@ -441,10 +467,12 @@ const handleStop = async () => {
.product-item {
margin: 10rpx 0;
.hight-color {
color: #00B42A;
}
}
.product-row {
margin: 20rpx 0;
display: flex;
@ -456,8 +484,10 @@ const handleStop = async () => {
flex: 1;
display: flex;
flex-direction: row;
.label {
margin-bottom: 10rpx;
&.high-color {
color: #00B42A
}
@ -473,15 +503,18 @@ const handleStop = async () => {
}
}
.tip-index {
position: absolute;
top: 0rpx;
right: 0rpx;
.icon-status {
width: 100rpx;
height: 72rpx;
z-index: 1;
}
.text {
color: #fff;
position: absolute;
@ -590,6 +623,7 @@ const handleStop = async () => {
.label {
font-size: 32rpx;
width: 260rpx;
.star {
color: red
}
@ -599,6 +633,7 @@ const handleStop = async () => {
flex: 1;
font-size: 32rpx;
}
.unit {
width: 100rpx;
margin-left: 4rpx;