Fixiaobai
2023-11-14 21d976db1dcdf9ea4b6c300c159a654a7cd62b63
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
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
<template>
  <div class="avue-crud" style="width: 100%">
    <div class="grid-header" v-if="isShow('toolbar')" style="margin: 0px 20px">
      <div style="display:flex;margin-bottom:15px;">
        <div
          v-for="(searchItem, index) in searchList"
          :key="index"
          style="margin-left:20px;"
        >
          <div style="display:flex;" v-if="searchItem.type == 'text'">
            <div
              style="font-weight:bold;font-size:15px;line-height:28px;margin-right:8px;"
            >
              {{ searchItem.text }}
            </div>
            <div>
              <el-input
                v-model="searchItem.value"
                size="mini"
                style="width:100%"
                clearable
              />
            </div>
          </div>
          <div style="display:flex;" v-if="searchItem.type == 'customSelect'">
            <div
              style="font-weight:bold;font-size:15px;line-height:28px;margin-right:8px;"
            >
              {{ searchItem.text }}
            </div>
            <div>
              <el-select
                v-model="searchItem.value"
                placeholder="请选择"
                filterable
                clearable
                size="mini"
                @change="searchItem.changeFun"
              >
                <el-option
                  v-for="item in searchItem.searchOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                  <span style="float: left">{{ item.name }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{
                    item.desc
                  }}</span>
                </el-option>
              </el-select>
            </div>
          </div>
          <div style="display:flex;" v-if="searchItem.type == 'normalSelect'">
            <div
              style="font-weight:bold;font-size:15px;line-height:28px;margin-right:8px;"
            >
              {{ searchItem.text }}
            </div>
            <div>
              <el-select
                v-model="searchItem.value"
                placeholder="请选择"
                filterable
                clearable
                size="mini"
                @change="searchItem.changeFun"
              >
                <el-option
                  v-for="item in searchItem.searchOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
          </div>
          <div style="display:flex;" v-if="searchItem.type == 'select'">
            <div
              style="font-weight:bold;font-size:15px;line-height:28px;margin-right:8px;"
            >
              {{ searchItem.text }}
            </div>
            <div>
              <el-select
                v-model="searchItem.value"
                placeholder="请选择"
                filterable
                remote
                size="mini"
                :remote-method="searchItem.remoteFun"
                @change="searchItem.changeFun"
              >
                <el-option
                  v-for="item in searchItem.searchOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
          </div>
        </div>
      </div>
      <el-form :inline="true" @submit.native.prevent>
        <el-form-item class="btn-group">
          <el-button
            v-for="(item, index) in getToolBarBtn"
            :key="index"
            @click="toolBarFun(item)"
            :icon="item.icon"
            :type="item.type"
            :size="item.size || 'small'"
            :plain="item.plain"
            :disabled="item.disabled"
            :loading="item.loading"
            :class="item.cls"
            v-show="item.barShow"
            >{{ item.text }}
          </el-button>
        </el-form-item>
        <el-form-item class="btn-custom">
          <slot name="toolbar"></slot>
        </el-form-item>
        <!--刷新和显隐以及高级搜索-->
        <el-form-item class="fr" style="margin-right:0">
          <el-tooltip content="刷新" placement="top" v-if="options.isRefresh">
            <el-button
              circle
              icon="fab fa-refresh"
              @click="refreshData()"
              class="icon-btn"
            ></el-button>
          </el-tooltip>
          <el-tooltip
            content="自定义列"
            placement="top"
            v-if="options.isShowHide"
          >
            <el-button
              circle
              icon="fab fa-table"
              @click="chooseCol()"
              class="icon-btn"
            ></el-button>
          </el-tooltip>
          <el-tooltip content="导出" placement="top" v-if="table.isExport">
            <!-- jipf 新增导出 以复用 -->
            <el-button
              circle
              icon="el-icon-download"
              @click="exportPage()"
              style="font-size: 15px;border: 0px solid #DCDFE6"
            ></el-button>
          </el-tooltip>
        </el-form-item>
      </el-form>
    </div>
    <div class="title-division"></div>
    <div class="custom-table-div" style="margin: 20px 20px 0px">
      <el-table
        ref="customTable"
        :size="tableSize"
        :key="tableKey"
        :data="tableData"
        :stripe="options.stripe"
        :border="options.border"
        :fit="options.fit"
        :lazy="options.lazy"
        :show-summary="options.showSummary"
        :summary-method="options.getSummaries"
        v-bind="$attrs"
        v-on="$listeners"
        @selection-change="handleSelectionChange"
        :span-method="objectSpanMethod"
        :header-cell-style="tableHeaderStyle"
        v-adaptive="{ bottomOffset: bottomOffset, fixedHeight: fixedHeight }"
        height="100px"
        :class="['customTable']"
        v-loading="dataListLoading"
        element-loading-text="加载中..."
        element-loading-spinner="el-icon-loading"
      >
        <!--多选择框-->
        <el-table-column
          align="center"
          type="selection"
          v-if="options.multiSelect"
          style="width: 55px;"
        >
        </el-table-column>
        <!--序号-->
        <el-table-column
          v-if="options.seqNo"
          type="index"
          label="序号"
          :fixed="options.seqNoFix"
        >
        </el-table-column>
        <!-- 默认渲染列 -->
        <el-table-column
          v-for="(item, index) in columnList"
          :key="index"
          :label="item.label"
          :align="item.align || 'center'"
          :show-overflow-tooltip="!item.noShowTip"
          :width="inMemoryColWidth[item.prop] || item.width"
          :prop="item.prop"
          v-bind="$attrs"
          v-on="$listeners"
          v-if="item.isTrue"
        >
          <template slot="header" slot-scope="scope">
            <template v-if="item.isSearch">
              <div class="th" @click.stop>
                <div>{{ item.label }}</div>
                <template
                  v-if="
                    ['text', 'textarea', 'number', 'email'].indexOf(
                      item.searchInfoType
                    ) !== -1
                  "
                >
                  <el-input
                    v-model="queryParam[item.prop]"
                    @keyup.enter.native="handlesFirstPage"
                    clearable
                    @clear="handlesFirstPage"
                    size="mini"
                  ></el-input>
                </template>
                <template v-if="item.searchInfoType === 'select'">
                  <el-select
                    v-model="queryParam[item.prop]"
                    @change="handlesFirstPage"
                    clearable
                    filterable
                    size="mini"
                  >
                    <el-option
                      v-for="(j, k) in item.optList()"
                      :key="k"
                      :label="j.label"
                      :value="j.value"
                    ></el-option>
                  </el-select>
                </template>
              </div>
            </template>
            <template v-else>
              <div class="th" @click.stop>{{ item.label }}</div>
            </template>
          </template>
          <template slot-scope="scope">
            <template v-if="item.isEdit && scope.row.isRowEdit">
              <template v-if="item.editInfoType === 'text'">
                <el-input
                  v-model="scope.row[item.prop]"
                  size="mini"
                  style="width:100%"
                  @blur="fieldInputEnter(item.prop, scope.row)"
                />
              </template>
              <template v-if="item.editInfoType === 'select'">
                <el-select
                  v-model="scope.row[item.prop]"
                  placeholder=""
                  clearable
                  filterable
                  size="mini"
                >
                  <el-option
                    v-for="(j, k) in item.editOptList()"
                    :key="k"
                    :label="j.label"
                    :value="j.value"
                  ></el-option>
                </el-select>
              </template>
            </template>
            <template v-else>
              <template v-if="item.formatter">
                <span
                  v-html="item.formatter(scope.row, item, scope.row[item.prop])"
                ></span>
              </template>
              <template v-if="!item.formatter">
                <template v-if="item.isSplitCell">
                  <div
                    v-if="
                      scope.row[item.prop] != null && scope.row[item.prop] != ''
                    "
                  >
                    <div
                      v-for="(eleVal, index) in scope.row[item.prop].split(',')"
                      :key="index"
                    >
                      <div
                        v-if="
                          index < scope.row[item.prop].split(',').length - 1
                        "
                        style="border-bottom:1px solid #EBEEF5"
                      >
                        {{ eleVal }}
                      </div>
                      <div v-else>
                        {{ eleVal }}
                      </div>
                    </div>
                  </div>
                </template>
                <template v-else>
                  <span>{{ scope.row[item.prop] }}</span>
                </template>
              </template>
            </template>
          </template>
        </el-table-column>
        <el-table-column
          v-if="table.operator"
          :label="
            (table.operatorConfig && table.operatorConfig.label) || '操作'
          "
          :width="table.operatorConfig && table.operatorConfig.width"
          :min-width="
            (table.operatorConfig && table.operatorConfig.width) ||
              table.operatorConfig.minWidth ||
              100
          "
          align="center"
          fixed="right"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <el-button
              v-for="(item, index) in table.operator"
              :key="index"
              @click.stop="item.fun(scope.row)"
              :type="item.type || 'text'"
              :icon="item.icon"
              :size="item.size || 'small'"
              :disabled="!checkIsShow(scope, item)"
              class="customButton"
              >{{ item.text }}
            </el-button>
            <!-- jipf 自定义操作 -->
            <slot name="customize" v-bind:invnotice="scope.row"></slot>
          </template>
        </el-table-column>
        <slot name="end"></slot>
      </el-table>
    </div>
    <div
      class="avue-crud__pagination"
      style="margin-bottom: 0px;margin-top:0px;padding:5px 20px;"
    >
      <el-pagination
        v-show="tableData && tableData.length && isShowPagination"
        :current-page="pagination.currentPage"
        @current-change="handlesCurrentChange"
        @size-change="sizeChangeHandle"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pagination.pageSize"
        :layout="
          size
            ? 'total, prev, pager, next'
            : 'total, sizes, prev, pager, next, jumper'
        "
        :total="pagination.total"
        v-bind="$attrs"
        v-on="$listeners"
        background
      ></el-pagination>
    </div>
    <!--原有显隐-->
    <el-dialog
      title="多选"
      :visible.sync="colSelectDialogVisible"
      width="30%"
      center
      append-to-body
    >
      <span>
        <el-checkbox
          :value="columnList.length === colSelect.length"
          @change="handleCheckedColAll"
        >
          全选</el-checkbox
        >
        <div style="margin: 15px 0;"></div>
        <el-checkbox-group v-model="colSelect" @change="handleCheckedColChange">
          <zttdraggable :list="columnList" @end="onDragEnd">
            <transition-group>
              <el-checkbox
                v-for="(item, i) in columnList"
                :label="item.prop"
                :key="i"
                class="ztt-drag-block-checkbox"
              >
                <span style="font-size:14px;">{{ item.label }}</span>
                <i
                  style="margin-left:5px;"
                  class="icon aufontAll  h-icon-all-drag"
                ></i>
              </el-checkbox>
            </transition-group>
          </zttdraggable>
        </el-checkbox-group>
      </span>
    </el-dialog>
 
    <!-- 导出modal jipf -->
    <el-dialog
      title="导出"
      :visible.sync="exportDialogVisible"
      width="30%"
      center
    >
      <span>
        <el-checkbox
          :indeterminate="isIndeterminate_export"
          v-model="checkAll_export"
          @change="handleCheckAllChange_export"
        >
          全选
        </el-checkbox>
        <div style="margin: 15px 0;"></div>
        <el-checkbox-group
          v-model="checkedExportColumnLabels"
          @change="handleCheckedColumnsChange_export"
        >
          <el-checkbox
            v-for="(item, i) in eColumnLabels"
            :label="item"
            :key="i"
          >
            {{ item }}
          </el-checkbox>
        </el-checkbox-group>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="exportDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="startExport()">确认</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import qs from 'qs' // jipf
