123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <div class="subPage">
  3. <div class="system-table-search">
  4. <div class="flex-h">
  5. <div class="flex-item flex-h">
  6. <el-button size="mini" type="success" @click="addCoupon('')">新增优惠券</el-button>
  7. <!-- <el-button size="mini" type="success" @click="addCoupon('drink')">新增饮品优惠券</el-button>
  8. <el-button size="mini" type="success" @click="addCoupon('course')">新增课程优惠券</el-button> -->
  9. </div>
  10. <ul>
  11. <li>
  12. <!-- <span>选择案场:</span> -->
  13. <el-select v-model="CaseId" placeholder="请选择案场">
  14. <el-option
  15. v-for="item in cases"
  16. :key="item.CaseId"
  17. :label="item.CaseName"
  18. :value="item.CaseId">
  19. </el-option>
  20. </el-select>
  21. </li>
  22. </ul>
  23. <el-button
  24. size="mini"
  25. type="primary" @click="search">搜索</el-button>
  26. </div>
  27. <div class="moreFilter"></div>
  28. </div>
  29. <div class="system-table-box">
  30. <el-table
  31. :data="couponList.list"
  32. stripe
  33. style="width: 100%">
  34. <el-table-column
  35. prop="CouponName"
  36. label="券名称">
  37. </el-table-column>
  38. <el-table-column
  39. prop="CouponType"
  40. label="券类型">
  41. <template slot-scope="scope">{{scope.row.CouponType === 'goods' ? '商品券' : '课程券'}}</template>
  42. </el-table-column>
  43. <el-table-column
  44. prop="Price"
  45. label="券价格">
  46. </el-table-column>
  47. <el-table-column
  48. prop="StartDate"
  49. label="有效期"
  50. width="150">
  51. <template slot-scope="scope">
  52. <span v-if="scope.row.StartDate.substr(0, 4) !== '0001'" style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.StartDate, 'yyyy-MM-dd')}}</span>
  53. <span v-if="scope.row.StartDate.substr(0, 4) !== '0001'" style="width:100%;display:block;text-align:center;white-space: nowrap;">至</span>
  54. <span v-if="scope.row.StartDate.substr(0, 4) !== '0001'" style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.EndDate, 'yyyy-MM-dd')}}</span>
  55. <span v-else>-</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. prop="SendType"
  60. label="发放类型">
  61. <template slot-scope="scope">{{scope.row.SendType === 'channel' ? '渠道' : scope.row.SendType === 'case' ? '案场' : '系统'}}</template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="TotalCount"
  65. label="总数量">
  66. </el-table-column>
  67. <!-- <el-table-column
  68. prop="SentCount"
  69. label="已发">
  70. </el-table-column>
  71. <el-table-column
  72. prop="UsedCount"
  73. label="实际使用">
  74. </el-table-column> -->
  75. <el-table-column
  76. prop="Status"
  77. label="状态">
  78. <template slot-scope="scope">
  79. <span>{{scope.row.Status === 1 ? '正常' : '已过期'}}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="操作" fixed='right' width="350">
  83. <template slot-scope="scope">
  84. <el-button
  85. size="mini"
  86. type="warning"
  87. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  88. <el-button
  89. size="mini"
  90. type="danger"
  91. @click="sendCoupon(scope.$index, scope.row)">赠送客户</el-button>
  92. <el-button
  93. size="mini"
  94. type="success"
  95. v-if="scope.row.SendType === 'channel'"
  96. v-clipboard:copy="clientUrl + '/receiveChannelShared/' + scope.row.CouponId + '/coupon/receive'"
  97. v-clipboard:success="onCopy"
  98. v-clipboard:error="onError"
  99. >点击复制链接</el-button>
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. </div>
  104. <el-pagination
  105. @current-change="handleCurrentChange"
  106. :current-page.sync="postData.page"
  107. :page-size="postData.pagesize"
  108. layout="prev, pager, next, jumper"
  109. :total="total">
  110. </el-pagination>
  111. <el-dialog
  112. title="选择赠送客户"
  113. :visible.sync="centerDialogVisible"
  114. width="800px"
  115. center>
  116. <div>
  117. <ul class="dialogSearchList flex-h" style="margin-bottom:10px;">
  118. <li class="flex-item">
  119. <el-input
  120. placeholder="请输入用户名"
  121. v-model="dialogPostData.username"
  122. clearable>
  123. </el-input>
  124. </li>
  125. <li class="flex-item">
  126. <el-input
  127. placeholder="请输入手机号"
  128. v-model="dialogPostData.phone"
  129. clearable>
  130. </el-input>
  131. </li>
  132. <li class="flex-item">
  133. <el-input
  134. placeholder="请输入推荐人"
  135. v-model="dialogPostData.recommendname"
  136. clearable>
  137. </el-input>
  138. </li>
  139. <li>
  140. <el-button type="primary" @click="dialogSearch">搜索</el-button>
  141. </li>
  142. </ul>
  143. <ul class="dialogSearchList flex-h">
  144. <li class="flex-item">
  145. <el-date-picker
  146. v-model="dialogPostData.begindate"
  147. type="date"
  148. placeholder="选择起始日期">
  149. </el-date-picker>
  150. <el-date-picker
  151. v-model="dialogPostData.enddate"
  152. type="date"
  153. placeholder="选择截止日期">
  154. </el-date-picker>
  155. </li>
  156. </ul>
  157. </div>
  158. <div>
  159. <el-table
  160. ref="multipleTable"
  161. :data="customers.list"
  162. tooltip-effect="dark"
  163. style="width: 100%"
  164. @selection-change="handleSelectionChange">
  165. <el-table-column
  166. type="selection">
  167. </el-table-column>
  168. <el-table-column
  169. prop="Name"
  170. label="姓名">
  171. </el-table-column>
  172. <el-table-column
  173. prop="CustomerName"
  174. label="微信昵称">
  175. </el-table-column>
  176. <el-table-column
  177. prop="Phone"
  178. label="手机号">
  179. </el-table-column>
  180. <el-table-column
  181. prop="CreateDate"
  182. label="创建时间">
  183. <template slot-scope="scope">
  184. <span>{{toolClass.dateFormat(scope.row.CreateDate, 'yyyy-MM-dd')}}</span>
  185. </template>
  186. </el-table-column>
  187. <el-table-column
  188. prop="RecommendName"
  189. label="推荐人">
  190. </el-table-column>
  191. </el-table>
  192. </div>
  193. <div>
  194. <el-pagination
  195. @current-change="handleCurrentChangeDialog"
  196. :current-page.sync="dialogPostData.page"
  197. :page-size="dialogPostData.pagesize"
  198. layout="prev, pager, next, jumper"
  199. :total="customers.pagenum">
  200. </el-pagination>
  201. </div>
  202. <span slot="footer" class="dialog-footer">
  203. <el-button @click="centerDialogVisible = false">取 消</el-button>
  204. <el-button type="primary" @click="ForCustomer">确 定</el-button>
  205. </span>
  206. </el-dialog>
  207. </div>
  208. </template>
  209. <script>
  210. import { mapState, createNamespacedHelpers } from 'vuex'
  211. const { mapState: mapCouponState, mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
  212. const { mapState: mapCustomerState, mapActions: mapCustomerActions } = createNamespacedHelpers('customer')
  213. export default {
  214. name: '',
  215. data () {
  216. return {
  217. dialogTotal: 0,
  218. dialogPostData: {
  219. username: '',
  220. phone: '',
  221. recommendname: '',
  222. begindate: '',
  223. enddate: '',
  224. page: 1, // 当前页码
  225. pagesize: 6, // 请求数据量
  226. },
  227. centerDialogVisible: false,
  228. total: 0,
  229. postData: { // 表格搜索条件
  230. caseid: '', // 案场id
  231. page: 1, // 当前页码
  232. pagesize: 10, // 请求数据量
  233. },
  234. currentInfo: {},
  235. selUsers: '',
  236. }
  237. },
  238. mounted () {
  239. this.$nextTick(function () {
  240. this.getList()
  241. })
  242. },
  243. computed: {
  244. ...mapCouponState({
  245. couponList: x => x.couponList,
  246. }),
  247. ...mapCustomerState({
  248. customers: x => x.customers,
  249. }),
  250. ...mapState({
  251. clientUrl: x => x.app.clientUrl,
  252. cases: x => x.app.cases.list,
  253. defaultCaseId: x => x.app.cases.default
  254. }),
  255. CaseId: {
  256. get () {
  257. return this.postData.caseid || this.defaultCaseId
  258. },
  259. set (val) {
  260. this.postData.caseid = val
  261. }
  262. }
  263. },
  264. methods: {
  265. ...mapCouponActions([
  266. 'GetCouponList',
  267. 'GiveCoupon',
  268. ]),
  269. ...mapCustomerActions([
  270. 'GetCustomerList',
  271. 'SetCustomerListNull',
  272. ]),
  273. dialogSearch () { // 赠送客户搜索
  274. this.GetCustomerList(this.dialogPostData)
  275. // 1
  276. },
  277. handleCurrentChangeDialog (val) {
  278. // 1
  279. },
  280. handleSelectionChange (val) {
  281. this.selUsers = val.map(x => x.CustomerId).join(',')
  282. // 1
  283. },
  284. sendCoupon (index, row) { // 赠送优惠券
  285. this.currentInfo = row
  286. this.selUsers = ''
  287. this.SetCustomerListNull()
  288. this.centerDialogVisible = true
  289. },
  290. search () { // 搜索
  291. this.postData.page = 1
  292. if (this.couponList.length) {
  293. this.couponList = []
  294. }
  295. this.getList()
  296. },
  297. getList () { // 获取列表
  298. this.GetCouponList({
  299. ...this.postData,
  300. caseid: this.CaseId || this.defaultCaseId
  301. }).then((res) => {
  302. this.total = res.pagenum
  303. // console.log(JSON.stringify(res))
  304. })
  305. },
  306. handleCurrentChange (val) { // 跳转到分页
  307. this.postData.page = val
  308. this.getList()
  309. },
  310. handleEdit (index, row) { // 编辑
  311. this.$router.push({ name: 'editCoupon', query: { type: row.CouponType, id: row.CouponId, caseid: row.CaseId } })
  312. },
  313. handleDelete (index, row) { // 删除
  314. let name = '确认删除渠道“' + row.ChannelName + '”?'
  315. this.$confirm(name, '提示', {
  316. confirmButtonText: '确定',
  317. cancelButtonText: '取消',
  318. type: 'warning'
  319. }).then(() => {
  320. this.$ajax(this.$api.channelManager.deleteChannel.url, {
  321. method: this.$api.channelManager.deleteChannel.method,
  322. urlData: { channelId: row.ChannelId }
  323. }).then(res => {
  324. this.$message({
  325. type: 'success',
  326. message: '删除成功!'
  327. })
  328. this.search()
  329. })
  330. }).catch(() => {
  331. this.$message({
  332. type: 'info',
  333. message: '已取消删除'
  334. })
  335. })
  336. },
  337. addCoupon (val) {
  338. this.$router.push({ name: 'editCoupon', query: { type: val } })
  339. },
  340. ForCustomer () {
  341. if (this.selUsers === '') {
  342. this.$message({
  343. type: 'error',
  344. message: '请先选择客户!'
  345. })
  346. return false
  347. }
  348. if (!this.currentInfo || this.currentInfo.CouponId === '') {
  349. this.$message({
  350. type: 'error',
  351. message: '请先选择需要赠送的优惠券!'
  352. })
  353. return false
  354. }
  355. this.GiveCoupon({
  356. id: this.currentInfo.CouponId,
  357. users: this.selUsers,
  358. }).then(res => {
  359. this.$message({
  360. type: 'success',
  361. message: '赠送成功!'
  362. })
  363. this.centerDialogVisible = false
  364. this.getList()
  365. })
  366. },
  367. onCopy () {
  368. this.$message({
  369. type: 'success',
  370. message: '复制成功!'
  371. })
  372. },
  373. onError () {
  374. this.$message({
  375. type: 'error',
  376. message: '复制失败!'
  377. })
  378. },
  379. }
  380. }
  381. </script>
  382. <!-- Add "scoped" attrib0 0ute to limit CSS to this component only -->
  383. <style lang="scss" scoped>
  384. @import "page.scss";
  385. .dialogSearchList {
  386. align-items: center;
  387. > li {
  388. font-size: 0;
  389. margin-left: 10px;
  390. &:first-child {
  391. margin-left: 0;
  392. }
  393. > *:nth-child(2) {
  394. margin-left: 10px;
  395. }
  396. }
  397. }
  398. </style>