couponShop.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <div>
  3. <div style="font-size:18px;margin-bottom: 15px;">
  4. <a href="#" @click="prev" style="text-decoration:none;font-size: 14px;">
  5. <icon-svg name="jiantou" style="width: 1.2em;height: 1.2em;position: relative;top: 0.3em;"></icon-svg>
  6. 返回
  7. </a>
  8. <span style="display: inline-block;margin: 0 15px;color: #D9D9D9;">|</span>
  9. <span>优惠券管理</span>
  10. </div>
  11. <div style="display: inline-block;float: right;">
  12. <el-button size="mini" type="primary" icon="document" @click="refresh">刷新</el-button>
  13. <el-button style='margin:0 0 20px 10px;' :disabled="!isAuth('coupon:add')" size="mini" type="primary"
  14. icon="document" @click="classifyStair()">添加优惠券</el-button>
  15. </div>
  16. <el-table v-loading="tableDataLoading" :data="tableData.list">
  17. <!-- <el-table-column type="selection" fixed>
  18. </el-table-column> @selection-change="changeFun"-->
  19. <el-table-column prop="couponId" label="编号" width="80">
  20. </el-table-column>
  21. <el-table-column prop="couponName" label="优惠券名称">
  22. </el-table-column>
  23. <el-table-column prop="couponPicture" label="图片">
  24. <template slot-scope="scope">
  25. <img :src="scope.row.couponPicture" alt="" width="40" height="40">
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="money" label="优惠券金额">
  29. </el-table-column>
  30. <el-table-column prop="minMoney" label="最低消费">
  31. </el-table-column>
  32. <el-table-column prop="endDate" label="有效天数">
  33. </el-table-column>
  34. <!-- <el-table-column prop="needIntegral" label="兑换积分">
  35. </el-table-column> -->
  36. <el-table-column label="操作" width="250">
  37. <template slot-scope="scope">
  38. <el-button style='margin-left:15px;' :disabled="!isAuth('coupon:update')" size="mini" type="primary" icon="document"
  39. @click="songCoupon(scope.row)">赠送</el-button>
  40. <el-button size="mini" type="primary" :disabled="!isAuth('coupon:update')"
  41. @click="compile(scope.$index, scope.row)">编辑
  42. </el-button>
  43. <el-button size="mini" type="danger" :disabled="!isAuth('coupon:delete')" @click="deleteStair(scope.row)">删除
  44. </el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <div style="text-align: center;margin-top: 10px;">
  49. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  50. :page-sizes="[10, 20, 30, 40]" :page-size="limit" :current-page="page" layout="total,sizes, prev, pager, next"
  51. :total="tableData.totalCount">
  52. </el-pagination>
  53. </div>
  54. <!-- 添加优惠券 -->
  55. <el-dialog title="添加优惠券" :visible.sync="dialogFormVisible" center>
  56. <div style="margin-bottom: 10px;">
  57. <span style="width: 200px;display: inline-block;text-align: right;">优惠券名称:</span>
  58. <el-input style="width:50%;" v-model="couponName" type="text" placeholder="请输入优惠券名称"></el-input>
  59. </div>
  60. <div style="margin-bottom: 10px;">
  61. <span style="width: 200px;display: inline-block;text-align: right;">图片:</span>
  62. <!-- <el-input style="width:50%;" v-model="couponPicture" type="text" placeholder="请输入图片"></el-input> -->
  63. <div
  64. style=" width:148px;height:148px;background-color: #fbfdff; border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;display: inline-block;">
  65. <el-upload class="avatar-uploader" v-model="couponPicture"
  66. action="https://mxys.chuanghai-tech.com/sqx_fast/alioss/upload" :show-file-list="false"
  67. :on-success="handleAvatarSuccess1">
  68. <img v-if="couponPicture" :src="couponPicture" class="avatar" style="width: 148px;height: 148px;" />
  69. <i v-else class="el-icon-plus avatar-uploader-icon" style="font-size: 28px;color: #8c939d"></i>
  70. </el-upload>
  71. </div>
  72. </div>
  73. <div style="margin-bottom: 10px;">
  74. <span style="width: 200px;display: inline-block;text-align: right;">优惠券金额:</span>
  75. <el-input style="width:50%;" v-model="money" type="text" placeholder="请输入优惠券金额"></el-input>
  76. </div>
  77. <div style="margin-bottom: 10px;">
  78. <span style="width: 200px;display: inline-block;text-align: right;">最低消费:</span>
  79. <el-input style="width:50%;" v-model="minMoney" type="text" placeholder="请输入最低消费"></el-input>
  80. </div>
  81. <div style="margin-bottom: 10px;">
  82. <span style="width: 200px;display: inline-block;text-align: right;">有效天数:</span>
  83. <el-input style="width:50%;" v-model="endDate" type="text" placeholder="请输入有效天数"></el-input>
  84. </div>
  85. <!-- <div style="margin-bottom: 10px;">
  86. <span style="width: 200px;display: inline-block;text-align: right;">兑换积分:</span>
  87. <el-input style="width:50%;" v-model="needIntegral" type="text" placeholder="请输入兑换积分"></el-input>
  88. </div> -->
  89. <div slot="footer" class="dialog-footer">
  90. <el-button @click="dialogFormVisible = false">取 消</el-button>
  91. <el-button type="primary" @click="StairNoticeTo()">确 定</el-button>
  92. </div>
  93. </el-dialog>
  94. <!-- 修改一级分类 -->
  95. <el-dialog title="修改优惠券" :visible.sync="dialogFormVisible1" center>
  96. <el-form :model="form">
  97. <el-form-item label="优惠券名称:" :label-width="formLabelWidth">
  98. <el-input v-model="form.couponName" style="width:65%;"></el-input>
  99. </el-form-item>
  100. <el-form-item label="图片:" :label-width="formLabelWidth">
  101. <!-- <el-input v-model="form.campusDetails" style="width:65%;"></el-input> -->
  102. <div
  103. style=" width:148px;height:148px;background-color: #fbfdff; border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;display: inline-block;">
  104. <el-upload class="avatar-uploader" v-model="form.couponPicture"
  105. action="https://mxys.chuanghai-tech.com/sqx_fast/alioss/upload" :show-file-list="false"
  106. :on-success="handleAvatarSuccess2">
  107. <img v-if="form.couponPicture" :src="form.couponPicture" class="avatar" style="width: 148px;height: 148px;" />
  108. <i v-else class="el-icon-plus avatar-uploader-icon" style="font-size: 28px;color: #8c939d"></i>
  109. </el-upload>
  110. </div>
  111. </el-form-item>
  112. <el-form-item label="优惠券金额:" :label-width="formLabelWidth">
  113. <el-input v-model="form.money" style="width:65%;"></el-input>
  114. </el-form-item>
  115. <el-form-item label="最低消费:" :label-width="formLabelWidth">
  116. <el-input v-model="form.minMoney" style="width:65%;"></el-input>
  117. </el-form-item>
  118. <el-form-item label="有效天数:" :label-width="formLabelWidth">
  119. <el-input v-model="form.endDate" style="width:65%;"></el-input>
  120. </el-form-item>
  121. <!-- <el-form-item label="兑换积分:" :label-width="formLabelWidth">
  122. <el-input v-model="form.needIntegral" style="width:65%;"></el-input>
  123. </el-form-item> -->
  124. </el-form>
  125. <div slot="footer" class="dialog-footer">
  126. <el-button @click="dialogFormVisible1 = false">取 消</el-button>
  127. <el-button type="primary" @click="CompileNoticeTo()">确 定</el-button>
  128. </div>
  129. </el-dialog>
  130. <!-- 赠送优惠券-->
  131. <el-dialog title="赠送优惠券" :visible.sync="dialogFormVisible0" center>
  132. <div style="margin: 10px 0;">
  133. <span style="width: 200px;display: inline-block;text-align: right;">选择用户:</span>
  134. <el-tag :key="tag" v-for="(tag,j) in userNameList" closable :disable-transitions="false"
  135. @close="couponIdClose1(tag,j)">
  136. {{tag}}
  137. </el-tag>
  138. <el-button class="button-new-tag" size="small" @click="couponIdBtn1()">添加</el-button>
  139. </div>
  140. <div slot="footer" class="dialog-footer">
  141. <el-button @click="dialogFormVisible0 = false">取 消</el-button>
  142. <el-button type="primary" @click="songNoticeTo()">确 定</el-button>
  143. </div>
  144. </el-dialog>
  145. <!-- 用户列表 -->
  146. <el-dialog title="用户列表" :visible.sync="dialogFormVisible5" center>
  147. <el-input style="width: 150px;" @keydown.enter.native="select1" clearable placeholder="请输入手机号" v-model="phone">
  148. </el-input>&nbsp;&nbsp;&nbsp;&nbsp;
  149. <el-input style="width: 150px;" @keydown.enter.native="select1" clearable placeholder="请输入昵称" v-model="nickName">
  150. </el-input>
  151. <div style="display: inline-block;">
  152. <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="select1">查询</el-button>
  153. <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleans1">重置</el-button>
  154. </div>
  155. <el-button style="margin-left:15px;" :disabled="userIdList.length <= 0 " size="mini" type="primary"
  156. icon="document" @click="closes2()">确定</el-button>
  157. <el-table v-loading="tableDataLoading1" @selection-change="changeFun1" :data="userData.list"
  158. :row-key="(row)=>{ return row.userId}">
  159. <el-table-column :reserve-selection="true" type="selection" fixed>
  160. </el-table-column>
  161. <el-table-column prop="userId" label="编号" >
  162. </el-table-column>
  163. <el-table-column fixed prop="nickName" label="昵称" >
  164. <template slot-scope="scope">
  165. <span style="color: #f56c6c;">{{ scope.row.nickName ? scope.row.nickName : '未设置' }}</span>
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="图像">
  169. <template slot-scope="scope">
  170. <img v-if="scope.row.avatar==null" src="~@/assets/img/avatar.png" alt="" width="40" height="40">
  171. <img v-else :src="scope.row.avatar" alt="" width="40" height="40">
  172. </template>
  173. </el-table-column>
  174. <el-table-column prop="phone" label="手机号" width="120">
  175. <template slot-scope="scope">
  176. <span style="color: #4f9dec;cursor: pointer;"
  177. @click="updates(scope.row)">{{ scope.row.phone ? scope.row.phone : '未绑定' }}</span>
  178. </template>
  179. </el-table-column>
  180. <el-table-column prop="platform" label="来源" >
  181. </el-table-column>
  182. <el-table-column prop="createTime" label="创建时间">
  183. </el-table-column>
  184. </el-table>
  185. <div style="text-align: center;margin-top: 10px;">
  186. <el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
  187. :page-sizes="[5, 10, 15, 20]" :page-size="size1" :current-page="page1"
  188. layout="total,sizes, prev, pager, next,jumper" :total="userData.totalCount">
  189. </el-pagination>
  190. </div>
  191. </el-dialog>
  192. </div>
  193. </template>
  194. <script>
  195. export default {
  196. data() {
  197. return {
  198. limit: 10,
  199. page: 1,
  200. size1: 10,
  201. page1: 1,
  202. checkBoxData: [], //多选框选择的值
  203. formLabelWidth: '200px',
  204. tableDataLoading: false,
  205. dialogFormVisible: false,
  206. dialogFormVisible1: false,
  207. dialogFormVisible0:false,
  208. dialogFormVisible5: false,
  209. tableDataLoading1:false,
  210. tableData: [],
  211. couponName: '',
  212. couponPicture: '',
  213. endDate:'',
  214. minMoney:'',
  215. money:'',
  216. needIntegral:'',
  217. form: {
  218. couponId: '',
  219. couponName: '',
  220. couponPicture: '',
  221. endDate:'',
  222. minMoney:'',
  223. money:'',
  224. needIntegral:''
  225. },
  226. userNameList:[],
  227. userIdList: [],
  228. userData: [],
  229. phone:'',
  230. nickName:'',
  231. couponId:'',
  232. shopId:'',
  233. }
  234. },
  235. methods: {
  236. // 多选
  237. changeFun(val) {
  238. this.checkBoxData = val;
  239. },
  240. handleSizeChange(val) {
  241. this.limit = val;
  242. this.dataSelect()
  243. },
  244. handleCurrentChange(val) {
  245. this.page = val;
  246. this.dataSelect()
  247. },
  248. handleSizeChange2(val) {
  249. this.size1 = val;
  250. this.dataSelect1()
  251. },
  252. handleCurrentChange2(val) {
  253. this.page1 = val;
  254. this.dataSelect1()
  255. },
  256. handleAvatarSuccess1(file, fileList) {
  257. this.couponPicture = file.data
  258. },
  259. handleAvatarSuccess2(file, fileList) {
  260. this.form.couponPicture = file.data
  261. },
  262. // 刷新
  263. refresh() {
  264. this.page = 1
  265. this.dataSelect()
  266. },
  267. // 添加优惠券弹框
  268. classifyStair() {
  269. this.couponName = ''
  270. this.couponPicture = ''
  271. this.endDate = ''
  272. this.minMoney = ''
  273. this.money = ''
  274. this.needIntegral = ''
  275. this.dialogFormVisible = true
  276. },
  277. // 添加优惠券
  278. StairNoticeTo() {
  279. if (this.campusName == '') {
  280. this.$notify({
  281. title: '提示',
  282. duration: 1800,
  283. message: '请输入优惠券名称',
  284. type: 'warning'
  285. });
  286. return
  287. }
  288. if (this.campusDetails == '') {
  289. this.$notify({
  290. title: '提示',
  291. duration: 1800,
  292. message: '请输入优惠券地址',
  293. type: 'warning'
  294. });
  295. return
  296. }
  297. this.$http({
  298. url: this.$http.adornUrl('admin/coupon/issueCoupon'),
  299. method: 'post',
  300. data: this.$http.adornData({
  301. 'couponName': this.couponName,
  302. 'couponPicture': this.couponPicture,
  303. 'endDate':this.endDate,
  304. 'minMoney':this.minMoney,
  305. 'money':this.money,
  306. 'needIntegral':this.needIntegral,
  307. 'shopId':this.shopId
  308. })
  309. }).then(({
  310. data
  311. }) => {
  312. if(data.code==0){
  313. this.dialogFormVisible = false
  314. this.$message({
  315. message: '添加成功',
  316. type: 'success',
  317. duration: 1500,
  318. onClose: () => {
  319. this.dataSelect()
  320. }
  321. })
  322. }else{
  323. this.$message({
  324. message: data.msg,
  325. type: 'warning',
  326. duration: 1500,
  327. onClose: () => {
  328. }
  329. })
  330. }
  331. })
  332. },
  333. // 修改优惠券
  334. compile(index, rows) {
  335. this.form.couponName = rows.couponName
  336. this.form.couponPicture = rows.couponPicture
  337. this.form.endDate = rows.endDate
  338. this.form.minMoney = rows.minMoney
  339. this.form.money = rows.money
  340. this.form.needIntegral = rows.needIntegral
  341. this.form.couponId = rows.couponId
  342. this.dialogFormVisible1 = true;
  343. },
  344. // 修改优惠券
  345. CompileNoticeTo() {
  346. this.$http({
  347. url: this.$http.adornUrl('admin/coupon/updateCoupon'),
  348. method: 'post',
  349. data: this.$http.adornData({
  350. 'couponId': this.form.couponId,
  351. 'couponName': this.form.couponName,
  352. 'couponPicture': this.form.couponPicture,
  353. 'endDate':this.form.endDate,
  354. 'minMoney':this.form.minMoney,
  355. 'money':this.form.money,
  356. 'needIntegral':this.form.needIntegral,
  357. 'shopId':this.shopId
  358. })
  359. }).then(({
  360. data
  361. }) => {
  362. if (data.code == 0) {
  363. this.$message({
  364. message: '操作成功',
  365. type: 'success',
  366. duration: 1500,
  367. onClose: () => {
  368. this.dialogFormVisible1 = false
  369. this.dataSelect()
  370. }
  371. })
  372. } else {
  373. this.$message({
  374. message: data.msg,
  375. type: 'error',
  376. duration: 1500,
  377. onClose: () => {
  378. this.dialogFormVisible1 = false
  379. this.dataSelect()
  380. }
  381. })
  382. }
  383. })
  384. },
  385. //删除
  386. deleteStair(row) {
  387. this.$confirm(`确定删除此条信息?`, '提示', {
  388. confirmButtonText: '确定',
  389. cancelButtonText: '取消',
  390. type: 'warning'
  391. }).then(() => {
  392. this.$http({
  393. url: this.$http.adornUrl('admin/coupon/deleteCoupon'),
  394. method: 'post',
  395. params: this.$http.adornParams({
  396. 'couponId':row.couponId
  397. })
  398. }).then(({
  399. data
  400. }) => {
  401. if (data.code == 0) {
  402. this.$message({
  403. message: '删除成功',
  404. type: 'success',
  405. duration: 1500,
  406. onClose: () => {
  407. this.dataSelect()
  408. }
  409. })
  410. } else {
  411. this.$message({
  412. message: data.msg,
  413. type: 'error',
  414. duration: 1500,
  415. onClose: () => {
  416. this.dataSelect()
  417. }
  418. })
  419. }
  420. })
  421. }).catch(() => {})
  422. },
  423. // 重置
  424. cleans() {
  425. this.phone = ''
  426. this.status = 0
  427. this.dataSelect()
  428. },
  429. // 获取派单数据列表
  430. dataSelect() {
  431. this.tableDataLoading = true
  432. this.$http({
  433. url: this.$http.adornUrl('admin/coupon/seleteAllCoupon'),
  434. method: 'get',
  435. params: this.$http.adornParams({
  436. 'page': this.page,
  437. 'limit': this.limit,
  438. 'content': this.content,
  439. 'shopId':this.shopId
  440. })
  441. }).then(({
  442. data
  443. }) => {
  444. this.tableDataLoading = false
  445. let returnData = data.data;
  446. this.tableData = returnData
  447. // if(data.data.list.length==0){
  448. // this.page = this.page-1
  449. // this.dataSelect()
  450. // }
  451. })
  452. },
  453. // 赠送优惠券
  454. songCoupon(row) {
  455. this.couponId = row.couponId
  456. this.userIdList = []
  457. this.userNameList = []
  458. this.dialogFormVisible0 = true
  459. },
  460. // 打开用户列表
  461. couponIdBtn1() {
  462. this.page1 = 1
  463. this.dataSelect1()
  464. this.dialogFormVisible5 = true
  465. if(this.userIdList.length==0){
  466. this.cleansHc()
  467. }
  468. },
  469. // 清空选中缓存
  470. cleansHc(rows) {
  471. console.log('---', this.$refs.multipleTable)
  472. if (this.$refs.multipleTable) {
  473. this.$refs.multipleTable.clearSelection();
  474. }
  475. },
  476. // 多选用户
  477. changeFun1(val) {
  478. console.log('多选', val)
  479. var userIdList = []
  480. var userNameList = []
  481. for (var i in val) {
  482. userIdList.push(val[i].userId)
  483. userNameList.push(val[i].nickName)
  484. }
  485. this.userIdList = userIdList
  486. this.userNameList = userNameList
  487. },
  488. // 赠送优惠券
  489. songNoticeTo() {
  490. if (this.userIdList.length == 0) {
  491. this.$notify({
  492. title: '提示',
  493. duration: 1800,
  494. message: '请选择用户',
  495. type: 'warning'
  496. });
  497. return
  498. }
  499. var userIdList = this.userIdList.toString()
  500. this.$http({
  501. url: this.$http.adornUrl('admin/coupon/giveCoupon'),
  502. method: 'get',
  503. params: this.$http.adornParams({
  504. 'userIds': userIdList,
  505. 'shopId': this.shopId,
  506. 'couponId': this.couponId,
  507. })
  508. }).then(({
  509. data
  510. }) => {
  511. this.$message({
  512. message: '操作成功',
  513. type: 'success',
  514. duration: 1500,
  515. onClose: () => {
  516. this.userIdList = []
  517. this.userNameList = []
  518. this.dataSelect()
  519. }
  520. })
  521. this.dialogFormVisible0 = false
  522. })
  523. },
  524. // 获取用户数据列表
  525. dataSelect1() {
  526. let phone = -1
  527. if (this.phone) {
  528. phone = this.phone
  529. }
  530. this.tableDataLoading1 = true
  531. this.$http({
  532. url: this.$http.adornUrl('user/selectUserList'),
  533. method: 'get',
  534. params: this.$http.adornParams({
  535. 'page': this.page1,
  536. 'limit': this.size1,
  537. 'shopAdminFlag': '',
  538. 'phone': this.phone,
  539. 'userName': this.nickName,
  540. 'type': ''
  541. })
  542. }).then(({
  543. data
  544. }) => {
  545. this.tableDataLoading1 = false
  546. let returnData = data.data
  547. this.userData = returnData
  548. })
  549. },
  550. // 查询
  551. select1() {
  552. this.page = 1
  553. this.dataSelect1()
  554. },
  555. // 重置
  556. cleans1() {
  557. this.page = 1
  558. this.phone = ''
  559. this.nickName = ''
  560. this.dataSelect1()
  561. },
  562. couponIdClose1(ietm,index) {
  563. console.log('index', index, 'ietm', ietm, this.userIdList.length)
  564. if (this.userIdList.length < 2) {
  565. this.$message({
  566. title: '提示',
  567. type: 'error',
  568. duration: 1800,
  569. message: '最少需要选中一位用户',
  570. type: 'warning'
  571. });
  572. return
  573. } else {
  574. this.userIdList.splice(index, 1)
  575. this.userNameList.splice(index, 1)
  576. }
  577. },
  578. // 批量开启
  579. closes2(id) {
  580. this.isCoupon = 1
  581. this.dialogFormVisible5 = false
  582. },
  583. // 返回上一级
  584. prev() {
  585. this.$router.back()
  586. },
  587. },
  588. mounted() {
  589. this.shopId = this.$route.query.shopId
  590. this.dataSelect()
  591. }
  592. };
  593. </script>
  594. <style>
  595. </style>