CouponAdd.vue 4.5 KB

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