|
|
|
@ -33,7 +33,7 @@ |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="2" v-model="pageData.customerName" ></el-input> |
|
|
|
:rows="2" v-model="pageData.customerName"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
@ -44,7 +44,7 @@ |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="2" v-model="pageData.overseasShipper" ></el-input> |
|
|
|
:rows="2" v-model="pageData.overseasShipper"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
@ -56,7 +56,7 @@ |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="3" v-model="pageData.localShipAddress" ></el-input> |
|
|
|
:rows="3" v-model="pageData.localShipAddress"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
@ -68,7 +68,7 @@ |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="3" v-model="pageData.overseasAddress" ></el-input> |
|
|
|
:rows="3" v-model="pageData.overseasAddress"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24" style="margin-top: 60px"> |
|
|
|
@ -227,13 +227,95 @@ |
|
|
|
localShipAddressFlag:false, |
|
|
|
overseasShipperFlag:false, |
|
|
|
overseasAddressFlag:false, |
|
|
|
cacheKey: '', // 缓存键 |
|
|
|
cacheTimer: null, // 缓存定时器 |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
// 深度监听pageData的变化,自动保存到缓存 |
|
|
|
pageData: { |
|
|
|
handler: function(newVal, oldVal) { |
|
|
|
// 只有在组件已初始化且对话框可见时才保存缓存 |
|
|
|
if (this.visible && this.cacheKey) { |
|
|
|
this.saveToCache(); |
|
|
|
} |
|
|
|
}, |
|
|
|
deep: true |
|
|
|
} |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
// 组件销毁前清理定时器 |
|
|
|
if (this.cacheTimer) { |
|
|
|
clearTimeout(this.cacheTimer); |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 生成缓存键 |
|
|
|
generateCacheKey() { |
|
|
|
const userId = this.$store.state.user.id || this.$store.state.user.name; |
|
|
|
return `ecss_del_upload_cache_${userId}`; |
|
|
|
}, |
|
|
|
|
|
|
|
// 保存数据到缓存(防抖处理) |
|
|
|
saveToCache() { |
|
|
|
// 清除之前的定时器 |
|
|
|
if (this.cacheTimer) { |
|
|
|
clearTimeout(this.cacheTimer); |
|
|
|
} |
|
|
|
|
|
|
|
// 设置新的定时器,500ms后执行保存 |
|
|
|
this.cacheTimer = setTimeout(() => { |
|
|
|
try { |
|
|
|
const cacheData = { |
|
|
|
pageData: { |
|
|
|
buNo: this.pageData.buNo, |
|
|
|
customerName: this.pageData.customerName, |
|
|
|
localShipAddress: this.pageData.localShipAddress, |
|
|
|
overseasShipper: this.pageData.overseasShipper, |
|
|
|
overseasAddress: this.pageData.overseasAddress, |
|
|
|
cnative: this.pageData.cnative, |
|
|
|
salesArea: this.pageData.salesArea, |
|
|
|
} |
|
|
|
}; |
|
|
|
localStorage.setItem(this.cacheKey, JSON.stringify(cacheData)); |
|
|
|
} catch (error) { |
|
|
|
console.warn('保存缓存失败:', error); |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, |
|
|
|
|
|
|
|
// 从缓存加载数据 |
|
|
|
loadFromCache() { |
|
|
|
try { |
|
|
|
const cachedData = localStorage.getItem(this.cacheKey); |
|
|
|
if (cachedData) { |
|
|
|
const parsedData = JSON.parse(cachedData); |
|
|
|
if (parsedData.pageData) { |
|
|
|
// 恢复缓存的数据(不包括文件) |
|
|
|
Object.assign(this.pageData, parsedData.pageData); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.warn('加载缓存失败:', error); |
|
|
|
} |
|
|
|
return false; |
|
|
|
}, |
|
|
|
|
|
|
|
// 清除缓存 |
|
|
|
clearCache() { |
|
|
|
try { |
|
|
|
localStorage.removeItem(this.cacheKey); |
|
|
|
} catch (error) { |
|
|
|
console.warn('清除缓存失败:', error); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 初始化组件的参数 |
|
|
|
init () { |
|
|
|
this.fileList = [] |
|
|
|
this.cacheKey = this.generateCacheKey(); |
|
|
|
|
|
|
|
let tempData = { |
|
|
|
username: this.$store.state.user.name, |
|
|
|
} |
|
|
|
@ -244,18 +326,27 @@ |
|
|
|
this.pageData.buNo=data.row2[0].buNo |
|
|
|
} |
|
|
|
} |
|
|
|
// 在获取BU列表后尝试加载缓存 |
|
|
|
this.loadFromCache(); |
|
|
|
}) |
|
|
|
|
|
|
|
getCustomerList({}).then(({data}) => { |
|
|
|
//区分请求成功和失败的状况 |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.customerList=data.rows |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 如果没有缓存数据,则初始化为空 |
|
|
|
if (!this.loadFromCache()) { |
|
|
|
this.pageData.customerName='' |
|
|
|
this.pageData.cnative='' |
|
|
|
this.pageData.localShipAddress='', |
|
|
|
this.pageData.overseasShipper='', |
|
|
|
this.pageData.overseasAddress='', |
|
|
|
this.pageData.salesArea='' |
|
|
|
} |
|
|
|
|
|
|
|
this.customerPersons=[] |
|
|
|
this.customerAddrs=[] |
|
|
|
// 打开页面 |
|
|
|
@ -338,6 +429,7 @@ |
|
|
|
this.deleteFile() |
|
|
|
// 关闭当前的页面 |
|
|
|
this.visible = false |
|
|
|
// 注意:这里不清除缓存,让数据保留到下次打开 |
|
|
|
}, |
|
|
|
deleteFile(){ |
|
|
|
this.fileList = [] |
|
|
|
@ -392,6 +484,8 @@ |
|
|
|
saveEcssCoDelNotifyByExcel(formData).then(({data}) => { |
|
|
|
if (data.code === 0) { |
|
|
|
this.$message.success(data.msg) |
|
|
|
// 保存成功后清除缓存 |
|
|
|
this.clearCache() |
|
|
|
// 关闭窗口并刷新页面 |
|
|
|
this.closeDialog() |
|
|
|
} else { |
|
|
|
|