index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="paymentCode">
  3. <div class="paymentCode-select">
  4. <el-form :inline="true" :model="payQuery">
  5. <el-form-item label="收款码状态">
  6. <el-select v-model="payQuery.state" placeholder="请选择">
  7. <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value">
  8. </el-option>
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="primary" @click="getAllPay()">查询</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. <div class="paymentCode-table">
  17. <el-table ref="multipleTable" :data="tableData" border
  18. :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" tooltip-effect="dark"
  19. style="width: 100%" v-loading="loading">
  20. <el-table-column label="商家名称" width="220" align="center">
  21. <template slot-scope="scope">{{ scope.row.shopName }}</template>
  22. </el-table-column>
  23. <el-table-column prop="codeImage" label="商家收款码" align="center">
  24. <template slot-scope="scope">
  25. <img :src="scope.row.codeImage" alt="" style="width: 120px; height: 120px;">
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="state" label="收款码状态" align="center">
  29. <template slot-scope="scope">{{ scope.row.state == 1 ? '已启用' : '已禁用' }}</template>
  30. </el-table-column>
  31. <el-table-column prop="createTime" label="创建时间" align="center" />
  32. <el-table-column label="操作" align="center" show-overflow-tooltip>
  33. <template slot-scope="scope">
  34. <div class="btnList">
  35. <template v-if="scope.row.state == 1">
  36. <el-button type="text" @click="handleDel(scope.row, 2)">禁用该收款码</el-button>
  37. </template>
  38. <template v-if="scope.row.state == 2">
  39. <el-button type="text" @click="handleDel(scope.row, 1)">启用该收款码</el-button>
  40. </template>
  41. </div>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. </div>
  46. <div class="fenye">
  47. <el-pagination :current-page="payQuery.page" :page-sizes="[5, 10, 15, 20]" :page-size="10"
  48. layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
  49. @current-change="handleCurrentChange" />
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import { getAllPaymentCode, disablePaymentCode } from '@/api/business'
  55. export default {
  56. created() {
  57. this.getAllPay()
  58. },
  59. data() {
  60. return {
  61. tableData: [],
  62. total: null,
  63. // 获取收款码的参数
  64. payQuery: {
  65. codeType: '',
  66. state: '',
  67. page: 1,
  68. pageSize: 5
  69. },
  70. typeList:[
  71. {
  72. label:'全部',
  73. value:''
  74. },
  75. {
  76. label:'启用',
  77. value:1
  78. },
  79. {
  80. label:'禁用',
  81. value:2
  82. }
  83. ],
  84. loading: false
  85. }
  86. },
  87. methods: {
  88. async getAllPay() {
  89. this.loading = true
  90. try {
  91. let res = await getAllPaymentCode(this.payQuery)
  92. this.tableData = res.data.list
  93. this.total = res.data.total
  94. } catch (error) {
  95. console.log(error);
  96. } finally {
  97. this.loading = false
  98. }
  99. },
  100. handleSizeChange(val) {
  101. this.payQuery.pageSize = val
  102. this.getAllPay()
  103. },
  104. handleCurrentChange(val) {
  105. this.payQuery.page = val
  106. this.getAllPay()
  107. },
  108. // 启用禁用收款码
  109. handleDel(row, state) {
  110. this.$confirm('此操作将操作该收款码, 是否继续?', '提示', {
  111. confirmButtonText: '确定',
  112. cancelButtonText: '取消',
  113. type: 'warning'
  114. }).then(async () => {
  115. let result = await disablePaymentCode({ codeId: row.codeId, state: state })
  116. if (result.code == '') {
  117. this.$message({
  118. type: 'success',
  119. message: '操作成功!'
  120. });
  121. this.getAllPay()
  122. }
  123. }).catch(() => {
  124. this.$message({
  125. type: 'info',
  126. message: '已取消操作'
  127. });
  128. });
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .paymentCode {
  135. padding: 50px;
  136. .fenye {
  137. margin: 30px auto;
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. }
  142. }
  143. </style>