knowledgeSet.vue 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. <template>
  2. <div class="project-search">
  3. <div class="file-categories">
  4. <el-button type="primary" @click="createNewFolder">
  5. <i class="el-icon-plus"></i> 新建目录
  6. </el-button>
  7. <p>{{ $route.query.name }}</p>
  8. <el-tree
  9. :data="folders"
  10. :props="defaultProps"
  11. @node-click="handleNodeClick"
  12. ref="folderTree"
  13. :default-expanded-keys="['0']"
  14. node-key="id"
  15. highlight-current
  16. >
  17. <span class="custom-tree-node" slot-scope="{ node, data }">
  18. <span class="tree_title">
  19. <i class="el-icon-folder"></i>
  20. <span class="folder-name" :title="node.label">{{
  21. node.label
  22. }}</span>
  23. </span>
  24. <span v-if="data.id !== '001'" :class="getFileCountClass(data.id)"
  25. >{{ data.document_count }} files</span
  26. >
  27. <span
  28. class="folder-actions"
  29. v-if="data.id !== 0 && data.id !== '001'"
  30. >
  31. <el-tooltip
  32. class="item"
  33. effect="dark"
  34. content="编辑"
  35. placement="top"
  36. >
  37. <i class="el-icon-edit" @click.stop="editFolder(data)"></i>
  38. </el-tooltip>
  39. <el-tooltip
  40. class="item"
  41. effect="dark"
  42. content="删除"
  43. placement="top"
  44. >
  45. <i class="el-icon-delete" @click.stop="deleteFolder(data.id)"></i>
  46. </el-tooltip>
  47. </span>
  48. </span>
  49. </el-tree>
  50. </div>
  51. <div class="right">
  52. <dataSearch
  53. @bindSetQuery="setQuery"
  54. @refreshFolders="typeList"
  55. ></dataSearch>
  56. <!-- <dataList
  57. :queryForm="queryForm"
  58. :allowEdit="checkAuth('/document/update')"
  59. :allowDelete="checkAuth('/document/delete')"
  60. ></dataList> -->
  61. <div
  62. class="data-list"
  63. v-loading="loading"
  64. element-loading-text="加载中..."
  65. >
  66. <div class="batch-actions" style="margin: 10px 0">
  67. <el-dropdown
  68. @command="handleBatchCommand"
  69. :disabled="!selectedRows.length"
  70. >
  71. <el-button type="primary" style="color: #fff">
  72. 批量操作
  73. <i data-feather="chevron-down" class="el-icon--right icons"></i>
  74. </el-button>
  75. <el-dropdown-menu slot="dropdown">
  76. <el-dropdown-item command="analysis">
  77. <i data-feather="play" class="icons"></i> 批量解析
  78. </el-dropdown-item>
  79. <el-dropdown-item command="modifyFolder">
  80. <i data-feather="folder" class="icons"></i> 批量修改目录
  81. </el-dropdown-item>
  82. <el-dropdown-item command="delete">
  83. <i data-feather="trash-2" class="icons"></i> 批量删除
  84. </el-dropdown-item>
  85. </el-dropdown-menu>
  86. </el-dropdown>
  87. <el-button type="danger" @click="endAnalysis()">
  88. <i data-feather="stop-circle" class="icons"></i>
  89. 终止所有任务
  90. </el-button>
  91. </div>
  92. <div class="selection-control" v-if="selectedRows.length > 0">
  93. <el-alert
  94. type="info"
  95. show-icon
  96. :closable="false"
  97. style="margin-bottom: 10px"
  98. >
  99. <template v-if="!isAllDataSelected">
  100. <!-- <span>已选择 {{ selectedRows.length }} 项</span> -->
  101. <span
  102. type="text"
  103. style="cursor: pointer; color: #409eff; margin-left: 10px"
  104. @click="handleSelectAllData"
  105. >
  106. 选择全部{{ recordCount }}条数据
  107. </span>
  108. </template>
  109. <template v-else>
  110. <span>已选择全部{{ recordCount }}条数据</span>
  111. <span
  112. type="text"
  113. style="cursor: pointer; color: #409eff; margin-left: 10px"
  114. @click="handleCancelAllSelection"
  115. >
  116. 取消全选
  117. </span>
  118. </template>
  119. </el-alert>
  120. </div>
  121. <el-table
  122. ref="dataTable"
  123. :data="dataList"
  124. style="width: 100%; font-size: 12px"
  125. header-row-class-name="headerBg"
  126. empty-text="暂无数据"
  127. @selection-change="handleSelectionChange"
  128. @sort-change="handleSortChange"
  129. :row-key="getRowKey"
  130. >
  131. <el-table-column
  132. type="selection"
  133. width="55"
  134. :reserve-selection="true"
  135. ></el-table-column>
  136. <el-table-column prop="id" label="ID" align="center" width="80" />
  137. <el-table-column prop="name" label="文件名称" sortable width="350">
  138. <template #default="scope">
  139. <span>{{ scope.row.name }}</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column prop="type" label="文件类型" align="center" />
  143. <el-table-column prop="chunk_num" label="分块数" align="center" />
  144. <el-table-column
  145. prop="create_time"
  146. label="上传时间"
  147. align="center"
  148. sortable
  149. width="140"
  150. />
  151. <el-table-column prop="run" label="解析状态" align="center">
  152. <template #default="scope">
  153. <el-tooltip
  154. effect="dark"
  155. placement="top"
  156. :disabled="
  157. Number(scope.row.run) !== 1 && Number(scope.row.run) !== 4
  158. "
  159. >
  160. <template #content>
  161. <div style="padding: 5px">
  162. <div style="margin-top: 5px; font-size: 12px">
  163. {{ scope.row.progress_msg || "正在解析中..." }}
  164. </div>
  165. </div>
  166. </template>
  167. <div class="status-wrapper">
  168. <template v-if="Number(scope.row.run) === 1">
  169. <div class="progress-wrapper">
  170. <el-progress
  171. type="circle"
  172. :percentage="Math.floor(scope.row.progress) || 0"
  173. :width="30"
  174. :stroke-width="2"
  175. :format="percentFormat"
  176. ></el-progress
  177. ><!-- :status="getProgressStatus(scope.row.progress)" -->
  178. </div>
  179. </template>
  180. <template v-else>
  181. <el-tag :type="getStatusType(scope.row.run)" size="small">
  182. {{ getStatusText(scope.row.run) }}
  183. </el-tag>
  184. </template>
  185. </div>
  186. </el-tooltip>
  187. </template>
  188. </el-table-column>
  189. <el-table-column
  190. label="操作"
  191. align="center"
  192. fixed="right"
  193. width="180"
  194. >
  195. <template #default="scope">
  196. <div class="operations-container">
  197. <el-tooltip
  198. class="item"
  199. effect="dark"
  200. content="预览"
  201. placement="top"
  202. >
  203. <el-button
  204. type="text"
  205. size="small"
  206. circle
  207. icon="el-icon-view"
  208. v-if="checkAuth('/document/update')"
  209. style="font-size: 15px"
  210. @click="getName(scope.row)"
  211. ></el-button>
  212. </el-tooltip>
  213. <el-tooltip
  214. class="item"
  215. effect="dark"
  216. content="修改文件名"
  217. placement="top"
  218. >
  219. <el-button
  220. type="text"
  221. size="small"
  222. circle
  223. icon="el-icon-edit"
  224. v-if="checkAuth('/document/update')"
  225. style="font-size: 15px"
  226. @click="btnEdit(scope.row)"
  227. ></el-button>
  228. </el-tooltip>
  229. <el-popover
  230. placement="bottom"
  231. trigger="click"
  232. popper-class="operations-popover"
  233. >
  234. <template #reference>
  235. <el-button
  236. type="text"
  237. size="small"
  238. circle
  239. class="operation-button"
  240. style="font-size: 15px; margin-left: 10px"
  241. icon="el-icon-more"
  242. ></el-button>
  243. </template>
  244. <div class="additional-operations">
  245. <el-tooltip
  246. class="item"
  247. effect="dark"
  248. :content="
  249. scope.row.run == 1 || scope.row.run == 5
  250. ? `解析中`
  251. : '解析'
  252. "
  253. placement="top"
  254. >
  255. <el-button
  256. v-if="scope.row.run != 1 && scope.row.run != 5"
  257. type="text"
  258. icon="el-icon-caret-right"
  259. circle
  260. @click="analysis(scope.row)"
  261. style="font-size: 15px"
  262. >
  263. </el-button>
  264. <el-button
  265. v-else
  266. type="text"
  267. icon="el-icon-loading"
  268. circle
  269. :disabled="true"
  270. style="font-size: 15px"
  271. >
  272. </el-button>
  273. </el-tooltip>
  274. <el-tooltip
  275. class="item"
  276. effect="dark"
  277. content="解析方法"
  278. placement="top"
  279. >
  280. <el-button
  281. type="text"
  282. size="small"
  283. circle
  284. icon="el-icon-tickets"
  285. v-if="checkAuth('/document/update')"
  286. style="font-size: 15px"
  287. @click="Analytical(scope.row)"
  288. ></el-button>
  289. </el-tooltip>
  290. <el-tooltip
  291. class="item"
  292. effect="dark"
  293. content="下载"
  294. placement="top"
  295. >
  296. <el-button
  297. type="text"
  298. size="small"
  299. circle
  300. icon="el-icon-download"
  301. @click="btnDown(scope.row)"
  302. :loading="scope.row.downloading"
  303. style="font-size: 15px"
  304. ></el-button>
  305. </el-tooltip>
  306. <el-tooltip
  307. class="item"
  308. effect="dark"
  309. content="删除"
  310. placement="top"
  311. >
  312. <el-button
  313. type="text"
  314. size="small"
  315. circle
  316. icon="el-icon-delete"
  317. v-if="checkAuth('/document/delete')"
  318. @click="btnDelete(scope.row.id)"
  319. style="font-size: 15px"
  320. ></el-button>
  321. </el-tooltip>
  322. </div>
  323. </el-popover>
  324. </div>
  325. </template>
  326. </el-table-column>
  327. </el-table>
  328. <div class="page-info">
  329. <el-pagination
  330. :currentPage="queryForm.page"
  331. :page-size="queryForm.pageSize"
  332. :total="recordCount"
  333. :page-count="pageTotal"
  334. :page-sizes="[10, 20, 50, 100]"
  335. background
  336. layout="total,sizes, prev, pager, next"
  337. @current-change="ChangePage"
  338. @size-change="handleSizeChange"
  339. >
  340. </el-pagination>
  341. </div>
  342. <el-dialog
  343. title="修改名称"
  344. :visible.sync="dialogVisible"
  345. width="30%"
  346. :before-close="handleClose"
  347. >
  348. <el-form :model="wordForm" ref="wordRef" :rules="wordRules">
  349. <el-form-item label="文件名称:" prop="new_name">
  350. <el-input
  351. v-model="wordForm.new_name"
  352. placeholder="请输入文件名称"
  353. ></el-input>
  354. </el-form-item>
  355. </el-form>
  356. <span slot="footer" class="dialog-footer">
  357. <el-button @click="handleClose">取 消</el-button>
  358. <el-button type="primary" @click="submitBuck">确 定</el-button>
  359. </span>
  360. </el-dialog>
  361. <!-- 解析方法 -->
  362. <el-dialog
  363. title="解析方法"
  364. :visible.sync="anaDialogVisible"
  365. width="30%"
  366. :before-close="handleAnalClose"
  367. >
  368. <el-form
  369. :model="analForm"
  370. ref="analRef"
  371. label-position="top"
  372. :rules="analRules"
  373. >
  374. <el-form-item label="语言选择:" prop="language">
  375. <el-radio-group v-model="analForm.language">
  376. <el-radio label="zh">中文</el-radio>
  377. <el-radio label="en">英文</el-radio>
  378. </el-radio-group>
  379. </el-form-item>
  380. <el-form-item label="页码范围:" prop="new_name">
  381. <el-input-number
  382. v-model="analForm.start_page"
  383. controls-position="right"
  384. :min="1"
  385. ></el-input-number>
  386. <el-input-number
  387. v-model="analForm.end_page"
  388. controls-position="right"
  389. :min="1"
  390. style="margin-left: 10px"
  391. ></el-input-number>
  392. </el-form-item>
  393. <el-form-item label="块token数">
  394. <div class="block">
  395. <el-slider v-model="analForm.token_num" :max="2048" show-input>
  396. </el-slider>
  397. </div>
  398. </el-form-item>
  399. </el-form>
  400. <span slot="footer" class="dialog-footer">
  401. <el-button type="primary" @click="handleAnalClose">取 消</el-button>
  402. <el-button type="primary" @click="submitAnal">确 定</el-button>
  403. </span>
  404. </el-dialog>
  405. <el-dialog
  406. title="新建目录"
  407. :visible.sync="newFolderDialogVisible"
  408. width="30%"
  409. >
  410. <el-form
  411. :model="newFolderForm"
  412. :rules="newFolderRules"
  413. ref="newFolderFormRef"
  414. >
  415. <el-form-item label="文件夹名称" prop="name">
  416. <el-input v-model="newFolderForm.name"></el-input>
  417. </el-form-item>
  418. </el-form>
  419. <span slot="footer" class="dialog-footer">
  420. <el-button type="primary" @click="newFolderDialogVisible = false"
  421. >取 消</el-button
  422. >
  423. <el-button type="primary" @click="submitNewFolder">确 定</el-button>
  424. </span>
  425. </el-dialog>
  426. <!-- 批量修改目录 -->
  427. <el-dialog
  428. title="批量修改目录"
  429. :visible.sync="batchModifyFolderDialogVisible"
  430. width="30%"
  431. >
  432. <el-form
  433. :model="batchModifyFolderForm"
  434. :rules="batchModifyFolderRules"
  435. ref="batchModifyFolderFormRef"
  436. >
  437. <el-form-item label="选择目录" prop="folderId">
  438. <el-select
  439. v-model="batchModifyFolderForm.folderId"
  440. placeholder="请选择目录"
  441. >
  442. <el-option
  443. v-for="folder in folders.filter((f) => f.id !== 0)"
  444. :key="folder.id"
  445. :label="folder.name"
  446. :value="folder.id"
  447. >
  448. </el-option>
  449. </el-select>
  450. </el-form-item>
  451. </el-form>
  452. <span slot="footer" class="dialog-footer">
  453. <el-button
  454. type="primary"
  455. @click="batchModifyFolderDialogVisible = false"
  456. >取 消</el-button
  457. >
  458. <el-button type="primary" @click="submitBatchModifyFolder"
  459. >确 定</el-button
  460. >
  461. </span>
  462. </el-dialog>
  463. </div>
  464. </div>
  465. </div>
  466. </template>
  467. <script>
  468. import { mapGetters } from "vuex";
  469. import { dataSearch, dataList } from "./components";
  470. import {
  471. getBucketContents,
  472. deleteFile,
  473. nameGetUrl,
  474. renameFile,
  475. analysis,
  476. batchAnalysis,
  477. getRunStatus,
  478. insertType,
  479. updateType,
  480. selectTypeList,
  481. deleteType,
  482. Info,
  483. batchMove,
  484. selectType0,
  485. delDocumentList,
  486. getdocpro,
  487. analysisPro,
  488. resultTask,
  489. endClear,
  490. } from "@/api/knowledge";
  491. export default {
  492. components: {
  493. dataSearch,
  494. dataList,
  495. },
  496. computed: {
  497. ...mapGetters(["roleInfo", "authList"]),
  498. },
  499. data() {
  500. return {
  501. queryForm: {
  502. page: 1,
  503. pageSize: 10,
  504. bucket_id: "",
  505. doc_type_id: 0,
  506. },
  507. typeForm: {
  508. page: 1,
  509. pageSize: 9999,
  510. kb_id: "",
  511. },
  512. folders: [{ id: "001", name: "全部", document_count: 0 }],
  513. defaultProps: {
  514. children: "children",
  515. label: "name",
  516. },
  517. // dataList 组件的数据
  518. loading: false,
  519. dialogVisible: false,
  520. currentDataId: 0,
  521. recordCount: 0,
  522. pageTotal: 1,
  523. dataList: [],
  524. currentData: {},
  525. wordForm: {
  526. document_id: "",
  527. new_name: "",
  528. },
  529. wordRules: {
  530. new_name: [
  531. { required: true, message: "请输文件名称", trigger: "blur" },
  532. ],
  533. },
  534. anaDialogVisible: false,
  535. analForm: {
  536. start_page: 1,
  537. end_page: 10000,
  538. token_num: 0,
  539. language:'zh'
  540. },
  541. analRules: {},
  542. selectedRows: [],
  543. sortColumn: "",
  544. sortOrder: "",
  545. analysisStatusCheckers: {},
  546. newFolderDialogVisible: false,
  547. newFolderForm: {
  548. name: "",
  549. kb_id: "",
  550. status: 5,
  551. },
  552. newFolderRules: {
  553. name: [
  554. { required: true, message: "请输入文件夹名称", trigger: "blur" },
  555. ],
  556. },
  557. /* 批量修改目录 */
  558. batchModifyFolderDialogVisible: false,
  559. batchModifyFolderForm: {
  560. folderId: null,
  561. },
  562. batchModifyFolderRules: {
  563. folderId: [
  564. { required: true, message: "请选择目标目录", trigger: "change" },
  565. ],
  566. },
  567. selectedRows: [], // 已选择的行
  568. allSelectedRows: new Map(), // 存储所有选中的行
  569. isAllDataSelected: false, // 是否选中所有数据
  570. };
  571. },
  572. mounted() {
  573. this.queryForm.bucket_id = this.$route.query.id;
  574. this.typeForm.kb_id = this.$route.query.id;
  575. /* this.$nextTick(() => {
  576. this.initializeTree();
  577. }); */
  578. this.typeList();
  579. /* this.search(); */
  580. },
  581. beforeDestroy() {
  582. Object.values(this.analysisStatusCheckers).forEach(clearTimeout);
  583. },
  584. methods: {
  585. // 获取行的唯一标识
  586. getRowKey(row) {
  587. return row.id;
  588. },
  589. /* 功按钮 */
  590. handleBatchCommand(command) {
  591. switch (command) {
  592. case "analysis":
  593. this.batchAnalysis();
  594. break;
  595. case "modifyFolder":
  596. this.batchModifyFolder();
  597. break;
  598. case "delete":
  599. this.batchDelect();
  600. break;
  601. }
  602. },
  603. getProgressStatus(progress) {
  604. // el-progress 只接受 'success'/'exception'/'warning' 这几个值
  605. if (progress >= 100) {
  606. return "success";
  607. }
  608. // 如果进度小于100,返回undefined,使用默认样式
  609. return undefined;
  610. },
  611. /* 操作栏 */
  612. handleCommand(command, row) {
  613. switch (command) {
  614. case "analysis":
  615. this.analysis(row);
  616. break;
  617. case "analyticalMethod":
  618. this.Analytical(row);
  619. break;
  620. case "download":
  621. this.btnDown(row);
  622. break;
  623. case "delete":
  624. this.btnDelete(row.id);
  625. break;
  626. }
  627. },
  628. /* 状态展示 */
  629. getStatusType(status) {
  630. const statusMap = {
  631. 0: "info", // 未解析
  632. 1: "warning", // 解析中
  633. 3: "success", // 成功
  634. 4: "danger", // 失败
  635. 5: "info", // 待解析
  636. 6: "danger", // 文件异常
  637. };
  638. return statusMap[status] || "info";
  639. },
  640. getStatusText(status) {
  641. const statusMap = {
  642. 0: "未解析",
  643. 1: "解析中",
  644. 3: "解析成功",
  645. 4: "解析失败",
  646. 5: "待解析",
  647. 6: "文件异常",
  648. };
  649. return statusMap[status] || "未知状态";
  650. },
  651. /* 判断类名 */
  652. getFileCountClass(id) {
  653. const isSpecialFolder = id === 0 || id === "001";
  654. console.log(
  655. `ID: ${id}, Class: ${isSpecialFolder ? "file-counts" : "file-count"}`
  656. );
  657. return isSpecialFolder ? "file-counts" : "file-count";
  658. },
  659. /* 批量修改目录 */
  660. batchModifyFolder() {
  661. if (this.selectedRows.length === 0) {
  662. this.$message.warning("请选择要修改目录的文件");
  663. return;
  664. }
  665. this.batchModifyFolderDialogVisible = true;
  666. },
  667. submitBatchModifyFolder() {
  668. this.$refs.batchModifyFolderFormRef.validate((valid) => {
  669. if (valid) {
  670. const selectedIds = this.selectedRows.map((row) => row.id);
  671. console.log(selectedIds);
  672. batchMove({
  673. ids: JSON.stringify(selectedIds),
  674. doc_type_id: this.batchModifyFolderForm.folderId,
  675. })
  676. .then((res) => {
  677. if (res.status === 200) {
  678. this.$message.success("批量修改目录成功");
  679. this.batchModifyFolderDialogVisible = false;
  680. this.search(); // Refresh the document list
  681. this.typeList(); // Refresh the folder list
  682. this.clearSelection();
  683. } else {
  684. this.$message.error("批量修改目录失败");
  685. }
  686. })
  687. .catch((error) => {
  688. console.error("批量修改目录时出错:", error);
  689. this.$message.error("批量修改目录时出错");
  690. });
  691. }
  692. });
  693. },
  694. editFolder(folder) {
  695. this.$prompt("请输入新的文件夹名称", "编辑文件夹", {
  696. confirmButtonText: "确定",
  697. cancelButtonText: "取消",
  698. inputValue: folder.name,
  699. inputValidator: (value) => {
  700. if (!value) {
  701. return "文件夹名称不能为空";
  702. }
  703. return true;
  704. },
  705. })
  706. .then(({ value }) => {
  707. if (value !== folder.name) {
  708. const updatedFolder = { ...folder, name: value };
  709. updateType(updatedFolder)
  710. .then((res) => {
  711. if (res.status === 200) {
  712. this.$message.success("更新文件夹成功");
  713. this.typeList(); // 刷新文件夹列表
  714. } else {
  715. this.$message.error("更新文件夹失败");
  716. }
  717. })
  718. .catch((error) => {
  719. console.error("更新文件夹时出错:", error);
  720. this.$message.error("更新文件夹时出错");
  721. });
  722. }
  723. })
  724. .catch(() => {
  725. // 用户取消操作,不做任何处理
  726. });
  727. },
  728. deleteFolder(folderId) {
  729. this.$confirm("确定要删除该文件夹吗?删除后无法恢复。", "警告", {
  730. confirmButtonText: "确定",
  731. cancelButtonText: "取消",
  732. type: "warning",
  733. })
  734. .then(() => {
  735. deleteType({ id: folderId })
  736. .then((res) => {
  737. if (res.status === 200) {
  738. this.$message.success("删除文件夹成功");
  739. this.typeList(); // 刷新文件夹列表
  740. } else {
  741. this.$message.error("删除文件夹失败");
  742. }
  743. })
  744. .catch((error) => {
  745. console.error("删除文件夹时出错:", error);
  746. this.$message.error("删除文件夹时出错");
  747. });
  748. })
  749. .catch(() => {
  750. // 用户取消删除操作,不做任何处理
  751. });
  752. },
  753. /* 目录初始化 */
  754. typeList() {
  755. this.loading = true;
  756. Promise.all([
  757. selectTypeList(this.typeForm),
  758. selectType0({ kb_id: this.typeForm.kb_id, type_id: 0 }),
  759. ])
  760. .then(([typeListRes, type0Res]) => {
  761. if (typeListRes.status === 200 && type0Res.status === 200) {
  762. const folderList = typeListRes.data.dataList.map((folder) => ({
  763. ...folder,
  764. id: folder.id === 0 ? "001" : folder.id.toString(),
  765. document_count: folder.document_count || 0,
  766. }));
  767. // Calculate total documents
  768. const totalDocuments = folderList.reduce(
  769. (sum, folder) => sum + folder.document_count,
  770. 0
  771. );
  772. // Get the count of "其他" documents from selectType0 response
  773. const otherFolderCount = type0Res.data || 0;
  774. this.folders = [
  775. {
  776. id: "001",
  777. name: "全部",
  778. document_count: totalDocuments + otherFolderCount,
  779. },
  780. ...folderList.filter(
  781. (folder) => folder.id !== "001" && folder.id !== 0
  782. ),
  783. {
  784. id: 0,
  785. name: "其他",
  786. document_count: otherFolderCount,
  787. },
  788. ];
  789. // 直接在这里执行一次性的初始化
  790. this.$nextTick(() => {
  791. if (this.$refs.folderTree) {
  792. this.$refs.folderTree.setCurrentKey("001");
  793. // 只在这里调用一次 search
  794. this.queryForm.doc_type_id = "";
  795. this.search();
  796. }
  797. });
  798. } else {
  799. this.$message.error("获取文件夹列表败");
  800. }
  801. })
  802. .catch((error) => {
  803. console.error("获取文件夹列表时出错:", error);
  804. this.$message.error("获取文件夹列表时出错");
  805. })
  806. .finally(() => {
  807. this.loading = false;
  808. });
  809. },
  810. /* initializeTree() {
  811. this.$nextTick(() => {
  812. if (this.$refs.folderTree) {
  813. this.$refs.folderTree.setCurrentKey(0);
  814. this.handleNodeClick(this.folders[0]);
  815. }
  816. });
  817. }, */
  818. createNewFolder() {
  819. this.newFolderDialogVisible = true;
  820. },
  821. /* 新增 */
  822. submitNewFolder() {
  823. this.$refs.newFolderFormRef.validate((valid) => {
  824. if (valid) {
  825. this.newFolderForm.kb_id = this.$route.query.id;
  826. insertType(this.newFolderForm).then((res) => {
  827. if (res.status === 200) {
  828. this.$message.success("创建文件夹成功");
  829. this.newFolderDialogVisible = false;
  830. this.$refs.newFolderFormRef.resetFields();
  831. this.typeList(); // Refresh folder list
  832. } else {
  833. this.$message.error("创建文件夹失败");
  834. }
  835. });
  836. }
  837. });
  838. },
  839. // 移除或简化 initializeTree 方法,因为相关逻辑已经到 typeList 中
  840. initializeTree() {
  841. // 可以保留这个方法但不执行 search
  842. this.$nextTick(() => {
  843. if (this.$refs.folderTree) {
  844. this.$refs.folderTree.setCurrentKey("001");
  845. }
  846. });
  847. },
  848. /* initializeTree() {
  849. this.$nextTick(() => {
  850. if (this.$refs.folderTree) {
  851. this.$refs.folderTree.setCurrentKey("001");
  852. this.handleNodeClick(this.folders[0]);
  853. }
  854. });
  855. }, */
  856. checkAuth(path) {
  857. if (this.roleInfo.is_admin === 1) {
  858. return true;
  859. }
  860. return this.authList.some(
  861. (auth) => auth.type === 999 && auth.path === path
  862. );
  863. },
  864. setQuery(e) {
  865. this.queryForm = { ...this.queryForm, ...e };
  866. this.search();
  867. },
  868. handleNodeClick(data) {
  869. this.queryForm.doc_type_id = data.id === "001" ? "" : data.id;
  870. this.queryForm.page = 1; // Reset to first page when changing folder
  871. this.search();
  872. },
  873. /*列表事件 */
  874. /* 排序 */
  875. handleSortChange({ prop, order }) {
  876. this.sortColumn = prop;
  877. this.sortOrder = order;
  878. this.sortData();
  879. },
  880. sortData() {
  881. const { sortColumn, sortOrder } = this;
  882. if (!sortColumn || !sortOrder) {
  883. this.search(); // Reset to original order
  884. return;
  885. }
  886. this.dataList.sort((a, b) => {
  887. let comparison = 0;
  888. if (sortColumn === "name") {
  889. comparison = a.name.localeCompare(b.name, "zh-CN");
  890. } else if (sortColumn === "create_time") {
  891. comparison = new Date(a.create_time) - new Date(b.create_time);
  892. }
  893. return sortOrder === "ascending" ? comparison : -comparison;
  894. });
  895. },
  896. /* 处理选择变化*/
  897. handleSelectionChange(selection) {
  898. if (!this.isAllDataSelected) {
  899. // 更新当前页选中状态
  900. this.dataList.forEach((row) => {
  901. if (selection.find((item) => item.id === row.id)) {
  902. this.allSelectedRows.set(row.id, row);
  903. } else {
  904. this.allSelectedRows.delete(row.id);
  905. }
  906. });
  907. this.selectedRows = Array.from(this.allSelectedRows.values());
  908. }
  909. },
  910. // 选择全部数据
  911. async handleSelectAllData() {
  912. try {
  913. // 构建查询参数,获取所有数据
  914. const params = {
  915. ...this.queryForm,
  916. page: 1,
  917. page_size: this.recordCount,
  918. };
  919. const response = await getBucketContents(params);
  920. if (response.status === 200) {
  921. const allData = response.data.documents;
  922. // 清空之前的选择
  923. this.allSelectedRows.clear();
  924. // 将所有数据添加到选中集合
  925. allData.forEach((item) => {
  926. this.allSelectedRows.set(item.id, item);
  927. });
  928. this.isAllDataSelected = true;
  929. this.selectedRows = allData;
  930. // 选中当前页显示的所有行
  931. this.$nextTick(() => {
  932. if (this.$refs.dataTable) {
  933. this.dataList.forEach((row) => {
  934. this.$refs.dataTable.toggleRowSelection(row, true);
  935. });
  936. }
  937. });
  938. this.$message.success(`已选中全部${this.recordCount}条数据`);
  939. }
  940. } catch (error) {
  941. console.error("获取全部数据失败:", error);
  942. this.$message.error("选择全部数据失败");
  943. }
  944. },
  945. // 取消全选
  946. handleCancelAllSelection() {
  947. this.clearSelection();
  948. this.isAllDataSelected = false;
  949. this.$message.info("已取消全部选择");
  950. },
  951. // 修改清除选择方法
  952. clearSelection() {
  953. if (this.$refs.dataTable) {
  954. this.$refs.dataTable.clearSelection();
  955. }
  956. this.selectedRows = [];
  957. this.allSelectedRows.clear();
  958. this.isAllDataSelected = false;
  959. },
  960. // 修改分页方法,保持选中状态
  961. ChangePage(e) {
  962. this.queryForm.page = e;
  963. this.search().then(() => {
  964. this.$nextTick(() => {
  965. if (this.$refs.dataTable) {
  966. this.dataList.forEach((row) => {
  967. if (this.isAllDataSelected || this.allSelectedRows.has(row.id)) {
  968. this.$refs.dataTable.toggleRowSelection(row, true);
  969. }
  970. });
  971. }
  972. });
  973. });
  974. },
  975. batchAnalysis() {
  976. const selectedIds = this.selectedRows.map((row) => row.id);
  977. if (selectedIds.length === 0) {
  978. this.$message.warning("请选择要解析的文件");
  979. return;
  980. }
  981. this.$confirm("确定要批量解析选中的文件吗?", "提示", {
  982. confirmButtonText: "确定",
  983. cancelButtonText: "取消",
  984. type: "warning",
  985. })
  986. .then(() => {
  987. this.loading = true;
  988. analysisPro({
  989. document_ids: JSON.stringify(selectedIds),
  990. ocr_params: {
  991. language: this.analForm.language,
  992. max_retries: 3,
  993. timeout: [10, 180],
  994. },
  995. }) /* { ids: JSON.stringify(selectedIds) } */
  996. .then((res) => {
  997. if (res.status === 200) {
  998. this.$message.success("批量解析任务已提交");
  999. this.updateAnalysisStatus(selectedIds);
  1000. this.clearSelection();
  1001. } else {
  1002. this.$message.error("批量解析请求失败");
  1003. }
  1004. })
  1005. .catch((error) => {
  1006. console.error("批量解析错误:", error);
  1007. this.$message.error("批量解析过程中出错误");
  1008. })
  1009. .finally(() => {
  1010. this.loading = false;
  1011. });
  1012. })
  1013. .catch(() => {
  1014. // 取消操作
  1015. });
  1016. },
  1017. /* 批量删除 */
  1018. batchDelect() {
  1019. const selectedIds = this.selectedRows.map((row) => row.id);
  1020. if (selectedIds.length === 0) {
  1021. this.$message.warning("请选择要删除的文件");
  1022. return;
  1023. }
  1024. this.$confirm("确定要批量删除选中的文件吗?", "提示", {
  1025. confirmButtonText: "确定",
  1026. cancelButtonText: "取消",
  1027. type: "warning",
  1028. })
  1029. .then(() => {
  1030. this.loading = true;
  1031. delDocumentList({ document_ids: JSON.stringify(selectedIds) })
  1032. .then((res) => {
  1033. if (res.status === 200) {
  1034. this.$message.success("批量删除已完成");
  1035. this.search();
  1036. } else {
  1037. this.$message.error("批量删除请求失败");
  1038. }
  1039. })
  1040. .catch((error) => {
  1041. /* console.error("批量删除错误:", error);
  1042. this.$message.error("批量删除过程中出现错误"); */
  1043. })
  1044. .finally(() => {
  1045. this.loading = false;
  1046. });
  1047. })
  1048. .catch(() => {
  1049. // 取消操作
  1050. });
  1051. },
  1052. updateAnalysisStatus(ids) {
  1053. this.dataList.forEach((row) => {
  1054. if (ids.includes(row.id)) {
  1055. row.run = 1; // 设置状态为"解析中"
  1056. this.startAnalysisStatusChecker(row);
  1057. }
  1058. });
  1059. },
  1060. clearSelection() {
  1061. this.$refs.dataTable.clearSelection();
  1062. this.selectedRows = [];
  1063. },
  1064. /* 跳转页面 */
  1065. getName(e) {
  1066. /* this.$router.push({
  1067. path: "/knowledge/category/infoList",
  1068. query: { id: e.id, type: e.type },
  1069. }); */
  1070. let _this = this;
  1071. let a = document.createElement("a");
  1072. a.href = `#/infoList?id=${e.id}&type=${e.type.toLowerCase()}`; // 使用 hash
  1073. a.target = "_blank";
  1074. a.click();
  1075. },
  1076. /*终止 */
  1077. endAnalysis() {
  1078. endClear().then((res) => {
  1079. if (res.status !== 200) return;
  1080. this.search();
  1081. });
  1082. },
  1083. /* 解析 */
  1084. analysis(row) {
  1085. if (row.run == 1 || row.run == 5) return;
  1086. // Set the status to "解析中" (1) immediately
  1087. this.$set(row, "run", 1);
  1088. const analysisConfig = {
  1089. document_ids: JSON.stringify([row.id]),
  1090. start_page: row.start_page ?? 0, // 使用空值合并运算符
  1091. end_page: row.end_page ?? 1000, // 使用空值合并运算符
  1092. max_tokens: row.token_num,
  1093. ocr_params: {
  1094. language: this.analForm.language, //en,zh
  1095. max_retries: 3,
  1096. timeout: [10, 180],
  1097. },
  1098. };
  1099. analysisPro(analysisConfig)
  1100. .then((res) => {
  1101. if (res.status === 200) {
  1102. // Start checking the status immediately after successful API call
  1103. setTimeout(() => {
  1104. this.startAnalysisStatusChecker(row);
  1105. });
  1106. } else {
  1107. this.$message.error("解析请求失败");
  1108. this.$set(row, "run", 0);
  1109. }
  1110. })
  1111. .catch((error) => {
  1112. console.error("解析错误:", error);
  1113. this.$message.error("解析过程中出现错误");
  1114. this.$set(row, "run", 0);
  1115. });
  1116. },
  1117. startAnalysisStatusChecker(row) {
  1118. // Clear any existing checker for this row
  1119. if (this.analysisStatusCheckers[row.id]) {
  1120. clearTimeout(this.analysisStatusCheckers[row.id]);
  1121. }
  1122. /* 获取token数 */
  1123. /* const checkStatus = () => {
  1124. getdocpro({ document_id: row.id })
  1125. .then((res) => {
  1126. if (res.status === 200) {
  1127. const newStatus = Number(res.data.status);
  1128. const newProgress = Number(res.data.total_tasks);
  1129. this.$set(row, "run", newStatus);
  1130. this.$set(row, "progress", newProgress);
  1131. if (newStatus === 3) {
  1132. this.$message.success("解析成功");
  1133. delete this.analysisStatusCheckers[row.id];
  1134. // 在这里添加刷新列表的逻辑
  1135. this.refreshCurrentList();
  1136. } else if (newStatus === 4) {
  1137. this.$message.error("解析失败");
  1138. delete this.analysisStatusCheckers[row.id];
  1139. } else if (newStatus === 1 || newStatus === 5) {
  1140. // Continue checking
  1141. this.analysisStatusCheckers[row.id] = setTimeout(
  1142. checkStatus,
  1143. 15000
  1144. );
  1145. }
  1146. } else {
  1147. this.$message.error("获取解析状态失败");
  1148. delete this.analysisStatusCheckers[row.id];
  1149. }
  1150. })
  1151. .catch((error) => {
  1152. console.error("获取解析状态错误:", error);
  1153. this.$message.error("获取解析状态时出现错误");
  1154. delete this.analysisStatusCheckers[row.id];
  1155. });
  1156. }; */
  1157. /* 监控任务 */
  1158. const checkStatus = () => {
  1159. resultTask(row.id)
  1160. .then((res) => {
  1161. if (res.status === 200) {
  1162. const newStatus = Number(res.data.document_status);
  1163. const newProgress = Number(res.data.progress);
  1164. const newProgressMsg = res.data.progress_msg;
  1165. this.$set(row, "run", newStatus);
  1166. this.$set(row, "progress", newProgress);
  1167. this.$set(row, "progress_msg", newProgressMsg);
  1168. if (newStatus === 3) {
  1169. this.$message.success("解析成功");
  1170. delete this.analysisStatusCheckers[row.id];
  1171. // 在这里添加刷新列表的逻辑
  1172. this.refreshCurrentList();
  1173. } else if (newStatus === 4) {
  1174. this.$message.error("解析失败");
  1175. delete this.analysisStatusCheckers[row.id];
  1176. } else if (newStatus === 1 || newStatus === 5) {
  1177. // Continue checking
  1178. this.analysisStatusCheckers[row.id] = setTimeout(
  1179. checkStatus,
  1180. 15000
  1181. );
  1182. }
  1183. } else {
  1184. this.$message.error("获取解析状态失败");
  1185. delete this.analysisStatusCheckers[row.id];
  1186. }
  1187. })
  1188. .catch((error) => {
  1189. console.error("获取解析状态错误:", error);
  1190. this.$message.error("获取解析状态时出现错误");
  1191. delete this.analysisStatusCheckers[row.id];
  1192. });
  1193. };
  1194. // Start checking immediately
  1195. checkStatus();
  1196. },
  1197. // 修改 refreshCurrentList 方法
  1198. refreshCurrentList() {
  1199. // 保存当前页码和每页显示数量
  1200. const currentPage = this.queryForm.page;
  1201. const currentPageSize = this.queryForm.pageSize;
  1202. // 重新获取数据
  1203. return this.search()
  1204. .then(() => {
  1205. // 恢复之前的页码和每页显示数量
  1206. this.queryForm.page = currentPage;
  1207. this.queryForm.pageSize = currentPageSize;
  1208. })
  1209. .catch((error) => {
  1210. console.error("刷新列表时出错:", error);
  1211. this.$message.error("刷新列表失败,请稍后重试");
  1212. });
  1213. },
  1214. handleAnalClose() {
  1215. this.anaDialogVisible = false;
  1216. },
  1217. /* 确认 */
  1218. submitAnal() {
  1219. this.dataList.map((el) => {
  1220. if (this.analForm.id == el.id) {
  1221. el.language=this.analForm.language
  1222. el.start_page = this.analForm.start_page;
  1223. el.end_page = this.analForm.end_page;
  1224. el.token_num = this.analForm.token_num;
  1225. }
  1226. });
  1227. this.anaDialogVisible = false;
  1228. },
  1229. /* 解析方法 */
  1230. Analytical(e) {
  1231. this.analForm.id = e.id;
  1232. this.analForm.token_num = e.token_num;
  1233. this.anaDialogVisible = true;
  1234. },
  1235. editWidth() {
  1236. if (this.allowDelete && this.allowEdit) {
  1237. return 200;
  1238. }
  1239. if (this.allowDelete || this.allowEdit) {
  1240. return 120;
  1241. }
  1242. return 100;
  1243. },
  1244. onFocusVal(e) {
  1245. let _this = this;
  1246. _this.currentDataId = e.target.dataset.id;
  1247. },
  1248. onChangeVal(e) {
  1249. let _this = this;
  1250. let par = {
  1251. id: _this.currentDataId,
  1252. val: e,
  1253. };
  1254. },
  1255. btnDelete(e) {
  1256. let _this = this;
  1257. let par = {
  1258. document_id: e,
  1259. };
  1260. _this
  1261. .$confirm("您是否确认删除该记录?", "提示", {
  1262. confirmButtonText: "确认",
  1263. cancelButtonText: "取消",
  1264. type: "warning",
  1265. })
  1266. .then((res) => {
  1267. deleteFile(par).then((res) => {
  1268. if (res.status !== 200) return;
  1269. _this.$message.success(res.data);
  1270. _this.search();
  1271. });
  1272. })
  1273. .catch(() => {});
  1274. },
  1275. searchData() {
  1276. let _this = this;
  1277. _this.dialogVisible = false;
  1278. _this.search();
  1279. },
  1280. /* 关闭 */
  1281. handleClose(done) {
  1282. done();
  1283. },
  1284. /* 修改文件名 */
  1285. btnEdit(e) {
  1286. this.wordForm.new_name = e.name;
  1287. this.wordForm.document_id = e.id;
  1288. this.dialogVisible = true;
  1289. },
  1290. /* 提交 */
  1291. submitBuck() {
  1292. this.$refs.wordRef.validate((valid) => {
  1293. if (valid) {
  1294. renameFile(this.wordForm).then((res) => {
  1295. if (res.status !== 200) return;
  1296. this.search();
  1297. this.dialogVisible = false;
  1298. this.wordForm = {
  1299. new_name: "",
  1300. document_id: "",
  1301. };
  1302. });
  1303. } else {
  1304. this.$message.error("请填写文档名称");
  1305. }
  1306. });
  1307. },
  1308. //下载
  1309. btnDown(e) {
  1310. // Set downloading flag for this specific row
  1311. this.$set(e, "downloading", true);
  1312. nameGetUrl({
  1313. document_id: e.id,
  1314. })
  1315. .then((res) => {
  1316. if (res.status !== 200) {
  1317. this.$message.error("获取下载链接失败");
  1318. return;
  1319. }
  1320. return fetch(res.data.url);
  1321. })
  1322. .then((response) => response.blob())
  1323. .then((blob) => {
  1324. const url = window.URL.createObjectURL(blob);
  1325. const link = document.createElement("a");
  1326. link.href = url;
  1327. link.download = e.name;
  1328. document.body.appendChild(link);
  1329. link.click();
  1330. setTimeout(() => {
  1331. document.body.removeChild(link);
  1332. window.URL.revokeObjectURL(url);
  1333. }, 100);
  1334. })
  1335. .catch((error) => {
  1336. console.error("下载出错:", error);
  1337. this.$message.error("下载失败,请稍后重试");
  1338. })
  1339. .finally(() => {
  1340. // Reset downloading flag when done
  1341. this.$set(e, "downloading", false);
  1342. });
  1343. },
  1344. handleClose() {
  1345. let _this = this;
  1346. _this.currentData = {};
  1347. _this.dialogVisible = false;
  1348. },
  1349. //搜索
  1350. search() {
  1351. let _this = this;
  1352. _this.loading = true;
  1353. return new Promise((resolve, reject) => {
  1354. getBucketContents(_this.queryForm)
  1355. .then((res) => {
  1356. if (res.status !== 200) {
  1357. reject(new Error("Invalid response status"));
  1358. return;
  1359. }
  1360. _this.dataList = res.data.documents.map((el) => ({
  1361. ...el,
  1362. token_num: 256,
  1363. start_page: _this.analForm.start_page,
  1364. end_page: _this.analForm.end_page,
  1365. }));
  1366. // 获取失败状态的文档的失败原因
  1367. const failedDocs = _this.dataList.filter(
  1368. (doc) => Number(doc.run) === 4
  1369. );
  1370. if (failedDocs.length > 0) {
  1371. Promise.all(
  1372. failedDocs.map((doc) =>
  1373. resultTask(doc.id)
  1374. .then((res) => {
  1375. if (res.status === 200) {
  1376. // 找到对应的文档并更新其 progress_msg
  1377. const docIndex = _this.dataList.findIndex(
  1378. (item) => item.id === doc.id
  1379. );
  1380. if (docIndex !== -1) {
  1381. _this.$set(
  1382. _this.dataList[docIndex],
  1383. "progress_msg",
  1384. res.data.progress_msg
  1385. );
  1386. }
  1387. }
  1388. })
  1389. .catch((error) => {
  1390. console.error(
  1391. `获取文档 ${doc.id} 的失败原因时出错:`,
  1392. error
  1393. );
  1394. })
  1395. )
  1396. );
  1397. }
  1398. _this.pageTotal = res.data.pagination.total_count;
  1399. _this.recordCount = res.data.pagination.total_count;
  1400. _this.queryForm.pageSize = res.data.pagination.total_size;
  1401. _this.loading = false;
  1402. // Initialize the analysis status for each row
  1403. _this.dataList.forEach((row) => {
  1404. if (row.run == 1 || row.run == 5) {
  1405. _this.startAnalysisStatusChecker(row);
  1406. }
  1407. });
  1408. resolve();
  1409. })
  1410. .catch((error) => {
  1411. _this.loading = false;
  1412. reject(error);
  1413. });
  1414. });
  1415. },
  1416. // 处理每页显示数量变化
  1417. handleSizeChange(val) {
  1418. this.queryForm.pageSize = val;
  1419. this.queryForm.page = 1;
  1420. this.search().then(() => {
  1421. // 恢复选中状态
  1422. this.$nextTick(() => {
  1423. this.dataList.forEach((row) => {
  1424. if (this.pageSelected.has(row.id)) {
  1425. this.$refs.dataTable.toggleRowSelection(row, true);
  1426. }
  1427. });
  1428. });
  1429. });
  1430. },
  1431. // 添加格式化方法
  1432. percentFormat(percentage) {
  1433. return `${percentage}%`;
  1434. },
  1435. },
  1436. };
  1437. </script>
  1438. <style lang="scss" scoped>
  1439. .project-search {
  1440. display: flex;
  1441. height: calc(100vh - 100px); // 假设顶部导航栏高度为60px
  1442. background-color: #f9fafb;
  1443. .custom-tree-node {
  1444. width: 100%;
  1445. display: flex;
  1446. align-items: center;
  1447. justify-content: space-between;
  1448. padding: 8px 0;
  1449. position: relative;
  1450. .el-icon-folder {
  1451. color: #409eff;
  1452. margin-right: 8px;
  1453. }
  1454. .file-count {
  1455. color: #909399;
  1456. font-size: 12px;
  1457. padding: 2px 6px;
  1458. border-radius: 10px;
  1459. transition: opacity 0.3s;
  1460. }
  1461. .file-counts {
  1462. color: #909399;
  1463. font-size: 12px;
  1464. padding: 2px 6px;
  1465. border-radius: 10px;
  1466. transition: opacity 0.3s;
  1467. }
  1468. .folder-actions {
  1469. position: absolute;
  1470. right: 0;
  1471. top: 50%;
  1472. transform: translateY(-50%);
  1473. display: none;
  1474. padding-left: 10px;
  1475. i {
  1476. font-size: 16px;
  1477. margin-left: 8px;
  1478. color: #606266;
  1479. cursor: pointer;
  1480. &:hover {
  1481. color: #409eff;
  1482. }
  1483. }
  1484. }
  1485. &:hover {
  1486. .file-count {
  1487. opacity: 0;
  1488. }
  1489. .folder-actions {
  1490. display: inline-block;
  1491. }
  1492. }
  1493. }
  1494. .el-tree-node__content:hover {
  1495. background-color: #f5f7fa;
  1496. }
  1497. .el-tree-node__content:hover {
  1498. background-color: #f5f7fa;
  1499. }
  1500. .file-categories {
  1501. flex: 0 0 280px;
  1502. padding: 20px;
  1503. background-color: #ffffff;
  1504. box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
  1505. overflow-y: auto;
  1506. .el-button {
  1507. width: 100%;
  1508. margin-bottom: 20px;
  1509. }
  1510. .el-tree {
  1511. background-color: transparent;
  1512. }
  1513. }
  1514. .right {
  1515. flex: 1;
  1516. padding: 20px;
  1517. overflow-y: auto;
  1518. }
  1519. .custom-tree-node {
  1520. font-size: 14px;
  1521. width: 100%;
  1522. display: flex;
  1523. align-items: center;
  1524. justify-content: space-between;
  1525. padding: 8px 0;
  1526. .el-icon-folder {
  1527. color: #409eff;
  1528. margin-right: 8px;
  1529. }
  1530. .file-count {
  1531. color: #909399;
  1532. font-size: 12px;
  1533. background-color: #f0f2f5;
  1534. padding: 2px 6px;
  1535. border-radius: 10px;
  1536. }
  1537. .tree_title {
  1538. display: flex;
  1539. align-items: center;
  1540. width: 140px;
  1541. .folder-name {
  1542. white-space: nowrap;
  1543. overflow: hidden;
  1544. text-overflow: ellipsis;
  1545. max-width: calc(100% - 24px); // 减去图标的宽度
  1546. }
  1547. }
  1548. }
  1549. }
  1550. .el-tree {
  1551. margin-left: 10px;
  1552. }
  1553. ::v-deep .el-tree-node__expand-icon {
  1554. display: none;
  1555. }
  1556. ::v-deep .el-tag {
  1557. display: inline-flex;
  1558. align-items: center;
  1559. justify-content: center;
  1560. height: auto;
  1561. padding: 5px 10px;
  1562. }
  1563. .batch-actions {
  1564. display: flex;
  1565. gap: 10px;
  1566. .el-dropdown {
  1567. /* margin-right: auto; */
  1568. }
  1569. .icons {
  1570. width: 15px;
  1571. height: 15px;
  1572. vertical-align: middle;
  1573. margin-right: 4px;
  1574. }
  1575. }
  1576. ::v-deep .el-dropdown-menu__item {
  1577. display: flex;
  1578. align-items: center;
  1579. padding: 8px 16px;
  1580. .icons {
  1581. width: 14px;
  1582. height: 14px;
  1583. margin-right: 8px;
  1584. }
  1585. }
  1586. @import "./components/dataList.scss";
  1587. .status-wrapper {
  1588. display: inline-flex;
  1589. align-items: center;
  1590. justify-content: center;
  1591. transition: none !important;
  1592. }
  1593. .progress-wrapper {
  1594. display: inline-flex;
  1595. align-items: center;
  1596. justify-content: center;
  1597. padding: 2px;
  1598. transition: none !important;
  1599. ::v-deep .el-progress {
  1600. line-height: 1;
  1601. transition: none !important;
  1602. .el-progress__text {
  1603. font-size: 12px !important;
  1604. color: inherit;
  1605. transition: none !important;
  1606. }
  1607. .el-progress-circle {
  1608. margin: 0;
  1609. transition: none !important;
  1610. }
  1611. // 禁用 SVG 动画
  1612. svg {
  1613. transition: none !important;
  1614. }
  1615. // 禁用进度条路径动画
  1616. .el-progress-circle__track,
  1617. .el-progress-circle__path {
  1618. transition: none !important;
  1619. }
  1620. }
  1621. }
  1622. // 添加选择提示区域样式
  1623. .selection-control {
  1624. margin-bottom: 10px;
  1625. .el-alert {
  1626. padding: 8px 16px;
  1627. }
  1628. }
  1629. </style>