list.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. $diyPath = dirname(__DIR__) . '/components';
  4. ComponentHelper::loadComponentView('stock-edit', $diyPath);
  5. ?>
  6. <div id="app" v-cloak>
  7. <el-card shadow="never" style="border:0;min-width: 1500px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  8. <div slot="header">
  9. <span>亲友卡列表</span>
  10. <div style="float: right;margin-top: -5px">
  11. <el-button type="primary" @click="editClick" size="small">添加亲友卡</el-button>
  12. </div>
  13. </div>
  14. <div class="table-body">
  15. <div class="input-item">
  16. <el-input @keyup.enter.native="loadData" size="small" placeholder="亲友卡名称" v-model="search.keyword"
  17. clearable @clear="toSearch">
  18. </el-input>
  19. </div>
  20. <div class="input-item">
  21. <el-input @keyup.enter.native="loadData" size="small" placeholder="会员信息" v-model="search.keyword2"
  22. clearable @clear="toSearch">
  23. </el-input>
  24. </div>
  25. <el-select size="small" v-model="search.type" @change='toSearch' class="select" placeholder="请选择">
  26. <el-option :key="item.value" :label="item.label" :value="item.value"
  27. v-for="(item, index) in incomeCapitalTypeList"></el-option>
  28. </el-select>
  29. <el-date-picker
  30. style="margin-right: 20px;"
  31. size="small"
  32. v-model="selectData"
  33. type="daterange"
  34. value-format="yyyy-MM-dd"
  35. range-separator="至"
  36. start-placeholder="开始日期"
  37. end-placeholder="结束日期">
  38. </el-date-picker>
  39. <el-button type="primary" size="small" style="padding: 9px 15px !important;" @click="toSearch">搜索</el-button>
  40. <el-tabs v-model="activeName" @tab-click="handleClick">
  41. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;"
  42. @selection-change="handleSelectionChange">
  43. <el-table-column prop="id" label="编码" align="center"></el-table-column>
  44. <el-table-column prop="user_id" label="用户ID" align="center"></el-table-column>
  45. <el-table-column label="基本信息" >
  46. <template slot-scope="scope">
  47. <div class="user_img" flex="cross:center">
  48. <el-image class="default-avatar" :src="scope.row.avatar_url">
  49. <div slot="error" class="image-slot">
  50. <com-image src="resources/img/mall/default_avatar_url.png"></com-image>
  51. </div>
  52. </el-image>
  53. <div class="uer-nickname over1" v-if="scope.row.nickname">{{scope.row.nickname}}</div>
  54. <div class="uer-nickname over1" v-else >ID:{{scope.row.user_id}}</div>
  55. </div>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="卡的编号" prop="mobile" align="center" >
  59. <template slot-scope="scope">
  60. <div>{{scope.row.card_no}}</div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="名称" prop="mobile" align="center" >
  64. <template slot-scope="scope">
  65. <div>{{scope.row.name}}</div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="样式" prop="background_url" align="center" style="width: 50px;height: 50px;">
  69. <template slot-scope="scope">
  70. <div>
  71. <el-image :src="scope.row.background_url" :preview-src-list="[scope.row.background_url]">
  72. </el-image>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="折扣" prop="discount" align="center" >
  77. <template slot-scope="scope">
  78. <div>{{scope.row.discount}}</div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="子卡数量" prop="child_num" align="center" >
  82. <template slot-scope="scope">
  83. <div v-if="sort_id != scope.row.id">
  84. <el-tooltip class="item" effect="dark" content="子卡数量" placement="top">
  85. <span>{{scope.row.child_num}}</span>
  86. </el-tooltip>
  87. <el-button class="edit-sort" type="text" @click="editNum(scope.row,'sort')">
  88. <img src="resources/img/mall/order/edit.png" alt="">
  89. </el-button>
  90. </div>
  91. <div style="display: flex;align-items: center" v-else>
  92. <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="sort" autocomplete="off"></el-input>
  93. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('sort')"></el-button>
  94. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('sort',scope.row)">
  95. </el-button>
  96. </div>
  97. </template>
  98. <!-- <template slot-scope="scope">
  99. <div>{{scope.row.child_num}}</div>
  100. </template> -->
  101. </el-table-column>
  102. <el-table-column label="创建时间" align="center">
  103. <template slot-scope="scope">
  104. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="过期时间" align="center">
  108. <template slot-scope="scope">
  109. {{scope.row.expired_at|dateTimeFormat('Y-m-d H:i:s')}}
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" min-width="150" align="center">
  113. <template slot-scope="scope">
  114. <el-button type="text" @click="editDetail(scope.row.id)">查看亲友</el-button>
  115. <el-button type="text" @click="operate('destroy',scope.row)">删除</el-button>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. </el-tabs>
  120. <div flex="box:last cross:center">
  121. <div></div>
  122. <div>
  123. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  124. style="display: inline-block;float: right;" background @current-change="pageChange"
  125. layout="prev, pager, next" :total="pagination.totalCount">
  126. </el-pagination>
  127. </div>
  128. </div>
  129. </div>
  130. </el-card>
  131. <stock-edit v-model="edit.show" @savesuccess="stockEditFun"></stock-edit>
  132. </div>
  133. <script>
  134. const app = new Vue({
  135. el: '#app',
  136. data: {
  137. avatar: '',
  138. nickname: '',
  139. search: {
  140. keyword: '',
  141. keyword2:'',
  142. page: 1,
  143. start:'',
  144. end:'',
  145. type:'',
  146. },
  147. loading: false,
  148. activeName: '-1',
  149. list: [],
  150. pagination: null,
  151. dialogChild: false,
  152. dialogLoading: false,
  153. dialogContent: false,
  154. remarksForm: {
  155. remarks: '',
  156. user_id: '',
  157. id: '',
  158. },
  159. remarksLoading: false,
  160. exportList: {},
  161. userEdit: {
  162. show: false,
  163. },
  164. level: {
  165. show: false,
  166. agent: null,
  167. },
  168. commission_arr: {},
  169. agentLevelList: [],
  170. levelList: {},
  171. choose_list: [],
  172. sort: 0,
  173. sort_id: 0,
  174. incomeCapitalTypeList:[
  175. {
  176. value:1,
  177. label:'母卡',
  178. },
  179. {
  180. value:2,
  181. label:'子卡',
  182. },
  183. ],
  184. selectData:'',
  185. edit: {
  186. show: false,
  187. },
  188. },
  189. mounted() {
  190. this.loadData();
  191. },
  192. methods: {
  193. loadData() {
  194. this.loading = true;
  195. let params = {
  196. r: 'members-card/default/list'
  197. };
  198. params = Object.assign(params, this.search);
  199. request({
  200. params: params,
  201. method: 'get',
  202. }).then(e => {
  203. this.loading = false;
  204. if (e.data.code == 0) {
  205. this.list = e.data.data.list;
  206. this.pagination = e.data.data.pagination;
  207. } else {
  208. this.$message.error(e.data.msg);
  209. }
  210. }).catch(e => {
  211. this.loading = false;
  212. });
  213. },
  214. pageChange(page) {
  215. this.search.page = page;
  216. this.loadData();
  217. },
  218. handleClick(tab, event) {
  219. this.search.page = 1;
  220. this.search.status = this.activeName;
  221. this.loadData()
  222. },
  223. toSearch() {
  224. if(this.selectData && this.selectData[0]){
  225. this.search.start = this.selectData[0];
  226. this.search.end = this.selectData[1];
  227. }else{
  228. this.search.start = '';
  229. this.search.end = '';
  230. }
  231. this.search.page = 1;
  232. this.loadData();
  233. },
  234. switchFun(event,id){
  235. console.log(event);
  236. this.listLoading = true;
  237. request({
  238. params: {
  239. r: 'members-card/default/update-status'
  240. },
  241. method: 'post',
  242. data:{
  243. id:id,
  244. is_enable:event,
  245. }
  246. }).then(e => {
  247. this.listLoading = false;
  248. if (e.data.code == 0) {
  249. this.$message.success('更改状态成功');
  250. } else {
  251. this.$message.error(e.data.msg);
  252. }
  253. this.loadData();
  254. }).catch(e => {
  255. this.$message.error(e.data.msg);
  256. this.listLoading = false;
  257. this.loadData();
  258. });
  259. },
  260. // 跳转编辑页
  261. editDetail(id) {
  262. id = parseInt(id);
  263. let params = {
  264. r: 'members-card/default/child-list',
  265. };
  266. if (id) params = Object.assign(params, {
  267. id: id
  268. });
  269. navigateTo(params);
  270. },
  271. operate(type, data = null) {
  272. let param = { id: data.id, type: type };
  273. switch (type) {
  274. case 'destroy':
  275. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {
  276. type: 'warning'
  277. }).then(() => {
  278. this.send(param)
  279. })
  280. break;
  281. }
  282. },
  283. send(params) {
  284. let self = this;
  285. request({
  286. params: {
  287. r: 'members-card/default/list-label',
  288. },
  289. method: 'post',
  290. data: params
  291. }).then(e => {
  292. if (e.data.code == 0) {
  293. self.$message.success(e.data.msg);
  294. self.loadData();
  295. } else {
  296. self.$message.error(e.data.msg);
  297. }
  298. }).catch(e => {
  299. console.log(e);
  300. });
  301. },
  302. editClick() {
  303. this.edit.show = true;
  304. },
  305. stockEditFun(){
  306. this.loadData();
  307. },
  308. editNum(row, type) {
  309. switch (type) {
  310. case 'sort':
  311. this.sort = row.child_num;
  312. this.sort_id = row.id;
  313. break;
  314. }
  315. },
  316. cancelEdit(type) {
  317. switch (type) {
  318. case 'sort':
  319. this.sort = 0;
  320. this.sort_id = 0;
  321. break;
  322. }
  323. },
  324. handle(type, data = null) {
  325. let id = data ? parseInt(data.id) : '';
  326. switch (type) {
  327. case 'sort':
  328. param = {
  329. id: id,
  330. child_num: this.sort,
  331. type:type,
  332. };
  333. this.send(param);
  334. break;
  335. }
  336. this.cancelEdit(type);
  337. },
  338. }
  339. });
  340. </script>
  341. <style>
  342. .el-tabs__header {
  343. font-size: 16px;
  344. }
  345. .table-body {
  346. padding: 20px;
  347. background-color: #fff;
  348. }
  349. .table-body .el-button {
  350. padding: 0 !important;
  351. border: 0;
  352. margin: 0 5px;
  353. }
  354. .input-item {
  355. width: 250px;
  356. margin: 0 0 20px;
  357. display: inline-block;
  358. }
  359. /*.input-item .el-input__inner {*/
  360. /* border-right: 0;*/
  361. /*}*/
  362. .input-item .el-input__inner:hover {
  363. border: 1px solid #dcdfe6;
  364. /*border-right: 0;*/
  365. outline: 0;
  366. }
  367. .input-item .el-input__inner:focus {
  368. border: 1px solid #dcdfe6;
  369. /*border-right: 0;*/
  370. outline: 0;
  371. }
  372. .input-item .el-input-group__append {
  373. background-color: #fff;
  374. border-left: 0;
  375. width: 10%;
  376. padding: 0;
  377. }
  378. .input-item .el-input-group__append .el-button {
  379. padding: 0;
  380. }
  381. .input-item .el-input-group__append .el-button {
  382. margin: 0;
  383. }
  384. .batch {
  385. margin: 0 0 20px;
  386. display: inline-block;
  387. }
  388. .batch .el-button {
  389. padding: 9px 15px !important;
  390. }
  391. .el-table th>.cell{
  392. color: #333;
  393. font-weight: bold;
  394. font-size: 14px;
  395. }
  396. .el-table__footer-wrapper, .el-table__header-wrapper{
  397. border-bottom: 1.4px solid #D6D6D6;
  398. }
  399. .el-table th>.cell {
  400. color: #333;
  401. font-weight: bold;
  402. font-size: 14px;
  403. }
  404. .table1 .el-table__footer-wrapper,
  405. .table1 .el-table__header-wrapper {
  406. border-bottom: 1.4px solid #D6D6D6;
  407. }
  408. .user_img{
  409. position: relative;
  410. margin-right: 8px;
  411. /* height: 50px;
  412. width: 50px; */
  413. }
  414. .default-avatar{
  415. width: 50px;
  416. height: 50px;
  417. border-radius: 50%;
  418. margin-right: 8px;
  419. }
  420. .uer-nickname {
  421. flex: 1;
  422. }
  423. </style>