ludc
2023-07-06 abe9f2de85ff402a4c989dbc1427807b4e3a59f4
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
<!--suppress ALL -->
<template>
  <el-container>
    <!--    左侧菜单-->
    <el-aside>
      <basic-container style="height: 85vh; max-height: 155vh; overflow-y: scroll;">
        <div>
          <div style="display: flex;justify-content: space-around">
            <el-button plain size="small" type="primary" @click="TreeAdd">添加</el-button>
            <el-button plain size="small" type="primary" @click="TreeEdit">修改</el-button>
            <el-button plain size="small" type="primary" @click="TreeDel">删除</el-button>
<!--            <el-button plain size="small" type="primary" @click="ExportExcel">导出</el-button>-->
<!--            <el-button plain size="small" type="primary" @click="ImportExcel">导入</el-button>-->
            <el-button plain size="small" type="primary" @click="flushed">刷新</el-button>
          </div>
          <div style="display: flex;justify-content: space-around;margin-top: 5px;margin-bottom: 5px">
          </div>
        </div>
        <!--        树节点添加对话框-->
        <el-dialog :title="this.TreeFlag ? '添加分类' :'添加主题库'" :visible.sync="TreeAddFormVisible" append-to-body
                   style="width: 1700px;margin: auto">
          <el-form :model="TreeAddform">
            <el-form-item :label="this.TreeFlag ? '分类编号:' :'主题库编号:'" label-width="150px" style="display: inline-block">
              <el-input v-model="TreeAddform.id" autocomplete="off" style="width: 170px"></el-input>
            </el-form-item>
            <el-form-item :label="this.TreeFlag ? '分类名称:' :'主题库名称:'" label-width="100px" style="display: inline-block">
              <el-input v-model="TreeAddform.name" autocomplete="off" style="width: 170px"></el-input>
            </el-form-item>
            <el-form-item label="描述:" label-width="150px">
              <el-input v-model="TreeAddform.description" autocomplete="off" style="width: 585px"></el-input>
            </el-form-item>
            <el-form-item label="编码规则:" label-width="150px">
              <el-input v-model="TreeAddform.coderuleoidName" autocomplete="off" style="width: 585px"></el-input>
            </el-form-item>
            <el-form-item label="关键属性查询规则:" label-width="150px">
              <el-input v-model="TreeAddform.codekeyattrrepeatoidName" autocomplete="off"
                        style="width: 585px"></el-input>
            </el-form-item>
            <el-form-item label="相似查询规则:" label-width="150px">
              <el-input v-model="TreeAddform.codeResembleRuleOidName" autocomplete="off"
                        style="width: 585px"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="TreeAddFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="TreeAddHandler">确 定</el-button>
          </div>
        </el-dialog>
        <!--        修改对话框-->
        <el-dialog :visible.sync="TreeEditFormVisible" append-to-body title="修改分类">
          <classifyTreeform ref="childForm" :loneTreeNewForm="TreeList" :nodeList="nodeList" :flag="'edit'" @MasterHandler="MasterHandler" :Editclose=" ()=>{TreeEditFormVisible=false}"></classifyTreeform>
        </el-dialog>
        <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="CloneTreedata" :defaultExpandAll="false"
                   :option="Treeoption"
                   style="height: 80.5vh;padding-top: 5px;padding-bottom: 30px"
                   @node-click=" nodeClick"
                   @check-change="checkChange"
        >
        </avue-tree>
      </basic-container>
    </el-aside>
    <el-main>
      <basic-container style="height: 85vh; max-height: 155vh; ">
        <!--        右侧表格-->
        <avue-tabs :option="tabOption" @change="handleChange"></avue-tabs>
        <span v-if="type.prop==='tab1'">
           <classifyTreeform ref="childForm" :loneTreeNewForm="TreeList" :nodeList="nodeList" :flag="'renonly'"></classifyTreeform>
        </span>
        <span v-else-if="type.prop==='tab2'">
            <basic-container>
               <avue-crud v-model="crudForm" v-loading="FormLoing" :data="this.Formlist" :option="this.crudTreeOption"
                          @row-save="CrudRowSave"
                          @row-del="CrudRowDel"
                          @row-update="CrudRowUpdata"
                          :before-close="beforeClose"
                          @select="selectHandle"
               >
            <template slot="menuLeft">
              <el-button plain size="small" type="primary" @click="FindeHanler">查询</el-button>
              <el-button plain size="small" type="primary" @click="TemRefresh">刷新</el-button>
            <el-button plain size="small" type="primary" @click="Enable">启用</el-button>
            <el-button plain size="small" type="primary" @click="Deactivate">停用</el-button>
              <el-button plain size="small" type="primary" @click="CloneBtn">从其它模板克隆</el-button>
              <!--              查询对话框-->
           <el-dialog :visible.sync="FindFormVisible" append-to-body title="高级查询">
              <div>
                <el-button size="small" type="primary" @click="AdvQueries">查询</el-button>
                <el-button size="small" type="primary">重置</el-button>
              </div>
             <div style="padding-left: 80px;margin-top: 15px;">
               <template v-for="(value, key) in FindSelect">
                <div style="display: flex; justify-content: space-around; width: 85%; margin-bottom: 15px">
                <el-select v-model="FindSelect[key]" placeholder="请选择" style="width: 28%"
                           @change="handleSelectChange(key)">
                  <el-option label="模板编号" value="0"></el-option>
                  <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-select>
                <el-select v-model="condition[0]" placeholder="请选择" style="width: 15%">
                  <el-option label="包含" value="0"></el-option>
                  <el-option label="等于" value="1"></el-option>
                </el-select>
              <el-input v-model="QueryArray[key]" style="width: 49%"></el-input>
          <span> <i class="el-icon-delete" style="font-size: 22px;margin-top:8px;margin-left: 10px"/></span>
             </div>
          </template>
        </div>
           </el-dialog>
              <!--            模板克隆  -->
                <el-dialog :visible.sync="CloneVisible" append-to-body title="克隆模板">
                  <el-container>
                    <el-aside width="300px">
                      <div style="margin-bottom: 5px"><el-tag>主题库分类</el-tag></div>
                      <!--                      克隆模板的树 沿用首页树的loading和option,但是data和v-model绑定的数据创建一个新的变量,另外点击方法也是重新获取来操作克隆模板的数据-->
                        <avue-tree ref="tree" v-model="TreeAvueform" v-loading="loading" :data="Treedata"
                                   :defaultExpandAll="false"
                                   :option="Treeoption"
                                   style="height: 50.5vh;margin-right: 10px"
                                   @node-click="ClonenodeClick"
                        >
                        </avue-tree>
                    </el-aside>
                     <el-container>
                       <el-main>
                         <div style="padding-left: 10px;height: 50.5vh">
                           <div style="margin: 8px 0;display: flex">
                             <el-select v-model="Clonevalue" size="small" style="width: 130px;">
                               <el-option
                                 v-for="item in this.CloneSelectOptions"
                                 :key="item.value"
                                 :label="item.label"
                                 :value="item.value">
                              </el-option>
                             </el-select>
                            <el-input v-model="CloneFind" size="small" style="width: 40%;margin-left: 15px" placeholder="输入值后按回车进行模糊查询"></el-input>
                             <el-button size="small" type="primary" plain style="margin-left: 10px" @click="CloneEnterFind"  @keyup.enter.native="CloneEnterFind">查询</el-button>
                           </div>
                            <avue-crud v-model="ClonecrudForm" v-loading="FormLoing" :data="this.CloneFormlist"
                                       :option="this.ClonecrudTreeOption"
                                       @selection-change="selectionChange"
                            ></avue-crud>
                         </div>
                       </el-main>
                     </el-container>
                    </el-container >
                   <div style="display: flex; justify-content: flex-end; align-items: center;margin-top: 10px" >
                     <el-button size="small " type="primary" @click="Clonehandler">确定</el-button>
                     <el-button size="small" @click="CloneVisible=false" >取消</el-button>
                   </div>
                      <el-dialog
                        width="30%"
                        title="克隆模板"
                        :visible.sync="CloneinnerVisible"
                        append-to-body>
                        <div>
                          <avue-form :option="CloneOption" @submit="Clonesubmit" v-model="CloneModel"></avue-form>
                        </div>
                    </el-dialog>
                </el-dialog>
            </template>
          </avue-crud>
 
          </basic-container>
          <templatePro :ProData="this.ProData" :crudOid="this.crudOid" :crudArray="this.crudArray" :Formlist="this.Formlist" :codeClassifyOid="this.codeClassifyOid"></templatePro>
        </span>
      </basic-container>
    </el-main>
  </el-container>
