mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2026-01-14 06:57:09 +08:00
33 lines
988 B
TypeScript
33 lines
988 B
TypeScript
import { updateFile, type FileItem } from '@/apis'
|
|
import { ref, h } from 'vue'
|
|
import { Modal, Message } from '@arco-design/web-vue'
|
|
import ModalContent from './ModalContent.vue'
|
|
|
|
export function openFileRenameModal(data: FileItem, callback?: () => void) {
|
|
const ModalContentRef = ref<InstanceType<typeof ModalContent>>()
|
|
return Modal.open({
|
|
title: '重命名',
|
|
modalAnimationName: 'el-fade',
|
|
modalStyle: { maxWidth: '450px' },
|
|
width: '90%',
|
|
content: () =>
|
|
h(ModalContent, {
|
|
data,
|
|
ref: (e) => {
|
|
ModalContentRef.value = e as any
|
|
}
|
|
}),
|
|
onBeforeOk: async () => {
|
|
const isInvalid = await ModalContentRef.value?.formRef?.validate()
|
|
const modelParams = ModalContentRef.value?.formRef?.model
|
|
if (isInvalid) return false
|
|
await updateFile({ name: modelParams?.name }, data.id)
|
|
Message.success('重命名成功')
|
|
if (callback) {
|
|
callback()
|
|
}
|
|
return true
|
|
}
|
|
})
|
|
}
|