index.vue 10 KB

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