|
@@ -131,7 +131,8 @@ export default {
|
|
|
},
|
|
|
//国际化金融单位转换 10000 转换为 1000 100000000 转化为 100000000
|
|
|
unitConversion(amount, dividend) {
|
|
|
- if (localStorage.getItem('lang') != 'ZH') {
|
|
|
+ let lang = localStorage.getItem('lang') || 'ZH';
|
|
|
+ if (lang != 'ZH') {
|
|
|
if (dividend == 10000) {
|
|
|
dividend = 1000
|
|
|
} else if (dividend == 100000000) {
|
|
@@ -142,7 +143,8 @@ export default {
|
|
|
},
|
|
|
//非中文环境下,返回空
|
|
|
onlyZh(value) {
|
|
|
- return localStorage.getItem('lang') == 'ZH' ? value : ''
|
|
|
+ let lang = localStorage.getItem('lang') || 'ZH';
|
|
|
+ return lang == 'ZH' ? value : ''
|
|
|
},
|
|
|
// 金额格式化
|
|
|
formatAmount(amount, decimalDigits, unit='') {
|
|
@@ -225,28 +227,35 @@ export default {
|
|
|
return result
|
|
|
},
|
|
|
//计算表格列宽度
|
|
|
- calcTableColWidth (vm,layout,index) {
|
|
|
+ async calcTableColWidth (vm,layout,index) {
|
|
|
if (!vm) return
|
|
|
- if (localStorage.getItem('lang') != 'ZH') {
|
|
|
- let el = vm.$el
|
|
|
- const ths = el.querySelector('.el-table__header-wrapper').querySelectorAll('table thead th .cell') // 获取头部列元素
|
|
|
- // 定义变量 存储每列的宽度数据
|
|
|
- let widths = [];
|
|
|
- // 获取标题中的单元格宽度
|
|
|
- ths.forEach((item, i) => {
|
|
|
- widths[i] = item.offsetWidth
|
|
|
- })
|
|
|
- if (timer) clearTimeout(timer)
|
|
|
- timer = setTimeout(() => {
|
|
|
- vm.doLayout()
|
|
|
- },1000)
|
|
|
- let isCheckbox = ths[0].querySelector('.el-checkbox__inner') ? 1 : 0
|
|
|
-
|
|
|
- if (typeof layout == 'number') {
|
|
|
- return widths[index+isCheckbox] > layout ? widths[index+isCheckbox]:layout
|
|
|
- } else {
|
|
|
- return widths[index+isCheckbox] > layout[index].width ? widths[index+isCheckbox]:layout[index].width
|
|
|
- }
|
|
|
+ let lang = localStorage.getItem('lang') || 'ZH';
|
|
|
+ if (lang != 'ZH') {
|
|
|
+ const res = await new Promise((resolve, reject) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ let widths = [],
|
|
|
+ el = vm.$el,
|
|
|
+ width = 0;
|
|
|
+ const ths = el.querySelector('.el-table__header-wrapper').querySelectorAll('table thead tr:first-child th .cell') // 获取头部列元素
|
|
|
+ // 定义变量 存储每列的宽度数据
|
|
|
+ // 获取标题中的单元格宽度
|
|
|
+ ths.forEach((item, i) => {
|
|
|
+ widths[i] = item.offsetWidth
|
|
|
+ })
|
|
|
+ if (timer) clearTimeout(timer)
|
|
|
+ timer = setTimeout(() => {
|
|
|
+ vm.doLayout()
|
|
|
+ }, 1000)
|
|
|
+ let isCheckbox = ths[0].querySelector('.el-checkbox__inner') ? 1 : 0
|
|
|
+ if (typeof layout == 'number') {
|
|
|
+ width = widths[index + isCheckbox] > layout ? widths[index + isCheckbox] : layout
|
|
|
+ } else {
|
|
|
+ width = widths[index + isCheckbox] > layout[index].width ? widths[index + isCheckbox] : layout[index].width
|
|
|
+ }
|
|
|
+ resolve(Number(width - 0 + 20))
|
|
|
+ });
|
|
|
+ })
|
|
|
+ return Number(res)
|
|
|
} else {
|
|
|
if (typeof layout == 'number') {
|
|
|
return layout === 0 ? 150 : layout
|