diff --git a/src/components/Table/src/Table.vue b/src/components/Table/src/Table.vue index 15b93be06..a7a988359 100644 --- a/src/components/Table/src/Table.vue +++ b/src/components/Table/src/Table.vue @@ -247,6 +247,25 @@ export default defineComponent({ }) } + // 默认排序 + const updateSort= (val)=>{ + val.forEach(item=>{ + if(!item.sortDefault){ + if(item.fixed=='left'){ + item.sortDefault = 0 + }else if(item.fixed=='right'){ + item.sortDefault = 9999 + }else{ + item.sortDefault = 999 // 默认999 + } + } + }) + val.sort((column1,column2)=>{ + return column1.sortDefault - column2.sortDefault + }) + } + + const rnderTableColumn = (columnsChildren?: TableColumn[]) => { const { columns, @@ -258,6 +277,8 @@ export default defineComponent({ showOverflowTooltip, border } = unref(getProps) + //默认排序 + updateSort(columns) return [...[renderTableExpand()], ...[renderTableSelection()]].concat( (columnsChildren || columns).map((v) => { // 自定生成序号 diff --git a/src/components/rowDrop/index.vue b/src/components/rowDrop/index.vue index f02a935b8..a8333f833 100644 --- a/src/components/rowDrop/index.vue +++ b/src/components/rowDrop/index.vue @@ -84,10 +84,12 @@ const save = () => { saveDate.push(props.allSchemas.tableColumns[0]) allData.value.forEach((item) => { const _item:any = props.allSchemas.tableColumns.find(itemColumns => (itemColumns.label == item )) - _item.isTable = false - if (checkedDataList.value.indexOf(_item.label) > -1) { - _item.isTable = true - saveDate.push(_item) + if(_item){ + _item.isTable = false + if (checkedDataList.value.indexOf(_item.label) > -1) { + _item.isTable = true + saveDate.push(_item) + } } }) // 默认操作列 @@ -130,6 +132,7 @@ const initSelectSta = () => { if(props.detailAllSchemas){ _myTableColumns = [...props.allSchemas?.tableColumns,...props.detailAllSchemas?.tableMainColumns] } + updateSort(_myTableColumns) // 有缓存 if (res) { checkedDataList.value = [] @@ -197,7 +200,22 @@ const initSelectSta = () => { console.log(err) }) } - +const updateSort= (val)=>{ + val.forEach(item=>{ + if(!item.sortDefault){ + if(item.fixed=='left'){ + item.sortDefault = 0 + }else if(item.fixed=='right'){ + item.sortDefault = 9999 + }else{ + item.sortDefault = 999 // 默认999 + } + } + }) + val.sort((column1,column2)=>{ + return column1.sortDefault - column2.sortDefault + }) +} // 更新主列表字段 const updataTableColumns = (val) => { emit('updataTableColumns', val)