index.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  1. <template>
  2. <div class="view-table-content">
  3. <div style="width: 100%">
  4. <div class="view-dataType-title">
  5. <div class="view-dataType-title-btn">
  6. <el-button type="success" @click="openDialog()">新增抽取任务</el-button>
  7. <el-button type="warning" @click="remove(tableCheckItems)" :disabled="tableCheckItems.length === 0">删除</el-button>
  8. </div>
  9. <div class="view-dataType-title-search">
  10. <el-input placeholder="请输入任务名称" v-model="keyWordData" class="input1">
  11. <el-button slot="append" icon="el-icon-search" @click="searchClick"></el-button>
  12. </el-input>
  13. </div>
  14. </div>
  15. <div class="view-dataType-table">
  16. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequest"></LTable>
  17. </div>
  18. <!-- 添加或修改抽取任务对话框 -->
  19. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
  20. <el-form ref="form" :model="form" label-width="80px" :rules="rules">
  21. <el-form-item label="任务名称" prop="taskName">
  22. <el-input v-model="form.taskName" placeholder="请输入任务名称" />
  23. </el-form-item>
  24. <el-form-item label="选择抽取文件" label-width="110px" prop="ossId">
  25. <el-select v-model="form.ossId" placeholder="请选择文件">
  26. <el-option v-for="item in optionFileList" :key="item.id" :label="item.dataTitle" :value="item.id" />
  27. </el-select>
  28. </el-form-item>
  29. </el-form>
  30. <span slot="footer" class="dialog-footer">
  31. <el-button @click="handleClose">取 消</el-button>
  32. <el-button type="primary" @click="submit">确 定</el-button>
  33. </span>
  34. </el-dialog>
  35. <el-dialog title="详情" :visible.sync="detailDialogVisible" top="10vh" width="90%" :before-close="detailHandleClose">
  36. <div style="width: 80%; margin-left: 10%">
  37. <!-- 分句、抽取、审核、入库 -->
  38. <el-steps :active="active" finish-status="success" process-status="finish">
  39. <!-- 需要判断分句中、抽取中、。。。。 -->
  40. <el-step :title="zeroTitle"></el-step>
  41. <el-step :title="oneTitle"></el-step>
  42. <el-step :title="twoTitle"></el-step>
  43. <el-step :title="threeTitle"></el-step>
  44. </el-steps>
  45. </div>
  46. <div class="view-dataType-table">
  47. <div v-if="active === 0" style="width: 500px; margin: 50px 0px 0px 300px">
  48. <el-form ref="taskFormRef" disabled :model="taskForm" label-width="80px">
  49. <el-form-item label="任务名称" prop="taskName">
  50. <el-input v-model="taskForm.taskName" />
  51. </el-form-item>
  52. <el-form-item label="抽取文件" prop="ossId">
  53. <!-- <el-input v-model="taskForm.ossId" /> -->
  54. <el-select v-model="taskForm.ossId" placeholder="请选择文件">
  55. <el-option v-for="item in optionFileList" :key="item.id" :label="item.dataTitle" :value="item.id" />
  56. </el-select>
  57. </el-form-item>
  58. </el-form>
  59. </div>
  60. <LTable
  61. ref="clauseTableRef"
  62. v-if="active === 1 || active === 2"
  63. @selection-change="clauseSelection"
  64. :defaultFetch="false"
  65. :fetch="clauseFetch"
  66. :showColumnSetting="false"
  67. :columns="clauseColumns"
  68. :dataSource="clauseTableData"
  69. :options="clauseOptions"
  70. :pagination="clauseTableRequest"
  71. ></LTable>
  72. <graphECharts v-if="active === 3" style="margin: 0 auto" :width="1400" :height="500" :graphData="graphData" class="charts"></graphECharts>
  73. <!-- <LTable ref="extractTable" v-if="active === 2" @selection-change="extractSelection" :defaultFetch="false" :fetch="fetch" :columns="extractColumns" :dataSource="extractTableData" :options="extractOptions" :pagination="extractTableRequest"></LTable> -->
  74. </div>
  75. <el-dialog width="50%" title="详情" :visible.sync="clauseDialogVisible" :before-close="clauseHandleClose" append-to-body>
  76. <el-form ref="clauseFormRef" :model="clauseForm" label-width="80px">
  77. <el-form-item label="内容" prop="clause">
  78. <el-input type="textarea" :rows="7" v-model="clauseForm.clause" placeholder="请输入内容" />
  79. </el-form-item>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button @click="clauseDialogVisible = false">取 消</el-button>
  83. <el-button type="primary" @click="clauseSubmit">确 定</el-button>
  84. </div>
  85. </el-dialog>
  86. <el-dialog width="80%" title="抽取详情" :visible.sync="extractDialogVisible" :before-close="extractHandleClose" append-to-body>
  87. <div class="content">
  88. <div class="left">
  89. <p>{{ this.extractData.content }}</p>
  90. </div>
  91. <div class="right">
  92. <LTable
  93. ref="extractDetailTableRef"
  94. :showColumnSetting="false"
  95. :defaultFetch="false"
  96. :fetch="extractDetailFetch"
  97. :columns="extractDetailColumns"
  98. :dataSource="extractData.extractDetailTable"
  99. :pagination="extractDetailRequest"
  100. :options="extractDetailOptions"
  101. ></LTable>
  102. </div>
  103. </div>
  104. <div slot="footer" class="dialog-footer">
  105. <el-button type="success" @click="addER">新增实体关系</el-button>
  106. <el-button @click="handleCancel">作 废</el-button>
  107. <el-button type="primary" @click="passThrough">通 过</el-button>
  108. </div>
  109. </el-dialog>
  110. <span slot="footer" class="dialog-footer">
  111. <!-- <el-button @click="handleClose">取 消</el-button> -->
  112. <el-button type="primary" v-if="active === 0 && zeroTitle !== '分句中'" :loading="clauseLoading" @click="handleClause">分 句</el-button>
  113. <el-button type="primary" v-if="active === 1 && oneTitle !== '抽取中'" :loading="extractLoading" @click="handleExtract">抽 取</el-button>
  114. <el-button type="primary" v-if="active === 2 && oneTitle !== '入库中'" :loading="storageLoading" @click="handleStorage">入 库</el-button>
  115. </span>
  116. </el-dialog>
  117. <el-dialog width="30%" title="增加实体关系" :visible.sync="addERDialogVisible" :before-close="addERHandleClose" append-to-body>
  118. <el-form ref="addERFormRef" :model="addERForm" label-width="80px">
  119. <el-form-item label="头实体" prop="headEntity">
  120. <el-input v-model="addERForm.headEntity" placeholder="请输入内容" />
  121. </el-form-item>
  122. <el-form-item label="头实体类" prop="headEntityClass">
  123. <!-- <el-input v-model="addERForm.headEntityClass" placeholder="请输入内容" /> -->
  124. <el-select v-model="addERForm.headEntityClass" placeholder="请选择实体类型">
  125. <el-option v-for="(item, index) in entityClassList" :key="index" :label="item" :value="item" />
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="关系" prop="relation">
  129. <!-- <el-input v-model="addERForm.relation" placeholder="请输入内容" /> -->
  130. <el-select v-model="addERForm.relation" placeholder="请选择实体类型">
  131. <el-option v-for="(item, index) in relationClassList" :key="index" :label="item" :value="item" />
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item label="尾实体" prop="tailEntity">
  135. <el-input v-model="addERForm.tailEntity" placeholder="请输入内容" />
  136. </el-form-item>
  137. <el-form-item label="尾实体类" prop="tailEntityClass">
  138. <el-select v-model="addERForm.tailEntityClass" placeholder="请选择实体类型">
  139. <el-option v-for="(item, index) in entityClassList" :key="index" :label="item" :value="item" />
  140. </el-select>
  141. </el-form-item>
  142. </el-form>
  143. <div slot="footer" class="dialog-footer">
  144. <el-button @click="addERHandleClose">取 消</el-button>
  145. <el-button type="primary" @click="addERSubmit">确 定</el-button>
  146. </div>
  147. </el-dialog>
  148. </div>
  149. </div>
  150. </template>
  151. <script>
  152. import {extractStatusss} from '@/utils/enum-data'
  153. import { listTechData, download, delTechData, addTechData, updateTechData } from "@/api/tech/techData";
  154. import { getTaskList, addTask, updateTask, removeTask, taskPro, getVisually, removeClause, updateClause, getClauseList, getExtractList, updateExtractInfo, removeExtractInfo, addER } from '@/api/als/knowledgeExtraction'
  155. import { getAllEntityClass } from '@/api/als/entityManage'
  156. import { getAllRelationClass } from '@/api/als/ERManage'
  157. import graphECharts from '@/views/components/Charts/graph.vue'
  158. import { getAtlasFile } from '@/api/als/atlasFile'
  159. // import { getOssIdDataAPI } from '@/api/als/algorithm'
  160. import { deepClone, debounce } from '@/utils'
  161. import LTable from '@/views/components/LTable/index.vue'
  162. export default {
  163. name: 'KnowledgeExtraction',
  164. components: { LTable, graphECharts },
  165. data() {
  166. // 这里存放数据
  167. return {
  168. dialogTitle: '新增',
  169. dialogVisible: false,
  170. detailDialogVisible: false,
  171. clauseDialogVisible: false,
  172. extractDialogVisible: false,
  173. addERDialogVisible: false,
  174. clauseLoading: false,
  175. extractLoading: false,
  176. storageLoading: false,
  177. keyWordData: '',
  178. searchValue: '',
  179. rules: {
  180. taskName: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  181. ossId: [{ required: true, message: '抽取文件不能为空', trigger: 'change' }]
  182. },
  183. columns: [
  184. {
  185. prop: 'taskName',
  186. label: '任务名称'
  187. },
  188. {
  189. prop: 'ossId',
  190. label: '文件',
  191. render: (h, params) => {
  192. const matchedItem = this.fileList.find((item) => params.row.ossId.trim() === item.ossId.trim())
  193. if (matchedItem) {
  194. return h('span', matchedItem.fileName)
  195. } else {
  196. return h('span', {}, '')
  197. }
  198. }
  199. },
  200. {
  201. prop: 'status',
  202. label: '状态',
  203. render: (h, params) => {
  204. const matchedItem = extractStatusss.find((item) => params.row.status === item.key)
  205. if (matchedItem) {
  206. return h('span', matchedItem.name)
  207. // return h('span', { class: matchedItem.colorType }, matchedItem.name)
  208. } else {
  209. return h('span', {}, '')
  210. }
  211. }
  212. },
  213. {
  214. button: true,
  215. label: '操作',
  216. width: '240px',
  217. group: [
  218. {
  219. name: '查看',
  220. type: 'text',
  221. round: false,
  222. plain: false,
  223. onClick: (row, index, scope) => {
  224. this.checkProcess(row)
  225. }
  226. },
  227. {
  228. name: '编辑',
  229. type: 'text',
  230. round: false,
  231. plain: false,
  232. onClick: (row, index, scope) => {
  233. this.handUpdate(row)
  234. }
  235. },
  236. {
  237. name: '删除',
  238. type: 'text',
  239. round: false,
  240. plain: false,
  241. onClick: (row, index, scope) => {
  242. this.remove([row])
  243. }
  244. }
  245. ]
  246. }
  247. ],
  248. options: {
  249. stripe: false, // 斑马纹
  250. mutiSelect: true, // 多选框
  251. index: false, // 显示序号, 多选则 mutiSelect
  252. loading: false, // 表格动画
  253. initTable: false, // 是否一挂载就加载数据
  254. border: true,
  255. height: 'calc(100vh - 300px)'
  256. },
  257. tableCheckItems: [],
  258. tableData: [],
  259. tableRequest: {
  260. total: 0,
  261. pageIndex: 1,
  262. pageSize: 20,
  263. searchValue: ''
  264. },
  265. clauseColumns: [
  266. {
  267. prop: 'clause',
  268. label: '内容'
  269. },
  270. {
  271. prop: 'status',
  272. label: '状态',
  273. width: '240px',
  274. render: (h, params) => {
  275. if (params.row.status === '0') {
  276. return h('span', { class: 'danger-state' }, '未审核')
  277. } else if (params.row.status === '1') {
  278. return h('span', { class: 'success-state' }, '通过')
  279. } else if (params.row.status === '2') {
  280. return h('span', { class: 'warning-state' }, '作废')
  281. }
  282. }
  283. },
  284. // {
  285. // prop: 'statusKey',
  286. // label: '状态',
  287. // width: '240px',
  288. // render: (h, params) => {
  289. // // if (params.row.status !== ' ') {
  290. // // if (params.row.status == '0') {
  291. // // return h('span', { class: 'danger-state' }, '未审核')
  292. // // } else if (params.row.status == '1') {
  293. // // return h('span', { class: 'success-state' }, '通过')
  294. // // } else if (params.row.status == '2') {
  295. // // return h('span', { class: 'warning-state' }, '作废')
  296. // // }
  297. // // } else {
  298. // const matchedItem = this.$enumData.extractStatus.find((item) => params.row.statusKey === item.key)
  299. // if (matchedItem) {
  300. // return h('span', { class: 'success-state' }, matchedItem.name)
  301. // // return h('span', { class: matchedItem.colorType }, matchedItem.name)
  302. // } else {
  303. // return h('span', {}, '')
  304. // }
  305. // // }
  306. // }
  307. // },
  308. {
  309. button: true,
  310. label: '操作',
  311. width: '240px',
  312. group: [
  313. {
  314. name: '编辑',
  315. type: 'text',
  316. statusKey: 'statusKey',
  317. disableKey: [3, 4],
  318. round: false,
  319. plain: false,
  320. onClick: (row, index, scope) => {
  321. this.clauseHandUpdate(row)
  322. }
  323. },
  324. {
  325. name: '删除',
  326. type: 'text',
  327. statusKey: 'statusKey',
  328. disableKey: [3, 4],
  329. round: false,
  330. plain: false,
  331. onClick: (row, index, scope) => {
  332. this.clauseRemove([row])
  333. }
  334. },
  335. {
  336. name: '查看抽取结果',
  337. type: 'text',
  338. statusKey: 'statusKey',
  339. unDisableKey: '4',
  340. round: false,
  341. plain: false,
  342. onClick: (row, index, scope) => {
  343. this.getExtractListAPI({ clauseId: row.id })
  344. this.checkExtractResult(row)
  345. }
  346. }
  347. ]
  348. }
  349. ],
  350. clauseOptions: {
  351. stripe: false, // 斑马纹
  352. mutiSelect: false, // 多选框
  353. index: true, // 显示序号, 多选则 mutiSelect
  354. loading: false, // 表格动画
  355. initTable: false, // 是否一挂载就加载数据
  356. border: true,
  357. height: 'calc(100vh - 470px)'
  358. },
  359. clauseTableCheckItems: [],
  360. clauseTableData: [],
  361. clauseTableRequest: {
  362. total: 0,
  363. pageIndex: 1,
  364. pageSize: 20,
  365. searchValue: ''
  366. },
  367. form: {
  368. id: '',
  369. taskName: '',
  370. ossId: ''
  371. },
  372. taskForm: {
  373. id: '',
  374. ossId: '',
  375. status: '',
  376. taskName: '',
  377. fileName: '',
  378. taskType: ''
  379. },
  380. debounceFn: debounce(this.fetch, 500),
  381. fileList: [],
  382. active: 0,
  383. clauseForm: {
  384. id: '',
  385. taskId: '',
  386. clause: '',
  387. status: ''
  388. },
  389. extractData: {
  390. content: '',
  391. extractDetailTable: []
  392. },
  393. extractDetailColumns: [
  394. {
  395. prop: 'headEntity',
  396. label: '头实体',
  397. edit: true,
  398. editStatus: false,
  399. onChange: (scope, oldRow) => {
  400. const { row } = scope
  401. if (oldRow.headEntity === row.headEntity) return
  402. this.updateExtractInfoAPI(row)
  403. }
  404. },
  405. {
  406. prop: 'headEntityClass',
  407. label: '头实体类',
  408. edit: true,
  409. editStatus: false,
  410. onChange: (scope, oldRow) => {
  411. const { row } = scope
  412. if (oldRow.headEntity === row.headEntityClass) return
  413. this.updateExtractInfoAPI(row)
  414. }
  415. },
  416. {
  417. prop: 'relation',
  418. label: '关系',
  419. edit: true,
  420. editStatus: false,
  421. onChange: (scope, oldRow) => {
  422. const { row } = scope
  423. if (oldRow.headEntity === row.relation) return
  424. this.updateExtractInfoAPI(row)
  425. }
  426. },
  427. {
  428. prop: 'tailEntity',
  429. label: '尾实体',
  430. edit: true,
  431. editStatus: false,
  432. onChange: (scope, oldRow) => {
  433. const { row } = scope
  434. if (oldRow.headEntity === row.tailEntity) return
  435. this.updateExtractInfoAPI(row)
  436. }
  437. },
  438. {
  439. prop: 'tailEntityClass',
  440. label: '尾实体类',
  441. edit: true,
  442. editStatus: false,
  443. onChange: (scope, oldRow) => {
  444. const { row } = scope
  445. if (oldRow.headEntity === row.tailEntityClass) return
  446. this.updateExtractInfoAPI(row)
  447. }
  448. },
  449. {
  450. button: true,
  451. label: '操作',
  452. width: '120px',
  453. group: [
  454. {
  455. name: '删除',
  456. type: 'text',
  457. round: false,
  458. plain: false,
  459. onClick: (row, index, scope) => {
  460. this.removeExtractDetail([row])
  461. }
  462. }
  463. ]
  464. }
  465. ],
  466. extractDetailOptions: {
  467. stripe: false, // 斑马纹
  468. mutiSelect: false, // 多选框
  469. index: true, // 显示序号, 多选则 mutiSelect
  470. loading: false, // 表格动画
  471. initTable: false, // 是否一挂载就加载数据
  472. border: true,
  473. height: '450px'
  474. },
  475. extractDetailRequest: {
  476. total: 0,
  477. pageIndex: 1,
  478. pageSize: 20,
  479. searchValue: ''
  480. },
  481. // extractDetailTableData: [{ content: 'qqq' }, { content: 'www' }, { content: 'eee' }]
  482. zeroTitle: '分句',
  483. oneTitle: '抽取',
  484. twoTitle: '审核',
  485. threeTitle: '入库',
  486. taskStatus: null,
  487. optionFileList:[],
  488. entityClassList: [],
  489. relationClassList: [],
  490. addERForm: {
  491. clauseId: '',
  492. headEntity: '',
  493. headEntityClass: '',
  494. relation: '',
  495. tailEntity: '',
  496. tailEntityClass: ''
  497. },
  498. graphData: {}
  499. }
  500. },
  501. watch: {
  502. keyWord() {
  503. this.tableRequest.pageIndex = 1
  504. this.debounceFn()
  505. }
  506. },
  507. mounted() {
  508. this.init()
  509. },
  510. methods: {
  511. init() {
  512. this.getTaskListAPI()
  513. this.getAtlasFileAPI()
  514. // this.getEntityClassAPI()
  515. // this.getAllRelationClassAPI()
  516. },
  517. infoOptions(){
  518. listTechData().then(response => {
  519. this.optionFileList = response.rows;
  520. console.log('logData',this.optionFileList)
  521. });
  522. },
  523. async getAtlasFileAPI(params) {
  524. try {
  525. const {
  526. data: { list, total }
  527. } = await getAtlasFile()
  528. this.fileList = list
  529. } catch (error) {}
  530. },
  531. async getEntityClassAPI(params) {
  532. try {
  533. const {
  534. data: { dataList }
  535. } = await getAllEntityClass()
  536. dataList.forEach((item) => {
  537. this.entityClassList.push(item.name)
  538. })
  539. } catch (error) {}
  540. },
  541. async getAllRelationClassAPI(params) {
  542. try {
  543. const {
  544. data: { dataList }
  545. } = await getAllRelationClass()
  546. dataList.forEach((item) => {
  547. this.relationClassList.push(item.name)
  548. })
  549. } catch (error) {}
  550. },
  551. async removeTaskAPI(params) {
  552. try {
  553. const { code } = await removeTask(params)
  554. if (code === 200) {
  555. this.$message({
  556. type: 'success',
  557. message: '操作成功!'
  558. })
  559. await this.getTaskListAPI()
  560. this.handleClose()
  561. }
  562. } catch (error) {}
  563. },
  564. async removeClauseAPI(params) {
  565. try {
  566. const { code } = await removeClause(params)
  567. if (code === 200) {
  568. this.$message({
  569. type: 'success',
  570. message: '操作成功!'
  571. })
  572. await this.getClauseListAPI({ taskId: this.taskForm.id })
  573. this.clauseHandleClose()
  574. }
  575. } catch (error) {}
  576. },
  577. async getTaskListAPI(params) {
  578. if (this.$refs.table) this.$refs.table.clearSelection()
  579. const { keyWord } = this
  580. const { pageSize, pageIndex } = this.tableRequest
  581. await getTaskList({ pageSize, pageNum: pageIndex, ...params }).then(res=>{
  582. this.tableData= res.rows
  583. this.tableRequest.total= res.total
  584. })
  585. },
  586. async getClauseListAPI(params) {
  587. if (this.$refs.clauseTableRef) this.$refs.clauseTableRef.clearSelection()
  588. const { keyWord } = this
  589. const { pageSize, pageIndex } = this.clauseTableRequest
  590. await getClauseList({ pageSize, pageNum: pageIndex, ...params }).then(res=>{
  591. this.clauseTableRequest.total = res.total
  592. this.clauseTableData = res.rows.map((el) => {
  593. return { ...el, statusKey: this.taskStatus }
  594. })
  595. })
  596. },
  597. async getExtractListAPI(params) {
  598. if (this.$refs.extractDetailTableRef) this.$refs.extractDetailTableRef.clearSelection()
  599. const { keyWord } = this
  600. const { pageSize, pageIndex } = this.extractDetailRequest
  601. await getExtractList({ pageSize, pageNum: pageIndex, ...params }).then(res=>{
  602. this.extractData.extractDetailTable = res.data.records;
  603. this.extractDetailRequest.total = res.total
  604. })
  605. },
  606. fetch() {
  607. this.getTaskListAPI()
  608. },
  609. clauseFetch() {
  610. this.getClauseListAPI({ taskId: this.taskForm.id })
  611. },
  612. extractDetailFetch() {
  613. this.getExtractListAPI({ clauseId: this.clauseForm.id })
  614. },
  615. async searchClick() {
  616. await this.getTaskListAPI({ taskName: this.keyWordData })
  617. },
  618. async addTaskAPI() {
  619. try {
  620. delete this.form.aircaftModelName
  621. const { code } = await addTask({ ...this.form })
  622. if (code === 200) {
  623. this.$message({
  624. type: 'success',
  625. message: '操作成功!'
  626. })
  627. this.handleClose()
  628. await this.getTaskListAPI()
  629. }
  630. } catch (error) {}
  631. },
  632. async updateTaskAPI() {
  633. try {
  634. const { code } = await updateTask({ ...this.form })
  635. if (code === 200) {
  636. this.$message({
  637. type: 'success',
  638. message: '操作成功!'
  639. })
  640. this.handleClose()
  641. await this.getTaskListAPI()
  642. }
  643. } catch (error) {}
  644. },
  645. async updateClauseAPI() {
  646. try {
  647. const { code } = await updateClause({ ...this.clauseForm })
  648. if (code === 200) {
  649. this.$message({
  650. type: 'success',
  651. message: '操作成功!'
  652. })
  653. this.clauseHandleClose()
  654. this.extractHandleClose()
  655. await this.getClauseListAPI({ taskId: this.taskForm.id })
  656. }
  657. } catch (error) {}
  658. },
  659. openDialog() {
  660. this.dialogTitle = '新增'
  661. this.infoOptions()
  662. this.dialogVisible = true
  663. },
  664. handleClose() {
  665. this.dialogVisible = false
  666. this.form = {
  667. id: '',
  668. taskName: '',
  669. ossId: ''
  670. }
  671. },
  672. handUpdate(row) {
  673. this.dialogTitle = '编辑'
  674. this.form = deepClone(row)
  675. this.dialogVisible = true
  676. },
  677. // 分句编辑
  678. clauseHandUpdate(row) {
  679. this.clauseForm = deepClone(row)
  680. this.clauseDialogVisible = true
  681. },
  682. // 查看抽取结果
  683. checkExtractResult(row) {
  684. this.clauseForm = deepClone(row)
  685. this.getExtractListAPI({ clauseId: row.id })
  686. this.extractData.content = row.clause
  687. console.log('this.extractData.content',this.extractData.content)
  688. this.extractDialogVisible = true
  689. },
  690. // 表格更新抽取结果
  691. async updateExtractInfoAPI(row) {
  692. if (this.handleVerify(row)) {
  693. try {
  694. console.log('row', row)
  695. const { code } = await updateExtractInfo({ ...row })
  696. if (code === 200) {
  697. this.$message({
  698. type: 'success',
  699. message: '操作成功!'
  700. })
  701. // this.clauseHandleClose()
  702. // this.getClauseListAPI({ taskId: this.taskForm.id })
  703. this.getExtractListAPI({ clauseId: this.clauseForm.id })
  704. }
  705. } catch (error) {}
  706. }fen
  707. },
  708. // 校验实体关系
  709. handleVerify(data) {
  710. const { headEntity, headEntityClass, relation, tailEntity, tailEntityClass } = data
  711. let str = this.extractData.content
  712. if (str.indexOf(headEntity) === -1 || str.indexOf(tailEntity) === -1) {
  713. this.extractDetailFetch()
  714. this.$message({
  715. type: 'warning',
  716. message: '实体与文本中匹配有误,请重新输入'
  717. })
  718. return false
  719. }
  720. if (!this.entityClassList.includes(headEntityClass) || !this.entityClassList.includes(tailEntityClass)) {
  721. this.extractDetailFetch()
  722. this.$message({
  723. type: 'warning',
  724. message: `实体类有误,请重新输入。目前实体类有<${this.entityClassList}>`,
  725. duration: 5000
  726. })
  727. return false
  728. }
  729. if (!this.relationClassList.includes(relation)) {
  730. this.extractDetailFetch()
  731. this.$message({
  732. type: 'warning',
  733. message: `关系有误,请重新输入。目前关系有<${this.relationClassList}>`,
  734. duration: 5000
  735. })
  736. return false
  737. }
  738. return true
  739. },
  740. // 新增实体关系
  741. addER() {
  742. this.addERDialogVisible = true
  743. },
  744. async addERSubmit() {
  745. if (this.handleVerify(this.addERForm)) {
  746. try {
  747. this.addERForm.clauseId = this.clauseForm.id
  748. const { code } = await addER({ ...this.addERForm })
  749. if (code === 200) {
  750. this.$message({
  751. type: 'success',
  752. message: '操作成功!'
  753. })
  754. this.addERHandleClose()
  755. this.getExtractListAPI({ clauseId: this.clauseForm.id })
  756. }
  757. } catch (error) {}
  758. }
  759. },
  760. // 作废
  761. handleCancel() {
  762. this.clauseForm.status = 2
  763. this.$confirm('是否将该抽取结果作废?', '提示', {
  764. confirmButtonText: '确定',
  765. cancelButtonText: '取消',
  766. type: 'warning'
  767. })
  768. .then(() => {
  769. // this.removeTaskAPI(row.map((e) => e.id))
  770. this.updateClauseAPI()
  771. })
  772. .catch(() => {})
  773. },
  774. // 通过
  775. passThrough() {
  776. this.clauseForm.status = 1
  777. this.updateClauseAPI()
  778. },
  779. submit() {
  780. this.$refs.form.validate((valid) => {
  781. if (valid) {
  782. switch (this.dialogTitle) {
  783. case '编辑':
  784. this.updateTaskAPI()
  785. break
  786. case '新增':
  787. this.addTaskAPI()
  788. break
  789. }
  790. }
  791. })
  792. },
  793. clauseSubmit() {
  794. this.updateClauseAPI()
  795. },
  796. extractSubmit() {
  797. // this.updateClauseAPI()
  798. },
  799. selection(val) {
  800. this.tableCheckItems = val
  801. },
  802. clauseSelection(val) {
  803. this.clauseTableCheckItems = val
  804. },
  805. // extractSelection(val) {
  806. // this.extractTableCheckItems = val
  807. // },
  808. remove(row) {
  809. this.$confirm('是否删除该数据', '提示', {
  810. confirmButtonText: '确定',
  811. cancelButtonText: '取消',
  812. type: 'warning'
  813. })
  814. .then(() => {
  815. this.removeTaskAPI(row.map((e) => e.id))
  816. })
  817. .catch(() => {})
  818. },
  819. removeExtractDetail(row) {
  820. console.log('row', row)
  821. this.$confirm('是否删除该条实体关系', '提示', {
  822. confirmButtonText: '确定',
  823. cancelButtonText: '取消',
  824. type: 'warning'
  825. })
  826. .then(() => {
  827. this.removeExtractInfoAPI(row.map((e) => e.id))
  828. })
  829. .catch(() => {})
  830. },
  831. async removeExtractInfoAPI(params) {
  832. try {
  833. const { code } = await removeExtractInfo(params)
  834. if (code === 200) {
  835. this.$message({
  836. type: 'success',
  837. message: '操作成功!'
  838. })
  839. await this.getExtractListAPI({ clauseId: this.clauseForm.id })
  840. }
  841. } catch (error) {}
  842. },
  843. clauseRemove(row) {
  844. this.$confirm('是否删除该数据', '提示', {
  845. confirmButtonText: '确定',
  846. cancelButtonText: '取消',
  847. type: 'warning'
  848. })
  849. .then(() => {
  850. this.removeClauseAPI(row.map((e) => e.id))
  851. })
  852. .catch(() => {})
  853. },
  854. checkProcess(row) {
  855. this.taskStatus = row.status
  856. this.taskForm = deepClone(row)
  857. switch (this.taskStatus) {
  858. case '0':
  859. this.active = 0
  860. this.zeroTitle = '待分句'
  861. break
  862. case '1':
  863. this.active = 0
  864. this.zeroTitle = '分句中'
  865. break
  866. case '2':
  867. this.active = 1
  868. this.zeroTitle = '分句'
  869. this.getClauseListAPI({ taskId: row.id })
  870. this.oneTitle = '待抽取'
  871. break
  872. case '3':
  873. this.active = 1
  874. this.oneTitle = '抽取中'
  875. this.getClauseListAPI({ taskId: row.id })
  876. break
  877. case '4':
  878. this.active = 2
  879. this.oneTitle = '抽取'
  880. this.getClauseListAPI({ taskId: row.id })
  881. this.twoTitle = '审核中'
  882. break
  883. case '5':
  884. this.active = 2
  885. this.getClauseListAPI({ taskId: row.id })
  886. this.twoTitle = '入库中'
  887. break
  888. case '6':
  889. this.twoTitle = '审核'
  890. this.threeTitle = '已入库'
  891. this.getVisuallyAPI(row)
  892. this.active = 3
  893. break
  894. default:
  895. break
  896. }
  897. this.detailDialogVisible = true
  898. },
  899. async getVisuallyAPI(row) {
  900. try {
  901. const { code, data } = await getVisually({ ossId: row.ossId })
  902. if (code === 200) {
  903. // const newData = this.handleData(JSON.parse(data))
  904. // console.log('newData', newData)
  905. const categories = []
  906. data.data.forEach((node) => {
  907. const flag = categories.find((item) => {
  908. return item.name === node.category
  909. })
  910. if (!flag) {
  911. categories.push({ name: node.category })
  912. }
  913. })
  914. data.categories = categories
  915. this.graphData = data
  916. console.log('this.graphData', this.graphData)
  917. }
  918. } catch (error) {}
  919. },
  920. handleData(data) {
  921. if (data) {
  922. // const newData = eval('(' + data + ')')
  923. // data.data = graphData
  924. const categories = []
  925. data.data.forEach((node) => {
  926. const flag = categories.find((item) => {
  927. return item.name === node.category
  928. })
  929. if (!flag) {
  930. categories.push({ name: node.category })
  931. }
  932. })
  933. data.categories = categories
  934. }
  935. return data
  936. },
  937. detailHandleClose() {
  938. this.detailDialogVisible = false
  939. this.taskForm = {
  940. id: '',
  941. ossId: '',
  942. status: '',
  943. taskName: '',
  944. fileName: '',
  945. taskType: ''
  946. }
  947. this.clauseForm = {
  948. id: '',
  949. taskId: '',
  950. clause: '',
  951. status: ''
  952. }
  953. },
  954. clauseHandleClose() {
  955. this.clauseDialogVisible = false
  956. this.clauseForm = {
  957. id: '',
  958. taskId: '',
  959. clause: '',
  960. status: ''
  961. }
  962. },
  963. extractHandleClose() {
  964. this.extractDialogVisible = false
  965. this.extractData = {
  966. content: '',
  967. extractDetailTable: []
  968. }
  969. },
  970. addERHandleClose() {
  971. this.addERDialogVisible = false
  972. this.addERForm = {
  973. clauseId: '',
  974. headEntity: '',
  975. headEntityClass: '',
  976. relation: '',
  977. tailEntity: '',
  978. tailEntityClass: ''
  979. }
  980. },
  981. async handleClause() {
  982. this.clauseLoading = true
  983. this.taskForm.taskType = 0
  984. try {
  985. const { code } = await taskPro(this.taskForm)
  986. if (code === 200) {
  987. this.$message({
  988. type: 'success',
  989. message: '文件开始分句中,稍后刷新页面查看进度',
  990. duration: 5000
  991. })
  992. this.getTaskListAPI()
  993. this.detailDialogVisible = false
  994. this.clauseLoading = false
  995. this.active = 1
  996. }
  997. } catch (error) {
  998. this.clauseLoading = false
  999. this.$message({
  1000. type: 'warning',
  1001. message: '接口错误请联系管理员'
  1002. })
  1003. }
  1004. },
  1005. async handleExtract() {
  1006. this.extractLoading = true
  1007. this.taskForm.taskType = 2
  1008. try {
  1009. const { code } = await taskPro(this.taskForm)
  1010. if (code === 200) {
  1011. this.$message({
  1012. type: 'success',
  1013. message: '文件开始抽取中,稍后刷新页面查看进度',
  1014. duration: 5000
  1015. })
  1016. this.getTaskListAPI()
  1017. this.detailDialogVisible = false
  1018. this.extractLoading = false
  1019. this.active = 2
  1020. }
  1021. } catch (error) {
  1022. this.extractLoading = false
  1023. this.$message({
  1024. type: 'warning',
  1025. message: '接口错误请联系管理员'
  1026. })
  1027. }
  1028. },
  1029. async handleStorage() {
  1030. this.storageLoading = true
  1031. this.taskForm.taskType = 4
  1032. try {
  1033. const { code } = await taskPro(this.taskForm)
  1034. if (code === 200) {
  1035. this.$message({
  1036. type: 'success',
  1037. message: '文件开始入库中,稍后刷新页面查看进度',
  1038. duration: 5000
  1039. })
  1040. this.getTaskListAPI()
  1041. this.detailDialogVisible = false
  1042. this.storageLoading = false
  1043. this.active = 2
  1044. }
  1045. } catch (error) {
  1046. this.storageLoading = false
  1047. this.$message({
  1048. type: 'warning',
  1049. message: '接口错误请联系管理员'
  1050. })
  1051. }
  1052. }
  1053. }
  1054. }
  1055. </script>
  1056. <style lang="scss" scoped>
  1057. .content {
  1058. width: 100%;
  1059. height: 500px;
  1060. display: flex;
  1061. .left {
  1062. width: 30%;
  1063. padding: 20px;
  1064. // font-size: 1.1rem;
  1065. color: white;
  1066. border-right: 1px solid #eeeeee;
  1067. overflow: hidden;
  1068. }
  1069. .right {
  1070. width: 70%;
  1071. }
  1072. }
  1073. </style>