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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
<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:400px" size="small" v-model="search.keyword" placeholder="请输入姓名、联系电话、管辖区域等关键词进行查找"></el-input>
      </el-form-item>
      <el-form-item label="职位">
        <el-select v-model="search.position" placeholder="请选择">
          <el-option
            v-for="item in positionList"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </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="both-box">
      <!-- 显示多选数量 -->
      <div class="Tips">
        <i style="color: #409EFF" class="el-icon-info"></i>
        <div class="Tips-cont">已选择<span>{{ids.length}}</span>项</div>
        <el-button
          type="text"
          @click="cancel"
        >取消</el-button>
      </div>
      <!-- 操作按钮 -->
      <div class="operation-btn">
        <el-button type="primary" @click="add()">新增</el-button>
        <el-button type="primary" @click="deletes()">删除</el-button>
        <el-button type="primary" @click="enable()">启用</el-button>
        <el-button type="primary" @click="disable()">禁用</el-button>
        <el-button type="primary" @click="resetPassword()">密码重置</el-button>
      </div>
      <div style="clear:both"></div>
    </div>
     <!-- 表单 -->
    <div class="tab">
      <v-tool-table
        :trs="trs"
        :tds="tds"
        first
      >
      <template v-slot:first-th>
        <div>
          <el-checkbox @change="cheAll" v-model="alls"></el-checkbox>
        </div>
      </template>
      <template v-slot:first-td="item">
        <div>
          <el-checkbox @change="change" v-model="item.scope.che"></el-checkbox>
        </div>
      </template>
      
      <template v-slot:jurisdictionContentList ="{scope}">
        <span :title="scope.jurisdictionContentList.join(',')" v-if="scope.jurisdictionContentList">{{ scope.jurisdictionContentList.join(",")}}</span>
      </template>
      <template v-slot:status ="{scope}">
        <span>{{scope.status == '1' ? '启用' : '禁用'}}</span>
      </template>
        <template v-slot:btn="{scope}">
          <div class="table_flex">
            <span @click="seeDetails(scope)">查看</span>
            <span @click="onEdit(scope)">修改</span>
            <span @click="deletes(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>
    <!-- 新增弹窗 -->
    <AddModel 
      v-model="isShow" 
      @change="details = {}, isShow = false"  
      :positionList="positionList"
      @success="onEditSuccess"
      :detail="details" />
      <!-- 编辑弹窗 -->
      <EditModel 
      v-model="isShowEdit" 
      @change="details = {}, isShowEdit = false"  
      :positionList="positionList"
      @success="onEditSuccess"
      :detail="details" />
     <!-- 查看弹窗 -->
    <SeeModel v-model="isShowSee" :seedata="details" @change="details = {}, isShowSee = false"   />
  </div>
