liu
2026-10-26 7763f23f3224a0f609c4c483351edd656b0dfb26
src/views/ai/model/model/data.ts
@@ -1,7 +1,9 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { AiModelTypeEnum, CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import type { AiModelModelApi } from '#/api/ai/model/model';
import { AiModelCapabilityEnum, AiModelTypeEnum, CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { z } from '#/adapter/form';
@@ -41,6 +43,26 @@
        };
      },
      rules: 'required',
    },
    {
      fieldName: 'capability',
      label: '模型能力',
      component: 'Select',
      componentProps: (values) => {
        return {
          placeholder: '请选择模型能力',
          // 只有对话类型区分文本/视觉,其余类型统一按文本能力处理
          disabled: !!values.id || values.type !== AiModelTypeEnum.CHAT,
          options: getDictOptions(DICT_TYPE.AI_MODEL_CAPABILITY, 'string'),
          allowClear: true,
        };
      },
      help: '同一类型同一能力只能启用一个模型;视觉能力用于图片识别',
      dependencies: {
        triggerFields: ['type'],
        show: (values) => values.type === AiModelTypeEnum.CHAT,
      },
      rules: z.string().default(AiModelCapabilityEnum.TEXT),
    },
    {
      fieldName: 'keyId',
@@ -162,11 +184,31 @@
      },
    },
    {
      fieldName: 'type',
      label: '模型类型',
      component: 'Select',
      componentProps: {
        placeholder: '请选择模型类型',
        options: getDictOptions(DICT_TYPE.AI_MODEL_TYPE, 'number'),
        allowClear: true,
      },
    },
    {
      fieldName: 'model',
      label: '模型标识',
      component: 'Input',
      componentProps: {
        placeholder: '请输入模型标识',
        allowClear: true,
      },
    },
    {
      fieldName: 'capability',
      label: '模型能力',
      component: 'Select',
      componentProps: {
        placeholder: '请选择模型能力',
        options: getDictOptions(DICT_TYPE.AI_MODEL_CAPABILITY, 'string'),
        allowClear: true,
      },
    },
@@ -183,23 +225,34 @@
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
export function useGridColumns(
  onStatusChange?: (newStatus: number, row: AiModelModelApi.Model) => Promise<boolean | undefined>,
): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'platform',
      title: '所属平台',
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.AI_PLATFORM },
      },
      minWidth: 100,
    },
    {
      field: 'type',
      title: '模型类型',
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.AI_MODEL_TYPE },
      },
      minWidth: 100,
    },
    {
      field: 'capability',
      title: '模型能力',
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.AI_MODEL_CAPABILITY },
      },
      minWidth: 100,
    },
    {
      field: 'platform',
      title: '所属平台',
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.AI_PLATFORM },
      },
      minWidth: 100,
    },
@@ -225,12 +278,17 @@
    },
    {
      field: 'status',
      title: '状态',
      title: '启用',
      minWidth: 100,
      align: 'center',
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.COMMON_STATUS },
        attrs: { beforeChange: onStatusChange },
        name: 'CellSwitch',
        props: {
          checkedValue: CommonStatusEnum.ENABLE,
          unCheckedValue: CommonStatusEnum.DISABLE,
        },
      },
      minWidth: 80,
    },
    {
      field: 'temperature',