|
|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<el-dialog :visible.sync="dialogVisible">
|
|
|
|
|
<el-dialog title="请选择" :visible.sync="dialogVisible">
|
|
|
|
|
<template>
|
|
|
|
|
<div class="select">
|
|
|
|
|
<Select
|
|
|
|
|
@ -27,6 +27,11 @@
|
|
|
|
|
v-model="select.filter[0].value"
|
|
|
|
|
style="width: 150px; margin-left: 10px"
|
|
|
|
|
placeholder="请填写关键词"
|
|
|
|
|
@input="e => {
|
|
|
|
|
if (!select.filter[0].key) {
|
|
|
|
|
select.keyword = e
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
@ -54,6 +59,7 @@
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<xy-table
|
|
|
|
|
:isHandlerKey="false"
|
|
|
|
|
:is-first-req="false"
|
|
|
|
|
ref="table"
|
|
|
|
|
:row-key="(row) => row.id"
|
|
|
|
|
@ -105,6 +111,7 @@ export default {
|
|
|
|
|
tempRow: {},
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
select: {
|
|
|
|
|
keyword: "",
|
|
|
|
|
table_name: "",
|
|
|
|
|
table_id: "",
|
|
|
|
|
filter: [
|
|
|
|
|
@ -219,8 +226,9 @@ export default {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
this.columns.unshift({
|
|
|
|
|
type: "index",
|
|
|
|
|
prop: "id",
|
|
|
|
|
width: 50,
|
|
|
|
|
formatter: (row, column, cellValue, index) => (this.$refs['xyTable'].selectOpt.page - 1) * this.$refs['xyTable'].selectOpt.page_size + index + 1
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (this.linkType === "hasMany" || this.linkType === "newHasMany") {
|
|
|
|
|
@ -234,20 +242,30 @@ export default {
|
|
|
|
|
adjustAlignment () {
|
|
|
|
|
if (this.firstAdjustTable) {
|
|
|
|
|
const data = this.$refs['table'].getListData();
|
|
|
|
|
if (data.length === 0) return;
|
|
|
|
|
this.fields.forEach((i) => {
|
|
|
|
|
let lengthTemp = data[0][i.field]?.length??0;
|
|
|
|
|
for (let j = 0;j < data.length;j++) {
|
|
|
|
|
if (/^-?\d+\.\d+/.test(data[j][i.field])) {
|
|
|
|
|
if (data.length < 2) return;
|
|
|
|
|
try {
|
|
|
|
|
this.fields.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.columns.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.columns.find(a => a.prop === i.field).align = 'left';
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
console.log(this.columns)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e)
|
|
|
|
|
}
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs['table'].doLayout();
|
|
|
|
|
this.firstAdjustTable = false;
|
|
|
|
|
@ -256,17 +274,28 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
selectRows() {
|
|
|
|
|
this.originalRowIds.forEach((id) => {
|
|
|
|
|
let data = this.$refs["table"].getListData();
|
|
|
|
|
if (this.linkType === 'hasMany' || this.linkType === 'newHasMany') {
|
|
|
|
|
this.originalRowIds.forEach((id) => {
|
|
|
|
|
let data = this.$refs["table"].getListData();
|
|
|
|
|
|
|
|
|
|
let row = data.find((i) => i.id === id);
|
|
|
|
|
if (row) {
|
|
|
|
|
this.$refs["table"].toggleRowSelection(row);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
let row = data.find((i) => i.id === id);
|
|
|
|
|
if (row) {
|
|
|
|
|
this.$refs["table"].toggleRowSelection(row);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs['table'].setCurrentRow(
|
|
|
|
|
this.$refs['table'].getListData().find(i => i.id === this.originalRows?.id)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
rowPick({ row }) {
|
|
|
|
|
this.tempRow = row;
|
|
|
|
|
if (JSON.stringify(this.tempRow) === JSON.stringify(row)) {
|
|
|
|
|
this.tempRow = {};
|
|
|
|
|
this.$refs['table'].setCurrentRow();
|
|
|
|
|
} else {
|
|
|
|
|
this.tempRow = row;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
selectBk(selections, row) {
|
|
|
|
|
if (!selections.find((i) => i.id === row.id)) {
|
|
|
|
|
@ -295,6 +324,11 @@ export default {
|
|
|
|
|
computed: {},
|
|
|
|
|
watch: {
|
|
|
|
|
async linkTableName(newVal) {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
if (this.$refs['table']) {
|
|
|
|
|
this.$refs['table'].loading = true;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
await this.getDataTableName();
|
|
|
|
|
await this.getColumns();
|
|
|
|
|
await this.$refs["table"].getTableData();
|
|
|
|
|
@ -308,9 +342,11 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
originalRows(newVal) {
|
|
|
|
|
this.originalRowIds = newVal.map((i) => i[this.field]);
|
|
|
|
|
if (newVal instanceof Array) {
|
|
|
|
|
this.originalRowIds = newVal.map((i) => i[this.field]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.selectRows();
|
|
|
|
|
//this.selectRows();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
@ -320,4 +356,8 @@ export default {
|
|
|
|
|
.select {
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
::v-deep .el-table__body tr.current-row > td.el-table__cell {
|
|
|
|
|
background: $primaryColor;
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|