|
|
|
|
@ -572,25 +572,30 @@ export default {
|
|
|
|
|
adjustAlignment () {
|
|
|
|
|
if (this.firstAdjustTable) {
|
|
|
|
|
const data = this.$refs['xyTable'].getListData();
|
|
|
|
|
if (data.length === 0) return;
|
|
|
|
|
this.form.filter(i => i.list_show).forEach((i) => {
|
|
|
|
|
let lengthTemp;
|
|
|
|
|
let temp = 0;
|
|
|
|
|
while (!lengthTemp || temp < data.length) {
|
|
|
|
|
lengthTemp = data[temp][i.field]?.length??0;
|
|
|
|
|
temp++;
|
|
|
|
|
}
|
|
|
|
|
for (let j = 0;j < data.length;j++) {
|
|
|
|
|
if (/^-?\d+\.\d+/.test(data[j][i.field])) {
|
|
|
|
|
if (data.length < 2) return;
|
|
|
|
|
try {
|
|
|
|
|
this.form.filter(i => i.list_show).forEach((i) => {
|
|
|
|
|
let maxLength = -Infinity;
|
|
|
|
|
let minLength = Infinity;
|
|
|
|
|
let numberLength = 0;
|
|
|
|
|
let temp = 0;
|
|
|
|
|
while (temp < data.length) {
|
|
|
|
|
maxLength = Math.max(maxLength, data[temp][i.field]?.length??0);
|
|
|
|
|
minLength = Math.min(minLength, data[temp][i.field]?.length??0);
|
|
|
|
|
numberLength += /^-?[0-9]+(\.[0-9]+)?$/.test(data[temp][i.field]) ? 1 : 0;
|
|
|
|
|
temp++;
|
|
|
|
|
}
|
|
|
|
|
if (numberLength === temp) {
|
|
|
|
|
this.table.find(a => a.prop === i.field).align = 'right';
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (Math.abs(lengthTemp - (data[j][i.field]?.length)??0) > 4) {
|
|
|
|
|
else if (Math.abs(maxLength - minLength) > 4) {
|
|
|
|
|
this.table.find(a => a.prop === i.field).align = 'left';
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
console.log(this.table)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e)
|
|
|
|
|
}
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs['xyTable'].doLayout();
|
|
|
|
|
this.firstAdjustTable = false;
|
|
|
|
|
|