CouponAdd.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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="couponTitle"
  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="handleSelectionCoupon"
  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="券ID" prop="couponId" />
  41. <el-table-column label="券图片">
  42. <template slot-scope="scope">
  43. <div>
  44. <el-image
  45. style="width: 100px; height: 100px"
  46. :src="scope.row.picUrl"
  47. :preview-src-list="[scope.row.picUrl]"
  48. >
  49. </el-image>
  50. </div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="券名称" prop="title" min-width="85" />
  54. <el-table-column label="使用场景" min-width="85">
  55. <template slot-scope="scope">
  56. <div>{{ scope.row.type.desc }}</div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="券价格" min-width="85">
  60. <template slot-scope="scope">
  61. <div>¥{{ $numberFormat(scope.row.discount) }}</div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="有效期限" min-width="85">
  65. <template slot-scope="scope">
  66. <div>领取后{{ scope.row.dueDays }}天有效</div>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. <pagination
  71. v-show="couponTotal > 0"
  72. :total="couponTotal"
  73. :page.sync="pageParams.pageNum"
  74. :limit.sync="pageParams.pageSize"
  75. @pagination="getCouponList"
  76. />
  77. <div class="dialog-btn">
  78. <el-button size="small" @click="close"> 取 消 </el-button>
  79. <div class="ge"></div>
  80. <el-button type="primary" size="small" @click="confirmCoupon">
  81. 确 认
  82. </el-button>
  83. </div>
  84. </el-dialog>
  85. </div>
  86. </template>
  87. <script>
  88. import { publicFileGetUrl } from "@/api/common";
  89. import { getCouponList } from "@/api/business/coupon";
  90. export default {
  91. name: "CouponAdd",
  92. props: {
  93. dialogVisible: {
  94. type: Boolean,
  95. default: false,
  96. },
  97. },
  98. data() {
  99. return {
  100. loading: false,
  101. couponTitle: "", // 券名称
  102. couponList: [], // 卡券列表
  103. couponTotal: 0, // 卡券总数
  104. selectCouponList: [], // 选中卡券
  105. pageParams: {
  106. pageNum: 1,
  107. pageSize: 10,
  108. },
  109. };
  110. },
  111. created() {
  112. this.getCouponList();
  113. },
  114. methods: {
  115. // 卡券列表
  116. getCouponList() {
  117. this.loading = true;
  118. getCouponList(
  119. "pageNum=" +
  120. this.pageParams.pageNum +
  121. "&pageSize=" +
  122. this.pageParams.pageSize +
  123. "&",
  124. { title: this.couponTitle, status: "on" }
  125. ).then((res) => {
  126. this.couponList = res.rows.map((item) => {
  127. return {
  128. ...item,
  129. type: JSON.parse(item.type),
  130. useArea: JSON.parse(item.useArea),
  131. picUrl: publicFileGetUrl + item.picUrl,
  132. };
  133. });
  134. this.couponTotal = res.total;
  135. this.loading = false;
  136. });
  137. },
  138. // 选中卡券
  139. handleSelectionCoupon(e) {
  140. this.selectCouponList = e.map((item) => {
  141. return {
  142. prizeType: "coupon",
  143. // quantity: 1,
  144. couponId: item.couponId,
  145. picUrl: item.picUrl,
  146. title: item.title,
  147. };
  148. });
  149. },
  150. // 确认选中卡券
  151. confirmCoupon() {
  152. this.$emit("confirmCoupon", this.selectCouponList);
  153. },
  154. close() {
  155. this.$emit("close");
  156. },
  157. },
  158. };
  159. </script>
  160. <style lang="scss" scoped>
  161. .dialog-search {
  162. display: flex;
  163. line-height: 32px;
  164. margin-bottom: 20px;
  165. .ge {
  166. width: 40px;
  167. }
  168. }
  169. .dialog-btn {
  170. display: flex;
  171. align-content: center;
  172. justify-content: flex-end;
  173. padding: 40px 0 0;
  174. .ge {
  175. width: 40px;
  176. }
  177. }
  178. </style>