CouponAdd.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. <div>使用场景:</div>
  21. <el-select v-model="type" placeholder="请选择使用场景" clearable @keyup.enter.native="getCouponList">
  22. <el-option label="全部" value=""/>
  23. <el-option label="门店消费" :value="2"/>
  24. <el-option label="盲票购买" :value="1"/>
  25. <el-option label="采购商品核销" :value="4"/>
  26. </el-select>
  27. <div class="ge"></div>
  28. <el-button
  29. type="primary"
  30. icon="el-icon-search"
  31. size="mini"
  32. @click="getCouponList"
  33. >查询</el-button
  34. >
  35. </div>
  36. <el-table
  37. v-loading="loading"
  38. :data="couponList"
  39. row-key="couponId"
  40. @selection-change="handleSelectionCoupon"
  41. class="el-table"
  42. >
  43. <el-table-column
  44. type="selection"
  45. width="55"
  46. align="center"
  47. fixed="left"
  48. :reserve-selection="true"
  49. />
  50. <!-- -->
  51. <el-table-column label="券ID" prop="couponId" />
  52. <el-table-column label="券图片">
  53. <template slot-scope="scope">
  54. <div>
  55. <el-image
  56. style="width: 100px; height: 100px"
  57. :src="scope.row.picUrl"
  58. :preview-src-list="[scope.row.picUrl]"
  59. >
  60. </el-image>
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="券名称" prop="title" min-width="85" />
  65. <el-table-column label="使用场景" min-width="85">
  66. <template slot-scope="scope">
  67. <div>{{ scope.row.type.desc }}</div>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="券价格" min-width="85">
  71. <template slot-scope="scope">
  72. <div>¥{{ $numberFormat(scope.row.discount) }}</div>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="门店承担比例" min-width="85">
  76. <template slot-scope="scope">
  77. <div>{{ scope.row.channelSharedRate }}%</div>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="有效期限" min-width="85">
  81. <template slot-scope="scope">
  82. <div>领取后{{ scope.row.dueDays }}天有效</div>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <pagination
  87. v-show="couponTotal > 0"
  88. :total="couponTotal"
  89. :page.sync="pageParams.pageNum"
  90. :limit.sync="pageParams.pageSize"
  91. @pagination="getCouponList"
  92. />
  93. <div class="dialog-btn">
  94. <el-button size="small" @click="close"> 取 消 </el-button>
  95. <div class="ge"></div>
  96. <el-button type="primary" size="small" @click="confirmCoupon">
  97. 确 认
  98. </el-button>
  99. </div>
  100. </el-dialog>
  101. </div>
  102. </template>
  103. <script>
  104. import { publicFileGetUrl } from "@/api/common";
  105. import { getCouponList } from "@/api/business/coupon";
  106. export default {
  107. name: "CouponAdd",
  108. props: {
  109. dialogVisible: {
  110. type: Boolean,
  111. default: false,
  112. },
  113. },
  114. data() {
  115. return {
  116. loading: false,
  117. type: '',
  118. couponTitle: "", // 券名称
  119. couponList: [], // 卡券列表
  120. couponTotal: 0, // 卡券总数
  121. selectCouponList: [], // 选中卡券
  122. pageParams: {
  123. pageNum: 1,
  124. pageSize: 10,
  125. },
  126. };
  127. },
  128. created() {
  129. this.getCouponList();
  130. },
  131. methods: {
  132. // 卡券列表
  133. getCouponList() {
  134. this.loading = true;
  135. getCouponList(
  136. "pageNum=" +
  137. this.pageParams.pageNum +
  138. "&pageSize=" +
  139. this.pageParams.pageSize +
  140. "&",
  141. { title: this.couponTitle,type: this.type, status: "on" }
  142. ).then((res) => {
  143. this.couponList = res.rows.map((item) => {
  144. return {
  145. ...item,
  146. type: JSON.parse(item.type),
  147. useArea: JSON.parse(item.useArea),
  148. picUrl: publicFileGetUrl + item.picUrl,
  149. };
  150. });
  151. this.couponTotal = res.total;
  152. this.loading = false;
  153. });
  154. },
  155. // 选中卡券
  156. handleSelectionCoupon(e) {
  157. this.selectCouponList = e.map((item) => {
  158. return {
  159. prizeType: "coupon",
  160. // quantity: 1,
  161. couponId: item.couponId,
  162. picUrl: item.picUrl,
  163. title: item.title,
  164. sortWeight: 100
  165. };
  166. });
  167. },
  168. // 确认选中卡券
  169. confirmCoupon() {
  170. if(!this.selectCouponList.length) {
  171. this.msgInfo('请选择券')
  172. return
  173. }
  174. this.$emit("confirmCoupon", this.selectCouponList);
  175. },
  176. close() {
  177. this.$emit("close");
  178. },
  179. },
  180. };
  181. </script>
  182. <style lang="scss" scoped>
  183. .dialog-search {
  184. display: flex;
  185. line-height: 32px;
  186. margin-bottom: 20px;
  187. .ge {
  188. width: 40px;
  189. }
  190. }
  191. .dialog-btn {
  192. display: flex;
  193. align-content: center;
  194. justify-content: flex-end;
  195. padding: 40px 0 0;
  196. .ge {
  197. width: 40px;
  198. }
  199. }
  200. </style>