@@ -17,6 +17,8 @@ import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
1717import icon_fileExcel_colorful from ' @/assets/datasource/icon_excel.png'
1818import IconOpeDelete from ' @/assets/svg/icon_delete.svg'
1919import { useCache } from ' @/utils/useCache'
20+ import ExcelDetailDialog from ' ./ExcelDetailDialog.vue'
21+ import icon_visible_outlined from ' @/assets/embedded/icon_visible_outlined.svg'
2022
2123const props = withDefaults (
2224 defineProps <{
@@ -34,6 +36,7 @@ const props = withDefaults(
3436)
3537
3638const dsFormRef = ref <FormInstance >()
39+ const excelDetailDialogRef = ref <InstanceType <typeof ExcelDetailDialog >>()
3740const emit = defineEmits ([' refresh' , ' changeActiveStep' , ' close' ])
3841const isCreate = ref (true )
3942const isEditTable = ref (false )
@@ -44,7 +47,7 @@ const tableListLoading = ref(false)
4447const tableListLoadingV1 = ref (false )
4548const checkLoading = ref (false )
4649const dialogTitle = ref (' ' )
47- const getUploadURL = import .meta .env .VITE_API_BASE_URL + ' /datasource/uploadExcel '
50+ const getUploadURL = import .meta .env .VITE_API_BASE_URL + ' /datasource/parseExcel '
4851const saveLoading = ref <boolean >(false )
4952const uploadLoading = ref (false )
5053const { t } = useI18n ()
@@ -54,7 +57,7 @@ const rules = reactive<FormRules>({
5457 name: [
5558 {
5659 required: true ,
57- message: t (' datasource.please_enter' ) + t (' common.empty' ) + t (' ds.form. name' ),
60+ message: t (' datasource.please_enter' ) + t (' common.empty' ) + t (' ds.name' ),
5861 trigger: ' blur' ,
5962 },
6063 { min: 1 , max: 50 , message: t (' ds.form.validate.name_length' ), trigger: ' blur' },
@@ -166,9 +169,7 @@ const initForm = (item: any, editTable: boolean = false) => {
166169 ? configuration .lowVersion
167170 : true
168171 form .value .ssl =
169- configuration .ssl !== null && configuration .ssl !== undefined
170- ? configuration .ssl
171- : false
172+ configuration .ssl !== null && configuration .ssl !== undefined ? configuration .ssl : false
172173 }
173174
174175 if (editTable ) {
@@ -431,15 +432,26 @@ const beforeUpload = (rawFile: any) => {
431432 uploadLoading .value = true
432433 return true
433434}
434-
435+ let fileDetail : any = null
435436const onSuccess = (response : any ) => {
436- form .value .filename = response .data .filename
437- form .value .sheets = response .data .sheets
438- tableList .value = response .data .sheets
437+ fileDetail = response .data
438+ excelDetailDialogRef .value ?.init (response .data )
439439 excelUploadSuccess .value = true
440440 uploadLoading .value = false
441441}
442442
443+ const openFile = () => {
444+ onSuccess ({
445+ data: fileDetail ,
446+ })
447+ }
448+
449+ const saveExcel = (excel : any ) => {
450+ form .value .filename = excel .filename
451+ form .value .sheets = excel .sheets
452+ tableList .value = excel .sheets
453+ }
454+
443455const onError = (e : any ) => {
444456 ElMessage .error (e .toString ())
445457 uploadLoading .value = false
@@ -552,6 +564,26 @@ defineExpose({
552564 :rules =" rules"
553565 @submit.prevent
554566 >
567+ <el-form-item :label =" t('ds.name')" prop =" name" >
568+ <el-input
569+ v-model =" form.name"
570+ clearable
571+ :placeholder =" $t('datasource.please_enter') + $t('common.empty') + t('ds.name')"
572+ />
573+ </el-form-item >
574+ <el-form-item :label =" t('ds.form.description')" >
575+ <el-input
576+ v-model =" form.description"
577+ :placeholder ="
578+ $t('datasource.please_enter') + $t('common.empty') + t('ds.form.description')
579+ "
580+ :rows =" 2"
581+ show-word-limit
582+ maxlength =" 200"
583+ clearable
584+ type =" textarea"
585+ />
586+ </el-form-item >
555587 <div v-if =" form.type === 'excel'" >
556588 <el-form-item prop =" sheets" :label =" t('ds.form.file')" >
557589 <div v-if =" form.filename" class =" pdf-card" >
@@ -560,9 +592,22 @@ defineExpose({
560592 <div class =" name" >{{ form.filename }}</div >
561593 <div class =" size" >{{ form.filename.split('.')[1] }} - {{ fileSize }}</div >
562594 </div >
563- <el-icon v-if =" !form.id" class =" action-btn" size =" 16" @click =" clearFile" >
564- <IconOpeDelete ></IconOpeDelete >
565- </el-icon >
595+ <div
596+ style ="
597+ width : 40px ;
598+ margin-left : auto ;
599+ display : flex ;
600+ align-items : center ;
601+ justify-content : space-between ;
602+ "
603+ >
604+ <el-icon v-if =" !form.id" class =" action-btn" size =" 16" @click =" openFile" >
605+ <icon _visible_outlined ></icon _visible_outlined >
606+ </el-icon >
607+ <el-icon v-if =" !form.id" class =" action-btn" size =" 16" @click =" clearFile" >
608+ <IconOpeDelete ></IconOpeDelete >
609+ </el-icon >
610+ </div >
566611 </div >
567612 <el-upload
568613 v-if =" form.filename && !form.id"
@@ -602,26 +647,6 @@ defineExpose({
602647 <span v-if =" !form.filename" class =" not_exceed" >{{ $t('common.not_exceed_50mb') }}</span >
603648 </el-form-item >
604649 </div >
605- <el-form-item :label =" t('ds.form.name')" prop =" name" >
606- <el-input
607- v-model =" form.name"
608- clearable
609- :placeholder =" $t('datasource.please_enter') + $t('common.empty') + t('ds.form.name')"
610- />
611- </el-form-item >
612- <el-form-item :label =" t('ds.form.description')" >
613- <el-input
614- v-model =" form.description"
615- :placeholder ="
616- $t('datasource.please_enter') + $t('common.empty') + t('ds.form.description')
617- "
618- :rows =" 2"
619- show-word-limit
620- maxlength =" 200"
621- clearable
622- type =" textarea"
623- />
624- </el-form-item >
625650 <div v-if =" form.type !== 'excel'" style =" margin-top : 16px " >
626651 <el-form-item
627652 :label =" form.type !== 'es' ? t('ds.form.host') : t('ds.form.address')"
@@ -694,11 +719,7 @@ defineExpose({
694719 >
695720 <el-checkbox v-model =" form.lowVersion" :label =" t('ds.form.low_version')" />
696721 </el-form-item >
697- <el-form-item
698- v-if =" form.type === 'mysql'"
699- :label =" t('ds.form.ssl')"
700- prop =" ssl"
701- >
722+ <el-form-item v-if =" form.type === 'mysql'" :label =" t('ds.form.ssl')" prop =" ssl" >
702723 <el-switch v-model =" form.ssl" />
703724 </el-form-item >
704725 <el-form-item v-if =" form.type !== 'es'" :label =" t('ds.form.extra_jdbc')" >
@@ -829,6 +850,7 @@ defineExpose({
829850 </el-button >
830851 </div >
831852 </div >
853+ <ExcelDetailDialog ref =" excelDetailDialogRef" @finish =" saveExcel" />
832854</template >
833855
834856<style lang="less" scoped>
@@ -898,10 +920,6 @@ defineExpose({
898920 }
899921 }
900922
901- .action-btn {
902- margin-left : auto ;
903- }
904-
905923 .ed-icon {
906924 position : relative ;
907925 cursor : pointer ;
0 commit comments