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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
<template>
  <div class="committee-box">
    <v-header
      title="党委管理"
      :bar="bar"
      search
      @on-search="onSearch"
    ></v-header>
    <div class="but-boxc">
      <el-button @click="add()" type="primary">添加</el-button>
      <el-button @click="showImport" type="primary">导入</el-button>
      <el-button @click="pbMemberRole" type="primary">下载模板</el-button>
    </div>
    <!---->
    <div>
      <v-tool-table :trs="trs" :tds="tds">
        <template v-slot:photoPath="{ scope }">
          <img
            class="img"
            @click="onScaleImage(scope)"
            :src="scope.photoPath"
            alt=""
          />
        </template>
        <template v-slot:type="{ scope }">
          <span v-if="scope.type === 1">社区党委</span>
          <span v-if="scope.type === 2">区域党委委员</span>
        </template>
        <template v-slot:sex="{ scope }">
          <span v-if="scope.sex === 1">男</span>
          <span v-if="scope.sex === 2">女</span>
        </template>
        <template v-slot:isReg="{ scope }">
          {{ scope.isReg === 1 ? "是" : "否" }}
        </template>
        <template v-slot:btn="{ scope }">
          <el-button type="text" @click="edit(scope)">编辑</el-button>
          <el-button @click="clear(scope.id)" type="text">删除</el-button>
        </template>
      </v-tool-table>
      <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
    </div>
    <!---->
    <el-dialog
      :title="dilogTitle"
      :visible.sync="dialogVisible"
      width="520px"
      :modal="false"
      :close-on-click-modal="false"
    >
      <div class="form-box test-1">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item required label="手机号">
            <el-input v-model="form.phone"></el-input>
          </el-form-item>
          <!---->
          <el-form-item required label="身份证">
            <el-input v-model="form.idCard"></el-input>
          </el-form-item>
          <!---->
          <el-form-item required label="姓名">
            <el-input v-model="form.name"></el-input>
          </el-form-item>
          <!---->
          <el-form-item required label="党委标签">
            <el-select v-model="form.type" placeholder="请选择活动区域">
              <el-option label="社区党委" :value="1"></el-option>
              <el-option label="区域党委委员" :value="2"></el-option>
            </el-select>
          </el-form-item>
          <!---->
          <el-form-item label="入党日期">
            <el-date-picker
              v-model="form.joinTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
          <!---->
          <el-form-item label="转正日期">
            <el-date-picker
              v-model="form.employmentTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
          <!---->
          <el-form-item label="职位">
            <el-input v-model="form.position"></el-input>
          </el-form-item>
          <!---->
          <el-form-item label="职位二">
            <el-input v-model="form.positionTwo"></el-input>
          </el-form-item>
          <!---->
          <el-form-item label="岗位职责">
            <el-input v-model="form.jobResponsibilities"></el-input>
          </el-form-item>
          <!---->
          <el-form-item required label="负责党组织">
            <el-select v-model="form.orgId" placeholder="请选择负责党组织">
              <el-option
                v-for="item in OrgAllList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <!---->
          <el-form-item label="报到单位">
            <el-select v-model="form.checkUnitId" placeholder="请选择报到单位">
              <el-option
                v-for="item in checkUnitList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <!---->
          <el-form-item label="职能">
            <el-input v-model="form.function"></el-input>
          </el-form-item>
          <!---->
          <el-form-item label="特长">
            <el-input v-model="form.specialtyName">
              <el-select
                class="select-box"
                v-model="form.specialtyCategory"
                slot="prepend"
                placeholder="请选择"
              >
                <el-option label="体育类" :value="1"></el-option>
                <el-option label="舞蹈类" :value="2"></el-option>
                <el-option label="音乐类" :value="3"></el-option>
                <el-option label="美术类" :value="4"></el-option>
                <el-option label="其他" :value="5"></el-option>
              </el-select>
            </el-input>
          </el-form-item>
          <!---->
          <el-form-item label="照片">
            <v-upload @path="onPath" :pic="form.photoPath"></v-upload>
          </el-form-item>
        </el-form>
      </div>
 
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="sub()">确 定</el-button>
      </span>
    </el-dialog>
    <!---->
    <el-dialog
      title="导入"
      :modal="false"
      :close-on-click-modal="false"
      :visible.sync="dialogVisible1"
      width="30%"
    >
      <div>
        <el-upload
          name="file"
          accept=".xls, .xlsx"
          :headers="{ Authorization: Authorization }"
          class="upload-demo"
          :show-file-list="false"
          :action="$js.api.http + 'communitypartybuilding/importPbMemberRole'"
          :on-success="success"
          :on-error="error"
          multiple
        >
          <el-button type="primary" size="small">导入 </el-button>
        </el-upload>
        <el-button v-if="errMsg" @click="dowErr" type="text"
          >下载错误信息</el-button
        >
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible1 = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible1 = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import vUpload from "com/upload/upload";
export default {
  props: [],
  components: { vUpload },
  data() {
    return {
      dilogTitle: "新增社区党委",
      bar: [
        {
          title: "关键字",
          name: "keyWord",
          plac: "请输入姓名、手机号、身份证进行查找",
          width: "400px !important",
        },
        {
          title: "党委标签",
          name: "type",
          type: "select",
          list: [
            {
              label: "社区党委",
              value: 1,
            },
            {
              label: "区域党委委员",
              value: 2,
            },
          ],
        },
        {
          title: "性别",
          name: "sex",
          type: "select",
          list: [
            {
              label: "男",
              value: 1,
            },
            {
              label: "女",
              value: 2,
            },
          ],
        },
      ],
      trs: [
        { text: "序号", val: "id", width: "80px" },
        { text: "党员姓名", val: "name" },
        { text: "党员照片", val: "btn", slot: "photoPath" },
        { text: "党员标签", val: "btn", slot: "type" },
        { text: "性别", val: "btn", slot: "sex" },
        { text: "年龄", val: "age" },
        { text: "手机号", val: "phone" },
        { text: "是否注册", val: "btn", slot: "isReg" },
        { text: "职位", val: "position" },
        { text: "岗位职责", val: "jobResponsibilities" },
        { text: "负责党组织", val: "orgName" },
        { text: "报到单位", val: "checkUnitName" },
        { text: "特长", val: "specialtyName" },
        { text: "操作", val: "btn", width: "100px" },
      ],
      tds: [],
      search: {},
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      dialogVisible: false,
      form: {
        phone: "",
        idCard: "",
        name: "",
        type: "",
        joinTime: "",
        position: "",
        positionTwo: "",
        jobResponsibilities: "",
        orgId: "",
        checkUnitId: "",
        specialtyName: "",
        specialtyCategory: "",
      },
      OrgAllList: [],
      checkUnitList: [],
      dialogVisible1: false,
      Authorization: "",
      errMsg: "", //错误信息代码
    };
  },
  created() {
    this.Authorization = "Bearer " + demo.$session.get("token") || "";
    this.getPbOrgAllList();
    this.getCheckUnitList();
  },
  mounted() {},
  methods: {
    // 查看大图
    onScaleImage(v) {
      this.$store.dispatch("setImage", {
        time: Date.now(),
        title: v.name,
        pic: v.photoPath,
        tool: true,
      });
    },
    showImport() {
      this.dialogVisible1 = true;
      this.errMsg = "";
    },
    success(e) {
      console.log(e);
      if (e.code === 500) {
        this.errMsg = e.msg;
        demo.toast("导入错误");
        return;
      }
      this.errMsg = "";
      this.dialogVisible1 = false;
      this.init();
    },
    error(err) {
      console.log(err);
      demo.toast("导入失败");
    },
    dowErr() {
      //
      this.$api.get(
        "communitypartybuilding/download/error/pbMemberRole",
        { key: this.errMsg },
        (res) => {
          // console.log(res)
          location.href = res;
        }
      );
    },
    pbMemberRole() {
      //下载模板
      this.$api.get("communitypartybuilding/export/pbMemberRole", "", (res) => {
        // console.log(res)
        location.href = res;
      });
    },
    edit(item) {
      this.form = demo.copy(item);
      this.dilogTitle = "编辑社区党委";
      this.dialogVisible = true;
    },
    getPbOrgAllList() {
      //
      this.$api.get(
        "communitypartybuilding/listpartyorganization",
        {},
        (res) => {
          this.OrgAllList = res;
        }
      );
    },
    getCheckUnitList() {
      this.$api.post("checkUnit/list", {}, (res) => {
        this.checkUnitList = res;
      });
    },
    sub() {
      // demo.toast("请输入单位名称");
      if (!this.form.phone) {
        return demo.toast("请输入手机号");
      }
      if (!this.form.idCard) {
        return demo.toast("请输入身份证");
      }
      if (!this.form.name) {
        return demo.toast("请输入姓名");
      }
      if (!this.form.type) {
        return demo.toast("请选择党委标签");
      }
      if (!this.form.specialtyCategory && this.form.specialtyName) {
        return demo.toast("请选择特长类别");
      }
      if (this.form.specialtyCategory && !this.form.specialtyName) {
        return demo.toast("请输入特长");
      }
      if (!this.form.orgId) {
        return demo.toast("请选择负责党组织");
      }
 
      let data = demo.copy(this.form);
      let type = data.id ? "put" : "post";
      let url = data.id
        ? "communitypartybuilding/updatepartycommittee"
        : "communitypartybuilding/addpartycommittee";
      if (data.id) {
        this.$api[type](url, data, (res) => {
          demo.toast("操作成功");
          this.dialogVisible = false;
          this.init();
        });
      } else {
        this.$api.get(
          "communitypartybuilding/checkMember",
          {
            idCard: this.form.idCard,
          },
          (val) => {
            if (!val) {
              this.$confirm("已存在该党员,是否更新该党员资料?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }).then(() => {
                this.$api[type](url, data, (res) => {
                  demo.toast("操作成功");
                  this.dialogVisible = false;
                  this.init();
                });
              });
            } else {
              this.$api[type](url, data, (res) => {
                demo.toast("操作成功");
                this.dialogVisible = false;
                this.init();
              });
            }
          }
        );
      }
    },
    clear(id) {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$api.del(
          "communitypartybuilding/deletepartycommittee",
          { id },
          (res) => {
            console.log(res);
            demo.toast("删除成功");
            this.init();
          }
        );
      });
    },
    onPath(v) {
      this.form.photoPath = v;
    },
    add() {
      this.dilogTitle = "新增社区党委";
      for (let key in this.form) {
        this.form[key] = "";
      }
      this.dialogVisible = true;
    },
    init() {
      let v = demo.copy(
        Object.assign(this.search, {
          pageNum: this.paged.page,
          pageSize: this.paged.limit,
        })
      );
      this.$api.post("communitypartybuilding/pagepartycommittee", v, (res) => {
        // console.log(res)
        this.tds = res.records || [];
        this.paged.total = res.total;
      });
    },
    // 搜索
    onSearch(val) {
      let v = demo.copy(val);
      this.search = v;
      this.paged.page = 1;
      this.init();
    },
    // 分页点击
    onPage(v) {
      if (v.page === this.paged.page && v.page && !v.reset) {
        return 0;
      }
      this.paged.page = v.page;
      this.paged.limit = v.limit;
      this.init();
    },
  },
  watch: {},
  computed: {},
};
</script>
<style scoped lang="less">
.committee-box {
  overflow: scroll;
  .but-boxc {
    padding-bottom: 20px;
  }
  .img {
    width: 100px !important;
    height: 100px !important;
    /*object-fit: cover;*/
  }
  .form-box {
    width: 90%;
    padding-right: 30px;
    height: 410px;
    overflow-y: scroll;
    .select-box {
      width: 100px;
    }
  }
}
</style>