index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. <template>
  2. <div class="container">
  3. <Breadcrumb :items="['dmx.list.index', 'dmx.list.kbm']" />
  4. <div class="main-container">
  5. <div class="lf-container">
  6. <div class="lf-container-top">
  7. <a-input-search
  8. :placeholder="$t('cardList.searchInput.placeholder')"
  9. style="width: 130px;"
  10. />
  11. <addKnow @knowledgeData="knowledgeData"></addKnow>
  12. </div>
  13. <div class="lf-container-down">
  14. <div class="tabs">
  15. <div
  16. class="tab"
  17. v-for="(tab, index) in tabs"
  18. :key="index"
  19. @click="selectTab(index,tab)"
  20. :class="{ 'active': selectedTab === index }"
  21. >
  22. {{ tab.name }}
  23. <a-popover position="bl">
  24. <icon-more :style="{position: 'absolute',top:'10px',right:'20px'}"/>
  25. <template #content>
  26. <a-popconfirm content="确定删除吗?" @ok="deleteKnowledge(tab.id)" type="warning">
  27. <span style="cursor: pointer;color: #0960bd;font-size: 12px"><icon-delete />删除</span>
  28. </a-popconfirm>
  29. </template>
  30. </a-popover>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="rt-container">
  36. <a-tabs default-active-key="1">
  37. <a-tab-pane key="1" :title= "t('dmx.list.DataSet')">
  38. <div class="rt-container-main">
  39. <a-card ref="account" class="general-card" title="" style="padding-top: 20px">
  40. <a-row>
  41. <a-col :flex="1" :span="12">
  42. <a-form
  43. :model="formModel"
  44. :label-col-props="{ span: 6 }"
  45. :wrapper-col-props="{ span: 18 }"
  46. label-align="left"
  47. >
  48. <a-row :gutter="16">
  49. <a-col :span="24" style="margin-bottom: 10px;display: flex;justify-content: right">
  50. <a-input-search
  51. :placeholder="$t('cardList.searchInput.placeholder')"
  52. style="width: 200px;margin-right: 10px"
  53. v-model="keywords"
  54. @change="search"
  55. />
  56. <!--新建-->
  57. <add :kbobj="kbobj" @changeFetchData="changeFetchData"/>
  58. </a-col>
  59. </a-row>
  60. </a-form>
  61. </a-col>
  62. </a-row>
  63. <a-divider style="margin-top: 0" />
  64. <a-row style="margin-bottom: 16px">
  65. <a-col :span="12">
  66. <a-space>
  67. <!-- <a-button type="primary" @click="handleClick">-->
  68. <!-- <template #icon>-->
  69. <!-- <icon-plus />-->
  70. <!-- </template>-->
  71. <!-- {{ $t('searchTable.operation.create') }}-->
  72. <!-- </a-button>-->
  73. <!-- <a-upload action="/">-->
  74. <!-- <template #upload-button>-->
  75. <!-- <a-button>-->
  76. <!-- {{ $t('searchTable.operation.import') }}-->
  77. <!-- </a-button>-->
  78. <!-- </template>-->
  79. <!-- </a-upload>-->
  80. </a-space>
  81. </a-col>
  82. <a-col
  83. :span="12"
  84. style="display: flex; align-items: center; justify-content: end"
  85. >
  86. <!-- <a-button>-->
  87. <!-- <template #icon>-->
  88. <!-- <icon-download />-->
  89. <!-- </template>-->
  90. <!-- {{ $t('searchTable.operation.download') }}-->
  91. <!-- </a-button>-->
  92. <a-tooltip :content="$t('searchTable.actions.refresh')">
  93. <div class="action-icon"
  94. ><icon-refresh size="18"
  95. /></div>
  96. </a-tooltip>
  97. <a-dropdown @select="handleSelectDensity">
  98. <a-tooltip :content="$t('searchTable.actions.density')">
  99. <div class="action-icon"><icon-line-height size="18" /></div>
  100. </a-tooltip>
  101. <template #content>
  102. <a-doption
  103. v-for="item in densityList"
  104. :key="item.value"
  105. :value="item.value"
  106. :class="{ active: item.value === size }"
  107. >
  108. <span>{{ item.name }}</span>
  109. </a-doption>
  110. </template>
  111. </a-dropdown>
  112. <!-- <a-tooltip :content="$t('searchTable.actions.columnSetting')">-->
  113. <!-- <a-popover-->
  114. <!-- trigger="click"-->
  115. <!-- position="bl"-->
  116. <!-- @popup-visible-change="popupVisibleChange"-->
  117. <!-- >-->
  118. <!-- <div class="action-icon"><icon-settings size="18" /></div>-->
  119. <!-- <template #content>-->
  120. <!-- <div id="tableSetting">-->
  121. <!-- <div-->
  122. <!-- v-for="(item, index) in showColumns"-->
  123. <!-- :key="item.dataIndex"-->
  124. <!-- class="setting"-->
  125. <!-- >-->
  126. <!-- <div style="margin-right: 4px; cursor: move">-->
  127. <!-- <icon-drag-arrow />-->
  128. <!-- </div>-->
  129. <!-- <div>-->
  130. <!-- <a-checkbox-->
  131. <!-- v-model="item.checked"-->
  132. <!-- @change="-->
  133. <!-- handleChange($event, item as TableColumnData, index)-->
  134. <!-- "-->
  135. <!-- >-->
  136. <!-- </a-checkbox>-->
  137. <!-- </div>-->
  138. <!-- <div class="title">-->
  139. <!-- {{ item.title === '#' ? '序列号' : item.title }}-->
  140. <!-- </div>-->
  141. <!-- </div>-->
  142. <!-- </div>-->
  143. <!-- </template>-->
  144. <!-- </a-popover>-->
  145. <!-- </a-tooltip>-->
  146. </a-col>
  147. </a-row>
  148. <a-table
  149. row-key="id"
  150. :loading="loading"
  151. :pagination="pagination"
  152. :columns="cloneColumns"
  153. :data="renderData"
  154. :bordered="false"
  155. :size="size"
  156. @page-change="onPageChange"
  157. :scroll="{ y: 580 }"
  158. >
  159. <template #name="{ record }">
  160. <!-- <icon-file style="color: #0960bd;margin-right: 4px;" />-->
  161. <icon-file style="margin-right: 4px;" />
  162. <!-- <span style="color: #0960bd;cursor: pointer" @click="fileClick">-->
  163. <!-- {{record.name}}-->
  164. <!-- </span>-->
  165. {{record.name}}
  166. </template>
  167. <template #create_time="{ record }">
  168. <span>{{parseTime(record.create_time)}}</span>
  169. </template>
  170. <!-- <template #parser_id="{ record }">-->
  171. <!-- <span>{{ parser_ids[record.parser_id]}}</span>-->
  172. <!-- </template>-->
  173. <template #status="{ record }">
  174. <a-switch v-model="record.status" size="small" checked-value="1" unchecked-value="0" @change="handleChangeStatus(record)"/>
  175. </template>
  176. <template #run="{ record }">
  177. <div style="display: flex;align-items: center;">
  178. <div style="width: 100px">
  179. <a-popover title="Title" v-if="record.run == '3'">
  180. <a-tag :loading="record.loading" :color="'blue'" border>{{$t('dmx.list.complete')}}</a-tag>
  181. <template #content>
  182. <p>Here is the text content</p>
  183. </template>
  184. </a-popover>
  185. <a-popover title="Title" v-if="record.run == '1'">
  186. <a-tag :loading="record.loading" :color="'blue'" border>{{$t('dmx.list.complete')}}</a-tag>
  187. <template #content>
  188. <p>Here is the text content</p>
  189. </template>
  190. </a-popover>
  191. <a-popover title="Title" v-if="record.run == '2'">
  192. <a-tag :loading="record.loading" :color="'gold'" border>{{$t('dmx.list.cancel')}}</a-tag>
  193. <template #content>
  194. <p>Here is the text content</p>
  195. </template>
  196. </a-popover>
  197. <a-popover title="Title" v-if="record.run == '0'">
  198. <a-tag :loading="record.loading" :color="'green'" border>{{$t('dmx.list.NotStarted')}}</a-tag>
  199. <template #content>
  200. <p>Here is the text content</p>
  201. </template>
  202. </a-popover>
  203. </div>
  204. <div >
  205. <a-button type="text" size="large" @click="run(record)" :loading="record.loading">
  206. <template #icon>
  207. <icon-sync v-if="record.run == '3'"/>
  208. <icon-sync v-if="record.run == '2'"/>
  209. <icon-sync style="color: green" v-if="record.run == '1'"/>
  210. <icon-play-circle style="color: green" v-if="record.run == '0'"/>
  211. </template>
  212. </a-button>
  213. </div>
  214. </div>
  215. </template>
  216. <template #action="{ record }" >
  217. <tool :kbtenantInfo="kbtenantInfo" :item="record" :kbdetail="kbdetail" />
  218. <edit :item="record" @upTabdateItem="upTabdateItem"/>
  219. <a-popconfirm :content="'确定删除吗'" type="warning" @ok="deleteItem(record)">
  220. <a-button type="text" size="small">
  221. <template #icon>
  222. <icon-delete />
  223. </template>
  224. </a-button>
  225. </a-popconfirm>
  226. <a-button type="text" size="small" @click="onDownloadDocument(record)">
  227. <template #icon>
  228. <icon-download />
  229. </template>
  230. </a-button>
  231. <a-button type="text" size="small" @click="seeload(record)">
  232. <template #icon>
  233. <icon-eye />
  234. </template>
  235. </a-button>
  236. </template>
  237. </a-table>
  238. </a-card>
  239. </div>
  240. </a-tab-pane>
  241. <a-tab-pane key="2" :title="t('dmx.list.test')">
  242. <div class="rt-container-main">
  243. <test ref="testForm"></test>
  244. </div>
  245. </a-tab-pane>
  246. <a-tab-pane key="3" :title="t('dmx.list.disposition')">
  247. <div class="rt-container-main">
  248. <config ref="configForm" :kbtenantInfo="kbtenantInfo" :kbobj="kbobj"></config>
  249. </div>
  250. </a-tab-pane>
  251. </a-tabs>
  252. <!-- <div v-if="detailsShow" class="details">-->
  253. <!-- <div class="details-header">-->
  254. <!-- <div style="display: flex;align-items: center">-->
  255. <!-- <span><icon-arrow-left size="20px" style="cursor: pointer;color: #0960bd;margin: 10px" @click="goBackClick" /></span>-->
  256. <!-- <icon-file style="color: #0960bd;margin-right: 4px;" />-->
  257. <!-- <span style="">123.docx</span>-->
  258. <!-- </div>-->
  259. <!-- <div style="display: flex; align-items: center;">-->
  260. <!-- <a-radio-group v-model="position" type="button" style="margin-right: 10px">-->
  261. <!-- <a-radio value="top">{{'dmx.list.EntireArticle'}}</a-radio>-->
  262. <!-- <a-radio value="right">{{'dmx.list.omit'}}</a-radio>-->
  263. <!-- </a-radio-group>-->
  264. <!-- <a-popover position="bottom">-->
  265. <!-- <a-button type="outline" class="button" style="margin-right: 10px">{{'dmx.list.batch'}} <icon-down style="margin-left: 4px" /></a-button>-->
  266. <!-- <template #content>-->
  267. <!-- <p>Here is the text content</p>-->
  268. <!-- <p>Here is the text content</p>-->
  269. <!-- </template>-->
  270. <!-- </a-popover>-->
  271. <!-- <a-button type="outline" class="button" style="margin-right: 10px">-->
  272. <!-- <template #icon>-->
  273. <!-- <icon-search />-->
  274. <!-- </template>-->
  275. <!-- </a-button>-->
  276. <!-- <a-popover position="bottom">-->
  277. <!-- <a-button type="outline" class="button" style="margin-right: 10px"><icon-sort /></a-button>-->
  278. <!-- <template #content>-->
  279. <!-- <p>Here is the text content</p>-->
  280. <!-- <p>Here is the text content</p>-->
  281. <!-- </template>-->
  282. <!-- </a-popover>-->
  283. <!-- <addDetails></addDetails>-->
  284. <!-- </div>-->
  285. <!-- </div>-->
  286. <!-- <a-divider style="margin-top: 10px" />-->
  287. <!-- </div>-->
  288. </div>
  289. </div>
  290. <a-modal title=" " v-model:visible="visible" :footer="false" fullscreen>
  291. <!-- <docx v-if="documenttype=='docx'" previewSrc="http://192.168.20.116:1080/v1/document/get/405c3efa4d8c11ef97560242ac120006"></docx>-->
  292. <docx v-if="documenttype=='docx'" :previewSrc="previewSrc"></docx>
  293. <excel v-if="documenttype=='excel'" :previewSrc="previewSrc"></excel>
  294. <txtPdf v-if="documenttype=='txtPdf'" :previewSrc="previewSrc"></txtPdf>
  295. </a-modal>
  296. </div>
  297. </template>
  298. <script lang="ts" setup>
  299. import { computed, ref, reactive, watch, nextTick, onBeforeMount, onMounted } from "vue";
  300. import { useI18n } from 'vue-i18n';
  301. import useLoading from '@/hooks/loading';
  302. import {
  303. queryKbList,
  304. PolicyRecord,
  305. PolicyParams,
  306. queryKbDocumentList,
  307. deleteKnow,
  308. queryKbdetail,
  309. queryKbtenantInfo, kbdocumentrm, kbdocumentchangeparser, kbdocumentrun, kbdocumentchangeStatus,downloadFile
  310. } from "@/api/kbList";
  311. import { Pagination } from '@/types/global';
  312. import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface';
  313. import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
  314. import cloneDeep from 'lodash/cloneDeep';
  315. import Sortable from 'sortablejs';
  316. import add from '@/views/dmx/knowledgeLib/add.vue'
  317. import edit from '@/views/dmx/knowledgeLib/edit.vue'
  318. import addKnow from '@/views/dmx/knowledgeLib/addKnow.vue'
  319. import config from '@/views/dmx/knowledgeLib/config.vue'
  320. import test from '@/views/dmx/knowledgeLib/test.vue'
  321. import tool from '@/views/dmx/knowledgeLib/tool.vue'
  322. import docx from '@/views/dmx/knowledgeLib/components/docx.vue'
  323. import excel from '@/views/dmx/knowledgeLib/components/excel.vue'
  324. import txtPdf from '@/views/dmx/knowledgeLib/components/txtPdf.vue'
  325. import { Message } from "@arco-design/web-vue";
  326. import { parseTime } from "@/utils";
  327. type SizeProps = 'mini' | 'small' | 'medium' | 'large';
  328. type Column = TableColumnData & { checked?: true };
  329. const account = ref(null)
  330. const generateFormModel = () => {
  331. return {
  332. number: '',
  333. name: '',
  334. contentType: '',
  335. filterType: '',
  336. createdTime: [],
  337. status: '',
  338. };
  339. };
  340. const { loading, setLoading } = useLoading(true);
  341. const { t } = useI18n();
  342. const renderData = ref([]);
  343. const formModel = ref(generateFormModel());
  344. const cloneColumns = ref([]);
  345. const showColumns = ref<Column[]>([]);
  346. const size = ref<SizeProps>('medium');
  347. let visible = ref(false)
  348. let keywords = ref('')
  349. let detailsShow = ref(false)
  350. let selectedTab = ref(0)
  351. let testForm = ref(null)
  352. let configForm = ref(null)
  353. let documenttype = ref('docx')
  354. let previewSrc = ref('')
  355. let kbId = ref('')
  356. let kbobj = reactive({})
  357. let kbdetail = reactive({})
  358. let parser_ids = reactive({})
  359. let seeObj = reactive({})
  360. let kbtenantInfo = reactive({
  361. "asr_id": "paraformer-realtime-8k-v1",
  362. "embd_id": "BAAI/bge-large-zh-v1.5",
  363. "img2txt_id": "qwen-vl-max",
  364. "llm_id": "qwen-plus",
  365. "name": "wanghao‘s Kingdom",
  366. "parser_ids": "naive:General,qa:Q&A,resume:Resume,manual:Manual,table:Table,paper:Paper,book:Book,laws:Laws,presentation:Presentation,picture:Picture,one:One",
  367. "rerank_id": "BAAI/bge-reranker-v2-m3",
  368. "role": "owner",
  369. "tenant_id": "948fc6fa41ab11ef8fb80242ac120004",
  370. parser_idObj:{}
  371. })
  372. let tabs = ref([])
  373. const selectTab = (index,item) => {
  374. selectedTab.value= index;
  375. // console.log(item.id);
  376. kbobj= item;
  377. kbId = kbobj.id;
  378. testForm.value.changekbid(kbId);
  379. configForm.value.changekbObj(kbobj);
  380. fetchData({
  381. kb_id: kbobj.id,
  382. page: 1,
  383. page_size: 20
  384. })
  385. }
  386. const basePagination: Pagination = {
  387. current: 1,
  388. pageSize: 20,
  389. };
  390. const pagination = reactive({
  391. ...basePagination,
  392. });
  393. const densityList = computed(() => [
  394. {
  395. name: t('searchTable.size.mini'),
  396. value: 'mini',
  397. },
  398. {
  399. name: t('searchTable.size.small'),
  400. value: 'small',
  401. },
  402. {
  403. name: t('searchTable.size.medium'),
  404. value: 'medium',
  405. },
  406. {
  407. name: t('searchTable.size.large'),
  408. value: 'large',
  409. },
  410. ]);
  411. const columns = computed<TableColumnData[]>(() => [
  412. {
  413. title: t('dmx.column.name'),
  414. dataIndex: 'name',
  415. slotName: 'name',
  416. },
  417. {
  418. title: t('分快数'),
  419. dataIndex: 'chunk_num',
  420. },
  421. {
  422. title: t('dmx.column.UploadTime'),
  423. dataIndex: 'create_time',
  424. slotName: 'create_time',
  425. width:200
  426. },
  427. {
  428. title: t('解析方法'),
  429. dataIndex: 'parser_id',
  430. slotName: 'parser_id',
  431. },
  432. {
  433. title: t('启用'),
  434. dataIndex: 'status',
  435. slotName: 'status',
  436. },
  437. {
  438. title: t('解析状态'),
  439. dataIndex: 'run',
  440. slotName: 'run',
  441. },
  442. {
  443. title: t('dmx.column.Operate'),
  444. dataIndex: 'action',
  445. slotName: 'action',
  446. width: 200,
  447. minWidth: 200,
  448. },
  449. ]);
  450. const contentTypeOptions = computed<SelectOptionData[]>(() => [
  451. {
  452. label: t('searchTable.form.contentType.img'),
  453. value: 'img',
  454. },
  455. {
  456. label: t('searchTable.form.contentType.horizontalVideo'),
  457. value: 'horizontalVideo',
  458. },
  459. {
  460. label: t('searchTable.form.contentType.verticalVideo'),
  461. value: 'verticalVideo',
  462. },
  463. ]);
  464. const filterTypeOptions = computed<SelectOptionData[]>(() => [
  465. {
  466. label: t('searchTable.form.filterType.artificial'),
  467. value: 'artificial',
  468. },
  469. {
  470. label: t('searchTable.form.filterType.rules'),
  471. value: 'rules',
  472. },
  473. ]);
  474. const statusOptions = computed<SelectOptionData[]>(() => [
  475. {
  476. label: t('searchTable.form.status.online'),
  477. value: 'online',
  478. },
  479. {
  480. label: t('searchTable.form.status.offline'),
  481. value: 'offline',
  482. },
  483. ]);
  484. const fetchData = async (params) => {
  485. setLoading(true);
  486. try {
  487. const data = await queryKbDocumentList(params);
  488. console.log(data, 'data');
  489. if(data.code=='0'){
  490. // 详情
  491. // const kbtenantInfo = await queryKbtenantInfo();
  492. parser_ids = kbtenantInfo.parser_ids.split(',').reduce((acc, pair) => {
  493. const [key, value] = pair.split(':');
  494. acc[key] = value;
  495. return acc;
  496. }, {});
  497. // console.log(parser_ids, 'parser_ids');
  498. kbtenantInfo.parser_idObj = parser_ids;
  499. renderData.value = data.data.docs||[];
  500. renderData.value = renderData.value.map((item) => {
  501. return {
  502. ...item,
  503. loading: false,
  504. parser_id: parser_ids[item.parser_id],
  505. };
  506. });
  507. console.log(renderData.value, 'renderData');
  508. pagination.current = params.page;
  509. pagination.total = data.data.total;
  510. // 查询知识库详情
  511. kbdetail = await queryKbdetail({
  512. kb_id:params.kb_id,
  513. });
  514. }
  515. } catch (err) {
  516. // you can report use errorHandler or other
  517. } finally {
  518. setLoading(false);
  519. }
  520. };
  521. const search = () => {
  522. fetchData({
  523. kb_id: kbobj.id,
  524. page: 1,
  525. page_size: 20,
  526. keywords:keywords.value
  527. })
  528. };
  529. const handleClick = ()=>{
  530. visible.value = true;
  531. }
  532. const onPageChange = (current: number) => {
  533. fetchData({ ...basePagination, current });
  534. };
  535. const knowledgeData = async (
  536. params = { page: 1, page_size: 20 }
  537. ) => {
  538. setLoading(true);
  539. try {
  540. const { data } = await queryKbList(params);
  541. console.log(data, 'data');
  542. tabs.value = data;
  543. console.log(tabs.value, 'tabs');
  544. if(tabs.value.length>0 && tabs.value[0]){
  545. kbobj = tabs.value[0]
  546. kbId = kbobj.id;
  547. testForm.value.changekbid(kbId);
  548. configForm.value.changekbObj(kbobj);
  549. fetchData({
  550. kb_id: kbobj.id,
  551. page: 1,
  552. page_size: 20
  553. })
  554. }
  555. // renderData.value = data.list;
  556. // console.log(renderData, 'renderData');
  557. // pagination.current = params.current;
  558. // pagination.total = data.total;
  559. } catch (err) {
  560. // you can report use errorHandler or other
  561. } finally {
  562. setLoading(false);
  563. }
  564. };
  565. const deleteKnowledge = async (id) => {
  566. let data = await deleteKnow({
  567. kb_id:id
  568. })
  569. if(data.code == 0){
  570. Message.success('删除成功');
  571. knowledgeData()
  572. }
  573. }
  574. const reset = () => {
  575. formModel.value = generateFormModel();
  576. };
  577. const handleSelectDensity = (
  578. val: string | number | Record<string, any> | undefined,
  579. e: Event
  580. ) => {
  581. size.value = val as SizeProps;
  582. };
  583. const handleChange = (
  584. checked: boolean | (string | boolean | number)[],
  585. column: Column,
  586. index: number
  587. ) => {
  588. if (!checked) {
  589. cloneColumns.value = showColumns.value.filter(
  590. (item) => item.dataIndex !== column.dataIndex
  591. );
  592. } else {
  593. cloneColumns.value.splice(index, 0, column);
  594. }
  595. };
  596. const exchangeArray = <T extends Array<any>>(
  597. array: T,
  598. beforeIdx: number,
  599. newIdx: number,
  600. isDeep = false
  601. ): T => {
  602. const newArray = isDeep ? cloneDeep(array) : array;
  603. if (beforeIdx > -1 && newIdx > -1) {
  604. // 先替换后面的,然后拿到替换的结果替换前面的
  605. newArray.splice(
  606. beforeIdx,
  607. 1,
  608. newArray.splice(newIdx, 1, newArray[beforeIdx]).pop()
  609. );
  610. }
  611. return newArray;
  612. };
  613. const popupVisibleChange = (val: boolean) => {
  614. if (val) {
  615. nextTick(() => {
  616. const el = document.getElementById('tableSetting') as HTMLElement;
  617. const sortable = new Sortable(el, {
  618. onEnd(e: any) {
  619. const { oldIndex, newIndex } = e;
  620. exchangeArray(cloneColumns.value, oldIndex, newIndex);
  621. exchangeArray(showColumns.value, oldIndex, newIndex);
  622. },
  623. });
  624. });
  625. }
  626. };
  627. const fileClick = ()=>{
  628. detailsShow.value = true
  629. }
  630. const goBackClick = ()=>{
  631. detailsShow.value = false
  632. }
  633. function upTabdateItem(id, newName) {
  634. console.log(id, newName);
  635. const itemToUpdate = renderData.value.find(item => item.id === id);
  636. if (itemToUpdate) {
  637. itemToUpdate.name = newName;
  638. }
  639. }
  640. const deleteItem = async (row)=>{
  641. console.log(row);
  642. let data = await kbdocumentrm({doc_id: row.id})
  643. if(data.code == 0){
  644. Message.success('删除成功');
  645. console.log(kbobj, 'kbobj');
  646. fetchData({
  647. kb_id: kbobj.id,
  648. page: 1,
  649. page_size: 20
  650. })
  651. }
  652. }
  653. const onDownloadDocument = async (record)=>{
  654. console.log(record);
  655. downloadFile({
  656. url: `/api/v1/document/get/${record.id}`,
  657. filename: record.name,
  658. });
  659. }
  660. const seeload = async (row)=>{
  661. Object.assign(seeObj, row)
  662. // console.log(seeObj.name, 'seeObj');
  663. let type = row.name.split('.')[1];
  664. console.log(type);
  665. if(type=='pdf'){
  666. documenttype.value = 'txtPdf'
  667. }else if(type=='docx'){
  668. documenttype.value = 'docx'
  669. }else if(type=='xlsx'){
  670. documenttype.value = 'excel'
  671. }else if(type=='txt'){
  672. documenttype.value = 'txtPdf'
  673. }else {
  674. return false
  675. }
  676. previewSrc.value = `${import.meta.env.VITE_API_BASE_URL}/v1/document/get/${row.id}`
  677. visible.value = true;
  678. }
  679. const handleChangeStatus = async (row)=>{
  680. console.log(row);
  681. let data = await kbdocumentchangeStatus({
  682. doc_id: row.id,
  683. status: row.status
  684. })
  685. if(data.code == 0){
  686. Message.success('操作成功');
  687. }
  688. }
  689. const run = async (row)=>{
  690. console.log(row);
  691. row.loading = true;
  692. let run = '1'
  693. if(row.run!='2'){
  694. run = '1'
  695. }else {
  696. run = '2'
  697. }
  698. let data = await kbdocumentrun({
  699. doc_ids: [row.id],
  700. run: run
  701. })
  702. if(data.code == 0){
  703. Message.success('解析成功');
  704. row.run = '3';
  705. }else{
  706. Message.error('解析失败');
  707. row.run = '1';
  708. }
  709. row.loading = false;
  710. }
  711. const changeFetchData = async (row)=>{
  712. fetchData({
  713. kb_id: kbobj.id,
  714. page: 1,
  715. page_size: 20
  716. })
  717. }
  718. watch(
  719. () => columns.value,
  720. (val) => {
  721. // alert(columns.value)
  722. cloneColumns.value = cloneDeep(val);
  723. cloneColumns.value.forEach((item, index) => {
  724. item.checked = true;
  725. });
  726. showColumns.value = cloneDeep(cloneColumns.value);
  727. },
  728. { deep: true, immediate: true }
  729. );
  730. onBeforeMount(()=>{
  731. })
  732. onMounted(()=>{
  733. knowledgeData()
  734. })
  735. </script>
  736. <script lang="ts">
  737. export default {
  738. name: 'SearchTable',
  739. methods: {
  740. }
  741. };
  742. </script>
  743. <style scoped lang="less">
  744. .container {
  745. padding: 0 20px 20px 20px;
  746. .main-container{
  747. display: flex;
  748. .lf-container{
  749. display: flex;
  750. flex-direction: column;
  751. align-items: center;
  752. justify-content: space-evenly;
  753. background: #ffffff;
  754. width: 200px;
  755. .lf-container-top{
  756. display: flex;
  757. }
  758. .lf-container-down{
  759. display: flex;
  760. flex-direction: column;
  761. width: 90%;
  762. height: calc(100% - 5rem);
  763. border: 1px solid #eeeeee;
  764. overflow: auto;
  765. padding: 10px;
  766. .tabs .tab {
  767. cursor: pointer;
  768. box-sizing: border-box;
  769. margin: 10px 0;
  770. padding:0 10px;
  771. color: rgba(0, 0, 0, 0.88);
  772. font-size: 14px;
  773. height: 40px;
  774. line-height: 40px;
  775. list-style: none;
  776. position: relative;
  777. background: #ffffff;
  778. border: 1px solid #f0f0f0;
  779. border-radius: 8px;
  780. }
  781. .tabs .tab:hover {
  782. border: 1px solid #ffffff;
  783. background: #e8e8ea;
  784. box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
  785. }
  786. .tabs .tab.active {
  787. border: 1px solid #e8e8ea;
  788. background: #e8e8ea;
  789. cursor: pointer;
  790. }
  791. }
  792. }
  793. .rt-container{
  794. position: relative;
  795. //background: #626aea;
  796. margin-left: 20px;
  797. width: calc(100% - 200px);
  798. height: calc(100% - 5rem);
  799. .rt-container-main{
  800. height: 76vh;
  801. }
  802. .details{
  803. position: absolute;
  804. top: 0;
  805. left: 0;
  806. width: 100%;
  807. height: 100%;
  808. background: #ffffff;
  809. .details-header{
  810. display: flex;
  811. justify-content: space-between;
  812. margin-top: 10px;
  813. padding-right: 20px;
  814. }
  815. }
  816. }
  817. }
  818. }
  819. :deep(.arco-table-th) {
  820. &:last-child {
  821. .arco-table-th-item-title {
  822. margin-left: 16px;
  823. }
  824. }
  825. }
  826. .action-icon {
  827. margin-left: 12px;
  828. cursor: pointer;
  829. }
  830. .active {
  831. color: #0960bd;
  832. background-color: #e3f4fc;
  833. }
  834. .setting {
  835. display: flex;
  836. align-items: center;
  837. width: 200px;
  838. .title {
  839. margin-left: 12px;
  840. cursor: pointer;
  841. }
  842. }
  843. </style>