feat(前端):终端绑定用户

master
shaot 2025-08-11 18:11:44 +08:00
parent c96a251bde
commit 36f8dca46f
6 changed files with 151 additions and 88 deletions

View File

@ -60,24 +60,26 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
destroyOnHidden={true}
cancelText="取消"
okText="确定"
footer={
<div style={{ display: 'flex', justifyContent: 'right' }}>
<Button
type="primary"
onClick={handleOk}
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel} style={{ marginRight: '20px' }}>
</Button>
</div>
}
footer={null}
// footer={
// <div style={{ display: 'flex', justifyContent: 'right' }}>
// <Button
// type="primary"
// onClick={handleOk}
// style={{ marginRight: '20px' }}
// >
// 确定
// </Button>
// <Button onClick={onCancel} style={{ marginRight: '20px' }}>
// 取消
// </Button>
// </div>
// }
>
<div className={styles.model_content}>
<Form
form={form}
onFinish={handleOk}
labelCol={{ span: 4 }}
wrapperCol={{ span: 19 }}
layout="horizontal"
@ -97,6 +99,16 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
>
<Input.TextArea rows={4} />
</Form.Item> */}
<Form.Item label={null}>
<Button
type="primary"
htmlType="submit"
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel}></Button>
</Form.Item>
</Form>
</div>
</Modal>

View File

@ -9,8 +9,6 @@ import SelectedTable from '../selectedTable';
import styles from './index.less';
interface UserEditModalProps {
// visible: boolean;
// orgTreeData?: User.OrganizationNode[];
onCancel: () => void;
onOk: (values?: any) => void;
confirmLoading?: boolean;
@ -26,7 +24,7 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
dataDetial,
}) => {
const { recordData, visible } = dataDetial || {};
const { device_id, device_group_id } = recordData || {};
const { device_id } = recordData || {};
const [orgTreeData, setOrgTreeData] = useState<User.OrganizationNode[]>([]);
const [form] = Form.useForm();
@ -98,7 +96,6 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
user_id: record_id,
id: id,
device_id,
device_group_id,
type: type,
});
} else {
@ -107,7 +104,6 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
user_group_id: record_id,
id: id,
device_id: device_id,
device_group_id,
type: type,
});
}
@ -116,14 +112,17 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
data: list,
};
bindUserAdd(payload)
.then(() => {
.then((res: any) => {
const { code } = res || {};
if (code === ERROR_CODE) {
message.success('绑定成功');
onOk();
} else {
message.error('绑定失败');
}
})
.catch(() => {});
}
console.log('list=====', list);
onOk(list);
} catch (error) {
message.error('请检查表单字段');
}
@ -142,24 +141,26 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
destroyOnHidden={true}
cancelText="取消"
okText="确定"
footer={
<div style={{ display: 'flex', justifyContent: 'right' }}>
<Button
type="primary"
onClick={handleOk}
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel} style={{ marginRight: '20px' }}>
</Button>
</div>
}
footer={null}
// footer={
// <div style={{ display: 'flex', justifyContent: 'right' }}>
// <Button
// type="primary"
// onClick={handleOk}
// style={{ marginRight: '20px' }}
// >
// 确定
// </Button>
// <Button onClick={onCancel} style={{ marginRight: '20px' }}>
// 取消
// </Button>
// </div>
// }
>
<div className={styles.model_content}>
<Form
form={form}
onFinish={handleOk}
labelCol={{ span: 4 }}
wrapperCol={{ span: 19 }}
layout="horizontal"
@ -179,6 +180,16 @@ const BindUserModal: React.FC<UserEditModalProps> = ({
>
<Input.TextArea rows={4} />
</Form.Item> */}
<Form.Item label={null}>
<Button
type="primary"
htmlType="submit"
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel}></Button>
</Form.Item>
</Form>
</div>
</Modal>

View File

