hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<template>
  <div class="custom-scroll">
    <v-header
      title="群团组织成员"
    ></v-header>
    <!-- 条件搜索 -->
    <el-form :inline="true"  class="demo-form-inline">
      <el-form-item label="关键字" >
        <el-input style="width:300px" size="small" v-model="search.keyWord" placeholder="请输入姓名、联系电话"></el-input>
      </el-form-item>
      <el-form-item>
        <el-form-item label="所属组织" >
          <el-select size="small" v-model="search.clusterId" placeholder="请选择">
            <el-option v-for="item in clusterList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
      </el-form-item>
      <el-form-item label="状态">
        <el-radio-group v-model="search.status" size="medium">
          <el-radio-button label="">全部</el-radio-button>
          <el-radio-button label="1">启用</el-radio-button>
          <el-radio-button label="2">停用</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" @click="onSearch">查询</el-button>
        <el-button @click="Reset" size="small">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 操作按钮 -->
    <div class="operation-btn">
      <el-button size="small" type="primary" @click="addorg()">新增成员</el-button>
      <el-button @click="exports" size="small"  type="primary" plain >导出</el-button>
      <el-button @click="dialogVisible = true" size="small"  type="primary" plain >导入</el-button>
      <el-button size="small" @click="dow" >下载模板</el-button>
    </div>
    <!-- 表单 -->
    <div class="tab">
      <v-tool-table
        :trs="trs"
        :tds="tds"
      >
        <template v-slot:icon="{scope}">
         <span class="icon-s">
           <img  @click="onScaleUploadImage(scope.imageUrl)" :src="scope.imageUrl">
         </span>
        </template>
        <template v-slot:status="{scope}">
          {{scope.status==1?'启用':'停用'}}
        </template>
        <template v-slot:btn="{scope}">
          <div class="table_flex">
            <span @click="addorg(scope.id)">编辑</span>
            <span @click="clear(scope.id)">删除</span>
          </div>
        </template>
      </v-tool-table>
    </div>
    <!-- 分页 -->
    <div class="page">
      <el-pagination
        :current-page="paginationParams.currentPage"
        :page-size="paginationParams.pageSize"
        :page-sizes="[5, 10, 20, 50, 100]"
        background
        layout="total,prev,pager,next,sizes,jumper"
        :total="paginationParams.total"
        @size-change="onPageSizeChange"
        @current-change="onPaginationChange">
      </el-pagination>
    </div>
    <!---->
    <el-dialog
      title="提示"
      :modal="false"
      :close-on-click-modal="false"
      :visible.sync="dialogVisible"
      width="30%"
      >
      <div >
        <el-upload
          name="file"
          v-loading="loading"
          accept=".xls, .xlsx"
          :headers={Authorization:Authorization}
          class="upload-demo"
          :show-file-list="false"
          :action="$js.api.http+'cluster/member/import'"
          :on-success="success"
          :on-error="error"
          :before-upload="beforeUpload"
          multiple
        >
          <el-button
            type="primary"
            plain
            class="m_btn bgc_primary"
          >选择文件
          </el-button>
        </el-upload>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-link @click="downloadError" v-if="errUrl" type="danger">下载错误表格</el-link>
    <el-button size="small" @click="dialogVisible = false">取 消</el-button>
    <el-button size="small" type="primary" @click="confirm()">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
 
  export default {
    props: [],
    components: {},
    data() {
      return {
        loading:false,
        errUrl:'',//错误url
        Authorization: "",
        dialogVisible: false,
        clusterList:[],//所属组织
        search: {
          keyWord:'',
          status:'',
          clusterId:''
        },
        trs: [
          { text: "序号", val: "index" },
          { text: "姓名", val: "name" },
          { text: "照片", val: "btn",slot:"icon" },
          { text: "所属组织", val: "clusterName"},
          { text: "职务", val: "job"},
          { text: "联系电话", val: "phone" },
          { text: "状态", val: "btn",slot:"status" },
          { text: "操作", val: "btn" ,slot:"btn"},
        ],
        tds: [],
        /** 分页参数 */
        paginationParams: {
          currentPage: 1,
          pageSize: 10,
          total: 0
        },
      };
    },
 
 
    mounted() {
      this.Authorization = "Bearer " + demo.$session.get("token") || "";
      this.init();
      this.setClusterList()
    },
 
    methods: {
      onScaleUploadImage(d) {
        this.$store.dispatch("setImage", {
          time: Date.now(),
          pic: d,
          tool: true,
        });
      },
 
      handleClose(){
        this.dialogVisible = false
      },
      confirm(){
        //点击确认
        this.dialogVisible = false
      },
      dow(){
        //下载模板
        this.$api.get('cluster/member/import/download','',e=>{
          location.href = e
        })
      },
      exports(){
        //导出
        let params = Object.assign(this.search,{
          pageNum: this.paginationParams.currentPage,
          pageSize: this.paginationParams.pageSize,
        })
        this.$api.post('cluster/member/export',params,res=>{
          location.href = res
        })
      },
      clear(id){
        //删除
        this.$confirm('此操作将永久删除该组织, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$api.get('cluster/member/delete?id='+id,'',e=>{
            this.init()
          })
        })
 
      },
      downloadError(){
        //下载错误信息
        this.$api.post('cluster/member/download/error?key='+this.errUrl,'',e=>{
          location.href = e
        })
      },
      success(res){
        if(res.code!==200){
          this.errUrl = res.msg;
        } else {
          demo.toast("导入成功");
          this.init()
        }
        this.loading =false;
      },
      error(err){
        this.loading =false
        demo.toast("导入失败!请检查内容是否正确");
      },
      beforeUpload(){
        this.errUrl = '';
        this.loading =true
      },
      addorg(id){
        //新增 编辑
        let o = {path:'/act_addOrg1'}
        if(id){//编辑
          o.query = {id:id}
        }
        this.$router.push(o)
      },
      setClusterList(){
        this.$api.get('cluster/list','',res=>{
          // console.log(res)
          this.clusterList = res||[]
        })
      },
      /** pageSize 改变时会触发 */
      onPageSizeChange (pageSize) {
        this.paginationParams.pageSize = pageSize;
        this.init();
      },
 
      /** 分页 */
      onPaginationChange (page) {
        this.paginationParams.currentPage = page;
        this.init();
      },
 
      //条件搜索
      onSearch(v) {
        this.paginationParams.currentPage = 1;
        this.init();
      },
 
      /**搜索条件重置 */
      Reset() {
        this.search.keyWord = ''
        this.search.status = ''
        this.search.clusterId = ''
        this.paginationParams.currentPage = 1
        this.init()
      },
 
      /**
       * 初始化数据获取
       */
      init() {
        let params = Object.assign(this.search,{
          pageNum: this.paginationParams.currentPage,
          pageSize: this.paginationParams.pageSize,
        })
 
        this.$api.post("cluster/member/page", params, (e) => {
          this.paginationParams.total = e.total;
          e.records.map((item,index) => {
            item.index = (this.paginationParams.currentPage-1) * this.paginationParams.pageSize + index + 1
          })
          this.tds = (e.records || []).map((v) => {
            this.$set(v, 'che', false)
            return v;
          });
 
        });
      },
    },
 
  };
</script>
 
<style scoped lang="less">
  .custom-scroll {
    overflow: scroll;
    .icon-s {
      display: inline-block;
      width: 50px;
      height: 40px;
      overflow: hidden;
      img {
        width: 100%;
        object-fit: cover;
      }
    }
  }
  .operation-btn {
    margin-bottom: 10px;
  }
 
  .page {
    text-align: center;
    padding: 20px 0;
  }
 
 
</style>