fix: bugs

pull/158/head
xingyu4j 2025-06-25 18:22:06 +08:00
parent d94dbe73e1
commit 2855eb4e08
19 changed files with 178 additions and 51 deletions

View File

@ -5,6 +5,7 @@ import { requestClient } from '#/api/request';
export namespace CrmBusinessStatusApi {
/** 商机状态信息 */
export interface BusinessStatusType {
[x: string]: any;
id?: number;
name: string;
percent: number;

View File

@ -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}`,
);
}
/** 进入公海客户提醒的客户列表 */

View File

@ -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(

View File

@ -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',
},
{

View File

@ -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',

View File

@ -60,6 +60,8 @@ const [Modal, modalApi] = useVbenModal({
//
const data = modalApi.getData<CrmContactApi.Contact>();
if (!data || !data.id) {
// values
await formApi.setValues(data);
return;
}
modalApi.lock();

View File

@ -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' },
},
{

View File

@ -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();
}
/** 查看合同详情 */

View File

@ -90,6 +90,8 @@ const [Modal, modalApi] = useVbenModal({
//
const data = modalApi.getData<CrmContractApi.Contract>();
if (!data || !data.id) {
// values
await formApi.setValues(data);
return;
}
modalApi.lock();

View File

@ -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',
},
{

View File

@ -1,5 +1,6 @@
<script lang="ts" setup>
import { useVbenModal } from '@vben/common-ui';
import { useUserStore } from '@vben/stores';
import { message } from 'ant-design-vue';
@ -10,6 +11,8 @@ import { $t } from '#/locales';
const emit = defineEmits(['success']);
const userStore = useUserStore();
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
@ -39,6 +42,7 @@ const [Form, formApi] = useVbenForm({
value: 'id',
},
},
defaultValue: userStore.userInfo?.id,
rules: 'required',
},
],

View File

@ -1,6 +1,7 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { useUserStore } from '@vben/stores';
import { handleTree } from '@vben/utils';
import { z } from '#/adapter/form';
@ -10,6 +11,7 @@ import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
const userStore = useUserStore();
return [
{
component: 'Input',
@ -31,9 +33,13 @@ export function useFormSchema(): VbenFormSchema[] {
label: '负责人',
rules: 'required',
componentProps: {
api: getSimpleUserList,
fieldNames: { label: 'nickname', value: 'id' },
api: () => getSimpleUserList(),
fieldNames: {
label: 'nickname',
value: 'id',
},
},
defaultValue: userStore.userInfo?.id,
},
{
component: 'Input',

View File

@ -1,6 +1,8 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { useUserStore } from '@vben/stores';
import { getContractSimpleList } from '#/api/crm/contract';
import { getCustomerSimpleList } from '#/api/crm/customer';
import { getReceivablePlanSimpleList } from '#/api/crm/receivable/plan';
@ -9,6 +11,7 @@ import { DICT_TYPE, getDictOptions } from '#/utils';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
const userStore = useUserStore();
return [
{
fieldName: 'id',
@ -34,11 +37,14 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'ApiSelect',
rules: 'required',
componentProps: {
api: getSimpleUserList,
labelField: 'nickname',
valueField: 'id',
placeholder: '请选择客户',
api: () => getSimpleUserList(),
fieldNames: {
label: 'nickname',
value: 'id',
},
placeholder: '请选择负责人',
},
defaultValue: userStore.userInfo?.id,
},
{
fieldName: 'customerId',
@ -46,9 +52,11 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'ApiSelect',
rules: 'required',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
api: () => getCustomerSimpleList(),
fieldNames: {
label: 'name',
value: 'id',
},
placeholder: '请选择客户',
},
},
@ -159,9 +167,11 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '客户',
component: 'ApiSelect',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
api: () => getCustomerSimpleList(),
fieldNames: {
label: 'name',
value: 'id',
},
placeholder: '请选择客户',
},
},

View File

@ -33,7 +33,12 @@ function onRefresh() {
/** 创建回款 */
function handleCreate() {
formModalApi.setData(null).open();
formModalApi
.setData({
contractId: props.contractId,
customerId: props.customerId,
})
.open();
}
/** 编辑回款 */

View File

@ -66,6 +66,8 @@ const [Modal, modalApi] = useVbenModal({
//
const data = modalApi.getData();
if (!data) {
// values
await formApi.setValues(data);
return;
}
const { receivable, plan } = data;

View File

@ -16,9 +16,11 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'ApiSelect',
rules: 'required',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
api: () => getCustomerSimpleList(),
fieldNames: {
label: 'name',
value: 'id',
},
placeholder: '请选择客户',
},
},
@ -121,9 +123,11 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '客户',
component: 'ApiSelect',
componentProps: {
api: getCustomerSimpleList,
labelField: 'name',
valueField: 'id',
api: () => getCustomerSimpleList(),
fieldNames: {
label: 'name',
value: 'id',
},
placeholder: '请选择客户',
},
},

View File

@ -40,7 +40,12 @@ function onRefresh() {
/** 创建回款计划 */
function handleCreate() {
formModalApi.setData(null).open();
formModalApi
.setData({
contractId: props.contractId,
customerId: props.customerId,
})
.open();
}
/** 创建回款 */

View File

@ -66,6 +66,8 @@ const [Modal, modalApi] = useVbenModal({
//
const data = modalApi.getData<CrmReceivablePlanApi.Plan>();
if (!data || !data.id) {
// values
await formApi.setValues(data);
return;
}
modalApi.lock();

View File

@ -120,7 +120,7 @@ export function useBindFormSchema(): VbenFormSchema[] {
label: '门店名称',
dependencies: {
triggerFields: ['id'],
disabled: () => true,
disabled: true,
},
},
{
@ -149,7 +149,7 @@ export function useBindFormSchema(): VbenFormSchema[] {
trigger(values, form) {
form.setFieldValue('verifyUsers', values.verifyUserIds);
},
disabled: () => true,
disabled: true,
},
},
];