quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<template>
  <div class="user">
    <el-drawer :title="title" :visible.sync="drawerVisible" @close="drawerClose(false)" :direction="direction" :destroy-on-close="true" size="1000px" custom-class="drawer-box">
      <div class="d-s-c">
        <div class="common-seach-wrap flex-1">
          <el-form size="small" :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item label="成员搜索:">
                <el-input placeholder="请输入内容" v-model="formInline.keywords" class="input-with-select selWidth" clearable @keyup.enter.native="changeSearch(1)">
                    <el-select v-model="formInline.search_type" slot="prepend" clearable placeholder="请选择">
                        <el-option label="用户ID" value="user_id">用户ID</el-option>
                        <el-option label="用户昵称" value="nickName">用户昵称</el-option>
                        <el-option label="手机号" value="mobile">手机号</el-option>
                        <el-option label="真实姓名" value="real_name">真实姓名</el-option>
                    </el-select>
                </el-input>  
            </el-form-item>
            <el-form-item><el-button type="primary" @click="onSubmit">查询</el-button></el-form-item>
          </el-form>
        </div>
        <!--添加成员-->
        <div class="common-level-rail add-box">
          <el-button size="small" type="primary" @click="addClick" icon="el-icon-plus">添加成员</el-button>
        </div>
      </div>
 
      <!--内容-->
      <div class="product-content">
        <div class="table-wrap">
          <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
            <el-table-column prop="user_id" label="用户ID" width="70"></el-table-column>
            <el-table-column prop="nickName" label="头像" width="70">
              <template slot-scope="scope">
                <img class="radius" v-img-url="scope.row.avatarUrl" width="30" height="30" />
              </template>
            </el-table-column>
            <el-table-column prop="nickName" label="昵称"></el-table-column>
            <el-table-column prop="real_name" label="姓名"></el-table-column>
            <el-table-column prop="mobile" label="手机号"></el-table-column>
            <el-table-column prop="money" label="成员身份">
              <template slot-scope="scope">
                <span class="orange">{{ scope.row.position_name }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="create_time" label="入会时间" width="140"></el-table-column>
            <el-table-column fixed="right" label="操作" width="120">
              <template slot-scope="scope">
                <div>
                  <!-- <el-button @click="EditClick(scope.row)" type="text" size="small" v-auth="'/branch/branch/member'">修改</el-button> -->
                  <el-button @click="delClick(scope.row)" type="text" size="small" v-auth="'/branch/branch/member'">删除</el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
 
        <!--分页-->
        <div class="pagination">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            background
            :current-page="curPage"
            :page-size="pageSize"
            layout="total, prev, pager, next, jumper"
            :total="totalDataNumber"
          ></el-pagination>
        </div>
      </div>
    </el-drawer>
    <!--添加-->
    <Add v-if="open_add" :open_add="open_add" :positionList="positionList" @close="closeDialogFunc($event, 'add')"></Add>
    <!--编辑-->
    <!-- <Edit :open_edit="open_edit" :userModel="userModel" @close="closeDialogFunc($event, 'edit')"></Edit> -->
 
  </div>
</template>
 
<script>
import { deepClone } from '@/utils/base.js'
import BranchApi from '@/api/branch.js';
// import Edit from './dialog/editMember.vue';
import Add from './dialog/addMember.vue';
export default {
  components: {
    // Edit,
    Add
  },
  data() {
    return {
      /*是否加载完成*/
      loading: true,
      /*列表数据*/
      tableData: [],
      /*一页多少条*/
      pageSize: 20,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*搜索对象*/
      formInline: {
        keywords: '',
        search_type: 'user_id'
      },
      /*是否打开弹窗*/
      open_dialog: false,
      /*基础设置当前用户的信息*/
      basicSetting: [],
      /*选中的用户*/
      userModel:{},
      /*是否打开修改*/
      open_edit:false,
      open_add: false,
      drawerVisible: false, // 抽屉状态
      direction: 'rtl', // 抽屉呼出方向
      branch_id: 0,
      title: '成员管理',
      positionList: [], // 职务列表
    };
  },
  props: ['open'],
  watch:{
    open:function(n, o){
      this.drawerVisible = this.open;
    }
  },
  methods: {
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.loading = true;
      self.getData();
    },
 
    /*获取数据*/
    getData() {
      let self = this;
      let Params = {
        branch_id: self.branch_id,
        keywords: self.formInline.keywords,
        search_type: self.formInline.search_type
      };
      Params.page = self.curPage;
      Params.list_rows = self.pageSize;
      BranchApi.memberList(Params, true)
        .then(res => {
          self.loading = false;
          self.tableData = res.data.list.data;
          self.totalDataNumber = res.data.list.total;
          self.basicSetting = res.data.basicSetting;
        })
        .catch(error => {
          self.loading = false;
        });
    },
 
    // 获取职务列表
    getPosition() {
      let self = this;
      BranchApi.positionList({}, true)
        .then(res => {
          self.positionList = res.data.list;
        })
        .catch(error => {
        });
    },
 
    //搜索
    onSubmit() {
      this.curPage = 1;
      this.getData();
    },
 
    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.pageSize = val;
      this.getData();
    },
 
    /*删除成员*/
    delClick(row) {
      let self = this;
      self
        .$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        .then(() => {
          self.loading = true;
          BranchApi.deleteMember(
            {
              user_id: row.user_id
            },
            true
          )
            .then(data => {
              self.loading = false;
              self.$message({
                message: data.msg,
                type: 'success'
              });
              self.getData();
            })
            .catch(error => {
              self.loading = false;
            });
        })
        .catch(() => {
          self.loading = false;
        });
    },
 
    /*打开添加*/
    addClick() {
      this.open_add = true;
    },
 
     /*打开编辑用户弹窗*/
    EditClick(e){
      this.userModel = deepClone(e);
      this.open_edit = true;
    },
 
    /*关闭用户弹窗*/
    closeDialogFunc(e, f) {
      if (f == 'add') {
        this.open_add = false;
        if (e.type == 'success'){
          this.getData();
        }
      }
      if (f == 'edit') {
        this.open_edit = false;
        if(e.type == 'success'){
          this.getData();
        }
      }
    },
 
    /*关闭抽屉*/
      drawerClose(e) {
        this.$emit('closeDrawer', e);
      },
 
  }
};
</script>
 
<style scoped="scoped">
  .el-button{margin-left: 0; margin-right: 10px;}
  .add-box .el-button { margin-right: 0; }
  .input-with-select /deep/ .el-input-group__prepend .el-input__inner {
    width: 100px;
  }
</style>