@ -44,7 +44,7 @@ const UserEditModal: React.FC<UserEditModalProps> = ({
const { code } = res || {};
if (code === ERROR_CODE) {
message.success('保存成功');
onOk();
if (onOk) onOk();
}
} catch (error) {
message.error('保存失败');
@ -76,23 +76,25 @@ const UserEditModal: React.FC<UserEditModalProps> = ({
cancelText="取消"
okText="确定"
// 按钮居中对其
footer={
<div style={{ display: 'flex', justifyContent: 'right' }}>
<Button
type="primary"
onClick={handleOk}
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel} style={{ marginRight: '20px' }}>
</Button>
</div>
}
footer={null}
// footer={
// <div style={{ display: 'flex', justifyContent: 'right' }}>
// <Button
// type="primary"
// onClick={handleOk}
// style={{ marginRight: '20px' }}
// >
// 确定
// </Button>
// <Button onClick={onCancel} style={{ marginRight: '20px' }}>
// 取消
// </Button>
// </div>
// }
>
<Form
form={form}
onFinish={handleOk}
labelCol={{ span: 5 }}
wrapperCol={{ span: 18 }}
layout="horizontal"
@ -164,6 +166,16 @@ const UserEditModal: React.FC<UserEditModalProps> = ({
>
<Input.TextArea rows={4} />
</Form.Item>
<Form.Item label={null}>
<Button
type="primary"
htmlType="submit"
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel}></Button>
</Form.Item>
</Form>
</Modal>
);

View File

@ -20,7 +20,7 @@ const DeletableTable: React.FC<DeletableTableProps> = (props) => {
onDelete,
isSerial = true,
isAction = true,
scrollY = 300,
scrollY = 400,
...restProps
} = props;
console.log("datasource=====",dataSource);

View File

@ -7,6 +7,7 @@ import {
import { addUser, editUser, getUserById } from '@/services/userList';
import {
Button,
DatePicker,
Form,
Input,
message,
@ -14,7 +15,6 @@ import {
Radio,
Select,
TreeSelect,
DatePicker
} from 'antd';
import React, { useEffect } from 'react';
@ -46,7 +46,10 @@ const UserEditModal: React.FC<UserEditModalProps> = ({
form.setFieldsValue(data);
});
} else {
const initialValues = { user_group_id: [selectedOrg], status: 1 };
const initialValues = {
user_group_id: selectedOrg ? selectedOrg : null,
status: 1,
};
form.setFieldsValue(initialValues);
}
}, [visible, form, recordData, selectedOrg]);
@ -124,24 +127,26 @@ const UserEditModal: React.FC<UserEditModalProps> = ({
cancelText="取消"
okText="确定"
// 按钮居中对其
footer={
<div style={{ display: 'flex', justifyContent: 'right' }}>
<Button
type="primary"
onClick={handleOk}
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel} style={{ marginRight: '20px' }}>
</Button>
</div>
}
footer={null}
// footer={
// <div style={{ display: 'flex', justifyContent: 'right' }}>
// <Button
// type="primary"
// onClick={handleOk}
// style={{ marginRight: '20px' }}
// >
// 确定
// </Button>
// <Button onClick={onCancel} style={{ marginRight: '20px' }}>
// 取消
// </Button>
// </div>
// }
>
<Form
form={form}
labelCol={{ span: 5 }}
onFinish={handleOk}
wrapperCol={{ span: 18 }}
layout="horizontal"
style={{ paddingTop: '20px', paddingBottom: '20px' }}
@ -199,7 +204,7 @@ const UserEditModal: React.FC<UserEditModalProps> = ({
<Select placeholder="请选择用户类别" options={USER_TYPE_OPTIONS} />
</Form.Item>
<Form.Item name="birthday" label="出生日期">
<DatePicker style={{width:"414px"}}/>
<DatePicker style={{ width: '414px' }} />
</Form.Item>
<Form.Item
name="priority"
@ -249,6 +254,17 @@ const UserEditModal: React.FC<UserEditModalProps> = ({
>
<Input placeholder="请输入邮箱" />
</Form.Item>
<Form.Item label={null}>
<Button
type="primary"
htmlType="submit"
style={{ marginRight: '20px' }}
>
</Button>
<Button onClick={onCancel}></Button>
</Form.Item>
</Form>
</Modal>
);

View File

@ -80,21 +80,22 @@ const CreatGroup: React.FC<CreatGroupProps> = (props) => {
centered={true}
destroyOnHidden={true}
width={600}
footer={
<div style={{ display: 'flex', justifyContent: 'right' }}>
<Button
type="primary"
onClick={handleOk}
style={{ marginRight: '20px' }}
loading={loading}
>
</Button>
<Button onClick={onCancel} style={{ marginRight: '20px' }}>
</Button>
</div>
}
footer={null}
// footer={
// <div style={{ display: 'flex', justifyContent: 'right' }}>
// <Button
// type="primary"
// onClick={handleOk}
// style={{ marginRight: '20px' }}
// loading={loading}
// >
// 确定
// </Button>
// <Button onClick={onCancel} style={{ marginRight: '20px' }}>
// 取消
// </Button>
// </div>
// }
>
<div style={{ height: '300px' }}>
<Form
@ -123,6 +124,17 @@ const CreatGroup: React.FC<CreatGroupProps> = (props) => {
fieldNames={{ label: 'name', value: 'id', children: 'children' }}
/>
</Form.Item>
<Form.Item label={null}>
<Button
type="primary"
htmlType="submit"
style={{ marginRight: '20px' }}
loading={loading}
>
</Button>
<Button onClick={onCancel}></Button>
</Form.Item>
</Form>
</div>
</Modal>