Administrator
2021-12-25 5eb297ca090776f5e5e4daec219892f8c19592b4
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
<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
            ref="form"
            v-model="obj"
            :option="option01"
            @submit="submitBase"
          >
          </avue-form>
        </basic-container>
      </el-tab-pane>
      <!-- 出资人列表信息 -->
      <el-tab-pane :label="tab2label" name="tab2" v-if="shareholderVisiable">
        <shareholder
          v-if="overshareholder"
          :deptid="departmentid"
          :windowHeight="windowHeight"
        ></shareholder>
      </el-tab-pane>
      <!-- 主要管理人信息 -->
      <el-tab-pane :label="managerLabel" name="tab3">
        <manager
          v-if="overmanager"
          :deptid="departmentid"
        ></manager>
      </el-tab-pane>
      <!-- 装备管理列表 -->
      <el-tab-pane label="装备管理" name="tab4" v-if="equipmentVisiable">
        <equipments
          v-if="overzb"
          :fromDeptId="departmentid"
          :windowHeight="windowHeight"
        ></equipments>
      </el-tab-pane>
      <!-- 车辆管理 -->
      <el-tab-pane label="车辆管理" name="tab5" v-if="carVisiable">
        <car
          :fromDeptId="departmentid"
          v-if="overcar"
          :windowHeight="windowHeight"
        ></car>
      </el-tab-pane>
      <!-- 社保记录  -->
      <el-tab-pane label="社保记录" name="tab9">
        <social
          :deptid="objBase.departmentid"
          :socialRE="social"
          v-if="social"
        ></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>
      </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} from "./data";
import { getOncedata, update} 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,
      licenceVisiable: true,
      shareholderVisiable: true,
      equipmentVisiable: true,
      carVisiable: true,
      //结决id传入、信息获取的优先级
      overzb: false,
      overmanager: false,
      overshareholder: false,
      //结决id传入、信息获取的优先级
      overcar: false,
      //解决表格错乱
      social: false,
      overHtp: false,
      activeName: "tab1",
      departmentid: "",
      //全局单位统一社会信用代码
      creditcode: "",
      //保安单位信息表单
      objBase: {
        // title: "我是头部标题",
      },
      formData:{},
      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: {
    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();
    },
    //从 localStorage 获取数据
    readLock(name) {
      return window.localStorage.getItem(name);
    },
    handleClick(tab, event) {
      if (tab.name == "tab1") {
        this.loading1 = false;
      }else if (tab.name == "tab11") {
        this.obj = this.formData;
      }else if (tab.name == "tab5") {
        this.overcar = true;
      } else if (tab.name == "tab4") {
        this.overzb = true;
      } else if (tab.name == "tab2") {
        this.overshareholder = true; 
      } else if (tab.name == "tab3") {
        this.overmanager = true;
      } else if (tab.name == "tab9") {
        this.social = true; 
      } 
      else {
        this.social = false;
        this.overcar = false;
        this.overzb = false;
        this.overcar = false;
        this.overmanager = false;
        this.overshareholder = false;
      }
    },
    //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;
      //获取当前登录人员的角色信息
      var roleIds = this.userInfo.role_id.split(",");
      roleIds.forEach((roleId) => {
        getRoleDetail(roleId).then((res) => {
          var roleAlias = res.data.data.roleAlias;
          var d = that.optionBase.column;
          var e = that.option01.column;
          //控制按钮,编辑状态
          if (roleAlias == "保安公司管理员" || 
          roleAlias == "分公司管理员" ||
          roleAlias == "培训公司管理员") {
            that.optionBase.submitBtn = true;
            that.option01.submitBtn = true;
            for (var k in d) {
              d[k].disabled = false;
            }
            for (var n in e) {
              e[n].disabled = false;
            }
          } else {
            that.optionBase.submitBtn = false;
            that.option01.submitBtn = false;
            for (var a in d) {
              d[a].disabled = true;
            }
            for (var b in e) {
              e[b].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;
        if(data.stats == "0"){
          //自招保安单位
          const industrycolumn = this.findObject(this.optionBase.column, "industry");
          const representativecolumn = this.findObject(this.optionBase.column, "representative");
          const representativecellcolumn = this.findObject(this.optionBase.column, "representativecell");
          const fregioncolumn = this.findObject(this.optionBase.column, "fregion");
          const ftimecolumn = this.findObject(this.optionBase.column, "ftime");
          
          //法人及电话,办公地址不可见
          industrycolumn.display = false;
          representativecolumn.display=false;
          representativecellcolumn.display=false;
          //服务区域,时间可见
          fregioncolumn.display=true;
          ftimecolumn.display=true;
        }
        if(data.stats == "4"){
          //分公司
          const representativecolumn = this.findObject(this.optionBase.column, "representative");
          const representativecellcolumn = this.findObject(this.optionBase.column, "representativecell");
          //法人及电话不可见
          representativecolumn.label="分公司负责人";
          representativecellcolumn.label="分公司负责人电话";
        }
        // if (that.readLock("danweidataS") != null && a == 1) {
        //   var b = JSON.parse(that.readLock("danweidataS"));
        //   var i = 0;
        //   for (var k in b) {
        //     if (b[k].enterprisename == row.enterprisename) {
        //       i = 1;
        //     }
        //   }
        //   if (i != 1) {
        //     that.objBase = {};
        //     that.objBase.enterprisename = row.enterprisename + "该公司已删除";
        //     window.localStorage.removeItem("danweidata");
        //     that.creditcode = "";
        //   }
        // }
      } else {
        that.objBase.enterprisename = "未选择查询单位";
      }
    },
    //数据初始化
    initData() {
      // alert(1);
      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;
        // console.log(data,3333333);
        //单位列表进入
        var stats = data.stats;
        //初始tab控制
        this.initController(stats);
        //初始数据获取
        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;
          //初始tab控制
          this.initController(stats);
          //初始数据获取
          this.getdatas(res.data.data);
        });
      }
    },
    //tab 初始设置
    initController(stats) {
      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;
      }
      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>