index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="参数名称" prop="configName">
  5. <el-input
  6. v-model="queryParams.configName"
  7. placeholder="请输入参数名称"
  8. clearable
  9. size="small"
  10. style="width: 240px"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item label="参数键名" prop="configKey">
  15. <el-input
  16. v-model="queryParams.configKey"
  17. placeholder="请输入参数键名"
  18. clearable
  19. size="small"
  20. style="width: 240px"
  21. @keyup.enter.native="handleQuery"
  22. />
  23. </el-form-item>
  24. <el-form-item label="系统内置" prop="configType">
  25. <el-select v-model="queryParams.configType" placeholder="系统内置" clearable size="small">
  26. <el-option
  27. v-for="dict in dict.type.sys_yes_no"
  28. :key="dict.value"
  29. :label="dict.label"
  30. :value="dict.value"
  31. />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="创建时间">
  35. <el-date-picker
  36. v-model="dateRange"
  37. size="small"
  38. style="width: 240px"
  39. value-format="yyyy-MM-dd"
  40. type="daterange"
  41. range-separator="-"
  42. start-placeholder="开始日期"
  43. end-placeholder="结束日期"
  44. ></el-date-picker>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  48. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  49. </el-form-item>
  50. </el-form>
  51. <el-row :gutter="10" class="mb8">
  52. <el-col :span="1.5">
  53. <el-button
  54. type="primary"
  55. plain
  56. icon="el-icon-plus"
  57. size="mini"
  58. @click="handleAdd"
  59. v-hasPermi="['system:config:add']"
  60. >新增</el-button>
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-button
  64. type="success"
  65. plain
  66. icon="el-icon-edit"
  67. size="mini"
  68. :disabled="single"
  69. @click="handleUpdate"
  70. v-hasPermi="['system:config:edit']"
  71. >修改</el-button>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-button
  75. type="danger"
  76. plain
  77. icon="el-icon-delete"
  78. size="mini"
  79. :disabled="multiple"
  80. @click="handleDelete"
  81. v-hasPermi="['system:config:remove']"
  82. >删除</el-button>
  83. </el-col>
  84. <el-col :span="1.5">
  85. <el-button
  86. type="warning"
  87. plain
  88. icon="el-icon-download"
  89. size="mini"
  90. :loading="exportLoading"
  91. @click="handleExport"
  92. v-hasPermi="['system:config:export']"
  93. >导出</el-button>
  94. </el-col>
  95. <el-col :span="1.5">
  96. <el-button
  97. type="danger"
  98. plain
  99. icon="el-icon-refresh"
  100. size="mini"
  101. @click="handleRefreshCache"
  102. v-hasPermi="['system:config:remove']"
  103. >刷新缓存</el-button>
  104. </el-col>
  105. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  106. </el-row>
  107. <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
  108. <el-table-column type="selection" width="55" align="center" />
  109. <el-table-column label="参数主键" align="center" prop="configId" />
  110. <el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" />
  111. <el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" />
  112. <el-table-column label="参数键值" align="center" prop="configValue" />
  113. <el-table-column label="系统内置" align="center" prop="configType">
  114. <template slot-scope="scope">
  115. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.configType"/>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
  119. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  120. <template slot-scope="scope">
  121. <span>{{ parseTime(scope.row.createTime) }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  125. <template slot-scope="scope">
  126. <el-button
  127. size="mini"
  128. type="text"
  129. icon="el-icon-edit"
  130. @click="handleUpdate(scope.row)"
  131. v-hasPermi="['system:config:edit']"
  132. >修改</el-button>
  133. <el-button
  134. size="mini"
  135. type="text"
  136. icon="el-icon-delete"
  137. @click="handleDelete(scope.row)"
  138. v-hasPermi="['system:config:remove']"
  139. >删除</el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <pagination
  144. v-show="total>0"
  145. :total="total"
  146. :page.sync="queryParams.pageNum"
  147. :limit.sync="queryParams.pageSize"
  148. @pagination="getList"
  149. />
  150. <!-- 添加或修改参数配置对话框 -->
  151. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  152. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  153. <el-form-item label="参数名称" prop="configName">
  154. <el-input v-model="form.configName" placeholder="请输入参数名称" />
  155. </el-form-item>
  156. <el-form-item label="参数键名" prop="configKey">
  157. <el-input v-model="form.configKey" placeholder="请输入参数键名" />
  158. </el-form-item>
  159. <el-form-item label="参数键值" prop="configValue">
  160. <el-input v-model="form.configValue" placeholder="请输入参数键值" />
  161. </el-form-item>
  162. <el-form-item label="系统内置" prop="configType">
  163. <el-radio-group v-model="form.configType">
  164. <el-radio
  165. v-for="dict in dict.type.sys_yes_no"
  166. :key="dict.value"
  167. :label="dict.value"
  168. >{{dict.label}}</el-radio>
  169. </el-radio-group>
  170. </el-form-item>
  171. <el-form-item label="备注" prop="remark">
  172. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  173. </el-form-item>
  174. </el-form>
  175. <div slot="footer" class="dialog-footer">
  176. <el-button type="primary" @click="submitForm">确 定</el-button>
  177. <el-button @click="cancel">取 消</el-button>
  178. </div>
  179. </el-dialog>
  180. </div>
  181. </template>
  182. <script>
  183. import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, refreshCache } from "@/api/system/config";
  184. export default {
  185. name: "Config",
  186. dicts: ['sys_yes_no'],
  187. data() {
  188. return {
  189. // 遮罩层
  190. loading: true,
  191. // 导出遮罩层
  192. exportLoading: false,
  193. // 选中数组
  194. ids: [],
  195. // 非单个禁用
  196. single: true,
  197. // 非多个禁用
  198. multiple: true,
  199. // 显示搜索条件
  200. showSearch: true,
  201. // 总条数
  202. total: 0,
  203. // 参数表格数据
  204. configList: [],
  205. // 弹出层标题
  206. title: "",
  207. // 是否显示弹出层
  208. open: false,
  209. // 日期范围
  210. dateRange: [],
  211. // 查询参数
  212. queryParams: {
  213. pageNum: 1,
  214. pageSize: 10,
  215. configName: undefined,
  216. configKey: undefined,
  217. configType: undefined
  218. },
  219. // 表单参数
  220. form: {},
  221. // 表单校验
  222. rules: {
  223. configName: [
  224. { required: true, message: "参数名称不能为空", trigger: "blur" }
  225. ],
  226. configKey: [
  227. { required: true, message: "参数键名不能为空", trigger: "blur" }
  228. ],
  229. configValue: [
  230. { required: true, message: "参数键值不能为空", trigger: "blur" }
  231. ]
  232. }
  233. };
  234. },
  235. created() {
  236. this.getList();
  237. },
  238. methods: {
  239. /** 查询参数列表 */
  240. getList() {
  241. this.loading = true;
  242. listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  243. this.configList = response.rows;
  244. this.total = response.total;
  245. this.loading = false;
  246. }
  247. );
  248. },
  249. // 取消按钮
  250. cancel() {
  251. this.open = false;
  252. this.reset();
  253. },
  254. // 表单重置
  255. reset() {
  256. this.form = {
  257. configId: undefined,
  258. configName: undefined,
  259. configKey: undefined,
  260. configValue: undefined,
  261. configType: "Y",
  262. remark: undefined
  263. };
  264. this.resetForm("form");
  265. },
  266. /** 搜索按钮操作 */
  267. handleQuery() {
  268. this.queryParams.pageNum = 1;
  269. this.getList();
  270. },
  271. /** 重置按钮操作 */
  272. resetQuery() {
  273. this.dateRange = [];
  274. this.resetForm("queryForm");
  275. this.handleQuery();
  276. },
  277. /** 新增按钮操作 */
  278. handleAdd() {
  279. this.reset();
  280. this.open = true;
  281. this.title = "添加参数";
  282. },
  283. // 多选框选中数据
  284. handleSelectionChange(selection) {
  285. this.ids = selection.map(item => item.configId)
  286. this.single = selection.length!=1
  287. this.multiple = !selection.length
  288. },
  289. /** 修改按钮操作 */
  290. handleUpdate(row) {
  291. this.reset();
  292. const configId = row.configId || this.ids
  293. getConfig(configId).then(response => {
  294. this.form = response.data;
  295. this.open = true;
  296. this.title = "修改参数";
  297. });
  298. },
  299. /** 提交按钮 */
  300. submitForm: function() {
  301. this.$refs["form"].validate(valid => {
  302. if (valid) {
  303. if (this.form.configId != undefined) {
  304. updateConfig(this.form).then(response => {
  305. this.$modal.msgSuccess("修改成功");
  306. this.open = false;
  307. this.getList();
  308. });
  309. } else {
  310. addConfig(this.form).then(response => {
  311. this.$modal.msgSuccess("新增成功");
  312. this.open = false;
  313. this.getList();
  314. });
  315. }
  316. }
  317. });
  318. },
  319. /** 删除按钮操作 */
  320. handleDelete(row) {
  321. const configIds = row.configId || this.ids;
  322. this.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function() {
  323. return delConfig(configIds);
  324. }).then(() => {
  325. this.getList();
  326. this.$modal.msgSuccess("删除成功");
  327. }).catch(() => {});
  328. },
  329. /** 导出按钮操作 */
  330. handleExport() {
  331. const queryParams = this.queryParams;
  332. this.$modal.confirm('是否确认导出所有参数数据项?').then(() => {
  333. this.exportLoading = true;
  334. return exportConfig(queryParams);
  335. }).then(response => {
  336. this.$download.name(response.msg);
  337. this.exportLoading = false;
  338. }).catch(() => {});
  339. },
  340. /** 刷新缓存按钮操作 */
  341. handleRefreshCache() {
  342. refreshCache().then(() => {
  343. this.$modal.msgSuccess("刷新成功");
  344. });
  345. }
  346. }
  347. };
  348. </script>