index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('components/area-edit', __DIR__);
  4. ComponentHelper::loadComponentView('components/area-level', __DIR__);
  5. ComponentHelper::loadComponentView('com-dialog-select');
  6. ComponentHelper::loadComponentView('com-user-info');
  7. ?>
  8. <style>
  9. .el-table th>.cell {
  10. color: #333;
  11. font-weight: bold;
  12. font-size: 14px;
  13. }
  14. .table1 .el-table__footer-wrapper,
  15. .table1 .el-table__header-wrapper {
  16. border-bottom: 1.4px solid #D6D6D6;
  17. }
  18. .user_img{
  19. position: relative;
  20. margin-right: 8px;
  21. /* height: 50px;
  22. width: 50px; */
  23. }
  24. .default-avatar{
  25. width: 50px;
  26. height: 50px;
  27. border-radius: 50%;
  28. margin-right: 8px;
  29. }
  30. .uer-nickname {
  31. flex: 1;
  32. }
  33. .name-box {
  34. display: flex;
  35. flex-direction: column;
  36. }
  37. .el-cascader--small{
  38. margin-right: 20px;
  39. }
  40. </style>
  41. <div id="app">
  42. <div class="table-body" style="min-width: 1000px;">
  43. <div slot="header" class="clearfix" style="height: 20px;">
  44. <span>区域代理列表</span>
  45. <el-button style="float: right; padding: 3px 12px;margin-left: 20px;height: 32px;" type="primary" @click="editClick">添加区域代理</el-button>
  46. </div>
  47. <div slot="header" class="clearfix" style="margin-top: 20px;">
  48. <div class="demo-input-suffix" style="margin-top: 20px;margin-bottom: 10px;">
  49. <el-input @keyup.enter.native="toSearchActivity" size="small" style="width:300px;margin-right: 20px;" placeholder="请输入会员昵称/ID/手机号" v-model="search.keyword" clearable>
  50. </el-input>
  51. <el-select size="small" v-model="search.level" @change='toSearch' class="select" style="margin-right: 20px;width: 150px;" placeholder="请选择代理等级">
  52. <el-option label="全部等级" value=""></el-option>
  53. <el-option :key="index" :label="item.name" :value="item.level" v-for="(item, index) in levelList"></el-option>
  54. </el-select>
  55. <el-date-picker
  56. style="margin-right: 20px;"
  57. size="small"
  58. v-model="selectDate"
  59. type="daterange"
  60. value-format="yyyy-MM-dd"
  61. range-separator="至"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期">
  64. </el-date-picker>
  65. <el-cascader
  66. placeholder="选择代理区域"
  67. @change="addressChange"
  68. :options="districtList"
  69. :props="addressProps"
  70. v-model="addressIdsMap"
  71. clearable @clear="clearAreaIds"
  72. size="small"
  73. >
  74. </el-cascader>
  75. <el-button type="primary" size="small" @click="toSearch">搜索</el-button>
  76. </div>
  77. </div>
  78. <template>
  79. <el-table :data="list" stripe style="width: 100%" v-loading="listLoading" class="table1">
  80. <el-table-column prop="user_id" label="用户ID" align="center"></el-table-column>
  81. <el-table-column label="基本信息">
  82. <template slot-scope="scope">
  83. <com-user-info :user="scope.row.user"></com-user-info>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="total_commission" label="累计佣金" align="center"></el-table-column>
  87. <el-table-column prop="parent" label="推荐人" align="center">
  88. <template slot-scope="scope">
  89. <div v-if="scope.row.user && scope.row.user.parent">{{scope.row.user.parent.nickname}}</div>
  90. <div v-else>平台</div>
  91. </template>
  92. </el-table-column>
  93. <el-table-column prop="total_commission" label="区域代理等级" align="center">
  94. <template slot-scope="scope">
  95. <div>{{level_map[scope.row.level]}}</div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="address" label="代理区域" align="center">
  99. </el-table-column>
  100. <el-table-column label="时间" align="center">
  101. <template slot-scope="scope">
  102. 成为区域代理时间:<br>{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="操作" align="center">
  106. <template slot-scope="scope">
  107. <el-button @click="editLevel(scope.row)" type="text" size="mini">编辑</el-button>
  108. <el-button @click="update(scope.row)" type="text" size="mini">删除</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <div flex="main:right cross:center" style="margin-top: 20px;">
  113. <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
  114. style="display: inline-block;float: right;" background @current-change="pageChange"
  115. layout="prev, pager, next" :total="pagination.totalCount">
  116. </el-pagination>
  117. </div>
  118. </template>
  119. <area-edit v-model="show"></area-edit>
  120. <area-level v-model="level.show" :config="config" :area="current_area" @success="levelSuccess"></area-level>
  121. </div>
  122. </div>
  123. <script>
  124. const app = new Vue({
  125. el: '#app',
  126. data() {
  127. return {
  128. listLoading: false,
  129. list: [],
  130. pagination: {
  131. total: 0
  132. },
  133. loading: false,
  134. LoadDataType: -1, //默认显示全部数据
  135. dialogFormVisible: false, //默认不显示弹窗
  136. group_buy_attr_list: [],
  137. goodsDetail: {},
  138. dialogLoading:false,
  139. commander_level_limit_text:'',
  140. user_level_limit_text:'',
  141. level_map:null,
  142. selectDate:'',
  143. search: {
  144. page: 1,
  145. limit:10,
  146. start:'',
  147. end:'',
  148. keyword: '',
  149. level: '',
  150. province: null,
  151. },
  152. levelList:[
  153. ],
  154. show: false,
  155. level: {
  156. show: false,
  157. area: null,
  158. },
  159. current_area:null,
  160. config: {},
  161. addressIdsMap: [],
  162. districtList: [],
  163. addressProps: {
  164. value: 'id',
  165. label: 'name',
  166. children: 'list',
  167. checkStrictly: true,
  168. multiple: true,
  169. },
  170. }
  171. },
  172. methods: {
  173. //状态按钮的点击事件
  174. toSearch() {
  175. if(this.selectDate && this.selectDate[0]){
  176. this.search.start = this.selectDate[0];
  177. this.search.end = this.selectDate[1];
  178. }else{
  179. this.search.start = '';
  180. this.search.end = '';
  181. }
  182. this.search.page = 1;
  183. this.loadData();
  184. },
  185. toSearchActivity() {
  186. this.loadData()
  187. },
  188. update(row) {
  189. this.$confirm('删除该区域代理, 是否继续?', '提示', {
  190. confirmButtonText: '确定',
  191. cancelButtonText: '取消',
  192. type: 'warning'
  193. }).then(() => {
  194. this.loading = true;
  195. request({
  196. params: {
  197. r: 'area/default/delete',
  198. },
  199. method: 'post',
  200. data: {
  201. id: row.id,
  202. }
  203. }).then(e => {
  204. let res = e.data;
  205. this.listLoading = false;
  206. if (res.code === 0) {
  207. this.$message.success(res.msg);
  208. this.loadData();
  209. } else {
  210. this.$message.error(res.msg);
  211. }
  212. }).catch(e => {});
  213. }).catch(() => {
  214. // this.$message({
  215. // type: 'info',
  216. // message: ''
  217. // });
  218. });
  219. },
  220. pageChange(page) {
  221. this.search.page = page;
  222. this.loadData();
  223. },
  224. // 请求获取数据--获取拼团商品列表
  225. loadData() {
  226. this.listLoading = true;
  227. let params = {
  228. r: 'area/default/index'
  229. };
  230. params = Object.assign(params, this.search);
  231. request({
  232. params: params,
  233. method: 'get',
  234. }).then(e => {
  235. let res = e.data;
  236. this.listLoading = false;
  237. if (res.code === 0) {
  238. try {
  239. this.list = res.data.list;
  240. this.level_map = res.data.level_map;
  241. this.pagination = res.data.pagination; //拿到关于页码页容量的数据
  242. this.levelList = [];
  243. this.config = res.data.config
  244. for(var i in this.level_map){
  245. if (i == 6){
  246. this.levelList.splice(1, 0, {'name':this.level_map[i],'level':i})
  247. }else{
  248. this.levelList.push({'name':this.level_map[i],'level':i})
  249. }
  250. }
  251. } catch (e) {
  252. console.error(e)
  253. }
  254. } else {
  255. this.$message.error(res.msg);
  256. }
  257. }).catch(e => {});
  258. },
  259. editClick() {
  260. this.show = true;
  261. },
  262. levelSuccess() {
  263. this.loadData();
  264. },
  265. editLevel(row) {
  266. this.level.show = true;
  267. this.current_area = row;
  268. },
  269. addressChange(e) {
  270. this.search.province = this.chooseJqfl(e)
  271. },
  272. getDistrict(level) {
  273. if (level) {
  274. level1 = level;
  275. } else{
  276. level1 = 1;
  277. }
  278. request({
  279. params: {
  280. r: 'common/region/get-district-list',
  281. level: level1
  282. },
  283. }).then(e => {
  284. if (e.data.code == 0) {
  285. this.districtList = e.data.data
  286. }
  287. }).catch(e => {
  288. });
  289. },
  290. clearAreaIds(){
  291. this.search.province = null
  292. },
  293. chooseJqfl(params) {
  294. let finalArray = [];
  295. if (params.length > 0) {
  296. const uniqueIn = (arr) => (x) => 1 == arr.filter((v) => v == x).length;
  297. const appendLastId = (result, ids) => [...result, ids[ids.length - 1]];
  298. const flatted = params.flat();
  299. const lastIds = params.reduce(appendLastId, []);
  300. finalArray = lastIds.filter(uniqueIn(flatted));
  301. }
  302. return finalArray
  303. },
  304. },
  305. // 加载的时候获取到列表页
  306. mounted() {
  307. // 数据初始化
  308. this.LoadDataType = -1;
  309. this.loadData();
  310. this.getDistrict(3);
  311. }
  312. })
  313. </script>