centaline-data-driven 1.1.54 → 1.1.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/.babelrc +12 -12
  2. package/.editorconfig +9 -9
  3. package/.gitattributes +63 -63
  4. package/.postcssrc.js +10 -10
  5. package/Centaline.Front_End.DataDriven.csproj +37 -37
  6. package/Centaline.Front_End.DataDriven.sln +25 -25
  7. package/Properties/launchSettings.json +26 -26
  8. package/README.md +140 -140
  9. package/build/build.js +41 -41
  10. package/build/centaline/centaline.path.js +59 -59
  11. package/build/centaline/webpack.centaline.conf.js +106 -106
  12. package/build/check-versions.js +54 -54
  13. package/build/utils.js +102 -102
  14. package/build/vue-loader.conf.js +22 -22
  15. package/build/webpack.base.conf.js +82 -82
  16. package/build/webpack.dev.conf.js +111 -111
  17. package/build/webpack.prod.conf.js +145 -145
  18. package/config/dev.env.js +12 -12
  19. package/config/index.js +73 -73
  20. package/config/prod.env.js +4 -4
  21. package/index.html +14 -14
  22. package/package.json +75 -75
  23. package/src/App.vue +10 -10
  24. package/src/Detail.vue +26 -26
  25. package/src/Edit.vue +32 -32
  26. package/src/Form.vue +29 -29
  27. package/src/SearchList.vue +40 -40
  28. package/src/SearchTree.vue +51 -51
  29. package/src/Tabs.vue +19 -19
  30. package/src/centaline/api/index.js +249 -249
  31. package/src/centaline/comfirm/index.js +11 -11
  32. package/src/centaline/comfirm/src/comfirm.vue +44 -44
  33. package/src/centaline/common/index.js +738 -738
  34. package/src/centaline/css/common.css +748 -748
  35. package/src/centaline/css/max.css +207 -207
  36. package/src/centaline/dialogList/index.js +11 -11
  37. package/src/centaline/dialogList/src/dialog.vue +210 -210
  38. package/src/centaline/dialogList/src/dialogList.vue +65 -65
  39. package/src/centaline/dialogList/src/dialogNew.vue +78 -78
  40. package/src/centaline/dialogList/src/drag.js +77 -77
  41. package/src/centaline/directives/index.js +23 -23
  42. package/src/centaline/dynamicBtn/index.js +11 -11
  43. package/src/centaline/dynamicBtn/src/dynamicBtn.vue +100 -100
  44. package/src/centaline/dynamicCb/index.js +11 -11
  45. package/src/centaline/dynamicCb/src/dynamicCb.vue +72 -72
  46. package/src/centaline/dynamicCheckbox/index.js +11 -11
  47. package/src/centaline/dynamicCheckbox/src/dynamicCheckbox.vue +128 -128
  48. package/src/centaline/dynamicComboBoxWithTextBox/index.js +11 -11
  49. package/src/centaline/dynamicComboBoxWithTextBox/src/dynamicComboBoxWithTextBox.vue +240 -240
  50. package/src/centaline/dynamicD/index.js +11 -11
  51. package/src/centaline/dynamicD/src/dynamicD.vue +92 -92
  52. package/src/centaline/dynamicDetail/index.js +10 -10
  53. package/src/centaline/dynamicDetail/src/dynamicDetail.vue +40 -40
  54. package/src/centaline/dynamicDetail/src/dynamicPropertyDetailOFI.vue +1280 -1280
  55. package/src/centaline/dynamicDetail/src/dynamicPropertyDetailRET.vue +1293 -1293
  56. package/src/centaline/dynamicDrop/index.js +11 -11
  57. package/src/centaline/dynamicDrop/src/dynamicDrop.vue +54 -54
  58. package/src/centaline/dynamicDtd/index.js +11 -11
  59. package/src/centaline/dynamicDtd/src/dynamicDtd.vue +125 -125
  60. package/src/centaline/dynamicDtd/src/dynamicDtdOld.vue +93 -93
  61. package/src/centaline/dynamicFile/index.js +11 -11
  62. package/src/centaline/dynamicFile/src/dynamicFile.vue +288 -283
  63. package/src/centaline/dynamicForm/index.js +24 -24
  64. package/src/centaline/dynamicForm/src/dynamicForm.vue +564 -564
  65. package/src/centaline/dynamicForm/src/dynamicFormList.vue +209 -209
  66. package/src/centaline/dynamicForm/src/dynamicFormListTable.vue +376 -376
  67. package/src/centaline/dynamicGp/index.js +11 -11
  68. package/src/centaline/dynamicGp/src/dynamicGp.vue +27 -27
  69. package/src/centaline/dynamicHyperLink/index.js +11 -11
  70. package/src/centaline/dynamicHyperLink/src/dynamicHyperLink.vue +54 -54
  71. package/src/centaline/dynamicInput/index.js +35 -35
  72. package/src/centaline/dynamicInput/src/dynamicInput.vue +35 -35
  73. package/src/centaline/dynamicInputNumber/index.js +11 -11
  74. package/src/centaline/dynamicInputNumber/src/dynamicInputNumber.vue +157 -157
  75. package/src/centaline/dynamicIti/index.js +11 -11
  76. package/src/centaline/dynamicIti/src/dynamicIti.vue +148 -148
  77. package/src/centaline/dynamicL/index.js +11 -11
  78. package/src/centaline/dynamicL/src/dynamicL.vue +37 -37
  79. package/src/centaline/dynamicLabel/index.js +11 -11
  80. package/src/centaline/dynamicLabel/src/dynamicLabel.vue +73 -73
  81. package/src/centaline/dynamicLs/index.js +22 -22
  82. package/src/centaline/dynamicLs/src/dynamicLs.vue +233 -233
  83. package/src/centaline/dynamicMo/index.js +13 -13
  84. package/src/centaline/dynamicMo/src/dynamicMo.vue +421 -421
  85. package/src/centaline/dynamicMt/index.js +11 -11
  86. package/src/centaline/dynamicMt/src/dynamicMt.vue +44 -44
  87. package/src/centaline/dynamicPlaceHolder/index.js +11 -11
  88. package/src/centaline/dynamicPlaceHolder/src/dynamicPlaceHolder.vue +29 -29
  89. package/src/centaline/dynamicPopupSearchList/index.js +11 -11
  90. package/src/centaline/dynamicPopupSearchList/src/dynamicPopupSearchList.vue +157 -157
  91. package/src/centaline/dynamicPopupSearchList/src/dynamicPopupSearchListTable.vue +239 -239
  92. package/src/centaline/dynamicRichText/index.js +11 -11
  93. package/src/centaline/dynamicRichText/src/dynamicRichText.vue +33 -33
  94. package/src/centaline/dynamicSearchList/index.js +11 -11
  95. package/src/centaline/dynamicSearchList/src/dynamicSearchCategory.vue +121 -121
  96. package/src/centaline/dynamicSearchList/src/dynamicSearchList.vue +135 -135
  97. package/src/centaline/dynamicSearchList/src/dynamicSearchScreen.vue +206 -206
  98. package/src/centaline/dynamicSearchList/src/dynamicSearchTable.vue +1069 -1069
  99. package/src/centaline/dynamicSearchList/src/dynamicTableStatistics.vue +41 -41
  100. package/src/centaline/dynamicSearchList/src/dynamicTableTip.vue +46 -46
  101. package/src/centaline/dynamicSearchList/src/dynamicTableToolbar.vue +61 -61
  102. package/src/centaline/dynamicSeg/index.js +11 -11
  103. package/src/centaline/dynamicSeg/src/dynamicSeg.vue +100 -100
  104. package/src/centaline/dynamicSensitiveEye/index.js +11 -11
  105. package/src/centaline/dynamicSensitiveEye/src/dynamicSensitiveEye.vue +74 -74
  106. package/src/centaline/dynamicSo/index.js +14 -14
  107. package/src/centaline/dynamicSo/src/dynamicSo.vue +328 -328
  108. package/src/centaline/dynamicSo/src/dynamicSo/345/211/257/346/234/254.vue +69 -69
  109. package/src/centaline/dynamicSos/index.js +14 -14
  110. package/src/centaline/dynamicSos/src/dynamicSos - /345/244/215/345/210/266.vue" +223 -223
  111. package/src/centaline/dynamicSos/src/dynamicSos.vue +260 -260
  112. package/src/centaline/dynamicSw/index.js +11 -11
  113. package/src/centaline/dynamicSw/src/dynamicSw.vue +74 -74
  114. package/src/centaline/dynamicT/index.js +11 -11
  115. package/src/centaline/dynamicT/src/dynamicT.vue +79 -79
  116. package/src/centaline/dynamicTab/index.js +11 -11
  117. package/src/centaline/dynamicTab/src/dynamicTab.vue +49 -49
  118. package/src/centaline/dynamicTabs/index.js +11 -11
  119. package/src/centaline/dynamicTabs/src/dynamicTabs.vue +69 -69
  120. package/src/centaline/dynamicTags/index.js +13 -13
  121. package/src/centaline/dynamicTags/src/dynamicTags - /345/244/215/345/210/266.vue" +391 -391
  122. package/src/centaline/dynamicTags/src/dynamicTags.vue +427 -427
  123. package/src/centaline/dynamicTimeSelect/index.js +11 -11
  124. package/src/centaline/dynamicTimeSelect/src/dynamicTimeSelect.vue +141 -141
  125. package/src/centaline/dynamicTree/index.js +11 -11
  126. package/src/centaline/dynamicTree/src/dynamicSearchTree.vue +66 -66
  127. package/src/centaline/dynamicTree/src/dynamicTree.vue +233 -233
  128. package/src/centaline/dynamicTree/src/dynamicTreeList.vue +74 -74
  129. package/src/centaline/formData/index.js +290 -290
  130. package/src/centaline/imgPreview/index.js +42 -42
  131. package/src/centaline/imgPreview/src/imgPreview.vue +26 -26
  132. package/src/centaline/index.js +51 -51
  133. package/src/centaline/loader/index.js +157 -157
  134. package/src/centaline/loader/src/ctl/Base.js +261 -261
  135. package/src/centaline/loader/src/ctl/Button.js +44 -44
  136. package/src/centaline/loader/src/ctl/Cb.js +27 -27
  137. package/src/centaline/loader/src/ctl/Checkbox.js +107 -107
  138. package/src/centaline/loader/src/ctl/ComboBoxWithTextBox.js +162 -162
  139. package/src/centaline/loader/src/ctl/D.js +31 -31
  140. package/src/centaline/loader/src/ctl/Detail.js +175 -175
  141. package/src/centaline/loader/src/ctl/Dtd.js +115 -115
  142. package/src/centaline/loader/src/ctl/DtdOld.js +129 -129
  143. package/src/centaline/loader/src/ctl/File.js +292 -292
  144. package/src/centaline/loader/src/ctl/Form.js +380 -380
  145. package/src/centaline/loader/src/ctl/FormList.js +428 -428
  146. package/src/centaline/loader/src/ctl/GM.js +20 -20
  147. package/src/centaline/loader/src/ctl/Gp.js +9 -9
  148. package/src/centaline/loader/src/ctl/Hd.js +13 -13
  149. package/src/centaline/loader/src/ctl/HyperLink.js +24 -24
  150. package/src/centaline/loader/src/ctl/InputNumber.js +51 -51
  151. package/src/centaline/loader/src/ctl/Iti.js +108 -108
  152. package/src/centaline/loader/src/ctl/L.js +18 -18
  153. package/src/centaline/loader/src/ctl/Mo.js +183 -183
  154. package/src/centaline/loader/src/ctl/Mt.js +20 -20
  155. package/src/centaline/loader/src/ctl/PlaceHolder.js +17 -17
  156. package/src/centaline/loader/src/ctl/Router.js +273 -273
  157. package/src/centaline/loader/src/ctl/SearchCategory.js +54 -54
  158. package/src/centaline/loader/src/ctl/SearchScreen.js +236 -236
  159. package/src/centaline/loader/src/ctl/SearchTable.js +772 -772
  160. package/src/centaline/loader/src/ctl/Seg.js +37 -37
  161. package/src/centaline/loader/src/ctl/SensitiveEye.js +65 -65
  162. package/src/centaline/loader/src/ctl/So.js +117 -117
  163. package/src/centaline/loader/src/ctl/Sos.js +128 -128
  164. package/src/centaline/loader/src/ctl/Sw.js +27 -27
  165. package/src/centaline/loader/src/ctl/T.js +65 -65
  166. package/src/centaline/loader/src/ctl/Tabs.js +57 -57
  167. package/src/centaline/loader/src/ctl/Tags.js +191 -191
  168. package/src/centaline/loader/src/ctl/TimeSelect.js +87 -87
  169. package/src/centaline/loader/src/ctl/Tree.js +151 -151
  170. package/src/centaline/loader/src/ctl/Ttts.js +78 -78
  171. package/src/centaline/loader/src/ctl/lib/Enum.js +563 -563
  172. package/src/centaline/loader/src/ctl/lib/LibFunction.js +364 -364
  173. package/src/centaline/loader/src/ctl.js +36 -36
  174. package/src/centaline/mixins/dynamicElement.js +151 -151
  175. package/src/centaline/mixins/dynamicSelect.js +84 -84
  176. package/src/centaline/mixins/emitter.js +33 -33
  177. package/src/centaline/progress/index.js +11 -11
  178. package/src/centaline/progress/src/progress.vue +70 -70
  179. package/src/centaline/quickInput/src/quickInput.vue +64 -64
  180. package/src/centaline/selectOption/src/selectOption.vue +61 -61
  181. package/src/centaline/selectOption/src/selectOptionVertical.vue +80 -80
  182. package/src/centaline/templateControls/index.js +17 -17
  183. package/src/centaline/templateControls/src/dynamicTableA.vue +20 -20
  184. package/src/centaline/templateControls/src/dynamicTableCurrency.vue +62 -62
  185. package/src/centaline/templateControls/src/dynamicTableImg.vue +25 -25
  186. package/src/centaline/templates/index.js +34 -34
  187. package/src/centaline/templates/src/ContractSearch.js +67 -67
  188. package/src/centaline/templates/src/test.js +44 -44
  189. package/src/centaline/validate/index.js +332 -332
  190. package/src/main.js +46 -46
  191. package/src/router/index.js +44 -44
  192. package/wwwroot/static/centaline/centaline-data-driven.js +1 -1
  193. package/wwwroot/static/centaline/centaline-data-driven.js.map +1 -1
