管理后台初始化,登录,团队管理,报价单管理 完成
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import React from 'react';
|
||||
import { Form, Input, Select, Upload } from 'antd';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import { supabase } from '@/config/supabase';
|
||||
|
||||
export const TeamForm = ({ form }) => {
|
||||
const handleUpload = async ({ file, onSuccess, onError }) => {
|
||||
try {
|
||||
const fileExt = file.name.split('.').pop();
|
||||
const fileName = `${Math.random()}.${fileExt}`;
|
||||
const filePath = `team-avatars/${fileName}`;
|
||||
|
||||
const { error: uploadError } = await supabase.storage
|
||||
.from('avatars')
|
||||
.upload(filePath, file);
|
||||
|
||||
if (uploadError) throw uploadError;
|
||||
|
||||
const { data: { publicUrl } } = supabase.storage
|
||||
.from('avatars')
|
||||
.getPublicUrl(filePath);
|
||||
|
||||
form.setFieldValue('avatarUrl', publicUrl);
|
||||
onSuccess(publicUrl);
|
||||
} catch (error) {
|
||||
console.error('Upload error:', error);
|
||||
onError(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
requiredMark={false}
|
||||
>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="团队名称"
|
||||
rules={[{ required: true, message: '请输入团队名称' }]}
|
||||
>
|
||||
<Input placeholder="请输入团队名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="avatarUrl"
|
||||
label="团队头像"
|
||||
>
|
||||
<Upload
|
||||
customRequest={handleUpload}
|
||||
showUploadList={false}
|
||||
maxCount={1}
|
||||
listType="picture-card"
|
||||
>
|
||||
{form.getFieldValue('avatarUrl') ? (
|
||||
<img
|
||||
src={form.getFieldValue('avatarUrl')}
|
||||
alt="avatar"
|
||||
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
|
||||
/>
|
||||
) : (
|
||||
<div>
|
||||
<PlusOutlined />
|
||||
<div style={{ marginTop: 8 }}>上传头像</div>
|
||||
</div>
|
||||
)}
|
||||
</Upload>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="tags"
|
||||
label="标签"
|
||||
rules={[{ required: true, message: '请选择至少一个标签' }]}
|
||||
>
|
||||
<Select
|
||||
mode="tags"
|
||||
placeholder="请输入或选择标签"
|
||||
options={[
|
||||
{ label: '研发', value: 'development' },
|
||||
{ label: '设计', value: 'design' },
|
||||
{ label: '运营', value: 'operation' },
|
||||
{ label: '市场', value: 'marketing' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
32
src/pages/resource/team/components/CreateTeamModal/index.jsx
Normal file
32
src/pages/resource/team/components/CreateTeamModal/index.jsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import { Modal, Form } from 'antd';
|
||||
import { TeamForm } from './TeamForm';
|
||||
|
||||
const CreateTeamModal = ({ open, onCancel, onSubmit, confirmLoading }) => {
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
await onSubmit(values);
|
||||
form.resetFields();
|
||||
} catch (error) {
|
||||
console.error('Validation failed:', error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="新增团队"
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
onOk={handleSubmit}
|
||||
confirmLoading={confirmLoading}
|
||||
width={600}
|
||||
>
|
||||
<TeamForm form={form} />
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default CreateTeamModal;
|
||||
Reference in New Issue
Block a user