小程序需重进页面才提示错误问题

This commit is contained in:
Ledo 2025-07-07 14:54:48 +08:00
parent 391818d086
commit 4194f5e9ee

View File

@ -1,49 +1,49 @@
<script setup lang="ts">
import { toRaw, ref, computed } from 'vue'
import { formatDate } from '@/utils/index'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useLoginStore } from '@/stores/modules/login'
import { getTaskRepotPageAPI, getTaskDetailAPI, postOperateAPI } from '@/services/productionReport'
const popup = ref<UniHelper.UniPopupInstance>()
import { toRaw, ref, computed } from 'vue'
import { formatDate } from '@/utils/index'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useLoginStore } from '@/stores/modules/login'
import { getTaskRepotPageAPI, getTaskDetailAPI, postOperateAPI } from '@/services/productionReport'
const popup = ref<UniHelper.UniPopupInstance>()
const userStore = useLoginStore()
const dictInfo = userStore?.dictInfo || []
const unitDictData = dictInfo.filter(e => e.dictType == 'heli_material_unit') || []
const userId = userStore.userInfo.userId
const userStore = useLoginStore()
const dictInfo = userStore?.dictInfo || []
const unitDictData = dictInfo.filter(e => e.dictType == 'heli_material_unit') || []
const userId = userStore.userInfo.userId
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)
//
const detailInfo = ref({})
let isLoading = ref(false)
const historyList = ref([])
const formObj = ref({})
//
const getData = async () => {
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)
//
const detailInfo = ref({})
let isLoading = ref(false)
const historyList = ref([])
const formObj = ref({})
//
const getData = async () => {
//
// isLoading.value = true
const params = {
@ -61,7 +61,7 @@ const getData = async () => {
if (data.list[0]) {
// Date
formObj.value = data.list[0]
const endTime= new Date(formObj.value.endTimeStr);
const endTime = new Date(formObj.value.endTimeStr);
const startTime = new Date(formObj.value.startTimeStr);
//
const timeDifferenceInMs = endTime - startTime;
@ -69,9 +69,9 @@ const getData = async () => {
//
const timeDifferenceInHours = timeDifferenceInMs / (3600 * 1000);
const roundedTimeDifference = parseFloat(timeDifferenceInHours.toFixed(2));
if ("Y"==detailInfo.value.isOutsourcing){
if ("Y" == detailInfo.value.isOutsourcing) {
}else {
} else {
workTime.value = roundedTimeDifference;
}
@ -83,7 +83,7 @@ const getData = async () => {
const obj = historyList.value[0]
console.log('s')
if (!obj?.amount) {
isShowStart.value= false
isShowStart.value = false
}
}
if (historyList.value.length) {
@ -94,12 +94,12 @@ const getData = async () => {
} 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 beforeAmount = detailInfo.value.totalReportAmount
if(totalAmount >= beforeAmount){
if (totalAmount >= beforeAmount) {
amount.value = totalAmount - beforeAmount
}else{
} else {
amount.value = 0
}
@ -107,17 +107,17 @@ const getData = async () => {
isLoading.value = false
}
//
const isOverBeforeProcedure = ref(true)
const getDetailData = async (id) => {
}
//
const isOverBeforeProcedure = ref(true)
const getDetailData = async (id) => {
//
// isLoading.value = true
const params = {
id,
}
const data = await getTaskDetailAPI(params)
if(data.beforeProcedureStatus == 0){
if (data.beforeProcedureStatus == 0) {
//
isOverBeforeProcedure.value = true;
}
@ -137,9 +137,9 @@ const getDetailData = async (id) => {
data.unit = lineObj.label
detailInfo.value = data || {}
isLoading.value = false
}
const popupShow = ref(false)
onLoad(async (options: any) => {
}
const popupShow = ref(false)
onLoad(async (options : any) => {
await getDetailData(options.id)
await getData()
const obj = historyList.value[0]
@ -147,10 +147,10 @@ onLoad(async (options: any) => {
if (obj && obj?.workTime == null && obj.endTime) {
popupShow.value = true
}
})
})
//
const handleComplate = async () => {
//
const handleComplate = async () => {
isLoading.value = true
const params = {
id: detailInfo.value?.id,
@ -158,14 +158,17 @@ const handleComplate = async () => {
}
try {
const data = await postOperateAPI(params);
console.log(data)
console.log('ai')
} catch (error) {
console.log(error)
console.log('meijinlai ')
uni.showToast({
icon: 'none',
duration: 3000,
title: error.data.msg,
})
} finally {
console.log('jie')
await getDetailData(detailInfo.value.id)
await getData()
const obj = historyList.value[0]
@ -179,9 +182,9 @@ const handleComplate = async () => {
// uni.redirectTo({
// url,
// })
}
//
const handleOk = async (active) => {
}
//
const handleOk = async (active) => {
const params = {
id: detailInfo.value?.id,
active: 'SUBMIT',
@ -189,37 +192,54 @@ const handleOk = async (active) => {
workTime: workTime.value,
}
const data = await postOperateAPI(params)
const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
uni.redirectTo({
url,
})
}
//
const handleStart = async () => {
const pages = getCurrentPages(); //
const currentPage = pages[pages.length - 1]; //
const url = `/${currentPage.route}?${Object.entries(currentPage.options).map(([key, val]) => `${key}=${val}`).join('&')}`;
uni.reLaunch({ url }); //
// const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
// uni.redirectTo({
// url,
// })
}
//
const handleStart = async () => {
const params = {
id: detailInfo.value.id,
active: 'START',
}
const data = await postOperateAPI(params)
const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
uni.redirectTo({
url,
})
}
//
const handleStop = async () => {
const pages = getCurrentPages(); //
const currentPage = pages[pages.length - 1]; //
const url = `/${currentPage.route}?${Object.entries(currentPage.options).map(([key, val]) => `${key}=${val}`).join('&')}`;
uni.reLaunch({ url }); //
// const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
// uni.redirectTo({
// url,
// })
}
//
const handleStop = async () => {
const params = {
id: detailInfo.value?.id,
active: 'END',
}
const data = await postOperateAPI(params)
await getDetailData(detailInfo.value.id)
await getData()
const obj = historyList.value[0]
//
if (obj && obj?.workTime == null && obj.endTime) {
popupShow.value = true
}
// const url = `/pages/productionReport/productionReport-detail?id=${detailInfo.value.id}`
// uni.redirectTo({
// url,
// })
popup.value?.open()
}
}
</script>
<template>
<view>
@ -228,10 +248,12 @@ const handleStop = async () => {
<view class="module">
<view class="module-info">
<view class="product-item">项目{{ detailInfo.projectCode }} {{ detailInfo.projectName }}</view>
<image src="/static/images/productionReport-page.png" class="product-img" mode="scaleToFill"></image>
<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-item">派工工序{{ detailInfo.procedureName }}</view>
<view class="product-row">
@ -255,9 +277,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>
@ -283,7 +307,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>
@ -314,12 +339,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"></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>
@ -333,8 +360,8 @@ const handleStop = async () => {
</template>
<style lang="scss">
//
.data-detail {
//
.data-detail {
border-radius: 10rpx;
padding-bottom: 200rpx;
@ -409,6 +436,7 @@ const handleStop = async () => {
}
}
.finish {
position: absolute;
right: 40rpx;
@ -649,5 +677,5 @@ const handleStop = async () => {
color: #fff;
}
}
}
}
</style>