index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <style>
  2. .link_url {
  3. text-align: left;
  4. font-size: 14px;
  5. }
  6. .showqr .el-dialog__body {
  7. text-align: center;
  8. padding-bottom: 10px;
  9. }
  10. .el-dialog {
  11. min-width: 400px;
  12. }
  13. </style>
  14. <div id="app" v-cloak>
  15. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  16. <div slot="header">
  17. <span>电子券管理</span>
  18. <div style="float: right;margin-top: -5px">
  19. <el-button type="primary"
  20. @click="$navigate({r: 'electron-coupon/default/edit'})"
  21. size="small">新建电子券
  22. </el-button>
  23. </div>
  24. </div>
  25. <div class="search-box">
  26. <!-- 搜索 -->
  27. <el-form :inline="true" :model="searchForm" size="small" class="demo-form-inline">
  28. <el-form-item label="电子券名称">
  29. <el-input placeholder="请输入电子券名称" v-model="searchForm.name"></el-input>
  30. </el-form-item>
  31. <el-form-item label="领取状态">
  32. <el-select v-model="searchForm.receive_status" placeholder="请选择领取状态">
  33. <el-option v-for="(name, index) in receive_status_option" :label="name" :value="index" :key="index"></el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="使用状态">
  37. <el-select v-model="searchForm.usage_status" placeholder="请选择使用状态">
  38. <el-option v-for="(item,index) in usage_status_option" :label="item" :value="index" :key="index"></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" @click="search">搜索</el-button>
  43. <el-button type="danger" @click="resetSearch" v-if="show_clear_search_btn">清除条件</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </div>
  47. <div class="table-body">
  48. <el-tabs>
  49. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;">
  50. <el-table-column prop="id" label="序号" align="center"></el-table-column>
  51. <!-- <el-table-column prop="name" label="电子券名称" align="center"></el-table-column>-->
  52. <el-table-column
  53. label="电子券名称"
  54. min-width="120">
  55. <template slot-scope="scope">
  56. <div style="display: flex;align-items: center;">
  57. <el-image fit="cover" :src="scope.row.pic ? scope.row.pic : diy_img_prefix + '/static/addons/ElectronCoupon/ElectronCoupon.png'" style="width: 40px;height: 40px;display: block;margin-right: 5px;flex-shrink: 0;"></el-image>
  58. <div>
  59. <div>{{scope.row.name}}</div>
  60. </div>
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="price" label="激活金额" align="center"></el-table-column>
  65. <el-table-column label="专有券" align="center" width="65px">
  66. <template slot-scope="scope">
  67. <span v-if="scope.row.is_proper == 1">是</span>
  68. <span v-else>否</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="类型" align="center" width="65px">
  72. <template slot-scope="scope">
  73. <span v-if="scope.row.pieces_type == 1">单券</span>
  74. <span v-else>多券</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="领取时间" min-width="150" align="center">
  78. <template slot-scope="scope">
  79. {{ scope.row.receive_begin_time | dateTimeFormat('Y-m-d H:i') }} 至 {{ scope.row.receive_end_time | dateTimeFormat('Y-m-d H:i') }}
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="使用时间" min-width="150" align="center">
  83. <template slot-scope="scope">
  84. {{ scope.row.use_begin_time | dateTimeFormat('Y-m-d H:i') }} 至 {{ scope.row.use_end_time | dateTimeFormat('Y-m-d H:i') }}
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="user_level_name" label="可领取等级" min-width="90" align="center">
  88. <template slot-scope="scope">
  89. <span v-if="scope.row.receive_codition == 1">全体会员</span>
  90. <span v-else>{{ scope.row.user_level_name }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column prop="used_amount" label="已兑换" min-width="90" align="center"></el-table-column>
  94. <el-table-column prop="receive_amount" label="已领取" min-width="90" align="center"></el-table-column>
  95. <el-table-column prop="remain_num" label="剩余数量" min-width="90" align="center"></el-table-column>
  96. <el-table-column prop="give_quantity" label="赠送数量" min-width="90" align="center"></el-table-column>
  97. <el-table-column prop="is_show_in_center" label="领取中心" min-width="90" align="center">
  98. <template slot-scope="scope">
  99. <el-switch
  100. v-model="scope.row.is_show_in_center"
  101. @change="((val)=>{switchFun(val,scope.row.id,'is_show_in_center')})"
  102. :active-value="1"
  103. :inactive-value="0"
  104. active-text=""
  105. inactive-text=""
  106. >
  107. </el-switch>
  108. </template>
  109. </el-table-column>
  110. <el-table-column prop="status" label="状态" min-width="90" align="center">
  111. <template slot-scope="scope">
  112. <el-switch
  113. v-model="scope.row.status"
  114. @change="((val)=>{switchFunStatus(val,scope.row.id,'status')})"
  115. :active-value="1"
  116. :inactive-value="0"
  117. active-text=""
  118. inactive-text=""
  119. >
  120. </el-switch>
  121. </template>
  122. </el-table-column>
  123. <el-table-column prop="receive_status_name" label="领取状态" min-width="90" align="center"></el-table-column>
  124. <el-table-column prop="usage_status_name" label="使用状态" min-width="90" align="center"></el-table-column>
  125. <el-table-column label="操作" align="center" fixed="right" >
  126. <template slot-scope="scope">
  127. <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
  128. <el-button type="text" @click="handle('destroy',scope.row)">删除</el-button>
  129. <el-button type="text" @click="giveClick(scope.row.id)">赠送</el-button>
  130. <el-button type="text" @click="userCoupon(scope.row.id)">列表</el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. <div style="text-align: right;margin: 20px 0;">
  135. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  136. </div>
  137. </el-tabs>
  138. </div>
  139. </el-card>
  140. <el-dialog :visible.sync="give.show" width="20%" title="赠送电子券">
  141. <div>
  142. <el-form @submit.native.prevent size="small" label-width="150px">
  143. <el-form-item label="用户昵称">
  144. <el-autocomplete size="small" v-model="give.nickname" value-key="nickname" @keyup.enter.native="keyUp"
  145. :fetch-suggestions="querySearchAsync" placeholder="请输入用户昵称/id/手机号"
  146. @select="shareClick"></el-autocomplete>
  147. </el-form-item>
  148. <el-form-item label="赠送数量" prop="marks">
  149. <el-input type="number"
  150. :rows="4"
  151. placeholder="数量"
  152. v-model="give.number">
  153. </el-input>
  154. </el-form-item>
  155. </el-form>
  156. </div>
  157. <span slot="footer" class="dialog-footer">
  158. <el-button @click="giveCancel" type="default" size="small">取消</el-button>
  159. <el-button type="primary" :loading="give.btnLoading" style="margin-bottom: 10px;" size="small" @click="giveSave">保存</el-button>
  160. </span>
  161. </el-dialog>
  162. </div>
  163. <script>
  164. const app = new Vue({
  165. el: '#app',
  166. data: {
  167. diy_img_prefix: '<?= Yii::getAlias('@attachurl') ?>',
  168. loading: false,
  169. give: {
  170. show:false,
  171. btnLoading:false,
  172. user_id:0,
  173. e_coupon_id:0,
  174. number:0,
  175. keyword:'',
  176. },
  177. delLoading: false,
  178. page: 1,
  179. pageCount: 0,
  180. list: [],
  181. receive_status_option: {
  182. 0: '未开始',
  183. 1: '领取中',
  184. 2: '已结束'
  185. },
  186. usage_status_option: {
  187. 0: '未开始',
  188. 1: '使用中',
  189. 2: '已过期'
  190. },
  191. searchForm:{
  192. name: null,
  193. receive_status: null,
  194. usage_status: null,
  195. },
  196. },
  197. mounted() {
  198. this.getList();
  199. },
  200. computed: {
  201. show_clear_search_btn: function() {
  202. return this.searchForm.name != null ||
  203. this.searchForm.receive_status != null ||
  204. this.searchForm.usage_status != null;
  205. },
  206. },
  207. methods: {
  208. pagination(currentPage) {
  209. let self = this;
  210. self.page = currentPage;
  211. self.getList();
  212. },
  213. switchFun(val, id, field) {
  214. if (field == 'is_show_in_center') {
  215. let param = {id: id, is_show_in_center: val};
  216. this.send('electron-coupon/default/handle',param)
  217. }
  218. },
  219. handle(type, data = null) {
  220. let id = data ? parseInt(data.id) : '';
  221. switch (type) {
  222. case 'edit':
  223. let params = {
  224. r: 'electron-coupon/default/edit'
  225. };
  226. if (id) params = Object.assign(params, {
  227. id: id
  228. });
  229. navigateTo(params);
  230. break;
  231. case 'destroy':
  232. param = {id: data.id,status: -1};
  233. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {this.send('electron-coupon/default/handle',param)})
  234. break;
  235. }
  236. },
  237. send(url, params, callback = null) {
  238. let self = this;
  239. request({
  240. params: {
  241. r: url,
  242. },
  243. method: 'post',
  244. data: params
  245. }).then(e => {
  246. if (e.data.code == 0) {
  247. self.$message.success(e.data.msg);
  248. self.getList();
  249. } else {
  250. self.$message.error(e.data.msg);
  251. }
  252. }).catch(e => {
  253. console.log(e);
  254. });
  255. if(callback) return e.data;
  256. },
  257. search() {// 清空查询条件
  258. this.page = 1;
  259. this.getList(this.searchForm);
  260. },
  261. resetSearch() {// 清空查询条件
  262. this.searchForm = {
  263. name: null,
  264. receive_status: null,
  265. usage_status: null
  266. };
  267. this.page = 1;
  268. this.getList();
  269. },
  270. getList(search = {}) {
  271. let self = this;
  272. self.loading = true;
  273. let basic_params = {
  274. page: self.page
  275. };
  276. let params = Object.assign(basic_params, search);
  277. request({
  278. params: {
  279. r: 'electron-coupon/default/index'
  280. },
  281. method: 'post',
  282. data: params
  283. }).then(e => {
  284. self.loading = false;
  285. if (e.data.code == 0) {
  286. self.list = e.data.data.page_data.list;
  287. self.pageCount = e.data.data.page_data.page_count;
  288. } else {
  289. self.$message.error(e.data.msg);
  290. }
  291. }).catch(e => {
  292. self.loading = false;
  293. });
  294. },
  295. switchFunStatus(val, id, field) {
  296. let param = {id: id, status: val};
  297. this.send('electron-coupon/default/handle-status',param)
  298. },
  299. giveClick(id) {
  300. this.give.show = true;
  301. this.give.e_coupon_id = id;
  302. },
  303. shareClick(row) {
  304. this.give.user_id = row.id;
  305. },
  306. giveCancel() {
  307. this.$emit('input', false);
  308. this.give.show = false;
  309. },
  310. giveSave() {
  311. if (!this.give.user_id) {
  312. this.$message.error('请选择会员');
  313. return null;
  314. }
  315. this.give.btnLoading = true;
  316. request({
  317. params: {
  318. r: 'electron-coupon/default/give-coupon',
  319. },
  320. method: 'post',
  321. data: {
  322. e_coupon_id: this.give.e_coupon_id,
  323. user_id: this.give.user_id,
  324. number: this.give.number,
  325. }
  326. }).then(response => {
  327. this.give.btnLoading = false;
  328. if (response.data.code == 0) {
  329. this.$message.success('赠送成功');
  330. setTimeout(() => {
  331. location.reload();
  332. }, 500);
  333. this.editCancel();
  334. } else {
  335. this.$message.error(response.data.msg);
  336. }
  337. }).catch(response => {
  338. this.give.btnLoading = false;
  339. });
  340. },
  341. querySearchAsync(queryString, cb) {
  342. this.give.keyword = queryString;
  343. this.get_user(cb);
  344. },
  345. get_user(cb) {
  346. request({
  347. params: {
  348. r: 'distribution/default/search-user',
  349. keyword: this.give.keyword
  350. }
  351. }).then(res => {
  352. if (res.data.code == 0) {
  353. cb(res.data.data.list)
  354. } else {
  355. this.$message.error(res.data.msg);
  356. }
  357. });
  358. },
  359. userCoupon(id){
  360. this.$navigate({
  361. r: 'electron-coupon/user-coupon/index',
  362. e_coupon_id: id
  363. })
  364. },
  365. }
  366. });
  367. </script>
  368. <style>
  369. .el-tabs__header {
  370. font-size: 16px;
  371. }
  372. .table-body {
  373. padding: 20px;
  374. background-color: #fff;
  375. }
  376. .table-body .el-button {
  377. padding: 0 !important;
  378. border: 0;
  379. margin: 0 5px;
  380. }
  381. .input-item {
  382. width: 250px;
  383. margin: 0 0 20px;
  384. display: inline-block;
  385. }
  386. .input-item .el-input__inner {
  387. border-right: 0;
  388. }
  389. .input-item .el-input__inner:hover {
  390. border: 1px solid #dcdfe6;
  391. border-right: 0;
  392. outline: 0;
  393. }
  394. .input-item .el-input__inner:focus {
  395. border: 1px solid #dcdfe6;
  396. border-right: 0;
  397. outline: 0;
  398. }
  399. .input-item .el-input-group__append {
  400. background-color: #fff;
  401. border-left: 0;
  402. width: 10%;
  403. padding: 0;
  404. }
  405. .input-item .el-input-group__append .el-button {
  406. padding: 0;
  407. }
  408. .input-item .el-input-group__append .el-button {
  409. margin: 0;
  410. }
  411. .batch {
  412. margin: 0 0 20px;
  413. display: inline-block;
  414. }
  415. .batch .el-button {
  416. padding: 9px 15px !important;
  417. }
  418. .el-table th>.cell{
  419. color: #333;
  420. font-weight: bold;
  421. font-size: 14px;
  422. }
  423. .el-table__footer-wrapper, .el-table__header-wrapper{
  424. border-bottom: 1.4px solid #D6D6D6;
  425. }
  426. .search-box {
  427. padding: 10px 0 0 10px;
  428. background-color: #fff;
  429. margin-bottom: 10px;
  430. }
  431. </style>