index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <div>
  3. <el-container>
  4. <el-header>
  5. <el-steps :active="parseInt(task.status)" simple direction finish-status="wait" process-status="finish">
  6. <el-step title="知识加工" icon="el-icon-cpu"></el-step>
  7. <el-step title="人工审核" icon="el-icon-s-custom"></el-step>
  8. <el-step title="数据入库" icon="el-icon-document-checked"></el-step>
  9. </el-steps>
  10. </el-header>
  11. <el-main>
  12. <el-table v-loading="loading" :data="subTaskList">
  13. <el-table-column type="index" width="50"/>
  14. <el-table-column label="子任务名称" align="center" prop="type">
  15. <template slot-scope="scope">
  16. <dict-tag :options="dict.type.extract_sub_task_list" :value="scope.row.type"/>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="任务状态" align="center" prop="status">
  20. <template slot-scope="scope">
  21. <dict-tag :options="dict.type.extract_sub_task_status" :value="scope.row.status"/>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="启动时间" align="center" prop="createTime" width="180">
  25. </el-table-column>
  26. <el-table-column label="花费时间(s)" align="center" prop="costTime" />
  27. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  28. <template slot-scope="scope">
  29. <el-button
  30. v-show="scope.row.status >= 1"
  31. size="mini"
  32. type="text"
  33. icon="el-icon-warning-outline"
  34. @click="viewSentence(scope.row)"
  35. v-hasPermi="['extract:subTask:edit']"
  36. >查看分句</el-button>
  37. <el-button
  38. v-show="scope.row.status == 1"
  39. size="mini"
  40. type="text"
  41. icon="el-icon-warning-outline"
  42. @click="handleApprove(scope.row)"
  43. v-hasPermi="['extract:subTask:edit']"
  44. >审核</el-button>
  45. <el-button
  46. v-show="scope.row.status == 3"
  47. size="mini"
  48. type="text"
  49. icon="el-icon-warning-outline"
  50. @click="viewResult(scope.row)"
  51. v-hasPermi="['extract:subTask:edit']"
  52. >查看抽取结果</el-button>
  53. <el-button
  54. v-show="scope.row.status == 4"
  55. size="mini"
  56. type="text"
  57. icon="el-icon-finished"
  58. @click="handleViewLog(scope.row)"
  59. v-hasPermi="['extract:subTask:edit']"
  60. >查看日志</el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <pagination
  65. v-show="total>0"
  66. :total="total"
  67. :page.sync="queryParams.pageNum"
  68. :limit.sync="queryParams.pageSize"
  69. @pagination="getListByTaskId"
  70. />
  71. </el-main>
  72. </el-container>
  73. <!-- 添加或修改知识抽取子任务对话框 -->
  74. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  75. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  76. <el-form-item label="抽取任务id" prop="taskId">
  77. <el-input v-model="form.taskId" placeholder="请输入抽取任务id" />
  78. </el-form-item>
  79. <el-form-item label="子任务类型" prop="type">
  80. <el-select v-model="form.type" placeholder="请选择子任务类型">
  81. <el-option
  82. v-for="dict in dict.type.extract_sub_task_list"
  83. :key="dict.value"
  84. :label="dict.label"
  85. :value="dict.value"
  86. ></el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="任务状态">
  90. <el-radio-group v-model="form.status">
  91. <el-radio
  92. v-for="dict in dict.type.extract_sub_task_status"
  93. :key="dict.value"
  94. :label="dict.value"
  95. >{{dict.label}}</el-radio>
  96. </el-radio-group>
  97. </el-form-item>
  98. <el-form-item label="日志" prop="log">
  99. <el-input v-model="form.log" type="textarea" placeholder="请输入内容" />
  100. </el-form-item>
  101. <el-form-item label="完成时间" prop="completedDate">
  102. <el-date-picker clearable
  103. v-model="form.completedDate"
  104. type="date"
  105. value-format="yyyy-MM-dd"
  106. placeholder="请选择完成时间">
  107. </el-date-picker>
  108. </el-form-item>
  109. <el-form-item label="花费时间(s)" prop="costTime">
  110. <el-input v-model="form.costTime" placeholder="请输入花费时间(s)" />
  111. </el-form-item>
  112. </el-form>
  113. <div slot="footer" class="dialog-footer">
  114. <el-button type="primary" @click="submitForm">确 定</el-button>
  115. <el-button @click="cancel">取 消</el-button>
  116. </div>
  117. </el-dialog>
  118. <el-dialog :title="tripletInfoOpenTitle" v-if="tripletInfoOpen" :visible.sync="tripletInfoOpen" width="80%" append-to-body destroy-on-close :close-on-click-modal="false">
  119. <!-- <TripletInfo :subTask="subTask" :subTaskOpen.sync="tripletInfoOpen" @closeInfo="closeInfo"></TripletInfo> -->
  120. <IndexV2 :subTask="subTask" @closeInfo="closeInfo" :readonly="tripletInfoReadOnly"/>
  121. </el-dialog>
  122. <el-dialog title="分句结果" v-if="viewSentenceOpen" :visible.sync="viewSentenceOpen" width="80%" append-to-body destroy-on-close :close-on-click-modal="false">
  123. <p v-for="sentence in sentenceList" :key="sentence.id">
  124. {{ sentence.id }}. {{ sentence.text }}
  125. </p>
  126. </el-dialog>
  127. </div>
  128. </template>
  129. <script>
  130. import { listSubTask, getSubTask, delSubTask, addSubTask, updateSubTask } from "@/api/extract/subTask";
  131. import { getSentence } from "@/api/extract/result";
  132. import TripletInfo from '@/views/extract/info';
  133. import IndexV2 from '@/views/extract/info/indexV2';
  134. export default {
  135. name: "SubTask",
  136. dicts: ['extract_sub_task_status', 'extract_sub_task_list'],
  137. components: { TripletInfo,IndexV2 },
  138. props: {
  139. task: {
  140. type: Object,
  141. },
  142. subTaskOpen: {
  143. type: Boolean,
  144. },
  145. },
  146. data() {
  147. return {
  148. // 遮罩层
  149. loading: true,
  150. // 选中数组
  151. ids: [],
  152. // 非单个禁用
  153. single: true,
  154. // 非多个禁用
  155. multiple: true,
  156. // 显示搜索条件
  157. showSearch: true,
  158. // 总条数
  159. total: 0,
  160. // 知识抽取子任务表格数据
  161. subTaskList: [],
  162. // 弹出层标题
  163. title: "",
  164. // 是否显示弹出层
  165. open: false,
  166. // 步骤
  167. setp: 1,
  168. // 查询参数
  169. queryParams: {
  170. pageNum: 1,
  171. pageSize: 10,
  172. taskId: this.task.id,
  173. },
  174. // 表单参数
  175. form: {},
  176. // 表单校验
  177. rules: {
  178. taskId: [
  179. { required: true, message: "抽取任务id不能为空", trigger: "blur" }
  180. ],
  181. },
  182. tripletInfoOpenTitle: "",
  183. tripletInfoOpen: false,
  184. subTask: {},
  185. viewSentenceOpen: false,
  186. sentenceList: [],
  187. tripletInfoReadOnly: false,
  188. };
  189. },
  190. created() {
  191. this.getListByTaskId();
  192. },
  193. methods: {
  194. /** 查询知识抽取子任务列表 */
  195. // getList() {
  196. // this.loading = true;
  197. // listSubTask(this.queryParams).then(response => {
  198. // this.subTaskList = response.rows;
  199. // this.total = response.total;
  200. // this.loading = false;
  201. // });
  202. // },
  203. /** 查询知识抽取子任务列表 */
  204. getListByTaskId() {
  205. this.loading = true;
  206. listSubTask(this.queryParams).then(response => {
  207. this.subTaskList = response.rows;
  208. this.total = response.total;
  209. this.loading = false;
  210. });
  211. },
  212. // 取消按钮
  213. cancel() {
  214. this.open = false;
  215. this.reset();
  216. },
  217. // 表单重置
  218. reset() {
  219. this.form = {
  220. id: null,
  221. taskId: null,
  222. type: null,
  223. status: "0",
  224. log: null,
  225. completedDate: null,
  226. costTime: null,
  227. };
  228. this.resetForm("form");
  229. },
  230. /** 搜索按钮操作 */
  231. handleQuery() {
  232. this.queryParams.pageNum = 1;
  233. this.getList();
  234. },
  235. /** 重置按钮操作 */
  236. resetQuery() {
  237. this.resetForm("queryForm");
  238. this.handleQuery();
  239. },
  240. // 多选框选中数据
  241. // handleSelectionChange(selection) {
  242. // this.ids = selection.map(item => item.id)
  243. // this.single = selection.length!==1
  244. // this.multiple = !selection.length
  245. // },
  246. /** 新增按钮操作 */
  247. handleAdd() {
  248. this.reset();
  249. this.open = true;
  250. this.title = "添加知识抽取子任务";
  251. },
  252. /** 修改按钮操作 */
  253. handleUpdate(row) {
  254. this.reset();
  255. const id = row.id || this.ids
  256. getSubTask(id).then(response => {
  257. this.form = response.data;
  258. this.open = true;
  259. this.title = "修改知识抽取子任务";
  260. });
  261. },
  262. /** 提交按钮 */
  263. submitForm() {
  264. this.$refs["form"].validate(valid => {
  265. if (valid) {
  266. if (this.form.id != null) {
  267. updateSubTask(this.form).then(response => {
  268. this.$modal.msgSuccess("修改成功");
  269. this.open = false;
  270. this.getList();
  271. });
  272. } else {
  273. addSubTask(this.form).then(response => {
  274. this.$modal.msgSuccess("新增成功");
  275. this.open = false;
  276. this.getList();
  277. });
  278. }
  279. }
  280. });
  281. },
  282. /** 删除按钮操作 */
  283. handleDelete(row) {
  284. const ids = row.id || this.ids;
  285. this.$modal.confirm('是否确认删除知识抽取子任务编号为"' + ids + '"的数据项?').then(function() {
  286. return delSubTask(ids);
  287. }).then(() => {
  288. this.getList();
  289. this.$modal.msgSuccess("删除成功");
  290. }).catch(() => {});
  291. },
  292. /** 导出按钮操作 */
  293. handleExport() {
  294. this.download('extract/subTask/export', {
  295. ...this.queryParams
  296. }, `subTask_${new Date().getTime()}.xlsx`)
  297. },
  298. closeSubTask() {
  299. this.subTaskOpen = false;
  300. },
  301. handleApprove(row){
  302. this.tripletInfoReadOnly = false
  303. this.tripletInfoOpen = true
  304. this.tripletInfoOpenTitle = this.dict.label.extract_sub_task_list[row.type]
  305. this.subTask = row
  306. },
  307. handleViewLog(row){
  308. this.$alert(row.log, '日志', {
  309. confirmButtonText: '确定',
  310. });
  311. },
  312. closeInfo(){
  313. this.tripletInfoOpen = false
  314. this.tripletInfoOpenTitle = ''
  315. this.subTask = {}
  316. this.getListByTaskId()
  317. },
  318. viewSentence(row){
  319. getSentence(row.id).then(resp => {
  320. this.sentenceList = resp.data
  321. this.viewSentenceOpen = true
  322. })
  323. },
  324. viewResult(row){
  325. debugger
  326. this.tripletInfoReadOnly = true
  327. this.tripletInfoOpen = true
  328. this.tripletInfoOpenTitle = this.dict.label.extract_sub_task_list[row.type]
  329. this.subTask = row
  330. }
  331. }
  332. };
  333. </script>
  334. <style scoped>
  335. .el-dialog__body {
  336. padding: 0px
  337. }
  338. </style>