From 089f78c8363f3a83749cabf2afa9c8e383aed947 Mon Sep 17 00:00:00 2001 From: dzq Date: Mon, 9 Jun 2025 17:39:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=B5=81=E7=A8=8B=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增审批处理路由和页面 - 商品模型添加belongType字段区分审批类型 - 订单提交支持审批支付类型 - 根据商品类型自动选择支付方式 - 审批支付添加领用说明字段 - 优化余额获取逻辑 --- src/common/apis/shop/type.ts | 6 ++- src/pages/approval/list.vue | 9 ++-- src/pages/product/components/checkout.vue | 50 +++++++++++++++++++---- src/pinia/stores/product.ts | 4 +- src/pinia/stores/wx.ts | 7 ++-- src/router/index.ts | 5 +++ 6 files changed, 63 insertions(+), 18 deletions(-) diff --git a/src/common/apis/shop/type.ts b/src/common/apis/shop/type.ts index c82186c..a560cd8 100644 --- a/src/common/apis/shop/type.ts +++ b/src/common/apis/shop/type.ts @@ -8,7 +8,8 @@ export type Goods = { coverImg: string, goodsDetail: string, usageInstruction: string, - cellId: number + cellId: number, + belongType: number } export type category = { @@ -25,7 +26,7 @@ export interface SubmitOrderRequestData { /** 企业ID */ corpid: string; /** 支付类型 wechat:微信 balance:余额 */ - paymentType: 'wechat' | 'balance'; + paymentType: 'wechat' | 'balance' | "approval"; /** 联系电话 */ mobile: string; /** 用户姓名 */ @@ -34,6 +35,7 @@ export interface SubmitOrderRequestData { qyUserid: string; /** 是否内部订单 0否 1汇邦云用户 2企业微信用户 */ isInternal: number; + applyRemark: string; /** 订单商品明细列表 */ goodsList: Array<{ goodsId: number diff --git a/src/pages/approval/list.vue b/src/pages/approval/list.vue index dfee47c..fcf599a 100644 --- a/src/pages/approval/list.vue +++ b/src/pages/approval/list.vue @@ -67,7 +67,6 @@ const wxStore = useWxStore(); // 搜索参数 const searchParams = reactive({ corpid: wxStore.corpid, - approvalType: 0, pageNum: 1, pageSize: 10, }) @@ -102,9 +101,13 @@ const handleCellClick = (approvalId: number) => { const approvalStore = useApprovalStore() const currentItem = list.value.find(item => item.approvalId === approvalId) if (currentItem) { - approvalStore.setCurrentApproval(currentItem) + approvalStore.setCurrentApproval(currentItem); + } + if (currentItem?.approvalType == 1) { + router.push(`/approval/handleApply/${approvalId}`); + } else { + router.push(`/approval/handle/${approvalId}`); } - router.push(`/approval/handle/${approvalId}`) } // 状态标签类型 diff --git a/src/pages/product/components/checkout.vue b/src/pages/product/components/checkout.vue index 3fb12f2..3c1a78f 100644 --- a/src/pages/product/components/checkout.vue +++ b/src/pages/product/components/checkout.vue @@ -19,18 +19,37 @@ const { openid, balance, corpidLogin, userid: qyUserid, name: qyName } = storeTo const ab98UserStore = useAb98UserStore() const { tel, userid: ab98Userid, name } = storeToRefs(ab98UserStore) -const selectedPayment = ref<'wechat' | 'balance'>('wechat') -const contact = ref("") -const remark = ref("") +const selectedPayment = ref<'wechat' | 'balance' | 'approval'>('wechat'); +const contact = ref(""); +const applyRemark = ref(""); const submitting = ref(false); +const isApproval = computed(() => { + return cartItems.value.some(item => item.product.belongType == 1); +}); + watch(corpidLogin, (newValue) => { - if (newValue) { - selectedPayment.value = 'balance'; + if (isApproval.value) { + selectedPayment.value = 'approval'; } else { - selectedPayment.value = 'wechat'; + if (newValue) { + selectedPayment.value = 'balance'; + } else { + selectedPayment.value = 'wechat'; + } } }, { immediate: true }); +watch(isApproval, (newValue) => { + if (newValue) { + selectedPayment.value = 'approval'; + } else { + if (corpidLogin.value) { + selectedPayment.value = 'balance'; + } else { + selectedPayment.value = 'wechat'; + } + } +}) function callWxJsApi(paymentInfo: WxJsApiPreCreateResponse) { return new Promise((resolve, reject) => { @@ -111,11 +130,12 @@ async function handleSubmit() { paymentType: selectedPayment.value, mobile: tel.value, name: isInternal === 2 ? qyName.value : name.value, + applyRemark: applyRemark.value, qyUserid: isInternal === 2 ? qyUserid.value : ab98Userid.value, isInternal: isInternal } - const { code, data } = await submitOrderApi(requestData) + const { code, data } = await submitOrderApi(requestData); if (code !== 0) { throw new Error("订单提交失败") @@ -125,7 +145,7 @@ async function handleSubmit() { if (data.paymentInfo) { await callWxJsApi(data.paymentInfo); } - } else { + } else if (selectedPayment.value === 'balance') { // 余额支付成功处理 wxStore.setBalance(data.newBalance || 0); try { @@ -135,6 +155,14 @@ async function handleSubmit() { }) } catch (error) { } + } else if (selectedPayment.value === 'approval') { + // 审批支付成功处理 + try { + await showConfirmDialog({ + title: "提交领用申请成功", + message: `请等待管理员审批` + }) + } catch (error) { } } router.push({ @@ -193,7 +221,11 @@ async function handleSubmit() { - + + + + + diff --git a/src/pinia/stores/product.ts b/src/pinia/stores/product.ts index 7a91c07..a94a0c9 100644 --- a/src/pinia/stores/product.ts +++ b/src/pinia/stores/product.ts @@ -11,6 +11,7 @@ export interface Product { label: number // 商品标签 cellId: number // 商品所在的格子ID usageInstruction: string // 商品使用说明 + belongType: number // 商品所属类型 0: 智借还 1: 固资通 } export const useProductStore = defineStore("product", () => { @@ -50,7 +51,8 @@ export const useProductStore = defineStore("product", () => { image: g.coverImg, label: g.categoryId, cellId: g.cellId, - usageInstruction: g.usageInstruction || "" + usageInstruction: g.usageInstruction || "", + belongType: g.belongType })) } catch (error) { console.error("获取商品数据失败:", error) diff --git a/src/pinia/stores/wx.ts b/src/pinia/stores/wx.ts index d96c72e..1b9d4bf 100644 --- a/src/pinia/stores/wx.ts +++ b/src/pinia/stores/wx.ts @@ -107,19 +107,20 @@ export const useWxStore = defineStore("wx", () => { if(corpid.value) { balanceRes = await getBalanceByQyUserid(corpid.value, userid.value); } else { - balanceRes = await getBalanceApi(openid.value) + corpid.value = "wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw"; + // balanceRes = await getBalanceApi(openid.value) } console.log('获取余额成功:', balanceRes) if (balanceRes && balanceRes.code == 0) { balance.value = balanceRes.data.balance; useBalance.value = balanceRes.data.useBalance; balanceLimit.value = balanceRes.data.balanceLimit; - if (!userid.value) { + /* if (!userid.value) { userid.value = balanceRes.data.userid; } if (!corpid.value) { corpid.value = balanceRes.data.corpid; - } + } */ } } } catch (err) { diff --git a/src/router/index.ts b/src/router/index.ts index c10a6b2..50a96f7 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -39,6 +39,11 @@ export const routes: RouteRecordRaw[] = [ component: () => import('@/pages/approval/handle.vue'), meta: { requiresAuth: true } }, + { + path: '/approval/handleApply/:approvalId', + component: () => import('@/pages/approval/handleApply.vue'), + meta: { requiresAuth: true } + }, { path: '/order-success', name: 'OrderSuccess',