|
|
|
@ -1,199 +1,112 @@ |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<w-form |
|
|
|
v-model="valueReactive" |
|
|
|
:cols-num="12" |
|
|
|
:fields="[ |
|
|
|
{ |
|
|
|
colSpan: 2, |
|
|
|
name: 'datasource', |
|
|
|
label: $t('developer.backend.export.liquibase.datasource'), |
|
|
|
type: 'w-select', |
|
|
|
options: datasourceOptionsRef, |
|
|
|
onUpdateValue: (args) => { |
|
|
|
datasourceChanged(args.value); |
|
|
|
}, |
|
|
|
<w-grid |
|
|
|
ref="i18nGridRef" |
|
|
|
:title="$t('system.i18n.grid.title')" |
|
|
|
:config-button="true" |
|
|
|
db-click-operation="edit" |
|
|
|
selection="multiple" |
|
|
|
:checkbox-selection="true" |
|
|
|
:data-url="Environment.apiContextPath('/api/system/i18n')" |
|
|
|
:query-form-fields="[ |
|
|
|
{ name: 'code', label: $t('code'), type: 'w-text' }, |
|
|
|
{ name: 'message', label: $t('i18nMessage'), type: 'w-text' }, |
|
|
|
{ name: 'lang', label: $t('language'), type: 'w-select', options: Options.enum(LanguageEnum), queryOperator: 'equals' }, |
|
|
|
]" |
|
|
|
:toolbar-configure="{ noIcon: false }" |
|
|
|
:toolbar-actions="[ |
|
|
|
'query', |
|
|
|
'refresh', |
|
|
|
'separator', |
|
|
|
'add', |
|
|
|
'clone', |
|
|
|
'edit', |
|
|
|
'remove', |
|
|
|
{ |
|
|
|
name: 'deleteAll', |
|
|
|
label: $t('deleteAll'), |
|
|
|
icon: 'bi-trash3', |
|
|
|
click: () => { |
|
|
|
DialogManager.confirm($t('system.i18n.grid.toolbar.removeAll.tip'), () => { |
|
|
|
axios.post(Environment.apiContextPath('/api/system/i18n/removeMessages'), {}, { loading: true }).then(() => { |
|
|
|
NotifyManager.info($t('operationSuccess')); |
|
|
|
i18nGridRef.refresh(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
{ |
|
|
|
colSpan: 2, |
|
|
|
name: 'catalog', |
|
|
|
label: $t('developer.backend.export.liquibase.catalog'), |
|
|
|
type: 'w-select', |
|
|
|
options: catalogOptionsRef, |
|
|
|
onUpdateValue: (args) => { |
|
|
|
catalogChanged(valueReactive.datasource, args.value); |
|
|
|
}, |
|
|
|
}, |
|
|
|
'separator', |
|
|
|
{ |
|
|
|
name: 'importAll', |
|
|
|
label: $t('import'), |
|
|
|
icon: 'bi-arrow-right-circle', |
|
|
|
click: () => { |
|
|
|
DialogManager.confirm($t('system.i18n.grid.toolbar.importAll.tip'), () => { |
|
|
|
axios.post(Environment.apiContextPath('/api/system/i18n/importMessages'), {}, { loading: true }).then(() => { |
|
|
|
NotifyManager.info($t('operationSuccess')); |
|
|
|
i18nGridRef.refresh(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
{ |
|
|
|
colSpan: 2, |
|
|
|
name: 'schema', |
|
|
|
label: $t('developer.backend.export.liquibase.schema'), |
|
|
|
type: 'w-select', |
|
|
|
options: schemaOptionsRef, |
|
|
|
onUpdateValue: (args) => { |
|
|
|
schemaChanged(valueReactive.datasource, valueReactive.catalog, args.value); |
|
|
|
}, |
|
|
|
}, |
|
|
|
'separator', |
|
|
|
{ |
|
|
|
name: 'reload', |
|
|
|
label: $t('reload'), |
|
|
|
icon: 'bi-arrow-repeat', |
|
|
|
click: (args) => { |
|
|
|
axios.post(Environment.apiContextPath('/api/system/i18n/reload')).then(() => { |
|
|
|
NotifyManager.info($t('operationSuccess')); |
|
|
|
}); |
|
|
|
}, |
|
|
|
{ |
|
|
|
colSpan: 6, |
|
|
|
name: 'tables', |
|
|
|
label: $t('developer.backend.export.liquibase.tables'), |
|
|
|
type: 'w-grid-select', |
|
|
|
multiple: true, |
|
|
|
displayValue: 'name', |
|
|
|
grid: { |
|
|
|
denseBody: true, |
|
|
|
hideBottom: true, |
|
|
|
configButton: true, |
|
|
|
checkboxSelection: true, |
|
|
|
primaryKey: 'name', |
|
|
|
dataUrl: Environment.apiContextPath( |
|
|
|
'/api/jdbc/metadata/getTables?datasource=' + |
|
|
|
(valueReactive.datasource || '') + |
|
|
|
'&catalog=' + |
|
|
|
(valueReactive.catalog || '') + |
|
|
|
'&schema=' + |
|
|
|
(valueReactive.schema || ''), |
|
|
|
), |
|
|
|
pageable: false, |
|
|
|
sortBy: ['type', 'namec', '-lastModifyDate'], |
|
|
|
sortNo: true, |
|
|
|
toolbarConfigure: { noIcon: false }, |
|
|
|
toolbarActions: ['refresh'], |
|
|
|
columns: [ |
|
|
|
{ name: 'name', label: $t('name') }, |
|
|
|
{ name: 'remarks', label: $t('remarks') }, |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ colSpan: 12, name: 'sql', label: $t('SQL'), type: 'w-code-mirror', toolbar: false, lang: 'sql' }, |
|
|
|
]" |
|
|
|
> |
|
|
|
</w-form> |
|
|
|
<div class="row justify-center q-gutter-md py-2"> |
|
|
|
<w-progress-btn |
|
|
|
ref="progressBtnRef" |
|
|
|
icon="bi-database-down" |
|
|
|
:label="$t('export')" |
|
|
|
data-url="/api/jdbc/data/traceExporterExecuteProgress" |
|
|
|
@click="exportData" |
|
|
|
@success=" |
|
|
|
(progressInfo) => { |
|
|
|
Downloader.get(Environment.apiContextPath('/api/mvc/download?filePath=' + encodeURIComponent(progressInfo.result))); |
|
|
|
} |
|
|
|
" |
|
|
|
></w-progress-btn> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
}, |
|
|
|
'separator', |
|
|
|
'view', |
|
|
|
'separator', |
|
|
|
'export', |
|
|
|
]" |
|
|
|
:columns="[ |
|
|
|
{ width: 500, name: 'code', label: $t('code') }, |
|
|
|
{ width: 100, name: 'lang', label: $t('language'), format: Formater.enum(LanguageEnum) }, |
|
|
|
{ width: '100%', name: 'message', label: $t('i18nMessage') }, |
|
|
|
]" |
|
|
|
:editor="{ |
|
|
|
dialog: { |
|
|
|
width: '600px', |
|
|
|
}, |
|
|
|
form: { |
|
|
|
colsNum: 1, |
|
|
|
fields: [ |
|
|
|
{ name: 'code', label: $t('code'), type: 'w-text', requiredIf: true }, |
|
|
|
{ name: 'lang', label: $t('language'), type: 'w-select', requiredIf: true, options: Options.enum(LanguageEnum) }, |
|
|
|
{ name: 'message', label: $t('i18nMessage'), type: 'w-text', requiredIf: true }, |
|
|
|
], |
|
|
|
}, |
|
|
|
}" |
|
|
|
:viewer="{ |
|
|
|
panel: { |
|
|
|
columnNum: 1, |
|
|
|
fields: [ |
|
|
|
{ name: 'id', label: $t('id') }, |
|
|
|
{ name: 'code', label: $t('code') }, |
|
|
|
{ name: 'lang', label: $t('language'), format: Formater.none() }, |
|
|
|
{ name: 'message', label: $t('i18nMessage') }, |
|
|
|
{ name: 'dataComeFrom', label: $t('dataComeFrom') }, |
|
|
|
{ name: 'creator', label: $t('creator') }, |
|
|
|
{ name: 'createDate', label: $t('createDate') }, |
|
|
|
{ name: 'lastModifier', label: $t('lastModifier') }, |
|
|
|
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() }, |
|
|
|
{ name: 'corporationCode', label: $t('corporationCode') }, |
|
|
|
], |
|
|
|
}, |
|
|
|
}" |
|
|
|
@row-click="(evt, row, index) => {}" |
|
|
|
></w-grid> |
|
|
|
</template> |
|
|
|
<script setup lang="ts"> |
|
|
|
import 'tailwindcss/utilities.css'; |
|
|
|
import { ref, reactive, onMounted, onUpdated } from 'vue'; |
|
|
|
|
|
|
|
import { t, axios, Environment, DialogManager, Downloader } from '@/platform'; |
|
|
|
|
|
|
|
const progressBtnRef = ref(); |
|
|
|
const datasourceOptionsRef = ref([]); |
|
|
|
const catalogOptionsRef = ref([]); |
|
|
|
const schemaOptionsRef = ref([]); |
|
|
|
const tablesOptionsRef = ref([]); |
|
|
|
|
|
|
|
const valueReactive = reactive({ |
|
|
|
datasource: undefined, |
|
|
|
catalog: undefined, |
|
|
|
schema: undefined, |
|
|
|
tables: [], |
|
|
|
sql: undefined, |
|
|
|
}); |
|
|
|
|
|
|
|
const loadDatasource = () => { |
|
|
|
axios.get(Environment.apiContextPath('/api/system/datasource?pageable=false&sortBy=name')).then((response) => { |
|
|
|
const data = response?.data.content; |
|
|
|
const datasourceOptions = [{ label: t('default'), value: '' }]; |
|
|
|
if (data && data.length > 0) { |
|
|
|
for (let item of data) { |
|
|
|
datasourceOptions.push({ label: item.name, value: item.name }); |
|
|
|
} |
|
|
|
} |
|
|
|
datasourceOptionsRef.value = datasourceOptions; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const datasourceChanged = (datasource: string) => { |
|
|
|
datasource = datasource || ''; |
|
|
|
axios.get(Environment.apiContextPath('/api/jdbc/metadata/getCatalogs?datasource=' + datasource)).then((response) => { |
|
|
|
const data = response?.data; |
|
|
|
const catalogOptions = []; |
|
|
|
if (data && data.length > 0) { |
|
|
|
for (let item of data) { |
|
|
|
catalogOptions.push({ label: item.name, value: item.name }); |
|
|
|
} |
|
|
|
} |
|
|
|
catalogOptionsRef.value = catalogOptions; |
|
|
|
schemaOptionsRef.value = []; |
|
|
|
tablesOptionsRef.value = []; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const catalogChanged = (datasource: string, catalog: string) => { |
|
|
|
datasource = datasource || ''; |
|
|
|
axios.get(Environment.apiContextPath('/api/jdbc/metadata/getSchemas?datasource=' + datasource + '&catalog=' + catalog)).then((response) => { |
|
|
|
const data = response?.data; |
|
|
|
const schemaOptions = []; |
|
|
|
if (data && data.length > 0) { |
|
|
|
for (let item of data) { |
|
|
|
schemaOptions.push({ label: item.name, value: item.name }); |
|
|
|
} |
|
|
|
} |
|
|
|
schemaOptionsRef.value = schemaOptions; |
|
|
|
tablesOptionsRef.value = []; |
|
|
|
if (schemaOptions.length === 0) { |
|
|
|
schemaChanged(datasource, catalog, ''); |
|
|
|
} else if (schemaOptions.length === 1) { |
|
|
|
schemaChanged(datasource, catalog, schemaOptions[0]); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const schemaChanged = (datasource: string, catalog: string, schema: string) => { |
|
|
|
datasource = datasource || ''; |
|
|
|
catalog = catalog || ''; |
|
|
|
schema = schema || ''; |
|
|
|
axios |
|
|
|
.get(Environment.apiContextPath('/api/jdbc/metadata/getTables?datasource=' + datasource + '&catalog=' + catalog + '&schema=' + schema)) |
|
|
|
.then((response) => { |
|
|
|
const data = response?.data; |
|
|
|
const tablesOptions = []; |
|
|
|
if (data && data.length > 0) { |
|
|
|
for (let item of data) { |
|
|
|
tablesOptions.push({ label: item.name + ' - ' + item.remarks, value: item.name }); |
|
|
|
} |
|
|
|
} |
|
|
|
tablesOptionsRef.value = tablesOptions; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const exportData = (e) => { |
|
|
|
DialogManager.confirm(t('developer.backend.export.liquibase.export.tip'), () => { |
|
|
|
const data = valueReactive; |
|
|
|
const config = { |
|
|
|
datasource: data.datasource, |
|
|
|
schema: data.schema, |
|
|
|
tables: [], |
|
|
|
}; |
|
|
|
const length = data.tables.length; |
|
|
|
const sql = length === 1 ? data.sql : ''; |
|
|
|
for (let i = 0; i < length; i++) { |
|
|
|
config.tables[i] = { name: data.tables[i], sql: sql ? sql : 'select * from ' + data.tables[i] }; |
|
|
|
} |
|
|
|
axios.post(Environment.apiContextPath('/api/jdbc/data/exportData'), config).then((response) => { |
|
|
|
progressBtnRef.value.start(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
import { ref } from 'vue'; |
|
|
|
import { axios, Environment, EnumTools, Formater, Options, DialogManager, NotifyManager } from '@/platform'; |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
loadDatasource(); |
|
|
|
datasourceChanged(''); |
|
|
|
}); |
|
|
|
const i18nGridRef = ref(); |
|
|
|
const LanguageEnum = await EnumTools.fetch('io.sc.platform.core.enums.Language'); |
|
|
|
</script> |
|
|
|
|