index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-image');
  4. ?>
  5. <style>
  6. </style>
  7. <div id="app" v-cloak>
  8. <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  9. <div slot="header">
  10. <span>推广员列表</span>
  11. </div>
  12. <div class="table-body">
  13. <div class="input-item">
  14. <el-input @keyup.enter.native="loadData" size="small" placeholder="请输入用户id" v-model="search.user_id"
  15. clearable @clear="toSearch">
  16. </el-input>
  17. </div>
  18. <div class="input-item">
  19. <el-input @keyup.enter.native="loadData" size="small" placeholder="请输入用户昵称/手机号搜索" v-model="search.keyword" clearable @clear="toSearch">
  20. </el-input>
  21. </div>
  22. <el-button type="primary" size="small" style="padding: 9px 15px !important;" @click="toSearch">搜索</el-button>
  23. <div style="float: right">
  24. <el-button type="primary" size="small" style="padding: 9px 15px !important;" @click="editClick">添加推广员
  25. </el-button>
  26. </div>
  27. <el-tabs v-model="activeName" @tab-click="handleClick">
  28. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;"
  29. @selection-change="handleSelectionChange">
  30. <el-table-column prop="user_id" label="用户ID" align="center"></el-table-column>
  31. <el-table-column label="基本信息" >
  32. <template slot-scope="scope">
  33. <div class="user_img" flex="cross:center">
  34. <el-image class="default-avatar" :src="scope.row.avatar_url">
  35. <div slot="error" class="image-slot">
  36. <com-image src="resources/img/mall/default_avatar_url.png"></com-image>
  37. </div>
  38. </el-image>
  39. <div class="uer-nickname over1" v-if="scope.row.nickname">{{scope.row.nickname}}</div>
  40. <div class="uer-nickname over1" v-else >ID:{{scope.row.user_id}}</div>
  41. </div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="手机号" prop="mobile" align="center" >
  45. <template slot-scope="scope">
  46. <div>{{scope.row.mobile}}</div>
  47. </template>
  48. </el-table-column></el-table-column>
  49. <el-table-column label="时间" align="center">
  50. <template slot-scope="scope">
  51. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  52. </template>
  53. </el-table-column>
  54. </el-table-column>
  55. <el-table-column label="操作" align="center">
  56. <template slot-scope="scope">
  57. <el-button circle size="mini" type="text" @click="promoterDelete(scope.row, scope.$index)">
  58. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  59. <img src="resources/img/mall/del.png" alt="">
  60. </el-tooltip>
  61. </el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. </el-tabs>
  66. <div flex="box:last cross:center">
  67. <div></div>
  68. <div>
  69. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  70. style="display: inline-block;float: right;" background @current-change="pageChange"
  71. layout="prev, pager, next" :total="pagination.totalCount">
  72. </el-pagination>
  73. </div>
  74. </div>
  75. </div>
  76. </el-card>
  77. <el-dialog :visible.sync="edit_visible" width="20%" title="添加推广员">
  78. <div>
  79. <el-form @submit.native.prevent size="small" label-width="150px">
  80. <el-form-item label="用户昵称">
  81. <el-autocomplete size="small" v-model="edit_nickname" value-key="nickname"
  82. @keyup.enter.native="keyUp"
  83. :fetch-suggestions="querySearchAsync" placeholder="请输入用户昵称/id/手机号"
  84. @select="agentClick"></el-autocomplete>
  85. </el-form-item>
  86. </el-form>
  87. </div>
  88. <span slot="footer" class="dialog-footer">
  89. <el-button @click="editCancel" type="default" size="small">取消</el-button>
  90. <el-button type="primary" :loading="edit_btnLoading" style="margin-bottom: 10px;" size="small"
  91. @click="editSave">保存</el-button>
  92. </span>
  93. </el-dialog>
  94. </div>
  95. <script>
  96. const app = new Vue({
  97. el: '#app',
  98. data: {
  99. edit_visible:false,
  100. edit_btnLoading:false,
  101. edit_nickname:'',
  102. edit_id:'',
  103. search: {
  104. user_id: null,
  105. keyword: '',
  106. status: -1,
  107. page: 1,
  108. level: ''
  109. },
  110. avatar: '',
  111. nickname: '',
  112. loading: false,
  113. activeName: '-1',
  114. list: [],
  115. pagination: null,
  116. dialogLoading: false,
  117. choose_list: [],
  118. },
  119. mounted() {
  120. this.loadData();
  121. },
  122. methods: {
  123. agentClick(row) {
  124. this.edit_id = row.id
  125. },
  126. querySearchAsync(queryString, cb) {
  127. this.get_user(cb);
  128. },
  129. get_user(cb) {
  130. request({
  131. params: {
  132. r: 'course/course-promoter/search-user',
  133. keyword: this.edit_nickname
  134. }
  135. }).then(res => {
  136. if (res.data.code == 0) {
  137. cb(res.data.data.list)
  138. } else {
  139. this.$message.error(res.data.msg);
  140. }
  141. });
  142. },
  143. editSave() {
  144. this.edit_btnLoading = true;
  145. if(!this.edit_id){
  146. this.$message.error('请选择会员');
  147. this.edit_btnLoading = false;
  148. return false;
  149. }
  150. request({
  151. params: {
  152. r: 'course/course-promoter/edit',
  153. },
  154. method: 'post',
  155. data: {
  156. user_id: this.edit_id,
  157. }
  158. }).then(response => {
  159. this.edit_btnLoading = false;
  160. if (response.data.code == 0) {
  161. this.$message.success('添加成功');
  162. this.editCancel();
  163. } else {
  164. this.$message.error(response.data.msg);
  165. }
  166. }).catch(response => {
  167. this.edit.btnLoading = false;
  168. });
  169. },
  170. editCancel() {
  171. this.$emit('input', false);
  172. navigateTo({
  173. r: 'course/course-promoter/index',
  174. })
  175. },
  176. promoterDelete(row, index) {
  177. let self = this;
  178. self.$confirm('删除该推广员, 是否继续?', '提示', {
  179. confirmButtonText: '确定',
  180. cancelButtonText: '取消',
  181. type: 'warning'
  182. }).then(() => {
  183. self.listLoading = true;
  184. request({
  185. params: {
  186. r: 'course/course-promoter/delete',
  187. },
  188. method: 'post',
  189. data: {
  190. id: row.id,
  191. }
  192. }).then(e => {
  193. self.listLoading = false;
  194. if (e.data.code === 0) {
  195. self.$message.success(e.data.msg);
  196. self.list.splice(index, 1);
  197. } else {
  198. self.$message.error(e.data.msg);
  199. }
  200. }).catch(e => {
  201. console.log(e);
  202. });
  203. }).catch(() => {
  204. self.$message.info('已取消删除')
  205. });
  206. },
  207. loadData() {
  208. this.loading = true;
  209. let params = {
  210. r: 'course/course-promoter/index'
  211. };
  212. params = Object.assign(params, this.search);
  213. request({
  214. params: params,
  215. method: 'get',
  216. }).then(e => {
  217. this.loading = false;
  218. if (e.data.code == 0) {
  219. this.list = e.data.data.list;
  220. this.pagination = e.data.data.pagination;
  221. } else {
  222. this.$message.error(e.data.msg);
  223. }
  224. }).catch(e => {
  225. this.loading = false;
  226. });
  227. },
  228. pageChange(page) {
  229. this.search.page = page;
  230. this.loadData();
  231. },
  232. handleClick(tab, event) {
  233. this.search.page = 1;
  234. this.search.status = this.activeName;
  235. this.loadData()
  236. },
  237. toSearch() {
  238. this.search.page = 1;
  239. this.loadData();
  240. },
  241. editClick() {
  242. this.edit_visible = true;
  243. },
  244. handleSelectionChange(val) {
  245. let self = this;
  246. self.choose_list = [];
  247. val.forEach(function (item) {
  248. self.choose_list.push(item.id);
  249. })
  250. }
  251. }
  252. });
  253. </script>
  254. <style>
  255. .el-tabs__header {
  256. font-size: 16px;
  257. }
  258. .table-body {
  259. padding: 20px;
  260. background-color: #fff;
  261. }
  262. .table-body .el-button {
  263. padding: 0 !important;
  264. border: 0;
  265. margin: 0 5px;
  266. }
  267. .input-item {
  268. width: 250px;
  269. margin: 0 0 20px;
  270. display: inline-block;
  271. }
  272. /*.input-item .el-input__inner {*/
  273. /* border-right: 0;*/
  274. /*}*/
  275. .input-item .el-input__inner:hover {
  276. border: 1px solid #dcdfe6;
  277. /*border-right: 0;*/
  278. outline: 0;
  279. }
  280. .input-item .el-input__inner:focus {
  281. border: 1px solid #dcdfe6;
  282. /*border-right: 0;*/
  283. outline: 0;
  284. }
  285. .input-item .el-input-group__append {
  286. background-color: #fff;
  287. border-left: 0;
  288. width: 10%;
  289. padding: 0;
  290. }
  291. .input-item .el-input-group__append .el-button {
  292. padding: 0;
  293. }
  294. .input-item .el-input-group__append .el-button {
  295. margin: 0;
  296. }
  297. .batch {
  298. margin: 0 0 20px;
  299. display: inline-block;
  300. }
  301. .batch .el-button {
  302. padding: 9px 15px !important;
  303. }
  304. .el-table th>.cell{
  305. color: #333;
  306. font-weight: bold;
  307. font-size: 14px;
  308. }
  309. .el-table__footer-wrapper, .el-table__header-wrapper{
  310. border-bottom: 1.4px solid #D6D6D6;
  311. }
  312. .el-table th>.cell {
  313. color: #333;
  314. font-weight: bold;
  315. font-size: 14px;
  316. }
  317. .table1 .el-table__footer-wrapper,
  318. .table1 .el-table__header-wrapper {
  319. border-bottom: 1.4px solid #D6D6D6;
  320. }
  321. .user_img{
  322. position: relative;
  323. margin-right: 8px;
  324. /* height: 50px;
  325. width: 50px; */
  326. }
  327. .default-avatar{
  328. width: 50px;
  329. height: 50px;
  330. border-radius: 50%;
  331. margin-right: 8px;
  332. }
  333. .uer-nickname {
  334. flex: 1;
  335. }
  336. </style>