增加注释
Showing
2 changed files
with
102 additions
and
13 deletions
... | @@ -52,6 +52,10 @@ export default { | ... | @@ -52,6 +52,10 @@ export default { |
52 | LbRender | 52 | LbRender |
53 | }, | 53 | }, |
54 | methods: { | 54 | methods: { |
55 | /** | ||
56 | * @description: setColumn | ||
57 | * @author: renchao | ||
58 | */ | ||
55 | setColumn () { | 59 | setColumn () { |
56 | if (this.column.type) { | 60 | if (this.column.type) { |
57 | this.column.renderHeader = forced[this.column.type].renderHeader | 61 | this.column.renderHeader = forced[this.column.type].renderHeader | ... | ... |
1 | /* | 1 | /* |
2 | * FileName: lb-table.vue | 2 | * FileName: lb-table.vue |
3 | * Remark: element table | 3 | * Remark: element table |
4 | * Project: lb-element-table | 4 | * Project: lb-element-table |
5 | * Author: 任超 | 5 | * Author: 任超 |
6 | * File Created: Tuesday, 19th March 2019 9:55:27 am | 6 | * File Created: Tuesday, 19th March 2019 9:55:27 am |
7 | * Last Modified: Tuesday, 19th March 2019 9:55:34 am | 7 | * Last Modified: Tuesday, 19th March 2019 9:55:34 am |
8 | * Modified By: 任超 | 8 | * Modified By: 任超 |
9 | */ | 9 | */ |
10 | 10 | ||
11 | <template> | 11 | <template> |
12 | <div :class="['lb-table', customClass]"> | 12 | <div :class="['lb-table', customClass]"> |
13 | <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable" :border='border' | 13 | <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable" :border='border' |
14 | :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection" v-bind="$attrs" | 14 | :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection" v-bind="$attrs" |
15 | :height="tableHeight" v-on="$listeners" :data="data" style="width: 100%" | 15 | :height="tableHeight" v-on="$listeners" :data="data" style="width: 100%" |
16 | :span-method="this.merge ? this.mergeMethod : this.spanMethod"> | 16 | :span-method="this.merge ? this.mergeMethod : this.spanMethod"> |
17 | <el-table-column width="45" align="center" v-if="isRadio"> | 17 | <el-table-column width="45" align="center" v-if="isRadio"> |
18 | <template slot-scope="scope"> | 18 | <template slot-scope="scope"> |
19 | <el-radio v-model="selected" :label="scope.$index"></el-radio> | 19 | <el-radio v-model="selected" :label="scope.$index"></el-radio> |
... | @@ -27,8 +27,8 @@ | ... | @@ -27,8 +27,8 @@ |
27 | </el-table> | 27 | </el-table> |
28 | <br> | 28 | <br> |
29 | <el-pagination class="lb-table-pagination" v-if="pagination" v-bind="$attrs" v-on="$listeners" background | 29 | <el-pagination class="lb-table-pagination" v-if="pagination" v-bind="$attrs" v-on="$listeners" background |
30 | layout="total, prev, pager, next" @current-change="paginationCurrentChange" | 30 | layout="total, prev, pager, next" @current-change="paginationCurrentChange" |
31 | :style="{ 'margin-top': paginationTop, 'text-align': paginationAlign }"> | 31 | :style="{ 'margin-top': paginationTop, 'text-align': paginationAlign }"> |
32 | </el-pagination> | 32 | </el-pagination> |
33 | </div> | 33 | </div> |
34 | </template> | 34 | </template> |
... | @@ -112,15 +112,30 @@ export default { | ... | @@ -112,15 +112,30 @@ export default { |
112 | }, | 112 | }, |
113 | methods: { | 113 | methods: { |
114 | // 单选 | 114 | // 单选 |
115 | /** | ||
116 | * @description: 单选 | ||
117 | * @param {*} row | ||
118 | * @author: renchao | ||
119 | */ | ||
115 | singleElection (row) { | 120 | singleElection (row) { |
116 | this.selected = this.data.indexOf(row); | 121 | this.selected = this.data.indexOf(row); |
117 | }, | 122 | }, |
118 | 123 | ||
124 | /** | ||
125 | * @description: tableRowClassName | ||
126 | * @param {*} row | ||
127 | * @param {*} rowIndex | ||
128 | * @author: renchao | ||
129 | */ | ||
119 | tableRowClassName ({ row, rowIndex }) { | 130 | tableRowClassName ({ row, rowIndex }) { |
120 | if (rowIndex % 2 === 1) { | 131 | if (rowIndex % 2 === 1) { |
121 | return 'interlaced'; | 132 | return 'interlaced'; |
122 | } | 133 | } |
123 | }, | 134 | }, |
135 | /** | ||
136 | * @description: getHeight | ||
137 | * @author: renchao | ||
138 | */ | ||
124 | getHeight () { | 139 | getHeight () { |
125 | if (!this.heightNumSetting) { | 140 | if (!this.heightNumSetting) { |
126 | let _this = this | 141 | let _this = this |
... | @@ -137,6 +152,12 @@ export default { | ... | @@ -137,6 +152,12 @@ export default { |
137 | } | 152 | } |
138 | } | 153 | } |
139 | }, | 154 | }, |
155 | /** | ||
156 | * @description: calcHeightx | ||
157 | * @param {*} value | ||
158 | * @param {*} wappered | ||
159 | * @author: renchao | ||
160 | */ | ||
140 | calcHeightx (value, wappered = true) { | 161 | calcHeightx (value, wappered = true) { |
141 | //项目自定义的公共header部分的高度,可忽略 | 162 | //项目自定义的公共header部分的高度,可忽略 |
142 | let header = document.querySelector(".from-clues-header").offsetHeight; | 163 | let header = document.querySelector(".from-clues-header").offsetHeight; |
... | @@ -156,36 +177,91 @@ export default { | ... | @@ -156,36 +177,91 @@ export default { |
156 | } | 177 | } |
157 | return res; | 178 | return res; |
158 | }, | 179 | }, |
180 | /** | ||
181 | * @description: clearSelection | ||
182 | * @author: renchao | ||
183 | */ | ||
159 | clearSelection () { | 184 | clearSelection () { |
160 | this.$refs.elTable.clearSelection() | 185 | this.$refs.elTable.clearSelection() |
161 | }, | 186 | }, |
187 | /** | ||
188 | * @description: toggleRowSelection | ||
189 | * @param {*} row | ||
190 | * @param {*} selected | ||
191 | * @author: renchao | ||
192 | */ | ||
162 | toggleRowSelection (row, selected) { | 193 | toggleRowSelection (row, selected) { |
163 | this.$refs.elTable.toggleRowSelection(row, selected) | 194 | this.$refs.elTable.toggleRowSelection(row, selected) |
164 | }, | 195 | }, |
196 | /** | ||
197 | * @description: toggleAllSelection | ||
198 | * @author: renchao | ||
199 | */ | ||
165 | toggleAllSelection () { | 200 | toggleAllSelection () { |
166 | this.$refs.elTable.toggleAllSelection() | 201 | this.$refs.elTable.toggleAllSelection() |
167 | }, | 202 | }, |
203 | /** | ||
204 | * @description: toggleRowExpansion | ||
205 | * @param {*} row | ||
206 | * @param {*} expanded | ||
207 | * @author: renchao | ||
208 | */ | ||
168 | toggleRowExpansion (row, expanded) { | 209 | toggleRowExpansion (row, expanded) { |
169 | this.$refs.elTable.toggleRowExpansion(row, expanded) | 210 | this.$refs.elTable.toggleRowExpansion(row, expanded) |
170 | }, | 211 | }, |
212 | /** | ||
213 | * @description: setCurrentRow | ||
214 | * @param {*} row | ||
215 | * @author: renchao | ||
216 | */ | ||
171 | setCurrentRow (row) { | 217 | setCurrentRow (row) { |
172 | this.$refs.elTable.setCurrentRow(row) | 218 | this.$refs.elTable.setCurrentRow(row) |
173 | }, | 219 | }, |
220 | /** | ||
221 | * @description: clearSort | ||
222 | * @author: renchao | ||
223 | */ | ||
174 | clearSort () { | 224 | clearSort () { |
175 | this.$refs.elTable.clearSort() | 225 | this.$refs.elTable.clearSort() |
176 | }, | 226 | }, |
227 | /** | ||
228 | * @description: clearFilter | ||
229 | * @param {*} columnKey | ||
230 | * @author: renchao | ||
231 | */ | ||
177 | clearFilter (columnKey) { | 232 | clearFilter (columnKey) { |
178 | this.$refs.elTable.clearFilter(columnKey) | 233 | this.$refs.elTable.clearFilter(columnKey) |
179 | }, | 234 | }, |
235 | /** | ||
236 | * @description: doLayout | ||
237 | * @author: renchao | ||
238 | */ | ||
180 | doLayout () { | 239 | doLayout () { |
181 | this.$refs.elTable.doLayout() | 240 | this.$refs.elTable.doLayout() |
182 | }, | 241 | }, |
242 | /** | ||
243 | * @description: sort | ||
244 | * @param {*} prop | ||
245 | * @param {*} order | ||
246 | * @author: renchao | ||
247 | */ | ||
183 | sort (prop, order) { | 248 | sort (prop, order) { |
184 | this.$refs.elTable.sort(prop, order) | 249 | this.$refs.elTable.sort(prop, order) |
185 | }, | 250 | }, |
251 | /** | ||
252 | * @description: paginationCurrentChange | ||
253 | * @param {*} val | ||
254 | * @author: renchao | ||
255 | */ | ||
186 | paginationCurrentChange (val) { | 256 | paginationCurrentChange (val) { |
187 | this.$emit('p-current-change', val) | 257 | this.$emit('p-current-change', val) |
188 | }, | 258 | }, |
259 | /** | ||
260 | * @description: getMergeArr | ||
261 | * @param {*} tableData | ||
262 | * @param {*} merge | ||
263 | * @author: renchao | ||
264 | */ | ||
189 | getMergeArr (tableData, merge) { | 265 | getMergeArr (tableData, merge) { |
190 | if (!merge) return | 266 | if (!merge) return |
191 | this.mergeLine = {} | 267 | this.mergeLine = {} |
... | @@ -208,6 +284,14 @@ export default { | ... | @@ -208,6 +284,14 @@ export default { |
208 | }) | 284 | }) |
209 | }) | 285 | }) |
210 | }, | 286 | }, |
287 | /** | ||
288 | * @description: mergeMethod | ||
289 | * @param {*} row | ||
290 | * @param {*} column | ||
291 | * @param {*} rowIndex | ||
292 | * @param {*} columnIndex | ||
293 | * @author: renchao | ||
294 | */ | ||
211 | mergeMethod ({ row, column, rowIndex, columnIndex }) { | 295 | mergeMethod ({ row, column, rowIndex, columnIndex }) { |
212 | const index = this.merge.indexOf(column.property) | 296 | const index = this.merge.indexOf(column.property) |
213 | if (index > -1) { | 297 | if (index > -1) { |
... | @@ -249,3 +333,4 @@ export default { | ... | @@ -249,3 +333,4 @@ export default { |
249 | display: none; | 333 | display: none; |
250 | } | 334 | } |
251 | </style> | 335 | </style> |
336 | ... | ... |
-
Please register or sign in to post a comment