gaoluyang
2 天以前 787ccc59ba89bacc075562a161ecf02bc76ebadc
src/views/crm/contract/data.ts
@@ -1,14 +1,16 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { useUserStore } from '../../../packages/stores/src';
import { erpPriceInputFormatter, erpPriceMultiply } from '../../../packages/utils/src';
import { useUserStore } from '@vben/stores';
import { erpPriceInputFormatter, erpPriceMultiply } from '@vben/utils';
import { z } from '#/adapter/form';
import { getSimpleBusinessList } from '#/api/crm/business';
import { getSimpleContactList } from '#/api/crm/contact';
import { getCustomerSimpleList } from '#/api/crm/customer';
import { getSimpleUserList } from '#/api/system/user';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
import { markRaw } from 'vue';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@@ -59,13 +61,26 @@
    {
      fieldName: 'customerId',
      label: '客户名称',
      component: 'ApiSelect',
      component: markRaw(CrmCustomerSelect),
      rules: 'required',
      componentProps: {
        api: getCustomerSimpleList,
        labelField: 'name',
        valueField: 'id',
        placeholder: '请选择客户',
      },
      dependencies: {
        triggerFields: ['customerId'],
        disabled: (values) => !!values.customerId,
      },
    },
    {
      fieldName: 'orderDate',
      label: '下单日期',
      component: 'DatePicker',
      rules: 'required',
      componentProps: {
        showTime: false,
        format: 'YYYY-MM-DD',
        valueFormat: 'x',
        placeholder: '请选择下单日期',
      },
    },
    {
@@ -77,9 +92,15 @@
        placeholder: '请选择商机',
      },
      dependencies: {
        triggerFields: ['customerId'],
        disabled: (values) => !values.customerId,
        triggerFields: ['customerId', 'businessId'],
        disabled: (values) => !!values.businessId || !values.customerId,
        async componentProps(values) {
          if (values.businessId && values.businessName) {
            return {
              options: [{ label: values.businessName, value: values.businessId }],
              placeholder: '请选择商机',
            };
          }
          if (!values.customerId) {
            return {
              options: [],
@@ -98,18 +119,6 @@
            placeholder: '请选择商机',
          };
        },
      },
    },
    {
      fieldName: 'orderDate',
      label: '下单日期',
      component: 'DatePicker',
      rules: 'required',
      componentProps: {
        showTime: false,
        format: 'YYYY-MM-DD',
        valueFormat: 'x',
        placeholder: '请选择下单日期',
      },
    },
    {
@@ -133,6 +142,18 @@
        valueFormat: 'x',
        placeholder: '请选择合同结束时间',
      },
    },
    {
      fieldName: 'depositPrice',
      label: '定金金额(元)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 2,
        placeholder: '请输入定金金额',
      },
      rules: z.number().min(0).optional(),
    },
    {
      fieldName: 'signUserId',
@@ -268,11 +289,8 @@
    {
      fieldName: 'customerId',
      label: '客户',
      component: 'ApiSelect',
      component: markRaw(CrmCustomerSelect),
      componentProps: {
        api: getCustomerSimpleList,
        labelField: 'name',
        valueField: 'id',
        placeholder: '请选择客户',
        allowClear: true,
      },
@@ -341,6 +359,12 @@
      formatter: 'formatAmount2',
    },
    {
      title: '定金金额(元)',
      field: 'depositPrice',
      minWidth: 140,
      formatter: 'formatAmount2',
    },
    {
      title: '下单时间',
      field: 'orderDate',
      minWidth: 120,