Bläddra i källkod

ai题名接口调用

duy 1 månad sedan
förälder
incheckning
448a81eedc
2 ändrade filer med 58 tillägg och 11 borttagningar
  1. 7 1
      src/api/modules/ai/ai.js
  2. 51 10
      src/views/archives/manage/ai.vue

+ 7 - 1
src/api/modules/ai/ai.js

@@ -25,6 +25,12 @@ export default {
             params: form,
         }, msg)
     },
-
+    async confirmAiName(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-archive/archiveainame/confirmAiName',
+            method: 'post',
+            data: form,
+        }, msg)
+    },
 
 }

+ 51 - 10
src/views/archives/manage/ai.vue

@@ -4,24 +4,24 @@
             AI案卷题名生成列表
         </template>
         <template #extra>
-            <el-button type="primary" hc-btn>
+            <el-button type="primary" hc-btn :loading="saveLoading" @click="saveClick">
                 <HcIcon name="save" />
                 <span>确认页面</span>
             </el-button>
-            <el-button hc-btn>
+            <el-button hc-btn @click="closePage">
                 <HcIcon name="close" />
                 <span>关闭页面</span>
             </el-button>
         </template>
         
 
-        <hc-table :column="tableColumn" :datas="tableData">
+        <hc-table ref="tableRef" :column="tableColumn" :datas="tableData" :check-style="{ width: 29 }" is-check is-new @selection-change="tableSelection">
             <template #archiveNameAi="{ row }">
                 <hc-table-input v-model="row.archiveNameAi" class="blue-text" />
             </template>
             <template #action="{ row, index }">
                 <el-link type="warning">修订</el-link>
-                <el-link type="success">确认</el-link>
+                <el-link v-loading="row?.load" type="success" @click="confirmClick">确认</el-link>
             </template>
         </hc-table>
 
@@ -35,23 +35,33 @@
 import { onMounted, ref } from 'vue'
 import aiApi from '~api/ai/ai.js'
 import { useAppStore } from '~src/store'
-import { useRoute } from 'vue-router'
+import { useRoute, useRouter } from 'vue-router'
 import { getArrValue } from 'js-fast-way'
+import { rowsToId } from '~uti/tools'
 const useAppState = useAppStore()
 
 const projectId = ref(useAppState.getProjectId)
 const contractId = ref(useAppState.getContractId)
 const useRoutes = useRoute()
+const router = useRouter() // 获取路由实例
 const tableColumn = [
     { key: 'archiveName', name: '案卷题名' },
     { key: 'archiveNameAi', name: 'AI题名' },
     { key: 'action', name: '操作', width: 120 },
 ]
+const tableRef = ref(null)
 const tableData = ref([
     { id: 1, name: '名称1', text: '文本1', color: 'red' },
     { id: 2, name: '名称2', text: '文本2', color: 'blue' },
     { id: 3, name: '名称3', text: '文本3', color: '无' },
 ])
+
+//渲染完成
+onMounted(() => {
+    // getClassIfyList()
+    getTableData
+
+})
 //搜索表单
 const searchForm = ref({ current: 1, size: 20, total: 60 })
 const taskId = ref(useRoutes.query.taskId)
@@ -80,12 +90,43 @@ const getTableData = async () => {
     }
 }
 
-//渲染完成
-onMounted(() => {
-    // getClassIfyList()
-    getTableData
+const tableSelection = (rows) => {
+    tableCheckedKeys.value = rows
+}
+const saveLoading = ref(false)
+const tableCheckedKeys = ref([])
+const saveClick = async () => {
+         let ids = ''
+    const rows = tableCheckedKeys.value
+    ids = rowsToId(rows)
+    saveLoading.value = true
+    const { error, code, msg } = await aiApi.confirmAiName({
+        ids,
+        status:1,
+    })
+     saveLoading.value = false
+    if (!error && code === 200) {
+       window.$message.success(msg)
+       getTableData()
+    } 
+}
 
-})
+const confirmClick = async (row) => {
+    
+    row.load = true
+    const { error, code, msg } = await aiApi.confirmAiName({
+        ids:row.id,
+        status:1,
+    })
+      row.load = false
+    if (!error && code === 200) {
+       window.$message.success(msg)
+       getTableData()
+    } 
+}
+const closePage = ()=>{
+      router.go(-1) 
+}
 </script>
 
 <style>