From fcc4e79283c8b21f5240b81cbb040541e1774e7b Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Thu, 22 Jan 2026 10:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=8D=9F=E3=80=81=E7=BB=B4=E4=BF=AE?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=A0=87=E8=AE=B0=E4=BD=8D=E7=BD=AE=E5=9B=9E?= =?UTF-8?q?=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/repair/equipAssessment/details.vue | 164 +++++++++------- src/pages/repair/equipAssessment/index.vue | 195 ++++++++++--------- src/pages/repair/repairManage/details.vue | 103 +++++----- src/pages/repair/repairManage/index.vue | 40 +++- 4 files changed, 276 insertions(+), 226 deletions(-) diff --git a/src/pages/repair/equipAssessment/details.vue b/src/pages/repair/equipAssessment/details.vue index 8b2b66a..410aa8f 100644 --- a/src/pages/repair/equipAssessment/details.vue +++ b/src/pages/repair/equipAssessment/details.vue @@ -158,28 +158,36 @@ const options = ref([ ]) // 右滑按钮点击事件 const onClick = async (e, item) => { - // 驳回逻辑 - console.log('驳回') + // 驳回逻辑 + console.log('驳回') console.log(item) - const parm ={ - ids:item.ids - } - console.log(parm) - const res = await repairRejectAPI(parm) - if (res.code === 200) { - await uni.showToast({ - title: '驳回成功!', - icon: 'none', - }) - await getRepairDetailsData() - } + // 标记操作 + uni.setStorageSync('fromDetailOperation', true) + + const parm = { + ids:item.ids + } + console.log(parm) + const res = await repairRejectAPI(parm) + if (res.code === 200) { + await uni.showToast({ + title: '驳回成功!', + icon: 'none', + }) + await getRepairDetailsData() + } } const search = () => { - console.log('🚀 ~ search ~ keyWord:', keyWord.value) - getRepairDetailsData() + console.log('🚀 ~ search ~ keyWord:', keyWord.value) + // 标记操作 + uni.setStorageSync('fromDetailOperation', true) + getRepairDetailsData() } const submit = async () => { + // 标记操作 + uni.setStorageSync('fromDetailOperation', true) + // 提交逻辑 const res = await repairSubmitAPI([{taskId: taskId.value}]) if (res.code === 200) { @@ -195,48 +203,51 @@ const submit = async () => { // 获取列表详情 const getRepairDetailsData = async () => { - const res = await getLossAssessmentDetailsAPI({ taskId: taskId.value,keyword:keyWord.value }) - console.log("xxxxxxxxxxxxx",res) - detailsList.value = res.data - detailsList.value = detailsList.value.map((e) => { - return { ...e, isChecked: false } - }) + const res = await getLossAssessmentDetailsAPI({ taskId: taskId.value,keyword:keyWord.value }) + console.log("xxxxxxxxxxxxx",res) + detailsList.value = res.data + detailsList.value = detailsList.value.map((e) => { + return { ...e, isChecked: false } + }) } // 复选框全选 const onChangeAllChecked = (e) => { - detailsList.value.forEach((item) => { - if (e.detail.value.length > 0) { - if(Number(item.typeRepairNum)-Number(item.typeRepairedNum)-Number(item.typeScrapNum)==0){ - item.isChecked = false - }else{ - item.isChecked = true - } - } else { - item.isChecked = false - } - }) + detailsList.value.forEach((item) => { + if (e.detail.value.length > 0) { + if(Number(item.typeRepairNum)-Number(item.typeRepairedNum)-Number(item.typeScrapNum)==0){ + item.isChecked = false + }else{ + item.isChecked = true + } + } else { + item.isChecked = false + } + }) } // 复选框每一项 const onChangeChecked = (val) => { - val.isChecked = !val.isChecked + val.isChecked = !val.isChecked } // 计算全选按钮是否选中 const allChecked = computed(() => { - return detailsList.value.every((e) => e.isChecked == true) + return detailsList.value.every((e) => e.isChecked == true) }) // 点击合格按钮 const onQualified = async () => { - const isSelect = detailsList.value.some((e) => e.isChecked == true) - if (!isSelect) { - uni.showToast({ - title: '请选择要驳回的数据!', - icon: 'none', - }) - return - } + const isSelect = detailsList.value.some((e) => e.isChecked == true) + if (!isSelect) { + uni.showToast({ + title: '请选择要驳回的数据!', + icon: 'none', + }) + return + } + // 标记操作 + uni.setStorageSync('fromDetailOperation', true) + // 提示 uni.showModal({ title: '提示', @@ -274,49 +285,52 @@ const onQualified = async () => { // 点击跳转维修页面 const onRepairItem = (item) => { - console.log(item) - let codingUrl = '' - if (item.manageType === 0) {// 编码维修 - // if(item.status==0){ - codingUrl = '/pages/repair/equipAssessment/code-view' - uni.navigateTo({ url: `${codingUrl}?queryParams=${JSON.stringify(item)}` }) - // }else{ - // uni.showToast({ - // title: '该规格已完成定损', - // icon: 'none', - // }) - // } + console.log(item) + // 标记为跳转,返回时需要恢复滚动 + uni.setStorageSync('fromDetailOperation', false) + + let codingUrl = '' + if (item.manageType === 0) {// 编码维修 + // if(item.status==0){ + codingUrl = '/pages/repair/equipAssessment/code-view' + uni.navigateTo({ url: `${codingUrl}?queryParams=${JSON.stringify(item)}` }) + // }else{ + // uni.showToast({ + // title: '该规格已完成定损', + // icon: 'none', + // }) + // } + } + if (item.manageType == 1) {// 数量维修 + if(item.status==0){ + codingUrl = '/pages/repair/equipAssessment/num-operate' + uni.navigateTo({ url: `${codingUrl}?queryParams=${JSON.stringify(item)}` }) + }else{ + uni.showToast({ + title: '该规格已完成定损', + icon: 'none', + }) } - if (item.manageType == 1) {// 数量维修 - if(item.status==0){ - codingUrl = '/pages/repair/equipAssessment/num-operate' - uni.navigateTo({ url: `${codingUrl}?queryParams=${JSON.stringify(item)}` }) - }else{ - uni.showToast({ - title: '该规格已完成定损', - icon: 'none', - }) - } - } - + } } + onShow(() => { - getRepairDetailsData() + getRepairDetailsData() }) // 页面加载完毕 onLoad((options) => { - taskId.value = options.taskId + taskId.value = options.taskId + getRepairDetailsData() + // 监听出库完成事件 刷新列表 + uni.$on('onUpdate', () => { + // 刷新列表 getRepairDetailsData() - // 监听出库完成事件 刷新列表 - uni.$on('onUpdate', () => { - // 刷新列表 - getRepairDetailsData() - }) + }) }) // 页面销毁时移除事件监听 onUnmounted(() => { - uni.$off('onUpdate') // 移除事件监听 + uni.$off('onUpdate') // 移除事件监听 }) diff --git a/src/pages/repair/equipAssessment/index.vue b/src/pages/repair/equipAssessment/index.vue index 585ff7f..6670847 100644 --- a/src/pages/repair/equipAssessment/index.vue +++ b/src/pages/repair/equipAssessment/index.vue @@ -136,13 +136,15 @@ const total = ref(0) // 数据总�� const active = ref(1) // tap索引 const tableList = ref([]) // 列表数据源 const dateArray = ref([ - new Date(new Date().getTime() - 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0], - new Date().toISOString().split('T')[0] + new Date(new Date().getTime() - 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0], + new Date().toISOString().split('T')[0] ]) // 日期范围 const showCustomModal = ref(false) const currentItem = ref(null) const modalTitle = ref('提示') const modalContent = ref('是否确认进行定损?') +// 添加标记位 +const shouldRestoreScroll = ref(true) // 查询参数 const queryParams = ref({ startTime: dateArray.value[0] || '', @@ -180,15 +182,17 @@ const onClick = async (e, item) => { if (e.index === 0) { // 提交逻辑 const res = await repairSubmitAPI([{ taskId: item.taskId }]) - if (res.code === 200) { - uni.showToast({ - title: '提交成功!', - icon: 'none', - }) - queryParams.value.pageNum = 1 - tableList.value = [] - getTableList(true) - } + if (res.code === 200) { + uni.showToast({ + title: '提交成功!', + icon: 'none', + }) + shouldRestoreScroll.value = false + uni.setStorageSync('fromDetailOperation', true) + queryParams.value.pageNum = 1 + tableList.value = [] + getTableList(true) + } } else { // 驳回逻辑 console.log('驳回') @@ -199,30 +203,34 @@ const onClick = async (e, item) => { } console.log(parm) const res = await repairRejectAPI(parm) - if (res.code === 200) { - uni.showToast({ - title: '驳回成功!', - icon: 'none', - }) - queryParams.value.pageNum = 1 - tableList.value = [] - getTableList(true) - } + if (res.code === 200) { + uni.showToast({ + title: '驳回成功!', + icon: 'none', + }) + shouldRestoreScroll.value = false + uni.setStorageSync('fromDetailOperation', true) + queryParams.value.pageNum = 1 + tableList.value = [] + getTableList(true) + } } } // 日期 change 事件 const onChangeDate = (val) => { - const [val_1, val_2] = val - queryParams.value.startTime = val_1 - queryParams.value.endTime = val_2 + const [val_1, val_2] = val + queryParams.value.startTime = val_1 + queryParams.value.endTime = val_2 } // 搜索按钮 const onSearchBtn = () => { - queryParams.value.pageNum = 1 - tableList.value = [] - getTableList(true) + shouldRestoreScroll.value = false + uni.setStorageSync('fromDetailOperation', true) + queryParams.value.pageNum = 1 + tableList.value = [] + getTableList(true) } // 获取列表数据 @@ -234,10 +242,7 @@ const getTableList = async (isTap = false) => { }) console.log('queryParams.value查询参数', queryParams.value) const res = await getLossAssessmentListAPI(queryParams.value) - setTimeout(() => { - scrollTop.value = uni.getStorageSync('scrollTop') || 0 - console.log('🚀 ~ scrollTop.value:', scrollTop.value) - }, 400) + total.value = res.data.total if (isTap) { tableList.value = res.data.rows @@ -272,9 +277,32 @@ const getTableList = async (isTap = false) => { // }) onShow(() => { - tableList.value = [] - total.value = 0 - getTableList(true) + // 检查是否有操作标记 + const fromDetailOperation = uni.getStorageSync('fromDetailOperation') + + if (shouldRestoreScroll.value && !fromDetailOperation) { + // 只有从详情页简单返回且没有操作时才恢复滚动 + setTimeout(() => { + const cachedScrollTop = uni.getStorageSync('scrollTop') + if (cachedScrollTop) { + scrollTop.value = cachedScrollTop + // 为了确保滚动生效,可以再次设置 + setTimeout(() => { + scrollTop.value = cachedScrollTop + 0.1 + }, 50) + } + }, 100) + } + + // 清除操作标记 + uni.removeStorageSync('fromDetailOperation') + // 重置标记位 + shouldRestoreScroll.value = true + + // 获取数据 + tableList.value = [] + total.value = 0 + getTableList(true) }) let timers = null @@ -288,34 +316,41 @@ const onScroll = (e) => { // 滚动触底事件 const onScrollTolower = debounce(() => { - console.log('触底事件') - if (total.value > tableList.value.length) { - queryParams.value.pageNum += 1 - getTableList() - } + console.log('触底事件') + if (total.value > tableList.value.length) { + queryParams.value.pageNum += 1 + getTableList() + } }, 500) // tap 栏切换 const changeTab = (index) => { - active.value = index + active.value = index + shouldRestoreScroll.value = false + uni.setStorageSync('fromDetailOperation', true) uni.setStorageSync('scrollTop', 0) uni.setStorageSync('activeTab', index) uni.removeStorageSync('queryParams') uni.removeStorageSync('scrollTop') - queryParams.value.pageNum = 1 - tableList.value = [] - if (index == 1) { - queryParams.value.appTaskStatus = 0 // 查未完成的 - getTableList(true) - } else if (index == 2) { - queryParams.value.appTaskStatus = 1 // 查已完成的 - getTableList(true) - } + queryParams.value.pageNum = 1 + tableList.value = [] + if (index == 1) { + queryParams.value.appTaskStatus = 0 // 查未完成的 + getTableList(true) + } else if (index == 2) { + queryParams.value.appTaskStatus = 1 // 查已完成的 + getTableList(true) + } } // 点击跳转详情 const handleItem = (item) => { - console.log(item) + console.log(item) currentItem.value = item + + // 设置标记:这是从列表正常跳转到详情页,返回时需要恢复滚动 + shouldRestoreScroll.value = true + uni.setStorageSync('fromDetailOperation', false) + if(item.repairStatusCode == "0") { // 使用自定义弹窗 showCustomModal.value = true @@ -333,49 +368,15 @@ const handleItem = (item) => { } else { uni.navigateTo({ url: `/pages/repair/equipAssessment/view?taskId=${item.taskId}` }) } - - - - // if(item.repairStatusCode=="0"){ - // // 弹出确认弹窗 - // uni.showModal({ - // title: '提示', - // content: '是否确认进行定损?', - // confirmText: '进入定损', - // cancelText: '转至维修', - // success: async (res) => { - // if (res.confirm) { - // // 用户点击确认,进行页面跳转 - // uni.navigateTo({ url: `/pages/repair/equipAssessment/details?taskId=${item.taskId}` }) - // } else if (res.cancel) { - // //直接进行维修 - // const res = await updateRepairStatusAPI({taskId: item.taskId}) - // if(res.code==200){ - // uni.showToast({ - // title: '成功转至维修', - // icon: 'none', - // }) - // setTimeout(() => { - // queryParams.value.pageNum = 1 - // tableList.value = [] - // getTableList(true) - // }, 1000) - // - // } - // } - // } - // }) - // // uni.navigateTo({ url: `/pages/repair/equipAssessment/details?taskId=${item.taskId}` }) - // }else{ - // uni.navigateTo({ url: `/pages/repair/equipAssessment/view?taskId=${item.taskId}` }) - // } - } // 自定义弹窗确认事件 const handleConfirm = () => { if (countdown.value > 0) return showCustomModal.value = false + // 设置标记 + shouldRestoreScroll.value = true + uni.setStorageSync('fromDetailOperation', false) uni.navigateTo({ url: `/pages/repair/equipAssessment/details?taskId=${currentItem.value.taskId}` }) } @@ -383,6 +384,10 @@ const handleConfirm = () => { const handleCancel = async () => { if (countdown.value > 0) return showCustomModal.value = false + // 设置标记:这是操作,返回时不需要恢复滚动 + shouldRestoreScroll.value = false + uni.setStorageSync('fromDetailOperation', true) + const res = await updateRepairStatusAPI({taskId: currentItem.value.taskId}) if(res.code == 200) { uni.showToast({ @@ -404,22 +409,22 @@ const handleCloseModal = () => { // 判断数据是否加载完毕 const finish = computed(() => { - if (total.value === tableList.value.length) return true + if (total.value === tableList.value.length) return true }) // 状态标签样式 const successStyle = { - color: '#52c41a', - backgroundColor: 'rgba(82, 196, 26, 0.1)', - border: '2rpx solid rgba(82, 196, 26, 0.2)', - fontWeight: '600' + color: '#52c41a', + backgroundColor: 'rgba(82, 196, 26, 0.1)', + border: '2rpx solid rgba(82, 196, 26, 0.2)', + fontWeight: '600' } const warningStyle = { - color: '#fa8c16', - backgroundColor: 'rgba(250, 140, 22, 0.1)', - border: '2rpx solid rgba(250, 140, 22, 0.2)', - fontWeight: '600' + color: '#fa8c16', + backgroundColor: 'rgba(250, 140, 22, 0.1)', + border: '2rpx solid rgba(250, 140, 22, 0.2)', + fontWeight: '600' } const maskClick = () => {} diff --git a/src/pages/repair/repairManage/details.vue b/src/pages/repair/repairManage/details.vue index e5d70cc..5d3b000 100644 --- a/src/pages/repair/repairManage/details.vue +++ b/src/pages/repair/repairManage/details.vue @@ -105,8 +105,10 @@ const detailsList = ref([]) const taskId = ref('') const keyWord = ref('') const search = () => { - console.log('🚀 ~ search ~ keyWord:', keyWord.value) - getRepairDetailsData() + console.log('🚀 ~ search ~ keyWord:', keyWord.value) + // 标记不是从详情页简单返回 + uni.setStorageSync('fromDetailOperation', true) + getRepairDetailsData() } // 获取列表详情 const getRepairDetailsData = async () => { @@ -158,34 +160,39 @@ const allChecked = computed(() => { // 点击合格按钮 const onQualified = async () => { - const isSelect = detailsList.value.some((e) => e.isChecked == true) - if (!isSelect) { - uni.showToast({ - title: '请勾选需要合格的数据!', - icon: 'none', + const isSelect = detailsList.value.some((e) => e.isChecked == true) + if (!isSelect) { + uni.showToast({ + title: '请勾选需要合格的数据!', + icon: 'none', + }) + return + } + + // 标记不是从详情页简单返回 + uni.setStorageSync('fromDetailOperation', true) + + // 组装参数 + const ids = [] + detailsList.value.forEach((e) => { + if (e.isChecked) { + if (e.ids.length > 0) { + e.ids.forEach((f) => { + ids.push(f) }) - return - } - // 组装参数 - const ids = [] - detailsList.value.forEach((e) => { - if (e.isChecked) { - if (e.ids.length > 0) { - e.ids.forEach((f) => { - ids.push(f) - }) - } - } - }) - console.log(ids) - const res = await auditRepairPass(ids) - if (res.code === 200) { - uni.showToast({ - title: '操作成功!', - icon: 'none', - }) - getRepairDetailsData() + } } + }) + + console.log(ids) + const res = await auditRepairPass(ids) + if (res.code === 200) { + uni.showToast({ + title: '操作成功!', + icon: 'none', + }) + getRepairDetailsData() + } } // 点击跳转维修页面 @@ -225,25 +232,29 @@ const onRepairItem = (item) => { const isSubmit = ref(false) const handleSubmit = async () => { - try { - if (isSubmit.value) return - isSubmit.value = true - uni.showLoading({ title: '提交中...', mask: true }) - // 提交逻辑 - const res = await repairSubmitAPI([{ taskId: taskId.value }]) - if (res.code === 200) { - uni.showToast({ - title: '提交成功!', - icon: 'none', - }) - uni.navigateBack() - } - } catch (error) { - console.log('🚀 ~ handleSubmit ~ error:', error) - } finally { - uni.hideLoading() - isSubmit.value = false + try { + if (isSubmit.value) return + isSubmit.value = true + uni.showLoading({ title: '提交中...', mask: true }) + + // 标记不是从详情页简单返回 + uni.setStorageSync('fromDetailOperation', true) + + // 提交逻辑 + const res = await repairSubmitAPI([{ taskId: taskId.value }]) + if (res.code === 200) { + uni.showToast({ + title: '提交成功!', + icon: 'none', + }) + uni.navigateBack() } + } catch (error) { + console.log('🚀 ~ handleSubmit ~ error:', error) + } finally { + uni.hideLoading() + isSubmit.value = false + } } diff --git a/src/pages/repair/repairManage/index.vue b/src/pages/repair/repairManage/index.vue index 110dfd9..47c5908 100644 --- a/src/pages/repair/repairManage/index.vue +++ b/src/pages/repair/repairManage/index.vue @@ -146,6 +146,7 @@ const queryParams = ref({ pageSize: 20, }) const scrollTop = ref(0) // 滚动位置 +const shouldRestoreScroll = ref(true) // 右滑按钮组 const options = ref([ @@ -249,9 +250,25 @@ const getTableList = async (isTap = false) => { onShow(() => { - tableList.value = [] - total.value = 0 - getTableList(true) + // 检查是否有缓存的滚动位置 + const cachedScrollTop = uni.getStorageSync('scrollTop') + const cachedQueryParams = uni.getStorageSync('queryParams') + const cachedActiveTab = uni.getStorageSync('activeTab') + + // 如果是从详情页返回(且不是从查询/合格操作返回),才恢复滚动 + if (shouldRestoreScroll.value && cachedScrollTop) { + scrollTop.value = cachedScrollTop + // 延迟设置以确保DOM已更新 + setTimeout(() => { + scrollTop.value = cachedScrollTop + }, 100) + } + + // 重置标志位 + shouldRestoreScroll.value = true + + // 正常获取数据 + getTableList(true) }) let timer = null @@ -260,6 +277,7 @@ const onScroll = (e) => { timer = setTimeout(() => { uni.setStorageSync('scrollTop', e.detail.scrollTop) uni.setStorageSync('queryParams', JSON.stringify(queryParams.value)) + uni.setStorageSync('activeTab', activeTab.value) }, 500) } @@ -291,13 +309,15 @@ const changeTab = (index) => { } // 点击跳转详情 const handleItem = (item) => { - console.log(item) - if(item.repairStatusCode=="0" || item.repairStatusCode=="4" || item.repairStatusCode=="3"){ - uni.navigateTo({ url: `/pages/repair/repairManage/details?taskId=${item.taskId}` }) - }else{ - uni.navigateTo({ url: `/pages/repair/repairManage/view?taskId=${item.taskId}` }) - } - + console.log(item) + shouldRestoreScroll.value = true + uni.setStorageSync('fromDetailOperation', false) + + if(item.repairStatusCode=="0" || item.repairStatusCode=="4" || item.repairStatusCode=="3"){ + uni.navigateTo({ url: `/pages/repair/repairManage/details?taskId=${item.taskId}` }) + }else{ + uni.navigateTo({ url: `/pages/repair/repairManage/view?taskId=${item.taskId}` }) + } } // 判断数据是否加载完毕