gaoluyang
2026-10-12 d841a8ea6dc2f7fdedbf0ea2b1e539842f5f3e37
src/views/crm/business/detail/data.ts
@@ -7,7 +7,6 @@
import { erpPriceInputFormatter, formatDateTime } from '@vben/utils';
import {
  DEFAULT_STATUSES,
  getBusinessStatusSimpleList,
} from '#/api/crm/business/status';
@@ -95,47 +94,34 @@
    },
    {
      fieldName: 'statusId',
      label: '商机状态',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'endStatus',
      label: '商机状态',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'status',
      label: '商机阶段',
      component: 'Select',
      dependencies: {
        triggerFields: [''],
        async componentProps() {
          const statusList = await getBusinessStatusSimpleList(
            formData.value?.statusTypeId ?? 0,
          );
          const statusOptions = statusList.map((item) => ({
          const statusTypeId = formData.value?.statusTypeId;
          // 商机状态组为选填:未设置状态组时没有可选阶段,禁用并说明原因
          if (!statusTypeId) {
            return {
              disabled: true,
              options: [],
              placeholder: '该商机未设置「商机状态组」,无可选商机阶段',
            };
          }
          const statusList = await getBusinessStatusSimpleList(statusTypeId);
          const options = statusList.map((item) => ({
            label: `${item.name}(赢单率:${item.percent}%)`,
            value: item.id,
          }));
          const options = DEFAULT_STATUSES.map((item) => ({
            label: `${item.name}(赢单率:${item.percent}%)`,
            value: item.endStatus,
          }));
          statusOptions.push(...options);
          return {
            options: statusOptions,
            disabled: false,
            options,
            placeholder: '请选择商机阶段',
          };
        },
        // 未设置商机状态组时不做必填校验(此时也没有阶段可供选择)
        rules: () => (formData.value?.statusTypeId ? 'required' : null),
      },
      rules: 'required',
    },
  ];
}