index.vue 8.8 KB

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