You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.7 KiB
Vue
65 lines
1.7 KiB
Vue
<template>
|
|
<BasicModal
|
|
v-bind="$attrs"
|
|
@register="registerModal"
|
|
title="重命名"
|
|
height="100"
|
|
@ok="handleSubmit"
|
|
>
|
|
<BasicForm @register="registerForm" />
|
|
</BasicModal>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { ref } from 'vue';
|
|
import { BasicModal, useModalInner } from '@/components/Modal';
|
|
import { BasicForm, useForm } from '@/components/Form';
|
|
import { renameSchema } from '../modal.data';
|
|
|
|
import { orgPosGroup } from '@/api/demo/system';
|
|
import { useMessage } from '@/hooks/web/useMessage';
|
|
const { createMessage } = useMessage();
|
|
|
|
const emit = defineEmits(['success']);
|
|
|
|
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
|
labelWidth: 100,
|
|
baseColProps: { span: 24 },
|
|
schemas: renameSchema,
|
|
showActionButtonGroup: false,
|
|
});
|
|
|
|
// 上级文件夹的id
|
|
let id = ref();
|
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
|
resetFields();
|
|
setModalProps({ confirmLoading: false });
|
|
id.value = data.record?.id;
|
|
setFieldsValue({
|
|
...data.record,
|
|
});
|
|
});
|
|
|
|
// 提交
|
|
async function handleSubmit() {
|
|
try {
|
|
const values = await validate();
|
|
let query = {
|
|
id: id.value,
|
|
name: values.name,
|
|
};
|
|
// 调用接口
|
|
const data = await orgPosGroup(query);
|
|
if (data) {
|
|
setModalProps({ confirmLoading: true });
|
|
closeModal();
|
|
emit('success');
|
|
return createMessage.success('重命名成功');
|
|
} else {
|
|
return createMessage.error('重命名失败');
|
|
}
|
|
} finally {
|
|
setModalProps({ confirmLoading: false });
|
|
}
|
|
}
|
|
</script>
|