</template>
<script>
import {
  getAtrrList,
  TreeSave,
  TreeDel,
  TreeCheckDel,
  TreeObjcet,
  TreeEnable,
  TreeDeactivate,
  gridCodeClassifyTemplate,
  getObjectByOid,
  gridCodeClassifyTemplateAttr,
  gridCodeClassifyFindTemplate,
  addSave,
  deleteData,
  editSave,
  copy
} from "@/api/template/templateAttr";
 
export default {
  name: "classifyTrees.vue",
  //使用inject接收参数
  //Treeoption左侧树新增表单项 Treedata左侧树节点 配置项 crudTreeOption右侧表格配置项 crudTreeData右侧表格显示内容
  //Treeform右侧表单配置项
  inject: [, "crudTreeData"],
  data() {
    return {
      addFlag:false,
      // 表格当前行id
      crudOid:"",
      //表格当前选择数组
      crudArray:[],
      //模板属性展示内容
      ProData: [],
      //回车键搜索绑定值
      searchTemplate: {
        searchCondition: 'id',
        findText: "",
      },
 
      //高级查询对话框
      FindFormVisible: false,
      //克隆模板对话框
      CloneVisible: false,
      CloneinnerVisible:false,
      //高级查询下拉框
      FindSelect: {
        id: "0",
        name: "1",
        description: "2",
        revisionValue: "3",
        lcStatus: "4"
      },
      //高级查询条件
      condition: ["0", "0", "0", "0", "0"],
      //高级查询 等于/不等于
      Equalto: "0",
      //高级查询 输入框数据
      QueryArray: {
        id: "",
        name: "",
        description: "",
        revisionValue: "",
        lcStatus: ""
      },
      //停用启用接收数组
      FlagObj: {},
      //修改对话框
      TreeEditFormVisible: false,
      //添加对话框
      TreeAddFormVisible: false,
      //当前点击项
      nodeClickList: "",
      ClonenodeClickList:"",
      //分类和主题库状态
      TreeFlag: false,
      //树加载
      loading: false,
      FormLoing: false,
      TreeAddform: {
        id: "",
        name: "",
        description: "",
        //相似查询规则
        codeResembleRuleOidName: "",
        //关键属性查询规则
        codekeyattrrepeatoidName: "",
        //编码规则
        coderuleoidName: "",
        //存储的业务类型
        btmtypename: ""
      },
      //avue-tree数据,暂时没有作用,里面功能用element写了,只用avue的一个树组件不用内置表单了。
      TreeAvueform: {},
      //克隆树
      CloneTreeAvueform:{},
      Treedata: [],
      CloneTreedata:[],
      Treeoption: {
        addBtn: false,
        editBtn: false,
        delBtn: false,
        defaultExpandAll: false,
        menu: false,
        // //这个是多选
        // multiple: true,
      },
      //模板管理form
      crudForm: "",
      //克隆模板form
      ClonecrudForm: "",
      //动态切换处理过的模板表格数据
      Formlist: [],
      //克隆模板数据
      CloneFormlist: [],
      //克隆模板下拉框value
      Clonevalue: "0",
      //克隆模板搜索输入框
      CloneFind:"",
      //克隆模板下拉框数据
      CloneSelectOptions: [{
        value: '0',
        label: '模板编号'
      },
        {
          value: '1',
          label: '模板名称'
        },
      ],
      //克隆模板确认表单数据
      CloneOption:{
        column:[
          {
            label:'模板编号',
            prop:'id',
            rules: [{
              required: true,
              message: "请输入模板编号",
              trigger: "blur"
            }]
          }, {
            label:'模板名称',
            prop:'name',
            rules: [{
              required: true,
              message: "请输入模板名称",
              trigger: "blur"
            }]
          },
          {
            label:'描述',
            prop:'desc',
            type:'textarea',
            span:24
          }
        ]
      },
      //克隆模板双向绑定数据
      CloneModel:[],
      CloneSelect:[],
      //克隆模板option
      ClonecrudTreeOption: {
        index: true,
        border: true,
        menu: false,
        addBtn: false,
        selection: true,
        header: false,
        height: 430,
        column: [
          {
            label: "模板编号",
            prop: "id"
          },
          {
            label: "模板名称",
            prop: "name",
          },
          {
            label: "模板描述",
            prop: "description"
          },
          {
            label: "版本号",
            prop: "revisionSeq",
            display: false
          },
          {
            label: "状态",
            prop: "lcStatusText",
            display: false
          }
        ]
      },
      //tab状态
      type: {},
      //Tab配置项
      tabOption: {
        column: [{
          label: '基本信息',
          prop: 'tab1',
        }, {
          label: '模板管理',
          prop: 'tab2',
        }]
      },
      //模拟表单假数据
      Treeform: [
        {
          name: "测试1",
          sex: "男",
          value: 0
        },
        {
          name: "测试2",
          sex: "女",
          value: 1
        }
      ],
      //传递给子组件动态渲染的数据
      TreeList: {},
      codeClassifyOid: ""
    }
  },
  //tab栏默认是表格
  mounted() {
    this.type = this.tabOption.column[0];
    this.getAttr();
  },
  computed:{
    crudTreeOption(){
      return{
        index: true,
        border: true,
        height:180,
        selection:true,
        addBtn:this.Formlist.length<=0  && this.nodeClickList != "",
        column: [
          {
            label: "模板编号",
            prop: "id"
          },
          {
            label:"模板名称",
            prop:"name"
          },
          {
            label: "模板描述",
            prop:"description"
          },
          {
            label:"版本号",
            prop:"revisionSeq",
            display:false
          },
          {
            label:"状态",
            prop:"lcStatusText",
            display:false
          }
        ]
      }
    }
  },
  methods: {
    MasterHandler(val){
      console.log('父亲',val)
      this.TreeList=val
    },
    //行单选事件
    selectHandle(selection,row){
      this.crudOid=row.oid;
      this.crudArray=selection;
      gridCodeClassifyTemplateAttr({'conditionMap[classifyTemplateOid]': this.Formlist[0].oid}).then(res => {
        this.ProData = res.data.data;
      }).catch(res => {
        this.$message.error(res)
      })
    },
    //分类树数据处理
    getAttr() {
      getAtrrList().then(res => {
        this.Treedata = res.data;
        this.CloneTreedata = res.data;
        this.Treedata.forEach(() => {
          for (let i = 0; i < this.Treedata.length; i++) {
            this.Treedata[i].value = i;
          }
        })
        //调用修改属性名方法
        this.ModifyProperties(this.CloneTreedata, 'name', 'label');
      }).catch(res => {
        this.$message.error(res)
      })
    },
    //定义一个修改数据属性名的方法
    ModifyProperties(obj, oldName, newName) {
      for (let key in obj) {
        if (key === oldName) {
          obj[newName] = obj[key];
          delete obj[key];
        }
        if (typeof obj[key] === 'object') {
          this.ModifyProperties(obj[key], oldName, newName);
        }
      }
    },
    //树节点添加按钮
    TreeAdd() {
      this.TreeAddFormVisible = true;
      // 判断当前是否有点击子项
      if (this.nodeClickList !== "") {
        this.TreeFlag = true
      }
    },
    //树节点添加事件
    TreeAddHandler() {
      const data = this.TreeAddform
      this.$set(data, "parentCodeClassifyOid", this.nodeClickList.oid)
      TreeSave(data).then(() => {
        this.$message({
          type: 'success',
          message: '添加成功!'
        });
        this.getAttr();
        this.TreeAddFormVisible = false
        this.TreeAddform = ""
      }).catch(res => {
        this.$message({
          type: 'warning',
          message: res
        });
      })
    },
    //树节点删除按钮
    TreeDel() {
      this.$confirm('是否删除当前选择的分类,将会把子分类一并删除,如果存在编码数据将不能被删除,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        customClass: 'my-messagebox',
      }).then(() => {
        TreeCheckDel(this.nodeClickList).then(res => {
          if (res.data.data) {
            TreeDel(this.nodeClickList).then(() => {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getAttr();
            }).catch(res => {
              this.$message({
                type: 'warning',
                message: res
              });
            })
          } else {
            this.$confirm('当前数据包含有下级数据,要删除的话会和下级数据一起删除,你确认继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning',
              customClass: 'my-messageboxs',
            }).then(() => {
              TreeDel(this.nodeClickList).then(() => {
                this.$message({
                  type: 'success',
                  message: '删除成功!'
                });
                this.getAttr();
              }).catch(res => {
                this.$message({
                  type: 'warning',
                  message: res
                });
              })
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消删除'
              });
            });
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    //修改回填
    TreeEdit() {
      if (this.nodeClickList == "") {
        this.$message({
          type: 'warning',
          message: '请先从树上选择一条数据!'
        });
      } else {
        this.TreeEditFormVisible = true;
      }
    },
    //树刷新
    flushed() {
      this.loading = true
      this.getAttr()
      setTimeout(() => {
        this.loading = false;
        this.nodeClickList = ""
      }, 600);
    },
    //启用和停用都先判断状态
    //启用
    Enable() {
      if (this.FlagObj.lcStatus == "Enabled") {
        this.$message({
          type: 'warning',
          message: '当前分类不是停用状态'
        });
      } else {
        this.$confirm('是否将子分类一并启用?', '提示', {
          confirmButtonText: '是',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          TreeEnable(this.nodeClickList).then(() => {
            this.$message({
              type: 'success',
              message: '启用成功!'
            });
            this.getAttr()
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消启用'
          });
        });
      }
    },
    //停用
    Deactivate() {
      if (this.FlagObj.lcStatus === "Disabled") {
        this.$message({
          type: 'warning',
          message: '当前分类不是启用状态!'
        });
      } else {
        this.$confirm('是否停用当前分类,停用后,子分类也将不能被使用,是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          TreeDeactivate(this.nodeClickList).then(() => {
            this.$message({
              type: 'success',
              message: '停用成功!'
            });
            this.nodeClickList['flag'] = true;
            this.getAttr()
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消停用'
          });
        });
      }
    },
    //树点击事件
    async nodeClick(data) {
      //定义一个模板属性id,数据是模板管理表格里面的oid
      this.nodeClickList = data
      this.ProData=[]
      try {
        await TreeObjcet(data.oid).then(res => {
          this.FlagObj = res.data.data
        }).catch(res => {
          this.$message.error(res)
        })
        //模板管理表格数据
        await gridCodeClassifyTemplate({'conditionMap[codeclassifyoid]': data.oid}).then(res => {
          this.Formlist = res.data.data.filter(item => {
            if (item.codeclassifyoid != "") {
              this.codeClassifyOid = item.codeclassifyoid
              return item.codeclassifyoid == this.nodeClickList.oid
            }
          })
        }).catch(res => {
          this.$message.error(res)
        })
        //  基本信息表单数据
        await getObjectByOid(this.nodeClickList.oid).then(res => {
          this.TreeList = res.data.data;
        }).catch(res => {
          this.$message.error(res)
        })
      } catch (error) {
        this.$message.error(error)
      }
    },
    //克隆模板树的点击切换数据
    async ClonenodeClick(data){
      this.ClonenodeClickList=data;
      await gridCodeClassifyTemplate({'conditionMap[codeclassifyoid]': data.oid}).then(res=>{
        this.CloneFormlist = res.data.data.filter(item => {
          if (item.codeclassifyoid != "") {
            this.codeClassifyOid = item.codeclassifyoid
            return item.codeclassifyoid == this.ClonenodeClickList.oid
          }
        })
      })
    },
    //tab栏切换
    handleChange(column) {
      this.type = column;
    },
    // //高级查询按钮
    // handleSelectChange(key) {
    //   const selectedValue = this.FindSelect[key];
    //   console.log(selectedValue)
    //   console.log(this.QueryArray[0])
    //   switch (this.FindSelect[key]) {
    //     case '0':
    //       this.QueryArray[key] = '';
    //       this.$set(this.QueryArray, key, '');
    //       // 如果选中的是模板编号,相应的输入框双向绑定关系为 QueryArray.id
    //       this.$set(this.QueryArray, 'id', this.QueryArray[key]);
    //       break;
    //     case '1':
    //       this.QueryArray[key] = '';
    //       this.$set(this.QueryArray, key, '');
    //       // 如果选中的是模板名称,相应的输入框双向绑定关系为 QueryArray.name
    //       this.$set(this.QueryArray, 'name', this.QueryArray[key]);
    //       break;
    //     case '2':
    //       this.QueryArray[key] = '';
    //       this.$set(this.QueryArray, key, '');
    //       // 如果选中的是模板描述,相应的输入框双向绑定关系为 QueryArray.description
    //       this.$set(this.QueryArray, 'description', this.QueryArray[key]);
    //       break;
    //     case '3':
    //       this.QueryArray[key] = '';
    //       this.$set(this.QueryArray, key, '');
    //       // 如果选中的是版本号,相应的输入框双向绑定关系为 QueryArray.revisionValue
    //       this.$set(this.QueryArray, 'revisionValue', this.QueryArray[key]);
    //       break;
    //     case '4':
    //       this.QueryArray[key] = '';
    //       this.$set(this.QueryArray, key, '');
    //       // 如果选中的是状态,相应的输入框双向绑定关系为 QueryArray.lcStatus
    //       this.$set(this.QueryArray, 'lcStatus', this.QueryArray[key]);
    //       break;
    //   }
    // },
    AdvQueries() {
      this.FindFormVisible = false
      //如果全部为空 allEmpty为true
      const allEmpty = Object.values(this.QueryArray).every(value => !value);
      //如果全部为空,点击查询出现所有数据
      if (allEmpty) {
        gridCodeClassifyTemplate().then(res => {
          this.Formlist = res.data.data
        })
      } else {
        //默认是等于
        gridCodeClassifyFindTemplate({'conditionMap[id]': this.QueryArray.id},
          {'conditionMap[name]': this.QueryArray.name},
          {'conditionMap[description]': this.QueryArray.description},
          {'conditionMap[revisionValue]': this.QueryArray.revisionValue},
          {'conditionMap[lcStatus]': this.QueryArray.lcStatus}
        ).then(res => {
          this.Formlist = res.data.data
        })
      }
    },
    //模板管理渲染
    CrudRend() {
      gridCodeClassifyTemplate({'conditionMap[codeclassifyoid]': this.nodeClickList.oid}).then(res => {
        this.Formlist = res.data.data
      })
    },
 
    //模板管理表格添加
    CrudRowSave(row,done) {
      if (this.nodeClickList.length <= 0) {
        this.$message({
          type: 'warning',
          message: '请先从树上选择一条数据!'
        });
      } else {
        this.$set(row, "codeclassifyoid", this.nodeClickList.oid)
        addSave(row).then(() => {
          this.$message({
            type: "success",
            message: "添加成功!"
          });
          done(row)
          this.CrudRend()
        }).catch(res => {
          this.$message({
            type: 'info',
            message: res
          });
        })
      }
      console.log('123',this.codeClassifyOid)
    },
    //模板管理修改
    CrudRowUpdata(row,index,done) {
      editSave(row).then(() => {
        this.CrudRend()
        this.$message({
          type: "success",
          message: "操作成功!"
        });
        done()
      }).catch(res => {
        this.$message.error(res)
      })
    },
    //模板管理删除
    CrudRowDel(row) {
      deleteData(row).then(()=> {
        this.CrudRend()
      }).catch(res => {
        this.$message({
          type: 'info',
          message: res
        });
      })
    },
    //模板管理表格查询,只有一条数据没必要做搜索
    /*nterFind() {
      if (this.findText == "") {
        gridCodeClassifyTemplate().then(res => {
          this.Formlist = res.data.data
        })
      } else {
        gridCodeClassifyTemplate().then(res => {
          this.Formlist = res.data.data.filter(item => {
            return item.name.includes(this.findText)
          })
        })
      }
    },*/
    //克隆模板查询
    CloneEnterFind(){
      gridCodeClassifyTemplate().then(res => {
        this.CloneFormlist = res.data.data.filter(item => {
          if(this.Clonevalue == 0){
            return item.id.includes(this.CloneFind)
          }else if(this.Clonevalue == 1){
            return item.name.includes(this.CloneFind)
          }
        })
      })
    },
    // 查询
    FindeHanler(){
      if(this.nodeClickList != ""){
        this.FindFormVisible=true
      }else {
        this.$message.warning('请从树上选择一条数据')
      }
    },
    //克隆模板选择确定
    Clonehandler(){
      if(this.CloneSelect.length <= 0){
        this.$message({
          type: 'warning',
          message: '请选择要克隆的模板!'
        });
      }else if(this.CloneSelect.length >1){
        this.$message({
          type: 'warning',
          message: '只能选择一条数据!'
        });
      } else {
        this.CloneinnerVisible=true;
 
      }
    },
    //点击从其它模板克隆
    CloneBtn(){
      if(this.nodeClickList.length <= 0){
        this.$message({
          type: 'warning',
          message: '请先从[主题库分类】树上选择一条数据!'
        });
      }else {
        this.CloneVisible=true;
      }
    },
    //克隆模板单选框改变
    selectionChange(row){
      this.CloneSelect=row;
      //双向绑定,提交表单输入框回填上当前选择的数据
      this.CloneModel.id=row[0].id;
      this.CloneModel.name=row[0].name;
      //这里有点绕,CloneSelect是我选择框选择的数据。等于this.nodeClickList.oid是因为,克隆模板传递数据要把当前选择树的oid传递给后端。而不是当前要克隆模板的oid
      this.CloneSelect[0].codeclassifyoid=this.nodeClickList.oid
    },
    //克隆表单提交
    Clonesubmit(row,done){
      //重新赋值CloneSelect传递的数据为输入框可以修改的数据,CloneModel提交表单输入框双向绑定数据
      this.CloneSelect[0].id=this.CloneModel.id;
      this.CloneSelect[0].name=this.CloneModel.name;
      copy(this.CloneSelect[0]).then(()=>{
        //因为是嵌套弹窗所以手动关闭CloneinnerVisible,CloneVisible两个弹窗。
        this.CloneinnerVisible=false
        this.CloneVisible=false
        this.$message.success("复制成功")
        this.CrudRend()
        done(row)
      }).catch(res=>{
        done(res)
      })
    },
    //刷新
    TemRefresh() {
      this.FormLoing = true
      if (this.nodeClickList.oid != "") {
        gridCodeClassifyTemplate({'conditionMap[codeclassifyoid]': this.nodeClickList.oid}).then(res => {
          this.Formlist = res.data.data.filter(item => {
            return item.codeclassifyoid == this.nodeClickList.oid
          })
        })
      } else {
        this.FormLoing = true
      }
      setTimeout(() => {
        this.FormLoing = false
      }, 600);
    },
  }
}
</script>
 
<style lang="scss" scoped>
.el-form {
  display: flex;
  flex-wrap: wrap; /* 设置可换行,以便在小屏幕设备上使用多行布局 */
}
 
.el-form-item {
  flex: 1; /* 设置元素占据1份空间 */
  margin-right: 1rem; /* 设置元素之间的间距 */
}
 
.my-messagebox {
  width: 700px;
}
 
.my-messageboxs {
  width: 500px;
}
 
</style>