index.php 14 KB

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