index.vue 11 KB

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