</template>
<script>
import AddModel from "./components/AddModel.vue";
import SeeModel from "./components/SeeModel.vue";
import EditModel from "./components/editModel.vue";
export default {
  props: [],
  components: {AddModel, SeeModel,EditModel},
  data() {
    return {
      search: {
        keyword:'',
        position:'',
      },
      paramsDeletes:{},
      positionList:[
        {
          label:"全部",
          value:'全部',
        },
         {
          label:"居民小组长",
          value:'居民小组长',
        },
         {
          label:"楼栋长",
          value:"楼栋长",
        },
        {
          label:"党小组长",
          value:"党小组长",
        },
        {
          label:"妇女小组长",
          value:"妇女小组长",
        },
        {
          label:"宣传员",
          value:"宣传员",
        },
        {
          label:"监督员",
          value:"监督员",
        },
        {
          label:"调解员",
          value:"调解员",
        },
        {
          label:"安全员",
          value:"安全员",
        }
      ],
      jurisdictionOptionList: [],
      trs: [
        { text: "序号", val: "index",width:"80px"  },
        { text: "姓名", val: "name" },
        { text: "职位", val: "position" },
        { text: "联系电话", val: "phone" },
        { text: "账号", val: "account" },
        { text: "身份证号码", val: "idCard" },
        { text: "管辖区域", val: "btn",slot:'jurisdictionContentList',width:"250px" },
        { text: "状态", val: "btn",slot:"status" },
        { text: "操作", val: "btn" ,slot:"btn",width:"150px"},
      ],
      tds: [],
      /** 分页参数 */
      paginationParams: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      Change:false, //默认都不选中
      ids:[], //选中的id集合
      userIds:[], //选中的userid集合
      alls: false, //全选状态
      isShow:false,
      isShowSee:false,
      isShowEdit:false,
      details: {},
    };
  },
 
 
  mounted() {
    this.init();
  },
 
  methods: {
    onEdit (data) {
      this.details = data;
      this.isShowEdit = true;
    },
 
    /** pageSize 改变时会触发 */
    onPageSizeChange (pageSize) {
      this.paginationParams.pageSize = pageSize;
      this.init();
    },
    
    /** 分页 */
    onPaginationChange (page) {
      this.paginationParams.currentPage = page;
      this.init();
    },
    
    /** 编辑和新增弹窗确认后 初始化数据 */
    onEditSuccess() {
      this.init();
    },
   /** 新增 */
    add() {
      this.isShow = true;
    },
 
    /** 查看 */
    seeDetails(d) {
      this.details = d;
      this.isShowSee = true;
      // this.$api.get(`comActFourMember/${d}`,{},e=> {
      //   this.details = e;
      //   console.log(e)
      // })
    },
 
    deletes(id) {
      if(!this.ids.length && !id) {
        return demo.toast("请勾选需要删除的数据")   
      } else{
      this.$confirm('确定要删除该人员吗? 温馨提示:删除后该人员所管辖的区域将无人', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if(id) {
          this.paramsDeletes = {
            "id":id
          } 
        }else {
         this.paramsDeletes = {
             "ids":this.ids
          }   
        }
        this.$api.post("comActFourMember/del", this.paramsDeletes, e => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
          this.ids = [];
          this.init();
        });
 
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });          
      });
      }
    },
 
    enable() {
      console.log(this.ids)
      if(!this.ids.length) {
        return demo.toast("请勾选需要启用的人员")   
      } else{
      this.$confirm('确定要启用所选人员吗?温馨提示:启用后该人员将可以正常登录使用相关功能', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let params = {
          ids :this.ids,
          status:1,
        }
        this.$api.post("comActFourMember/update", params, e => {
          this.$message({
            type: 'success',
            message: '启用成功!'
          });
          this.ids = [];
          this.init();
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消启用'
        });          
      });
      }
    },
 
    disable() {
       if(!this.ids.length) {
        return demo.toast("请勾选需要禁用的人员")   
      } else{
      this.$confirm('确定要禁用所选人员吗?温馨提示:禁用后该人员将无法使用相关功能', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let params = {
          ids :this.ids,
          status:2,
        }
        this.$api.post("comActFourMember/update", params, e => {
          this.$message({
            type: 'success',
            message: '禁用成功!'
          });
          this.ids = [];
          this.init();
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消禁用'
        });          
      });
      }
    },
 
    resetPassword() {
      if(!this.ids.length) {
        return demo.toast("请勾选需要密码重置的数据")   
      } else{
        this.$prompt('登录密码', '密码重置', {
          inputPlaceholder:'请输入新的密码',
          inputValidator: (val) => { // 点击按钮时,对文本框里面的值进行验证
            if (val === null) {
              return '登录密码不能为空';
            }
            var passwordValue = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/;
            if(!passwordValue.test(val)) {
               return '登录密码为6-12个字符,且必须包含英文和数字';
            }
          }
        }).then((val) => {
 
          this.$api.get("resetPasswordPatch", {userIds:this.userIds.toString(),password:val.value}, e => {
            this.$message({
              type: 'success',
              message: '密码重置成功!'
            });
            this.ids = [];
            this.init();
          });
        }, () => {
        });
      }
    },
 
    //条件搜索 
    onSearch(v) {
      this.paginationParams.currentPage = 1;
      this.init();
    },
 
    /**搜索条件重置 */
    Reset() {
      this.search.keyword = '',
      this.search.position = '',
      this.init();
    },
 
    /**
     * 初始化数据获取
     */
    init() {
      let params = {
        page: this.paginationParams.currentPage,
        size: this.paginationParams.pageSize,
        ...this.search
      }
      this.$api.post("comActFourMember/queryAll", 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;
        });
 
      });
    },
 
    cancel() {
      //取消
      this.Change = false;
      this.alls = false;
      this.ids = [];
      this.userIds = [];
      this.tds.map(item=>{
        item.che = false
      })
    },
 
    cheAll () {
      this.Change = !this.Change
      //全选
      this.tds.map(item => {
        item.che = this.alls
      })
      this.change()
    },
 
    change () {
      //单个选择
      this.ids = [];
      this.userIds = [];
      this.tds.map(item => {
        if (item.che) {
          this.ids.push(item.id);
          this.userIds.push(item.userId);
 
        } else {
          this.alls = false
        }
      })
    },
 
  },
 
};
</script>
 
<style scoped lang="less">
/deep/.el-message-box__message{
  position: relative;
  p::before {
    content: '* ';
    color: red;
    position: absolute;
  }
 
}
.custom-scroll {
  overflow: scroll;
}
.both-box {
  .Tips {
    float: left;
    margin: 10px 0;
    box-sizing: border-box;
    width: 240px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    height: 40px;
    padding: 0 20px;
    .Tips-cont {
      padding: 0 10px;
      font-size: 16px;
      color: #606266;
    }
    .Tips-cont > span {
      padding: 0 4px;
      color: #409eff;
      font-weight: 600;
    }
  }
  .operation-btn {
    float: right;
    margin-top: 10px;
  }
}
.page {
  text-align: center;
  padding: 20px 0;
}
 
 
</style>