From 39d606a1e6edca7a352aa82194c3f833dc181170 Mon Sep 17 00:00:00 2001 From: cxr <15040459460@163,com> Date: Thu, 26 Feb 2026 14:40:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(system):=20=E5=8D=8E=E4=B8=AD=E9=98=9C?= =?UTF-8?q?=E5=A4=96=E7=BB=93=E7=AE=97=E4=BC=98=E5=8C=96=E9=9C=80=E6=B1=82?= =?UTF-8?q?=20=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=AB=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=AE=A1=E6=89=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index.wpy | 383 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 368 insertions(+), 15 deletions(-) diff --git a/src/pages/index.wpy b/src/pages/index.wpy index 03c3cf6..510eb3a 100644 --- a/src/pages/index.wpy +++ b/src/pages/index.wpy @@ -10,6 +10,7 @@ flex: 1; overflow-y: scroll; width: 100%; + padding-bottom: 120rpx; /* 为批量操作按钮留出空间 */ } .header { z-index: 1000; @@ -61,9 +62,32 @@ margin-top: 10rpx; padding-left: 20rpx;background: white;height: 150rpx;width: 100%; box-sizing: border-box; - display: flex;flex-direction: column; + display: flex;flex-direction: row; + align-items: center; + justify-content: space-between; +} + +.item-content { + flex: 1; + display: flex; + flex-direction: column; justify-content: center; } + +.batch-actions { + position: fixed; + bottom: 0; + left: 0; + right: 0; + background: white; + padding: 20rpx; + box-sizing: border-box; + display: flex; + flex-direction: row; + justify-content: space-around; + border-top: 1rpx solid #EDEDED; + z-index: 100; +} .van-tabs__line { z-index: 1; left: 0; @@ -135,10 +159,10 @@ @click="showPicker = true" custom-class="project-source-field" /> - @@ -152,13 +176,56 @@ -
- {{ item.orderSn }} -
- {{ item.omsOrderApproveItemVoList[0].projectSources || '' }} +
+ +
+ {{ item.orderSn }} +
+ {{ item.omsOrderApproveItemVoList[0].projectSources || '' }} +
+ + +
+ + 批量通过{{ hasSelected ? '(' + selectedCount + ')' : '' }} + + + 批量拒绝{{ hasSelected ? '(' + selectedCount + ')' : '' }} + +
+ + + +
+ +
+
@@ -205,9 +272,21 @@ wepy.page({ columns: [ { name: '阜外华中心血管病医院' }, { name: '河南心血管病中心(国家心血管病中心华中 分中心)' } - ] + ], + batchProcessing: false, // 批量处理中 + showBatchRefuseDialog: false, // 显示批量拒绝对话框 + batchRefuseReason: '', // 批量拒绝原因 + }, + computed: { + // 获取选中的订单数量 + selectedCount() { + return this.orderList.filter(item => item.selected === true).length + }, + // 判断是否有选中的订单 + hasSelected() { + return this.selectedCount > 0 + } }, - computed: {}, methods: { item_click(item){ let data = JSON.parse(JSON.stringify(item)) @@ -221,7 +300,7 @@ wepy.page({ url: '/pages/sydwApprovePreview?data=' + encodeURIComponent(JSON.stringify(data)) }) } - + // wx.setStorageSync("order", item); // wx.navigateTo({ @@ -298,7 +377,11 @@ wepy.page({ }, success: (res) => { if (res.data.success) { - this.orderList = res.data.data + // 初始化每个订单的 selected 字段为 false + this.orderList = (res.data.data || []).map(item => ({ + ...item, + selected: false + })) } else if(res.statusCode === 401) { wx.showModal({ title: '提示', @@ -348,7 +431,11 @@ wepy.page({ }, success: (res) => { if (res.data.success) { - this.orderList = res.data.data + // 初始化每个订单的 selected 字段为 false + this.orderList = (res.data.data || []).map(item => ({ + ...item, + selected: false + })) } else if(res.statusCode === 401) { wx.showModal({ title: '提示', @@ -406,6 +493,270 @@ wepy.page({ } else { this.getSydwList() } + }, + onCheckboxChange(event, item, index) { + // 获取 checkbox 的选中状态 + let checked = false + if (event.$wx && event.$wx.detail !== undefined) { + checked = event.$wx.detail + } else if (event.detail !== undefined) { + checked = event.detail + } else { + // 如果无法获取,则切换当前状态 + checked = !item.selected + } + // 确保 checked 是布尔值 + const isChecked = checked === true || checked === 'true' || checked === 1 || checked === '1' + // 在 wepy 中,直接修改对象属性可能不会触发响应式更新 + // 使用 $set 或者重新赋值整个数组来确保响应式更新 + if (this.$set) { + this.$set(this.orderList[index], 'selected', isChecked) + } else { + // 如果 $set 不存在,则通过重新赋值整个数组来触发更新 + const newOrderList = [...this.orderList] + newOrderList[index] = { + ...newOrderList[index], + selected: isChecked + } + this.orderList = newOrderList + } + }, + batchPass() { + const selectedOrders = this.orderList.filter(item => item.selected === true) + if (selectedOrders.length === 0) { + wx.showToast({ + title: '请选择要审批的订单', + icon: 'none' + }) + return + } + wx.showModal({ + title: "提示", + content: `确认批量通过 ${selectedOrders.length} 个订单吗?`, + success: (res) => { + if (res.confirm) { + this.executeBatchPass() + } + } + }) + }, + executeBatchPass() { + this.batchProcessing = true + wx.showLoading({ + title: '处理中...' + }) + const requestURL = wx.getStorageSync('requestURL') + // 获取选中的订单 + const selectedOrders = this.orderList.filter(item => item.selected === true) + const selectedCount = selectedOrders.length + let successCount = 0 + let failCount = 0 + let processedCount = 0 + const successTaskIds = [] // 记录成功的taskId + // 循环调用通过接口 + selectedOrders.forEach((order, index) => { + const taskId = order.taskId + wx.request({ + url: `${requestURL}/approveOpera/pass`, + method: 'post', + header: { + 'Content-Type': 'application/json', + 'token': this.userInfo.token + }, + data: { + taskId: taskId, + option: '通过', + type: '审批' + }, + success: (res) => { + processedCount++ + if (res.data.success) { + successCount++ + successTaskIds.push(taskId) + } else { + failCount++ + } + // 所有请求完成后处理 + if (processedCount === selectedCount) { + this.batchProcessing = false + wx.hideLoading() + // 从列表中移除已成功的订单 + this.orderList = this.orderList.filter(item => { + return successTaskIds.indexOf(item.taskId) === -1 + }) + // 显示结果 + let message = `批量通过完成!成功:${successCount},失败:${failCount}` + wx.showModal({ + title: "提示", + showCancel: false, + content: message, + success: () => { + // 刷新列表 + if (this.activeTitle === '试剂耗材') { + this.getList() + } else { + this.getSydwList() + } + } + }) + } + }, + fail: (err) => { + processedCount++ + failCount++ + if (processedCount === selectedCount) { + this.batchProcessing = false + wx.hideLoading() + // 从列表中移除已成功的订单 + this.orderList = this.orderList.filter(item => { + return successTaskIds.indexOf(item.taskId) === -1 + }) + // 清空选择 + let message = `批量通过完成!成功:${successCount},失败:${failCount}` + wx.showModal({ + title: "提示", + showCancel: false, + content: message, + success: () => { + if (this.activeTitle === '试剂耗材') { + this.getList() + } else { + this.getSydwList() + } + } + }) + } + } + }) + }) + }, + openBatchRefuseDialog() { + const selectedOrders = this.orderList.filter(item => item.selected === true) + if (selectedOrders.length === 0) { + wx.showToast({ + title: '请选择要审批的订单', + icon: 'none' + }) + return + } + this.showBatchRefuseDialog = true + this.batchRefuseReason = '' + }, + onBatchRefuseClose() { + this.showBatchRefuseDialog = false + }, + cancelBatchRefuse() { + this.showBatchRefuseDialog = false + wx.showToast({ + title: '您取消了批量拒绝', + icon: 'none' + }) + }, + batchRefuse() { + if (!this.batchRefuseReason || this.batchRefuseReason.trim() === '') { + wx.showToast({ + title: '请输入拒绝原因', + icon: 'none' + }) + return + } + this.showBatchRefuseDialog = false + this.executeBatchRefuse() + }, + executeBatchRefuse() { + this.batchProcessing = true + wx.showLoading({ + title: '处理中...' + }) + const requestURL = wx.getStorageSync('requestURL') + // 获取选中的订单 + const selectedOrders = this.orderList.filter(item => item.selected === true) + const selectedCount = selectedOrders.length + let successCount = 0 + let failCount = 0 + let processedCount = 0 + const successTaskIds = [] // 记录成功的taskId + // 循环调用拒绝接口 + selectedOrders.forEach((order, index) => { + const taskId = order.taskId + wx.request({ + url: `${requestURL}/approveOpera/refuse`, + method: 'post', + header: { + 'Content-Type': 'application/json', + 'token': this.userInfo.token + }, + data: { + taskId: taskId, + option: this.batchRefuseReason, + type: '审批' + }, + success: (res) => { + processedCount++ + if (res.data.success) { + successCount++ + successTaskIds.push(taskId) + } else { + failCount++ + } + + // 所有请求完成后处理 + if (processedCount === selectedCount) { + this.batchProcessing = false + wx.hideLoading() + + // 从列表中移除已成功的订单 + this.orderList = this.orderList.filter(item => { + return successTaskIds.indexOf(item.taskId) === -1 + }) + this.batchRefuseReason = '' + // 显示结果 + let message = `批量拒绝完成!成功:${successCount},失败:${failCount}` + wx.showModal({ + title: "提示", + showCancel: false, + content: message, + success: () => { + // 刷新列表 + if (this.activeTitle === '试剂耗材') { + this.getList() + } else { + this.getSydwList() + } + } + }) + } + }, + fail: (err) => { + processedCount++ + failCount++ + + if (processedCount === selectedCount) { + this.batchProcessing = false + wx.hideLoading() + + // 从列表中移除已成功的订单 + this.orderList = this.orderList.filter(item => { + return successTaskIds.indexOf(item.taskId) === -1 + }) + this.batchRefuseReason = '' + let message = `批量拒绝完成!成功:${successCount},失败:${failCount}` + wx.showModal({ + title: "提示", + showCancel: false, + content: message, + success: () => { + if (this.activeTitle === '试剂耗材') { + this.getList() + } else { + this.getSydwList() + } + } + }) + } + } + }) + }) } }, onShow() { @@ -653,7 +1004,9 @@ header: '~@/components/header', "van-tabs": "module:@vant/weapp/lib/tabs/index", "van-tab": "module:@vant/weapp/lib/tab/index", "van-tag": "module:@vant/weapp/lib/tag/index", -"van-field": "module:@vant/weapp/lib/field/index" +"van-field": "module:@vant/weapp/lib/field/index", +"van-checkbox": "module:@vant/weapp/lib/checkbox/index", +"van-checkbox-group": "module:@vant/weapp/lib/checkbox-group/index" } } -- 2.24.1