index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="二维码名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  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="proportion">
  15. <el-input
  16. v-model="queryParams.proportion"
  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>
  25. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  26. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-row :gutter="10" class="mb8">
  30. <el-col :span="1.5">
  31. <el-button
  32. type="primary"
  33. plain
  34. icon="el-icon-plus"
  35. size="mini"
  36. @click="handleAdd"
  37. v-hasPermi="['system:admin:add']"
  38. >新增</el-button>
  39. </el-col>
  40. <!-- <el-col :span="1.5">
  41. <el-button
  42. type="success"
  43. plain
  44. icon="el-icon-edit"
  45. size="mini"
  46. :disabled="single"
  47. @click="handleUpdate"
  48. v-hasPermi="['system:admin:edit']"
  49. >修改</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="danger"
  54. plain
  55. icon="el-icon-delete"
  56. size="mini"
  57. :disabled="multiple"
  58. @click="handleDelete"
  59. v-hasPermi="['system:admin:remove']"
  60. >删除</el-button>
  61. </el-col> wt注释-->
  62. </el-row>
  63. <el-table v-loading="loading" :data="adminList" @selection-change="handleSelectionChange">
  64. <el-table-column type="selection" width="55" align="center" />
  65. <el-table-column label="二维码名称" align="center" prop="name" />
  66. <el-table-column label="渠道名称" align="center" prop="topChannelName"/>
  67. <el-table-column label="渠道名称" align="center" prop="topChannelName"/>
  68. <el-table-column label="二维码" align="center" prop="createBy">
  69. <template slot-scope="scope">
  70. <el-image
  71. v-if="scope.row.qrPath"
  72. style="width: 24px; height: 24px"
  73. :preview-src-list="['data:image/gif;base64,' + scope.row.qrPath]"
  74. :src="'data:image/gif;base64,' + scope.row.qrPath">
  75. </el-image>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  79. <template slot-scope="scope">
  80. <span>{{ parseTime(scope.row.createTime) }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  84. <template slot-scope="scope">
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-edit"
  89. @click="handleUpdate(scope.row)"
  90. v-hasPermi="['system:admin:edit']"
  91. >修改</el-button>
  92. <el-button
  93. size="mini"
  94. type="text"
  95. icon="el-icon-delete"
  96. @click="handleDelete(scope.row)"
  97. v-hasPermi="['system:admin:remove']"
  98. >删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination
  103. v-show="total>0"
  104. :total="total"
  105. :page.sync="queryParams.current"
  106. :limit.sync="queryParams.size"
  107. @pagination="getList"
  108. />
  109. <!-- 添加或修改参数配置对话框 -->
  110. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :before-close="cancel" :close-on-click-modal="false">
  111. <el-form ref="form" :model="form" :rules="rules" label-width="100px" >
  112. <el-form-item label="二维码名称" prop="name">
  113. <el-input v-model="form.name" placeholder="请输入二维码名称" />
  114. </el-form-item>
  115. <el-form-item label="渠道名称" prop="topChannelId">
  116. <el-select v-model="form.topChannelId" placeholder="请选择渠道名称" clearable style="width:100%">
  117. <el-option
  118. v-for="dict in channelList"
  119. :key="dict.id"
  120. :label="dict.name"
  121. :value="dict.id"/>
  122. </el-select>
  123. </el-form-item>
  124. </el-form>
  125. <div slot="footer" class="dialog-footer">
  126. <el-button type="primary" @click="submitForm">确 定</el-button>
  127. <el-button @click="cancel">取 消</el-button>
  128. </div>
  129. </el-dialog>
  130. </div>
  131. </template>
  132. <script>
  133. import { addCode, updataCode, delCode, listCode, channlPageCode, getBs } from "@/api/recharge/qrCode";
  134. export default {
  135. name: "admin",
  136. data() {
  137. return {
  138. // 遮罩层
  139. loading: true,
  140. // 导出遮罩层
  141. exportLoading: false,
  142. // 选中数组
  143. ids: [],
  144. // 非单个禁用
  145. single: true,
  146. // 非多个禁用
  147. multiple: true,
  148. // 显示搜索条件
  149. showSearch: true,
  150. // 总条数
  151. total: 0,
  152. // 参数表格数据
  153. adminList: [],
  154. // 充值渠道下拉
  155. channelList: [],
  156. // 弹出层标题
  157. title: "",
  158. // 是否显示弹出层
  159. open: false,
  160. // 查询参数
  161. queryParams: {
  162. current: 1,
  163. size: 10,
  164. name: undefined,
  165. topChannelName: undefined,
  166. },
  167. // 表单参数
  168. form: {},
  169. codeUrl:null,
  170. // 表单校验
  171. rules: {
  172. name: [
  173. { required: true, message: "二维码名称不能为空", trigger: "blur" }
  174. ],
  175. topChannelName: [
  176. { required: true, message: "渠道名称不能为空", trigger: "blur" }
  177. ],
  178. }
  179. };
  180. },
  181. created() {
  182. this.getList();
  183. channlPageCode().then(response => this.channelList = response.data);
  184. },
  185. methods: {
  186. /** 查询参数列表 */
  187. getList() {
  188. this.loading = true;
  189. listCode(this.addDateRange(this.queryParams)).then(response => {
  190. this.adminList = response.data.records;
  191. this.total = response.data.total;
  192. this.loading = false;
  193. }
  194. );
  195. },
  196. // 取消按钮
  197. cancel() {
  198. this.open = false;
  199. this.reset();
  200. },
  201. // 表单重置
  202. reset() {
  203. this.form = {
  204. ids: undefined,
  205. name: undefined,
  206. topChannelName: undefined,
  207. topChannelId:undefined
  208. };
  209. this.resetForm("form");
  210. },
  211. /** 搜索按钮操作 */
  212. handleQuery() {
  213. this.queryParams.current = 1;
  214. this.getList();
  215. },
  216. /** 重置按钮操作 */
  217. resetQuery() {
  218. this.dateRange = [];
  219. this.resetForm("queryForm");
  220. this.handleQuery();
  221. },
  222. /** 新增按钮操作 */
  223. handleAdd() {
  224. this.reset();
  225. this.open = true;
  226. this.title = "添加参数";
  227. },
  228. // 多选框选中数据
  229. handleSelectionChange(selection) {
  230. this.ids = selection.map(item => item.id)
  231. this.single = selection.length!=1
  232. this.multiple = !selection.length
  233. console.log(this.ids)
  234. },
  235. /** 修改按钮操作 */
  236. handleUpdate(row) {
  237. Object.assign(this.form, row.id ? this.adminList.find(val=>val.id === row.id) : this.adminList.find(val=>val.id === this.ids[0]))
  238. this.open = true;
  239. this.title = "修改参数";
  240. },
  241. /** 提交按钮 */
  242. submitForm(row) {
  243. this.$refs["form"].validate(valid => {
  244. if (valid) {
  245. if (this.form.id != undefined) {
  246. updataCode(this.form).then(response => {
  247. console.log(response)
  248. this.msgSuccess("修改成功");
  249. this.open = false;
  250. this.getList();
  251. });
  252. } else {
  253. addCode(this.form).then(response => {
  254. this.msgSuccess("新增成功");
  255. this.open = false;
  256. this.getList();
  257. });
  258. }
  259. }
  260. });
  261. },
  262. /** 删除按钮操作 */
  263. handleDelete(row) {
  264. const ids = row.id || this.ids;
  265. this.$confirm('是否确认删除', "警告", {
  266. confirmButtonText: "确定",
  267. cancelButtonText: "取消",
  268. type: "warning"
  269. }).then(function(res) {
  270. return delCode(ids);
  271. }).then(() => {
  272. this.getList();
  273. this.msgSuccess("删除成功");
  274. }).catch(() => {});
  275. },
  276. }
  277. };
  278. </script>