@@ -173,15 +173,54 @@ export default {
173173 }
174174 }
175175 return result ;
176- }
177- } ,
178- methods : {
176+ } ,
177+
178+ /*
179+ * @bodyTdStyle
180+ * @desc body td style
181+ */
182+ bodyTdStyle ( ) {
183+ const { key, align, fixed } = this . column ;
184+
185+ let result = { } ;
186+
187+ const { colgroups, column } = this ;
188+
189+ // text align
190+ result [ "text-align" ] = align || "center" ;
191+
192+ // fixed left total width or right total width
193+ if ( fixed ) {
194+ let totalWidth = 0 ;
195+ // column index
196+ const columnIndex = colgroups . findIndex ( x => x . key === key ) ;
197+ if (
198+ ( fixed === "left" && columnIndex > 0 ) ||
199+ ( fixed === "right" && columnIndex < colgroups . length - 1 )
200+ ) {
201+ totalWidth = getFixedTotalWidthByColumnKey (
202+ colgroups ,
203+ key ,
204+ fixed
205+ ) ;
206+
207+ totalWidth = getValByUnit ( totalWidth ) ;
208+ }
209+
210+ result [ "left" ] = fixed === "left" ? totalWidth : "" ;
211+ result [ "right" ] = fixed === "right" ? totalWidth : "" ;
212+ }
213+
214+ return result ;
215+ } ,
216+
179217 /*
180- * @getBodyTdClass
181- * @desc get body td class
182- * @param {string } fixed - 固定方式
218+ * @bodyTdClass
219+ * @desc body td class
183220 */
184- getBodyTdClass ( { fixed } ) {
221+ bodyTdClass ( ) {
222+ const { fixed } = this . column ;
223+
185224 let result = {
186225 [ clsName ( "body-td" ) ] : true
187226 } ;
@@ -234,48 +273,9 @@ export default {
234273 }
235274
236275 return result ;
237- } ,
238-
239- /*
240- * @getBodyTdStyle
241- * @desc get body td style
242- * @param {any } key - column key
243- * @param {string } align - 居中方式
244- * @param {bool } fixed - 固定方式
245- */
246- getBodyTdStyle ( { key, align, fixed } ) {
247- let result = { } ;
248-
249- const { colgroups, column } = this ;
250-
251- // text align
252- result [ "text-align" ] = align || "center" ;
253-
254- // fixed left total width or right total width
255- if ( fixed ) {
256- let totalWidth = 0 ;
257- // column index
258- const columnIndex = colgroups . findIndex ( x => x . key === key ) ;
259- if (
260- ( fixed === "left" && columnIndex > 0 ) ||
261- ( fixed === "right" && columnIndex < colgroups . length - 1 )
262- ) {
263- totalWidth = getFixedTotalWidthByColumnKey (
264- colgroups ,
265- key ,
266- fixed
267- ) ;
268-
269- totalWidth = getValByUnit ( totalWidth ) ;
270- }
271-
272- result [ "left" ] = fixed === "left" ? totalWidth : "" ;
273- result [ "right" ] = fixed === "right" ? totalWidth : "" ;
274- }
275-
276- return result ;
277- } ,
278-
276+ }
277+ } ,
278+ methods : {
279279 // get ellipsis content style
280280 getEllipsisContentStyle ( ) {
281281 let result = { } ;
@@ -531,8 +531,8 @@ export default {
531531
532532 // td props
533533 const tdProps = {
534- class : this . getBodyTdClass ( column ) ,
535- style : this . getBodyTdStyle ( column ) ,
534+ class : this . bodyTdClass ,
535+ style : this . bodyTdStyle ,
536536 attrs : {
537537 rowspan,
538538 colspan
0 commit comments