import { getStore } from '@/util/store.js'
import adaptive from '@/util/adaptive'
import zttdraggable from 'vuedraggable'
 
export default {
  name: 'TTable',
  components: { zttdraggable },
  props: {
    // 表格型号:mini,medium,small
    tableSize: { type: String, default: 'small' },
    // 数据请求方法
    ajaxFun: { type: Function },
    // 请求参数数组
    paramArr: {
      type: Array,
      default: () => {
        return []
      }
    },
    // 请求参数对象
    paramObj: {
      type: Object,
      default: () => {
        return {}
      }
    },
    // table所需数据
    table: {
      type: Object,
      default: () => {
        return {}
      },
      required: true
    },
    prelang: {
      type: String
    },
    // 是否固定高度
    height: {
      type: Boolean,
      default: true
    },
    // 是否需要固定表头
    fixHeight: {
      type: String || Number,
      default: ''
    },
    // 是否需要显示切换页条数
    size: {
      type: Boolean,
      default: false
    },
    // 是否显示分页
    isShowPagination: {
      type: Boolean,
      default: true
    },
 
    options: {
      type: Object,
      default: {
        height: 300, // 默认高度-为了表头固定
        stripe: false, // 是否为斑马纹 table
        highlightCurrentRow: false, // 是否要高亮当前行
        border: false, // 是否有纵向边框
        lazy: false, // 是否需要懒加载
        fit: true, // 列的宽度是否自撑开
        multiSelect: true, // 选择
        seqNo: true, // 序号
        seqNoFix: false,
        isRefresh: false, // 是否显示刷新按钮
        isShowHide: false, // 是否显示显影按钮
        isSearch: false, // 高级查询按钮
        isCopy: false,
        showSummary: false,
        IsCurrRow: false,
        defaultOrderBy: {}, // 默认排序规则
        tableCellMerge: false,
        cancelRunCreated: false, // 是否执行created()内容
        isRowEdit: false // 数据行是否可编辑
      }
    },
    // table自适应高度底部高度
    bottomOffset: {
      type: Number,
      default: 65
    },
    fixedHeight: {
      type: Number,
      default: 0
    },
    searchList: {
      type: Array,
      default: () => {
        return []
      }
    },
    mergeCols: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      dataListLoading: false,
      tableKey: 0,
      // jipf  导出所用变量
      exportDialogVisible: false, // modal 显隐控制
      isIndeterminate_export: true, // 控制导出是否全选
      checkAll_export: true, // 导出列全选
      checkedExportColumnLabels: [], // 勾选的导出变量
      eColumnLabels: [], // 显示的导出变量
      //
      otherHeight: 0,
      rowData: '',
      colSelect: [], // 选择的列
      // 是否展示显隐
      colSelectDialogVisible: false,
      fileList: [], // 上传文件列表
      // 上传头信息
      headers: {
        Authorization: 'Bearer ' + getStore({ name: 'access_token' })
      },
      multipleSelection: [], // 多行选中
      isCleanInfo: false, // 是否展示清除
      queryParam: {}, // 快速查询对象
      orderBy: null, // 排序规则
      dateTimeFilters: {}, // 时间过滤字段
      multiSearchFilter: {}, // 高级搜索字段
      tableData: [], // 表格数据
      pagination: {
        currentPage:
          this.table.currentPage == null ? 1 : this.table.currentPage,
        pageSize: this.table.pageSize == null ? 20 : this.table.pageSize,
        total: this.table.total == null ? 0 : this.table.total
      }, // 分页信息
      inMemoryColWidth: {}, // 记忆中列宽,默认列宽
      currPath: null, // 获取当前窗口路由路径
      mergeRowColSplitObj: {}
    }
  },
  computed: {
    // 需要展示的列 === prop:列数据对应的属性,label:列名,align:对齐方式,width:列宽
    columnList() {
      const orderColumns = JSON.parse(
        localStorage.getItem(this.currPath + '_custom_column') || '[]'
      )
      const columns = this.table.column.filter((item) => {
        return !item.noShowColumn
      })
      const colList = []
      for (let i = 0; i < orderColumns.length; i++) {
        const exist = columns.find((item) => item.prop === orderColumns[i].prop)
        if (exist === undefined) {
        } else {
          exist.isTrue = orderColumns[i].isTrue
          colList.push(exist)
        }
      }
      for (let j = 0; j < columns.length; j++) {
        const exist = colList.find((item) => item.prop === columns[j].prop)
        if (exist === undefined) {
          colList.push(columns[j])
        }
      }
      return colList
    },
    getToolBarBtn() {
      return this.table.toolbar ? this.table.toolbar.slice(0, 8) : []
    }
  },
  mounted() {
    const toolBarHeight = this.isShow('toolbar') ? 60 : 0
    const pageHeight = 60
    this.$nextTick(() => {
      this.otherHeight = toolBarHeight + pageHeight + 30
    })
 
    this.handleCheckedColAllExport(true)
    // 获取ztt-table在父元素中的ref
    const defaultSlots = this.$parent.$slots.default
    // 有bug,参照工作台产出记录页面列表
    if (defaultSlots != undefined) {
      let parentRef
      for (let i = 0; i < defaultSlots.length; i++) {
        if (
          defaultSlots[i].child != undefined &&
          defaultSlots[i].child.$refs.customTable != undefined
        ) {
          parentRef = defaultSlots[i].data.ref
          break
        }
      }
      // 获取当前窗口路由路径,并与父ref拼接
      this.currPath = this.$route.path + '_' + parentRef
      // 初始化记忆中列宽
      this.initColWidth()
    }
  },
  watch: {
    queryParam: {
      handler(newValue, oldValue) {
        if (JSON.stringify(newValue) === '{}') {
          this.isCleanInfo = false
        } else {
          var bl = 0
          for (var i in newValue) {
            if (
              newValue[i] == '' ||
              newValue[i] == null ||
              newValue == undefined
            ) {
              ++bl
            }
          }
          if (bl == Object.keys(newValue).length) {
            this.isCleanInfo = false
          } else {
            this.isCleanInfo = true
          }
        }
      },
      deep: true
    },
    table(val) {
      this.doLayout()
    }
  },
  directives: {
    adaptive
  },
  created() {
    if (!this.options.cancelRunCreated) {
      this.getDataList()
    }
  },
  updated() {
    this.$nextTick(() => {
      this.$refs.customTable.doLayout()
    })
  },
  methods: {
    fieldInputEnter(prop, row) {
      console.log('sadasdasdsa')
      this.$emit('inputEnterEvent', { prop: prop, row: row })
    },
    onDragEnd() {
      this.$forceUpdate()
      const currPathColumnOrder = this.currPath + '_custom_column'
      localStorage.setItem(currPathColumnOrder, JSON.stringify(this.columnList))
    },
    initColWidth() {
      this.inMemoryColWidth = JSON.parse(
        localStorage.getItem(this.currPath) || '{}'
      )
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (this.options.tableCellMerge) {
        let result = ''
        this.$emit(
          'objectSpanMethod',
          row,
          column,
          rowIndex,
          columnIndex,
          (val) => {
            if (val) {
              result = val
            }
          },
          this.mergeRowColSplitObj
        )
        if (result) {
          return result
        }
      }
    },
    getDataList() {
      this.dataListLoading = true
      var criteria = {}
      criteria.dateTimeFilters = this.dateTimeFilters
      criteria.multiSearchFilter = this.multiSearchFilter
      criteria.orderBy =
        this.orderBy == null ? this.options.defaultOrderBy : this.orderBy
      var arr = new Array()
      arr.push(
        Object.assign(
          {
            current: this.pagination.currentPage,
            size: this.pagination.pageSize,
            criteria: JSON.stringify(criteria)
          },
          this.queryParam,
          this.paramObj
        )
      )
      if (this.paramArr != null && this.paramArr.length > 0) {
        for (var i = 0; i < this.paramArr.length; i++) {
          arr.push(this.paramArr[i])
        }
      }
 
      return this.doCallback(this.ajaxFun, arr)
    },
    doCallback(fn, args) {
      return fn
        .apply(this, args)
        .then((response) => {
          var _this = this
          _this.tableData = response.data.data.records
          _this.pagination.total = response.data.data.total
          // 置空选中
          this.$refs.customTable.setCurrentRow()
          // 增加行是否可编辑
          _this.tableData.forEach((item) => {
            _this.$set(item, 'isRowEdit', this.options.isRowEdit)
            if (_this.options.showCol) {
              _this.$set(item, _this.options.showCol, '')
            }
          })
          if (_this.options.tableCellMerge) {
            _this.mergeRowColSplitObj = {}
            let mergeCol
            for (let i = 0; i < _this.mergeCols.length; i++) {
              mergeCol = _this.mergeCols[i]
              _this.tableData.forEach((ele, index) => {
                if (_this.mergeRowColSplitObj[mergeCol]) {
                  const rowColSplitNodes =
                    _this.mergeRowColSplitObj[mergeCol].rowColSplitNodes
                  const lastRowColSplitNode =
                    rowColSplitNodes[rowColSplitNodes.length - 1]
                  if (lastRowColSplitNode.key == ele[mergeCol]) {
                    lastRowColSplitNode.num = lastRowColSplitNode.num + 1
                  } else {
                    rowColSplitNodes.push({
                      key: ele[mergeCol],
                      node: index,
                      num: 1
                    })
                  }
                } else {
                  _this.$set(_this.mergeRowColSplitObj, mergeCol, {
                    rowColSplitNodes: [
                      { key: ele[mergeCol], node: index, num: 1 }
                    ]
                  })
                }
              })
            }
          }
 
          _this.dataListLoading = false
        })
        .catch((error) => {
          this.dataListLoading = false
        })
    },
    // jipf 导出方法
    exportPage() {
      // modal开关
      this.exportDialogVisible = true
    },
    handleCheckedColAllExport(val) {
      // this.colChecked = [];
      for (var i = 0; i < this.columnList.length; i++) {
        if (val) {
          // this.colChecked[i] = this.tableColumns[i].prop;
          this.eColumnLabels[i] = this.columnList[i].prop
        }
        //  this.columnList[i].isTrue = val;
      }
      if (val) {
        this.checkedExportColumnLabels = this.eColumnLabels
      }
    },
    handleCheckAllChange_export(val) {
      this.checkedExportColumnLabels = val ? this.eColumnLabels : []
      this.isIndeterminate_export = false
    },
    handleCheckedColumnsChange_export(value) {
      this.checkedExportColumnLabels = value
      const checkedCount = value.length
      this.checkAll_export = checkedCount === this.columnLabels.length
      this.isIndeterminate_export =
        checkedCount > 0 && checkedCount < this.eColumnLabels.length
    },
 
    startExport() {
      // 实际导出方法
      this.exportDialogVisible = false
      var param = this.queryParam
      param.fieldNames = this.checkedExportColumnLabels
      var param2 = qs.stringify(param, {
        allowDots: true,
        arrayFormat: 'repeat'
      })
      this.table.exportFun(param2).then((res) => {
        const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' })
        const disposition = res.headers['content-disposition']
        const temp = disposition.substring(
          disposition.lastIndexOf('filename=') + 10,
          disposition.lastIndexOf('"')
        )
        const iconv = require('iconv-lite')
        iconv.skipDecodeWarning = true // 忽略警告
        const filename = iconv.decode(temp, 'utf-8')
        // 创建一个超链接,将文件流赋进去,然后实现这个超链接的单击事件
        const elink = document.createElement('a')
        elink.download = filename
        elink.style.display = 'none'
        elink.href = URL.createObjectURL(blob)
        document.body.appendChild(elink)
        elink.click()
        URL.revokeObjectURL(elink.href) // 释放URL 对象
        document.body.removeChild(elink)
      })
    },
 
    //
    // 是否显示表格操作按钮
    checkIsShow(scope, item) {
      let isNoShow = false
      if (item.noshow) {
        item.noshow.map((rs) => {
          rs.isShow =
            typeof rs.val === 'string'
              ? rs.val === 'isHadVal'
                ? scope.row[rs.key]
                  ? 'true'
                  : 'false'
                : 'true'
              : rs.val.includes(scope.row[rs.key])
              ? 'false'
              : 'true'
        })
        isNoShow = item.noshow.every((key) => {
          return key.isShow === 'true'
        })
      } else {
        isNoShow = true
      }
      return (
        (!item.show || item.show.val.includes(scope.row[item.show.key])) &&
        isNoShow
      )
    },
    // 在第一页刷新列表数据
    handlesFirstPage() {
      this.pagination.currentPage = 1
      this.getDataList()
    },
    // 当前页码
    handlesCurrentChange(val) {
      this.pagination.currentPage = val
      this.getDataList()
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pagination.pageSize = val
      this.pagination.currentPage = 1
      this.getDataList()
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
      this.$emit('handleSelectionChange', val)
    },
    tableHeaderStyle(row, column, rowIndex, columnIndex) {
      return `background:#fff;color:#666`
    },
    // 表格头部按钮
    toolBarFun(item) {
      item.fun()
    },
    isShow(name) {
      return Object.keys(this.$slots).includes(name)
    },
    // 初始化显示列-显隐
    handleCheckedCol() {
      this.colSelect = []
      for (var i = 0; i < this.columnList.length; i++) {
        if (this.columnList[i].isTrue) {
          this.colSelect.push(this.columnList[i].prop)
        }
      }
    },
    // 显示列全选-显隐
    handleCheckedColAll(val) {
      this.colSelect = []
      for (var i = 0; i < this.columnList.length; i++) {
        if (val) {
          this.colSelect[i] = this.columnList[i].prop
          // this.eColumnLabels[i] = this.columnList[i].prop;
        }
        this.columnList[i].isTrue = val
      }
      this.tableKey = Math.random()
      const currPathColumnOrder = this.currPath + '_custom_column'
      localStorage.setItem(currPathColumnOrder, JSON.stringify(this.columnList))
    },
    // 选中显示列变化-显隐
    handleCheckedColChange(value) {
      for (var i = 0; i < this.columnList.length; i++) {
        this.columnList[i].isTrue = false
        for (var j = 0; j < this.colSelect.length; j++) {
          if (this.columnList[i].prop === this.colSelect[j]) {
            this.columnList[i].isTrue = true
            // this.$set(this.columnList[i],'isTrue',true);
          }
        }
      }
      this.tableKey = Math.random()
      // this.$forceUpdate();
      const currPathColumnOrder = this.currPath + '_custom_column'
      localStorage.setItem(currPathColumnOrder, JSON.stringify(this.columnList))
    },
    refreshData() {
      // this.$refs.customTable.setCurrentRow()
      this.getDataList()
    },
 
    chooseCol() {
      this.colSelectDialogVisible = true
      this.handleCheckedCol()
    },
    // 查询条件
    getQueryParam() {
      var criteria = {}
      criteria.dateTimeFilters = this.dateTimeFilters
      criteria.multiSearchFilter = this.multiSearchFilter
      criteria.orderBy =
        this.orderBy == null ? this.options.defaultOrderBy : this.orderBy
      return Object.assign(
        {
          current: this.pagination.currentPage,
          size: this.pagination.pageSize,
          criteria: JSON.stringify(criteria)
        },
        this.queryParam,
        this.paramObj
      )
    },
    getTableData() {
      return this.tableData
    },
    doLayout() {
      this.$nextTick(() => {
        this.$refs.customTable && this.$refs.customTable.doLayout()
      })
    }
  }
}
</script>
<style>
.customTable * {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}
 
