From 2855eb4e08a1ab74f3520fd3d0ffd9bb5ed35432 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Wed, 25 Jun 2025 18:22:06 +0800 Subject: [PATCH] fix: bugs --- .../src/api/crm/business/status/index.ts | 1 + apps/web-antd/src/api/crm/customer/index.ts | 7 +- apps/web-antd/src/views/crm/business/data.ts | 17 +++- apps/web-antd/src/views/crm/clue/data.ts | 4 + apps/web-antd/src/views/crm/contact/data.ts | 4 + .../src/views/crm/contact/modules/form.vue | 2 + apps/web-antd/src/views/crm/contract/data.ts | 96 +++++++++++++++---- .../crm/contract/modules/detail-list.vue | 10 +- .../src/views/crm/contract/modules/form.vue | 2 + apps/web-antd/src/views/crm/customer/data.ts | 4 + .../customer/poolConfig/distribute-form.vue | 4 + apps/web-antd/src/views/crm/product/data.ts | 10 +- .../web-antd/src/views/crm/receivable/data.ts | 30 ++++-- .../crm/receivable/modules/detail-list.vue | 7 +- .../src/views/crm/receivable/modules/form.vue | 2 + .../src/views/crm/receivable/plan/data.ts | 16 ++-- .../receivable/plan/modules/detail-list.vue | 7 +- .../crm/receivable/plan/modules/form.vue | 2 + .../mall/trade/delivery/pickUpStore/data.ts | 4 +- 19 files changed, 178 insertions(+), 51 deletions(-) diff --git a/apps/web-antd/src/api/crm/business/status/index.ts b/apps/web-antd/src/api/crm/business/status/index.ts index 98c969af9..00001feb1 100644 --- a/apps/web-antd/src/api/crm/business/status/index.ts +++ b/apps/web-antd/src/api/crm/business/status/index.ts @@ -5,6 +5,7 @@ import { requestClient } from '#/api/request'; export namespace CrmBusinessStatusApi { /** 商机状态信息 */ export interface BusinessStatusType { + [x: string]: any; id?: number; name: string; percent: number; diff --git a/apps/web-antd/src/api/crm/customer/index.ts b/apps/web-antd/src/api/crm/customer/index.ts index 611d56bc2..73b786b80 100644 --- a/apps/web-antd/src/api/crm/customer/index.ts +++ b/apps/web-antd/src/api/crm/customer/index.ts @@ -121,10 +121,9 @@ export function putCustomerPool(id: number) { /** 更新客户的成交状态 */ export function updateCustomerDealStatus(id: number, dealStatus: boolean) { - return requestClient.put('/crm/customer/update-deal-status', { - id, - dealStatus, - }); + return requestClient.put( + `/crm/customer/update-deal-status?id=${id}&dealStatus=${dealStatus}`, + ); } /** 进入公海客户提醒的客户列表 */ diff --git a/apps/web-antd/src/views/crm/business/data.ts b/apps/web-antd/src/views/crm/business/data.ts index 2a0642e46..b913ebdc8 100644 --- a/apps/web-antd/src/views/crm/business/data.ts +++ b/apps/web-antd/src/views/crm/business/data.ts @@ -1,14 +1,17 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import { useUserStore } from '@vben/stores'; import { erpPriceMultiply } from '@vben/utils'; +import { z } from '#/adapter/form'; import { getBusinessStatusTypeSimpleList } from '#/api/crm/business/status'; import { getCustomerSimpleList } from '#/api/crm/customer'; import { getSimpleUserList } from '#/api/system/user'; /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { + const userStore = useUserStore(); return [ { fieldName: 'id', @@ -35,6 +38,7 @@ export function useFormSchema(): VbenFormSchema[] { value: 'id', }, }, + defaultValue: userStore.userInfo?.id, rules: 'required', }, { @@ -50,7 +54,7 @@ export function useFormSchema(): VbenFormSchema[] { }, dependencies: { triggerFields: ['id'], - disabled: (values) => !values.customerId, + disabled: (values) => values.customerDefault, }, rules: 'required', }, @@ -103,8 +107,9 @@ export function useFormSchema(): VbenFormSchema[] { component: 'InputNumber', componentProps: { min: 0, + precision: 2, }, - rules: 'required', + rules: z.number().min(0).optional().default(0), }, { fieldName: 'discountPercent', @@ -114,15 +119,19 @@ export function useFormSchema(): VbenFormSchema[] { min: 0, precision: 2, }, - rules: 'required', + rules: z.number().min(0).max(100).optional().default(0), }, { fieldName: 'totalPrice', label: '折扣后金额', component: 'InputNumber', + componentProps: { + min: 0, + precision: 2, + disabled: true, + }, dependencies: { triggerFields: ['totalProductPrice', 'discountPercent'], - disabled: () => true, trigger(values, form) { const discountPrice = erpPriceMultiply( diff --git a/apps/web-antd/src/views/crm/clue/data.ts b/apps/web-antd/src/views/crm/clue/data.ts index e3b31da22..35ebf1831 100644 --- a/apps/web-antd/src/views/crm/clue/data.ts +++ b/apps/web-antd/src/views/crm/clue/data.ts @@ -1,12 +1,15 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import { useUserStore } from '@vben/stores'; + import { getAreaTree } from '#/api/system/area'; import { getSimpleUserList } from '#/api/system/user'; import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { + const userStore = useUserStore(); return [ { fieldName: 'id', @@ -46,6 +49,7 @@ export function useFormSchema(): VbenFormSchema[] { valueField: 'id', allowClear: true, }, + defaultValue: userStore.userInfo?.id, rules: 'required', }, { diff --git a/apps/web-antd/src/views/crm/contact/data.ts b/apps/web-antd/src/views/crm/contact/data.ts index e6a168004..85672390a 100644 --- a/apps/web-antd/src/views/crm/contact/data.ts +++ b/apps/web-antd/src/views/crm/contact/data.ts @@ -1,6 +1,8 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import { useUserStore } from '@vben/stores'; + import { getSimpleContactList } from '#/api/crm/contact'; import { getCustomerSimpleList } from '#/api/crm/customer'; import { getAreaTree } from '#/api/system/area'; @@ -9,6 +11,7 @@ import { DICT_TYPE, getDictOptions } from '#/utils'; /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { + const userStore = useUserStore(); return [ { fieldName: 'id', @@ -35,6 +38,7 @@ export function useFormSchema(): VbenFormSchema[] { value: 'id', }, }, + defaultValue: userStore.userInfo?.id, }, { fieldName: 'customerId', diff --git a/apps/web-antd/src/views/crm/contact/modules/form.vue b/apps/web-antd/src/views/crm/contact/modules/form.vue index 769a92647..37c76d955 100644 --- a/apps/web-antd/src/views/crm/contact/modules/form.vue +++ b/apps/web-antd/src/views/crm/contact/modules/form.vue @@ -60,6 +60,8 @@ const [Modal, modalApi] = useVbenModal({ // 加载数据 const data = modalApi.getData(); if (!data || !data.id) { + // 设置到 values + await formApi.setValues(data); return; } modalApi.lock(); diff --git a/apps/web-antd/src/views/crm/contract/data.ts b/apps/web-antd/src/views/crm/contract/data.ts index 651ddb082..44a0cd144 100644 --- a/apps/web-antd/src/views/crm/contract/data.ts +++ b/apps/web-antd/src/views/crm/contract/data.ts @@ -1,6 +1,7 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import { useUserStore } from '@vben/stores'; import { erpPriceMultiply, floatToFixed2 } from '@vben/utils'; import { z } from '#/adapter/form'; @@ -12,6 +13,7 @@ import { DICT_TYPE } from '#/utils'; /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { + const userStore = useUserStore(); return [ { fieldName: 'id', @@ -27,7 +29,7 @@ export function useFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '保存时自动生成', - disabled: () => true, + disabled: true, }, }, { @@ -50,6 +52,7 @@ export function useFormSchema(): VbenFormSchema[] { value: 'id', }, }, + defaultValue: userStore.userInfo?.id, rules: 'required', }, { @@ -58,22 +61,45 @@ export function useFormSchema(): VbenFormSchema[] { component: 'ApiSelect', rules: 'required', componentProps: { - api: getCustomerSimpleList, - labelField: 'name', - valueField: 'id', + api: () => getCustomerSimpleList(), + fieldNames: { + label: 'name', + value: 'id', + }, placeholder: '请选择客户', }, }, { fieldName: 'businessId', label: '商机名称', - component: 'ApiSelect', + component: 'Select', componentProps: { - api: getSimpleBusinessList, - labelField: 'name', - valueField: 'id', + options: [], placeholder: '请选择商机', }, + dependencies: { + triggerFields: ['customerId'], + disabled: (values) => !values.customerId, + async componentProps(values) { + if (!values.customerId) { + return { + options: [], + placeholder: '请选择客户', + }; + } + const res = await getSimpleBusinessList(); + const list = res.filter( + (item) => item.customerId === values.customerId, + ); + return { + options: list.map((item) => ({ + label: item.name, + value: item.id, + })), + placeholder: '请选择商机', + }; + }, + }, }, { fieldName: 'orderDate', @@ -117,17 +143,39 @@ export function useFormSchema(): VbenFormSchema[] { value: 'id', }, }, + defaultValue: userStore.userInfo?.id, }, { fieldName: 'signContactId', label: '客户签约人', - component: 'ApiSelect', + component: 'Select', componentProps: { - api: getSimpleContactList, - labelField: 'name', - valueField: 'id', + options: [], placeholder: '请选择客户签约人', }, + dependencies: { + triggerFields: ['customerId'], + disabled: (values) => !values.customerId, + async componentProps(values) { + if (!values.customerId) { + return { + options: [], + placeholder: '请选择客户', + }; + } + const res = await getSimpleContactList(); + const list = res.filter( + (item) => item.customerId === values.customerId, + ); + return { + options: list.map((item) => ({ + label: item.name, + value: item.id, + })), + placeholder: '请选择客户签约人', + }; + }, + }, }, { fieldName: 'remark', @@ -150,25 +198,31 @@ export function useFormSchema(): VbenFormSchema[] { component: 'InputNumber', componentProps: { min: 0, + precision: 2, }, + rules: z.number().min(0).optional().default(0), }, { fieldName: 'discountPercent', label: '整单折扣(%)', component: 'InputNumber', - rules: z.number().min(0).max(100).default(0), componentProps: { min: 0, precision: 2, }, + rules: z.number().min(0).max(100).optional().default(0), }, { fieldName: 'totalPrice', label: '折扣后金额', component: 'InputNumber', + componentProps: { + min: 0, + precision: 2, + disabled: true, + }, dependencies: { triggerFields: ['totalProductPrice', 'discountPercent'], - disabled: () => true, trigger(values, form) { const discountPrice = erpPriceMultiply( @@ -203,9 +257,11 @@ export function useGridFormSchema(): VbenFormSchema[] { label: '客户', component: 'ApiSelect', componentProps: { - api: getCustomerSimpleList, - labelField: 'name', - valueField: 'id', + api: () => getCustomerSimpleList(), + fieldNames: { + label: 'name', + value: 'id', + }, placeholder: '请选择客户', }, }, @@ -223,20 +279,20 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { title: '合同名称', field: 'name', - minWidth: 150, + minWidth: 220, fixed: 'left', slots: { default: 'name' }, }, { title: '客户名称', field: 'customerName', - minWidth: 150, + minWidth: 240, slots: { default: 'customerName' }, }, { title: '商机名称', field: 'businessName', - minWidth: 150, + minWidth: 220, slots: { default: 'businessName' }, }, { diff --git a/apps/web-antd/src/views/crm/contract/modules/detail-list.vue b/apps/web-antd/src/views/crm/contract/modules/detail-list.vue index 183a652f6..3dfe57ddb 100644 --- a/apps/web-antd/src/views/crm/contract/modules/detail-list.vue +++ b/apps/web-antd/src/views/crm/contract/modules/detail-list.vue @@ -45,7 +45,15 @@ function onRefresh() { /** 创建合同 */ function handleCreate() { - formModalApi.setData(null).open(); + formModalApi + .setData( + props.bizType === BizTypeEnum.CRM_CUSTOMER + ? { + customerId: props.bizId, + } + : { businessId: props.bizId }, + ) + .open(); } /** 查看合同详情 */ diff --git a/apps/web-antd/src/views/crm/contract/modules/form.vue b/apps/web-antd/src/views/crm/contract/modules/form.vue index 22cad31f6..e09b475bb 100644 --- a/apps/web-antd/src/views/crm/contract/modules/form.vue +++ b/apps/web-antd/src/views/crm/contract/modules/form.vue @@ -90,6 +90,8 @@ const [Modal, modalApi] = useVbenModal({ // 加载数据 const data = modalApi.getData(); if (!data || !data.id) { + // 设置到 values + await formApi.setValues(data); return; } modalApi.lock(); diff --git a/apps/web-antd/src/views/crm/customer/data.ts b/apps/web-antd/src/views/crm/customer/data.ts index 46aa99d05..ef93e523d 100644 --- a/apps/web-antd/src/views/crm/customer/data.ts +++ b/apps/web-antd/src/views/crm/customer/data.ts @@ -1,12 +1,15 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import { useUserStore } from '@vben/stores'; + import { getAreaTree } from '#/api/system/area'; import { getSimpleUserList } from '#/api/system/user'; import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { + const userStore = useUserStore(); return [ { fieldName: 'id', @@ -47,6 +50,7 @@ export function useFormSchema(): VbenFormSchema[] { value: 'id', }, }, + defaultValue: userStore.userInfo?.id, rules: 'required', }, { diff --git a/apps/web-antd/src/views/crm/customer/poolConfig/distribute-form.vue b/apps/web-antd/src/views/crm/customer/poolConfig/distribute-form.vue index 57a487b33..64ca6c7ce 100644 --- a/apps/web-antd/src/views/crm/customer/poolConfig/distribute-form.vue +++ b/apps/web-antd/src/views/crm/customer/poolConfig/distribute-form.vue @@ -1,5 +1,6 @@