CouponAdd.vue 5.5 KB

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