add subtypes to imported file types

This commit is contained in:
MaysWind
2024-10-20 10:05:44 +08:00
parent 45faa269a4
commit a23a194660
5 changed files with 66 additions and 20 deletions
+17 -13
View File
@@ -29,19 +29,23 @@ const supportedImportFileTypes = [
}
},
{
type: 'qif_ymd',
name: 'Quicken Interchange Format (QIF) File (Year-month-day format)',
extensions: '.qif'
},
{
type: 'qif_mdy',
name: 'Quicken Interchange Format (QIF) File (Month-day-year format)',
extensions: '.qif'
},
{
type: 'qif_dmy',
name: 'Quicken Interchange Format (QIF) File (Day-month-year format)',
extensions: '.qif'
type: 'qif',
name: 'Quicken Interchange Format (QIF) File',
extensions: '.qif',
subTypes: [
{
type: 'qif_ymd',
name: 'Year-month-day format',
},
{
type: 'qif_mdy',
name: 'Month-day-year format',
},
{
type: 'qif_dmy',
name: 'Day-month-year format',
}
]
},
{
type: 'feidee_mymoney_csv',
+14
View File
@@ -1299,10 +1299,24 @@ function getAllSupportedImportFileTypes(i18nGlobal, translateFn) {
document = null;
}
const subTypes = [];
if (fileType.subTypes) {
for (let i = 0; i < fileType.subTypes.length; i++) {
const subType = fileType.subTypes[i];
subTypes.push({
type: subType.type,
displayName: translateFn(subType.name),
});
}
}
allSupportedImportFileTypes.push({
type: fileType.type,
displayName: translateFn(fileType.name),
extensions: fileType.extensions,
subTypes: subTypes.length ? subTypes : undefined,
document: document
});
}
+4 -3
View File
@@ -1518,9 +1518,10 @@
"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)",
"Quicken Interchange Format (QIF) File (Year-month-day format)": "Quicken Interchange Format (QIF) File (Year-month-day format)",
"Quicken Interchange Format (QIF) File (Month-day-year format)": "Quicken Interchange Format (QIF) File (Month-day-year format)",
"Quicken Interchange Format (QIF) File (Day-month-year format)": "Quicken Interchange Format (QIF) File (Day-month-year format)",
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) File",
"Year-month-day format": "Year-month-day format",
"Month-day-year format": "Month-day-year format",
"Day-month-year format": "Day-month-year format",
"Firefly III Data Export File": "Firefly III Data Export File",
"Feidee MyMoney (App) Data Export File": "Feidee MyMoney (App) Data Export File",
"Feidee MyMoney (Web) Data Export File": "Feidee MyMoney (Web) Data Export File",
+4 -3
View File
@@ -1518,9 +1518,10 @@
"How to export this file?": "如何导出该文件?",
"ezbookkeeping Data Export File (CSV)": "ezbookkeeping 数据导出文件 (CSV)",
"ezbookkeeping Data Export File (TSV)": "ezbookkeeping 数据导出文件 (TSV)",
"Quicken Interchange Format (QIF) File (Year-month-day format)": "Quicken Interchange Format (QIF) 文件 (年-月-日 格式)",
"Quicken Interchange Format (QIF) File (Month-day-year format)": "Quicken Interchange Format (QIF) 文件 (月-日-年 格式)",
"Quicken Interchange Format (QIF) File (Day-month-year format)": "Quicken Interchange Format (QIF) 文件 (日-月-年 格式)",
"Quicken Interchange Format (QIF) File": "Quicken Interchange Format (QIF) 文件",
"Year-month-day format": "年-月-日 格式",
"Month-day-year format": "月-日-年 格式",
"Day-month-year format": "日-月-年 格式",
"Firefly III Data Export File": "Firefly III 数据导出文件",
"Feidee MyMoney (App) Data Export File": "金蝶随手记 (App) 数据导出文件",
"Feidee MyMoney (Web) Data Export File": "金蝶随手记 (Web版) 数据导出文件",
@@ -78,6 +78,18 @@
/>
</v-col>
<v-col cols="12" md="12" v-if="allFileSubTypes">
<v-select
item-title="displayName"
item-value="type"
:disabled="submitting"
:label="$t('Type')"
:placeholder="$t('Type')"
:items="allFileSubTypes"
v-model="fileSubType"
/>
</v-col>
<v-col cols="12" md="12">
<v-text-field
readonly
@@ -523,6 +535,7 @@ export default {
clientSessionId: '',
currentStep: 'uploadFile',
fileType: 'ezbookkeeping_csv',
fileSubType: '',
importFile: null,
importTransactions: null,
editingTransaction: null,
@@ -579,6 +592,9 @@ export default {
allSupportedImportFileTypes() {
return this.$locale.getAllSupportedImportFileTypes();
},
allFileSubTypes() {
return getNameByKeyValue(this.allSupportedImportFileTypes, this.fileType, 'type', 'subTypes');
},
allTransactionTypes() {
return transactionConstants.allTransactionTypes;
},
@@ -826,6 +842,10 @@ export default {
},
watch: {
fileType: function () {
if (this.allFileSubTypes && this.allFileSubTypes.length) {
this.fileSubType = this.allFileSubTypes[0].type;
}
this.importFile = null;
this.importTransactions = null;
this.editingTransaction = null;
@@ -893,8 +913,14 @@ export default {
const self = this;
self.submitting = true;
let fileType = self.fileType;
if (self.allFileSubTypes) {
fileType = self.fileSubType;
}
self.transactionsStore.parseImportTransaction({
fileType: self.fileType,
fileType: fileType,
importFile: self.importFile
}).then(response => {
const parsedTransactions = response.items;