index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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="algorithmName">
  5. <el-input
  6. v-model="queryParams.algorithmName"
  7. placeholder="请输入算法名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="算法类型" prop="algorithmType">
  13. <el-select v-model="queryParams.algorithmType" placeholder="请选择算法类型" clearable>
  14. <el-option
  15. v-for="dict in dict.type.sys_job_status"
  16. :key="dict.value"
  17. :label="dict.label"
  18. :value="dict.value"
  19. />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. plain
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. v-hasPermi="['biz:config:add']"
  36. >新增</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. v-hasPermi="['biz:config:edit']"
  47. >修改</el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. plain
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. v-hasPermi="['biz:config:remove']"
  58. >删除</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. plain
  64. icon="el-icon-download"
  65. size="mini"
  66. @click="handleExport"
  67. v-hasPermi="['biz:config:export']"
  68. >导出</el-button>
  69. </el-col>
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center" />
  74. <el-table-column label="编号" align="center" prop="id" />
  75. <el-table-column label="算法名称" align="center" prop="algorithmName" />
  76. <el-table-column label="算法类型" align="center" prop="algorithmType">
  77. <template slot-scope="scope">
  78. <dict-tag :options="dict.type.sys_job_status" :value="scope.row.algorithmType"/>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="备注" align="center" prop="remark" />
  82. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  83. <template slot-scope="scope">
  84. <el-button
  85. size="mini"
  86. type="text"
  87. icon="el-icon-edit"
  88. @click="handleUpdate(scope.row)"
  89. v-hasPermi="['biz:config:edit']"
  90. >修改</el-button>
  91. <el-button
  92. size="mini"
  93. type="text"
  94. icon="el-icon-delete"
  95. @click="handleDelete(scope.row)"
  96. v-hasPermi="['biz:config:remove']"
  97. >删除</el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <pagination
  102. v-show="total>0"
  103. :total="total"
  104. :page.sync="queryParams.pageNum"
  105. :limit.sync="queryParams.pageSize"
  106. @pagination="getList"
  107. />
  108. <!-- 添加或修改算法配置对话框 -->
  109. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  110. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  111. <el-form-item label="算法名称" prop="algorithmName">
  112. <el-input v-model="form.algorithmName" placeholder="请输入算法名称" />
  113. </el-form-item>
  114. <el-form-item label="算法类型" prop="algorithmType">
  115. <el-select v-model="form.algorithmType" placeholder="请选择算法类型">
  116. <el-option
  117. v-for="dict in dict.type.sys_job_status"
  118. :key="dict.value"
  119. :label="dict.label"
  120. :value="dict.value"
  121. ></el-option>
  122. </el-select>
  123. </el-form-item>
  124. <el-form-item label="算法参数" prop="algorithmParams">
  125. <el-input v-model="form.algorithmParams" type="textarea" placeholder="请输入内容" />
  126. </el-form-item>
  127. <el-form-item label="备注" prop="remark">
  128. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  129. </el-form-item>
  130. </el-form>
  131. <div slot="footer" class="dialog-footer">
  132. <el-button type="primary" @click="submitForm">确 定</el-button>
  133. <el-button @click="cancel">取 消</el-button>
  134. </div>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import { listConfig, getConfig, delConfig, addConfig, updateConfig } from "@/api/biz/config";
  140. export default {
  141. name: "Config",
  142. dicts: ['sys_job_status'],
  143. data() {
  144. return {
  145. // 遮罩层
  146. loading: true,
  147. // 选中数组
  148. ids: [],
  149. // 非单个禁用
  150. single: true,
  151. // 非多个禁用
  152. multiple: true,
  153. // 显示搜索条件
  154. showSearch: true,
  155. // 总条数
  156. total: 0,
  157. // 算法配置表格数据
  158. configList: [],
  159. // 弹出层标题
  160. title: "",
  161. // 是否显示弹出层
  162. open: false,
  163. // 查询参数
  164. queryParams: {
  165. pageNum: 1,
  166. pageSize: 10,
  167. algorithmName: null,
  168. algorithmType: null,
  169. },
  170. // 表单参数
  171. form: {},
  172. // 表单校验
  173. rules: {
  174. }
  175. };
  176. },
  177. created() {
  178. this.getList();
  179. },
  180. methods: {
  181. /** 查询算法配置列表 */
  182. getList() {
  183. this.loading = true;
  184. listConfig(this.queryParams).then(response => {
  185. this.configList = response.rows;
  186. this.total = response.total;
  187. this.loading = false;
  188. });
  189. },
  190. // 取消按钮
  191. cancel() {
  192. this.open = false;
  193. this.reset();
  194. },
  195. // 表单重置
  196. reset() {
  197. this.form = {
  198. id: null,
  199. algorithmName: null,
  200. algorithmType: null,
  201. algorithmParams: null,
  202. remark: null,
  203. createBy: null,
  204. createTime: null,
  205. updateBy: null,
  206. updateTime: null
  207. };
  208. this.resetForm("form");
  209. },
  210. /** 搜索按钮操作 */
  211. handleQuery() {
  212. this.queryParams.pageNum = 1;
  213. this.getList();
  214. },
  215. /** 重置按钮操作 */
  216. resetQuery() {
  217. this.resetForm("queryForm");
  218. this.handleQuery();
  219. },
  220. // 多选框选中数据
  221. handleSelectionChange(selection) {
  222. this.ids = selection.map(item => item.id)
  223. this.single = selection.length!==1
  224. this.multiple = !selection.length
  225. },
  226. /** 新增按钮操作 */
  227. handleAdd() {
  228. this.reset();
  229. this.open = true;
  230. this.title = "添加算法配置";
  231. },
  232. /** 修改按钮操作 */
  233. handleUpdate(row) {
  234. this.reset();
  235. const id = row.id || this.ids
  236. getConfig(id).then(response => {
  237. this.form = response.data;
  238. this.open = true;
  239. this.title = "修改算法配置";
  240. });
  241. },
  242. /** 提交按钮 */
  243. submitForm() {
  244. this.$refs["form"].validate(valid => {
  245. if (valid) {
  246. if (this.form.id != null) {
  247. updateConfig(this.form).then(response => {
  248. this.$modal.msgSuccess("修改成功");
  249. this.open = false;
  250. this.getList();
  251. });
  252. } else {
  253. addConfig(this.form).then(response => {
  254. this.$modal.msgSuccess("新增成功");
  255. this.open = false;
  256. this.getList();
  257. });
  258. }
  259. }
  260. });
  261. },
  262. /** 删除按钮操作 */
  263. handleDelete(row) {
  264. const ids = row.id || this.ids;
  265. this.$modal.confirm('是否确认删除算法配置编号为"' + ids + '"的数据项?').then(function() {
  266. return delConfig(ids);
  267. }).then(() => {
  268. this.getList();
  269. this.$modal.msgSuccess("删除成功");
  270. }).catch(() => {});
  271. },
  272. /** 导出按钮操作 */
  273. handleExport() {
  274. this.download('biz/config/export', {
  275. ...this.queryParams
  276. }, `config_${new Date().getTime()}.xlsx`)
  277. }
  278. }
  279. };
  280. </script>