src/views/crm/business/detail/data.ts
@@ -99,19 +99,29 @@
      dependencies: {
        triggerFields: [''],
        async componentProps() {
          const statusList = await getBusinessStatusSimpleList(
            formData.value?.statusTypeId ?? 0,
          );
          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,
          }));
          return {
            disabled: false,
            options,
            placeholder: '请选择商机阶段',
          };
        },
        // 未设置商机状态组时不做必填校验(此时也没有阶段可供选择)
        rules: () => (formData.value?.statusTypeId ? 'required' : null),
      },
      rules: 'required',
    },
  ];
}