index.vue 11 KB

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