优化列宽
Showing
3 changed files
with
10 additions
and
9 deletions
| ... | @@ -5,14 +5,14 @@ export function resolveRoutePath(basePath: string, routePath?: string) { | ... | @@ -5,14 +5,14 @@ export function resolveRoutePath(basePath: string, routePath?: string) { |
| 5 | } | 5 | } |
| 6 | 6 | ||
| 7 | /** 计算表格列宽 */ | 7 | /** 计算表格列宽 */ |
| 8 | export const calcColumnWidth = (data, title, dataFont, titleFont, otherWidth = 0) => { | 8 | export const calcColumnWidth = (data, title, dataFont, titleFont, otherWidth = 0, minWidth = 96) => { |
| 9 | let titleW = measureTextWidth(title, titleFont || dataFont); | 9 | let titleW = measureTextWidth(title, titleFont || dataFont); |
| 10 | if (!data.length) { | 10 | if (!data.length) { |
| 11 | if (titleW + otherWidth > 260) { | 11 | if (titleW + otherWidth > 260) { |
| 12 | return 260; | 12 | return 260; |
| 13 | } | 13 | } |
| 14 | if (titleW + otherWidth + 32 < 96) { | 14 | if (titleW + otherWidth + 32 < minWidth) { |
| 15 | return 96; | 15 | return minWidth; |
| 16 | } | 16 | } |
| 17 | return titleW + 32 + otherWidth;//20边距,+2px边框 + 10px间隙 | 17 | return titleW + 32 + otherWidth;//20边距,+2px边框 + 10px间隙 |
| 18 | } | 18 | } |
| ... | @@ -32,8 +32,8 @@ export const calcColumnWidth = (data, title, dataFont, titleFont, otherWidth = 0 | ... | @@ -32,8 +32,8 @@ export const calcColumnWidth = (data, title, dataFont, titleFont, otherWidth = 0 |
| 32 | if (titleW + otherWidth > maxWidth) { | 32 | if (titleW + otherWidth > maxWidth) { |
| 33 | maxWidth = titleW + otherWidth; | 33 | maxWidth = titleW + otherWidth; |
| 34 | } | 34 | } |
| 35 | if (maxWidth + 32 < 96) { | 35 | if (maxWidth + 32 < minWidth) { |
| 36 | return 96; | 36 | return minWidth; |
| 37 | } | 37 | } |
| 38 | return maxWidth + 32; | 38 | return maxWidth + 32; |
| 39 | } | 39 | } | ... | ... |
| ... | @@ -136,7 +136,8 @@ const calcTableColumnWidth = (data: any[], prop, title, otherWidth = 0) => { | ... | @@ -136,7 +136,8 @@ const calcTableColumnWidth = (data: any[], prop, title, otherWidth = 0) => { |
| 136 | fontSize: 14, | 136 | fontSize: 14, |
| 137 | fontFamily: "SimSun", | 137 | fontFamily: "SimSun", |
| 138 | }, | 138 | }, |
| 139 | otherWidth | 139 | otherWidth, |
| 140 | 70 | ||
| 140 | ); | 141 | ); |
| 141 | }; | 142 | }; |
| 142 | 143 | ||
| ... | @@ -156,7 +157,7 @@ watch( | ... | @@ -156,7 +157,7 @@ watch( |
| 156 | val?.slice(0, 30) || [], | 157 | val?.slice(0, 30) || [], |
| 157 | field.field, | 158 | field.field, |
| 158 | field.label, | 159 | field.label, |
| 159 | 24 | 160 | 10 |
| 160 | ); | 161 | ); |
| 161 | }); | 162 | }); |
| 162 | }, | 163 | }, | ... | ... |
| ... | @@ -249,9 +249,9 @@ function getTableFields () { | ... | @@ -249,9 +249,9 @@ function getTableFields () { |
| 249 | 'length': 100, | 249 | 'length': 100, |
| 250 | // 'inside_identifier': 100, | 250 | // 'inside_identifier': 100, |
| 251 | 'indicate_format': 110, | 251 | 'indicate_format': 110, |
| 252 | 'other_data_relationship': 150, | 252 | 'other_data_relationship': 159, |
| 253 | 'unit': 100, | 253 | 'unit': 100, |
| 254 | 'meta_data_type': 150, | 254 | 'meta_data_type': 156, |
| 255 | 'definition': 300, | 255 | 'definition': 300, |
| 256 | 'explanation': 300 | 256 | 'explanation': 300 |
| 257 | } | 257 | } | ... | ... |
-
Please register or sign in to post a comment