| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <?php
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('components/area-edit', __DIR__);
- ComponentHelper::loadComponentView('components/area-level', __DIR__);
- ComponentHelper::loadComponentView('com-dialog-select');
- ComponentHelper::loadComponentView('com-user-info');
- ?>
- <style>
- .el-table th>.cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .table1 .el-table__footer-wrapper,
- .table1 .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- .user_img{
- position: relative;
- margin-right: 8px;
- /* height: 50px;
- width: 50px; */
- }
- .default-avatar{
- width: 50px;
- height: 50px;
- border-radius: 50%;
- margin-right: 8px;
- }
- .uer-nickname {
- flex: 1;
- }
- .name-box {
- display: flex;
- flex-direction: column;
- }
- .el-cascader--small{
- margin-right: 20px;
- }
- </style>
- <div id="app">
- <div class="table-body" style="min-width: 1000px;">
- <div slot="header" class="clearfix" style="height: 20px;">
- <span>区域代理列表</span>
- <el-button style="float: right; padding: 3px 12px;margin-left: 20px;height: 32px;" type="primary" @click="editClick">添加区域代理</el-button>
- </div>
- <div slot="header" class="clearfix" style="margin-top: 20px;">
- <div class="demo-input-suffix" style="margin-top: 20px;margin-bottom: 10px;">
- <el-input @keyup.enter.native="toSearchActivity" size="small" style="width:300px;margin-right: 20px;" placeholder="请输入会员昵称/ID/手机号" v-model="search.keyword" clearable>
- </el-input>
- <el-select size="small" v-model="search.level" @change='toSearch' class="select" style="margin-right: 20px;width: 150px;" placeholder="请选择代理等级">
- <el-option label="全部等级" value=""></el-option>
- <el-option :key="index" :label="item.name" :value="item.level" v-for="(item, index) in levelList"></el-option>
- </el-select>
- <el-date-picker
- style="margin-right: 20px;"
- size="small"
- v-model="selectDate"
- type="daterange"
- value-format="yyyy-MM-dd"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期">
- </el-date-picker>
- <el-cascader
- placeholder="选择代理区域"
- @change="addressChange"
- :options="districtList"
- :props="addressProps"
- v-model="addressIdsMap"
- clearable @clear="clearAreaIds"
- size="small"
- >
- </el-cascader>
- <el-button type="primary" size="small" @click="toSearch">搜索</el-button>
- </div>
- </div>
- <template>
- <el-table :data="list" stripe style="width: 100%" v-loading="listLoading" class="table1">
- <el-table-column prop="user_id" label="用户ID" align="center"></el-table-column>
- <el-table-column label="基本信息">
- <template slot-scope="scope">
- <com-user-info :user="scope.row.user"></com-user-info>
- </template>
- </el-table-column>
- <el-table-column prop="total_commission" label="累计佣金" align="center"></el-table-column>
- <el-table-column prop="parent" label="推荐人" align="center">
- <template slot-scope="scope">
- <div v-if="scope.row.user && scope.row.user.parent">{{scope.row.user.parent.nickname}}</div>
- <div v-else>平台</div>
- </template>
- </el-table-column>
- <el-table-column prop="total_commission" label="区域代理等级" align="center">
- <template slot-scope="scope">
- <div>{{level_map[scope.row.level]}}</div>
- </template>
- </el-table-column>
- <el-table-column prop="address" label="代理区域" align="center">
- </el-table-column>
- <el-table-column label="时间" align="center">
- <template slot-scope="scope">
- 成为区域代理时间:<br>{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center">
- <template slot-scope="scope">
- <el-button @click="editLevel(scope.row)" type="text" size="mini">编辑</el-button>
- <el-button @click="update(scope.row)" type="text" size="mini">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div flex="main:right cross:center" style="margin-top: 20px;">
- <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
- style="display: inline-block;float: right;" background @current-change="pageChange"
- layout="prev, pager, next" :total="pagination.totalCount">
- </el-pagination>
- </div>
- </template>
- <area-edit v-model="show"></area-edit>
- <area-level v-model="level.show" :config="config" :area="current_area" @success="levelSuccess"></area-level>
- </div>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- listLoading: false,
- list: [],
- pagination: {
- total: 0
- },
- loading: false,
- LoadDataType: -1, //默认显示全部数据
- dialogFormVisible: false, //默认不显示弹窗
- group_buy_attr_list: [],
- goodsDetail: {},
- dialogLoading:false,
- commander_level_limit_text:'',
- user_level_limit_text:'',
- level_map:null,
- selectDate:'',
- search: {
- page: 1,
- limit:10,
- start:'',
- end:'',
- keyword: '',
- level: '',
- province: null,
- },
- levelList:[
- ],
- show: false,
- level: {
- show: false,
- area: null,
- },
- current_area:null,
- config: {},
- addressIdsMap: [],
- districtList: [],
- addressProps: {
- value: 'id',
- label: 'name',
- children: 'list',
- checkStrictly: true,
- multiple: true,
- },
- }
- },
- methods: {
- //状态按钮的点击事件
- toSearch() {
- if(this.selectDate && this.selectDate[0]){
- this.search.start = this.selectDate[0];
- this.search.end = this.selectDate[1];
- }else{
- this.search.start = '';
- this.search.end = '';
- }
- this.search.page = 1;
- this.loadData();
- },
- toSearchActivity() {
- this.loadData()
- },
- update(row) {
- this.$confirm('删除该区域代理, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.loading = true;
- request({
- params: {
- r: 'area/default/delete',
- },
- method: 'post',
- data: {
- id: row.id,
- }
- }).then(e => {
- let res = e.data;
- this.listLoading = false;
- if (res.code === 0) {
- this.$message.success(res.msg);
- this.loadData();
- } else {
- this.$message.error(res.msg);
- }
- }).catch(e => {});
- }).catch(() => {
- // this.$message({
- // type: 'info',
- // message: ''
- // });
- });
- },
- pageChange(page) {
- this.search.page = page;
- this.loadData();
- },
- // 请求获取数据--获取拼团商品列表
- loadData() {
- this.listLoading = true;
- let params = {
- r: 'area/default/index'
- };
- params = Object.assign(params, this.search);
- request({
- params: params,
- method: 'get',
- }).then(e => {
- let res = e.data;
- this.listLoading = false;
- if (res.code === 0) {
- try {
- this.list = res.data.list;
- this.level_map = res.data.level_map;
- this.pagination = res.data.pagination; //拿到关于页码页容量的数据
- this.levelList = [];
- this.config = res.data.config
- for(var i in this.level_map){
- if (i == 6){
- this.levelList.splice(1, 0, {'name':this.level_map[i],'level':i})
- }else{
- this.levelList.push({'name':this.level_map[i],'level':i})
- }
- }
- } catch (e) {
- console.error(e)
- }
- } else {
- this.$message.error(res.msg);
- }
- }).catch(e => {});
- },
- editClick() {
- this.show = true;
- },
- levelSuccess() {
- this.loadData();
- },
- editLevel(row) {
- this.level.show = true;
- this.current_area = row;
- },
- addressChange(e) {
- this.search.province = this.chooseJqfl(e)
- },
- getDistrict(level) {
- if (level) {
- level1 = level;
- } else{
- level1 = 1;
- }
- request({
- params: {
- r: 'common/region/get-district-list',
- level: level1
- },
- }).then(e => {
- if (e.data.code == 0) {
- this.districtList = e.data.data
- }
- }).catch(e => {
- });
- },
- clearAreaIds(){
- this.search.province = null
- },
- chooseJqfl(params) {
- let finalArray = [];
- if (params.length > 0) {
- const uniqueIn = (arr) => (x) => 1 == arr.filter((v) => v == x).length;
- const appendLastId = (result, ids) => [...result, ids[ids.length - 1]];
- const flatted = params.flat();
- const lastIds = params.reduce(appendLastId, []);
- finalArray = lastIds.filter(uniqueIn(flatted));
- }
- return finalArray
- },
- },
- // 加载的时候获取到列表页
- mounted() {
- // 数据初始化
- this.LoadDataType = -1;
- this.loadData();
- this.getDistrict(3);
- }
- })
- </script>
|