index.vue 11 KB

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