Skip to content

Commit

Permalink
feat: Fix file name not displaying after upload
Browse files Browse the repository at this point in the history
  • Loading branch information
FU-design committed Feb 24, 2025
1 parent 439ae64 commit 0dbe888
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions bigtop-manager-ui/src/pages/cluster-manage/hosts/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
const hiddenItems = ref<string[]>([])
const autoFormRef = ref<Comp.AutoFormInstance | null>(null)
const formValue = ref<HostReq & { hostname?: string }>({})
const fileName = ref('')
const { locale } = storeToRefs(localeStore)
const isEdit = computed(() => mode.value === 'EDIT')

Expand Down Expand Up @@ -163,7 +164,7 @@
}
},
{
type: 'input',
type: 'inputPassword',
field: 'sshKeyPassword',
formItemProps: {
name: 'sshKeyPassword',
Expand All @@ -174,7 +175,7 @@
}
},
{
type: 'textarea',
type: 'inputPassword',
field: 'sshKeyPasswordAgain',
formItemProps: {
name: 'sshKeyPasswordAgain',
Expand Down Expand Up @@ -428,6 +429,7 @@
authType: '1',
inputType: '1'
}
fileName.value = ''
open.value = false
}

Expand All @@ -452,16 +454,16 @@
formData.append('file', file)
const data = await uploadFile(formData)
formValue.value!.sshKeyFilename = data
fileName.value = file.name
onSuccess(data, file)
message.success(t('common.upload_success'))
} catch (error) {
onError(error)
message.error(t('common.upload_failed'))
fileName.value = ''
}
}

const fileList = ref()

defineExpose({
handleOpen
})
Expand Down Expand Up @@ -492,7 +494,7 @@
<template #sshKeyFilenameSlot="{ item }">
<a-form-item v-bind="item.formItemProps">
<a-upload
:file-list="fileList"
accept="text/plain"
:before-upload="beforeUpload"
:custom-request="customRequest"
:show-upload-list="false"
Expand All @@ -502,34 +504,9 @@
{{ $t('common.upload_file') }}
</a-button>
</a-upload>
<span class="filename">{{ fileName }}</span>
</a-form-item>
</template>
<!-- <template #agentDirSlot="{ item, state }">
<a-form-item>
<template #label>
<div class="question">
<span>
{{ item.formItemProps?.label }}
</span>
<svg-icon style="padding: 1px 0 0 0" name="question" />
</div>
</template>
<a-input v-bind="item.controlProps" v-model:value="state[item.field]" />
</a-form-item>
</template> -->
<!-- <template #grpcPortSlot="{ item, state }">
<a-form-item>
<template #label>
<div class="question">
<span>
{{ item.formItemProps?.label }}
</span>
<svg-icon style="padding: 1px 0 0 0" name="question" />
</div>
</template>
<a-input v-bind="item.controlProps" v-model:value="state[item.field]" />
</a-form-item>
</template> -->
</auto-form>
<template #footer>
<footer>
Expand All @@ -551,6 +528,10 @@
.question {
cursor: pointer;
}
.filename {
color: $color-primary;
padding-inline: $space-sm;
}
footer {
width: 100%;
@include flexbox($justify: flex-end);
Expand Down

0 comments on commit 0dbe888

Please sign in to comment.