index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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="table-button-box">
  114. <p class="table-button-null"></p>
  115. <p class="table-button-p"
  116. @click="handleUpdate(scope.row)"
  117. v-hasPermi="['system:config:edit']"
  118. >编辑</p>
  119. <p class="table-button-p"
  120. @click="handleDelete(scope.row)"
  121. v-hasPermi="['system:config:remove']"
  122. >删除</p>
  123. <p class="table-button-null"></p>
  124. </div>
  125. </template>
  126. </el-table-column>
  127. </el-table>
  128. <pagination :page-sizes="[20, 30, 40, 50]"
  129. v-show="total>0"
  130. :total="total"
  131. layout="total, prev, pager, next, sizes, jumper"
  132. :page.sync="queryParams.pageNum"
  133. :limit.sync="queryParams.pageSize"
  134. @pagination="getList"
  135. />
  136. <!-- 添加或修改参数配置对话框 -->
  137. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false">
  138. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  139. <el-form-item label="参数名称" prop="configName">
  140. <el-input v-model="form.configName" placeholder="请输入参数名称" />
  141. </el-form-item>
  142. <el-form-item label="参数键名" prop="configKey">
  143. <el-input v-model="form.configKey" placeholder="请输入参数键名" />
  144. </el-form-item>
  145. <el-form-item label="参数键值" prop="configValue">
  146. <el-input v-model="form.configValue" placeholder="请输入参数键值" />
  147. </el-form-item>
  148. <el-form-item label="系统内置" prop="configType">
  149. <el-radio-group v-model="form.configType">
  150. <el-radio
  151. v-for="dict in typeOptions"
  152. :key="dict.dictValue"
  153. :label="dict.dictValue"
  154. >{{dict.dictLabel}}</el-radio>
  155. </el-radio-group>
  156. </el-form-item>
  157. <el-form-item label="备注" prop="remark">
  158. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  159. </el-form-item>
  160. </el-form>
  161. <div slot="footer" class="dialog-footer">
  162. <el-button @click="cancel">取 消</el-button>
  163. <el-button type="primary" @click="submitForm">确 定</el-button>
  164. </div>
  165. </el-dialog>
  166. </div>
  167. </template>
  168. <script>
  169. import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config";
  170. export default {
  171. name: "Config",
  172. data() {
  173. return {
  174. tableButtonType:this.hasPermiDom(['system:config:edit','system:config:remove']),
  175. // 遮罩层
  176. loading: true,
  177. // 选中数组
  178. ids: [],
  179. // 非单个禁用
  180. single: true,
  181. // 非多个禁用
  182. multiple: true,
  183. // 显示搜索条件
  184. showSearch: true,
  185. // 总条数
  186. total: 0,
  187. // 参数表格数据
  188. configList: [],
  189. // 弹出层标题
  190. title: "",
  191. // 是否显示弹出层
  192. open: false,
  193. // 类型数据字典
  194. typeOptions: [],
  195. // 日期范围
  196. dateRange: [],
  197. // 查询参数
  198. queryParams: {
  199. pageNum: 1,
  200. pageSize:20,
  201. configName: undefined,
  202. configKey: undefined,
  203. configType: undefined
  204. },
  205. // 表单参数
  206. form: {},
  207. // 表单校验
  208. rules: {
  209. configName: [
  210. { required: true, message: "参数名称不能为空", trigger: "blur" },
  211. { required: true, message: "参数名称不能为空", validator: this.spaceJudgment, trigger: "blur" }
  212. ],
  213. configKey: [
  214. { required: true, message: "参数键名不能为空", trigger: "blur" },
  215. { required: true, message: "参数键名不能为空", validator: this.spaceJudgment, trigger: "blur" }
  216. ],
  217. configValue: [
  218. { required: true, message: "参数键值不能为空", trigger: "blur" },
  219. { required: true, message: "参数键值不能为空", validator: this.spaceJudgment, trigger: "blur" }
  220. ]
  221. }
  222. };
  223. },
  224. created() {
  225. this.getList();
  226. this.getDicts("sys_yes_no").then(response => {
  227. this.typeOptions = response.data;
  228. });
  229. },
  230. methods: {
  231. /** 查询参数列表 */
  232. getList() {
  233. this.loading = true;
  234. listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  235. this.configList = response.rows;
  236. this.total = response.total;
  237. this.loading = false;
  238. }
  239. );
  240. },
  241. // 参数系统内置字典翻译
  242. typeFormat(row, column) {
  243. return this.selectDictLabel(this.typeOptions, row.configType);
  244. },
  245. // 取消按钮
  246. cancel() {
  247. this.open = false;
  248. this.reset();
  249. },
  250. // 表单重置
  251. reset() {
  252. this.form = {
  253. configId: undefined,
  254. configName: undefined,
  255. configKey: undefined,
  256. configValue: undefined,
  257. configType: "Y",
  258. remark: undefined
  259. };
  260. this.resetForm("form");
  261. },
  262. /** 搜索按钮操作 */
  263. handleQuery() {
  264. this.queryParams.pageNum = 1;
  265. this.getList();
  266. },
  267. /** 重置按钮操作 */
  268. resetQuery() {
  269. this.dateRange = [];
  270. this.resetForm("queryForm");
  271. this.handleQuery();
  272. },
  273. /** 新增按钮操作 */
  274. handleAdd() {
  275. this.reset();
  276. this.open = true;
  277. this.title = "添加参数";
  278. },
  279. // 多选框选中数据
  280. handleSelectionChange(selection) {
  281. this.ids = selection.map(item => item.configId)
  282. this.single = selection.length!=1
  283. this.multiple = !selection.length
  284. },
  285. /** 修改按钮操作 */
  286. handleUpdate(row) {
  287. this.reset();
  288. const configId = row.configId || this.ids
  289. getConfig(configId).then(response => {
  290. this.form = response.data;
  291. this.open = true;
  292. this.title = "修改参数";
  293. });
  294. },
  295. /** 提交按钮 */
  296. submitForm: function() {
  297. this.$refs["form"].validate(valid => {
  298. if (valid) {
  299. if (this.form.configId != undefined) {
  300. updateConfig(this.form).then(response => {
  301. this.msgSuccess("修改成功");
  302. this.open = false;
  303. this.getList();
  304. });
  305. } else {
  306. addConfig(this.form).then(response => {
  307. this.msgSuccess("新增成功");
  308. this.open = false;
  309. this.getList();
  310. });
  311. }
  312. }
  313. });
  314. },
  315. /** 删除按钮操作 */
  316. handleDelete(row) {
  317. const configIds = row.configId || this.ids;
  318. this.$confirm('是否确认删除参数?', "警告", {
  319. confirmButtonText: "确定",
  320. cancelButtonText: "取消",
  321. type: "warning"
  322. }).then(function() {
  323. return delConfig(configIds);
  324. }).then(() => {
  325. this.getList();
  326. this.msgSuccess("删除成功");
  327. }).catch(() => {});
  328. },
  329. /** 导出按钮操作 */
  330. handleExport() {
  331. this.download('system/config/export', {
  332. ...this.queryParams
  333. }, `config_${new Date().getTime()}.xlsx`)
  334. },
  335. /** 刷新缓存按钮操作 */
  336. handleRefreshCache() {
  337. refreshCache().then(() => {
  338. this.msgSuccess("刷新成功");
  339. });
  340. }
  341. }
  342. };
  343. </script>
  344. <style scoped lang="scss">
  345. .config-page{
  346. padding:20px!important;
  347. }
  348. </style>