Browse Source

[Fix][UI] Support only one file upload on the file manage page. (#10007)

(cherry picked from commit 18bfe6399d)
3.0.0/version-upgrade
Amy0104 3 years ago committed by Jiajie Zhong
parent
commit
2eb8c626e3
  1. 16
      dolphinscheduler-ui/src/views/resource/file/upload/index.tsx
  2. 1
      dolphinscheduler-ui/src/views/resource/file/upload/use-form.ts

16
dolphinscheduler-ui/src/views/resource/file/upload/index.tsx

@ -44,16 +44,24 @@ export default defineComponent({
const customRequest = ({ file }: any) => { const customRequest = ({ file }: any) => {
state.uploadForm.name = file.name state.uploadForm.name = file.name
state.uploadForm.file = file.file state.uploadForm.file = file.file
state.uploadFormNameRef.validate({
trigger: 'input'
})
} }
const handleFile = () => { const handleFile = () => {
handleUploadFile(ctx.emit, hideModal, resetForm) handleUploadFile(ctx.emit, hideModal, resetForm)
} }
const removeFile = () => {
state.uploadForm.name = ''
}
return { return {
hideModal, hideModal,
customRequest, customRequest,
handleFile, handleFile,
removeFile,
...toRefs(state) ...toRefs(state)
} }
}, },
@ -70,7 +78,11 @@ export default defineComponent({
confirmLoading={this.saving} confirmLoading={this.saving}
> >
<NForm rules={this.rules} ref='uploadFormRef'> <NForm rules={this.rules} ref='uploadFormRef'>
<NFormItem label={t('resource.file.file_name')} path='name'> <NFormItem
label={t('resource.file.file_name')}
path='name'
ref='uploadFormNameRef'
>
<NInput <NInput
v-model={[this.uploadForm.name, 'value']} v-model={[this.uploadForm.name, 'value']}
placeholder={t('resource.file.enter_name_tips')} placeholder={t('resource.file.enter_name_tips')}
@ -90,6 +102,8 @@ export default defineComponent({
v-model={[this.uploadForm.file, 'value']} v-model={[this.uploadForm.file, 'value']}
customRequest={this.customRequest} customRequest={this.customRequest}
class='btn-upload' class='btn-upload'
max={1}
onRemove={this.removeFile}
> >
<NButton>{t('resource.file.upload_files')}</NButton> <NButton>{t('resource.file.upload_files')}</NButton>
</NUpload> </NUpload>

1
dolphinscheduler-ui/src/views/resource/file/upload/use-form.ts

@ -36,6 +36,7 @@ export function useForm() {
const state = reactive({ const state = reactive({
uploadFormRef: ref(), uploadFormRef: ref(),
uploadFormNameRef: ref(),
uploadForm: defaultValue(), uploadForm: defaultValue(),
saving: false, saving: false,
rules: { rules: {

Loading…
Cancel
Save