✨ 持久化存储表单信息;放在前端localStorage中
This commit is contained in:
parent
25c8e27e9b
commit
1ce2a7e210
|
@ -34,6 +34,8 @@ axiosInstance.interceptors.response.use(
|
||||||
} else {
|
} else {
|
||||||
antd.message.error(message || '系统出错');
|
antd.message.error(message || '系统出错');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return error.response.data;
|
||||||
}
|
}
|
||||||
return Promise.reject(error.message);
|
return Promise.reject(error.message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,11 +288,12 @@ const DatabaseForm = {
|
||||||
async onDownloadZip() {
|
async onDownloadZip() {
|
||||||
this.downloadLoading = true;
|
this.downloadLoading = true;
|
||||||
try {
|
try {
|
||||||
|
// 重要:指定响应类型为blob
|
||||||
const response = await axiosInstance({
|
const response = await axiosInstance({
|
||||||
url: "/generator/downloadByZip",
|
url: "/generator/downloadByZip",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: this.form,
|
data: this.form,
|
||||||
responseType: 'blob' // 重要:指定响应类型为blob
|
responseType: 'blob'
|
||||||
});
|
});
|
||||||
|
|
||||||
// 从响应头中获取文件名
|
// 从响应头中获取文件名
|
||||||
|
|
|
@ -169,21 +169,32 @@
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
/* 数据表选择 */
|
/* 数据表选择 */
|
||||||
dbSelect: {
|
dbSelect: "getDatabaseTableList",
|
||||||
handler() {
|
|
||||||
this.getDatabaseTableList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* 过滤数据表 */
|
/* 过滤数据表 */
|
||||||
tableSelect: {
|
tableSelect(val) {
|
||||||
handler(val) {
|
this.tableList = this.rawTableList;
|
||||||
this.tableList = this.rawTableList;
|
// 根据表名进行过滤筛选或者根据注释内容进行筛选
|
||||||
// 根据表名进行过滤筛选或者根据注释内容进行筛选
|
this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val));
|
||||||
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