index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="72px">
  4. <el-form-item label="渠道名称:" prop="name">
  5. <el-input
  6. v-model.trim="queryParams.name"
  7. placeholder="请输入渠道名称"
  8. clearable
  9. size="small"
  10. style="width: 140px"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item class="right">
  15. <el-button type="primary" size="mini" @click="handleQuery">搜索</el-button>
  16. <el-button plain size="mini" @click="resetQuery">重置</el-button>
  17. </el-form-item>
  18. <br>
  19. <el-form-item>
  20. <el-button
  21. type="primary"
  22. size="mini"
  23. @click="handleAdd"
  24. v-hasPermi="['system:admin:add']"
  25. >新增</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-table v-loading="loading" :data="adminList" >
  29. <el-table-column label="序号" align="center" prop="" show-overflow-tooltip border>
  30. <template slot-scope="scope">
  31. {{scope.$index + 1}}
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="渠道名称" align="center" prop="name" show-overflow-tooltip />
  35. <el-table-column label="渠道标识" align="center" prop="aliasName" show-overflow-tooltip />
  36. <el-table-column label="创建人" align="center" prop="createBy" show-overflow-tooltip />
  37. <el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip >
  38. <template slot-scope="scope">
  39. <span>{{ parseTime(scope.row.createTime) }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  43. <template slot-scope="scope">
  44. <el-button
  45. size="mini"
  46. type="text"
  47. icon="el-icon-edit"
  48. @click="handleUpdate(scope.row)"
  49. v-hasPermi="['system:admin:edit']"
  50. >修改</el-button>
  51. <el-button
  52. size="mini"
  53. type="text"
  54. icon="el-icon-delete"
  55. @click="handleDelete(scope.row)"
  56. v-hasPermi="['system:admin:remove']"
  57. >删除</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <pagination
  62. v-show="total>0"
  63. :total="total"
  64. :page.sync="queryParams.current"
  65. :limit.sync="queryParams.size"
  66. @pagination="getList"
  67. />
  68. <!-- 添加或修改参数配置对话框 -->
  69. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body :before-close="cancel" :close-on-click-modal="false" >
  70. <el-form ref="form" :model="form" :rules="rules" label-width="120px" >
  71. <el-row :gutter="20">
  72. <el-col :span="16">
  73. <el-form-item label="渠道名称" prop="name">
  74. <el-input v-model.trim="form.name" placeholder="请输入渠道名称" @input="forceUpdate" maxlength="15" show-word-limit />
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="16">
  78. <el-form-item label="渠道标识" prop="aliasName">
  79. <el-input v-model.trim="form.aliasName" placeholder="请输入渠道标识" @input="forceUpdate" maxlength="15" show-word-limit />
  80. </el-form-item>
  81. </el-col>
  82. </el-row>
  83. </el-form>
  84. <div slot="footer" class="dialog-footer">
  85. <el-button type="primary" @click="submitForm" v-if="!loading">确 定</el-button>
  86. <el-button :loading="loading" type="primary" @click="submitForm" v-else>提交中...</el-button>
  87. <el-button @click="cancel">取 消</el-button>
  88. </div>
  89. </el-dialog>
  90. </div>
  91. </template>
  92. <script>
  93. import { addChannel, updataChannel, delChannel, listChannel } from "@/api/recharge/channel";
  94. export default {
  95. name: "admin",
  96. data() {
  97. return {
  98. // 遮罩层
  99. loading: true,
  100. // 导出遮罩层
  101. exportLoading: false,
  102. dialogFormVisible:false,
  103. // 选中数组
  104. ids: [],
  105. // 非单个禁用
  106. single: true,
  107. // 非多个禁用
  108. multiple: true,
  109. // 显示搜索条件
  110. showSearch: true,
  111. // 总条数
  112. total: 0,
  113. // 参数表格数据
  114. adminList: [],
  115. // 弹出层标题
  116. title: "",
  117. // 是否显示弹出层
  118. open: false,
  119. // 类型数据字典
  120. typeOptions: [],
  121. // 日期范围
  122. dateRange: [],
  123. // 查询参数
  124. queryParams: {
  125. current: 1,
  126. size: 10,
  127. name: undefined,
  128. aliasName: undefined,
  129. },
  130. // 表单参数
  131. form: {
  132. name:'',
  133. aliasName:''
  134. },
  135. // 表单校验
  136. rules: {
  137. name: [
  138. { required: true, message: "渠道名称不能为空", trigger: "blur" }
  139. ],
  140. aliasName: [
  141. { required: true, message: "渠道标识不能为空", trigger: "blur" }
  142. ],
  143. }
  144. };
  145. },
  146. created() {
  147. this.getList();
  148. },
  149. methods: {
  150. keydown(e){
  151. if(e.keyCode == 32){
  152. e.returnValue = false
  153. }
  154. },
  155. forceUpdate(){ //重置form
  156. this.form = JSON.parse(JSON.stringify(this.form));
  157. },
  158. /** 查询参数列表 */
  159. getList() {
  160. this.loading = true;
  161. listChannel(this.addDateRange(this.queryParams)).then(response => {
  162. this.adminList = response.data.records;
  163. this.total = response.data.total;
  164. this.loading = false;
  165. }
  166. );
  167. },
  168. // 取消按钮
  169. cancel() {
  170. this.open = false;
  171. this.reset();
  172. },
  173. // 表单重置
  174. reset() {
  175. this.form = {
  176. ids: undefined,
  177. name: undefined,
  178. aliasName: undefined,
  179. adminType: "Y",
  180. };
  181. this.resetForm("form");
  182. },
  183. /** 搜索按钮操作 */
  184. handleQuery() {
  185. this.queryParams.current = 1;
  186. this.getList();
  187. },
  188. /** 重置按钮操作 */
  189. resetQuery() {
  190. this.dateRange = [];
  191. this.resetForm("queryForm");
  192. this.handleQuery();
  193. },
  194. /** 新增按钮操作 */
  195. handleAdd() {
  196. this.reset();
  197. this.open = true;
  198. this.title = "添加参数";
  199. },
  200. // 多选框选中数据
  201. handleSelectionChange(selection) {
  202. this.ids = selection.map(item => item.id)
  203. this.single = selection.length!=1
  204. this.multiple = !selection.length
  205. },
  206. /** 修改按钮操作 */
  207. handleUpdate(row) {
  208. // this.reset();
  209. // const id = row.id || this.ids
  210. // getadmin(id).then(response => {
  211. Object.assign(this.form, row.id ? this.adminList.find(val=>val.id === row.id) : this.adminList.find(val=>val.id === this.ids[0]))
  212. this.open = true;
  213. this.title = "修改参数";
  214. // });
  215. },
  216. /** 提交按钮 */
  217. submitForm(row) {
  218. this.$refs["form"].validate(valid => {
  219. if (valid) {
  220. this.loading = true
  221. if (this.form.id != undefined) {
  222. updataChannel(this.form).then(response => {
  223. this.loading = false,
  224. this.msgSuccess("修改成功");
  225. this.open = false;
  226. this.getList();
  227. }).catch(()=>{
  228. this.loading = false,
  229. this.open = false;
  230. })
  231. } else {
  232. addChannel(this.form).then(response => {
  233. this.loading = false,
  234. this.msgSuccess("新增成功");
  235. this.open = false;
  236. this.getList();
  237. }).catch(()=>{
  238. this.loading = false,
  239. this.open = false
  240. })
  241. }
  242. }
  243. });
  244. },
  245. /** 删除按钮操作 */
  246. handleDelete(row) {
  247. const ids = row.id || this.ids;
  248. this.$confirm('是否确认删除', "警告", {
  249. confirmButtonText: "确定",
  250. cancelButtonText: "取消",
  251. type: "warning"
  252. }).then(function() {
  253. return delChannel(ids);
  254. }).then(() => {
  255. this.getList();
  256. this.msgSuccess("删除成功");
  257. }).catch(() => {});
  258. },
  259. /** 导出按钮操作 */
  260. handleExport() {
  261. const queryParams = this.queryParams;
  262. this.$confirm('是否确认导出所有参数数据项?', "警告", {
  263. confirmButtonText: "确定",
  264. cancelButtonText: "取消",
  265. type: "warning"
  266. }).then(() => {
  267. this.exportLoading = true;
  268. return exportadmin(queryParams);
  269. }).then(response => {
  270. this.download(response.msg);
  271. this.exportLoading = false;
  272. }).catch(() => {});
  273. },
  274. /** 刷新缓存按钮操作 */
  275. handleRefreshCache() {
  276. refreshCache().then(() => {
  277. this.msgSuccess("刷新成功");
  278. });
  279. }
  280. }
  281. };
  282. </script>