From 555e5cfb21d393a6c3af11091248f2bf34e61e17 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期二, 03 六月 2025 17:12:49 +0800
Subject: [PATCH] 调度建议快照配置

---
 /dev/null                                    |   44 -----
 src/views/ai/model/template/index.vue        |  167 ++++++++++++++++++++
 src/views/ai/model/template/templateForm.vue |  211 ++++++++++++++++++++++++++
 3 files changed, 378 insertions(+), 44 deletions(-)

diff --git a/src/api/ai/questionparamsetting/index.ts b/src/api/ai/questionparamsetting/index.ts
deleted file mode 100644
index 0707080..0000000
--- a/src/api/ai/questionparamsetting/index.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import request from '@/config/axios'
-
-// 大模型问题设置参数 VO
-export interface QuestionParamSettingVO {
-  id: string // id
-  templateId: string // 问题模板id
-  settingKey: string // key
-  settingName: string // 参数名称
-  settingValue: string // 参数默认值
-  sort: number // 排序
-}
-
-// 大模型问题设置参数 API
-export const QuestionParamSettingApi = {
-  // 查询大模型问题设置参数分页
-  getQuestionParamSettingPage: async (params: any) => {
-    return await request.get({ url: `/ai/question-param-setting/page`, params })
-  },
-
-  // 查询大模型问题设置参数详情
-  getQuestionParamSetting: async (id: number) => {
-    return await request.get({ url: `/ai/question-param-setting/get?id=` + id })
-  },
-
-  // 新增大模型问题设置参数
-  createQuestionParamSetting: async (data: QuestionParamSettingVO) => {
-    return await request.post({ url: `/ai/question-param-setting/create`, data })
-  },
-
-  // 修改大模型问题设置参数
-  updateQuestionParamSetting: async (data: QuestionParamSettingVO) => {
-    return await request.put({ url: `/ai/question-param-setting/update`, data })
-  },
-
-  // 删除大模型问题设置参数
-  deleteQuestionParamSetting: async (id: number) => {
-    return await request.delete({ url: `/ai/question-param-setting/delete?id=` + id })
-  },
-
-  // 导出大模型问题设置参数 Excel
-  exportQuestionParamSetting: async (params) => {
-    return await request.download({ url: `/ai/question-param-setting/export-excel`, params })
-  },
-}
\ No newline at end of file
diff --git a/src/views/ai/model/template/index.vue b/src/views/ai/model/template/index.vue
new file mode 100644
index 0000000..9d3f2c3
--- /dev/null
+++ b/src/views/ai/model/template/index.vue
@@ -0,0 +1,167 @@
+<template>
+  <!-- 搜索 -->
+  <ContentWrap>
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item label="模型编号" prop="modelCode">
+        <el-input
+          v-model="queryParams.modelCode"
+          placeholder="请输入模型编号"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item label="模型名称" prop="modelName">
+        <el-input
+          v-model="queryParams.modelName"
+          placeholder="请输入模型名称"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="handleQuery">
+          <Icon icon="ep:search" class="mr-5px" />
+          搜索
+        </el-button>
+        <el-button @click="resetQuery">
+          <Icon icon="ep:refresh" class="mr-5px" />
+          重置
+        </el-button>
+        <el-button
+          type="primary"
+          plain
+          @click="openForm('create')"
+          v-hasPermi="['ai:question-template:create']"
+        >
+          <Icon icon="ep:plus" class="mr-5px" />
+          新增
+        </el-button>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+
+  <!-- 列表 -->
+  <ContentWrap>
+    <el-table v-loading="loading" :data="list">
+      <el-table-column label="模型id" align="center" prop="modelId" min-width="100"/>
+      <el-table-column label="问题编号" header-align="center" align="left" prop="questionCode" min-width="100"/>
+      <el-table-column label="问题内容" align="center" prop="questionName" min-width="100"/>
+      <el-table-column label="问题名称" header-align="center" align="left" prop="questionContent" min-width="200"/>
+      <el-table-column label="输入个数" align="center" prop="isEnable" min-width="100"/>
+      <el-table-column label="是否启用" align="center" prop="portLength" min-width="100"/>
+      <el-table-column label="备注" header-align="center" align="left" prop="remark" min-width="200" />
+      <el-table-column label="操作" align="center" min-width="100" fixed="right">
+        <template #default="scope">
+          <el-button
+            link
+            type="primary"
+            @click="openForm('update', scope.row.id)"
+            v-hasPermi="['ai:question-template:update']"
+          >
+            编辑
+          </el-button>
+          <el-button
+            link
+            type="danger"
+            @click="handleDelete(scope.row.id)"
+            v-hasPermi="['ai:question-template:delete']"
+          >
+            删除
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 表单弹窗:添加/修改 -->
+  <TemplateForm ref="formRef" @success="getList" />
+
+</template>
+<script lang="ts" setup>
+  import {DICT_TYPE, getIntDictOptions} from '@/utils/dict'
+  import {dateFormatter} from '@/utils/formatTime'
+  import download from '@/utils/download'
+  import * as AiQuestionTemplateApi from '@/api/ai/questiontemplate'
+  import TemplateForm from './templateForm.vue'
+
+  defineOptions({name: 'AiTemplate'})
+
+  const message = useMessage() // 消息弹窗
+  const {t} = useI18n() // 国际化
+
+  const loading = ref(true) // 列表的加载中
+  const total = ref(0) // 列表的总页数
+  const list = ref([]) // 列表的数据
+  const queryParams = reactive({
+    pageNo: 1,
+    pageSize: 10,
+    modelCode: undefined,
+    modelName: undefined
+  })
+  const queryFormRef = ref() // 搜索的表单
+  const exportLoading = ref(false) // 导出的加载中
+
+  /** 查询列表 */
+  const getList = async () => {
+    loading.value = true
+    try {
+      const page = await AiQuestionTemplateApi.QuestionTemplateApi.getQuestionTemplatePage(queryParams)
+      list.value = page.list
+      total.value = page.total
+    } finally {
+      loading.value = false
+    }
+  }
+
+  /** 搜索按钮操作 */
+  const handleQuery = () => {
+    queryParams.pageNo = 1
+    getList()
+  }
+
+  /** 重置按钮操作 */
+  const resetQuery = () => {
+    queryFormRef.value.resetFields()
+    handleQuery()
+  }
+
+  /** 添加/修改操作 */
+  const formRef = ref()
+  const openForm = (type: string, id?: number) => {
+    formRef.value.open(type, id)
+  }
+
+  /** 删除按钮操作 */
+  const handleDelete = async (id: number) => {
+    try {
+      // 删除的二次确认
+      await message.delConfirm()
+      // 发起删除
+      await AiQuestionTemplateApi.QuestionTemplateApi.deleteQuestionTemplate(id)
+      message.success(t('common.delSuccess'))
+      // 刷新列表
+      await getList()
+    } catch {
+    }
+  }
+
+  /** 初始化 **/
+  onMounted(async () => {
+    await getList()
+  })
+</script>
diff --git a/src/views/ai/model/template/templateForm.vue b/src/views/ai/model/template/templateForm.vue
new file mode 100644
index 0000000..5262d4c
--- /dev/null
+++ b/src/views/ai/model/template/templateForm.vue
@@ -0,0 +1,211 @@
+<template>
+  <Dialog v-model="dialogVisible" :title="dialogTitle" width="75%">
+    <el-form
+      ref="formRef"
+      v-loading="formLoading"
+      :model="formData"
+      :rules="formRules"
+      label-width="120px"
+    >
+      <el-divider content-position="left">基本信息</el-divider>
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="问题编号" prop="questionCode">
+            <el-input v-model="formData.questionCode" placeholder="请输入问题编号" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="问题名称" prop="questionName">
+            <el-input v-model="formData.questionName" placeholder="请输入问题名称" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="输入个数" prop="dataLength">
+            <el-input v-model="formData.dataLength" placeholder="请输入输入个数"/>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="问题内容" prop="questionContent">
+            <el-input
+              type="textarea"
+              :autosize="{ minRows: 2}"
+              placeholder="请输入问题内容"
+              v-model="formData.questionContent"/>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-divider content-position="left">设置参数</el-divider>
+      <el-table
+        :data="formData.settingList"
+        border
+        style="width: 100%; margin-top: 5px;">
+        <el-table-column
+          prop=""
+          label="键"
+          min-width="150"
+          align="center">
+          <template #default="scope">
+            <el-input v-model="scope.row.settingKey" maxlength="20" clearable
+                      style="width:100%;hight:100%"/>
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop=""
+          label="名称"
+          min-width="150"
+          align="center">
+          <template #default="scope">
+            <el-input v-model="scope.row.settingName" maxlength="20" clearable
+                      style="width:100%;hight:100%"/>
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop=""
+          label="值"
+          min-width="150"
+          align="center">
+          <template #default="scope">
+            <el-input v-model="scope.row.settingValue" maxlength="256" clearable
+                      style="width:100%;hight:100%"/>
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop=""
+          label="操作"
+          width="150"
+          align="center">
+          <template #default="scope">
+            <el-button
+              link
+              @click.prevent="addRow(scope.$index, formData.settingList)"
+              type="primary"
+              size="small">
+              添加
+            </el-button>
+            <el-button
+              link
+              @click.prevent="deleteRow(scope.$index, formData.settingList)"
+              type="primary"
+              size="small">
+              删除
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </el-form>
+    <template #footer>
+      <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
+      <el-button @click="dialogVisible = false">取 消</el-button>
+    </template>
+  </Dialog>
+</template>
+
+<script lang="ts" setup>
+  import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
+  import * as AiQuestionTemplateApi from '@/api/ai/questiontemplate'
+  import { CommonStatusEnum } from '@/utils/constants'
+  import { ElMessage } from 'element-plus'
+
+  defineOptions({ name: 'AiTemplateForm' })
+
+  const { t } = useI18n()
+  const message = useMessage()
+  const dialogVisible = ref(false)
+  const dialogTitle = ref('')
+  const formLoading = ref(false)
+  const formType = ref('')
+  const formData = ref({
+    id: undefined,
+    questionCode: undefined,
+    questionName: undefined,
+    dataLength: undefined,
+    questionContent: undefined,
+    settingList: [{
+      settingKey: '',
+      settingName: '',
+      settingValue: '',
+    }]
+  })
+  const formRules = reactive({
+    questionCode: [{ required: true, message: '问题编号不能为空', trigger: 'blur' }],
+    questionName: [{ required: true, message: '问题名称不能为空', trigger: 'blur' }],
+    dataLength: [{ required: true, message: '输入个数不能为空', trigger: 'blur' }],
+    questionContent: [{ required: true, message: '问题内容不能为空', trigger: 'blur' }]
+  })
+  const formRef = ref()
+
+  const addRow = function (index, rows) {
+    rows.splice(index + 1, 0, {
+      settingKey: '',
+      settingName: '',
+      settingValue: '',
+    })
+  }
+
+  const deleteRow = function (index, rows) {
+    if (rows.length <= 1) {
+      message.error('至少保留一个参数')
+      return
+    }
+    rows.splice(index, 1)
+  }
+
+  const open = async (type: string, id?: number) => {
+    dialogVisible.value = true
+    dialogTitle.value = t('action.' + type)
+    formType.value = type
+    resetForm()
+    if (id) {
+      formLoading.value = true
+      try {
+        formData.value = await AiQuestionTemplateApi.QuestionTemplateApi.getQuestionTemplate(id)
+      } finally {
+        formLoading.value = false
+      }
+    }
+  }
+  defineExpose({ open })
+
+  const emit = defineEmits(['success'])
+  const submitForm = async () => {
+    if (!formRef) return
+    const valid = await formRef.value.validate()
+    if (!valid) return
+
+    formLoading.value = true
+    try {
+      const data = formData.value
+      if (formType.value === 'create') {
+        await AiQuestionTemplateApi.QuestionTemplateApi.createQuestionTemplate(data)
+        message.success(t('common.createSuccess'))
+      } else {
+        await AiQuestionTemplateApi.QuestionTemplateApi.updateQuestionTemplate(data)
+        message.success(t('common.updateSuccess'))
+      }
+      dialogVisible.value = false
+      emit('success')
+    } finally {
+      formLoading.value = false
+    }
+  }
+
+  const resetForm = () => {
+    formData.value = {
+      id: undefined,
+      questionCode: undefined,
+      questionName: undefined,
+      dataLength: undefined,
+      questionContent: undefined,
+      settingList: [{
+        settingKey: '',
+        settingName: '',
+        settingValue: '',
+      }]
+    }
+    formRef.value?.resetFields()
+  }
+</script>

--
Gitblit v1.9.3