index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <div class="couponManage app-container">
  3. <div class="type-box">
  4. <!-- <div class="type">
  5. <div class="title">满减券</div>
  6. <div class="desc">例:满100元减20元 </div>
  7. <div class="desc">便于合理控制活动成本</div>
  8. <el-button
  9. class="add-btn"
  10. type="primary"
  11. size="small"
  12. @click="handleAdd('/operationManage/couponManage/fullDiscountCoupon')"
  13. >
  14. 立即添加
  15. </el-button>
  16. </div>
  17. <div class="type">
  18. <div class="title">折扣券</div>
  19. <div class="desc">例:满100元打8折</div>
  20. <div class="desc">便于合理控制活动成本</div>
  21. <el-button
  22. class="add-btn"
  23. type="primary"
  24. size="small"
  25. @click="handleAdd('/operationManage/couponManage/discountCoupon')"
  26. >
  27. 立即添加
  28. </el-button>
  29. </div> -->
  30. <div class="type">
  31. <div class="title">小桔加油券</div>
  32. <div class="desc">小桔加油券</div>
  33. <div class="desc">丰富会员权益增加会员价值</div>
  34. <el-button
  35. class="add-btn"
  36. type="primary"
  37. size="small"
  38. @click="handleAdd('/operationManage/couponManage/refuelCoupon')"
  39. >
  40. 立即添加
  41. </el-button>
  42. </div>
  43. </div>
  44. <div class="search">
  45. <div>
  46. <el-input
  47. v-model="query.couponName"
  48. size="small"
  49. placeholder="请输入优惠券名称"
  50. class="item-width-200"
  51. ></el-input>
  52. <el-date-picker
  53. v-model="date"
  54. size="small"
  55. :default-time="['00:00:00', '23:59:59']"
  56. value-format="yyyy-MM-dd HH:mm:ss"
  57. class="item-width-350 ml10"
  58. type="datetimerange"
  59. range-separator="至"
  60. start-placeholder="开始日期"
  61. end-placeholder="结束日期">
  62. </el-date-picker>
  63. <!-- <el-select
  64. v-model="query.couponType"
  65. size="small"
  66. clearable
  67. class="item-width-200 ml10"
  68. placeholder="请选择类型"
  69. >
  70. <el-option
  71. v-for="item in options"
  72. :key="item.value"
  73. :label="item.label"
  74. :value="item.value"
  75. >
  76. </el-option>
  77. </el-select> -->
  78. <el-select
  79. v-model="query.status"
  80. size="small"
  81. class="item-width-200 ml10"
  82. clearable
  83. placeholder="请选择状态"
  84. >
  85. <el-option
  86. v-for="item in options1"
  87. :key="item.value"
  88. :label="item.label"
  89. :value="item.value"
  90. >
  91. </el-option>
  92. </el-select>
  93. <el-button
  94. class="ml10"
  95. type="primary"
  96. size="small"
  97. icon="el-icon-search"
  98. @click="handleSearch"
  99. >
  100. 搜索
  101. </el-button>
  102. </div>
  103. </div>
  104. <el-table
  105. :data="tableData"
  106. tooltip-effect="dark"
  107. border
  108. v-loading="loading"
  109. style="width: 100%"
  110. >
  111. <el-table-column
  112. align="center"
  113. label="优惠券名称"
  114. prop="couponName"
  115. show-overflow-tooltip
  116. >
  117. </el-table-column>
  118. <el-table-column
  119. prop="couponType"
  120. align="center"
  121. label="优惠券类型"
  122. show-overflow-tooltip
  123. >
  124. <template slot-scope="scope">
  125. {{scope.row.couponType|filterType}}
  126. </template>
  127. </el-table-column>
  128. <el-table-column
  129. prop="limitNum"
  130. align="center"
  131. label="发放数量"
  132. show-overflow-tooltip
  133. >
  134. </el-table-column>
  135. <el-table-column
  136. prop="claimNum"
  137. align="center"
  138. label="已领取"
  139. show-overflow-tooltip
  140. >
  141. </el-table-column>
  142. <el-table-column
  143. prop="surplusNum"
  144. align="center"
  145. label="剩余数量"
  146. show-overflow-tooltip
  147. >
  148. </el-table-column>
  149. <el-table-column
  150. prop="useNum"
  151. align="center"
  152. label="已使用"
  153. show-overflow-tooltip
  154. >
  155. </el-table-column>
  156. <el-table-column
  157. prop="createTime"
  158. align="center"
  159. label="创建时间"
  160. show-overflow-tooltip
  161. >
  162. </el-table-column>
  163. <el-table-column
  164. align="center"
  165. prop="status"
  166. label="状态"
  167. show-overflow-tooltip
  168. >
  169. </el-table-column>
  170. <el-table-column prop="address" width="180px" fixed="right" align="center" label="操作">
  171. <template slot-scope="scope">
  172. <el-button
  173. type="text"
  174. size="small"
  175. @click="handleDetail(scope.row,'detail')"
  176. >查看</el-button
  177. >
  178. <el-button
  179. type="text"
  180. size="small"
  181. @click="handleDetail(scope.row,'edit')"
  182. >编辑</el-button
  183. >
  184. <el-button type="text" size="small" v-if="scope.row.status == '进行中'" @click="handle(scope.row.id)">停止</el-button>
  185. <el-button type="text" size="small" v-else @click="handleDel(scope.row.id)"
  186. >删除</el-button
  187. >
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. <div class="page-box">
  192. <el-pagination
  193. @size-change="handleSizeChange"
  194. @current-change="handleCurrentChange"
  195. background
  196. :current-page="query.currentPage"
  197. :page-sizes="[10, 20, 30, 40]"
  198. :page-size="query.pageSize"
  199. layout="total, sizes, prev, pager, next, jumper"
  200. :total="total"
  201. >
  202. </el-pagination>
  203. </div>
  204. </div>
  205. </template>
  206. <script>
  207. import { debounce } from "@/utils/index";
  208. import { getCouponList, delCoupon,stop } from "@/api/coupon";
  209. export default {
  210. name: "couponManage",
  211. data() {
  212. return {
  213. tableData: [],
  214. options: [
  215. {
  216. value: "1",
  217. label: "满减券",
  218. },
  219. {
  220. value: "2",
  221. label: "打折券",
  222. },
  223. {
  224. value: "3",
  225. label: "加油券",
  226. },
  227. ],
  228. options1: [
  229. {
  230. value: "1",
  231. label: "未开始",
  232. },
  233. {
  234. value: "2",
  235. label: "进行中",
  236. },
  237. {
  238. value: "3",
  239. label: "已停止",
  240. },
  241. ],
  242. loading: false,
  243. query: {
  244. couponName:'',
  245. couponType: 3,
  246. status:'',
  247. startTime:'',
  248. endTime:'',
  249. currentPage: 1,
  250. pageSize: 10,
  251. },
  252. total: 0,
  253. date:[]
  254. };
  255. },
  256. watch: {
  257. date(val){
  258. if(val){
  259. this.query.startTime = val[0]
  260. this.query.endTime = val[1]
  261. }else{
  262. this.query.startTime = ''
  263. this.query.endTime = ''
  264. }
  265. }
  266. },
  267. filters: {
  268. filterType: function(value) {
  269. if(value == 1){
  270. return '满减券';
  271. }else if(value == 2){
  272. return '打折券';
  273. }else if(value == 3){
  274. return '加油券';
  275. }
  276. }
  277. },
  278. methods: {
  279. handleSearch(){
  280. this.query.currentPage = 1
  281. this.getList();
  282. },
  283. handleAdd(path) {
  284. this.$router.push({
  285. path: path,
  286. });
  287. },
  288. handle(id) {
  289. this.$confirm(`此操作将停止该优惠券活动, 是否继续?`, "提示", {
  290. confirmButtonText: "确定",
  291. cancelButtonText: "取消",
  292. type: "warning",
  293. }).then(() => {
  294. stop({
  295. id
  296. }).then((res) => {
  297. if (res.state == "Success") {
  298. this.$notify({
  299. title: "成功",
  300. message: "操作成功",
  301. type: "success",
  302. });
  303. this.handleSearch();
  304. }
  305. });
  306. });
  307. },
  308. handleDetail(row,mode) {
  309. let url
  310. if(row.couponType == 1){
  311. url = 'fullDiscountCoupon'
  312. }else if(row.couponType == 2){
  313. url = 'discountCoupon'
  314. }else if(row.couponType == 3){
  315. url = 'refuelCoupon'
  316. }
  317. this.$router.push({
  318. path: "/operationManage/couponManage/"+url,
  319. query: {
  320. id:row.id,
  321. mode,
  322. status:row.status
  323. },
  324. });
  325. },
  326. handleDel(id){
  327. this.$confirm(`此操作将删除该优惠券活动, 是否继续?`, "提示", {
  328. confirmButtonText: "确定",
  329. cancelButtonText: "取消",
  330. type: "warning",
  331. }).then(() => {
  332. delCoupon({
  333. id
  334. }).then((res) => {
  335. if (res.state == "Success") {
  336. this.$notify({
  337. title: "成功",
  338. message: "操作成功",
  339. type: "success",
  340. });
  341. this.handleSearch();
  342. }
  343. });
  344. });
  345. },
  346. handleSizeChange(val) {
  347. this.query.currentPage = 1;
  348. this.query.pageSize = val;
  349. this.getList();
  350. },
  351. handleCurrentChange(val) {
  352. this.query.currentPage = val;
  353. this.getList();
  354. },
  355. getList() {
  356. this.loading = true;
  357. let query = JSON.parse(JSON.stringify(this.query))
  358. if(!query.status){
  359. delete query.status
  360. }
  361. if(!query.couponType){
  362. delete query.couponType
  363. }
  364. getCouponList(query).then((res) => {
  365. this.loading = false;
  366. if (res.state == "Success") {
  367. this.tableData = res.content.records;
  368. this.total = res.content.total;
  369. }
  370. });
  371. },
  372. },
  373. created() {
  374. this.getList();
  375. },
  376. };
  377. </script>
  378. <style lang="scss" scoped>
  379. .couponManage {
  380. .type-box{
  381. display: flex;
  382. align-items: center;
  383. margin-bottom: 20px;
  384. .type{
  385. display: flex;
  386. flex-direction: column;
  387. align-items: center;
  388. background: rgba(244, 248, 253, 1);
  389. border-radius: 8px;
  390. padding: 20px;
  391. width: 250px;
  392. .title{
  393. font-size: 20px;
  394. color: #222;
  395. font-weight: bold;
  396. margin-bottom: 10px;
  397. }
  398. .desc{
  399. color: #aaa;
  400. font-size: 14px;
  401. }
  402. .add-btn{
  403. margin-top: 10px;
  404. }
  405. }
  406. .type+.type{
  407. margin-left: 20px;
  408. }
  409. }
  410. .search {
  411. justify-content: space-between;
  412. .add-btn {
  413. // margin-right: 20px;
  414. }
  415. }
  416. }
  417. </style>