Browse Source

页面使用优化:表头上有多条数据,我选中第三条数据,这一行内容会高亮显示,然后进行修改、计算、导出等操作后,就变成第一行内容高亮显示,这时用户需要找到刚刚那条数据选中后才能进行剩余的操作

java8
han\hanst 3 months ago
parent
commit
71e03a05ce
  1. 153
      src/views/modules/ecss/codelnotify.vue
  2. 137
      src/views/modules/ecss/codelnotifyConfirm.vue

153
src/views/modules/ecss/codelnotify.vue

@ -722,6 +722,8 @@
pageSize: 100,
totalPage: 0,
height: 200,
//
selectedRowKey: null, //
componentPartModelFlag: false,
componentPartData: {
site: '',
@ -1786,11 +1788,36 @@
this.pageSize = data.page.pageSize
this.totalPage = data.page.totalCount
if(this.dataList.length>0){
this.$refs.mainTable.setCurrentRow(this.dataList[0]);
this.changeData(this.dataList[0])
this.dataList.forEach(o => {
o.modifyLabel = !!o.modifyFlag?'是':'';
});
// 使 $nextTick DOM
this.$nextTick(() => {
try {
//
if (!this.$refs.mainTable) {
console.warn('[行选择持久化] 表格引用不存在,跳过设置选中行');
return;
}
//
const restoredRow = this.restoreSelectedRow();
if (restoredRow) {
this.$refs.mainTable.setCurrentRow(restoredRow);
this.changeData(restoredRow);
} else {
//
this.$refs.mainTable.setCurrentRow(this.dataList[0]);
this.changeData(this.dataList[0]);
}
} catch (error) {
console.error('[行选择持久化] 设置选中行失败:', error);
// changeData
const restoredRow = this.restoreSelectedRow();
this.changeData(restoredRow || this.dataList[0]);
}
});
}else {
this.changeData(null)
}
@ -1861,6 +1888,13 @@
changeData(row){
this.currentRow = JSON.parse(JSON.stringify(row));
this.headerData=row;
//
if (row && row.delNo) {
this.selectedRowKey = row.delNo;
this.saveSelectedRowToStorage();
}
this.refreshCurrentTabTable ();
},
importModel(){
@ -1912,6 +1946,12 @@
}
updateEcssDelHeader(this.updateHeaderModel).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = this.currentRow ? this.currentRow.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.updateHeaderModelFlag = false
this.$message({
@ -1931,6 +1971,10 @@
this.$confirm('确认删除吗?', '提示').then(() => {
deleteEcssDelHeader(row).then(({data}) => {
if (data && data.code === 0) {
//
if (this.currentRow && this.currentRow.delNo === row.delNo) {
this.clearSelectedRowStorage();
}
this.searchTable()
this.$message({
message: '操作成功',
@ -1967,6 +2011,12 @@
this.$confirm('确认废弃吗?', '提示').then(() => {
cancelEcssDelHeader(row).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = row ? row.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.$message({
message: '操作成功',
@ -1986,6 +2036,12 @@
this.$confirm('确认取消废弃吗?', '提示').then(() => {
recoverEcssDelHeader(row).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = row ? row.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.$message({
message: '操作成功',
@ -2042,6 +2098,12 @@
changeEcssDelStatus(inData).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = this.currentRow ? this.currentRow.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.$message({
message: '操作成功',
@ -2078,6 +2140,12 @@
this.$confirm('确认取消下达吗?', '提示').then(() => {
changeEcssDelStatus(inData).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = row ? row.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.$message({
message: '操作成功',
@ -2103,6 +2171,12 @@
this.$confirm('确认一键结单吗?', '提示').then(() => {
changeEcssDelStatus(inData).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = row ? row.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.$message({
message: '操作成功',
@ -2552,6 +2626,70 @@
}
this.templateFlag = false
},
/**
* 保存选中行到本地存储
* 使用页面路径和用户名作为存储键的一部分确保不同页面和用户的选择互不影响
*/
saveSelectedRowToStorage() {
try {
const storageKey = `codelnotify_selected_row_${this.$store.state.user.name}`;
localStorage.setItem(storageKey, this.selectedRowKey);
console.log(`[行选择持久化] 已保存选中行: ${this.selectedRowKey}`);
} catch (error) {
console.warn('保存选中行状态失败:', error);
}
},
/**
* 从本地存储恢复选中行
* @returns {Object|null} 返回匹配的行数据如果没有找到则返回null
*/
restoreSelectedRow() {
try {
const storageKey = `codelnotify_selected_row_${this.$store.state.user.name}`;
const savedRowKey = localStorage.getItem(storageKey);
//
if (!savedRowKey) {
console.log('[行选择持久化] 没有保存的选中行');
return null;
}
if (!this.dataList || this.dataList.length === 0) {
console.log('[行选择持久化] 数据列表为空,无法恢复选中行');
return null;
}
//
const matchedRow = this.dataList.find(row => row && row.delNo === savedRowKey);
if (matchedRow) {
this.selectedRowKey = savedRowKey;
console.log(`[行选择持久化] 已恢复选中行: ${savedRowKey}`);
return matchedRow;
} else {
console.log(`[行选择持久化] 未找到匹配的行: ${savedRowKey},当前数据列表长度: ${this.dataList.length}`);
}
return null;
} catch (error) {
console.warn('恢复选中行状态失败:', error);
return null;
}
},
/**
* 清除本地存储的选中行状态
*/
clearSelectedRowStorage() {
try {
const storageKey = `codelnotify_selected_row_${this.$store.state.user.name}`;
localStorage.removeItem(storageKey);
this.selectedRowKey = null;
} catch (error) {
console.warn('清除选中行状态失败:', error);
}
},
},
activated() {
this.searchTable()
@ -2560,6 +2698,17 @@
this.getBu ()
//
this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
//
try {
const storageKey = `codelnotify_selected_row_${this.$store.state.user.name}`;
const savedRowKey = localStorage.getItem(storageKey);
if (savedRowKey) {
this.selectedRowKey = savedRowKey;
}
} catch (error) {
console.warn('初始化选中行状态失败:', error);
}
}
}
</script>

137
src/views/modules/ecss/codelnotifyConfirm.vue

@ -655,6 +655,8 @@
pageIndex: 1,
pageSize: 100,
totalPage: 0,
//
selectedRowKey: null, //
height: 200,
buList:[],
dataList:[],
@ -1935,15 +1937,38 @@
this.pageSize = data.page.pageSize
this.totalPage = data.page.totalCount
if(this.dataList.length>0){
this.$refs.mainTable.setCurrentRow(this.dataList[0]);
this.changeData(this.dataList[0])
this.dataList.forEach(o => {
if (o.notifyStatus==='仓库已确认'&&!o.notifyDate) {
o.notifyDate='发货日期不确定'
}
this.dataList.forEach(o => {
o.modifyLabel = !!o.modifyFlag?'是':'';
});
o.modifyLabel = !!o.modifyFlag?'是':'';
});
// 使 $nextTick DOM
this.$nextTick(() => {
try {
//
if (!this.$refs.mainTable) {
console.warn('[确认页面行选择持久化] 表格引用不存在,跳过设置选中行');
return;
}
//
const restoredRow = this.restoreSelectedRow();
if (restoredRow) {
this.$refs.mainTable.setCurrentRow(restoredRow);
this.changeData(restoredRow);
} else {
//
this.$refs.mainTable.setCurrentRow(this.dataList[0]);
this.changeData(this.dataList[0]);
}
} catch (error) {
console.error('[确认页面行选择持久化] 设置选中行失败:', error);
// changeData
const restoredRow = this.restoreSelectedRow();
this.changeData(restoredRow || this.dataList[0]);
}
});
}else {
this.changeData(null)
@ -1991,6 +2016,13 @@
this.currentRow.notifyDate=''
}
this.headerData=row;
//
if (row && row.delNo) {
this.selectedRowKey = row.delNo;
this.saveSelectedRowToStorage();
}
this.refreshCurrentTabTable ();
},
refreshCurrentTabTable(){
@ -2033,6 +2065,12 @@
confirmDo(){
confirmEcssDel(this.confirmModel).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = this.confirmModel ? this.confirmModel.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.confirmModelFlag=false
this.$message({
@ -2056,6 +2094,12 @@
this.$confirm('取消确认这条发货通知单?', '提示').then(() => {
cancerConfirmEcssDel(indata).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = row ? row.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.$message({
message: '操作成功',
@ -2106,6 +2150,12 @@
this.confirmModel.updateBy = this.$store.state.user.name
updateEcssDel(this.confirmModel).then(({data}) => {
if (data && data.code === 0) {
// 便
const currentSelectedKey = this.confirmModel ? this.confirmModel.delNo : null;
if (currentSelectedKey) {
this.selectedRowKey = currentSelectedKey;
this.saveSelectedRowToStorage();
}
this.searchTable()
this.updateModelFlag=false
this.$message({
@ -2595,8 +2645,70 @@
this.$nextTick(() => this.$refs.detailTable.doLayout());// ,
return sums;
},
/**
* 保存选中行到本地存储
* 使用页面路径和用户名作为存储键的一部分确保不同页面和用户的选择互不影响
*/
saveSelectedRowToStorage() {
try {
const storageKey = `codelnotifyConfirm_selected_row_${this.$store.state.user.name}`;
localStorage.setItem(storageKey, this.selectedRowKey);
console.log(`[确认页面行选择持久化] 已保存选中行: ${this.selectedRowKey}`);
} catch (error) {
console.warn('保存选中行状态失败:', error);
}
},
/**
* 从本地存储恢复选中行
* @returns {Object|null} 返回匹配的行数据如果没有找到则返回null
*/
restoreSelectedRow() {
try {
const storageKey = `codelnotifyConfirm_selected_row_${this.$store.state.user.name}`;
const savedRowKey = localStorage.getItem(storageKey);
//
if (!savedRowKey) {
console.log('[确认页面行选择持久化] 没有保存的选中行');
return null;
}
if (!this.dataList || this.dataList.length === 0) {
console.log('[确认页面行选择持久化] 数据列表为空,无法恢复选中行');
return null;
}
//
const matchedRow = this.dataList.find(row => row && row.delNo === savedRowKey);
if (matchedRow) {
this.selectedRowKey = savedRowKey;
console.log(`[确认页面行选择持久化] 已恢复选中行: ${savedRowKey}`);
return matchedRow;
} else {
console.log(`[确认页面行选择持久化] 未找到匹配的行: ${savedRowKey},当前数据列表长度: ${this.dataList.length}`);
}
return null;
} catch (error) {
console.warn('恢复选中行状态失败:', error);
return null;
}
},
/**
* 清除本地存储的选中行状态
*/
clearSelectedRowStorage() {
try {
const storageKey = `codelnotifyConfirm_selected_row_${this.$store.state.user.name}`;
localStorage.removeItem(storageKey);
this.selectedRowKey = null;
} catch (error) {
console.warn('清除选中行状态失败:', error);
}
},
},
activated() {
@ -2606,6 +2718,17 @@
this.getBu ()
//
this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
//
try {
const storageKey = `codelnotifyConfirm_selected_row_${this.$store.state.user.name}`;
const savedRowKey = localStorage.getItem(storageKey);
if (savedRowKey) {
this.selectedRowKey = savedRowKey;
}
} catch (error) {
console.warn('初始化选中行状态失败:', error);
}
}
}
</script>

Loading…
Cancel
Save