.customTable th {
  text-align: center;
}
 
.customTable th div {
  display: block;
}
 
.customTable tr td:first-child {
  text-align: center;
}
 
.customTable tr td:nth-child(2) {
  text-align: center;
}
 
.el-table th div.th {
  display: inline-flex;
  flex-direction: column;
  vertical-align: bottom;
  line-height: 28px;
  padding: 0;
  width: calc(100% - 24px);
}
 
.el-table th div.th > label {
  padding-left: 3px;
}
 
.el-table th div.th .el-input,
.el-table th div.th .el-select {
  line-height: inherit;
  padding: 0;
}
 
.el-table .caret-wrapper {
  margin-bottom: -3px;
}
 
.fr {
  float: right;
}
 
.customTable td {
  padding: 1px 0 0 0;
}
 
.customTable th {
  padding: 5px 0;
}
 
.customTable .el-table__header .cell {
  padding: 0 !important;
  text-overflow: unset !important;
  white-space: nowrap !important;
}
 
.customTable .el-table__body .cell {
  line-height: 30px !important;
}
 
.customButton {
  padding: 0px;
}
 
.el-table tbody tr:hover > td {
  background-color: #d6eaf8 !important;
}
 
/*隐藏搜索框、并实现动画效果*/
.ext-table-display thead tr:nth-child(2) {
  display: none;
}
 
