|
@@ -36,8 +36,9 @@ import {
|
|
|
} from 'naive-ui'
|
|
|
import Modal from '@/components/modal'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
-import { useForm, datasourceType, datasourceTypeList } from './use-form'
|
|
|
+import { useForm, datasourceType } from './use-form'
|
|
|
import { useDetail } from './use-detail'
|
|
|
+import styles from './index.module.scss'
|
|
|
|
|
|
const props = {
|
|
|
show: {
|
|
@@ -46,13 +47,17 @@ const props = {
|
|
|
},
|
|
|
id: {
|
|
|
type: Number as PropType<number>
|
|
|
+ },
|
|
|
+ selectType: {
|
|
|
+ type: String as PropType<any>,
|
|
|
+ default: 'MYSQL'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const DetailModal = defineComponent({
|
|
|
name: 'DetailModal',
|
|
|
props,
|
|
|
- emits: ['cancel', 'update'],
|
|
|
+ emits: ['cancel', 'update', 'open'],
|
|
|
setup(props, ctx) {
|
|
|
const { t } = useI18n()
|
|
|
|
|
@@ -95,9 +100,15 @@ const DetailModal = defineComponent({
|
|
|
|
|
|
const trim = getCurrentInstance()?.appContext.config.globalProperties.trim
|
|
|
|
|
|
+ const handleSourceModalOpen = () => {
|
|
|
+ ctx.emit('open')
|
|
|
+ }
|
|
|
+
|
|
|
watch(
|
|
|
() => props.show,
|
|
|
async () => {
|
|
|
+ state.detailForm.type = props.selectType
|
|
|
+ state.detailForm.label = props.selectType === 'HIVE' ? 'HIVE/IMPALA' : props.selectType
|
|
|
props.show &&
|
|
|
state.detailForm.type &&
|
|
|
(await changeType(
|
|
@@ -109,6 +120,19 @@ const DetailModal = defineComponent({
|
|
|
}
|
|
|
)
|
|
|
|
|
|
+ watch(
|
|
|
+ () => props.selectType,
|
|
|
+ async () => {
|
|
|
+ state.detailForm.type = props.selectType
|
|
|
+ state.detailForm.label = props.selectType === 'HIVE' ? 'HIVE/IMPALA' : props.selectType
|
|
|
+ state.detailForm.type &&
|
|
|
+ (await changeType(
|
|
|
+ state.detailForm.type,
|
|
|
+ datasourceType[state.detailForm.type]
|
|
|
+ ))
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
return {
|
|
|
t,
|
|
|
...toRefs(state),
|
|
@@ -119,7 +143,8 @@ const DetailModal = defineComponent({
|
|
|
onSubmit,
|
|
|
onTest,
|
|
|
onCancel,
|
|
|
- trim
|
|
|
+ trim,
|
|
|
+ handleSourceModalOpen
|
|
|
}
|
|
|
},
|
|
|
render() {
|
|
@@ -138,12 +163,12 @@ const DetailModal = defineComponent({
|
|
|
loading,
|
|
|
saving,
|
|
|
testing,
|
|
|
- onChangeType,
|
|
|
onChangeTestFlag,
|
|
|
onChangePort,
|
|
|
onCancel,
|
|
|
onTest,
|
|
|
- onSubmit
|
|
|
+ onSubmit,
|
|
|
+ handleSourceModalOpen
|
|
|
} = this
|
|
|
return (
|
|
|
<Modal
|
|
@@ -172,13 +197,10 @@ const DetailModal = defineComponent({
|
|
|
path='type'
|
|
|
show-require-mark
|
|
|
>
|
|
|
- <NSelect
|
|
|
- class='btn-data-source-type-drop-down'
|
|
|
- v-model={[detailForm.type, 'value']}
|
|
|
- options={datasourceTypeList}
|
|
|
- disabled={!!id}
|
|
|
- on-update:value={onChangeType}
|
|
|
- />
|
|
|
+ <div class={[styles.typeBox, !!id && styles.disabledBox]}>
|
|
|
+ <div v-model={[detailForm.type, 'value']}>{detailForm.label}</div>
|
|
|
+ <div class={[styles['text-color'], 'btn-data-source-type-drop-down']} onClick={handleSourceModalOpen}>更换</div>
|
|
|
+ </div>
|
|
|
</NFormItem>
|
|
|
<NFormItem
|
|
|
label={t('datasource.datasource_name')}
|