index.vue 11 KB

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