index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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 label-width="120px" prop="orgIndex" v-if="userInfoVO.userType == '00'">
  5. <el-select v-model="queryParams.orgIndex" placeholder="请选择门店" clearable>
  6. <el-option-group label="工厂">
  7. <template>
  8. <el-option v-for="factory in factoryList" :key="factory.id + factory.sourceType" :label="factory.name" :value="factory.id + ',' + factory.sourceType"> </el-option>
  9. </template>
  10. </el-option-group>
  11. <el-option-group label="门店">
  12. <template>
  13. <el-option v-for="store in storeList" :key="store.id + store.sourceType" :label="store.name" :value="store.id + ',' + store.sourceType"> </el-option>
  14. </template>
  15. </el-option-group>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item prop="discountWay">
  19. <el-select v-model="queryParams.discountWay" placeholder="请选择优惠券类型" clearable>
  20. <el-option v-for="dict in dict.type.coupon_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item prop="isUsed" v-if="isUsed != 'Y'">
  24. <el-select v-model="queryParams.isUsed" placeholder="请选择是否核销" clearable>
  25. <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-date-picker v-model="queryParams.duringDate" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  30. </el-form-item>
  31. <el-form-item prop="appUserPhoneNumber">
  32. <el-input v-model="queryParams.appUserPhoneNumber" placeholder="请输入客户手机号" clearable @keyup.enter.native="handleQuery" />
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  36. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  37. </el-form-item>
  38. </el-form>
  39. <el-row :gutter="10" class="mb8">
  40. <el-col :span="1.5">
  41. <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd" v-hasPermi="['app:couponItem:add']">手动发送优惠券</el-button>
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-button type="warning" plain icon="el-icon-download" @click="handleExport" v-hasPermi="['app:couponItem:export']">导出</el-button>
  45. </el-col>
  46. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  47. </el-row>
  48. <Page uri="/mapi/app/couponItem/list" :request-params="queryParams" ref="pagination">
  49. <!-- <el-table-column type="selection" width="55" align="center" fixed="left"/>-->
  50. <el-table-column label="编号" align="center" prop="id" fixed="left" />
  51. <!-- <el-table-column label="订单编码" align="center" prop="orderNo" />-->
  52. <el-table-column label="优惠券名称" align="center" prop="couponTypeTitle" width="120" :show-overflow-tooltip="true" />
  53. <el-table-column label="优惠券类型" align="center" prop="discountWay" width="120" :show-overflow-tooltip="true">
  54. <template slot-scope="scope">
  55. <dict-tag :options="dict.type.coupon_type" :value="scope.row.discountWay" />
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="活动名称" align="center" prop="activityTitle" width="120" :show-overflow-tooltip="true" />
  59. <!-- <el-table-column label="活动ID" align="center" prop="activityInfoId" />-->
  60. <el-table-column label="发放门店/工厂" align="center" prop="orgName" width="120" :show-overflow-tooltip="true" />
  61. <el-table-column label="客户姓名" align="center" prop="appUserName" width="100" />
  62. <el-table-column label="客户手机号" align="center" prop="appUserPhone" width="120" />
  63. <el-table-column label="是否核销" align="center" prop="isUsed" width="80">
  64. <template slot-scope="scope">
  65. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isUsed" />
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="核销门店/工厂" align="center" prop="usedOrgName" width="120" :show-overflow-tooltip="true" />
  69. <el-table-column label="核销时间" align="center" prop="usedTime" width="180"> </el-table-column>
  70. <el-table-column label="有效期开始时间" align="center" prop="startDate" width="180"> </el-table-column>
  71. <el-table-column label="有效期结束时间" align="center" prop="endDate" width="180"> </el-table-column>
  72. <el-table-column label="是否单件抵扣券" align="center" prop="isUnique" width="180">
  73. <template slot-scope="scope">
  74. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isUnique" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="是否手动发券" align="center" prop="canManual" width="180">
  78. <template slot-scope="scope">
  79. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.canManual" />
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="抵用金额(元)" align="center" prop="deductAmount" width="120" />
  83. <el-table-column label="核销订单编码" align="center" prop="deductOrderNo" width="150" />
  84. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150" v-if="isUsed != 'Y'">
  85. <template slot-scope="scope">
  86. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['app:couponItem:edit']">修改有效期</el-button>
  87. <!-- <el-button-->
  88. <!-- -->
  89. <!-- type="text"-->
  90. <!-- icon="el-icon-delete"-->
  91. <!-- @click="handleDelete(scope.row)"-->
  92. <!-- v-hasPermi="['app:couponItem:remove']"-->
  93. <!-- >删除</el-button>-->
  94. </template>
  95. </el-table-column>
  96. </Page>
  97. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  98. <!-- 发送优惠券对话框 -->
  99. <el-dialog :title="sendCouponTitle" :visible.sync="sendCouponOpen" size="30%" append-to-body>
  100. <el-row :gutter="15">
  101. <el-form ref="form" :model="sendCouponForm" :rules="rules" label-width="140px">
  102. <el-col :span="24">
  103. <el-form-item label="门店" prop="orgId">
  104. <el-select v-model="sendCouponForm.orgId" style="width: 200px" @input="getAllValidList(sendCouponForm.orgId)" placeholder="请选择门店" clearable>
  105. <el-option v-for="item in storeList" :key="item.id" :label="item.name" :value="item.id" />
  106. </el-select>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="24">
  110. <el-form-item label="优惠劵" prop="couponTypeId" v-if="sendCouponForm.orgId != null">
  111. <el-select v-model="sendCouponForm.couponTypeId" style="width: 200px" placeholder="请选择优惠劵" clearable>
  112. <el-option v-for="item in couponList" :key="item.id" :label="item.title" :value="item.id" />
  113. </el-select>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="24">
  117. <el-form-item label="用户手机号" prop="appUserPhoneNumber">
  118. <el-input style="width: 200px" v-model.number="sendCouponForm.appUserPhoneNumber" placeholder="请输入手机号" clearable maxlength="11" />
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="24">
  122. <el-form-item label="一次性发送数量" prop="sendNum">
  123. <el-input-number v-model.number="sendCouponForm.sendNum" placeholder="请输入发送数量" :controls="false" min="1" />
  124. </el-form-item>
  125. </el-col>
  126. </el-form>
  127. </el-row>
  128. <div slot="footer" class="dialog-footer">
  129. <el-button type="primary" @click="submitSendCouponForm" style="margin-left: 5%">提交</el-button>
  130. <el-button @click="sendCouponCancel">取 消</el-button>
  131. </div>
  132. </el-dialog>
  133. <!-- 添加或修改优惠券对话框 -->
  134. <el-dialog :title="title" :visible.sync="open" size="30%" append-to-body>
  135. <el-row :gutter="15">
  136. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  137. <el-col :span="24">
  138. <el-form-item label="有效期" prop="duringDate">
  139. <el-date-picker v-model="form.duringDate" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  140. </el-form-item>
  141. </el-col>
  142. </el-form>
  143. </el-row>
  144. <div slot="footer" class="dialog-footer">
  145. <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
  146. <el-button @click="cancel">取 消</el-button>
  147. </div>
  148. </el-dialog>
  149. </div>
  150. </template>
  151. <script>
  152. import { listCouponItem, getCouponItem, delCouponItem, sendCoupon, updateCouponItem, updateCouponItemStatus } from '@/api/coupon/item'
  153. import { allOrg } from '@/api/system/store'
  154. import { allValidList } from '@/api/coupon/type'
  155. export default {
  156. name: 'CouponItem',
  157. dicts: ['sys_source_type', 'sys_yes_no', 'coupon_type'],
  158. data() {
  159. return {
  160. // 遮罩层
  161. loading: true,
  162. // 选中数组
  163. ids: [],
  164. // 非单个禁用
  165. single: true,
  166. // 非多个禁用
  167. multiple: true,
  168. // 显示搜索条件
  169. showSearch: true,
  170. // 总条数
  171. total: 0,
  172. // 优惠券表格数据
  173. couponItemList: [],
  174. // 弹出层标题
  175. title: '',
  176. sendCouponTitle: '',
  177. // 是否显示弹出层
  178. open: false,
  179. sendCouponOpen: false,
  180. // 查询参数
  181. queryParams: {
  182. orgIndex: null,
  183. dateRange: []
  184. },
  185. // 表单参数
  186. form: {},
  187. // 表单参数
  188. sendCouponForm: {},
  189. // 表单校验
  190. rules: {
  191. duringDate: [{ required: true, message: '有效期不能为空', trigger: 'blur' }],
  192. orgId: [{ required: true, message: '门店不能为空', trigger: 'blur' }],
  193. couponTypeId: [{ required: true, message: '优惠券不能为空', trigger: 'blur' }],
  194. appUserPhoneNumber: [{ required: true, message: '用户手机号不能为空', trigger: 'blur' }],
  195. sendNum: [{ required: true, message: '发放数量不能为空', trigger: 'blur' }]
  196. },
  197. orgList: [],
  198. isUsed: null,
  199. storeList: [],
  200. factoryList: [],
  201. couponList: [],
  202. dateRange: []
  203. }
  204. },
  205. created() {
  206. this.handleUser()
  207. this.isUsed = this.getUrlParam('isUsed')
  208. if (this.isUsed == 'Y') {
  209. this.queryParams.isUsed = this.isUsed
  210. }
  211. this.getList()
  212. allOrg().then((res) => {
  213. this.orgList = res.data
  214. this.orgList.forEach((org) => {
  215. if (org.sourceType == '01') {
  216. this.factoryList.push(org)
  217. } else {
  218. this.storeList.push(org)
  219. }
  220. })
  221. })
  222. },
  223. methods: {
  224. handleUser() {
  225. this.userInfoVO = this.getUserInfo()
  226. },
  227. /** 查询优惠券列表 */
  228. getList() {
  229. if (this.queryParams.orgIndex != null) {
  230. this.queryParams.orgId = this.queryParams.orgIndex.split(',')[0]
  231. this.queryParams.sourceType = this.queryParams.orgIndex.split(',')[1]
  232. } else {
  233. delete this.queryParams.orgId
  234. delete this.queryParams.sourceType
  235. }
  236. if (null != this.queryParams.duringDate && this.queryParams.duringDate.length > 0) {
  237. this.queryParams.startDate = this.queryParams.duringDate[0]
  238. this.queryParams.endDate = this.queryParams.duringDate[1]
  239. } else {
  240. delete this.queryParams.startDate
  241. delete this.queryParams.endDate
  242. }
  243. this.$nextTick(() => {
  244. this.$refs.pagination.handleSearch(true)
  245. })
  246. },
  247. getAllValidList(id) {
  248. this.sendCouponForm.couponTypeId = null
  249. allValidList(id).then((res) => {
  250. this.couponList = res.data
  251. })
  252. },
  253. // 取消按钮
  254. cancel() {
  255. this.open = false
  256. this.reset()
  257. },
  258. // 取消按钮
  259. sendCouponCancel() {
  260. this.sendCouponOpen = false
  261. this.reset()
  262. },
  263. // 表单重置
  264. reset() {
  265. this.form = {
  266. id: null,
  267. orderNo: null,
  268. couponTypeId: null,
  269. activityInfoId: null,
  270. orgId: null,
  271. sourceType: null,
  272. appUserId: null,
  273. isUsed: null,
  274. usedOrgId: null,
  275. usedSourceType: null,
  276. usedTime: null,
  277. startDate: null,
  278. endDate: null,
  279. isUnique: null,
  280. canManual: null,
  281. deductAmount: null,
  282. deductOrderNo: null,
  283. createById: null,
  284. createBy: null,
  285. createTime: null,
  286. updateById: null,
  287. updateBy: null,
  288. updateTime: null,
  289. remark: null
  290. }
  291. this.sendCouponForm = {
  292. couponTypeId: null,
  293. activityInfoId: null,
  294. orgId: null,
  295. sourceType: null,
  296. appUserPhoneNumber: null,
  297. sendNum: null
  298. }
  299. this.resetForm('form')
  300. },
  301. /** 搜索按钮操作 */
  302. handleQuery() {
  303. this.getList()
  304. },
  305. /** 重置按钮操作 */
  306. resetQuery() {
  307. this.resetForm('queryForm')
  308. this.handleQuery()
  309. },
  310. // 多选框选中数据
  311. handleSelectionChange(selection) {
  312. this.ids = selection.map((item) => item.id)
  313. this.single = selection.length !== 1
  314. this.multiple = !selection.length
  315. },
  316. /** 发送优惠券按钮操作 */
  317. handleAdd() {
  318. this.reset()
  319. this.sendCouponOpen = true
  320. this.sendCouponTitle = '发送优惠券'
  321. },
  322. /** 修改按钮操作 */
  323. handleUpdate(row) {
  324. this.reset()
  325. const id = row.id || this.ids
  326. getCouponItem(id).then((response) => {
  327. var duringDate = []
  328. duringDate.push(response.data.startDate)
  329. duringDate.push(response.data.endDate)
  330. response.data.duringDate = duringDate
  331. this.form = response.data
  332. this.open = true
  333. this.title = '修改优惠券'
  334. })
  335. },
  336. /** 提交按钮 */
  337. submitForm() {
  338. var params = {}
  339. if (null != this.form.duringDate && this.form.duringDate.length > 0) {
  340. params['startDate'] = this.form.duringDate[0]
  341. params['endDate'] = this.form.duringDate[1]
  342. }
  343. params.id = this.form.id
  344. this.$refs['form'].validate((valid) => {
  345. if (valid) {
  346. // if (this.form.id != null) {
  347. updateCouponItem(params).then((response) => {
  348. this.$modal.msgSuccess('修改成功')
  349. this.open = false
  350. this.getList()
  351. })
  352. // } else {
  353. // addCouponItem(this.form).then(response => {
  354. // this.$modal.msgSuccess("新增成功");
  355. // this.open = false;
  356. // this.getList();
  357. // });
  358. // }
  359. }
  360. })
  361. },
  362. /** 提交发送优惠券 */
  363. submitSendCouponForm() {
  364. this.$refs['form'].validate((valid) => {
  365. if (valid) {
  366. this.sendCouponForm.sourceType = '02'
  367. sendCoupon(this.sendCouponForm).then((response) => {
  368. this.$modal.msgSuccess('提交成功')
  369. this.sendCouponOpen = false
  370. this.getList()
  371. })
  372. }
  373. })
  374. },
  375. /** 删除按钮操作 */
  376. handleDelete(row) {
  377. const ids = row.id || this.ids
  378. this.$modal
  379. .confirm('是否确认删除优惠券编号为"' + ids + '"的数据项?')
  380. .then(function () {
  381. return delCouponItem(ids)
  382. })
  383. .then(() => {
  384. this.getList()
  385. this.$modal.msgSuccess('删除成功')
  386. })
  387. .catch(() => {})
  388. },
  389. /** 导出按钮操作 */
  390. handleExport() {
  391. this.download(
  392. 'mapi/app/couponItem/export',
  393. {
  394. ...this.queryParams
  395. },
  396. `couponItem_${new Date().getTime()}.xlsx`
  397. )
  398. },
  399. checkClose(done) {
  400. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  401. .then(function () {
  402. done()
  403. })
  404. .then(() => {})
  405. .catch(() => {})
  406. }
  407. }
  408. }
  409. </script>