Compare commits
3 Commits
c86c6fc43b
...
452bc7a0a6
Author | SHA1 | Date |
---|---|---|
|
452bc7a0a6 | 3 weeks ago |
|
b01110c0e3 | 3 weeks ago |
|
eb8d2f34e1 | 3 weeks ago |
55 changed files with 1122 additions and 639 deletions
@ -1,82 +1,199 @@ |
|||
<template> |
|||
<w-grid |
|||
ref="userGridRef" |
|||
:title="$t('system.user.grid.title')" |
|||
:config-button="true" |
|||
selection="multiple" |
|||
db-click-operation="edit" |
|||
:checkbox-selection="true" |
|||
:data-url="Environment.apiContextPath('/api/system/user')" |
|||
:sort-by="['loginName']" |
|||
:query-form-cols-num="3" |
|||
:query-form-fields="[ |
|||
{ name: 'loginName', label: $t('loginName'), type: 'w-text' }, |
|||
{ name: 'userName', label: $t('userName'), type: 'w-text' }, |
|||
{ name: 'enable', label: $t('isEnable'), type: 'w-select', options: Options.yesNo(), queryOperator: 'equals' }, |
|||
]" |
|||
:toolbar-configure="{ noIcon: false }" |
|||
:toolbar-actions="['query', 'refresh', 'separator', 'add', 'clone', 'edit', 'remove', 'separator', 'view', 'separator', 'export']" |
|||
:columns="[ |
|||
{ width: 200, name: 'loginName', label: $t('loginName') }, |
|||
{ width: '100%', name: 'userName', label: $t('userName') }, |
|||
]" |
|||
:editor="{ |
|||
dialog: { |
|||
width: '800px', |
|||
}, |
|||
form: { |
|||
colsNum: 4, |
|||
fields: [ |
|||
{ name: 'loginName', label: $t('loginName'), type: 'w-text', requiredIf: true, colSpan: 2 }, |
|||
{ name: 'userName', label: $t('userName'), type: 'w-text', requiredIf: true, colSpan: 2 }, |
|||
{ name: 'description', label: $t('description'), type: 'w-textarea', rows: 1, colSpan: 2 }, |
|||
{ name: 'password', label: $t('password'), type: 'w-password', colSpan: 2 }, |
|||
{ name: 'mobile', label: $t('mobile'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'phone', label: $t('phone'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'email', label: $t('email'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'weixin', label: $t('weixin'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'qq', label: $t('qq'), type: 'w-text', colSpan: 2 }, |
|||
|
|||
{ name: 'enable', label: $t('enable'), type: 'w-checkbox', defaultValue: true, colsFirst: true }, |
|||
{ name: 'accountExpired', label: $t('accountExpired'), type: 'w-checkbox', defaultValue: false }, |
|||
{ name: 'accountLocked', label: $t('accountLocked'), type: 'w-checkbox', defaultValue: false }, |
|||
{ name: 'credentialsExpired', label: $t('credentialsExpired'), type: 'w-checkbox', defaultValue: false }, |
|||
], |
|||
}, |
|||
}" |
|||
:viewer="{ |
|||
panel: { |
|||
columnNum: 1, |
|||
fields: [ |
|||
{ name: 'id', label: $t('id') }, |
|||
{ name: 'loginName', label: $t('loginName') }, |
|||
{ name: 'userName', label: $t('userName') }, |
|||
{ name: 'description', label: $t('description') }, |
|||
{ name: 'enable', label: $t('enable'), format: Formater.none() }, |
|||
{ name: 'accountExpired', label: $t('accountExpired') }, |
|||
{ name: 'accountLocked', label: $t('accountLocked') }, |
|||
{ name: 'credentialsExpired', label: $t('credentialsExpired') }, |
|||
{ name: 'email', label: $t('email') }, |
|||
{ name: 'phone', label: $t('phone') }, |
|||
{ name: 'mobile', label: $t('mobile') }, |
|||
{ name: 'weixin', label: $t('weixin') }, |
|||
{ name: 'qq', label: $t('qq') }, |
|||
{ 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') }, |
|||
], |
|||
}, |
|||
}" |
|||
></w-grid> |
|||
<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); |
|||
}, |
|||
}, |
|||
{ |
|||
colSpan: 2, |
|||
name: 'catalog', |
|||
label: $t('developer.backend.export.liquibase.catalog'), |
|||
type: 'w-select', |
|||
options: catalogOptionsRef, |
|||
onUpdateValue: (args) => { |
|||
catalogChanged(valueReactive.datasource, args.value); |
|||
}, |
|||
}, |
|||
{ |
|||
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); |
|||
}, |
|||
}, |
|||
{ |
|||
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> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { ref } from 'vue'; |
|||
import { Environment, SessionManager, axios, Options, Formater, EnumTools } from '@/platform'; |
|||
import SelectUserGrid from './shared/SelectUserGrid.vue'; |
|||
import SelectMenuTreeGrid from './shared/SelectMenuTreeGrid.vue'; |
|||
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(); |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
const userGridRef = ref(); |
|||
onMounted(() => { |
|||
loadDatasource(); |
|||
datasourceChanged(''); |
|||
}); |
|||
</script> |
|||
|
@ -1,82 +1,199 @@ |
|||
<template> |
|||
<w-grid |
|||
ref="userGridRef" |
|||
:title="$t('system.user.grid.title')" |
|||
:config-button="true" |
|||
selection="multiple" |
|||
db-click-operation="edit" |
|||
:checkbox-selection="true" |
|||
:data-url="Environment.apiContextPath('/api/system/user')" |
|||
:sort-by="['loginName']" |
|||
:query-form-cols-num="3" |
|||
:query-form-fields="[ |
|||
{ name: 'loginName', label: $t('loginName'), type: 'w-text' }, |
|||
{ name: 'userName', label: $t('userName'), type: 'w-text' }, |
|||
{ name: 'enable', label: $t('isEnable'), type: 'w-select', options: Options.yesNo(), queryOperator: 'equals' }, |
|||
]" |
|||
:toolbar-configure="{ noIcon: false }" |
|||
:toolbar-actions="['query', 'refresh', 'separator', 'add', 'clone', 'edit', 'remove', 'separator', 'view', 'separator', 'export']" |
|||
:columns="[ |
|||
{ width: 200, name: 'loginName', label: $t('loginName') }, |
|||
{ width: '100%', name: 'userName', label: $t('userName') }, |
|||
]" |
|||
:editor="{ |
|||
dialog: { |
|||
width: '800px', |
|||
}, |
|||
form: { |
|||
colsNum: 4, |
|||
fields: [ |
|||
{ name: 'loginName', label: $t('loginName'), type: 'w-text', requiredIf: true, colSpan: 2 }, |
|||
{ name: 'userName', label: $t('userName'), type: 'w-text', requiredIf: true, colSpan: 2 }, |
|||
{ name: 'description', label: $t('description'), type: 'w-textarea', rows: 1, colSpan: 2 }, |
|||
{ name: 'password', label: $t('password'), type: 'w-password', colSpan: 2 }, |
|||
{ name: 'mobile', label: $t('mobile'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'phone', label: $t('phone'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'email', label: $t('email'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'weixin', label: $t('weixin'), type: 'w-text', colSpan: 2 }, |
|||
{ name: 'qq', label: $t('qq'), type: 'w-text', colSpan: 2 }, |
|||
|
|||
{ name: 'enable', label: $t('enable'), type: 'w-checkbox', defaultValue: true, colsFirst: true }, |
|||
{ name: 'accountExpired', label: $t('accountExpired'), type: 'w-checkbox', defaultValue: false }, |
|||
{ name: 'accountLocked', label: $t('accountLocked'), type: 'w-checkbox', defaultValue: false }, |
|||
{ name: 'credentialsExpired', label: $t('credentialsExpired'), type: 'w-checkbox', defaultValue: false }, |
|||
], |
|||
}, |
|||
}" |
|||
:viewer="{ |
|||
panel: { |
|||
columnNum: 1, |
|||
fields: [ |
|||
{ name: 'id', label: $t('id') }, |
|||
{ name: 'loginName', label: $t('loginName') }, |
|||
{ name: 'userName', label: $t('userName') }, |
|||
{ name: 'description', label: $t('description') }, |
|||
{ name: 'enable', label: $t('enable'), format: Formater.none() }, |
|||
{ name: 'accountExpired', label: $t('accountExpired') }, |
|||
{ name: 'accountLocked', label: $t('accountLocked') }, |
|||
{ name: 'credentialsExpired', label: $t('credentialsExpired') }, |
|||
{ name: 'email', label: $t('email') }, |
|||
{ name: 'phone', label: $t('phone') }, |
|||
{ name: 'mobile', label: $t('mobile') }, |
|||
{ name: 'weixin', label: $t('weixin') }, |
|||
{ name: 'qq', label: $t('qq') }, |
|||
{ 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') }, |
|||
], |
|||
}, |
|||
}" |
|||
></w-grid> |
|||
<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); |
|||
}, |
|||
}, |
|||
{ |
|||
colSpan: 2, |
|||
name: 'catalog', |
|||
label: $t('developer.backend.export.liquibase.catalog'), |
|||
type: 'w-select', |
|||
options: catalogOptionsRef, |
|||
onUpdateValue: (args) => { |
|||
catalogChanged(valueReactive.datasource, args.value); |
|||
}, |
|||
}, |
|||
{ |
|||
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); |
|||
}, |
|||
}, |
|||
{ |
|||
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> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { ref } from 'vue'; |
|||
import { Environment, SessionManager, axios, Options, Formater, EnumTools } from '@/platform'; |
|||
import SelectUserGrid from './shared/SelectUserGrid.vue'; |
|||
import SelectMenuTreeGrid from './shared/SelectMenuTreeGrid.vue'; |
|||
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(); |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
const userGridRef = ref(); |
|||
onMounted(() => { |
|||
loadDatasource(); |
|||
datasourceChanged(''); |
|||
}); |
|||
</script> |
|||
|
@ -1,4 +0,0 @@ |
|||
<template> |
|||
<div>XXX</div> |
|||
</template> |
|||
<script setup lang="ts"></script> |
@ -0,0 +1,245 @@ |
|||
<template> |
|||
<div> |
|||
<div class="row py-1 q-col-gutter-sm"> |
|||
<div class="col-2"> |
|||
<q-select |
|||
v-model="valueReactive.datasource" |
|||
:label="$t('developer.backend.export.liquibase.datasource')" |
|||
outlined |
|||
dense |
|||
emit-value |
|||
map-options |
|||
:options="datasourceOptionsRef" |
|||
default-value="" |
|||
@update:model-value=" |
|||
(value) => { |
|||
datasourceChanged(value); |
|||
} |
|||
" |
|||
></q-select> |
|||
</div> |
|||
<div class="col-2"> |
|||
<q-select |
|||
v-model="valueReactive.catalog" |
|||
:label="$t('developer.backend.export.liquibase.catalog')" |
|||
outlined |
|||
dense |
|||
emit-value |
|||
map-options |
|||
:options="catalogOptionsRef" |
|||
@update:model-value=" |
|||
(value) => { |
|||
catalogChanged(valueReactive.datasource, value); |
|||
} |
|||
" |
|||
></q-select> |
|||
</div> |
|||
<div class="col-2"> |
|||
<q-select |
|||
v-model="valueReactive.schema" |
|||
:label="$t('developer.backend.export.liquibase.schema')" |
|||
outlined |
|||
dense |
|||
emit-value |
|||
map-options |
|||
:options="schemaOptionsRef" |
|||
@update:model-value=" |
|||
(value) => { |
|||
schemaChanged(valueReactive.datasource, valueReactive.catalog, value); |
|||
} |
|||
" |
|||
></q-select> |
|||
</div> |
|||
<div class="col-6"> |
|||
<q-select |
|||
v-model="valueReactive.tables" |
|||
:label="$t('developer.backend.export.liquibase.tables')" |
|||
outlined |
|||
dense |
|||
emit-value |
|||
map-options |
|||
multiple |
|||
use-chips |
|||
:options="tablesOptionsRef" |
|||
@update:model-value=" |
|||
(value) => { |
|||
if (value) { |
|||
if (value.length > 1) { |
|||
valueReactive.sql = 'select * from ${table}'; |
|||
} else { |
|||
valueReactive.sql = 'select * from ' + value; |
|||
} |
|||
} |
|||
} |
|||
" |
|||
> |
|||
<template #append> |
|||
<q-btn |
|||
:title="$t('selectAll')" |
|||
icon="bi-check-square" |
|||
flat |
|||
dense |
|||
:disable="!(tablesOptionsRef?.length > 0)" |
|||
@click.stop.prevent=" |
|||
() => { |
|||
const selecteds = []; |
|||
if (tablesOptionsRef) { |
|||
for (const table of tablesOptionsRef) { |
|||
selecteds.push(table.value); |
|||
} |
|||
} |
|||
valueReactive.tables = selecteds; |
|||
} |
|||
" |
|||
/> |
|||
<q-btn |
|||
:title="$t('unSelectAll')" |
|||
icon="bi-square" |
|||
flat |
|||
dense |
|||
:disable="!(tablesOptionsRef?.length > 0)" |
|||
@click.stop.prevent=" |
|||
() => { |
|||
valueReactive.tables = []; |
|||
} |
|||
" |
|||
/> |
|||
</template> |
|||
</q-select> |
|||
</div> |
|||
</div> |
|||
<div class="row py-1 q-col-gutter-sm"> |
|||
<div class="col-12"> |
|||
<w-code-mirror v-model="valueReactive.sql" label="SQL" :rows="5" lang="sql" :toolbar="false"></w-code-mirror> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- |
|||
<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> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import 'tailwindcss/utilities.css'; |
|||
import { ref, reactive, onMounted, onUpdated } from 'vue'; |
|||
|
|||
import { t, axios, Environment, DialogManager, Downloader } from 'platform-core'; |
|||
|
|||
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: undefined, |
|||
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(); |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
onMounted(() => { |
|||
loadDatasource(); |
|||
datasourceChanged(''); |
|||
}); |
|||
</script> |
@ -0,0 +1,13 @@ |
|||
package io.sc.platform.jdbc.meta.support; |
|||
|
|||
public class Catalog { |
|||
private String name; |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
} |
Loading…
Reference in new issue