storeSendCoupon.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
  4. <el-form-item prop="discountWay">
  5. <el-select v-model="queryParams.discountWay" placeholder="请选择优惠券类型" clearable>
  6. <el-option v-for="dict in dict.type.coupon_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  7. </el-select>
  8. </el-form-item>
  9. <el-form-item prop="activityName">
  10. <el-input v-model="queryParams.activityName" placeholder="请输入活动名称" clearable @keyup.enter.native="handleQuery" />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <!-- <el-col :span="1.5">-->
  19. <!-- <el-button-->
  20. <!-- type="primary"-->
  21. <!-- plain-->
  22. <!-- icon="el-icon-plus"-->
  23. <!-- -->
  24. <!-- @click="handleAdd"-->
  25. <!-- v-hasPermi="['app:couponItem:add']"-->
  26. <!-- >手动发送优惠券</el-button>-->
  27. <!-- </el-col>-->
  28. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  29. </el-row>
  30. <el-table v-loading="loading" fit highlight-current-row border stripe :data="couponItemList">
  31. <!-- <el-table-column type="selection" width="55" align="center" fixed="left"/>-->
  32. <!-- <el-table-column label="编号" align="center" prop="id" fixed="left"/>-->
  33. <!-- <el-table-column label="订单编码" align="center" prop="orderNo" />-->
  34. <el-table-column label="活动名称" align="center" prop="activityTitle" :show-overflow-tooltip="true" />
  35. <el-table-column label="活动有效期" align="center" prop="startDate" width="220">
  36. <template slot-scope="scope"> {{ scope.row.activityStartDate }}至{{ scope.row.activityEndDate }} </template>
  37. </el-table-column>
  38. <el-table-column label="优惠券名称" align="center" prop="couponTypeTitle" :show-overflow-tooltip="true" />
  39. <el-table-column label="优惠券类型" align="center" prop="discountWay" width="120" :show-overflow-tooltip="true">
  40. <template slot-scope="scope">
  41. <dict-tag :options="dict.type.coupon_type" :value="scope.row.discountWay" />
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="优惠券有效期" align="center" width="220">
  45. <template slot-scope="scope"> {{ scope.row.couponStartDate }} 至 {{ scope.row.couponEndDate }} </template>
  46. </el-table-column>
  47. <!-- <el-table-column label="活动ID" align="center" prop="activityInfoId" />-->
  48. <!-- <el-table-column label="发放门店/工厂" align="center" prop="orgName" width="120" :show-overflow-tooltip="true" />-->
  49. <!-- <el-table-column label="客户姓名" align="center" prop="appUserName" width="100" />-->
  50. <!-- <el-table-column label="客户手机号" align="center" prop="appUserPhone" width="120" />-->
  51. <!-- <el-table-column label="是否核销" align="center" prop="isUsed" width="80">-->
  52. <!-- <template slot-scope="scope">-->
  53. <!-- <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isUsed"/>-->
  54. <!-- </template>-->
  55. <!-- </el-table-column>-->
  56. <!-- <el-table-column label="核销门店/工厂" align="center" prop="usedOrgName" width="120" :show-overflow-tooltip="true"/>-->
  57. <!-- <el-table-column label="核销时间" align="center" prop="usedTime" width="180">-->
  58. <!-- </el-table-column>-->
  59. <!-- <el-table-column label="有效期开始时间" align="center" prop="startDate" width="180">-->
  60. <!-- </el-table-column>-->
  61. <!-- <el-table-column label="有效期结束时间" align="center" prop="endDate" width="180">-->
  62. <!-- </el-table-column>-->
  63. <el-table-column label="是否单件抵扣券" align="center" prop="isUnique" width="180">
  64. <template slot-scope="scope">
  65. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isUnique" />
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="抵用金额(元)" align="center" prop="deductAmount" width="120" />
  69. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150" v-if="isUsed != 'Y'">
  70. <template slot-scope="scope">
  71. <el-button type="text" icon="el-icon-plus" @click="handleAdd(scope.row)" v-hasPermi="['app:couponItem:add']">发放优惠券</el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  76. <!-- 发送优惠券对话框 -->
  77. <el-dialog :title="sendCouponTitle" :visible.sync="sendCouponOpen" size="30%" append-to-body>
  78. <el-row :gutter="15">
  79. <el-form ref="form" :model="sendCouponForm" :rules="rules" label-width="140px">
  80. <el-col :span="24">
  81. <el-form-item label="用户手机号" prop="appUserPhoneNumber">
  82. <el-input style="width: 200px" v-model.number="sendCouponForm.appUserPhoneNumber" placeholder="请输入手机号" clearable maxlength="11" />
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="24">
  86. <el-form-item label="一次性发送数量" prop="sendNum">
  87. <el-input-number v-model.number="sendCouponForm.sendNum" placeholder="请输入发送数量" :controls="false" :min="1" />
  88. </el-form-item>
  89. </el-col>
  90. </el-form>
  91. </el-row>
  92. <div slot="footer" class="dialog-footer">
  93. <el-button type="primary" @click="submitSendCouponForm" style="margin-left: 5%">提交</el-button>
  94. <el-button @click="sendCouponCancel">取 消</el-button>
  95. </div>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. import { listCouponItem, getCouponItem, delCouponItem, sendCoupon, updateCouponItem, updateCouponItemStatus } from '@/api/coupon/item'
  101. import { allOrg } from '@/api/system/store'
  102. import { allValidList } from '@/api/coupon/type'
  103. import { listByStore } from '@/api/activity/couponInfo'
  104. export default {
  105. name: 'CouponItem',
  106. dicts: ['sys_source_type', 'sys_yes_no', 'coupon_type'],
  107. data() {
  108. return {
  109. // 遮罩层
  110. loading: true,
  111. // 选中数组
  112. ids: [],
  113. // 非单个禁用
  114. single: true,
  115. // 非多个禁用
  116. multiple: true,
  117. // 显示搜索条件
  118. showSearch: true,
  119. // 总条数
  120. total: 0,
  121. // 优惠券表格数据
  122. couponItemList: [],
  123. // 弹出层标题
  124. title: '',
  125. sendCouponTitle: '',
  126. // 是否显示弹出层
  127. open: false,
  128. sendCouponOpen: false,
  129. // 查询参数
  130. queryParams: {
  131. pageNum: 1,
  132. pageSize: 10,
  133. orgIndex: null,
  134. dateRange: []
  135. },
  136. // 表单参数
  137. form: {},
  138. // 表单参数
  139. sendCouponForm: {},
  140. // 表单校验
  141. rules: {
  142. duringDate: [{ required: true, message: '有效期不能为空', trigger: 'blur' }],
  143. orgId: [{ required: true, message: '门店不能为空', trigger: 'blur' }],
  144. couponTypeId: [{ required: true, message: '优惠券不能为空', trigger: 'blur' }],
  145. appUserPhoneNumber: [{ required: true, message: '用户手机号不能为空', trigger: 'blur' }],
  146. sendNum: [{ required: true, message: '发放数量不能为空', trigger: 'blur' }]
  147. },
  148. orgList: [],
  149. isUsed: null,
  150. storeList: [],
  151. factoryList: [],
  152. dateRange: []
  153. }
  154. },
  155. created() {
  156. this.handleUser()
  157. this.isUsed = this.getUrlParam('isUsed')
  158. if (this.isUsed == 'Y') {
  159. this.queryParams.isUsed = this.isUsed
  160. }
  161. this.getList()
  162. allOrg().then((res) => {
  163. this.orgList = res.data
  164. this.orgList.forEach((org) => {
  165. if (org.sourceType == '01') {
  166. this.factoryList.push(org)
  167. } else {
  168. this.storeList.push(org)
  169. }
  170. })
  171. })
  172. },
  173. methods: {
  174. handleUser() {
  175. this.userInfoVO = this.getUserInfo()
  176. },
  177. /** 查询优惠券列表 */
  178. getList() {
  179. this.loading = true
  180. listByStore(this.queryParams).then((response) => {
  181. this.couponItemList = response.data.records
  182. this.total = response.data.total
  183. this.loading = false
  184. })
  185. },
  186. // 取消按钮
  187. cancel() {
  188. this.open = false
  189. this.reset()
  190. },
  191. // 取消按钮
  192. sendCouponCancel() {
  193. this.sendCouponOpen = false
  194. this.reset()
  195. },
  196. // 表单重置
  197. reset() {
  198. this.sendCouponForm = {
  199. couponTypeId: null,
  200. activityId: null,
  201. orgId: null,
  202. sourceType: null,
  203. appUserPhoneNumber: null,
  204. sendNum: null
  205. }
  206. this.resetForm('form')
  207. },
  208. /** 搜索按钮操作 */
  209. handleQuery() {
  210. this.queryParams.pageNum = 1
  211. this.getList()
  212. },
  213. /** 重置按钮操作 */
  214. resetQuery() {
  215. this.resetForm('queryForm')
  216. this.handleQuery()
  217. },
  218. /** 发送优惠券按钮操作 */
  219. handleAdd(row) {
  220. this.reset()
  221. this.sendCouponForm.couponTypeId = row.couponTypeId
  222. this.sendCouponForm.activityId = row.activityInfoId
  223. this.sendCouponOpen = true
  224. this.sendCouponTitle = '发送优惠券'
  225. },
  226. /** 提交发送优惠券 */
  227. submitSendCouponForm() {
  228. this.$refs['form'].validate((valid) => {
  229. if (valid) {
  230. this.sendCouponForm.sourceType = this.userInfoVO.userType
  231. this.sendCouponForm.orgId = this.userInfoVO.storeId
  232. sendCoupon(this.sendCouponForm).then((response) => {
  233. this.$modal.msgSuccess('提交成功')
  234. this.sendCouponOpen = false
  235. this.getList()
  236. })
  237. }
  238. })
  239. },
  240. checkClose(done) {
  241. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  242. .then(function () {
  243. done()
  244. })
  245. .then(() => {})
  246. .catch(() => {})
  247. }
  248. }
  249. }
  250. </script>