index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="任务名称" prop="taskName">
  5. <el-input
  6. v-model="queryParams.taskName"
  7. placeholder="请输入任务名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <!-- <el-form-item label="任务数" prop="subtaskNum">-->
  13. <!-- <el-input-->
  14. <!-- v-model="queryParams.subtaskNum"-->
  15. <!-- placeholder="请输入任务数"-->
  16. <!-- clearable-->
  17. <!-- @keyup.enter.native="handleQuery"-->
  18. <!-- />-->
  19. <!-- </el-form-item>-->
  20. <!-- <el-form-item label="开始时间" prop="startTime">-->
  21. <!-- <el-date-picker clearable-->
  22. <!-- v-model="queryParams.startTime"-->
  23. <!-- type="date"-->
  24. <!-- value-format="yyyy-MM-dd"-->
  25. <!-- placeholder="请选择开始时间">-->
  26. <!-- </el-date-picker>-->
  27. <!-- </el-form-item>-->
  28. <!-- <el-form-item label="结束时间" prop="endTime">-->
  29. <!-- <el-date-picker clearable-->
  30. <!-- v-model="queryParams.endTime"-->
  31. <!-- type="date"-->
  32. <!-- value-format="yyyy-MM-dd"-->
  33. <!-- placeholder="请选择结束时间">-->
  34. <!-- </el-date-picker>-->
  35. <!-- </el-form-item>-->
  36. <!-- <el-form-item label="完成率" prop="progress">-->
  37. <!-- <el-input-->
  38. <!-- v-model="queryParams.progress"-->
  39. <!-- placeholder="请输入完成率"-->
  40. <!-- clearable-->
  41. <!-- @keyup.enter.native="handleQuery"-->
  42. <!-- />-->
  43. <!-- </el-form-item>-->
  44. <!-- <el-form-item label="准确率" prop="accuracyRate">-->
  45. <!-- <el-input-->
  46. <!-- v-model="queryParams.accuracyRate"-->
  47. <!-- placeholder="请输入准确率"-->
  48. <!-- clearable-->
  49. <!-- @keyup.enter.native="handleQuery"-->
  50. <!-- />-->
  51. <!-- </el-form-item>-->
  52. <!-- <el-form-item label="召回率" prop="recallRate">-->
  53. <!-- <el-input-->
  54. <!-- v-model="queryParams.recallRate"-->
  55. <!-- placeholder="请输入召回率"-->
  56. <!-- clearable-->
  57. <!-- @keyup.enter.native="handleQuery"-->
  58. <!-- />-->
  59. <!-- </el-form-item>-->
  60. <el-form-item>
  61. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  62. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  63. </el-form-item>
  64. </el-form>
  65. <el-row :gutter="10" class="mb8">
  66. <!-- <el-col :span="1.5">-->
  67. <!-- <el-button-->
  68. <!-- type="primary"-->
  69. <!-- plain-->
  70. <!-- icon="el-icon-plus"-->
  71. <!-- size="mini"-->
  72. <!-- @click="handleAdd"-->
  73. <!-- v-hasPermi="['biz:task:add']"-->
  74. <!-- >新增</el-button>-->
  75. <!-- </el-col>-->
  76. <!-- <el-col :span="1.5">-->
  77. <!-- <el-button-->
  78. <!-- type="success"-->
  79. <!-- plain-->
  80. <!-- icon="el-icon-edit"-->
  81. <!-- size="mini"-->
  82. <!-- :disabled="single"-->
  83. <!-- @click="handleUpdate"-->
  84. <!-- v-hasPermi="['biz:task:edit']"-->
  85. <!-- >修改</el-button>-->
  86. <!-- </el-col>-->
  87. <!-- <el-col :span="1.5">-->
  88. <!-- <el-button-->
  89. <!-- type="danger"-->
  90. <!-- plain-->
  91. <!-- icon="el-icon-delete"-->
  92. <!-- size="mini"-->
  93. <!-- :disabled="multiple"-->
  94. <!-- @click="handleDelete"-->
  95. <!-- v-hasPermi="['biz:task:remove']"-->
  96. <!-- >删除</el-button>-->
  97. <!-- </el-col>-->
  98. <el-col :span="1.5">
  99. <el-button
  100. type="info"
  101. icon="el-icon-upload2"
  102. size="mini"
  103. @click="handleImport"
  104. v-hasPermi="['biz:detail:import']"
  105. >导入</el-button>
  106. </el-col>
  107. <el-col :span="1.5">
  108. <el-button
  109. type="warning"
  110. plain
  111. icon="el-icon-download"
  112. size="mini"
  113. @click="handleExport"
  114. v-hasPermi="['biz:detail:export']"
  115. >选择任务导出任务详情</el-button>
  116. </el-col>
  117. <el-col :span="1.5" >
  118. <el-button
  119. type='success'
  120. plain
  121. icon="el-icon-video-play"
  122. size="mini"
  123. @click="handleRun"
  124. >验证运行</el-button>
  125. </el-col>
  126. <el-col :span="1.5" >
  127. <el-button
  128. type='info'
  129. plain
  130. icon="el-icon-document"
  131. size="mini"
  132. @click="gettraindata"
  133. >查询训练数据</el-button>
  134. </el-col>
  135. <el-col :span="1.5" >
  136. <el-button
  137. type='info'
  138. plain
  139. icon="el-icon-document"
  140. size="mini"
  141. @click="getverificationdata"
  142. >查询验证数据</el-button>
  143. </el-col>
  144. <!-- <el-col :span="1.5" >-->
  145. <!-- <el-button-->
  146. <!-- type='danger'-->
  147. <!-- plain-->
  148. <!-- icon="el-icon-video-pause"-->
  149. <!-- size="mini"-->
  150. <!-- @click="handleRun"-->
  151. <!-- >终止</el-button>-->
  152. <!-- </el-col>-->
  153. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  154. </el-row>
  155. <el-table v-loading="loading" :data="taskList" @selection-change="handleSelectionChange">
  156. <el-table-column type="selection" width="55" align="center" class="custom-selection"/>
  157. <el-table-column label="任务编号" align="center" prop="id" />
  158. <el-table-column label="任务名称" align="center" prop="taskName" :show-overflow-tooltip='true' />
  159. <el-table-column label="状态" align="center" prop="taskStatus" :show-overflow-tooltip='true' />
  160. <el-table-column label="任务数" align="center" prop="subtaskNum" />
  161. <el-table-column label="开始时间" align="center" prop="startTime" width="180">
  162. <template slot-scope="scope">
  163. <span>{{ parseTime(scope.row.startTime) }}</span>
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="结束时间" align="center" prop="endTime" width="180">
  167. <template slot-scope="scope">
  168. <span>{{ parseTime(scope.row.endTime) }}</span>
  169. </template>
  170. </el-table-column>
  171. <el-table-column label="准确率" align="center" prop="accuracyRate" />
  172. <el-table-column label="召回率" align="center" prop="recallRate" />
  173. <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip='true' />
  174. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
  175. <template slot-scope="scope">
  176. <el-button
  177. size="mini"
  178. type="text"
  179. icon="el-icon-edit"
  180. @click="handleUpdate(scope.row)"
  181. v-hasPermi="['biz:task:edit']"
  182. >修改</el-button>
  183. <el-button
  184. size="mini"
  185. type="text"
  186. icon="el-icon-delete"
  187. @click="handleDelete(scope.row)"
  188. v-hasPermi="['biz:task:remove']"
  189. >删除</el-button>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. <pagination
  194. v-show="total>0"
  195. :total="total"
  196. :page.sync="queryParams.pageNum"
  197. :limit.sync="queryParams.pageSize"
  198. @pagination="getList"
  199. />
  200. <!-- 任务详情导入对话框 -->
  201. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
  202. <el-upload
  203. ref="upload"
  204. :limit="1"
  205. accept=".xlsx, .xls"
  206. :headers="upload.headers"
  207. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  208. :disabled="upload.isUploading"
  209. :on-progress="handleFileUploadProgress"
  210. :on-success="handleFileSuccess"
  211. :auto-upload="false"
  212. drag
  213. >
  214. <i class="el-icon-upload"></i>
  215. <div class="el-upload__text">
  216. 将文件拖到此处,或
  217. <em>点击上传</em>
  218. </div>
  219. <div class="el-upload__tip" slot="tip">
  220. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
  221. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  222. </div>
  223. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  224. </el-upload>
  225. <div slot="footer" class="dialog-footer">
  226. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  227. <el-button @click="upload.open = false">取 消</el-button>
  228. </div>
  229. </el-dialog>
  230. <!-- 添加或修改验证任务对话框 -->
  231. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  232. <el-form style="border:1px solid #C0C0C0;padding: 5px;margin: auto" ref="form" :model="form" :rules="rules" label-width="120px">
  233. <el-form-item label="任务名称" prop="taskName">
  234. <el-input v-model="form.taskName" placeholder="请输入任务名称" />
  235. </el-form-item>
  236. <el-form-item label="任务数" prop="subtaskNum">
  237. <el-input v-model="form.subtaskNum" placeholder="请输入任务数" />
  238. </el-form-item>
  239. <el-form-item label="开始时间" prop="startTime">
  240. <el-date-picker clearable
  241. v-model="form.startTime"
  242. type="date"
  243. value-format="yyyy-MM-dd HH:mm:ss"
  244. placeholder="请选择开始时间">
  245. </el-date-picker>
  246. </el-form-item>
  247. <el-form-item label="结束时间" prop="endTime">
  248. <el-date-picker clearable
  249. v-model="form.endTime"
  250. type="date"
  251. value-format="yyyy-MM-dd HH:mm:ss"
  252. placeholder="请选择结束时间">
  253. </el-date-picker>
  254. </el-form-item>
  255. <el-form-item label="完成率" prop="progress">
  256. <el-input v-model="form.progress" placeholder="请输入完成率" />
  257. </el-form-item>
  258. <el-form-item label="准确率" prop="accuracyRate">
  259. <el-input v-model="form.accuracyRate" placeholder="请输入准确率" />
  260. </el-form-item>
  261. <el-form-item label="召回率" prop="recallRate">
  262. <el-input v-model="form.recallRate" placeholder="请输入召回率" />
  263. </el-form-item>
  264. <el-form-item label="备注" prop="remark">
  265. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  266. </el-form-item>
  267. </el-form>
  268. <div slot="footer" class="dialog-footer">
  269. <el-button type="primary" @click="submitForm">确 定</el-button>
  270. <el-button @click="cancel">取 消</el-button>
  271. </div>
  272. </el-dialog>
  273. <el-dialog title="训练数据" :visible.sync="traindatavisible" width="800px" append-to-body>
  274. <el-table v-loading = tloading :data="traindataset" >
  275. <el-table-column label="使用场景" align="center" prop="useScene" />
  276. <el-table-column label="查询条件" align="center" prop="searchCondition" />
  277. <el-table-column label="标准结果1" align="center" prop="result1" />
  278. <el-table-column label="标准结果2" align="center" prop="result2" />
  279. <el-table-column label="标准结果3" align="center" prop="result3" />
  280. <el-table-column label="标准结果4" align="center" prop="result4" />
  281. <el-table-column label="标准结果5" align="center" prop="result5" />
  282. <el-table-column label="trained" align="center" >{{1}}</el-table-column>
  283. <el-table-column label="tested" align="center" >{{0}}</el-table-column>
  284. </el-table>
  285. <pagination
  286. v-show="ttotal>0"
  287. :total="ttotal"
  288. :page.sync="queryParams.pageNum"
  289. :limit.sync="queryParams.pageSize"
  290. @pagination="gettraindata"
  291. />
  292. </el-dialog>
  293. <el-dialog title="验证数据" :visible.sync="verificationdatavisible" width="800px" append-to-body>
  294. <el-table v-loading = vloading :data="verificationtabledata" >
  295. <el-table-column label="使用场景" align="center" prop="useScene" />
  296. <el-table-column label="查询条件" align="center" prop="searchCondition" />
  297. <el-table-column label="标准结果1" align="center" prop="result1" />
  298. <el-table-column label="标准结果2" align="center" prop="result2" />
  299. <el-table-column label="标准结果3" align="center" prop="result3" />
  300. <el-table-column label="标准结果4" align="center" prop="result4" />
  301. <el-table-column label="标准结果5" align="center" prop="result5" />
  302. <el-table-column label="计算结果1" align="center" prop="calculate1" />
  303. <el-table-column label="计算结果2" align="center" prop="calculate2" />
  304. <el-table-column label="计算结果3" align="center" prop="calculate3" />
  305. <el-table-column label="计算结果4" align="center" prop="calculate4" />
  306. <el-table-column label="计算结果5" align="center" prop="calculate5" />
  307. <el-table-column label="trained" align="center" >{{0}}</el-table-column>
  308. <el-table-column label="tested" align="center" >{{1}}</el-table-column>
  309. </el-table>
  310. <pagination
  311. v-show="vtotal>0"
  312. :total="vtotal"
  313. :page.sync="queryParams.pageNum"
  314. :limit.sync="queryParams.pageSize"
  315. @pagination="getverificationdata"
  316. />
  317. </el-dialog>
  318. <el-dialog
  319. :title=progresstitle
  320. :visible.sync="dialogVisible"
  321. width="20%"
  322. style="top:225px"
  323. >
  324. <div align="center">
  325. <el-progress
  326. type="circle"
  327. :percentage="ProgressMap[taskidToIndexMap.get(ids[0])]"
  328. width="80"
  329. :status="progressStatus"
  330. ></el-progress>
  331. </div>
  332. </el-dialog>
  333. </div>
  334. </template>
  335. <script>
  336. import { listTask, getTask, delTask, addTask, updateTask } from "@/api/biz/task";
  337. import { verification,getTraindataset,updateDetails,getUpdatedDetails } from "@/api/biz/detail";
  338. import { getToken } from "@/utils/auth";
  339. import {Loading, Message} from "element-ui";
  340. import service from "../../../utils/request";
  341. import errorCode from "../../../utils/errorCode";
  342. import dayjs from "dayjs";
  343. import {updateDetail} from "../../../api/biz/detail";
  344. export default {
  345. name: "Task",
  346. data() {
  347. return {
  348. progresstitle:'',
  349. dialogVisible:false,
  350. // 遮罩层
  351. loading: true,
  352. vloading:true,
  353. tloading:true,
  354. // 选中数组
  355. ids: [],
  356. // 非单个禁用
  357. single: true,
  358. // 非多个禁用
  359. multiple: true,
  360. // 显示搜索条件
  361. showSearch: true,
  362. // 总条数
  363. total: 0,
  364. ttotal:0,
  365. vtotal:0,
  366. // 验证任务表格数据
  367. taskList: [],
  368. // 弹出层标题
  369. title: "",
  370. // 是否显示弹出层
  371. open: false,
  372. // 查询参数
  373. queryParams: {
  374. pageNum: 1,
  375. pageSize: 10,
  376. taskName: null,
  377. taskStatus: null,
  378. subtaskNum: null,
  379. startTime: null,
  380. endTime: null,
  381. progress: null,
  382. accuracyRate: null,
  383. recallRate: null,
  384. },
  385. // 表单参数
  386. form: {},
  387. // 表单校验
  388. rules: {
  389. },
  390. // 导入参数
  391. upload: {
  392. // 是否显示弹出层(导入)
  393. open: false,
  394. // 弹出层标题(导入)
  395. title: "",
  396. // 是否禁用上传
  397. isUploading: false,
  398. // 是否更新已经存在的用户数据
  399. updateSupport: 0,
  400. // 设置上传的请求头部
  401. headers: { Authorization: "Bearer " + getToken() },
  402. // 上传的地址
  403. url: process.env.VUE_APP_BASE_API + "/biz/detail/importData"
  404. },
  405. traindatavisible:false,
  406. verificationdatavisible:false,
  407. traindataset:[],
  408. verificationdataset:[],
  409. ProgressMap: [],
  410. taskidToIndexMap: new Map(),
  411. verificationtabledata:[],
  412. progressStatus:'',
  413. };
  414. },
  415. created() {
  416. this.getList();
  417. },
  418. // computed: {
  419. // progressStatus() {
  420. // return this.Progress === 100 ? 'success' : '';
  421. // },
  422. // },
  423. methods: {
  424. gettraindata(){
  425. getTraindataset().then(res=>{
  426. this.traindatavisible = true
  427. // console.log(res)
  428. this.tloading = false
  429. this.ttotal = res.total;
  430. this.traindataset = res.rows
  431. })
  432. },
  433. getverificationdata(){
  434. getUpdatedDetails(this.ids).then(res=>{
  435. this.verificationdatavisible = true
  436. this.verificationtabledata = res.rows
  437. this.vloading = false
  438. this.vtotal = res.total;
  439. })
  440. },
  441. handleRun() {
  442. if(this.ids.length>1) {
  443. this.$modal.msg("不能选择多个任务!")
  444. return ;
  445. }
  446. if(this.ids.length===0){
  447. this.$modal.msg("请先选中验证任务!")
  448. return ;
  449. }
  450. this.progresstitle = "验证任务"+this.ids[0]+"运行"
  451. this.progressStatus = ''
  452. this.dialogVisible = true
  453. let taskids = this.ids;
  454. const dayjs = require('dayjs');
  455. for (let taskid of taskids) {
  456. let index = this.taskidToIndexMap.get(taskid)
  457. getTask(taskid).then(response => {
  458. let task = response.data;
  459. task.startTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
  460. let code = 0;
  461. this.ProgressMap[index] = 0;
  462. verification(taskid).then(res => {
  463. console.log(res);
  464. code = res.code;
  465. if (res.code === 200) {
  466. this.verificationdataset = JSON.parse(res.data).dataSet;
  467. //更新任务详情表
  468. updateDetails(this.verificationdataset).then(res1=>{
  469. console.log(res1.msg)
  470. })
  471. // console.log(this.verificationdataset)
  472. task.accuracyRate = res.data.accuracyRate
  473. task.recallRate = res.data.recallRate
  474. task.endTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
  475. task.taskStatus = '运行成功';
  476. task.progress = 100;
  477. //这里需要更新数据库task
  478. updateTask(task).then(res2=>{
  479. console.log(res2.msg)
  480. })
  481. }
  482. });
  483. // 使用闭包确保每个循环迭代中创建一个新的 taskid
  484. const createInterval = (taskId) => {
  485. // 模拟进度变化,每0.1秒更新一次,共更新100次
  486. const intervalId = setInterval(() => {
  487. let idx = this.taskidToIndexMap.get(taskId)
  488. // this.ProgressMap[index] = this.ProgressMap[index] + 1
  489. this.$set(this.ProgressMap, idx, this.ProgressMap[idx] + 1);
  490. if(code!==200&&code!==0){
  491. clearInterval(intervalId);
  492. this.$message.error('任务' + taskId + '运行失败!');
  493. }
  494. // 如果进度达到100%,清除定时器并调用后端算法
  495. if (this.ProgressMap[idx] >= 100) {
  496. this.$set(this.ProgressMap, idx, 0);
  497. clearInterval(intervalId);
  498. this.progressStatus = 'success'
  499. this.dialogVisible = false
  500. if(code===200){
  501. this.$message.success('任务' + taskId + '运行成功!');
  502. this.getList();
  503. }
  504. }
  505. }, 100);
  506. };
  507. // 调用闭包函数,传入当前的 taskid
  508. createInterval(taskid);
  509. });
  510. }
  511. },
  512. /** 查询验证任务列表 */
  513. getList() {
  514. this.loading = true;
  515. listTask(this.queryParams).then(response => {
  516. this.taskList = response.rows;
  517. let task;
  518. let idx = 0;
  519. for(task of this.taskList){
  520. this.taskidToIndexMap.set(task.id, idx)
  521. // this.ProgressMap.push(task.progress)
  522. this.ProgressMap.push(0)
  523. idx++;
  524. }
  525. this.total = response.total;
  526. this.loading = false;
  527. });
  528. },
  529. // 取消按钮
  530. cancel() {
  531. this.open = false;
  532. this.reset();
  533. },
  534. // 表单重置
  535. reset() {
  536. this.form = {
  537. id: null,
  538. taskName: null,
  539. taskStatus: null,
  540. subtaskNum: null,
  541. startTime: null,
  542. endTime: null,
  543. progress: null,
  544. accuracyRate: null,
  545. recallRate: null,
  546. createBy: null,
  547. createTime: null,
  548. updateBy: null,
  549. updateTime: null,
  550. remark: null
  551. };
  552. this.resetForm("form");
  553. },
  554. /** 搜索按钮操作 */
  555. handleQuery() {
  556. this.queryParams.pageNum = 1;
  557. this.getList();
  558. },
  559. /** 重置按钮操作 */
  560. resetQuery() {
  561. this.resetForm("queryForm");
  562. this.handleQuery();
  563. },
  564. // 多选框选中数据
  565. handleSelectionChange(selection) {
  566. this.ids = selection.map(item => item.id)
  567. this.single = selection.length!==1
  568. this.multiple = !selection.length
  569. },
  570. /** 新增按钮操作 */
  571. handleAdd() {
  572. this.reset();
  573. this.open = true;
  574. this.title = "添加验证任务";
  575. },
  576. /** 修改按钮操作 */
  577. handleUpdate(row) {
  578. this.reset();
  579. const id = row.id || this.ids
  580. getTask(id).then(response => {
  581. this.form = response.data;
  582. this.open = true;
  583. this.title = "修改验证任务";
  584. });
  585. },
  586. /** 提交按钮 */
  587. submitForm() {
  588. this.$refs["form"].validate(valid => {
  589. if (valid) {
  590. if (this.form.id != null) {
  591. updateTask(this.form).then(response => {
  592. this.$modal.msgSuccess("修改成功");
  593. this.open = false;
  594. this.getList();
  595. });
  596. } else {
  597. addTask(this.form).then(response => {
  598. this.$modal.msgSuccess("新增成功");
  599. this.open = false;
  600. this.getList();
  601. });
  602. }
  603. }
  604. });
  605. },
  606. /** 删除按钮操作 */
  607. handleDelete(row) {
  608. const ids = row.id || this.ids;
  609. this.$modal.confirm('是否确认删除验证任务编号为"' + ids + '"的数据项?').then(function() {
  610. return delTask(ids);
  611. }).then(() => {
  612. this.getList();
  613. this.$modal.msgSuccess("删除成功");
  614. }).catch(() => {});
  615. },
  616. /** 导出按钮操作 */
  617. handleExport() {
  618. if(this.ids.length===0) {
  619. this.importTemplate()
  620. }else {
  621. // this.download('biz/detail/export', this.ids, `taskdetail_${new Date().getTime()}.xlsx`)
  622. let downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
  623. let taskids = this.ids;
  624. return service.post('biz/detail/export', taskids, {
  625. headers: { 'Content-Type': 'application/json' },
  626. responseType: 'blob',
  627. }).then(async (data) => {
  628. // Debug: 输出实际的响应 Content-Type
  629. // console.log(data)
  630. // console.log("Response Content-Type:", data.type);
  631. const isBlob = (data.type !== 'application/json');
  632. if (isBlob) {
  633. const blob = new Blob([data])
  634. saveAs(blob, `taskdetail_${new Date().getTime()}.xlsx`)
  635. } else {
  636. const resText = await data.text();
  637. const rspObj = JSON.parse(resText);
  638. const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
  639. Message.error(errMsg);
  640. }
  641. downloadLoadingInstance.close();
  642. }).catch((error) => {
  643. console.error(error)
  644. Message.error('下载文件出现错误,请联系管理员!')
  645. downloadLoadingInstance.close();
  646. })
  647. }
  648. },
  649. /** 导入按钮操作 */
  650. handleImport() {
  651. this.upload.title = "任务详情导入";
  652. this.upload.open = true;
  653. },
  654. /** 下载模板操作 */
  655. importTemplate() {
  656. this.download('biz/detail/importTemplate', {
  657. }, `taskdetail_template_${new Date().getTime()}.xlsx`)
  658. },
  659. // 文件上传中处理
  660. handleFileUploadProgress(event, file, fileList) {
  661. this.upload.isUploading = true;
  662. },
  663. // 文件上传成功处理
  664. handleFileSuccess(response, file, fileList) {
  665. this.upload.open = false;
  666. this.upload.isUploading = false;
  667. this.$refs.upload.clearFiles();
  668. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  669. this.getList();
  670. },
  671. // 提交上传文件
  672. submitFileForm() {
  673. this.$refs.upload.submit();
  674. }
  675. }
  676. };
  677. </script>
  678. <style>
  679. .el-checkbox__inner {
  680. border-color: #8492a6 !important;
  681. }
  682. .app-container {
  683. min-height: 100vh;
  684. background: radial-gradient(circle at 10% 20%, #3A71A8 0%, rgb(239, 249, 249) 90%);
  685. }
  686. </style>