✨ 持久化存储表单信息;放在前端localStorage中
This commit is contained in:
parent
25c8e27e9b
commit
1ce2a7e210
|
@ -34,6 +34,8 @@ axiosInstance.interceptors.response.use(
|
|||
} else {
|
||||
antd.message.error(message || '系统出错');
|
||||
}
|
||||
|
||||
return error.response.data;
|
||||
}
|
||||
return Promise.reject(error.message);
|
||||
}
|
||||
|
|
|
@ -288,11 +288,12 @@ const DatabaseForm = {
|
|||
async onDownloadZip() {
|
||||
this.downloadLoading = true;
|
||||
try {
|
||||
// 重要:指定响应类型为blob
|
||||
const response = await axiosInstance({
|
||||
url: "/generator/downloadByZip",
|
||||
method: "POST",
|
||||
data: this.form,
|
||||
responseType: 'blob' // 重要:指定响应类型为blob
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
// 从响应头中获取文件名
|
||||
|
|
|
@ -169,21 +169,32 @@
|
|||
},
|
||||
watch: {
|
||||
/* 数据表选择 */
|
||||
dbSelect: {
|
||||
handler() {
|
||||
this.getDatabaseTableList();
|
||||
}
|
||||
},
|
||||
dbSelect: "getDatabaseTableList",
|
||||
|
||||
/* 过滤数据表 */
|
||||
tableSelect: {
|
||||
handler(val) {
|
||||
this.tableList = this.rawTableList;
|
||||
// 根据表名进行过滤筛选或者根据注释内容进行筛选
|
||||
this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val));
|
||||
}
|
||||
tableSelect(val) {
|
||||
this.tableList = this.rawTableList;
|
||||
// 根据表名进行过滤筛选或者根据注释内容进行筛选
|
||||
this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val));
|
||||
},
|
||||
|
||||
/**
|
||||
* 监听form表单放到 localStorage
|
||||
* 不要使用 immediate 否则初始话加载的时候会将 localStorage 改成 原始表单
|
||||
*/
|
||||
form: {
|
||||
deep: true,
|
||||
handler(val) {
|
||||
localStorage.setItem("form", JSON.stringify(val));
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const form = localStorage.getItem("form");
|
||||
if (form !== null) {
|
||||
this.form = JSON.parse(form);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 注册组件
|
||||
|
|
Loading…
Reference in New Issue