quanyawei
2024-09-06 75c45150bcc5b1a3b45efe98ce6ec92b7b10aba3
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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
<template>
  <div>
    <a-card :bordered="false" style="margin-top: 24px">
      <div class="tableList">
        <div class="tableListForm">
          <a-form layout="horizontal">
            <a-row :gutter="{ md: 8, lg: 24, xl: 48 }">
              <a-col :md="8" :sm="24">
                <a-form-item fieldDecoratorId="query" v-bind="searchFormLayout">
                  <a-input type="text" placeholder="请输入名称" v-model="queryData"/>
                </a-form-item>
              </a-col>
              <a-col>
              </a-col>
              <div class="tableListOperator1">
                <a-button icon="plus" type="primary" @click="() => this.handleModalVisible(true)">
                  新建
                </a-button>
              </div>
            </a-row>
          </a-form>
        </div>
      </div>
      <av-system-table
          :dataSource="dataSource"
          :columns="columns"
          :total="total"
          :paginationProps="pagination"
          @cPage="turnCurrentPage">
      </av-system-table>
    </a-card>
    <a-modal width="45%" title="添加-组织" destroyOnClose :visible="visibleCreateModal" @ok="saveOrgData"
             @cancel="handleCreateModalCancel">
      <!---->
      <a-form style="margin-top: 8px" :form="form">
        <a-row>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }"  :wrapperCol="{ span: 15 }" label="名称">
              <a-input placeholder="名称"  v-decorator="['name', { rules: [{ required: true,message: '名称不能为空'}] }]"/>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item label="父组织" :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" >
              <a-select placeholder="请选择父组织" allowClear
                        show-search
                        option-filter-prop="children"
                        :filter-option="filterOption"
                        v-decorator="['pname', { rules: [{ required: false}] }]"
                        @change="handleChange">
                <!--                       @blur="handleBlur"-->
                <a-select-option v-for="(item,index) of orgMenu" :value="item.id"> {{ item.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="城市">
                <a-cascader :options="areaData" placeholder="请选择城市" @change="citydata" v-decorator="['city', { rules: [{ required: true, message: '城市不能为空'  }] }]"/>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="电话" >
              <a-input placeholder="请输入" v-decorator="['phone', { rules: [{ required: false,  message: '请输入正确的号码格式' ,  pattern:/^(13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|18[0-9]{9})$|(^\d{3}-\d{7,8}|\d{4}-\d{7,8})$/ }] }]"/>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="定位级别" >
              <a-cascader :options="areaData" placeholder="双击选择城市" change-on-select @change="positionLevel"
                          v-decorator="['position', { rules: [{ required: true, message: '定位级别不能为空'  }] }]"
                          labelInValue/>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="邮箱">
              <a-input placeholder="请输入" v-decorator="['email', { rules: [{ required: false,message:'请输入正确邮箱格式', pattern:/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/}] }]"/>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="地址" >
              <a-input placeholder="请输入" v-decorator="['address', { rules: [{ required: true, message: '地址不能为空'  }] }]"/>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="微信">
              <a-input placeholder="请输入" v-decorator="['wechat', { rules: [{ required: false }] }]"/>
            </a-form-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="有效期" >
              <a-date-picker
                  format="YYYY-MM-DD"
                  :disabled-date="disabledDate"
                  v-decorator="['expireTime', { rules: [{ required: true, message: '日期不能为空'  }] }]"
              />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-modal>
    <a-modal width="45%" title="编辑-组织" destroyOnClose :visible="visibleEditModal" @ok="editOrgData"
             @cancel="handleEditModalCancel">
      <!---->
      <a-form-model style="margin-top: 8px"
                    :model="beforeEdit"
                    :rules="rules"
                    ref="editOrgForm"
                    :label-col="{span: 4}"
                    :wrapper-col="{span: 14}">
        <a-row>
          <a-col :md="11" :sm="24">
            <a-form-model-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="名称" prop="name">
              <a-input placeholder="名称" v-model="beforeEdit.name"/>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item label="父组织" :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }">
 
              <a-select
                  show-search
                  placeholder="请选择父组织"
                  v-model="beforeEdit.pname"
                  allowClear
                  option-filter-prop="children"
                  :filter-option="filterOption"
                  @change="handleChange">
                <!--                       @blur="handleBlur"-->
                <a-select-option v-for="(item,index) of orgMenu" :value="item.id"> {{ item.name }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="城市" prop="cityBack">
              <a-cascader v-model="beforeEdit.cityBack" :options="areaData" placeholder="请选择城市" @change="vCity"
                          labelInValue/>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="电话" prop="phone">
              <a-input v-model="beforeEdit.phone" placeholder="请输入"/>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item  :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="定位级别" prop="positionBack">
              <a-cascader v-model="beforeEdit.positionBack" :options="areaData" placeholder="双击选择城市" change-on-select
                          @change="positionLevel" labelInValue/>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="邮箱" prop="email">
              <a-input v-model="beforeEdit.email" placeholder="请输入"/>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="地址" prop="address">
              <a-input v-model="beforeEdit.address" placeholder="请输入"/>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="微信">
              <a-input v-model="beforeEdit.wechat" placeholder="请输入"/>
            </a-form-model-item>
          </a-col>
          <a-col :md="11" :sm="24">
            <a-form-model-item :labelCol="{ span: 8 }" :wrapperCol="{ span: 15 }" label="有效期" prop="expireTime">
              <a-date-picker v-model="beforeEdit.expireTime"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-modal>
    <a-modal width="45%" title="菜单配置" destroyOnClose :visible="showTree" @ok="handleTreeOk" @cancel="handleTreeCancel">
      <a-tree
          v-model="selectMenus"
          checkable
          defaultExpandAll
          :tree-data="webMenusData"
          @check="onChangePermissionsTree"
      />
    </a-modal>
    <div class="deleteConfirm" :class="{ orDelete: !deleteConfimFlag }">
      <p>是否删除子组织</p>
      <span class="confimButton" @click="cancelDeleteChild">否</span>
      <span class="confimButton" @click="okDeleteChild">是</span>
    </div>
    <user-account @visible="turnAccountFlag"  v-if="userFlag" :visible="userFlag" :accountRecord="userRecord"/>
    <alarm-unit-configure :alarmUFlag="alarmFlag" :alarmRecord="alarmRecord" @turnAlarmFlag="turnAlarmFlag" />
    <configure-web :configure-flag="configureFlag" :configRecord="configRecord" @turnConfigureFlag="turnConfigureFlag"/>
  </div>
</template>
 
<script lang="tsx">
import {Component, Prop, Vue, Watch} from 'vue-property-decorator';
import org from '@/util/org'
import moment from 'moment'
import UserAccount from '@/views/system/userAccount.vue'
import AlarmUnitConfigure from "@/views/system/alarmUnitConfigure.vue";
import ConfigureWeb from "@/views/system/configureWeb.vue";
import { get, post } from "@/util/request";
 
@Component({
  components: {
    UserAccount,
    AlarmUnitConfigure,
    ConfigureWeb
  }
})
export default class Organization extends Vue {
 
  private userFlag: boolean = false
  private userRecord: any = null
 
  private deleteConfimFlag: boolean = false
  private updateTaskFormVisible: boolean = false;
  private updateRecord: any = {};
  private dataSource: any[] = []; //组织数据
 
  private visibleCreateModal: boolean = false;
  private visibleEditModal: boolean = false;
 
  private areaData: any = JSON.parse(JSON.stringify(org))
  private addForm: any = null
  private editForm: any = null
  private date: string = ''
 
  // web配置flag
  private configureFlag: boolean = false
  // 分页数据
  private pagination: any = {
    total: 0,
    current: 1,
    pageSize: 8,
    showSizeChanger: false,
    showQuickJumper: false,
  };
 
  // 分页数据总条数
  private total: number = 0
  // 修改组织规则验证
  private rules: any = {
    name: [
      {required: true, message: '名称不能为空', trigger: ['change', 'blur']},
    ],
    cityBack: [
      {required: true, message: '请选择城市', trigger: ['change', 'blur']},
    ],
    positionBack: [
      {required: true, message: '请选择定位级别'},
    ],
    phone: [
      {required: false, message: '请输入正确的电话格式', trigger: 'blur'},
    ],
    email: [
      {required: false, message: '请输入正确的邮箱格式', trigger: 'blur'},
    ],
    address: [
      {required: true, message: '地址不能为空', trigger: ['change', 'blur']},
    ],
    expireTime: [
      {required: true, message: '日期不能为空'},
    ]
  }
  // 列数据
  private columns: any[] = [
    {
      title: '名称',
      dataIndex: 'name',
    },
    {
      title: '父组织',
      dataIndex: 'parentName',
    },
    {
      title: '城市',
      dataIndex: 'provinceCityAreaName',
    },
    {
      title: '定位级别',
      dataIndex: 'locationLevelName',
    },
    {
      title: '电话',
      dataIndex: 'phone'
    },
    {
      title: '邮箱',
      dataIndex: 'email',
    },
    {
      title: '地址',
      dataIndex: 'address',
    },
    {
      title: '创建时间',
      dataIndex: 'createTime',
    },
    {
      title: '到期时间',
      dataIndex: 'expireTime',
    },
    {
      title: '用户账号',
      dataIndex: 'adminUserAccount',
    },
    {
      title: '操作',
      customRender: this.opRender
    }
  ];
  private codeAndName: any = null
  private editCodeAndName: any = null
  private queryData: string = ''
  private form: any = null
  private positionData: Array<any> = []
 
  //新增表单form
 
  // 修改前的数据(用于双向绑定)
  private beforeEdit: any = {
    id: 0,
    name: '',
    pname: '',
    locationLevelCode: '',
    locationLevelName: '',
    phone: '',
    email: '',
    wechat: '',
    address: '',
    expireTime: '',
    cityBack: [],
    positionBack: []
  }
  // 修改前的数据(用于记录)
  private record: any = null
  // 当前页
  private currentPage: number = 0
 
  // 接收子组件数据
  private turnCurrentPage(page: number) {
    this.currentPage = page
  }
 
  @Watch('queryData')
  private queryDataWatch(newVal: string, oldVal: string) {
    this.queryData = newVal.trim()
    this.currentPage = 1
    this.orgData()
  }
 
  @Watch('currentPage')
  private pageData() {
    this.orgData()
  }
 
  private searchFormLayout: any = {
    labelCol: {
      span: 5,
    },
    wrapperCol: {
      span: 18,
      offset: 1,
    },
  };
 
  private mounted() {
    this.form = this.$form.createForm(this, {name: "Organization"});
    this.orgData()
  }
 
 
  private queryOrg: string = ''
  private orgMenu: any = []
  //显示树状菜单
  private showTree: boolean = false
 
  private vCity(val: any, selectedOptions: any) {
    if (selectedOptions === undefined) {
      this.beforeEdit.cityBack = []
      this.editCodeAndName = []
    }else {
      this.beforeEdit.cityBack = val
      this.editCodeAndName = JSON.parse(JSON.stringify(selectedOptions))
    }
  }
 
  // 获取所有组织信息
  private getAllOrg() {
    if (this.record === null) {
      get("organization/queryNames", {
          name: this.queryOrg,
      }).then(res => {
        this.orgMenu = res.data.data.organizationVOs
      })
    } else {
      get("organization/queryNames", {
          name: this.queryOrg,
          id: this.record.id
      }).then(res => {
        this.orgMenu = res.data.data.organizationVOs
      })
    }
 
  }
 
  private handleEditModalCancel(): any {
    this.beforeEdit.cityBack = []
    this.beforeEdit.positionBack = []
    this.visibleEditModal = false;
  }
 
  // 隐藏弹框
  private handleCreateModalCancel(): any {
    this.visibleCreateModal = false;
  }
 
  // 显示增加弹框
  private handleModalVisible(isVisible: boolean): void {
    this.record = null
    this.getAllOrg()
    this.visibleCreateModal = isVisible;
  }
 
  // 城市数据
  private citydata(val: any, selectedOptions: any) {
    if (selectedOptions === undefined) {
      this.codeAndName = []
    }else {
      this.codeAndName = JSON.parse(JSON.stringify(selectedOptions))
    }
 
  }
 
  // 定位级别数据
  private positionLevel(val: any, selectedOptions: any) {
    if (selectedOptions === undefined) {
      this.beforeEdit.positionBack = []
      this.positionData = []
    }else {
      this.beforeEdit.positionBack = val
      this.positionData = JSON.parse(JSON.stringify(selectedOptions))
    }
  }
 
  // 日期格式转换
  private turnDate(date: any) {
    let d = new Date(date);
    // let datetime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
    let datetime = d.getFullYear() + '-' +( (d.getMonth() + 1).toString().length === 1 ? '0'+(d.getMonth() + 1) : (d.getMonth() + 1)  )+
                    '-' +( d.getDate().toString().length === 1 ? '0' + d.getDate() : d.getDate());
    this.date = datetime
  }
 
  // 禁止点击当前时间之前的时间
  private disabledDate(current: any) {
    // Can not select days before today and today
    return current && current < moment().endOf('day');
  }
 
  //保存数据
  private saveOrgData() {
    this.form.validateFields((err: any, values: any) => {
      if (err) {
        return;
      }
    this.turnDate(values.expireTime)
      post("organization/insert",
          {
            name: values.name.replace(/\s+/g, ""),
            parentId: values.pname ? values.pname : '',
            provinceCode: this.codeAndName[0].value ? this.codeAndName[0].value : '',
            provinceName: this.codeAndName[0].label ? this.codeAndName[0].label : '',
            cityCode: this.codeAndName[1].value ? this.codeAndName[1].value : '',
            cityName: this.codeAndName[1].label ? this.codeAndName[1].label : '',
            areaCode: this.codeAndName[2].value ? this.codeAndName[2].value : '',
            areaName: this.codeAndName[2].label ? this.codeAndName[2].label : '',
            locationLevelCode: this.positionData[this.positionData.length - 1].value,
            locationLevelName: this.positionData[this.positionData.length - 1].label,
            address: values.address ? values.address : '',
            phone: values.phone ? values.phone : '',
            email: values.email ? values.email : '',
            wechat: values.wechat ? values.wechat : '',
            expireTime: this.date ? this.date : ''
          },
      ).then(res => {
        if (res.data.code === 0) {
          this.visibleCreateModal = false;
          this.$message.success('添加成功')
          this.positionData = []
          this.orgData()
        }
      })
    })
 
 
  }
 
  private parentName: any = ''
 
  // 修改数据
  private editOrgData(): void {
 
    this.$refs.editOrgForm.validate((valid: any) => {
      if (valid) {
        this.parentName = ''
          let locationLevelCode = null
          let locationLevelName = null
          if (this.positionData.length === 0) {
            locationLevelCode = null
            locationLevelName = null
          } else {
            locationLevelCode = this.positionData[this.positionData.length - 1].value
            locationLevelName = this.positionData[this.positionData.length - 1].label
          }
          // 父组织没有变动
          if ((typeof this.beforeEdit.pname) === 'string') {
            for (let i = 0; i < this.orgMenu.length; i++) {
              if (this.beforeEdit.pname === this.orgMenu[i].name) {
                this.parentName = null
                break
              }
            }
          }
          // 删除父组织
          if ((typeof this.beforeEdit.pname) === 'undefined') {
            this.parentName = 0
          }
 
          let name = this.record.name === this.beforeEdit.name ? null : this.beforeEdit.name
 
        let parentId = this.parentName === null ? null :
                       (this.parentName === 0 && this.beforeEdit.pname === undefined && this.record.parentName === null) ? null :
                       this.beforeEdit.pname === undefined ? 0 : this.beforeEdit.pname
        let provinceCode = this.editCodeAndName === null ? null : this.editCodeAndName[0].value
        let  provinceName = this.editCodeAndName === null ? null : this.editCodeAndName[0].label
        let cityCode = this.editCodeAndName === null ? null : this.editCodeAndName[1].value
        let cityName = this.editCodeAndName === null ? null : this.editCodeAndName[1].label
        let areaCode = this.editCodeAndName === null ? null : this.editCodeAndName[2].value
        let areaName = this.editCodeAndName === null ? null : this.editCodeAndName[2].label
        let address = this.record.address === this.beforeEdit.address ? null : this.beforeEdit.address
        let phone = this.record.phone === this.beforeEdit.phone ? null : this.beforeEdit.phone
        let email = this.record.email === this.beforeEdit.email ? null : this.beforeEdit.email
        let wechat = this.record.wechat === this.beforeEdit.wechat ? null : this.beforeEdit.wechat
        this.turnDate(this.beforeEdit.expireTime)
        let expireTime = this.date === this.record.expireTime  ? null : this.date
 
        if (name || parentId || parentId === 0 || provinceName || provinceName || cityCode || cityName || locationLevelCode || locationLevelName ||
            areaCode || areaName || address || (phone || phone === '') || (email || email === '') || (wechat || wechat === '')  || expireTime) {
          post("organization/update",
              {
                organizationId: this.record.id,
                name: name,
                parentId: parentId,
                provinceCode: provinceCode,
                provinceName: provinceName,
                cityCode: cityCode,
                cityName: cityName,
                areaCode: areaCode,
                areaName: areaName,
                locationLevelCode: locationLevelCode,
                locationLevelName: locationLevelName,
                address: address,
                phone: phone,
                email: email,
                wechat: wechat,
                expireTime: expireTime
              }
          ).then(res => {
            if (res.data.code === 0) {
              this.orgData()
              this.positionData = []
              this.visibleEditModal = false;
              this.$message.success(res.data.message)
            }else {
              this.$message.warning(res.data.message)
            }
          })
        }else {
          this.$message.warning('未修改')
        }
 
 
      }else {
        return;
      }
    })
 
    }
 
 
  // 删除组织
  private deleteOrg(id: any, deleteChildren: number) {
    post("organization/delete",
        {
          organizationId: id,
          deleteChildren: deleteChildren
        }
    ).then(res => {
      if (res.data.code === 0) {
        this.$message.success(res.data.message)
        this.orgData()
      }
    })
  }
 
  // 获取组织列表数据
  private orgData() {
    get("organization/query", {
        page: this.currentPage,
        size: this.pagination.pageSize,
        name: this.queryData,
        order: 'createTime',
        orderType: 1
    }).then(res => {
      this.dataSource = res.data.data.organizations
      this.pagination.current = res.data.data.current
      this.pagination.total = res.data.data.total
      this.pagination.pageSize = res.data.data.size
      if (res.data.data.current - 1 === res.data.data.pages) {
        this.currentPage = res.data.data.pages
        this.orgData()
      }
    })
  }
 
 
  // 账号信息管理
  private handleAccountModalVisible(visible: boolean, record: any) {
    this.userFlag = visible
    this.userRecord = record
  }
 
  // 编辑组织信息
  private handleEditModalVisible(visible: boolean, record: any): void {
      this.record = record
    this.getAllOrg()
    this.beforeEdit.name = record.name
    this.beforeEdit.address = record.address
    this.beforeEdit.pname = record.parentName === null ? undefined :  record.parentName
    this.beforeEdit.expireTime = record.expireTime
    this.beforeEdit.phone = record.phone
    this.beforeEdit.email = record.email
    this.beforeEdit.wechat = record.wechat
    this.beforeEdit.cityBack = []
    this.beforeEdit.cityBack.push(record.provinceCode)
    this.beforeEdit.cityBack.push(record.cityCode)
    this.beforeEdit.cityBack.push(record.areaCode)
    if (JSON.stringify(record.locationLevelCode).substring(2, 6) === '0000') {
      this.beforeEdit.positionBack.push(record.locationLevelCode)
    } else {
      this.beforeEdit.positionBack = []
      if (JSON.stringify(record.locationLevelCode).substring(4, 6) === '00') {
        this.beforeEdit.positionBack.push(parseInt((JSON.stringify(record.locationLevelCode).substring(0, 2) + '0000')))
        this.beforeEdit.positionBack.push(record.locationLevelCode)
      } else {
        this.beforeEdit.positionBack.push(parseInt((JSON.stringify(record.locationLevelCode).substring(0, 2) + '0000')))
        this.beforeEdit.positionBack.push(parseInt((JSON.stringify(record.locationLevelCode).substring(0, 4) + '00')))
        this.beforeEdit.positionBack.push(record.locationLevelCode)
      }
    }
    // this.$refs.city.push(record.locationLevelCode)
    this.visibleEditModal = visible;
  }
 
  private deleteId: any = -1
 
  private cancelDeleteChild() {
    this.deleteOrg(this.deleteId, 0)
    this.deleteConfimFlag = false
  }
 
  private okDeleteChild() {
    this.deleteOrg(this.deleteId, 1)
    this.deleteConfimFlag = false
  }
 
  private handleChange(value: any) {
 
    // this.beforeEdit.pname = value != null && value != '' ? value : [];
  }
 
  private filterOption(input: any, option: any) {
    return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    );
  }
 
  // 所有前端菜单
  private webMenusData: any[] = []
  // 指定组织选中的菜单
  private selectMenus: any[] = []
 
  /*
  * 树形方法 --------------------------------------------------------------------
  * */
  private checkKey!: any
  private autoExpandParent: boolean = true
 
  private onSelect(selectedKeys: any[], info: any) {
    // this.selectedKeys = selectedKeys;
  }
 
  private onCheck(expandedKeys: any) {
    // if not set autoExpandParent to false, if children expanded, parent can not collapse.
    // or, you can remove all expanded children keys.
    // this.autoExpandParent = false;
  }
 
  private handleTreeCancel() {
    this.showTree = false
  }
 
  private menuIds!: any[]
 
  private onChangePermissionsTree(node: any, event: any) {
    this.menuIds = []
    let halfKeys = event.halfCheckedKeys
    this.menuIds = node.concat(halfKeys)
  }
 
  private oId: any = -2
 
  private handleTreeOk() {
    if (this.menuIds) {
      if (this.menuIds[0] === -1) {
        this.showTree = false
      } else {
        post("group/updateAdminGroupMenu",
            {
              organizationId: this.oId,
              channelKey: 0,
              menuIds: this.menuIds
            }
        ).then((res: any) => {
          if (res.data.code === 0) {
            this.$message.success(res.data.message)
            this.showTree = false
          }
        })
      }
    }
 
    this.menuIds = [-1]
  }
 
 
  // 选择菜单
  private webMenu: any[] = []
 
  private selectWebMenu(record: any) {
    this.oId = record.id
    this.webMenusData = []
    this.showTree = true
    get('menu/query', {}).then((res: any) => {
      this.webMenu = res.data.data.menus
      this.treeDatas(this.webMenu)
    })
    this.selectedWeb(record)
  }
 
  //已选前端菜单
  private selectedWeb(record: any) {
    get("menu/queryAdmin", {
        organizationId: record.id
    }).then(res => {
      if (res.data.code === 0) {
        let datas = res.data.data.menus
        let array = []
        for (let i in datas) {
          array.push(datas[i].id)
        }
        this.selectMenus = array
      }
    })
  }
 
  // 递归更改数据格式
  private treeDatas(datas: any[]) {
    for (let i in datas) {
      if (datas[i].children) {
        datas[i].key = datas[i].id
        datas[i].title = datas[i].name
        delete datas[i].name
        delete datas[i].url
        delete datas[i].order
        delete datas[i].id
        this.treeDatas(datas[i].children)
      } else {
        datas[i].title = datas[i].name
        datas[i].key = datas[i].id
        datas[i].parentId = datas[i].parentId
        delete datas[i].name
        delete datas[i].url
        delete datas[i].order
        delete datas[i].id
      }
    }
    this.webMenusData = datas
  }
 
  private showOrHidden() {
    this.showTree = false
  }
 
  private turnAccountFlag(flag: boolean) {
    this.userFlag = flag
  }
 
  // 配置报警以及显示单位===============================================
  private alarmFlag: boolean = false
  private turnAlarmFlag(flag: boolean) {
    this.alarmFlag = flag
  }
  private alarmRecord: any = null
  private displayUnitAndAlarm(record: any) {
    this.alarmRecord = record
    this.alarmFlag = true
  }
 
  // 接受大屏配置flag
  private turnConfigureFlag(flag: boolean) {
    this.configureFlag = flag
  }
 
  // 存放组织record
  private configRecord: any = null
  // 大屏布局model隐藏显示
  private configureWebLayout(record: any) {
    this.configRecord = record
    this.configureFlag = true
  }
 
  private opRender(text: string, record: any, index: number) {
    return (<div>
      <a onClick={
        () => this.handleEditModalVisible(true, record)
      }> 编辑 </a>
      <a-divider type='vertical'/>
      <a-popconfirm
          title="请确认删除"
          ok-text="是"
          cancel-text="否"
          onConfirm={() => {
            this.deleteId = record.id
            this.deleteConfimFlag = true
          }}
          oncancel="1"
      >
        <a>删除</a>
      </a-popconfirm>
      <a-divider type='vertical'/>
      <a  onClick={
        () => this.handleAccountModalVisible(true, record)
      }>
        账号
      </a>
      <a-divider type='vertical'/>
      <a onClick={
        () => this.selectWebMenu(record)
      }>
        前端菜单配置
      </a>
      <a-divider type='vertical'/>
      <a-dropdown>
        <a class="ant-dropdown-link">
          更多 <a-icon type="down"/></a>
        <a-menu slot="overlay">
          <a-menu-item>
            <a onClick={() => this.displayUnitAndAlarm(record)}>报警信息配置</a>
          </a-menu-item>
          <a-menu-item>
            <a onClick={() => this.configureWebLayout(record)}>配置大屏布局</a>
          </a-menu-item>
        </a-menu>
      </a-dropdown>
    </div>);
  }
}
</script>
 
<style lang="less">
.tableList {
  .tableListOperator1 {
    margin-bottom: 16px;
 
    button {
      margin-right: 8px;
      margin-top: 3px;
    }
  }
}
 
.orDelete {
  display: none;
}
 
.deleteConfirm {
  width: 16%;
  height: 100px;
  background-color: white;
  position: fixed;
  top: 220px;
  left: 48%;
  z-index: 2;
  border-radius: 10px;
  border: 1px solid red;
}
 
.confimButton {
  width: 30%;
  display: inline-block;
  text-align: center;
  height: 25px;
  margin-left: 14%;
  background-color: #00A0E9;
  color: white;
  height: 24px;
  line-height: 24px;
  border-radius: 4px;
  /*margin-top: 5px;*/
}
 
.confimButton:hover {
  opacity: 0.8;
}
 
.deleteConfirm p {
  width: 100%;
  text-align: center;
  margin-top: 25px;
  font-size: 16px;
  color: red;
}
 
/*.ant-calendar-picker{*/
/*  width: 180%;*/
/*}*/
</style>