CouponPkgAdd.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="添加券包奖品"
  5. width="1000px"
  6. :visible.sync="dialogVisible"
  7. :before-close="close"
  8. >
  9. <div class="dialog-search">
  10. <div>券名称:</div>
  11. <el-input
  12. v-model="title"
  13. placeholder="请输入券包名称"
  14. clearable
  15. size="small"
  16. style="width: 240px"
  17. @keyup.enter.native="getCouponList"
  18. />
  19. <div class="ge"></div>
  20. <el-button
  21. type="primary"
  22. icon="el-icon-search"
  23. size="mini"
  24. @click="getCouponList"
  25. >查询</el-button
  26. >
  27. </div>
  28. <el-table
  29. v-loading="loading"
  30. :data="couponList"
  31. @selection-change="handleSelectionCouponPkg"
  32. class="el-table"
  33. >
  34. <el-table-column
  35. type="selection"
  36. width="55"
  37. align="center"
  38. fixed="left"
  39. />
  40. <el-table-column label="券包编号" prop="id" />
  41. <el-table-column label="券包名称" prop="title" min-width="85" />
  42. <el-table-column label="优惠券数量" prop="couponNum" />
  43. <el-table-column label="总面值" min-width="85">
  44. <template slot-scope="scope">
  45. <div>¥{{ $numberFormat(scope.row.facePrice) }}</div>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <pagination
  50. v-show="couponPkgTotal > 0"
  51. :total="couponPkgTotal"
  52. :page.sync="pageParams.pageNum"
  53. :limit.sync="pageParams.pageSize"
  54. @pagination="getCouponList"
  55. />
  56. <div class="dialog-btn">
  57. <el-button size="small" @click="close"> 取 消 </el-button>
  58. <div class="ge"></div>
  59. <el-button type="primary" size="small" @click="confirmCouponPkg">
  60. 确 认
  61. </el-button>
  62. </div>
  63. </el-dialog>
  64. </div>
  65. </template>
  66. <script>
  67. import { publicFileGetUrl } from "@/api/common";
  68. import { getCouponList } from "@/api/business/couponPkg";
  69. export default {
  70. name: "CouponAdd",
  71. props: {
  72. dialogVisible: {
  73. type: Boolean,
  74. default: false,
  75. },
  76. },
  77. data() {
  78. return {
  79. loading: false,
  80. title: "", // 券包名称
  81. couponList: [], // 券包列表
  82. couponPkgTotal: 0, // 券包总数
  83. selectCouponPkgList: [], // 选中券包
  84. pageParams: {
  85. pageNum: 1,
  86. pageSize: 10,
  87. },
  88. };
  89. },
  90. created() {
  91. this.getCouponList();
  92. },
  93. methods: {
  94. // 券包列表
  95. getCouponList() {
  96. this.loading = true;
  97. getCouponList(
  98. "pageNum=" +
  99. this.pageParams.pageNum +
  100. "&pageSize=" +
  101. this.pageParams.pageSize +
  102. "&",
  103. { title: this.title, status: 1 }
  104. ).then((res) => {
  105. this.couponList = res.rows
  106. this.couponPkgTotal = res.total;
  107. this.loading = false;
  108. });
  109. },
  110. // 选中券包
  111. handleSelectionCouponPkg(e) {
  112. this.selectCouponPkgList = e.map((item) => {
  113. return {
  114. prizeType: "coupon_pkg",
  115. // quantity: 1,
  116. id: item.id,
  117. picUrl: publicFileGetUrl + item.picUrl,
  118. title: item.title,
  119. sortWeight: 100
  120. };
  121. });
  122. },
  123. // 确认选中券包
  124. confirmCouponPkg() {
  125. if(!this.selectCouponPkgList.length) {
  126. this.msgInfo('请选择券包')
  127. return
  128. }
  129. this.$emit("confirmCouponPkg", this.selectCouponPkgList);
  130. },
  131. close() {
  132. this.$emit("close");
  133. },
  134. },
  135. };
  136. </script>
  137. <style lang="scss" scoped>
  138. .dialog-search {
  139. display: flex;
  140. line-height: 32px;
  141. margin-bottom: 20px;
  142. .ge {
  143. width: 40px;
  144. }
  145. }
  146. .dialog-btn {
  147. display: flex;
  148. align-content: center;
  149. justify-content: flex-end;
  150. padding: 40px 0 0;
  151. .ge {
  152. width: 40px;
  153. }
  154. }
  155. </style>