@@ -1,1069 +1,1069 @@
1
- <template>
2
- <div style="width:100%;" class="ct-searchtable" ref="searchTable">
3
- <ct-tableStatistics ref="listHeader" class="ct-search-table-list-header" :tip="model.listHeader" v-if="!isLoading && searchDataStatisticsApi"></ct-tableStatistics>
4
- <ct-tabletoolbar ref="toolbar" v-if="!isLoading" :buttons="model.buttons"
5
- @click="toolbarClickHandler($event)"
6
- @importComplete="importComplete"
7
- :optionApi="model.optionApi"
8
- :searchModel="model.searchModel"></ct-tabletoolbar>
9
- <ct-tabletip ref="listHeader" class="ct-search-table-list-header" :tip="model.listHeader" v-if="!isLoading"></ct-tabletip>
10
- <div v-loading="tableLoading" v-if="!isLoading" :style="{'height':'0px','top':model.tableHeight*0.55+'px'}">
11
- </div>
12
- <div v-loading="operationLoading">
13
- </div>
14
- <div class="ct-tableParent" ref="tableParent" v-bind="model.attrs" v-if="!isLoading"
15
- :style="{'height':model.tableHeight+'px'}"
16
- @scroll="scrollHandle($event)" v-focus="true"
17
- @keydown.up="rowKeyDownHandle($event,0)" @keydown.down="rowKeyDownHandle($event,1)"
18
- tabindex="-1">
19
- <div class="ct-table-content">
20
- <table border="0" cellpadding="0" cellspacing="0"
21
- :class="['ct-table',model.attrs.size?'ct-table-'+model.attrs.size:'']">
22
- <!--表头-->
23
- <thead ref="tableHead">
24
- <tr class="ct-tr" ref="headTr" v-for="(columns,columnsIndex) in model.columnsArr">
25
- <th v-if="model.isMulti && columnsIndex === 0" ref="headLeftThs" class="ct-td left-fixation-th checkbox-td">
26
- <input type="checkbox" @click="selectAll($event)" v-model="model.selectAll" class="checkbox-td-1" />
27
- </th>
28
- <th :ref="column.fixed?(column.fixed==='left'?'headLeftThs':'headRightThs'):'headThs'" v-for="(column,colIndex) in columns"
29
- v-if="column.show" class="ct-td ct-searchtable-th"
30
- :rowspan="column.rowspan"
31
- :colspan="column.colspan"
32
- :class="[colHasWidth[colIndex],column.sortAction,
33
- colIndex === leftShadow?'shadowLeft':null,
34
- colIndex === rightShadow?'shadowRight':null,
35
- column.fixed === 'left'?'left-fixation-th':null,
36
- column.fixed === 'right'?'right-fixation-th':null,
37
- typeof column.fixed === 'undefined'?'right-no-fixation-th':null]"
38
- @mousemove="thMouseMoveHandle($event)" @mousedown="thMouseDownHandle($event,colIndex)"
39
- v-bind="column.attrs">
40
-
41
- <span>{{column.name}}</span>
42
- <span class="caret-wrapper" v-if="column.sort" @click="toSort($event,column);" @contextmenu.prevent="clearSort($event,column);">
43
- <i class="sort-caret ascending" @click.left="toSort($event,column,'asc')" @contextmenu.prevent="clearSort($event,column);"></i>
44
- <i class="sort-caret descending" @click.left="toSort($event,column,'desc')" @contextmenu.prevent="clearSort($event,column);"></i>
45
- </span>
46
- </th>
47
-
48
- <!--<th v-if="model.rowRouter.length > 0" class="ct-td tdFiexd" :class="[-1 === rightShadow?'shadowRight':null]" :style="{'min-width':'20px','transform':'translate('+scrollRight+'px, '+scrollTop+'px)'}">
49
- 操作
50
- </th>-->
51
- </tr>
52
- </thead>
53
- <!--表体-->
54
- <tbody>
55
- <!--这一行仅用于设置未加载数据时的列宽-->
56
- <!--<tr v-if="model.listData.length === 0" class="ct-tr" style="visibility: hidden;">
57
- <td v-if="model.isMulti">
58
- </td>
59
- <td v-for="(column,colIndex) in model.dataFieldcolumns" class="ct-td" v-if="column.show">
60
- <div :style="{'width': column.width + 'px'}">
61
- </div>
62
- </td>
63
- </tr>-->
64
- <!--可视区域的行数据-->
65
- <tr v-for="(row,rowindex) in model.listData"
66
- v-if="pageRowMin <= rowindex && rowindex <= pageRowMax"
67
- :ref="'rows.'+rowindex" @click="rowClickHandle($event,rowindex)"
68
- class="ct-tr"
69
- :style="row.$style">
70
- <td v-if="model.isMulti" class="ct-td tdFiexd left-fixation checkbox-td" align="center">
71
- <input v-if="!model.rightMulti || row[model.rightMulti] == 1" type="checkbox" v-model="row.$select" @change="selectOne($event)" class="checkbox-td-1" />
72
- </td>
73
- <td :ref="column.fixed?(column.fixed==='left'?'headLeftTds':'headRightTds'):null"
74
- v-for="(column,colIndex) in model.dataFieldcolumns"
75
- v-if="tdShow(column, row)"
76
- :rowspan="tdRowspan(column, row)"
77
- class="ct-td"
78
- :class="[colHasWidth[colIndex],
79
- colIndex === leftShadow?'shadowLeft':null,
80
- colIndex === rightShadow?'shadowRight':null,
81
- column.fixed === 'left'?'left-fixation':null,
82
- column.fixed === 'right'?'right-fixation':null]"
83
- v-bind="column.attrs">
84
- <!--操作列-->
85
- <div v-if="column.id==='operation'" class="div_allinline" :class="column.autoRowHeight ? 'lineFeedCell':'cell'">
86
- <ct-tablecurrency v-for="(router,rowRouterIndex) in model.rowRouter" :key="rowRouterIndex" v-if="!router.rightField || row[router.rightField] == 1" :isOperationalColumn="true"
87
- :router="router" :colValue="router.label" :rowData="row" @click="rolRouterClickHandler">
88
- </ct-tablecurrency>
89
- </div>
90
-
91
- <!--可点击的列-->
92
- <ct-tablecurrency v-else-if="column.router" :align="column.attrs.align" :class="column.autoRowHeight ? 'lineFeedCell':'cell'" :router="column.router" :colValue="row[column.id]" :rowData="row"
93
- @click="rolRouterClickHandler">
94
- </ct-tablecurrency>
95
-
96
- <!--正常的列-->
97
- <div v-else-if="typeof column.template === 'undefined'" :class="column.autoRowHeight ? 'lineFeedCell':'cell'">
98
- {{row[column.id]}}
99
- </div>
100
-
101
- <!--模版列(启用)-->
102
- <!--<component v-else :is="column.template(row).component" :class="column.autoRowHeight ? 'lineFeedCell':'cell'" :vmodel="column.template(row)" :style="{'width': column.width + 'px'}">
103
- <template slot="value">
104
- {{row[column.id]}}
105
- </template>
106
- </component>-->
107
- </td>
108
- </tr>
109
-
110
-
111
-
112
- <!--适配滚动条-->
113
- <tr v-else v-bind:style="{ height: row.$heigth + 'px' }"></tr>
114
- </tbody>
115
- </table>
116
- </div>
117
- </div>
118
-
119
- <ct-tabletip ref="listFooter" class="ct-search-table-list-footer" :tip="model.listFooter" v-if="!isLoading"></ct-tabletip>
120
- <ct-tabletip ref="footer" class="ct-search-table-footer" :tip="model.footer" v-if="!isLoading"></ct-tabletip>
121
- <div v-if="isLoading && searchLoading" v-loading="isLoading" style="top:30px;">
122
- </div>
123
- </div>
124
- </template>
125
- <script>
126
- import dynamicElement from '../../mixins/dynamicElement';
127
- import dynamicTableTip from './dynamicTableTip.vue';
128
- import dynamicTableToolbar from './dynamicTableToolbar.vue';
129
- import dynamicTableStatistics from './dynamicTableStatistics.vue';
130
- export default {
131
- name: 'ct-searchtable',
132
- mixins: [dynamicElement],
133
- components: {
134
- 'ct-tabletip': dynamicTableTip,
135
- 'ct-tabletoolbar': dynamicTableToolbar,
136
- 'ct-tableStatistics': dynamicTableStatistics
137
- },
138
- props: {
139
- vmodel: Object,
140
- api: String,
141
- searchDataStatisticsApi: String
142
- },
143
- computed: {
144
- },
145
- data() {
146
- return {
147
- currentTh: null,
148
- isLoading: true,
149
- searchLoading: true,
150
- tableLoading: false,//表格等待
151
- operationLoading: false,//操作等待
152
- tempSearchModel: null,
153
- isBusy: false,
154
- screenComplate: false,
155
- tableComplate: false,
156
- scrollTop: 0,
157
- scrollLeft: 0,
158
- scrollRight: 0,
159
- leftShadow: -1,//左阴影个数
160
- rightShadow: -1,//右阴影个数
161
- currentRow: null,
162
- colHasWidth: {},//有无列宽集合
163
- test: true,
164
- firstRow: 0,//展示出来可视的第一行号
165
- pageRowMin: 0,//页面实际的第一行号
166
- pageRowMax: 100,//页面实际的第后行号
167
- displayRowNumber: 30
168
- }
169
- },
170
- activated() {
171
- this.$nextTick(() => {
172
- // this.calculatingRowHeight();
173
- this.setTableHeight();
174
- })
175
- },
176
- methods: {
177
- load(data) {
178
- var self = this;
179
- self.model = data;
180
- self.model.$vue = self;
181
- self.model.columns.forEach((v, vi) => {
182
- if (v.fixed === 'left') {
183
- self.leftShadow = vi;
184
- }
185
- if (v.fixed === 'right' && self.rightShadow < 0) {
186
- self.rightShadow = vi;
187
- }
188
- if (typeof v.width !== 'undefined') {
189
- self.colHasWidth[vi] = '';
190
- }
191
- else {
192
- self.colHasWidth[vi] = 'nowidth';
193
- }
194
- });
195
-
196
- self.isLoading = false;
197
- self.$forceUpdate();
198
- this.model.scripts.formData = this.model.formData;
199
- this.model.scripts.formData.formTable = this.model;
200
-
201
- self.$emit('loaded');
202
- self.$emit('showTitle');
203
- if (this.tempSearchModel !== null) {
204
- self.model.searchModel = this.tempSearchModel;
205
- }
206
- //自动查询 调用合并列
207
- if (self.model.rowMergedColumns.length > 0 && self.model.listData.length > 0) {
208
- self.model.setRow(self.model.listData);
209
- }
210
- self.tableComplate = true;
211
- this.setTableHeight();
212
- this.$nextTick(() => {
213
- window.addEventListener("resize", (ev) => {
214
- self.setTableHeight();
215
- });
216
- //self.rowColorChange();
217
- self.fiexdHead();
218
-
219
- //当表格没有占满表格框时,主动请求下一页
220
- var next = function (rtn) {
221
- if (rtn) {
222
- self.$forceUpdate();
223
- self.$nextTick(() => {
224
- if (self.$refs.tableParent.scrollHeight <= self.$refs.tableParent.offsetHeight) {
225
- self.tableLoading = true;
226
- self.model.nextPage(next);
227
- }
228
- else {
229
- self.tableLoading = false;
230
- self.rowColorChange();
231
-
232
- self.calculatingRowHeight();
233
- }
234
- });
235
- }
236
- else {
237
- self.tableLoading = false;
238
- }
239
- }
240
- next(true);
241
-
242
- self.setfixedSize();
243
- });
244
- },
245
- thMouseMoveHandle(ev) {
246
- if (ev.offsetX > ev.currentTarget.offsetWidth - 10) {
247
- ev.currentTarget.style.cursor = 'col-resize';
248
- ev.currentTarget.canResize = true;
249
- }
250
- else {
251
- ev.currentTarget.style.cursor = 'default';
252
- ev.currentTarget.canResize = false;
253
- }
254
- },
255
- thMouseDownHandle(ev, colIndex) {
256
- var self = this;
257
- var col = self.model.columns[colIndex];
258
- if (ev.currentTarget.canResize) {
259
- ev.currentTarget.isDown = true;
260
- ev.currentTarget.oldX = ev.x;
261
- ev.currentTarget.oldWidth = ev.currentTarget.offsetWidth;
262
- this.currentTh = ev.currentTarget;
263
- var MouseUpHandle = function () {
264
- self.currentTh.isDown = false;
265
- self.currentTh = null;
266
- document.removeEventListener("mouseup", MouseUpHandle, false);
267
- document.removeEventListener("mousemove", MouseMoveHandle, false);
268
-
269
- //如果是高度可变的列,重新计算整个表的高度
270
- if (col.autoRowHeight) {
271
- self.model.listData.forEach(v => {
272
- v.$heigth = undefined;
273
- });
274
- self.$nextTick(() => {
275
- self.calculatingRowHeight();
276
- })
277
- }
278
- }
279
- var MouseMoveHandle = function () {
280
- var ev1 = event || e;
281
- if (self.currentTh.isDown) {
282
- if (self.currentTh) {
283
- if (typeof col.width === 'undefined') {
284
- self.colHasWidth[colIndex] = '';
285
- self.$forceUpdate();
286
- self.$nextTick(() => {
287
- var index = self.model.selectIndex;
288
- for (var j = 0; j < self.$refs['rows.' + index][0].children.length; j++) {
289
- self.$refs['rows.' + index][0].children[j].classList.add('select');
290
- }
291
- });
292
- }
293
-
294
- //col.width = (self.currentTh.oldWidth + (ev1.x - self.currentTh.oldX));
295
- self.$set(col, "width", (self.currentTh.oldWidth + (ev1.x - self.currentTh.oldX)));
296
- if (typeof self.$refs.headTr !== 'undefined' && self.$refs.headTr.length > 0) {
297
- self.currentTh.style.minWidth = col.width + 'px';
298
- self.currentTh.style.width = col.width + 'px';
299
- self.getScrollAttr();
300
- }
301
- }
302
- }
303
- }
304
- document.addEventListener("mouseup", MouseUpHandle, false);
305
- document.addEventListener("mousemove", MouseMoveHandle, false);
306
- }
307
- },
308
- getPage(index) {
309
- var self = this;
310
- if (typeof self.$refs.tableParent !== 'undefined') {
311
- self.$refs.tableParent.scrollTop = 0;
312
- self.$refs.tableParent.scrollLeft = 0;
313
- self.scrollTop = 0;
314
- self.scrollLeft = 0;
315
- }
316
- var next = function (rtn) {
317
- if (rtn) {
318
- self.$forceUpdate();
319
- self.$nextTick(() => {
320
- if (self.$refs.tableParent.scrollHeight <= self.$refs.tableParent.offsetHeight) {
321
- self.tableLoading = true;
322
- self.model.nextPage(next);
323
- }
324
- else {
325
- self.tableLoading = false;
326
- self.rowColorChange();
327
- self.resetScroll();
328
- self.calculatingRowHeight();
329
- self.getScrollAttr();
330
- }
331
- self.setfixedSize();
332
- });
333
- }
334
- else {
335
- self.tableLoading = false;
336
- self.rowColorChange();
337
- }
338
- self.$emit('searchComplate');
339
- }
340
- self.tableLoading = true;
341
- this.model.getPage(index, next);
342
- },
343
- toSort(ev, col, action) {
344
- var self = this;
345
- this.model.toSort(col, action, () => {
346
- self.$forceUpdate();
347
- self.getScrollAttr();
348
- });
349
- ev.cancelBubble = true;
350
- ev.stopPropagation();
351
- },
352
- clearSort(ev, col) {
353
- var self = this;
354
- this.model.clearSort(col, () => {
355
- self.$forceUpdate();
356
- self.getScrollAttr();
357
- });
358
- ev.cancelBubble = true;
359
- ev.stopPropagation();
360
- },
361
- fiexdHead() {
362
- this.$nextTick(() => {
363
- var self = this;
364
- var tableCont = this.$refs.tableParent;
365
- function scrollHandle(e) {
366
- self.getScrollAttr();
367
- }
368
- tableCont.addEventListener('scroll', self.getScrollAttr);
369
- });
370
- },
371
- removeScrollEvent() {
372
- var tableCont = this.$refs.tableParent;
373
- //移除事件监听器
374
- tableCont.removeEventListener("scroll", this.getScrollAttr, false);
375
- //tableCont.removeEventListener("scroll", this.scrollHandle, false);
376
- },
377
- addScrollEvent() {
378
- var tableCont = this.$refs.tableParent;
379
- //添加事件监听器
380
- tableCont.addEventListener("scroll", this.getScrollAttr, false);
381
- },
382
- freezeData() {
383
- Object.freeze(this.model.listData);
384
- },
385
- setfixedSize() {
386
- if (typeof this.$refs.headTr !== 'undefined' && this.$refs.headTr.length > 0) {
387
- let fixedSize = 0;
388
- let j = 0;
389
- let fixationThArr = this.$refs.headTr[0].getElementsByClassName('left-fixation-th');
390
- if (fixationThArr.length > 0) {
391
- if (this.model.isMulti) {
392
- fixedSize = fixationThArr[j++].offsetWidth
393
- }
394
- for (let i = 0; i < this.model.columns.length; i++) {
395
- if (this.model.columns[i].fixed === 'left' && this.model.columns[i].show) {
396
- this.model.columns[i].fixedSize = fixedSize;
397
- fixedSize = fixedSize + fixationThArr[j++].offsetWidth;
398
- }
399
- }
400
-
401
- fixedSize = 0;
402
- fixationThArr = this.$refs.headTr[0].getElementsByClassName('right-fixation-th');
403
- j = fixationThArr.length - 1;
404
- for (let i = this.model.columns.length - 1; i > 0; i--) {
405
- if (this.model.columns[i].fixed === 'right' && this.model.columns[i].show) {
406
- this.model.columns[i].fixedSize = fixedSize;
407
- fixedSize = fixedSize + fixationThArr[j--].offsetWidth;
408
- }
409
- }
410
- }
411
- }
412
- },
413
- getScrollAttr(e) {
414
- if (typeof this.$refs.tableParent !== 'undefined' && typeof this.$refs.headThs !== 'undefined') {
415
-
416
- this.calculatingRowHeight();
417
-
418
- var scrollTop = this.$refs.tableParent.scrollTop;
419
- var scrollLeft = this.$refs.tableParent.scrollLeft;
420
- var scrollRight = this.$refs.tableParent.scrollWidth - scrollLeft - this.$refs.tableParent.clientWidth;
421
-
422
- //计算可视范围的第一条数据
423
- let index = 0;
424
- let topHeigth = 0;
425
- for (; index < this.model.listData.length; index++) {
426
- if (topHeigth >= scrollTop) {
427
- break;
428
- }
429
- else {
430
- topHeigth = topHeigth + this.model.listData[index].$heigth;
431
- }
432
- }
433
- this.firstRow = index - 1;
434
- this.setTrLazyLoading();
435
- //若每行高度是固定的,可直接使用下面方法即可
436
- //this.firstRow = parseInt(scrollTop / 33);
437
-
438
- this.scrollTop = scrollTop;
439
- this.scrollLeft = scrollLeft;
440
- this.scrollRight = scrollRight;
441
- }
442
- },
443
- setTrLazyLoading() {
444
- this.pageRowMax = this.firstRow + this.displayRowNumber;
445
- this.pageRowMin = this.firstRow - this.displayRowNumber;
446
- if (this.pageRowMin > 0 && this.model.listData[this.pageRowMin].$rowspan === 0) {
447
- for (let i = this.pageRowMin; i >= 0; i--) {
448
- if (this.model.listData[i].$rowspan > 0) {
449
- this.pageRowMin = i;
450
- break;
451
- }
452
- }
453
- }
454
-
455
- //debugger
456
- //let index = this.model.listData.length - 1;
457
- //let isSet = false;
458
- //for (; index >= 0; index--) {
459
- // if (Math.abs(index - this.firstRow) < this.displayRowNumber || typeof (this.model.listData[index].$heigth) === 'undefined') {
460
- // //this.$set(this.model.listData[index], "$trLazyLoadingShow", true);
461
- // }
462
- // else {
463
- // if (index < this.firstRow && !isSet) {
464
- // if (this.model.listData[index].$rowspan === 0) {
465
- // this.$set(this.model.listData[index], "$trLazyLoadingShow", true);
466
- // continue;
467
- // }
468
- // else {
469
- // isSet = true;
470
- // this.$set(this.model.listData[index], "$trLazyLoadingShow", true);
471
- // continue;
472
- // }
473
- // }
474
- // this.$set(this.model.listData[index], "$trLazyLoadingShow", false);
475
- // }
476
- //}
477
- },
478
- setTableHeight() {
479
- var self = this;
480
- this.$nextTick(() => {
481
- if (this.$refs.searchTable && this.$refs.toolbar && this.$refs.searchTable.parentElement) {
482
- var h1 = this.$refs.searchTable.parentElement.offsetHeight | 0;
483
- var h2 = this.$refs.searchTable.offsetTop | 0;
484
- var h3 = this.$refs.toolbar.$el.offsetHeight | 0;
485
- var h4 = this.$refs.footer.$el.offsetHeight | 0;
486
- var h5 = this.$refs.listHeader.$el.offsetHeight | 0;
487
- var h6 = this.$refs.listFooter.$el.offsetHeight | 0;
488
- let tableHeight = h1 - h2 - h3 - h4 - h5 - h6 - 22;
489
- this.model.tableHeight = tableHeight < 40 ? 350 : tableHeight;
490
- this.$nextTick(() => {
491
- self.getScrollAttr();
492
- });
493
- }
494
- });
495
- },
496
- scrollHandle(ev) {
497
- var self = this;
498
- if ((this.$refs.tableParent.scrollTop + this.$refs.tableParent.clientHeight) >= (this.$refs.tableParent.scrollHeight - 5)) {
499
- if (!this.isBusy) {
500
- self.isBusy = true;
501
- self.tableLoading = true;
502
- self.model.nextPage((rtn) => {
503
- if (rtn) {
504
- self.$nextTick(() => {
505
- self.calculatingRowHeight();
506
- self.getScrollAttr();
507
-
508
- });
509
- self.$forceUpdate();
510
- }
511
- self.isBusy = false;
512
- self.tableLoading = false;
513
- });
514
- }
515
- }
516
- ev.cancelBubble = true;
517
- ev.stopPropagation();
518
- },
519
- rowClickHandle(ev, index) {
520
- this.model.selectIndex = index;
521
- this.rowColorChange();
522
- ev.cancelBubble = true;
523
- ev.stopPropagation();
524
- },
525
- rowColorChange() {
526
- var index = this.model.selectIndex;
527
- if (typeof this.$refs['rows.' + index] !== "undefined" && this.currentRow !== this.$refs['rows.' + index][0]) {
528
- if (this.currentRow !== null) {
529
- for (var i = 0; i < this.currentRow.children.length; i++) {
530
- this.currentRow.children[i].classList.remove('select');
531
- }
532
- }
533
- if(this.$refs['rows.' + index][0])
534
- {
535
- for (var j = 0; j < this.$refs['rows.' + index][0].children.length; j++) {
536
- this.$refs['rows.' + index][0].children[j].classList.add('select');
537
- }
538
- }
539
- this.currentRow = this.$refs['rows.' + index][0]||null;
540
- }
541
- },
542
- resetScroll: function () {
543
- var self = this;
544
- if (self.$refs.tableParent.scrollTop > self.$refs['rows.' + self.model.selectIndex][0].offsetTop - self.$refs.tableHead.offsetHeight) {
545
- self.$refs.tableParent.scrollTop = self.$refs['rows.' + self.model.selectIndex][0].offsetTop - self.$refs.tableHead.offsetHeight;
546
- }
547
- if (self.$refs.tableParent.scrollTop + self.$refs.tableParent.clientHeight <= self.$refs['rows.' + self.model.selectIndex][0].offsetTop + self.$refs['rows.' + self.model.selectIndex][0].offsetHeight) {
548
- self.$refs.tableParent.scrollTop = self.$refs['rows.' + self.model.selectIndex][0].offsetTop - self.$refs.tableParent.clientHeight + self.$refs['rows.' + self.model.selectIndex][0].offsetHeight;
549
- }
550
- self.scrollTop = self.$refs.tableParent.scrollTop;
551
- },
552
- rowKeyDownHandle(ev, action) {
553
- var self = this;
554
- if (action === 1) {
555
- this.model.downKey();
556
- }
557
- else {
558
- this.model.upKey();
559
- }
560
- this.rowColorChange();
561
- this.resetScroll();
562
- if (!this.isBusy) {
563
- if (this.model.selectIndex === this.model.listData.length - 1) {
564
- self.isBusy = true;
565
- self.tableLoading = true;
566
- self.model.nextPage((rtn) => {
567
- if (rtn) {
568
- self.$nextTick(() => {
569
- self.calculatingRowHeight();
570
- self.getScrollAttr();
571
- });
572
- self.$forceUpdate();
573
- }
574
- self.isBusy = false;
575
- self.tableLoading = false;
576
- });
577
- }
578
- }
579
- ev.cancelBubble = true;
580
- ev.stopPropagation();
581
- ev.preventDefault();
582
- },
583
- searchComplate(m, defaultSearch) {
584
- var self = this;
585
- this.$nextTick(function () {
586
- if (typeof this.api !== 'undefined') {
587
- self.loaderObj.SearchTable(self.api, self.load, m, defaultSearch);
588
- }
589
- if (typeof this.source !== 'undefined') {
590
- self.load(self.loaderObj.SearchTable(self.source));
591
- }
592
- if (typeof self.vmodel !== 'undefined') {
593
- self.load(self.vmodel);
594
- }
595
- });
596
- },
597
- toolbarClickHandler(field) {
598
- let self = this;
599
- let submitData = {};
600
- let action = field.action;
601
-
602
- var tempListData = self.model.getSelectRowData(field);
603
- if (tempListData != null) {
604
- field.submitListField.forEach((k) => {
605
- if (field.isMulti) {
606
- submitData[k] = [];
607
- for (var ri = 0; ri < tempListData.length; ri++) {
608
- submitData[k].push(tempListData[ri][k]);
609
- }
610
- }
611
- else {
612
- submitData[k] = tempListData[0][k];
613
- }
614
- });
615
-
616
- if (field.isSingle && tempListData.length > 0 && field.actionField) {
617
- action = tempListData[0][field.actionField];
618
- }
619
- }
620
-
621
- if (field.flagAttachSearchCondition) {
622
- submitData['searchFields'] = self.model.searchModel.searchData;
623
- }
624
-
625
- //如果是导出按钮,则直接交给父组件处理
626
- if (field.isExport) {
627
- self.$emit('toolbarClick', field, submitData);
628
- return;
629
- }
630
-
631
- this.routerClickHandler(field, submitData, action);
632
- },
633
- rolRouterClickHandler(field, rowData) {
634
- var self = this;
635
- var submitData = {};
636
- field.submitListField.forEach((k) => {
637
- submitData[k] = rowData[k];
638
- });
639
-
640
- let action = field.action;
641
- if (field.actionField) {
642
- action = rowData[field.actionField];
643
- }
644
-
645
- this.routerClickHandler(field, submitData, action);
646
- },
647
- routerClickHandler(field, submitData, action) {
648
- let self = this;
649
- action = action || field.action;
650
-
651
- var clickAcion = function () {
652
- //若不是客户端方法,则直接访问接口
653
- if (!field.isClientFuntion) {
654
- // 外部框架tab页打开
655
- if (field.isFormPageInTab || field.isSearchPageInTab) {
656
- submitData = field.getActionPara(submitData).para;
657
- if (field.pageStyle) {
658
- submitData.pageStyle = field.pageStyle;
659
- }
660
- self.$common.getDataDrivenOpts().handler.openTab(action, submitData, field.pageTitle, self.model);
661
- }
662
- else if (field.isBrowserNewTab) {// 浏览器打开
663
- submitData = field.getActionPara(submitData).para;
664
- let query = self.$common.objectToQueryStr(submitData);
665
- window.open(action + query, "_blank");
666
- }
667
- else {
668
- //self.operationLoading = true;
669
-
670
- //Form
671
- if (field.isOpenForm) {
672
- var dialogOption = {
673
- title: field.pageTitle,
674
- pane: self.$common.getParentPane(self),
675
- content: [{
676
- component: field.navToNewPageName,
677
- attrs: {
678
- //source: data.content,
679
- api: action,
680
- apiParam: field.getActionPara(submitData).para,
681
- showTitle: false,
682
- width: field.dialogWidth + 'px',
683
- height: field.dialogHeight + 'px'
684
- },
685
- on: {
686
- submit(ev) {
687
- if (!field.flagFreshCurrentRow) {
688
- self.model.doAction(ev);
689
- }
690
- self.$forceUpdate();
691
- self.$refs.footer.$forceUpdate();
692
- self.$common.closeDialog(dialogOption.dialog);
693
- self.updateCurrentRow(field);
694
- },
695
- refreshParent() {
696
- self.getPage(1);
697
- self.$common.closeDialog(dialogOption.dialog);
698
- },
699
- closeDialog() {
700
- self.updateCurrentRow(field);
701
- }
702
- }
703
- }]
704
- };
705
- self.$common.openDialog(dialogOption);
706
- }
707
- //SearchList
708
- else if (field.isOpenList) {
709
- var dialogOption = {
710
- title: field.pageTitle,
711
- pane: self.$common.getParentPane(self),
712
- content: [{
713
- component: field.navToNewPageName,
714
- attrs: {
715
- searchConditionApi: field.actionForSearchLayout,
716
- searchDataApi: field.actionForSearch,
717
- apiParam: submitData,
718
- width: field.dialogWidth + 'px',
719
- height: field.dialogHeight + 'px'
720
- },
721
- on: {
722
- refreshParent() {
723
- self.getPage(1);
724
- self.$common.closeDialog(dialogOption.dialog);
725
- },
726
- closeDialog() {
727
- self.updateCurrentRow(field);
728
- }
729
- }
730
- }]
731
- };
732
- self.$common.openDialog(dialogOption);
733
- }
734
- //Tabs
735
- else if (field.isOpenTabs) {
736
- var dialogOption = {
737
- title: field.pageTitle,
738
- pane: self.$common.getParentPane(self),
739
- content: [{
740
- component: field.navToNewPageName,
741
- attrs: {
742
- searchConditionApi: field.actionForSearchLayout,
743
- searchDataApi: field.actionForSearch,
744
- apiParam: submitData,
745
- width: field.dialogWidth + 'px',
746
- height: field.dialogHeight + 'px'
747
- },
748
- on: {
749
- }
750
- }]
751
- };
752
- self.$common.openDialog(dialogOption);
753
- }
754
- else {
755
- self.operationLoading = true;
756
- field.doAction(submitData, (data) => {
757
- self.operationLoading = false;
758
- self.model.doAction({ responseData: data });
759
- self.$forceUpdate();
760
- self.$refs.footer.$forceUpdate();
761
- })
762
- }
763
- }
764
- }
765
- //执行客户端脚本
766
- else {
767
- // let parm={submitData:submitData,field:field}
768
- // self.$common.excuteFunStr.call(self.model.scripts, field.action,parm);
769
- let title=field.pageTitle==undefined ?field.label:field.pageTitle;
770
- submitData.actionType=field.actionType;
771
- var fun =self.$common.getDataDrivenOpts().handler[action];
772
- fun(submitData,title,self.model);
773
- // var fun = self.model.scripts.formData[action];
774
- // fun(submitData,field);
775
- }
776
- }
777
-
778
- if (field.alert) {
779
- self.$common.confirm(field.alertMsg, field.alertCaption, {
780
- confirmButtonText: field.alertOKButtonText,
781
- cancelButtonText: field.alertCancelButtonText,
782
- //type: 'warning'
783
- center: field.alertCenter
784
- }).then(() => {
785
- clickAcion();
786
- }).catch(() => {
787
- });
788
- }
789
- else {
790
- clickAcion();
791
- }
792
- },
793
- selectAll($ev) {
794
- this.model.listData.forEach((ro) => {
795
- if (!this.model.rightMulti || ro[this.model.rightMulti] == 1) {
796
- ro.$select = $ev.srcElement.checked;
797
- }
798
- });
799
- this.model.setButtonsDisabled();
800
- this.$forceUpdate();
801
- },
802
- selectOne($ev) {
803
- this.model.setButtonsDisabled();
804
- },
805
- calculatingRowHeight() {
806
- let self = this;
807
- let count = 0;
808
-
809
- //查询出所有没有设置$heigth的数据并重新设置$heigth
810
- let notHeigthData = self.model.listData.filter(item => {
811
- return item.$heigth === undefined || item.$heigth <= 0
812
- })
813
- if (notHeigthData && notHeigthData.length > 0) {
814
- notHeigthData.forEach((v, i) => {
815
- if (self.$refs["rows." + i] && self.$refs["rows." + i].length > 0) {
816
- self.$set(v, "$heigth", self.$refs["rows." + i][0].clientHeight);
817
- }
818
- });
819
- }
820
-
821
- //for (let i = 0; i < self.model.listData.length; i++) {
822
- // if (self.$refs[]) {
823
- // }
824
- //}
825
- //self.$refs
826
- },
827
- updateCurrentRow(router) {
828
- let self = this;
829
- if (router.flagFreshCurrentRow) {
830
- self.tableComplate = true;
831
- self.model.getCurrentRowApiData(function () {
832
- self.$forceUpdate();
833
- self.tableComplate = false;
834
- });
835
- }
836
- },
837
- importComplete(res) {
838
- this.model.doAction(res);
839
- },
840
- tdRowspan(column, row) {
841
- if (!column.show) {
842
- return '';
843
- }
844
-
845
- //合并行
846
- if (row.$rowspan !== 0 && this.model.rowMergedColumns.indexOf(column.id) > -1) {
847
- return row.$rowspan;
848
- }
849
-
850
- return '';
851
- },
852
- tdShow(column, row) {
853
- if (!column.show) {
854
- return false;
855
- }
856
-
857
- //合并行
858
- if (row.$rowspan === 0 && this.model.rowMergedColumns.indexOf(column.id) > -1) {
859
- return false;
860
- }
861
-
862
- return true;
863
- },
864
- closeTabThen(ev) {
865
- let self = this;
866
- if (self.model.checkCloseTabThen(ev.notification)) {
867
- self.model.doAction(ev);
868
- self.$forceUpdate();
869
- self.$refs.footer.$forceUpdate();
870
- }
871
- }
872
- },
873
- }</script>
874
- <style>
875
- .ct-tableParent {
876
- overflow: auto;
877
- border-bottom: 1px solid #ebeef5;
878
- width: 100%;
879
- outline: 0;
880
- }
881
-
882
- .ct-searchtable .ct-table {
883
- min-width: 100%;
884
- }
885
-
886
- .ct-searchtable .ct-table th {
887
- background-color: #f4f7fa !important;
888
- border-top: 1px solid #ebeef5;
889
- }
890
-
891
- .ct-searchtable .ct-tr > .ct-td {
892
- /*border: 1px solid #e7e8eb;*/
893
- border-bottom: 1px solid #e7e8eb;
894
- /*border-right: 1px solid #e7e8eb;
895
- border-left: 1px solid #e7e8eb;*/
896
- padding: 2px 20px;
897
- cursor: default;
898
- background-color: #ffffff;
899
- }
900
-
901
- .shadowLeft {
902
- border-right: 1px solid #e7e8eb;
903
- box-shadow: 2px 0 3px -1px rgba(0,0,0,0.1);
904
- }
905
-
906
- .shadowRight {
907
- box-shadow: -2px 0 3px -1px rgba(0,0,0,0.1);
908
- }
909
-
910
- .ct-searchtable body:last-child > .ct-td {
911
- border-bottom: 0px;
912
- }
913
-
914
- .ct-searchtable .ct-tr > .ct-td.nowidth {
915
- white-space: nowrap;
916
- }
917
- /*.ct-searchtable tbody .ct-tr:hover .ct-td {
918
- background-color: #ebeef5 !important;
919
- }*/
920
-
921
- .ct-table {
922
- color: #606266;
923
- font-size: 18px;
924
- line-height: 40px;
925
- min-height: 40px;
926
- }
927
-
928
- .ct-table-mini {
929
- font-size: 12px;
930
- line-height: 26px;
931
- min-height: 28px;
932
- }
933
-
934
- .ct-table-small {
935
- font-size: 14px;
936
- line-height: 32px;
937
- min-height: 32px;
938
- }
939
-
940
- .ct-table-medium {
941
- font-size: 16px;
942
- line-height: 36px;
943
- min-height: 36px;
944
- }
945
-
946
- .ct-table .ct-td > .caret-wrapper {
947
- display: inline-flex;
948
- flex-direction: column;
949
- align-items: center;
950
- height: 34px;
951
- width: 10px;
952
- vertical-align: middle;
953
- cursor: pointer;
954
- overflow: initial;
955
- position: relative;
956
- }
957
-
958
- .ct-table .ct-td > .caret-wrapper > .sort-caret {
959
- width: 0;
960
- height: 0;
961
- border: 5px solid transparent;
962
- position: absolute;
963
- left: 7px;
964
- }
965
-
966
- .ct-table .ct-td > .caret-wrapper > .sort-caret.ascending {
967
- border-bottom-color: #c0c4cc;
968
- top: 5px;
969
- }
970
-
971
- .ct-table .ct-td > .caret-wrapper > .sort-caret.descending {
972
- border-top-color: #c0c4cc;
973
- bottom: 7px;
974
- }
975
-
976
- .ct-table .ct-td.select {
977
- background-color: #ecf5ff !important;
978
- }
979
-
980
- .ct-table .ct-tr:hover .ct-td.select {
981
- background-color: #ecf5ff !important;
982
- }
983
-
984
- .ct-table .ct-td.asc > .caret-wrapper > .sort-caret.ascending {
985
- border-bottom-color: #409eff;
986
- top: 5px;
987
- }
988
-
989
- .ct-table .ct-td.desc > .caret-wrapper > .sort-caret.descending {
990
- border-top-color: #409eff;
991
- bottom: 7px;
992
- }
993
-
994
-
995
- .ct-table .cell {
996
- /*white-space: nowrap;*/
997
- text-overflow: ellipsis;
998
- /*min-width: 50px; todo 实际宽度-21即可*/
999
- overflow: hidden;
1000
- /*padding-right: 10px;*/
1001
- }
1002
-
1003
- /*强制换行 todo 可去掉改成强制不换行*/
1004
- .ct-table .cell {
1005
- /* 这两个在技术上是一样的, 为了兼容了浏览器两个都加上 */
1006
- overflow-wrap: break-word;
1007
- word-wrap: break-word;
1008
- -ms-word-break: break-all;
1009
- /* 这个的使用在web-kit中有些危险,他可能会阶段所有东西 */
1010
- word-break: break-all;
1011
- /* Instead use this non-standard one: */
1012
- word-break: break-word;
1013
- /* 如果浏览器支持的话增加一个连接符(Blink不支持) */
1014
- -ms-hyphens: auto;
1015
- -moz-hyphens: auto;
1016
- -webkit-hyphens: auto;
1017
- hyphens: auto;
1018
- }
1019
-
1020
- .ct-table .lineFeedCell {
1021
- min-width: 40px;
1022
- /*padding-right: 10px;*/
1023
- }
1024
-
1025
- /*.ct-table .cell.ct-tooltip:hover {
1026
- text-overflow: inherit;
1027
- overflow: visible;
1028
- }*/
1029
-
1030
- .ct-table .left-fixation {
1031
- position: sticky;
1032
- }
1033
-
1034
- .ct-table .right-fixation {
1035
- position: sticky;
1036
- }
1037
-
1038
- .ct-table .left-fixation-th {
1039
- position: sticky;
1040
- top: 0px;
1041
- z-index: 99;
1042
- }
1043
-
1044
- .ct-table .right-fixation-th {
1045
- position: sticky;
1046
- top: 0px;
1047
- z-index: 99;
1048
- }
1049
-
1050
- .ct-table .right-no-fixation-th {
1051
- position: sticky;
1052
- top: 0px;
1053
- z-index: 50;
1054
- }
1055
-
1056
- .ct-table .ct-searchtable-th {
1057
- /*text-align: center*/
1058
- }
1059
-
1060
- .ct-table .checkbox-td {
1061
- min-width: 20px;
1062
- width: 20px;
1063
- left: 0px;
1064
- }
1065
-
1066
- .ct-table .checkbox-td .checkbox-td-1 {
1067
- vertical-align: inherit;
1068
- }
1069
- </style>
1
+ <template>
2
+ <div style="width:100%;" class="ct-searchtable" ref="searchTable">
3
+ <ct-tableStatistics ref="listHeader" class="ct-search-table-list-header" :tip="model.listHeader" v-if="!isLoading && searchDataStatisticsApi"></ct-tableStatistics>
4
+ <ct-tabletoolbar ref="toolbar" v-if="!isLoading" :buttons="model.buttons"
5
+ @click="toolbarClickHandler($event)"
6
+ @importComplete="importComplete"
7
+ :optionApi="model.optionApi"
8
+ :searchModel="model.searchModel"></ct-tabletoolbar>
9
+ <ct-tabletip ref="listHeader" class="ct-search-table-list-header" :tip="model.listHeader" v-if="!isLoading"></ct-tabletip>
10
+ <div v-loading="tableLoading" v-if="!isLoading" :style="{'height':'0px','top':model.tableHeight*0.55+'px'}">
11
+ </div>
12
+ <div v-loading="operationLoading">
13
+ </div>
14
+ <div class="ct-tableParent" ref="tableParent" v-bind="model.attrs" v-if="!isLoading"
15
+ :style="{'height':model.tableHeight+'px'}"
16
+ @scroll="scrollHandle($event)" v-focus="true"
17
+ @keydown.up="rowKeyDownHandle($event,0)" @keydown.down="rowKeyDownHandle($event,1)"
18
+ tabindex="-1">
19
+ <div class="ct-table-content">
20
+ <table border="0" cellpadding="0" cellspacing="0"
21
+ :class="['ct-table',model.attrs.size?'ct-table-'+model.attrs.size:'']">
22
+ <!--表头-->
23
+ <thead ref="tableHead">
24
+ <tr class="ct-tr" ref="headTr" v-for="(columns,columnsIndex) in model.columnsArr">
25
+ <th v-if="model.isMulti && columnsIndex === 0" ref="headLeftThs" class="ct-td left-fixation-th checkbox-td">
26
+ <input type="checkbox" @click="selectAll($event)" v-model="model.selectAll" class="checkbox-td-1" />
27
+ </th>
28
+ <th :ref="column.fixed?(column.fixed==='left'?'headLeftThs':'headRightThs'):'headThs'" v-for="(column,colIndex) in columns"
29
+ v-if="column.show" class="ct-td ct-searchtable-th"
30
+ :rowspan="column.rowspan"
31
+ :colspan="column.colspan"
32
+ :class="[colHasWidth[colIndex],column.sortAction,
33
+ colIndex === leftShadow?'shadowLeft':null,
34
+ colIndex === rightShadow?'shadowRight':null,
35
+ column.fixed === 'left'?'left-fixation-th':null,
36
+ column.fixed === 'right'?'right-fixation-th':null,
37
+ typeof column.fixed === 'undefined'?'right-no-fixation-th':null]"
38
+ @mousemove="thMouseMoveHandle($event)" @mousedown="thMouseDownHandle($event,colIndex)"
39
+ v-bind="column.attrs">
40
+
41
+ <span>{{column.name}}</span>
42
+ <span class="caret-wrapper" v-if="column.sort" @click="toSort($event,column);" @contextmenu.prevent="clearSort($event,column);">
43
+ <i class="sort-caret ascending" @click.left="toSort($event,column,'asc')" @contextmenu.prevent="clearSort($event,column);"></i>
44
+ <i class="sort-caret descending" @click.left="toSort($event,column,'desc')" @contextmenu.prevent="clearSort($event,column);"></i>
45
+ </span>
46
+ </th>
47
+
48
+ <!--<th v-if="model.rowRouter.length > 0" class="ct-td tdFiexd" :class="[-1 === rightShadow?'shadowRight':null]" :style="{'min-width':'20px','transform':'translate('+scrollRight+'px, '+scrollTop+'px)'}">
49
+ 操作
50
+ </th>-->
51
+ </tr>
52
+ </thead>
53
+ <!--表体-->
54
+ <tbody>
55
+ <!--这一行仅用于设置未加载数据时的列宽-->
56
+ <!--<tr v-if="model.listData.length === 0" class="ct-tr" style="visibility: hidden;">
57
+ <td v-if="model.isMulti">
58
+ </td>
59
+ <td v-for="(column,colIndex) in model.dataFieldcolumns" class="ct-td" v-if="column.show">
60
+ <div :style="{'width': column.width + 'px'}">
61
+ </div>
62
+ </td>
63
+ </tr>-->
64
+ <!--可视区域的行数据-->
65
+ <tr v-for="(row,rowindex) in model.listData"
66
+ v-if="pageRowMin <= rowindex && rowindex <= pageRowMax"
67
+ :ref="'rows.'+rowindex" @click="rowClickHandle($event,rowindex)"
68
+ class="ct-tr"
69
+ :style="row.$style">
70
+ <td v-if="model.isMulti" class="ct-td tdFiexd left-fixation checkbox-td" align="center">
71
+ <input v-if="!model.rightMulti || row[model.rightMulti] == 1" type="checkbox" v-model="row.$select" @change="selectOne($event)" class="checkbox-td-1" />
72
+ </td>
73
+ <td :ref="column.fixed?(column.fixed==='left'?'headLeftTds':'headRightTds'):null"
74
+ v-for="(column,colIndex) in model.dataFieldcolumns"
75
+ v-if="tdShow(column, row)"
76
+ :rowspan="tdRowspan(column, row)"
77
+ class="ct-td"
78
+ :class="[colHasWidth[colIndex],
79
+ colIndex === leftShadow?'shadowLeft':null,
80
+ colIndex === rightShadow?'shadowRight':null,
81
+ column.fixed === 'left'?'left-fixation':null,
82
+ column.fixed === 'right'?'right-fixation':null]"
83
+ v-bind="column.attrs">
84
+ <!--操作列-->
85
+ <div v-if="column.id==='operation'" class="div_allinline" :class="column.autoRowHeight ? 'lineFeedCell':'cell'">
86
+ <ct-tablecurrency v-for="(router,rowRouterIndex) in model.rowRouter" :key="rowRouterIndex" v-if="!router.rightField || row[router.rightField] == 1" :isOperationalColumn="true"
87
+ :router="router" :colValue="router.label" :rowData="row" @click="rolRouterClickHandler">
88
+ </ct-tablecurrency>
89
+ </div>
90
+
91
+ <!--可点击的列-->
92
+ <ct-tablecurrency v-else-if="column.router" :align="column.attrs.align" :class="column.autoRowHeight ? 'lineFeedCell':'cell'" :router="column.router" :colValue="row[column.id]" :rowData="row"
93
+ @click="rolRouterClickHandler">
94
+ </ct-tablecurrency>
95
+
96
+ <!--正常的列-->
97
+ <div v-else-if="typeof column.template === 'undefined'" :class="column.autoRowHeight ? 'lineFeedCell':'cell'">
98
+ {{row[column.id]}}
99
+ </div>
100
+
101
+ <!--模版列(启用)-->
102
+ <!--<component v-else :is="column.template(row).component" :class="column.autoRowHeight ? 'lineFeedCell':'cell'" :vmodel="column.template(row)" :style="{'width': column.width + 'px'}">
103
+ <template slot="value">
104
+ {{row[column.id]}}
105
+ </template>
106
+ </component>-->
107
+ </td>
108
+ </tr>
109
+
110
+
111
+
112
+ <!--适配滚动条-->
113
+ <tr v-else v-bind:style="{ height: row.$heigth + 'px' }"></tr>
114
+ </tbody>
115
+ </table>
116
+ </div>
117
+ </div>
118
+
119
+ <ct-tabletip ref="listFooter" class="ct-search-table-list-footer" :tip="model.listFooter" v-if="!isLoading"></ct-tabletip>
120
+ <ct-tabletip ref="footer" class="ct-search-table-footer" :tip="model.footer" v-if="!isLoading"></ct-tabletip>
121
+ <div v-if="isLoading && searchLoading" v-loading="isLoading" style="top:30px;">
122
+ </div>
123
+ </div>
124
+ </template>
125
+ <script>
126
+ import dynamicElement from '../../mixins/dynamicElement';
127
+ import dynamicTableTip from './dynamicTableTip.vue';
128
+ import dynamicTableToolbar from './dynamicTableToolbar.vue';
129
+ import dynamicTableStatistics from './dynamicTableStatistics.vue';
130
+ export default {
131
+ name: 'ct-searchtable',
132
+ mixins: [dynamicElement],
133
+ components: {
134
+ 'ct-tabletip': dynamicTableTip,
135
+ 'ct-tabletoolbar': dynamicTableToolbar,
136
+ 'ct-tableStatistics': dynamicTableStatistics
137
+ },
138
+ props: {
139
+ vmodel: Object,
140
+ api: String,
141
+ searchDataStatisticsApi: String
142
+ },
143
+ computed: {
144
+ },
145
+ data() {
146
+ return {
147
+ currentTh: null,
148
+ isLoading: true,
149
+ searchLoading: true,
150
+ tableLoading: false,//表格等待
151
+ operationLoading: false,//操作等待
152
+ tempSearchModel: null,
153
+ isBusy: false,
154
+ screenComplate: false,
155
+ tableComplate: false,
156
+ scrollTop: 0,
157
+ scrollLeft: 0,
158
+ scrollRight: 0,
159
+ leftShadow: -1,//左阴影个数
160
+ rightShadow: -1,//右阴影个数
161
+ currentRow: null,
162
+ colHasWidth: {},//有无列宽集合
163
+ test: true,
164
+ firstRow: 0,//展示出来可视的第一行号
165
+ pageRowMin: 0,//页面实际的第一行号
166
+ pageRowMax: 100,//页面实际的第后行号
167
+ displayRowNumber: 30
168
+ }
169
+ },
170
+ activated() {
171
+ this.$nextTick(() => {
172
+ // this.calculatingRowHeight();
173
+ this.setTableHeight();
174
+ })
175
+ },
176
+ methods: {
177
+ load(data) {
178
+ var self = this;
179
+ self.model = data;
180
+ self.model.$vue = self;
181
+ self.model.columns.forEach((v, vi) => {
182
+ if (v.fixed === 'left') {
183
+ self.leftShadow = vi;
184
+ }
185
+ if (v.fixed === 'right' && self.rightShadow < 0) {
186
+ self.rightShadow = vi;
187
+ }
188
+ if (typeof v.width !== 'undefined') {
189
+ self.colHasWidth[vi] = '';
190
+ }
191
+ else {
192
+ self.colHasWidth[vi] = 'nowidth';
193
+ }
194
+ });
195
+
196
+ self.isLoading = false;
197
+ self.$forceUpdate();
198
+ this.model.scripts.formData = this.model.formData;
199
+ this.model.scripts.formData.formTable = this.model;
200
+
201
+ self.$emit('loaded');
202
+ self.$emit('showTitle');
203
+ if (this.tempSearchModel !== null) {
204
+ self.model.searchModel = this.tempSearchModel;
205
+ }
206
+ //自动查询 调用合并列
207
+ if (self.model.rowMergedColumns.length > 0 && self.model.listData.length > 0) {
208
+ self.model.setRow(self.model.listData);
209
+ }
210
+ self.tableComplate = true;
211
+ this.setTableHeight();
212
+ this.$nextTick(() => {
213
+ window.addEventListener("resize", (ev) => {
214
+ self.setTableHeight();
215
+ });
216
+ //self.rowColorChange();
217
+ self.fiexdHead();
218
+
219
+ //当表格没有占满表格框时,主动请求下一页
220
+ var next = function (rtn) {
221
+ if (rtn) {
222
+ self.$forceUpdate();
223
+ self.$nextTick(() => {
224
+ if (self.$refs.tableParent.scrollHeight <= self.$refs.tableParent.offsetHeight) {
225
+ self.tableLoading = true;
226
+ self.model.nextPage(next);
227
+ }
228
+ else {
229
+ self.tableLoading = false;
230
+ self.rowColorChange();
231
+
232
+ self.calculatingRowHeight();
233
+ }
234
+ });
235
+ }
236
+ else {
237
+ self.tableLoading = false;
238
+ }
239
+ }
240
+ next(true);
241
+
242
+ self.setfixedSize();
243
+ });
244
+ },
245
+ thMouseMoveHandle(ev) {
246
+ if (ev.offsetX > ev.currentTarget.offsetWidth - 10) {
247
+ ev.currentTarget.style.cursor = 'col-resize';
248
+ ev.currentTarget.canResize = true;
249
+ }
250
+ else {
251
+ ev.currentTarget.style.cursor = 'default';
252
+ ev.currentTarget.canResize = false;
253
+ }
254
+ },
255
+ thMouseDownHandle(ev, colIndex) {
256
+ var self = this;
257
+ var col = self.model.columns[colIndex];
258
+ if (ev.currentTarget.canResize) {
259
+ ev.currentTarget.isDown = true;
260
+ ev.currentTarget.oldX = ev.x;
261
+ ev.currentTarget.oldWidth = ev.currentTarget.offsetWidth;
262
+ this.currentTh = ev.currentTarget;
263
+ var MouseUpHandle = function () {
264
+ self.currentTh.isDown = false;
265
+ self.currentTh = null;
266
+ document.removeEventListener("mouseup", MouseUpHandle, false);
267
+ document.removeEventListener("mousemove", MouseMoveHandle, false);
268
+
269
+ //如果是高度可变的列,重新计算整个表的高度
270
+ if (col.autoRowHeight) {
271
+ self.model.listData.forEach(v => {
272
+ v.$heigth = undefined;
273
+ });
274
+ self.$nextTick(() => {
275
+ self.calculatingRowHeight();
276
+ })
277
+ }
278
+ }
279
+ var MouseMoveHandle = function () {
280
+ var ev1 = event || e;
281
+ if (self.currentTh.isDown) {
282
+ if (self.currentTh) {
283
+ if (typeof col.width === 'undefined') {
284
+ self.colHasWidth[colIndex] = '';
285
+ self.$forceUpdate();
286
+ self.$nextTick(() => {
287
+ var index = self.model.selectIndex;
288
+ for (var j = 0; j < self.$refs['rows.' + index][0].children.length; j++) {
289
+ self.$refs['rows.' + index][0].children[j].classList.add('select');
290
+ }
291
+ });
292
+ }
293
+
294
+ //col.width = (self.currentTh.oldWidth + (ev1.x - self.currentTh.oldX));
295
+ self.$set(col, "width", (self.currentTh.oldWidth + (ev1.x - self.currentTh.oldX)));
296
+ if (typeof self.$refs.headTr !== 'undefined' && self.$refs.headTr.length > 0) {
297
+ self.currentTh.style.minWidth = col.width + 'px';
298
+ self.currentTh.style.width = col.width + 'px';
299
+ self.getScrollAttr();
300
+ }
301
+ }
302
+ }
303
+ }
304
+ document.addEventListener("mouseup", MouseUpHandle, false);
305
+ document.addEventListener("mousemove", MouseMoveHandle, false);
306
+ }
307
+ },
308
+ getPage(index) {
309
+ var self = this;
310
+ if (typeof self.$refs.tableParent !== 'undefined') {
311
+ self.$refs.tableParent.scrollTop = 0;
312
+ self.$refs.tableParent.scrollLeft = 0;
313
+ self.scrollTop = 0;
314
+ self.scrollLeft = 0;
315
+ }
316
+ var next = function (rtn) {
317
+ if (rtn) {
318
+ self.$forceUpdate();
319
+ self.$nextTick(() => {
320
+ if (self.$refs.tableParent.scrollHeight <= self.$refs.tableParent.offsetHeight) {
321
+ self.tableLoading = true;
322
+ self.model.nextPage(next);
323
+ }
324
+ else {
325
+ self.tableLoading = false;
326
+ self.rowColorChange();
327
+ self.resetScroll();
328
+ self.calculatingRowHeight();
329
+ self.getScrollAttr();
330
+ }
331
+ self.setfixedSize();
332
+ });
333
+ }
334
+ else {
335
+ self.tableLoading = false;
336
+ self.rowColorChange();
337
+ }
338
+ self.$emit('searchComplate');
339
+ }
340
+ self.tableLoading = true;
341
+ this.model.getPage(index, next);
342
+ },
343
+ toSort(ev, col, action) {
344
+ var self = this;
345
+ this.model.toSort(col, action, () => {
346
+ self.$forceUpdate();
347
+ self.getScrollAttr();
348
+ });
349
+ ev.cancelBubble = true;
350
+ ev.stopPropagation();
351
+ },
352
+ clearSort(ev, col) {
353
+ var self = this;
354
+ this.model.clearSort(col, () => {
355
+ self.$forceUpdate();
356
+ self.getScrollAttr();
357
+ });
358
+ ev.cancelBubble = true;
359
+ ev.stopPropagation();
360
+ },
361
+ fiexdHead() {
362
+ this.$nextTick(() => {
363
+ var self = this;
364
+ var tableCont = this.$refs.tableParent;
365
+ function scrollHandle(e) {
366
+ self.getScrollAttr();
367
+ }
368
+ tableCont.addEventListener('scroll', self.getScrollAttr);
369
+ });
370
+ },
371
+ removeScrollEvent() {
372
+ var tableCont = this.$refs.tableParent;
373
+ //移除事件监听器
374
+ tableCont.removeEventListener("scroll", this.getScrollAttr, false);
375
+ //tableCont.removeEventListener("scroll", this.scrollHandle, false);
376
+ },
377
+ addScrollEvent() {
378
+ var tableCont = this.$refs.tableParent;
379
+ //添加事件监听器
380
+ tableCont.addEventListener("scroll", this.getScrollAttr, false);
381
+ },
382
+ freezeData() {
383
+ Object.freeze(this.model.listData);
384
+ },
385
+ setfixedSize() {
386
+ if (typeof this.$refs.headTr !== 'undefined' && this.$refs.headTr.length > 0) {
387
+ let fixedSize = 0;
388
+ let j = 0;
389
+ let fixationThArr = this.$refs.headTr[0].getElementsByClassName('left-fixation-th');
390
+ if (fixationThArr.length > 0) {
391
+ if (this.model.isMulti) {
392
+ fixedSize = fixationThArr[j++].offsetWidth
393
+ }
394
+ for (let i = 0; i < this.model.columns.length; i++) {
395
+ if (this.model.columns[i].fixed === 'left' && this.model.columns[i].show) {
396
+ this.model.columns[i].fixedSize = fixedSize;
397
+ fixedSize = fixedSize + fixationThArr[j++].offsetWidth;
398
+ }
399
+ }
400
+
401
+ fixedSize = 0;
402
+ fixationThArr = this.$refs.headTr[0].getElementsByClassName('right-fixation-th');
403
+ j = fixationThArr.length - 1;
404
+ for (let i = this.model.columns.length - 1; i > 0; i--) {
405
+ if (this.model.columns[i].fixed === 'right' && this.model.columns[i].show) {
406
+ this.model.columns[i].fixedSize = fixedSize;
407
+ fixedSize = fixedSize + fixationThArr[j--].offsetWidth;
408
+ }
409
+ }
410
+ }
411
+ }
412
+ },
413
+ getScrollAttr(e) {
414
+ if (typeof this.$refs.tableParent !== 'undefined' && typeof this.$refs.headThs !== 'undefined') {
415
+
416
+ this.calculatingRowHeight();
417
+
418
+ var scrollTop = this.$refs.tableParent.scrollTop;
419
+ var scrollLeft = this.$refs.tableParent.scrollLeft;
420
+ var scrollRight = this.$refs.tableParent.scrollWidth - scrollLeft - this.$refs.tableParent.clientWidth;
421
+
422
+ //计算可视范围的第一条数据
423
+ let index = 0;
424
+ let topHeigth = 0;
425
+ for (; index < this.model.listData.length; index++) {
426
+ if (topHeigth >= scrollTop) {
427
+ break;
428
+ }
429
+ else {
430
+ topHeigth = topHeigth + this.model.listData[index].$heigth;
431
+ }
432
+ }
433
+ this.firstRow = index - 1;
434
+ this.setTrLazyLoading();
435
+ //若每行高度是固定的,可直接使用下面方法即可
436
+ //this.firstRow = parseInt(scrollTop / 33);
437
+
438
+ this.scrollTop = scrollTop;
439
+ this.scrollLeft = scrollLeft;
440
+ this.scrollRight = scrollRight;
441
+ }
442
+ },
443
+ setTrLazyLoading() {
444
+ this.pageRowMax = this.firstRow + this.displayRowNumber;
445
+ this.pageRowMin = this.firstRow - this.displayRowNumber;
446
+ if (this.pageRowMin > 0 && this.model.listData[this.pageRowMin].$rowspan === 0) {
447
+ for (let i = this.pageRowMin; i >= 0; i--) {
448
+ if (this.model.listData[i].$rowspan > 0) {
449
+ this.pageRowMin = i;
450
+ break;
451
+ }
452
+ }
453
+ }
454
+
455
+ //debugger
456
+ //let index = this.model.listData.length - 1;
457
+ //let isSet = false;
458
+ //for (; index >= 0; index--) {
459
+ // if (Math.abs(index - this.firstRow) < this.displayRowNumber || typeof (this.model.listData[index].$heigth) === 'undefined') {
460
+ // //this.$set(this.model.listData[index], "$trLazyLoadingShow", true);
461
+ // }
462
+ // else {
463
+ // if (index < this.firstRow && !isSet) {
464
+ // if (this.model.listData[index].$rowspan === 0) {
465
+ // this.$set(this.model.listData[index], "$trLazyLoadingShow", true);
466
+ // continue;
467
+ // }
468
+ // else {
469
+ // isSet = true;
470
+ // this.$set(this.model.listData[index], "$trLazyLoadingShow", true);
471
+ // continue;
472
+ // }
473
+ // }
474
+ // this.$set(this.model.listData[index], "$trLazyLoadingShow", false);
475
+ // }
476
+ //}
477
+ },
478
+ setTableHeight() {
479
+ var self = this;
480
+ this.$nextTick(() => {
481
+ if (this.$refs.searchTable && this.$refs.toolbar && this.$refs.searchTable.parentElement) {
482
+ var h1 = this.$refs.searchTable.parentElement.offsetHeight | 0;
483
+ var h2 = this.$refs.searchTable.offsetTop | 0;
484
+ var h3 = this.$refs.toolbar.$el.offsetHeight | 0;
485
+ var h4 = this.$refs.footer.$el.offsetHeight | 0;
486
+ var h5 = this.$refs.listHeader.$el.offsetHeight | 0;
487
+ var h6 = this.$refs.listFooter.$el.offsetHeight | 0;
488
+ let tableHeight = h1 - h2 - h3 - h4 - h5 - h6 - 22;
489
+ this.model.tableHeight = tableHeight < 40 ? 350 : tableHeight;
490
+ this.$nextTick(() => {
491
+ self.getScrollAttr();
492
+ });
493
+ }
494
+ });
495
+ },
496
+ scrollHandle(ev) {
497
+ var self = this;
498
+ if ((this.$refs.tableParent.scrollTop + this.$refs.tableParent.clientHeight) >= (this.$refs.tableParent.scrollHeight - 5)) {
499
+ if (!this.isBusy) {
500
+ self.isBusy = true;
501
+ self.tableLoading = true;
502
+ self.model.nextPage((rtn) => {
503
+ if (rtn) {
504
+ self.$nextTick(() => {
505
+ self.calculatingRowHeight();
506
+ self.getScrollAttr();
507
+
508
+ });
509
+ self.$forceUpdate();
510
+ }
511
+ self.isBusy = false;
512
+ self.tableLoading = false;
513
+ });
514
+ }
515
+ }
516
+ ev.cancelBubble = true;
517
+ ev.stopPropagation();
518
+ },
519
+ rowClickHandle(ev, index) {
520
+ this.model.selectIndex = index;
521
+ this.rowColorChange();
522
+ ev.cancelBubble = true;
523
+ ev.stopPropagation();
524
+ },
525
+ rowColorChange() {
526
+ var index = this.model.selectIndex;
527
+ if (typeof this.$refs['rows.' + index] !== "undefined" && this.currentRow !== this.$refs['rows.' + index][0]) {
528
+ if (this.currentRow !== null) {
529
+ for (var i = 0; i < this.currentRow.children.length; i++) {
530
+ this.currentRow.children[i].classList.remove('select');
531
+ }
532
+ }
533
+ if(this.$refs['rows.' + index][0])
534
+ {
535
+ for (var j = 0; j < this.$refs['rows.' + index][0].children.length; j++) {
536
+ this.$refs['rows.' + index][0].children[j].classList.add('select');
537
+ }
538
+ }
539
+ this.currentRow = this.$refs['rows.' + index][0]||null;
540
+ }
541
+ },
542
+ resetScroll: function () {
543
+ var self = this;
544
+ if (self.$refs.tableParent.scrollTop > self.$refs['rows.' + self.model.selectIndex][0].offsetTop - self.$refs.tableHead.offsetHeight) {
545
+ self.$refs.tableParent.scrollTop = self.$refs['rows.' + self.model.selectIndex][0].offsetTop - self.$refs.tableHead.offsetHeight;
546
+ }
547
+ if (self.$refs.tableParent.scrollTop + self.$refs.tableParent.clientHeight <= self.$refs['rows.' + self.model.selectIndex][0].offsetTop + self.$refs['rows.' + self.model.selectIndex][0].offsetHeight) {
548
+ self.$refs.tableParent.scrollTop = self.$refs['rows.' + self.model.selectIndex][0].offsetTop - self.$refs.tableParent.clientHeight + self.$refs['rows.' + self.model.selectIndex][0].offsetHeight;
549
+ }
550
+ self.scrollTop = self.$refs.tableParent.scrollTop;
551
+ },
552
+ rowKeyDownHandle(ev, action) {
553
+ var self = this;
554
+ if (action === 1) {
555
+ this.model.downKey();
556
+ }
557
+ else {
558
+ this.model.upKey();
559
+ }
560
+ this.rowColorChange();
561
+ this.resetScroll();
562
+ if (!this.isBusy) {
563
+ if (this.model.selectIndex === this.model.listData.length - 1) {
564
+ self.isBusy = true;
565
+ self.tableLoading = true;
566
+ self.model.nextPage((rtn) => {
567
+ if (rtn) {
568
+ self.$nextTick(() => {
569
+ self.calculatingRowHeight();
570
+ self.getScrollAttr();
571
+ });
572
+ self.$forceUpdate();
573
+ }
574
+ self.isBusy = false;
575
+ self.tableLoading = false;
576
+ });
577
+ }
578
+ }
579
+ ev.cancelBubble = true;
580
+ ev.stopPropagation();
581
+ ev.preventDefault();
582
+ },
583
+ searchComplate(m, defaultSearch) {
584
+ var self = this;
585
+ this.$nextTick(function () {
586
+ if (typeof this.api !== 'undefined') {
587
+ self.loaderObj.SearchTable(self.api, self.load, m, defaultSearch);
588
+ }
589
+ if (typeof this.source !== 'undefined') {
590
+ self.load(self.loaderObj.SearchTable(self.source));
591
+ }
592
+ if (typeof self.vmodel !== 'undefined') {
593
+ self.load(self.vmodel);
594
+ }
595
+ });
596
+ },
597
+ toolbarClickHandler(field) {
598
+ let self = this;
599
+ let submitData = {};
600
+ let action = field.action;
601
+
602
+ var tempListData = self.model.getSelectRowData(field);
603
+ if (tempListData != null) {
604
+ field.submitListField.forEach((k) => {
605
+ if (field.isMulti) {
606
+ submitData[k] = [];
607
+ for (var ri = 0; ri < tempListData.length; ri++) {
608
+ submitData[k].push(tempListData[ri][k]);
609
+ }
610
+ }
611
+ else {
612
+ submitData[k] = tempListData[0][k];
613
+ }
614
+ });
615
+
616
+ if (field.isSingle && tempListData.length > 0 && field.actionField) {
617
+ action = tempListData[0][field.actionField];
618
+ }
619
+ }
620
+
621
+ if (field.flagAttachSearchCondition) {
622
+ submitData['searchFields'] = self.model.searchModel.searchData;
623
+ }
624
+
625
+ //如果是导出按钮,则直接交给父组件处理
626
+ if (field.isExport) {
627
+ self.$emit('toolbarClick', field, submitData);
628
+ return;
629
+ }
630
+
631
+ this.routerClickHandler(field, submitData, action);
632
+ },
633
+ rolRouterClickHandler(field, rowData) {
634
+ var self = this;
635
+ var submitData = {};
636
+ field.submitListField.forEach((k) => {
637
+ submitData[k] = rowData[k];
638
+ });
639
+
640
+ let action = field.action;
641
+ if (field.actionField) {
642
+ action = rowData[field.actionField];
643
+ }
644
+
645
+ this.routerClickHandler(field, submitData, action);
646
+ },
647
+ routerClickHandler(field, submitData, action) {
648
+ let self = this;
649
+ action = action || field.action;
650
+
651
+ var clickAcion = function () {
652
+ //若不是客户端方法,则直接访问接口
653
+ if (!field.isClientFuntion) {
654
+ // 外部框架tab页打开
655
+ if (field.isFormPageInTab || field.isSearchPageInTab) {
656
+ submitData = field.getActionPara(submitData).para;
657
+ if (field.pageStyle) {
658
+ submitData.pageStyle = field.pageStyle;
659
+ }
660
+ self.$common.getDataDrivenOpts().handler.openTab(action, submitData, field.pageTitle, self.model);
661
+ }
662
+ else if (field.isBrowserNewTab) {// 浏览器打开
663
+ submitData = field.getActionPara(submitData).para;
664
+ let query = self.$common.objectToQueryStr(submitData);
665
+ window.open(action + query, "_blank");
666
+ }
667
+ else {
668
+ //self.operationLoading = true;
669
+
670
+ //Form
671
+ if (field.isOpenForm) {
672
+ var dialogOption = {
673
+ title: field.pageTitle,
674
+ pane: self.$common.getParentPane(self),
675
+ content: [{
676
+ component: field.navToNewPageName,
677
+ attrs: {
678
+ //source: data.content,
679
+ api: action,
680
+ apiParam: field.getActionPara(submitData).para,
681
+ showTitle: false,
682
+ width: field.dialogWidth + 'px',
683
+ height: field.dialogHeight + 'px'
684
+ },
685
+ on: {
686
+ submit(ev) {
687
+ if (!field.flagFreshCurrentRow) {
688
+ self.model.doAction(ev);
689
+ }
690
+ self.$forceUpdate();
691
+ self.$refs.footer.$forceUpdate();
692
+ self.$common.closeDialog(dialogOption.dialog);
693
+ self.updateCurrentRow(field);
694
+ },
695
+ refreshParent() {
696
+ self.getPage(1);
697
+ self.$common.closeDialog(dialogOption.dialog);
698
+ },
699
+ closeDialog() {
700
+ self.updateCurrentRow(field);
701
+ }
702
+ }
703
+ }]
704
+ };
705
+ self.$common.openDialog(dialogOption);
706
+ }
707
+ //SearchList
708
+ else if (field.isOpenList) {
709
+ var dialogOption = {
710
+ title: field.pageTitle,
711
+ pane: self.$common.getParentPane(self),
712
+ content: [{
713
+ component: field.navToNewPageName,
714
+ attrs: {
715
+ searchConditionApi: field.actionForSearchLayout,
716
+ searchDataApi: field.actionForSearch,
717
+ apiParam: submitData,
718
+ width: field.dialogWidth + 'px',
719
+ height: field.dialogHeight + 'px'
720
+ },
721
+ on: {
722
+ refreshParent() {
723
+ self.getPage(1);
724
+ self.$common.closeDialog(dialogOption.dialog);
725
+ },
726
+ closeDialog() {
727
+ self.updateCurrentRow(field);
728
+ }
729
+ }
730
+ }]
731
+ };
732
+ self.$common.openDialog(dialogOption);
733
+ }
734
+ //Tabs
735
+ else if (field.isOpenTabs) {
736
+ var dialogOption = {
737
+ title: field.pageTitle,
738
+ pane: self.$common.getParentPane(self),
739
+ content: [{
740
+ component: field.navToNewPageName,
741
+ attrs: {
742
+ searchConditionApi: field.actionForSearchLayout,
743
+ searchDataApi: field.actionForSearch,
744
+ apiParam: submitData,
745
+ width: field.dialogWidth + 'px',
746
+ height: field.dialogHeight + 'px'
747
+ },
748
+ on: {
749
+ }
750
+ }]
751
+ };
752
+ self.$common.openDialog(dialogOption);
753
+ }
754
+ else {
755
+ self.operationLoading = true;
756
+ field.doAction(submitData, (data) => {
757
+ self.operationLoading = false;
758
+ self.model.doAction({ responseData: data });
759
+ self.$forceUpdate();
760
+ self.$refs.footer.$forceUpdate();
761
+ })
762
+ }
763
+ }
764
+ }
765
+ //执行客户端脚本
766
+ else {
767
+ // let parm={submitData:submitData,field:field}
768
+ // self.$common.excuteFunStr.call(self.model.scripts, field.action,parm);
769
+ let title=field.pageTitle==undefined ?field.label:field.pageTitle;
770
+ submitData.actionType=field.actionType;
771
+ var fun =self.$common.getDataDrivenOpts().handler[action];
772
+ fun(submitData,title,self.model);
773
+ // var fun = self.model.scripts.formData[action];
774
+ // fun(submitData,field);
775
+ }
776
+ }
777
+
778
+ if (field.alert) {
779
+ self.$common.confirm(field.alertMsg, field.alertCaption, {
780
+ confirmButtonText: field.alertOKButtonText,
781
+ cancelButtonText: field.alertCancelButtonText,
782
+ //type: 'warning'
783
+ center: field.alertCenter
784
+ }).then(() => {
785
+ clickAcion();
786
+ }).catch(() => {
787
+ });
788
+ }
789
+ else {
790
+ clickAcion();
791
+ }
792
+ },
793
+ selectAll($ev) {
794
+ this.model.listData.forEach((ro) => {
795
+ if (!this.model.rightMulti || ro[this.model.rightMulti] == 1) {
796
+ ro.$select = $ev.srcElement.checked;
797
+ }
798
+ });
799
+ this.model.setButtonsDisabled();
800
+ this.$forceUpdate();
801
+ },
802
+ selectOne($ev) {
803
+ this.model.setButtonsDisabled();
804
+ },
805
+ calculatingRowHeight() {
806
+ let self = this;
807
+ let count = 0;
808
+
809
+ //查询出所有没有设置$heigth的数据并重新设置$heigth
810
+ let notHeigthData = self.model.listData.filter(item => {
811
+ return item.$heigth === undefined || item.$heigth <= 0
812
+ })
813
+ if (notHeigthData && notHeigthData.length > 0) {
814
+ notHeigthData.forEach((v, i) => {
815
+ if (self.$refs["rows." + i] && self.$refs["rows." + i].length > 0) {
816
+ self.$set(v, "$heigth", self.$refs["rows." + i][0].clientHeight);
817
+ }
818
+ });
819
+ }
820
+
821
+ //for (let i = 0; i < self.model.listData.length; i++) {
822
+ // if (self.$refs[]) {
823
+ // }
824
+ //}
825
+ //self.$refs
826
+ },
827
+ updateCurrentRow(router) {
828
+ let self = this;
829
+ if (router.flagFreshCurrentRow) {
830
+ self.tableComplate = true;
831
+ self.model.getCurrentRowApiData(function () {
832
+ self.$forceUpdate();
833
+ self.tableComplate = false;
834
+ });
835
+ }
836
+ },
837
+ importComplete(res) {
838
+ this.model.doAction(res);
839
+ },
840
+ tdRowspan(column, row) {
841
+ if (!column.show) {
842
+ return '';
843
+ }
844
+
845
+ //合并行
846
+ if (row.$rowspan !== 0 && this.model.rowMergedColumns.indexOf(column.id) > -1) {
847
+ return row.$rowspan;
848
+ }
849
+
850
+ return '';
851
+ },
852
+ tdShow(column, row) {
853
+ if (!column.show) {
854
+ return false;
855
+ }
856
+
857
+ //合并行
858
+ if (row.$rowspan === 0 && this.model.rowMergedColumns.indexOf(column.id) > -1) {
859
+ return false;
860
+ }
861
+
862
+ return true;
863
+ },
864
+ closeTabThen(ev) {
865
+ let self = this;
866
+ if (self.model.checkCloseTabThen(ev.notification)) {
867
+ self.model.doAction(ev);
868
+ self.$forceUpdate();
869
+ self.$refs.footer.$forceUpdate();
870
+ }
871
+ }
872
+ },
873
+ }</script>
874
+ <style>
875
+ .ct-tableParent {
876
+ overflow: auto;
877
+ border-bottom: 1px solid #ebeef5;
878
+ width: 100%;
879
+ outline: 0;
880
+ }
881
+
882
+ .ct-searchtable .ct-table {
883
+ min-width: 100%;
884
+ }
885
+
886
+ .ct-searchtable .ct-table th {
887
+ background-color: #f4f7fa !important;
888
+ border-top: 1px solid #ebeef5;
889
+ }
890
+
891
+ .ct-searchtable .ct-tr > .ct-td {
892
+ /*border: 1px solid #e7e8eb;*/
893
+ border-bottom: 1px solid #e7e8eb;
894
+ /*border-right: 1px solid #e7e8eb;
895
+ border-left: 1px solid #e7e8eb;*/
896
+ padding: 2px 20px;
897
+ cursor: default;
898
+ background-color: #ffffff;
899
+ }
900
+
901
+ .shadowLeft {
902
+ border-right: 1px solid #e7e8eb;
903
+ box-shadow: 2px 0 3px -1px rgba(0,0,0,0.1);
904
+ }
905
+
906
+ .shadowRight {
907
+ box-shadow: -2px 0 3px -1px rgba(0,0,0,0.1);
908
+ }
909
+
910
+ .ct-searchtable body:last-child > .ct-td {
911
+ border-bottom: 0px;
912
+ }
913
+
914
+ .ct-searchtable .ct-tr > .ct-td.nowidth {
915
+ white-space: nowrap;
916
+ }
917
+ /*.ct-searchtable tbody .ct-tr:hover .ct-td {
918
+ background-color: #ebeef5 !important;
919
+ }*/
920
+
921
+ .ct-table {
922
+ color: #606266;
923
+ font-size: 18px;
924
+ line-height: 40px;
925
+ min-height: 40px;
926
+ }
927
+
928
+ .ct-table-mini {
929
+ font-size: 12px;
930
+ line-height: 26px;
931
+ min-height: 28px;
932
+ }
933
+
934
+ .ct-table-small {
935
+ font-size: 14px;
936
+ line-height: 32px;
937
+ min-height: 32px;
938
+ }
939
+
940
+ .ct-table-medium {
941
+ font-size: 16px;
942
+ line-height: 36px;
943
+ min-height: 36px;
944
+ }
945
+
946
+ .ct-table .ct-td > .caret-wrapper {
947
+ display: inline-flex;
948
+ flex-direction: column;
949
+ align-items: center;
950
+ height: 34px;
951
+ width: 10px;
952
+ vertical-align: middle;
953
+ cursor: pointer;
954
+ overflow: initial;
955
+ position: relative;
956
+ }
957
+
958
+ .ct-table .ct-td > .caret-wrapper > .sort-caret {
959
+ width: 0;
960
+ height: 0;
961
+ border: 5px solid transparent;
962
+ position: absolute;
963
+ left: 7px;
964
+ }
965
+
966
+ .ct-table .ct-td > .caret-wrapper > .sort-caret.ascending {
967
+ border-bottom-color: #c0c4cc;
968
+ top: 5px;
969
+ }
970
+
971
+ .ct-table .ct-td > .caret-wrapper > .sort-caret.descending {
972
+ border-top-color: #c0c4cc;
973
+ bottom: 7px;
974
+ }
975
+
976
+ .ct-table .ct-td.select {
977
+ background-color: #ecf5ff !important;
978
+ }
979
+
980
+ .ct-table .ct-tr:hover .ct-td.select {
981
+ background-color: #ecf5ff !important;
982
+ }
983
+
984
+ .ct-table .ct-td.asc > .caret-wrapper > .sort-caret.ascending {
985
+ border-bottom-color: #409eff;
986
+ top: 5px;
987
+ }
988
+
989
+ .ct-table .ct-td.desc > .caret-wrapper > .sort-caret.descending {
990
+ border-top-color: #409eff;
991
+ bottom: 7px;
992
+ }
993
+
994
+
995
+ .ct-table .cell {
996
+ /*white-space: nowrap;*/
997
+ text-overflow: ellipsis;
998
+ /*min-width: 50px; todo 实际宽度-21即可*/
999
+ overflow: hidden;
1000
+ /*padding-right: 10px;*/
1001
+ }
1002
+
1003
+ /*强制换行 todo 可去掉改成强制不换行*/
1004
+ .ct-table .cell {
1005
+ /* 这两个在技术上是一样的, 为了兼容了浏览器两个都加上 */
1006
+ overflow-wrap: break-word;
1007
+ word-wrap: break-word;
1008
+ -ms-word-break: break-all;
1009
+ /* 这个的使用在web-kit中有些危险,他可能会阶段所有东西 */
1010
+ word-break: break-all;
1011
+ /* Instead use this non-standard one: */
1012
+ word-break: break-word;
1013
+ /* 如果浏览器支持的话增加一个连接符(Blink不支持) */
1014
+ -ms-hyphens: auto;
1015
+ -moz-hyphens: auto;
1016
+ -webkit-hyphens: auto;
1017
+ hyphens: auto;
1018
+ }
1019
+
1020
+ .ct-table .lineFeedCell {
1021
+ min-width: 40px;
1022
+ /*padding-right: 10px;*/
1023
+ }
1024
+
1025
+ /*.ct-table .cell.ct-tooltip:hover {
1026
+ text-overflow: inherit;
1027
+ overflow: visible;
1028
+ }*/
1029
+
1030
+ .ct-table .left-fixation {
1031
+ position: sticky;
1032
+ }
1033
+
1034
+ .ct-table .right-fixation {
1035
+ position: sticky;
1036
+ }
1037
+
1038
+ .ct-table .left-fixation-th {
1039
+ position: sticky;
1040
+ top: 0px;
1041
+ z-index: 99;
1042
+ }
1043
+
1044
+ .ct-table .right-fixation-th {
1045
+ position: sticky;
1046
+ top: 0px;
1047
+ z-index: 99;
1048
+ }
1049
+
1050
+ .ct-table .right-no-fixation-th {
1051
+ position: sticky;
1052
+ top: 0px;
1053
+ z-index: 50;
1054
+ }
1055
+
1056
+ .ct-table .ct-searchtable-th {
1057
+ /*text-align: center*/
1058
+ }
1059
+
1060
+ .ct-table .checkbox-td {
1061
+ min-width: 20px;
1062
+ width: 20px;
1063
+ left: 0px;
1064
+ }
1065
+
1066
+ .ct-table .checkbox-td .checkbox-td-1 {
1067
+ vertical-align: inherit;
1068
+ }
1069
+ </style>