Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<template>
  <div class="dispatch">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <!-- 基本信息 -->
      <el-tab-pane :label="baseTitle" name="tab1">
        <basic-container>
          <avue-form
            ref="form"
            v-model="objBase"
            :option="optionBase"
            @submit="submitBase"
          >
          </avue-form>
        </basic-container>
      </el-tab-pane>
      <!-- 工商信息 -->
      <el-tab-pane label="工商信息" name="tab11">
        <basic-container>
          <avue-form
            v-if="businessVisiable"
            ref="form"
            v-model="obj"
            :option="option01"
            @submit="submitBase"
          >
          </avue-form>
          <avue-form
            v-if="!businessVisiable"
            ref="businessForm"
            v-model="businessObj"
            :option="businessOption"
            @submit="businessSubmit"
          >
          </avue-form>
        </basic-container>
      </el-tab-pane>
      <!-- 出资人列表信息 -->
      <el-tab-pane :label="tab2label" name="tab2" v-if="shareholderVisiable">
        <shareholder
          v-if="seeWhere == 'tab2'"
          :deptid="departmentid"
          :windowHeight="windowHeight"
        ></shareholder>
      </el-tab-pane>
      <!-- 主要管理人信息 -->
      <el-tab-pane :label="managerLabel" name="tab3">
        <manager
          v-if="seeWhere == 'tab3'"
          :deptid="departmentid"
          :stats="stats"
        ></manager>
      </el-tab-pane>
      <!-- 装备管理列表 -->
      <el-tab-pane label="装备管理" name="tab4" v-if="equipmentVisiable">
        <equipments
          v-if="seeWhere == 'tab4'"
          :fromDeptId="departmentid"
          :windowHeight="windowHeight"
        ></equipments>
      </el-tab-pane>
      <!-- 车辆管理 -->
      <el-tab-pane label="车辆管理" name="tab5" v-if="carVisiable">
        <car
          :fromDeptId="departmentid"
          v-if="seeWhere == 'tab5'"
          :windowHeight="windowHeight"
        ></car>
      </el-tab-pane>
      <!-- 社保记录  -->
      <el-tab-pane label="社保记录" name="tab9">
        <social
          :deptid="objBase.departmentid"
          :socialRE="social"
          v-if="seeWhere == 'tab9'"
        ></social>
        <!-- </span> -->
      </el-tab-pane>
      <!-- 营业执照 -->
      <el-tab-pane label="营业执照" name="tab7" v-if="false">
        <businessLicense :row="objBase" v-if="overHtp"></businessLicense>
      </el-tab-pane>
      <!-- 许可证  -->
      <el-tab-pane :label="licenceLabel" name="tab8" v-if="licenceVisiable">
        <!-- <licence :row="objBase" v-if="overHtp"></licence> -->
        <basic-container>
          <avue-form
            v-if="true"
            ref="lincenceForm"
            v-model="licenceObj"
            :option="licenceOption"
            @submit="licenceSubmit"
          ></avue-form>
          <avue-form
            v-if="false"
            ref="licenceGroupForm"
            v-model="licenceGroupObj"
            :option="licenceGroupOption"
            @submit="licenceGroupSubmit"
          >
          </avue-form>
        </basic-container>
      </el-tab-pane>
      <!-- 备案证  -->
      <el-tab-pane label="备案证" name="tab12" v-if="certificdinedVisiable">
        <licence :row="objBase" v-if="overHtp"></licence>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
 
<script>
import {
  column11,
  column,
  filialeColumn,
  selfColumn,
  lincenceColumn,
  businessColumn,
  lincenceGroupColumn,
  lincenceGroupColumns,
  lincenceTrainColumn
} from "./data";
import {
  getOncedata,
  update,
  getBusinessInfo,
  submit,
  getLicenceDetail,
  licenceSubmit,
  submitGroup
} from "@/api/securityUnit/securityUnit";
import manager from "./manager.vue";
import shareholder from "./shareholder.vue";
import equipments from "../securityEquipment/equipments.vue";
import car from "../securityEquipment/car.vue";
import gun from "../securityEquipment/gun.vue";
import licence from "./licence.vue";
import businessLicense from "./businessLicense.vue";
import social from "./social.vue";
import { mapGetters } from "vuex";
import { getRoleDetail } from "@/api/system/role";
 
