xiaoyi
5 天以前 27c8277d717b34b55f3ea967027b53b067f77df3
src/views/crm/contract/data.ts
@@ -1,14 +1,18 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
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 +63,14 @@
    {
      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,
      },
    },
    {
@@ -76,7 +81,7 @@
      componentProps: {
        showTime: false,
        format: 'YYYY-MM-DD',
        valueFormat: 'x',
        valueFormat: 'YYYY-MM-DD',
        placeholder: '请选择下单日期',
      },
    },
@@ -89,9 +94,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: [],
@@ -119,7 +130,7 @@
      componentProps: {
        showTime: false,
        format: 'YYYY-MM-DD',
        valueFormat: 'x',
        valueFormat: 'YYYY-MM-DD',
        placeholder: '请选择合同开始时间',
      },
    },
@@ -130,7 +141,7 @@
      componentProps: {
        showTime: false,
        format: 'YYYY-MM-DD',
        valueFormat: 'x',
        valueFormat: 'YYYY-MM-DD',
        placeholder: '请选择合同结束时间',
      },
    },
@@ -187,6 +198,78 @@
            placeholder: '请选择客户签约人',
          };
        },
      },
    },
    {
      fieldName: 'contractType',
      label: '合同类型',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.CRM_CONTRACT_TYPE),
        placeholder: '请选择合同类型',
        allowClear: true,
      },
    },
    {
      fieldName: 'voltageLevel',
      label: '电压等级',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.CRM_VOLTAGE_LEVEL),
        placeholder: '请选择电压等级',
        allowClear: true,
      },
    },
    {
      fieldName: 'electricityType',
      label: '用电类型',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.CRM_ELECTRICITY_TYPE),
        placeholder: '请选择用电类型',
        allowClear: true,
      },
    },
    {
      fieldName: 'contractCapacity',
      label: '合同容量(kVA)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        precision: 2,
        placeholder: '请输入合同容量',
      },
    },
    {
      fieldName: 'tariffMode',
      label: '电价模式',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.CRM_TARIFF_MODE),
        placeholder: '请选择电价模式',
        allowClear: true,
      },
    },
    {
      fieldName: 'meterMode',
      label: '计量方式',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.CRM_METER_MODE),
        placeholder: '请选择计量方式',
        allowClear: true,
      },
    },
    {
      fieldName: 'payCycle',
      label: '缴费周期(月)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 1,
        precision: 0,
        placeholder: '请输入缴费周期',
      },
    },
    {
@@ -280,11 +363,8 @@
    {
      fieldName: 'customerId',
      label: '客户',
      component: 'ApiSelect',
      component: markRaw(CrmCustomerSelect),
      componentProps: {
        api: getCustomerSimpleList,
        labelField: 'name',
        valueField: 'id',
        placeholder: '请选择客户',
        allowClear: true,
      },
@@ -347,6 +427,34 @@
      slots: { default: 'businessName' },
    },
    {
      title: '合同类型',
      field: 'contractType',
      minWidth: 110,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.CRM_CONTRACT_TYPE },
      },
    },
    {
      title: '电压等级',
      field: 'voltageLevel',
      minWidth: 90,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.CRM_VOLTAGE_LEVEL },
      },
    },
    {
      title: '合同容量',
      field: 'contractCapacity',
      minWidth: 100,
    },
    {
      title: '指令数',
      field: 'commandCount',
      minWidth: 80,
    },
    {
      title: '合同金额(元)',
      field: 'totalPrice',
      minWidth: 140,
@@ -409,6 +517,18 @@
      },
    },
    {
      title: '已开票金额(元)',
      field: 'totalInvoicePrice',
      minWidth: 150,
      formatter: 'formatAmount2',
    },
    {
      title: '未开票金额(元)',
      field: 'unInvoicePrice',
      minWidth: 140,
      formatter: 'formatAmount2',
    },
    {
      title: '最后跟进时间',
      field: 'contactLastTime',
      minWidth: 180,