.ext-table .el-table__fixed-right .el-table__fixed-body-wrapper {
  top: 42px !important;
}
 
.ext-table-class .el-table__fixed-right .el-table__fixed-body-wrapper {
  top: 82px !important;
}
 
.btn-group .el-button,
.btn-custom .el-button {
  border-radius: 0;
  padding: 9px 30px;
}
 
.btn-group .el-dropdown .el-button {
  border-radius: 0;
  padding: 9px 20px;
}
 
.custom-table-btn.el-button--default {
  color: #333;
}
 
.customTable .el-table__fixed-right .el-table__fixed-body-wrapper {
  top: 82px;
}
 
.fab {
  display: inline-block;
  font: normal normal normal 14px/1 iconfont;
  color: #566573;
  font-size: 14px;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
}
 
.icon-btn {
  border: 0px solid #dcdfe6;
}
 
.customButton.is-disabled {
  color: #aacfff;
}
 
/*自定义disabled状态下checkbox的样式*/
.table-single-checkbox
  .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner {
  background-color: #006eff;
  border-color: #006eff;
}
.table-single-checkbox .el-checkbox__input.is-disabled .el-checkbox__inner {
  background-color: #ffffff;
  cursor: pointer;
}
.table-single-checkbox .el-checkbox__inner::after {
  border: 1px solid #fff !important;
  border-left: 0 !important;
  border-top: 0 !important;
  cursor: pointer !important;
}
 