export default {
  components: {
    equipments,
    car,
    gun,
    licence,
    businessLicense,
    social,
    manager,
    shareholder
  },
  data() {
    return {
      tab2label: "出资人信息",
      managerLabel: "主要管理人信息",
      licenceLabel: "许可证信息",
      baseTitle: "基本信息",
      visible: false,
      certificdinedVisiable: false,
      businessVisiable: true,
      licenceVisiable: true,
      shareholderVisiable: true,
      equipmentVisiable: true,
      carVisiable: true,
      seeWhere: "tab1",
      //结决id传入、信息获取的优先级
      overzb: false,
      overmanager: false,
      overshareholder: false,
      //结决id传入、信息获取的优先级
      overcar: false,
      //解决表格错乱
      social: false,
      overHtp: false,
      activeName: "tab1",
      stats: "",
      deptId: "",
      departmentid: "",
      //全局单位统一社会信用代码
      creditcode: "",
      //保安单位信息表单
      objBase: {
        // title: "我是头部标题",
      },
      formData: {},
      businessObj: {},
      businessOption: {
        height: "auto",
        // calcHeight: 80,
        emptyBtn: false,
        // submitBtn:false,
        submitText: "保存",
        group: businessColumn
      },
      licenceGroupObj: {},
      licenceGroupOption: {
        height: "auto",
        emptyBtn: false,
        submitText: "保存",
        group: [
          {
            label: "总公司许可证信息",
            labelWidth: "110",
            prop: "baseInfo",
            icon: "el-icon-user-solid",
            column: lincenceGroupColumn
          },
          {
            label: "分公司许可证信息",
            prop: "detailInfo",
            labelWidth: "110",
            icon: "el-icon-s-order",
            column: lincenceGroupColumns
          }
        ]
      },
      licenceObj: {},
      licenceOption: {
        emptyBtn: false,
        // submitBtn: false,
        submitText: "保存",
        gutter: 30,
        column: lincenceColumn
      },
      optionBase: {
        emptyBtn: false,
        submitBtn: false,
        submitText: "保存",
        gutter: 30,
        column: column
      },
      option01: {
        emptyBtn: false,
        submitBtn: false,
        submitText: "保存",
        gutter: 30,
        column: column11
      }
    };
  },
  computed: {
    ...mapGetters(["userInfo", "windowHeight"]),
    chuzitime() {
      return this.data1.capitaltime;
    }
  },
  methods: {
    //分公司工商信息修改
    businessSubmit(row, done, loading) {
      var that = this;
      if (
        this.userInfo.role_name == "保安公司管理员" ||
        this.userInfo.role_name == "培训公司管理员" ||
        this.userInfo.role_name == "分公司管理员"
      ) {
        //分公司
        var f = {
          departmentid: this.userInfo.dept_id,
          id: this.formData.id,
          businessLicense: row.businessLicense,
          establishtime: row.establishtime,
          creditcode: row.creditcode,
          registeredcapital: row.registeredcapital,
          business: row.business
        };
        //总公司
        var z = {
          id: row.id,
          deptId: this.userInfo.dept_id,
          registerTime: row.registerTime,
          socialCreditCode: row.socialCreditCode,
          capital: row.capital,
          businessScope: row.businessScope,
          trading: row.trading
        };
      }
 
      //分公司工商信息修改
      update(f).then(
        () => {
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
      //总公司工商信息修改
      submit(z).then(
        res => {
          that.businessObj = row;
          that.businessObj.id = res.data.data.id;
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
      done();
    },
    //分公司许可证信息修改
    licenceSubmit(row, done, loading) {
      var that = this;
      if (
        this.userInfo.role_name == "保安公司管理员" ||
        this.userInfo.role_name == "培训公司管理员" ||
        this.userInfo.role_name == "分公司管理员"
      ) {
        row["deptId"] = this.userInfo.dept_id;
        row["id"] = that.licenceObj.id;
      }
 
      if (this.stats == "1") {
        row["type"] = 2;
      } else {
        row["type"] = 1;
      }
 
      if (row.id) {
        row["updateUser"] = this.userInfo.Id;
      } else {
        row["createUser"] = this.userInfo.Id;
      }
      licenceSubmit(row).then(
        () => {
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          that.getLicenceInfo();
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
      done();
    },
    //其他公司基本信息,工商信息修改
    submitBase(row, done, loading) {
      var that = this;
      if (
        this.userInfo.role_name == "保安公司管理员" ||
        this.userInfo.role_name == "培训公司管理员" ||
        this.userInfo.role_name == "分公司管理员"
      ) {
        row["departmentid"] = this.userInfo.dept_id;
        row["id"] = this.formData.id;
      }
      // console.log(row);
      update(row).then(
        () => {
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          that.formData = row;
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
      done();
    },
    //分公司许可信息修改
    licenceGroupSubmit(row, done, loading) {
      var that = this;
      if (
        this.userInfo.role_name == "保安公司管理员" ||
        this.userInfo.role_name == "培训公司管理员" ||
        this.userInfo.role_name == "分公司管理员"
      ) {
        row["deptId"] = this.userInfo.dept_id;
        row["id"] = that.licenceGroupObj.id;
        row["sid"] = that.licenceGroupObj.sid;
      }
      row["type"] = 1;
 
      if (row.id) {
        row["updateUser"] = this.userInfo.Id;
      } else {
        row["createUser"] = this.userInfo.Id;
      }
      // console.log(row);
      submitGroup(row).then(
        () => {
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          that.getLicenceInfo();
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
      done();
    },
    //从 localStorage 获取数据
    readLock(name) {
      return window.localStorage.getItem(name);
    },
    handleClick(tab, event) {
      if (tab.name == "tab1") {
        this.loading1 = false;
        this.seeWhere = "tab1";
      } else if (tab.name == "tab11") {
        this.seeWhere = "tab11";
        this.obj = this.formData;
      } else if (tab.name == "tab5") {
        this.seeWhere = "tab5";
        this.overcar = true;
      } else if (tab.name == "tab4") {
        this.seeWhere = "tab4";
        this.overzb = true;
      } else if (tab.name == "tab2") {
        this.seeWhere = "tab2";
        this.overshareholder = true;
      } else if (tab.name == "tab3") {
        this.seeWhere = "tab3";
        this.overmanager = true;
      } else if (tab.name == "tab9") {
        this.seeWhere = "tab9";
        this.social = true;
      } else if (tab.name == "tab8") {
        //获取许可证信息
        this.seeWhere = "tab8";
        this.getLicenceInfo();
      } else {
        this.social = false;
        this.overcar = false;
        this.overzb = false;
        this.overcar = false;
        this.overmanager = false;
        this.overshareholder = false;
      }
      this.$store.commit("setWindowSizeHeightAdd");
    },
    //获取许可证信息
    getLicenceInfo() {
      var that = this;
      getLicenceDetail(this.deptId).then(res => {
        that.licenceObj = res.data.data;
      });
    },
    //tag 防重复处理
    tagTraim() {
      //tag 防重复处理
      var flag = false,
        i = 0,
        ind = null;
      this.$store.state.tags.tagList.forEach((item, index) => {
        if (item.label == "单位详情") {
          if (flag == false) {
            ind = index;
            flag = true;
          }
          i++;
        }
      });
      if (i > 1) {
        this.$store.state.tags.tagList.splice(ind, 1);
      }
    },
    //编辑状态控制
    editController() {
      var that = this;
      if (this.stats == "1") {
        //培训学校
        this.licenceOption.column = lincenceTrainColumn;
      } else {
        this.licenceOption.column = lincenceColumn;
      }
 
      //基本信息列控制
      if (this.stats == "4") {
        //分公司
        this.optionBase.column = filialeColumn;
      } else if (this.stats == "0") {
        //自招保安单位
        this.optionBase.column = selfColumn;
      } else {
        //学校,本市保安公司
        this.optionBase.column = column;
      }
 
      //获取当前登录人员的角色信息
      // var roleIds = this.userInfo.role_id.split(",");
      // roleIds.forEach((roleId) => {
      //   getRoleDetail(roleId).then((res) => {
      //     var roleAlias = res.data.data.roleAlias;
      var roleAlias = this.userInfo.role_name;
      var d = that.optionBase.column;
      var e = that.option01.column;
      var f = that.businessOption.group;
      var g = f[0].column;
      var h = f[1].column;
      var bb = that.licenceOption.column;
      //控制按钮,编辑状态
      if (
        roleAlias == "保安公司管理员" ||
        roleAlias == "分公司管理员" ||
        roleAlias == "培训公司管理员"
      ) {
        that.optionBase.submitBtn = true;
        that.businessOption.submitBtn = true;
        that.option01.submitBtn = true;
        that.licenceOption.submitBtn = true;
        for (var k in d) {
          d[k].disabled = false;
        }
        for (var n in e) {
          e[n].disabled = false;
        }
        for (var l in g) {
          g[l].disabled = false;
        }
        for (var m in h) {
          h[m].disabled = false;
        }
        for (var mm in bb) {
          bb[mm].disabled = false;
        }
      } else {
        that.optionBase.submitBtn = false;
        that.option01.submitBtn = false;
        that.businessOption.submitBtn = false;
        that.licenceOption.submitBtn = false;
        for (var a in d) {
          d[a].disabled = true;
        }
        for (var b in e) {
          e[b].disabled = true;
        }
        for (var c in g) {
          g[c].disabled = true;
        }
        for (var z in h) {
          h[z].disabled = true;
        }
        for (var zz in bb) {
          bb[zz].disabled = true;
        }
      }
      // });
      // });
    },
    //获取保安公司数据
    getdatas(data) {
      //页面编辑状态控制
      this.editController();
      //数据读取
      this.doit(data);
    },
    doit(data) {
      var that = this;
      var row = {};
      if (data != null) {
        row = data;
        that.departmentid = row.departmentid;
        for (var k in row) {
          that.objBase[k] = row[k];
        }
        if (row.creditcode == "") {
          that.creditcode = 111;
        } else {
          that.creditcode = row.creditcode;
        }
        that.overHtp = true;
      } else {
        that.objBase.enterprisename = "未选择查询单位";
      }
    },
    //数据初始化
    initData() {
      var that = this;
      var datas = this.$route.query.data;
      // console.log(datas,123456);
      //判断进入的入口,单位信息进入,单位列表查看进入
      if (datas) {
        var data = JSON.parse(this.$route.query.data);
        that.formData = data;
        //单位列表进入
        var stats = data.stats;
        var deptId = data.departmentid;
        //初始tab控制
        this.initController(stats, deptId);
        //初始数据获取
        this.getdatas(data);
      } else {
        //单位信息进入
        var value = {
          departmentid: that.userInfo.dept_id
        };
        getOncedata(value).then(res => {
          that.formData = res.data.data;
          var stats = res.data.data.stats;
          var deptId = res.data.data.departmentid;
          //初始tab控制
          this.initController(stats, deptId);
          //初始数据获取
          this.getdatas(res.data.data);
        });
      }
    },
    //tab 初始设置
    initController(stats, deptId) {
      this.stats = stats;
      this.deptId = deptId;
      var that = this;
      // 判断按进入的公司类型
      if (stats == "2") {
        //本市保安公司
        that.baseTitle = "保安单位基本信息";
      }
      if (stats == "0") {
        //自招保安单位
        that.baseTitle = "单位基本信息";
        that.equipmentVisiable = false;
        that.carVisiable = false;
        that.shareholderVisiable = false;
        that.certificdinedVisiable = true;
        that.licenceVisiable = false;
      }
      if (stats == "4") {
        //分公司
        that.baseTitle = "保安单位基本信息";
        that.certificdinedVisiable = true;
        that.businessVisiable = false;
        that.licenceLabel = "总公司许可证信息";
        //查询分公司(及总公司)工商信息
        getBusinessInfo(deptId).then(res => {
          that.businessObj = res.data.data;
          if (that.businessObj.id == -1) {
            that.businessObj.id = null;
          }
        });
      }
      if (stats == "1") {
        //培训学校
        that.baseTitle = "学校基本信息";
        that.managerLabel = "师资力量";
        that.licenceLabel = "培训许可证信息";
        that.carVisiable = false;
        that.shareholderVisiable = false;
      }
    }
  },
  mounted() {
    this.tagTraim();
  },
  created() {
    //初始化信息
    this.initData();
  },
  watch: {}
};
</script>
 
<style lang="scss" scoped>
.dispatch {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
 
.el-collapse-item {
  padding-top: 15px !important;
}
 
.tab {
  position: relative;
  // border: 1px solid red;
  background-color: #fff;
  height: 92%;
  display: inline-block;
  width: 100%;
  overflow: hidden;
  top: -10px;
}
 
.manager {
  height: 755px;
}
</style>