index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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="type">
  5. <el-select v-model="queryParams.type" placeholder="请选择算法类型" clearable filterable @change=changeQueryType()>
  6. <el-option
  7. v-for="dict in dict.type.algorithm_type"
  8. :key="dict.value"
  9. :label="dict.label"
  10. :value="dict.value"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="算法子类型" prop="subTypeId">
  15. <el-select
  16. v-model="queryParams.subTypeId"
  17. placeholder="请选择算法子类型"
  18. clearable
  19. filterable
  20. >
  21. <el-option
  22. v-for="item in algoTypeList"
  23. :key="item.id"
  24. :label="item.name"
  25. :value="item.id"
  26. >
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="名称" prop="name">
  31. <el-input
  32. v-model="queryParams.name"
  33. placeholder="请输入名称"
  34. clearable
  35. @keyup.enter.native="handleQuery"
  36. />
  37. </el-form-item>
  38. <!-- <el-form-item label="开始时间" prop="startTime">
  39. <el-date-picker clearable
  40. v-model="queryParams.startTime"
  41. type="date"
  42. value-format="yyyy-MM-dd"
  43. placeholder="请选择开始时间">
  44. </el-date-picker>
  45. </el-form-item>
  46. <el-form-item label="完成时间" prop="completedTime">
  47. <el-date-picker clearable
  48. v-model="queryParams.completedTime"
  49. type="date"
  50. value-format="yyyy-MM-dd"
  51. placeholder="请选择完成时间">
  52. </el-date-picker>
  53. </el-form-item>
  54. <el-form-item label="耗时(s)" prop="costSecond">
  55. <el-input
  56. v-model="queryParams.costSecond"
  57. placeholder="请输入耗时(s)"
  58. clearable
  59. @keyup.enter.native="handleQuery"
  60. />
  61. </el-form-item> -->
  62. <el-form-item>
  63. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  64. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  65. </el-form-item>
  66. </el-form>
  67. <el-row :gutter="10" class="mb8">
  68. <el-col :span="1.5">
  69. <el-button
  70. type="primary"
  71. plain
  72. icon="el-icon-plus"
  73. size="mini"
  74. @click="handleAdd"
  75. v-hasPermi="['algoManager:algorithm:add']"
  76. >新增</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="success"
  81. plain
  82. icon="el-icon-edit"
  83. size="mini"
  84. :disabled="single"
  85. @click="handleUpdate"
  86. v-hasPermi="['algoManager:algorithm:edit']"
  87. >修改</el-button>
  88. </el-col>
  89. <el-col :span="1.5">
  90. <el-button
  91. type="danger"
  92. plain
  93. icon="el-icon-delete"
  94. size="mini"
  95. :disabled="multiple"
  96. @click="handleDelete"
  97. v-hasPermi="['algoManager:algorithm:remove']"
  98. >删除</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. type="warning"
  103. plain
  104. icon="el-icon-download"
  105. size="mini"
  106. @click="handleExport"
  107. v-hasPermi="['algoManager:algorithm:export']"
  108. >导出</el-button>
  109. </el-col>
  110. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  111. </el-row>
  112. <el-table v-loading="loading" :data="algorithmList" @selection-change="handleSelectionChange">
  113. <el-table-column type="selection" width="55" align="center" />
  114. <el-table-column label="编号" align="center" prop="id" />
  115. <el-table-column label="算法类型" align="center" prop="type">
  116. <template slot-scope="scope">
  117. <dict-tag :options="dict.type.algorithm_type" :value="scope.row.type"/>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="算法子类型" align="center" prop="subTypeId" />
  121. <el-table-column label="名称" align="center" prop="name" />
  122. <el-table-column label="开始时间" align="center" prop="startTime" width="180">
  123. <template slot-scope="scope">
  124. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="完成时间" align="center" prop="completedTime" width="180">
  128. <template slot-scope="scope">
  129. <span>{{ parseTime(scope.row.completedTime, '{y}-{m}-{d}') }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="耗时(s)" align="center" prop="costSecond" />
  133. <el-table-column label="备注" align="center" prop="remark" />
  134. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  135. <template slot-scope="scope">
  136. <el-button
  137. size="mini"
  138. type="text"
  139. icon="el-icon-edit"
  140. @click="handleUpdate(scope.row)"
  141. v-hasPermi="['algoManager:algorithm:edit']"
  142. >修改</el-button>
  143. <el-button
  144. size="mini"
  145. type="text"
  146. icon="el-icon-delete"
  147. @click="handleDelete(scope.row)"
  148. v-hasPermi="['algoManager:algorithm:remove']"
  149. >删除</el-button>
  150. </template>
  151. </el-table-column>
  152. </el-table>
  153. <pagination
  154. v-show="total>0"
  155. :total="total"
  156. :page.sync="queryParams.pageNum"
  157. :limit.sync="queryParams.pageSize"
  158. @pagination="getList"
  159. />
  160. <!-- 添加或修改算法对话框 -->
  161. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  162. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  163. <el-form-item label="算法类型" prop="type">
  164. <el-select v-model="form.type" placeholder="请选择算法类型" clearable filterable @change='changeFormType()'>
  165. <el-option
  166. v-for="dict in dict.type.algorithm_type"
  167. :key="dict.value"
  168. :label="dict.label"
  169. :value="dict.value"
  170. ></el-option>
  171. </el-select>
  172. </el-form-item>
  173. <el-form-item label="算法子类型" prop="subTypeId">
  174. <el-select
  175. v-model="form.subTypeId"
  176. placeholder="请选择算法子类型"
  177. clearable
  178. filterable
  179. @change='changeFormSubType(form.subTypeId)'
  180. >
  181. <el-option
  182. v-for="item in algoTypeList"
  183. :key="item.id"
  184. :label="item.name"
  185. :value="item.id"
  186. >
  187. </el-option>
  188. </el-select>
  189. </el-form-item>
  190. <template v-if="form.subTypeId">
  191. <el-form-item v-for="item in ioSubList" :label="item.name" :key="item.id" prop="name">
  192. <file-upload v-model="form.path"/>
  193. </el-form-item>
  194. </template>
  195. <el-form-item label="备注" prop="remark">
  196. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  197. </el-form-item>
  198. </el-form>
  199. <div slot="footer" class="dialog-footer">
  200. <el-button type="primary" @click="submitForm">确 定</el-button>
  201. <el-button @click="cancel">取 消</el-button>
  202. </div>
  203. </el-dialog>
  204. </div>
  205. </template>
  206. <script>
  207. import { listAlgorithm, getAlgorithm, delAlgorithm, addAlgorithm, updateAlgorithm } from "@/api/algoManager/algorithm";
  208. import { getAlgoSubOption } from "@/api/algoManager/algorithm";
  209. import { getIoSubList } from "@/api/conf/field";
  210. export default {
  211. name: "Algorithm",
  212. dicts: ['algorithm_type'],
  213. data() {
  214. return {
  215. // 遮罩层
  216. loading: true,
  217. // 选中数组
  218. ids: [],
  219. // 非单个禁用
  220. single: true,
  221. // 非多个禁用
  222. multiple: true,
  223. // 显示搜索条件
  224. showSearch: true,
  225. // 总条数
  226. total: 0,
  227. // 算法表格数据
  228. algorithmList: [],
  229. // 算法子类列表
  230. algorithmSubList: [],
  231. // 算法特定类列表
  232. algoTypeList: [],
  233. // 具体算法输入输出文件列表
  234. ioSubList: [],
  235. // 弹出层标题
  236. title: "",
  237. // 是否显示弹出层
  238. open: false,
  239. // 查询参数
  240. queryParams: {
  241. pageNum: 1,
  242. pageSize: 10,
  243. type: null,
  244. subTypeId: null,
  245. name: null,
  246. startTime: null,
  247. completedTime: null,
  248. costSecond: null,
  249. },
  250. // 表单参数
  251. form: {},
  252. // 表单校验
  253. rules: {
  254. subTypeId: [
  255. { required: true, message: "算法子类型不能为空", trigger: "blur" }
  256. ],
  257. },
  258. typeMap: new Map(),
  259. };
  260. },
  261. created() {
  262. this.getList();
  263. this.getAlgoSubOption();
  264. },
  265. methods: {
  266. /** 查询算法列表 */
  267. getList() {
  268. this.loading = true;
  269. listAlgorithm(this.queryParams).then(response => {
  270. this.algorithmList = response.rows;
  271. this.total = response.total;
  272. this.loading = false;
  273. });
  274. },
  275. getAlgoSubOption() {
  276. getAlgoSubOption().then((resp) => {
  277. this.algorithmSubList = resp.data;
  278. this.createTypeMap();
  279. console.info(resp);
  280. });
  281. },
  282. // 取消按钮
  283. cancel() {
  284. this.open = false;
  285. this.reset();
  286. },
  287. // 表单重置
  288. reset() {
  289. this.form = {
  290. id: null,
  291. type: null,
  292. subTypeId: null,
  293. name: null,
  294. startTime: null,
  295. completedTime: null,
  296. costSecond: null,
  297. createBy: null,
  298. createTime: null,
  299. updateBy: null,
  300. updateTime: null,
  301. remark: null
  302. };
  303. this.resetForm("form");
  304. },
  305. /** 搜索按钮操作 */
  306. handleQuery() {
  307. this.queryParams.pageNum = 1;
  308. this.getList();
  309. },
  310. /** 重置按钮操作 */
  311. resetQuery() {
  312. this.resetForm("queryForm");
  313. this.handleQuery();
  314. },
  315. // 多选框选中数据
  316. handleSelectionChange(selection) {
  317. this.ids = selection.map(item => item.id)
  318. this.single = selection.length!==1
  319. this.multiple = !selection.length
  320. },
  321. /** 新增按钮操作 */
  322. handleAdd() {
  323. this.reset();
  324. this.open = true;
  325. this.title = "添加算法";
  326. },
  327. /** 修改按钮操作 */
  328. handleUpdate(row) {
  329. this.reset();
  330. const id = row.id || this.ids
  331. getAlgorithm(id).then(response => {
  332. this.form = response.data;
  333. this.open = true;
  334. this.title = "修改算法";
  335. });
  336. },
  337. /** 提交按钮 */
  338. submitForm() {
  339. this.$refs["form"].validate(valid => {
  340. if (valid) {
  341. if (this.form.id != null) {
  342. updateAlgorithm(this.form).then(response => {
  343. this.$modal.msgSuccess("修改成功");
  344. this.open = false;
  345. this.getList();
  346. });
  347. } else {
  348. addAlgorithm(this.form).then(response => {
  349. this.$modal.msgSuccess("新增成功");
  350. this.open = false;
  351. this.getList();
  352. });
  353. }
  354. }
  355. });
  356. },
  357. /** 删除按钮操作 */
  358. handleDelete(row) {
  359. const ids = row.id || this.ids;
  360. this.$modal.confirm('是否确认删除算法编号为"' + ids + '"的数据项?').then(function() {
  361. return delAlgorithm(ids);
  362. }).then(() => {
  363. this.getList();
  364. this.$modal.msgSuccess("删除成功");
  365. }).catch(() => {});
  366. },
  367. /** 导出按钮操作 */
  368. handleExport() {
  369. this.download('algoManager/algorithm/export', {
  370. ...this.queryParams
  371. }, `algorithm_${new Date().getTime()}.xlsx`)
  372. },
  373. createTypeMap() {
  374. for (const algorithmSub of this.algorithmSubList) {
  375. if(this.typeMap.has(algorithmSub.type)) {
  376. this.typeMap.get(algorithmSub.type).push({
  377. id: algorithmSub.id,
  378. name: algorithmSub.name
  379. });
  380. }
  381. else {
  382. this.typeMap.set(algorithmSub.type, [{
  383. id: algorithmSub.id,
  384. name: algorithmSub.name
  385. }]);
  386. }
  387. }
  388. },
  389. changeQueryType() {
  390. this.queryParams.subTypeId = null;
  391. this.algoTypeList = this.typeMap.get(this.queryParams.type);
  392. },
  393. changeFormType() {
  394. this.form.subTypeId = null;
  395. this.algoTypeList = this.typeMap.get(this.form.type);
  396. },
  397. changeFormSubType() {
  398. getIoSubList(this.form.subTypeId).then((resp) => {
  399. this.ioSubList = resp.data;
  400. console.info(resp);
  401. });
  402. },
  403. }
  404. };
  405. </script>