index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="100px"
  10. >
  11. <el-form-item label="任务名称" prop="name">
  12. <el-input
  13. v-model="queryParams.name"
  14. placeholder="请输入任务名称"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button
  21. type="primary"
  22. icon="el-icon-search"
  23. size="mini"
  24. @click="handleQuery"
  25. >搜索</el-button>
  26. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">
  27. 重置
  28. </el-button>
  29. </el-form-item>
  30. </el-form>
  31. <el-row :gutter="10" class="mb8">
  32. <el-col :span="1.5">
  33. <el-button
  34. type="primary"
  35. plain
  36. icon="el-icon-plus"
  37. size="mini"
  38. @click="handleAdd"
  39. v-hasPermi="['test:ddAlgorithm:add']"
  40. >
  41. 新增
  42. </el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button
  46. type="success"
  47. plain
  48. icon="el-icon-edit"
  49. size="mini"
  50. :disabled="single"
  51. v-hasPermi="['test:ddAlgorithm:edit']"
  52. >
  53. 修改
  54. </el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button
  58. type="danger"
  59. plain
  60. icon="el-icon-delete"
  61. size="mini"
  62. :disabled="multiple"
  63. @click="handleDelete(ids)"
  64. v-hasPermi="['test:ddAlgorithm:remove']"
  65. >
  66. 删除
  67. </el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="warning"
  72. plain
  73. icon="el-icon-download"
  74. size="mini"
  75. @click="handleExport"
  76. v-hasPermi="['test:ddAlgorithm:export']"
  77. >
  78. 导出
  79. </el-button>
  80. </el-col>
  81. <right-toolbar
  82. :showSearch.sync="showSearch"
  83. @queryTable="getList"
  84. ></right-toolbar>
  85. </el-row>
  86. <el-table
  87. v-loading="loading"
  88. :data="ddAlgorithmList"
  89. @selection-change="handleSelectionChange"
  90. >
  91. <el-table-column type="selection" width="55" align="center" />
  92. <el-table-column label="任务名称" align="center" prop="name" />
  93. <el-table-column label="文本结果" align="center" prop="returnData">
  94. <template slot-scope="scope">
  95. <el-input type="textarea" disabled v-model="scope.row.returnData" />
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="模型类型" align="center" prop="modelType">
  99. <template slot-scope="scope">
  100. <dict-tag
  101. :options="dict.type.biz_model_type"
  102. :value="scope.row.modelType"
  103. />
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="模型种类" align="center" prop="modelTypet">
  107. <template slot-scope="scope">
  108. <dict-tag
  109. :options="dict.type.model_tepe_t"
  110. :value="scope.row.modelTypet"
  111. />
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="说明" align="center" prop="remark" />
  115. <el-table-column
  116. label="开始时间"
  117. align="center"
  118. prop="startTime"
  119. width="180"
  120. >
  121. <template slot-scope="scope">
  122. <span>{{ scope.row.startTime }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column
  126. label="结束时间"
  127. align="center"
  128. prop="startTime"
  129. width="180"
  130. >
  131. <template slot-scope="scope">
  132. <span>{{ scope.row.endTime }}</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. label="操作"
  137. align="center"
  138. class-name="small-padding fixed-width"
  139. >
  140. <template slot-scope="scope">
  141. <el-button
  142. size="mini"
  143. type="text"
  144. icon="el-icon-video-play"
  145. @click="handleVerify(scope.row)"
  146. v-hasPermi="['test:ddAlgorithm:edit']"
  147. >
  148. 查看
  149. </el-button>
  150. <el-button
  151. size="mini"
  152. type="text"
  153. icon="el-icon-delete"
  154. @click="handleDelete(scope.row)"
  155. v-hasPermi="['test:ddAlgorithm:remove']"
  156. >
  157. 删除
  158. </el-button>
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. <pagination
  163. v-show="total > 0"
  164. :total="total"
  165. :page.sync="queryParams.pageNum"
  166. :limit.sync="queryParams.pageSize"
  167. @pagination="getList"
  168. />
  169. <!-- 新增:验证对话框 -->
  170. <el-dialog
  171. :title="!returnDataShow ? '验证配置' : '验证结果'"
  172. :visible.sync="verifyDialogVisible"
  173. width="1100px"
  174. append-to-body
  175. destroy-on-close
  176. @close="handleDialogClose"
  177. >
  178. <el-form :model="verifyRow" label-width="80px">
  179. <el-form-item label="验证结果">
  180. <template>
  181. <el-row :gutter="5">
  182. <el-col
  183. v-for="(url, index) in verifyRow.imageData"
  184. :key="index"
  185. :span="11"
  186. >
  187. <el-image
  188. :src="url"
  189. :preview-src-list="[url]"
  190. style="width: 95%; height: 150px;"
  191. ></el-image>
  192. </el-col>
  193. </el-row>
  194. </template>
  195. </el-form-item>
  196. </el-form>
  197. <div slot="footer" class="dialog-footer">
  198. <el-button v-if="!returnDataShow" @click="verifyDialogVisible = false">
  199. 关闭
  200. </el-button>
  201. <el-button v-if="returnDataShow" @click="handleDialogClose">
  202. 关闭
  203. </el-button>
  204. </div>
  205. </el-dialog>
  206. <DdAlgorithmForm
  207. v-model="open"
  208. :data-info="form"
  209. :options="options"
  210. :data-options="dataOptions"
  211. :fault-diagnosis-options="faultDiagnosisOptions"
  212. @callback="getList"
  213. />
  214. </div>
  215. </template>
  216. <script>
  217. import {
  218. listDdAlgorithm,
  219. getDdAlgorithm,
  220. delDdAlgorithm,
  221. verify,
  222. } from "@/api/test/ddAlgorithm";
  223. import { listFormulas } from "@/api/eval/formulas";
  224. import { getDataOptions } from "@/api/data/data";
  225. import { getFaultDiagnosisOptions } from "@/api/model/faultDiagnosis";
  226. import DdAlgorithmForm from "./form.vue";
  227. import txtContent from "@/assets/testImage/output3.txt";
  228. import info from "./info.vue";
  229. export default {
  230. name: "DdAlgorithm",
  231. components: {
  232. DdAlgorithmForm,
  233. info,
  234. },
  235. dicts: ["biz_model_type", "biz_perf_eval_type", "model_tepe_t"],
  236. data() {
  237. return {
  238. verifyDialogVisible: false,
  239. verifyRow: {
  240. verifyData: null, // 所属指标(单选)
  241. imageData: [], // 图片数据
  242. },
  243. returnDataShow: false,
  244. loading: true,
  245. ids: [],
  246. single: true,
  247. multiple: true,
  248. showSearch: true,
  249. total: 0,
  250. ddAlgorithmList: [],
  251. open: false,
  252. queryParams: {
  253. pageNum: 1,
  254. pageSize: 10,
  255. name: null,
  256. truthLabels: null,
  257. testLabels: null,
  258. startTime: null,
  259. endTime: null,
  260. },
  261. content: txtContent,
  262. form: {},
  263. options: "",
  264. dataOptions: [],
  265. faultDiagnosisOptions: [],
  266. };
  267. },
  268. created() {
  269. this.getList();
  270. this.getOption();
  271. },
  272. methods: {
  273. handleVerify(row) {
  274. console.log('row', this.row)
  275. // 初始化验证数据(清空上次选择)
  276. this.verifyRow = {
  277. verifyData: null, // 清空所属指标
  278. imageData: JSON.parse(row.returnDataImage || "[]"), // 解析图片数据
  279. };
  280. // 解析返回数据(如果存在)
  281. if (row.returnData) {
  282. try {
  283. const json = JSON.parse(row.returnData);
  284. // 这里假设returnData是单个对象,如有多个需调整
  285. this.verifyRow.tempData = json;
  286. } catch (error) {
  287. console.error("解析返回数据失败:", error);
  288. }
  289. }
  290. this.verifyDialogVisible = true;
  291. },
  292. handleDialogClose() {
  293. // 关闭对话框时清空验证指标
  294. this.verifyRow.verifyData = null;
  295. this.returnDataShow = false; // 隐藏结果
  296. // 可选:如需清空图片数据(根据业务需求)
  297. // this.verifyRow.imageData = [];
  298. },
  299. handleConfirmVerify() {
  300. // 执行验证逻辑
  301. console.log("开始验证,所选指标:", this.verifyRow.verifyData);
  302. this.$modal.msgSuccess("验证成功");
  303. // 模拟验证成功后显示结果
  304. this.returnDataShow = true;
  305. // 这里可以添加实际的API调用
  306. },
  307. getList() {
  308. this.loading = true;
  309. listDdAlgorithm(this.queryParams).then((response) => {
  310. this.ddAlgorithmList = response.rows;
  311. this.total = response.total;
  312. this.loading = false;
  313. });
  314. },
  315. getOption() {
  316. listFormulas().then((response) => {
  317. this.verifyOptions = response.rows;
  318. console.log("verifyOptions", response);
  319. });
  320. getDataOptions().then((resp) => {
  321. this.dataOptions = resp.data;
  322. });
  323. getFaultDiagnosisOptions().then((resp) => {
  324. this.faultDiagnosisOptions = resp.data;
  325. });
  326. },
  327. reset() {
  328. this.form = {
  329. id: null,
  330. name: null,
  331. modelId: null,
  332. dataId: null,
  333. truthLabels: null,
  334. testLabels: null,
  335. remark: null,
  336. startTime: null,
  337. endTime: null,
  338. createBy: null,
  339. createTime: null,
  340. updateBy: null,
  341. updateTime: null,
  342. };
  343. this.resetForm("form");
  344. },
  345. handleQuery() {
  346. this.queryParams.pageNum = 1;
  347. this.getList();
  348. },
  349. resetQuery() {
  350. this.resetForm("queryForm");
  351. this.handleQuery();
  352. },
  353. handleSelectionChange(selection) {
  354. this.ids = selection.map((item) => item.id);
  355. this.single = selection.length !== 1;
  356. this.multiple = !selection.length;
  357. },
  358. handleAdd() {
  359. this.reset();
  360. this.open = true;
  361. this.options = "add";
  362. },
  363. handleUpdate(row) {
  364. this.reset();
  365. const id = row.id || this.ids;
  366. getDdAlgorithm(id).then((response) => {
  367. this.form = response.data;
  368. this.open = true;
  369. this.options = "edit";
  370. });
  371. },
  372. handleDelete(deleteTarget) {
  373. const deleteIds = Array.isArray(deleteTarget)
  374. ? deleteTarget
  375. : [deleteTarget.id || deleteTarget];
  376. const deleteNames = deleteIds
  377. .map((id) => this.ddAlgorithmList.find((row) => row.id === id)?.name || `ID:${id}`)
  378. .filter(Boolean);
  379. const confirmMessage =
  380. deleteNames.length > 1
  381. ? `是否确认删除以下 ${deleteNames.length} 条任务?\n${deleteNames.join("\n")}`
  382. : `是否确认删除任务:${deleteNames[0]}?`;
  383. this.$modal
  384. .confirm(confirmMessage)
  385. .then(() => delDdAlgorithm(deleteIds))
  386. .then(() => {
  387. this.getList();
  388. this.$modal.msgSuccess("删除成功");
  389. })
  390. .catch((error) => {
  391. console.error("删除失败:", error);
  392. this.$modal.msgError("删除失败,请检查网络或重试");
  393. });
  394. },
  395. handleExport() {
  396. this.download(
  397. "test/ddAlgorithm/export",
  398. {
  399. ...this.queryParams,
  400. },
  401. `ddAlgorithm_${new Date().getTime()}.xlsx`
  402. );
  403. },
  404. },
  405. };
  406. </script>