show export data guide in import transaction dialog

This commit is contained in:
MaysWind
2024-10-07 20:46:04 +08:00
parent 3c428ade52
commit a6e765f51c
5 changed files with 117 additions and 12 deletions
+26 -6
View File
@@ -4,27 +4,47 @@ const supportedImportFileTypes = [
{
type: 'ezbookkeeping_csv',
name: 'ezbookkeeping Data Export File (CSV)',
extensions: '.csv'
extensions: '.csv',
document: {
supportMultiLanguages: true,
anchor: 'export-transactions'
}
},
{
type: 'ezbookkeeping_tsv',
name: 'ezbookkeeping Data Export File (TSV)',
extensions: '.tsv'
extensions: '.tsv',
document: {
supportMultiLanguages: true,
anchor: 'export-transactions'
}
},
{
type: 'feidee_mymoney_csv',
name: 'Feidee MyMoney (App) Data Export File',
extensions: '.csv'
extensions: '.csv',
document: {
supportMultiLanguages: 'zh-Hans',
anchor: '如何获取金蝶随手记app数据导出文件'
}
},
{
type: 'feidee_mymoney_xls',
name: 'Feidee MyMoney (Web) Data Export File',
extensions: '.xls'
extensions: '.xls',
document: {
supportMultiLanguages: 'zh-Hans',
anchor: '如何获取金蝶随手记web版数据导出文件'
}
},
{
type: 'alipay_csv',
name: 'Alipay Data Export File',
extensions: '.csv'
name: 'Alipay (Web) Data Export File',
extensions: '.csv',
document: {
supportMultiLanguages: 'zh-Hans',
anchor: '如何获取支付宝网页版数据导出文件'
}
}
];
+43 -4
View File
@@ -62,6 +62,10 @@ import {
import logger from './logger.js';
import services from './services.js';
function getLanguageDisplayName(translateFn, languageName) {
return translateFn(`language.${languageName}`);
}
function getAllLanguageInfoArray(translateFn, includeSystemDefault) {
const ret = [];
@@ -72,7 +76,7 @@ function getAllLanguageInfoArray(translateFn, includeSystemDefault) {
const languageInfo = allLanguages[languageTag];
let displayName = languageInfo.displayName;
let languageNameInCurrentLanguage = translateFn(`language.${languageInfo.name}`);
let languageNameInCurrentLanguage = getLanguageDisplayName(translateFn, languageInfo.name);
if (languageNameInCurrentLanguage && languageNameInCurrentLanguage !== displayName) {
displayName = `${languageNameInCurrentLanguage} (${displayName})`;
@@ -1255,16 +1259,51 @@ function getAllDisplayExchangeRates(exchangeRatesData, translateFn) {
return availableExchangeRates;
}
function getAllSupportedImportFileTypes(translateFn) {
function getAllSupportedImportFileTypes(i18nGlobal, translateFn) {
const allSupportedImportFileTypes = [];
for (let i = 0; i < fileConstants.supportedImportFileTypes.length; i++) {
const fileType = fileConstants.supportedImportFileTypes[i];
let document = {
language: '',
displayLanguageName: '',
anchor: ''
};
if (fileType.document) {
if (fileType.document.supportMultiLanguages === true) {
document.language = getCurrentLanguageTag(i18nGlobal);
document.anchor = translateFn(`document.anchor.export_and_import.${fileType.document.anchor}`);
} else if (isString(fileType.document.supportMultiLanguages) && allLanguages[fileType.document.supportMultiLanguages]) {
document.language = fileType.document.supportMultiLanguages;
if (document.language !== getCurrentLanguageTag(i18nGlobal)) {
document.displayLanguageName = getLanguageDisplayName(translateFn, allLanguages[fileType.document.supportMultiLanguages].name);
}
document.anchor = fileType.document.anchor;
}
if (document.language) {
document.language = document.language.replace(/-/g, '_');
}
if (document.anchor) {
document.anchor = document.anchor.toLowerCase().replace(/ /g, '-');
}
if (document.language === defaultLanguage) {
document.language = '';
}
} else {
document = null;
}
allSupportedImportFileTypes.push({
type: fileType.type,
displayName: translateFn(fileType.name),
extensions: fileType.extensions
extensions: fileType.extensions,
document: document
});
}
@@ -1618,7 +1657,7 @@ export function i18nFunctions(i18nGlobal) {
getAllTransactionScheduledFrequencyTypes: () => getAllTransactionScheduledFrequencyTypes(i18nGlobal.t),
getAllTransactionDefaultCategories: (categoryType, locale) => getAllTransactionDefaultCategories(categoryType, locale, i18nGlobal.t),
getAllDisplayExchangeRates: (exchangeRatesData) => getAllDisplayExchangeRates(exchangeRatesData, i18nGlobal.t),
getAllSupportedImportFileTypes: () => getAllSupportedImportFileTypes(i18nGlobal.t),
getAllSupportedImportFileTypes: () => getAllSupportedImportFileTypes(i18nGlobal, i18nGlobal.t),
getEnableDisableOptions: () => getEnableDisableOptions(i18nGlobal.t),
getCategorizedAccountsWithDisplayBalance: (allVisibleAccounts, showAccountBalance, defaultCurrency, settingsStore, userStore, exchangeRatesStore) => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts, showAccountBalance, defaultCurrency, userStore, settingsStore, exchangeRatesStore, i18nGlobal.t),
joinMultiText: (textArray) => joinMultiText(textArray, i18nGlobal.t),
+9 -1
View File
@@ -1183,6 +1183,13 @@
"parameter invalid color": "{parameter} is invalid format",
"parameter invalid amount filter": "{parameter} is invalid format"
},
"document": {
"anchor": {
"export_and_import": {
"export-transactions": "export-transactions"
}
}
},
"OK": "OK",
"Cancel": "Cancel",
"Operation": "Operation",
@@ -1504,11 +1511,12 @@
"Check and Modify Your Data": "Check and Modify Your Data",
"Data Import Completed": "Data Import Completed",
"File Type": "File Type",
"How to export this file?": "How to export this file?",
"ezbookkeeping Data Export File (CSV)": "ezbookkeeping Data Export File (CSV)",
"ezbookkeeping Data Export File (TSV)": "ezbookkeeping Data Export File (TSV)",
"Feidee MyMoney (Web) Data Export File": "Feidee MyMoney (Web) Data Export File",
"Feidee MyMoney (App) Data Export File": "Feidee MyMoney (App) Data Export File",
"Alipay Data Export File": "Alipay Data Export File",
"Alipay (Web) Data Export File": "Alipay (Web) Data Export File",
"Data File": "Data File",
"No data to import": "No data to import",
"Cannot import invalid transactions": "Cannot import invalid transactions",
+9 -1
View File
@@ -1183,6 +1183,13 @@
"parameter invalid color": "{parameter}格式错误",
"parameter invalid amount filter": "{parameter}格式错误"
},
"document": {
"anchor": {
"export_and_import": {
"export-transactions": "导出交易"
}
}
},
"OK": "确定",
"Cancel": "取消",
"Operation": "操作",
@@ -1504,11 +1511,12 @@
"Check and Modify Your Data": "检查及修改您的数据",
"Data Import Completed": "数据导入完成",
"File Type": "文件类型",
"How to export this file?": "如何导出该文件?",
"ezbookkeeping Data Export File (CSV)": "ezbookkeeping 数据导出文件 (CSV)",
"ezbookkeeping Data Export File (TSV)": "ezbookkeeping 数据导出文件 (TSV)",
"Feidee MyMoney (Web) Data Export File": "金蝶随手记 (Web版) 数据导出文件",
"Feidee MyMoney (App) Data Export File": "金蝶随手记 (App) 数据导出文件",
"Alipay Data Export File": "支付宝数据导出文件",
"Alipay (Web) Data Export File": "支付宝 (网页版) 数据导出文件",
"Data File": "数据文件",
"No data to import": "没有可以导入的数据",
"Cannot import invalid transactions": "不能导入无效的交易",
@@ -91,6 +91,14 @@
@click="showOpenFileDialog"
/>
</v-col>
<v-col cols="12" md="12" class="mb-0 pb-0" v-if="exportFileGuideDocumentUrl">
<a :href="exportFileGuideDocumentUrl" :class="{ 'disabled': submitting }" target="_blank">
<v-icon :icon="icons.document" size="16" />
<span class="ml-1">{{ $t('How to export this file?') }}</span>
<span class="ml-1" v-if="exportFileGuideDocumentLanguageName">({{ exportFileGuideDocumentLanguageName }})</span>
</a>
</v-col>
</v-row>
</v-window-item>
<v-window-item value="checkData">
@@ -486,6 +494,7 @@ import {
import {
mdiDotsVertical,
mdiHelpCircleOutline,
mdiFindReplace,
mdiClose,
mdiArrowRight,
@@ -527,6 +536,7 @@ export default {
reject: null,
icons: {
more: mdiDotsVertical,
document: mdiHelpCircleOutline,
replace: mdiFindReplace,
previous: mdiClose,
next: mdiArrowRight,
@@ -632,6 +642,26 @@ export default {
supportedImportFileExtensions() {
return getNameByKeyValue(this.allSupportedImportFileTypes, this.fileType, 'type', 'extensions');
},
exportFileGuideDocumentUrl() {
const document = getNameByKeyValue(this.allSupportedImportFileTypes, this.fileType, 'type', 'document');
if (!document) {
return null;
}
const language = document.language ? document.language + '/' : '';
const anchor = document.anchor ? '#' + document.anchor : '';
return `https://ezbookkeeping.mayswind.net/${language}export_and_import${anchor}`;
},
exportFileGuideDocumentLanguageName() {
const document = getNameByKeyValue(this.allSupportedImportFileTypes, this.fileType, 'type', 'document');
if (!document) {
return null;
}
return document.displayLanguageName;
},
fileName: {
get: function () {
if (this.importFile == null) {