diff --git a/src/components/ExportData.vue b/src/components/ExportData.vue index 746f992e2..ec1925d20 100644 --- a/src/components/ExportData.vue +++ b/src/components/ExportData.vue @@ -212,7 +212,9 @@ export default class ExportData extends Vue { } const exportDataToCSV = (jsonContent: ConnectionModel[]) => { try { - const content: string = CSVConvert(jsonContent) + // Prevent CSV from automatically converting string with trailing zeros after decimal point to number. + // https://stackoverflow.com/questions/165042/stop-excel-from-automatically-converting-certain-text-values-to-dates + const content: string = CSVConvert(jsonContent).replace(/"(\d+\.0+)"/g, '="$1"') this.exportDiffFormatData(content, 'CSV') } catch (err) { this.$message.error(err.toString()) diff --git a/src/components/ImportData.vue b/src/components/ImportData.vue index 976e6b063..4f23a8bea 100644 --- a/src/components/ImportData.vue +++ b/src/components/ImportData.vue @@ -318,10 +318,11 @@ export default class ImportData extends Vue { .fromString(data) .subscribe((jsonObj) => { try { - let { messages, subscriptions, will, ...otherProps } = jsonObj + let { messages, subscriptions, properties, will, ...otherProps } = jsonObj // format object messages = JSON.parse(messages) subscriptions = JSON.parse(subscriptions) + properties = JSON.parse(properties) will = JSON.parse(will) Object.keys(otherProps).forEach((item) => { // format boolean @@ -330,14 +331,20 @@ export default class ImportData extends Vue { } else if (otherProps[item] === 'false') { otherProps[item] = false } else if (this.stringProps.indexOf(item) === -1 && otherProps[item] !== '') { - // format number - const numValue = Number(otherProps[item]) - otherProps[item] = !isNaN(numValue) ? numValue : otherProps[item] + if (/^="(\d+\.0+)"/.test(otherProps[item])) { + // format string number + otherProps[item] = otherProps[item].replace(/^="(\d+\.0+)"/, '$1') + } else { + // format number + const numValue = Number(otherProps[item]) + otherProps[item] = !isNaN(numValue) ? numValue : otherProps[item] + } } }) const oneRealJSONObj = { messages, subscriptions, + properties, will, ...otherProps, } diff --git a/src/database/services/ConnectionService.ts b/src/database/services/ConnectionService.ts index 8106d8b7e..ff16ee251 100644 --- a/src/database/services/ConnectionService.ts +++ b/src/database/services/ConnectionService.ts @@ -355,7 +355,7 @@ export default class ConnectionService { // cascade getAll public async cascadeGetAll(id?: string) { - const query = await this.connectionRepository.createQueryBuilder('cn') + const query = this.connectionRepository.createQueryBuilder('cn') id && query.where('cn.id = :id', { id })