feat: 添加商品审批流程相关功能

- 新增审批处理路由和页面
- 商品模型添加belongType字段区分审批类型
- 订单提交支持审批支付类型
- 根据商品类型自动选择支付方式
- 审批支付添加领用说明字段
- 优化余额获取逻辑
This commit is contained in:
dzq 2025-06-09 17:39:08 +08:00
parent cbe79d1d6d
commit 089f78c836
6 changed files with 63 additions and 18 deletions

View File

@ -8,7 +8,8 @@ export type Goods = {
coverImg: string, coverImg: string,
goodsDetail: string, goodsDetail: string,
usageInstruction: string, usageInstruction: string,
cellId: number cellId: number,
belongType: number
} }
export type category = { export type category = {
@ -25,7 +26,7 @@ export interface SubmitOrderRequestData {
/** 企业ID */ /** 企业ID */
corpid: string; corpid: string;
/** 支付类型 wechat:微信 balance:余额 */ /** 支付类型 wechat:微信 balance:余额 */
paymentType: 'wechat' | 'balance'; paymentType: 'wechat' | 'balance' | "approval";
/** 联系电话 */ /** 联系电话 */
mobile: string; mobile: string;
/** 用户姓名 */ /** 用户姓名 */
@ -34,6 +35,7 @@ export interface SubmitOrderRequestData {
qyUserid: string; qyUserid: string;
/** 是否内部订单 0否 1汇邦云用户 2企业微信用户 */ /** 是否内部订单 0否 1汇邦云用户 2企业微信用户 */
isInternal: number; isInternal: number;
applyRemark: string;
/** 订单商品明细列表 */ /** 订单商品明细列表 */
goodsList: Array<{ goodsList: Array<{
goodsId: number goodsId: number

View File

@ -67,7 +67,6 @@ const wxStore = useWxStore();
// //
const searchParams = reactive<SearchApiReturnApprovalQuery>({ const searchParams = reactive<SearchApiReturnApprovalQuery>({
corpid: wxStore.corpid, corpid: wxStore.corpid,
approvalType: 0,
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
}) })
@ -102,9 +101,13 @@ const handleCellClick = (approvalId: number) => {
const approvalStore = useApprovalStore() const approvalStore = useApprovalStore()
const currentItem = list.value.find(item => item.approvalId === approvalId) const currentItem = list.value.find(item => item.approvalId === approvalId)
if (currentItem) { 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}`)
} }
// //

View File

@ -19,18 +19,37 @@ const { openid, balance, corpidLogin, userid: qyUserid, name: qyName } = storeTo
const ab98UserStore = useAb98UserStore() const ab98UserStore = useAb98UserStore()
const { tel, userid: ab98Userid, name } = storeToRefs(ab98UserStore) const { tel, userid: ab98Userid, name } = storeToRefs(ab98UserStore)
const selectedPayment = ref<'wechat' | 'balance'>('wechat') const selectedPayment = ref<'wechat' | 'balance' | 'approval'>('wechat');
const contact = ref("") const contact = ref("");
const remark = ref("") const applyRemark = ref("");
const submitting = ref(false); const submitting = ref(false);
const isApproval = computed(() => {
return cartItems.value.some(item => item.product.belongType == 1);
});
watch(corpidLogin, (newValue) => { watch(corpidLogin, (newValue) => {
if (newValue) { if (isApproval.value) {
selectedPayment.value = 'balance'; selectedPayment.value = 'approval';
} else { } else {
selectedPayment.value = 'wechat'; if (newValue) {
selectedPayment.value = 'balance';
} else {
selectedPayment.value = 'wechat';
}
} }
}, { immediate: true }); }, { 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) { function callWxJsApi(paymentInfo: WxJsApiPreCreateResponse) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -111,11 +130,12 @@ async function handleSubmit() {
paymentType: selectedPayment.value, paymentType: selectedPayment.value,
mobile: tel.value, mobile: tel.value,
name: isInternal === 2 ? qyName.value : name.value, name: isInternal === 2 ? qyName.value : name.value,
applyRemark: applyRemark.value,
qyUserid: isInternal === 2 ? qyUserid.value : ab98Userid.value, qyUserid: isInternal === 2 ? qyUserid.value : ab98Userid.value,
isInternal: isInternal isInternal: isInternal
} }
const { code, data } = await submitOrderApi(requestData) const { code, data } = await submitOrderApi(requestData);
if (code !== 0) { if (code !== 0) {
throw new Error("订单提交失败") throw new Error("订单提交失败")
@ -125,7 +145,7 @@ async function handleSubmit() {
if (data.paymentInfo) { if (data.paymentInfo) {
await callWxJsApi(data.paymentInfo); await callWxJsApi(data.paymentInfo);
} }
} else { } else if (selectedPayment.value === 'balance') {
// //
wxStore.setBalance(data.newBalance || 0); wxStore.setBalance(data.newBalance || 0);
try { try {
@ -135,6 +155,14 @@ async function handleSubmit() {
}) })
} catch (error) { } catch (error) {
} }
} else if (selectedPayment.value === 'approval') {
//
try {
await showConfirmDialog({
title: "提交领用申请成功",
message: `请等待管理员审批`
})
} catch (error) { }
} }
router.push({ router.push({
@ -193,7 +221,11 @@ async function handleSubmit() {
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
<van-cell-group class="contact-form"> <van-cell-group v-if="isApproval">
<van-field v-model="applyRemark" label="领用说明" type="textarea" rows="2" autosize />
</van-cell-group>
<van-cell-group v-if="!isApproval" class="contact-form">
<van-cell v-if="!corpidLogin" :class="['payment-option', { selected: selectedPayment === 'wechat' }]" <van-cell v-if="!corpidLogin" :class="['payment-option', { selected: selectedPayment === 'wechat' }]"
@click="selectedPayment = 'wechat'"> @click="selectedPayment = 'wechat'">
<van-icon name="wechat" class="method-icon" /> <van-icon name="wechat" class="method-icon" />

View File

@ -11,6 +11,7 @@ export interface Product {
label: number // 商品标签 label: number // 商品标签
cellId: number // 商品所在的格子ID cellId: number // 商品所在的格子ID
usageInstruction: string // 商品使用说明 usageInstruction: string // 商品使用说明
belongType: number // 商品所属类型 0: 智借还 1: 固资通
} }
export const useProductStore = defineStore("product", () => { export const useProductStore = defineStore("product", () => {
@ -50,7 +51,8 @@ export const useProductStore = defineStore("product", () => {
image: g.coverImg, image: g.coverImg,
label: g.categoryId, label: g.categoryId,
cellId: g.cellId, cellId: g.cellId,
usageInstruction: g.usageInstruction || "" usageInstruction: g.usageInstruction || "",
belongType: g.belongType
})) }))
} catch (error) { } catch (error) {
console.error("获取商品数据失败:", error) console.error("获取商品数据失败:", error)

View File

@ -107,19 +107,20 @@ export const useWxStore = defineStore("wx", () => {
if(corpid.value) { if(corpid.value) {
balanceRes = await getBalanceByQyUserid(corpid.value, userid.value); balanceRes = await getBalanceByQyUserid(corpid.value, userid.value);
} else { } else {
balanceRes = await getBalanceApi(openid.value) corpid.value = "wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw";
// balanceRes = await getBalanceApi(openid.value)
} }
console.log('获取余额成功:', balanceRes) console.log('获取余额成功:', balanceRes)
if (balanceRes && balanceRes.code == 0) { if (balanceRes && balanceRes.code == 0) {
balance.value = balanceRes.data.balance; balance.value = balanceRes.data.balance;
useBalance.value = balanceRes.data.useBalance; useBalance.value = balanceRes.data.useBalance;
balanceLimit.value = balanceRes.data.balanceLimit; balanceLimit.value = balanceRes.data.balanceLimit;
if (!userid.value) { /* if (!userid.value) {
userid.value = balanceRes.data.userid; userid.value = balanceRes.data.userid;
} }
if (!corpid.value) { if (!corpid.value) {
corpid.value = balanceRes.data.corpid; corpid.value = balanceRes.data.corpid;
} } */
} }
} }
} catch (err) { } catch (err) {

View File

@ -39,6 +39,11 @@ export const routes: RouteRecordRaw[] = [
component: () => import('@/pages/approval/handle.vue'), component: () => import('@/pages/approval/handle.vue'),
meta: { requiresAuth: true } meta: { requiresAuth: true }
}, },
{
path: '/approval/handleApply/:approvalId',
component: () => import('@/pages/approval/handleApply.vue'),
meta: { requiresAuth: true }
},
{ {
path: '/order-success', path: '/order-success',
name: 'OrderSuccess', name: 'OrderSuccess',