index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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="adminName">
  5. <el-input
  6. v-model="queryParams.adminName"
  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="参数键名" prop="adminKey">
  15. <el-input
  16. v-model="queryParams.adminKey"
  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="系统内置" prop="adminType">
  25. <el-select v-model="queryParams.adminType" 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 icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  49. </el-form-item>
  50. </el-form> -->
  51. <el-row :gutter="10" class="mb8">
  52. <el-col :span="1.5">
  53. <el-button
  54. type="primary"
  55. plain
  56. icon="el-icon-plus"
  57. size="mini"
  58. @click="handleAdd"
  59. v-hasPermi="['system:admin:add']"
  60. >新增</el-button>
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-button
  64. type="success"
  65. plain
  66. icon="el-icon-edit"
  67. size="mini"
  68. :disabled="single"
  69. @click="handleUpdate"
  70. v-hasPermi="['system:admin:edit']"
  71. >修改</el-button>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-button
  75. type="danger"
  76. plain
  77. icon="el-icon-delete"
  78. size="mini"
  79. :disabled="multiple"
  80. @click="handleDelete"
  81. v-hasPermi="['system:admin:remove']"
  82. >删除</el-button>
  83. </el-col>
  84. <!-- <el-col :span="1.5">
  85. <el-button
  86. type="warning"
  87. plain
  88. icon="el-icon-download"
  89. size="mini"
  90. :loading="exportLoading"
  91. @click="handleExport"
  92. v-hasPermi="['system:admin:export']"
  93. >导出</el-button>
  94. </el-col> -->
  95. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
  96. </el-row>
  97. <el-table v-loading="loading" :data="adminList" @selection-change="handleSelectionChange">
  98. <el-table-column type="selection" width="55" align="center" />
  99. <el-table-column label="身份信息" align="center" prop="adminId" />
  100. <el-table-column label="充值到账比例" align="center" prop="adminName"/>
  101. <el-table-column label="创建人" align="center" prop="adminValue" />
  102. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  103. <template slot-scope="scope">
  104. <span>{{ parseTime(scope.row.createTime) }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  108. <template slot-scope="scope">
  109. <el-button
  110. size="mini"
  111. type="text"
  112. icon="el-icon-edit"
  113. @click="handleUpdate(scope.row)"
  114. v-hasPermi="['system:admin:edit']"
  115. >修改</el-button>
  116. <el-button
  117. size="mini"
  118. type="text"
  119. icon="el-icon-delete"
  120. @click="handleDelete(scope.row)"
  121. v-hasPermi="['system:admin:remove']"
  122. >删除</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <pagination
  127. v-show="total>0"
  128. :total="total"
  129. :page.sync="queryParams.pageNum"
  130. :limit.sync="queryParams.pageSize"
  131. @pagination="getList"
  132. />
  133. <!-- 添加或修改参数配置对话框 -->
  134. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  135. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  136. <el-form-item label="身份信息" prop="adminName">
  137. <el-input v-model="form.adminName" placeholder="请输入身份信息" />
  138. </el-form-item>
  139. <el-form-item label="充值到账比例" prop="adminKey">
  140. <el-input v-model="form.adminKey" placeholder="充值到账比例" />
  141. </el-form-item>
  142. <el-form-item label="备注" prop="remark">
  143. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  144. </el-form-item>
  145. </el-form>
  146. <div slot="footer" class="dialog-footer">
  147. <el-button type="primary" @click="submitForm">确 定</el-button>
  148. <el-button @click="cancel">取 消</el-button>
  149. </div>
  150. </el-dialog>
  151. </div>
  152. </template>
  153. <script>
  154. import { listAdmin, } from "@/api/recharge/admin";
  155. export default {
  156. name: "admin",
  157. data() {
  158. return {
  159. // 遮罩层
  160. loading: true,
  161. // 导出遮罩层
  162. exportLoading: false,
  163. // 选中数组
  164. ids: [],
  165. // 非单个禁用
  166. single: true,
  167. // 非多个禁用
  168. multiple: true,
  169. // 显示搜索条件
  170. showSearch: true,
  171. // 总条数
  172. total: 0,
  173. // 参数表格数据
  174. adminList: [],
  175. // 弹出层标题
  176. title: "",
  177. // 是否显示弹出层
  178. open: false,
  179. // 类型数据字典
  180. typeOptions: [],
  181. // 日期范围
  182. dateRange: [],
  183. // 查询参数
  184. queryParams: {
  185. pageNum: 1,
  186. pageSize: 10,
  187. adminName: undefined,
  188. adminKey: undefined,
  189. adminType: undefined
  190. },
  191. // 表单参数
  192. form: {},
  193. // 表单校验
  194. rules: {
  195. adminName: [
  196. { required: true, message: "参数名称不能为空", trigger: "blur" }
  197. ],
  198. adminKey: [
  199. { required: true, message: "参数键名不能为空", trigger: "blur" }
  200. ],
  201. adminValue: [
  202. { required: true, message: "参数键值不能为空", trigger: "blur" }
  203. ]
  204. }
  205. };
  206. },
  207. created() {
  208. this.getList();
  209. },
  210. methods: {
  211. /** 查询参数列表 */
  212. getList() {
  213. this.loading = true;
  214. listAdmin(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  215. this.adminList = response.rows;
  216. // this.total = response.total;
  217. this.loading = false;
  218. }
  219. );
  220. },
  221. // 取消按钮
  222. cancel() {
  223. this.open = false;
  224. this.reset();
  225. },
  226. // 表单重置
  227. reset() {
  228. this.form = {
  229. adminId: undefined,
  230. adminName: undefined,
  231. adminKey: undefined,
  232. adminValue: undefined,
  233. adminType: "Y",
  234. remark: undefined
  235. };
  236. this.resetForm("form");
  237. },
  238. /** 搜索按钮操作 */
  239. handleQuery() {
  240. this.queryParams.pageNum = 1;
  241. this.getList();
  242. },
  243. /** 重置按钮操作 */
  244. resetQuery() {
  245. this.dateRange = [];
  246. this.resetForm("queryForm");
  247. this.handleQuery();
  248. },
  249. /** 新增按钮操作 */
  250. handleAdd() {
  251. this.reset();
  252. this.open = true;
  253. this.title = "添加参数";
  254. },
  255. // 多选框选中数据
  256. handleSelectionChange(selection) {
  257. this.ids = selection.map(item => item.adminId)
  258. this.single = selection.length!=1
  259. this.multiple = !selection.length
  260. },
  261. /** 修改按钮操作 */
  262. handleUpdate(row) {
  263. this.reset();
  264. const adminId = row.adminId || this.ids
  265. getadmin(adminId).then(response => {
  266. this.form = response.data;
  267. this.open = true;
  268. this.title = "修改参数";
  269. });
  270. },
  271. /** 提交按钮 */
  272. submitForm: function() {
  273. this.$refs["form"].validate(valid => {
  274. if (valid) {
  275. if (this.form.adminId != undefined) {
  276. updateadmin(this.form).then(response => {
  277. this.msgSuccess("修改成功");
  278. this.open = false;
  279. this.getList();
  280. });
  281. } else {
  282. addadmin(this.form).then(response => {
  283. this.msgSuccess("新增成功");
  284. this.open = false;
  285. this.getList();
  286. });
  287. }
  288. }
  289. });
  290. },
  291. /** 删除按钮操作 */
  292. handleDelete(row) {
  293. const adminIds = row.adminId || this.ids;
  294. this.$confirm('是否确认删除参数编号为"' + adminIds + '"的数据项?', "警告", {
  295. confirmButtonText: "确定",
  296. cancelButtonText: "取消",
  297. type: "warning"
  298. }).then(function() {
  299. return deladmin(adminIds);
  300. }).then(() => {
  301. this.getList();
  302. this.msgSuccess("删除成功");
  303. }).catch(() => {});
  304. },
  305. /** 导出按钮操作 */
  306. handleExport() {
  307. const queryParams = this.queryParams;
  308. this.$confirm('是否确认导出所有参数数据项?', "警告", {
  309. confirmButtonText: "确定",
  310. cancelButtonText: "取消",
  311. type: "warning"
  312. }).then(() => {
  313. this.exportLoading = true;
  314. return exportadmin(queryParams);
  315. }).then(response => {
  316. this.download(response.msg);
  317. this.exportLoading = false;
  318. }).catch(() => {});
  319. },
  320. /** 刷新缓存按钮操作 */
  321. handleRefreshCache() {
  322. refreshCache().then(() => {
  323. this.msgSuccess("刷新成功");
  324. });
  325. }
  326. }
  327. };
  328. </script>