多租户商城-商户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="product-select">
  3. <el-form :inline="true" :model="formData" class="demo-form-inline">
  4. <el-form-item label="">
  5. <el-input v-model="formData.keyword" maxlength="20" placeholder="请输入优惠券名称"></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" @click="onSubmit">{{ $t('common.query') }}</el-button>
  9. </el-form-item>
  10. </el-form>
  11. <el-table
  12. :data="tableData"
  13. max-height="500"
  14. border
  15. style="width: 100%"
  16. ref="couponTable"
  17. row-key="productId"
  18. @selection-change="handleSelectionChange"
  19. >
  20. <el-table-column
  21. width="40"
  22. type="selection"
  23. :reserve-selection="true"
  24. fixed="left"
  25. >
  26. </el-table-column>
  27. <el-table-column
  28. prop="couponName"
  29. label="优惠券名称"
  30. width="180">
  31. </el-table-column>
  32. <el-table-column
  33. prop="content"
  34. label="内容">
  35. </el-table-column>
  36. <el-table-column
  37. prop="effectiveStart"
  38. label="活动开始时间">
  39. </el-table-column>
  40. <el-table-column
  41. prop="effectiveEnd"
  42. label="活动结束时间">
  43. </el-table-column>
  44. </el-table>
  45. <el-pagination
  46. @size-change="handleSizeChange"
  47. @current-change="handleCurrentChange"
  48. :current-page="currentPage"
  49. :hide-on-single-page="true"
  50. :page-sizes="[10, 20, 50, 100]"
  51. :page-size="pageSize"
  52. layout="total, sizes, prev, pager, next, jumper"
  53. :total="total">
  54. </el-pagination>
  55. </div>
  56. </template>
  57. <script>
  58. import api from '@@/components/canvasShow/config/api'
  59. import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
  60. import Cookies from 'js-cookie'
  61. import { mapGetters } from 'vuex'
  62. import {getShopId} from "@@/utils/auth.js"
  63. export default {
  64. name: 'coupon-select',
  65. mixins: [sendReqMixin],
  66. data () {
  67. return {
  68. tableRadio: '',
  69. formData: {
  70. keyword: ''
  71. },
  72. currentPage: 1,
  73. total: 0,
  74. pageSize: 10,
  75. multipleSelection: [],
  76. tableData: [{
  77. id: 100,
  78. name: '测试'
  79. }]
  80. }
  81. },
  82. mounted () {
  83. this.getTableData()
  84. },
  85. computed: {
  86. ...mapGetters([
  87. 'typeId'
  88. ])
  89. },
  90. methods: {
  91. // 获取优惠券
  92. getTableData () {
  93. var _this = this
  94. let _url = ''
  95. if(this.typeId===1){
  96. _url = `${api.getCoupons}?page=${this.currentPage}&pageSize=${this.pageSize}`
  97. } else if(this.typeId===3){
  98. _url = `${api.getShopCoupons}?page=${this.currentPage}&pageSize=${this.pageSize}&shopId=${getShopId()}`
  99. }
  100. if (this.formData.keyword) {
  101. _url += `&search=${this.formData.keyword}`
  102. }
  103. let params = {
  104. url: _url,
  105. method: 'GET'
  106. }
  107. this.sendReq(params, (res) => {
  108. _this.tableData = res.data.list
  109. if(this.typeId===1){
  110. _this.tableData.map(function(value){
  111. value.couponName = value.activityName
  112. value.effectiveStart = value.activityStartTime
  113. value.effectiveEnd = value.activityEndTime
  114. return value;
  115. });
  116. }
  117. _this.total = res.data.total
  118. })
  119. },
  120. // 搜索
  121. onSubmit () {
  122. this.getTableData()
  123. },
  124. // 每页条数改变
  125. handleSizeChange (val) {
  126. this.pageSize = val
  127. this.getTableData()
  128. },
  129. // 当前页改变
  130. handleCurrentChange (val) {
  131. this.currentPage = val
  132. this.getTableData()
  133. },
  134. // 多选改变
  135. handleSelectionChange (val) {
  136. this.multipleSelection = val
  137. },
  138. // 多选改变
  139. resetTableData (list) {
  140. this.$refs.couponTable.clearSelection();
  141. this.$refs.couponTable.toggleRowSelection(list,true);
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .product-select{
  148. .el-pagination{
  149. padding: 0px;
  150. margin-top: 30px;
  151. }
  152. .el-table{
  153. .img{
  154. width: 80px;
  155. height: 80px;
  156. }
  157. }
  158. }
  159. </style>