|
|
@@ -583,10 +583,9 @@ const getCompanyTemplates = async () => {
|
|
|
onlineStoreTempListForeign.value = data.online_store_temp_list_foreign
|
|
|
}
|
|
|
|
|
|
- // 默认选中第一个模板
|
|
|
- if (templates.value.length > 0) {
|
|
|
- form.selectTemplate = templates.value[0]
|
|
|
- }
|
|
|
+ // 获取模板列表后,尝试从缓存恢复模板选择
|
|
|
+ loadTemplateFromCache()
|
|
|
+
|
|
|
excel_template_url.value = data.excel_template_url
|
|
|
// 计算总页数
|
|
|
totalPage.value = Math.ceil(templates.value.length / itemsPerPage);
|
|
|
@@ -671,17 +670,7 @@ const loadDetailCache = () => {
|
|
|
}
|
|
|
} catch {}
|
|
|
|
|
|
- // 加载模板缓存
|
|
|
- try {
|
|
|
- const template = localStorage.getItem('detail_template_cache')
|
|
|
- if (template) {
|
|
|
- const parsed = JSON.parse(template)
|
|
|
- if (parsed && parsed.id) {
|
|
|
- form.selectTemplate = parsed
|
|
|
- console.log('loadDetailCache - template:', parsed);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch {}
|
|
|
+ // 模板缓存加载将在获取模板列表后执行
|
|
|
|
|
|
// 加载服务选择状态缓存
|
|
|
try {
|
|
|
@@ -754,6 +743,41 @@ const saveServicesToCache = (services: string[]) => {
|
|
|
} catch {}
|
|
|
}
|
|
|
|
|
|
+// 从缓存加载模板选择
|
|
|
+const loadTemplateFromCache = () => {
|
|
|
+ try {
|
|
|
+ const template = localStorage.getItem('detail_template_cache')
|
|
|
+ if (template) {
|
|
|
+ const parsed = JSON.parse(template)
|
|
|
+ if (parsed && parsed.id) {
|
|
|
+ // 检查缓存的模板是否还在当前模板列表中
|
|
|
+ const templateExists = templates.value.some(t => t.id === parsed.id)
|
|
|
+ if (templateExists) {
|
|
|
+ form.selectTemplate = parsed
|
|
|
+ console.log('loadTemplateFromCache - template:', parsed);
|
|
|
+ } else {
|
|
|
+ console.log('缓存的模板不在当前模板列表中,使用默认模板');
|
|
|
+ // 如果缓存的模板不存在,使用默认模板(第一个)
|
|
|
+ if (templates.value.length > 0) {
|
|
|
+ form.selectTemplate = templates.value[0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 没有缓存时,使用默认模板
|
|
|
+ if (templates.value.length > 0) {
|
|
|
+ form.selectTemplate = templates.value[0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载模板缓存失败:', error);
|
|
|
+ // 出错时使用默认模板
|
|
|
+ if (templates.value.length > 0) {
|
|
|
+ form.selectTemplate = templates.value[0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const openModelDialog = () => {
|
|
|
modelDialogVisible.value = true
|
|
|
}
|