<script setup lang="ts">
import { ref } from 'vue';
import OperateModel from '@/components/advanced/operate-model.vue';
import { useFormRules } from '@/hooks/common/form';

defineOptions({
  name: 'ModelConfigOperateModel',
  inheritAttrs: false
});

defineProps<{
  modelTypeOptions: { label: string; value: string }[];
}>();

const { defaultRequiredRule } = useFormRules();

type Model = Omit<Api.ModelConfig.ContractModelConfigVo, 'id'>;
type RuleKey = keyof Omit<Model, 'modelKey' | 'modelVersion'>;

const model = ref<Model>({
  modelName: '',
  modelUrl: '',
  modelKey: '',
  modelVersion: '',
  modelType: null
});

const rules: Record<RuleKey, App.Global.FormRule> = {
  modelName: defaultRequiredRule,
  modelUrl: defaultRequiredRule,
  // modelKey: defaultRequiredRule,
  modelType: defaultRequiredRule
};
</script>

<template>
  <OperateModel v-model:model="model" :rules="rules" title="参数" v-bind="$attrs">
    <template #formItem>
      <NFormItemGi span="24" label="模型名称" path="modelName">
        <NInput v-model:value="model.modelName" placeholder="请输入模型名称" />
      </NFormItemGi>
      <NFormItemGi span="24" label="模型类型" path="modelType">
        <NSelect v-model:value="model.modelType" :options="modelTypeOptions" placeholder="请选择模型类型"></NSelect>
      </NFormItemGi>
      <NFormItemGi span="24" label="模型地址" path="modelUrl">
        <NInput v-model:value="model.modelUrl" placeholder="请输入模型地址" />
      </NFormItemGi>
      <NFormItemGi span="24" label="参数键值" path="modelKey">
        <NInput v-model:value="model.modelKey" placeholder="请输入参数键值" />
      </NFormItemGi>
      <NFormItemGi span="24" label="模型版本" path="modelVersion">
        <NInput v-model:value="model.modelVersion" placeholder="请输入模型版本" />
      </NFormItemGi>
    </template>
  </OperateModel>
</template>

<style scoped>

</style>