/*默认已选中行,checkbox样式,多选*/
.is-selected-row .el-table-column--selection .el-checkbox .el-checkbox__inner {
  background-color: #aacfff;
  border-color: #aacfff;
}
 
.el-table .warning-row {
  background: #ffc;
}
.el-table .success-row {
  background: #d1f5d1;
}
.el-table .danger-row {
  background: #ffdbd9;
}
.el-table .danger-light-row {
  background: rgba(255, 228, 225, 0.5);
}
 
.customTable .cell.el-tooltip .el-link {
  display: inline;
}
 
.ztt-drag-block-checkbox {
  padding: 3px;
}
.ztt-drag-block-checkbox .el-checkbox__label {
  line-height: 16px;
}
.ztt-drag-block-checkbox:hover {
  background: #f0f7ff;
  cursor: move;
}
 
.ztt-drag-block-checkbox:hover .icon {
  display: block;
}
 
.ztt-drag-block-checkbox .icon {
  color: rgba(0, 0, 0, 0.45);
  font-size: 12px;
  line-height: 16px;
  float: right;
  display: none;
}
 
.aufontAll {
  font-family: aufontAll !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
 
.h-icon-all-drag {
  background: url('/img/tz.png') center center no-repeat;
  background-size: cover;
  font-size: 14px;
}
.h-icon-all-drag:before {
  content: '\E63E';
  font-size: 14px;
  visibility: hidden;
}
</style>