Commit ad257f3eac121985509cace8e88b9b17d813cf6b
1 parent
205f0ca4
注册新增公司查询功能;
Showing
1 changed file
with
37 additions
and
15 deletions
src/components/UserRegistration/index.jsx
| 1 | -import { ConfigProvider, Modal, Form, Input, Select } from "antd"; | |
| 1 | +import { useState, useEffect } from "react"; | |
| 2 | +import { ConfigProvider, Modal, Form, Input, Select, message } from "antd"; | |
| 3 | +import commonConfig from "@/utils/config"; | |
| 4 | +import * as commonServices from "@/services/services"; | |
| 5 | + | |
| 6 | +const UserRegistrationEvent = () => { | |
| 7 | + const [state, setState0] = useState({}); | |
| 8 | + const setState = payload => { | |
| 9 | + setState0({ ...state, ...payload }); | |
| 10 | + }; | |
| 11 | + | |
| 12 | + // 初始化获取所属客户 | |
| 13 | + useEffect(() => { | |
| 14 | + const url = `${commonConfig.feedback_host}sysworkorder/getCustomerData`; | |
| 15 | + commonServices.postValueService("", {}, url).then(({ data: result = {} }) => { | |
| 16 | + const { code = -1, data, msg = "接口出错" } = result; | |
| 17 | + if (code > -1) { | |
| 18 | + setState({ customerData: data }); | |
| 19 | + } else { | |
| 20 | + message.error(msg); | |
| 21 | + } | |
| 22 | + }); | |
| 23 | + }, []); | |
| 24 | + | |
| 25 | + return { | |
| 26 | + ...state, | |
| 27 | + setState, | |
| 28 | + }; | |
| 29 | +}; | |
| 2 | 30 | |
| 3 | 31 | const UserRegistration = ({ _this }) => { |
| 4 | 32 | const { userRegisterMode } = _this.state; |
| 5 | 33 | if (!userRegisterMode) return ""; |
| 6 | 34 | |
| 35 | + const props = UserRegistrationEvent(); | |
| 36 | + const { customerData = [] } = props; | |
| 37 | + | |
| 7 | 38 | const [form] = Form.useForm(); |
| 8 | 39 | |
| 9 | 40 | const handleCancel = () => { |
| ... | ... | @@ -22,15 +53,7 @@ const UserRegistration = ({ _this }) => { |
| 22 | 53 | |
| 23 | 54 | return ( |
| 24 | 55 | <ConfigProvider prefixCls="antdV5"> |
| 25 | - <Modal | |
| 26 | - title="用户注册" | |
| 27 | - open={userRegisterMode} | |
| 28 | - okText="确认" | |
| 29 | - cancelText="取消" | |
| 30 | - onOk={handleOk} | |
| 31 | - onCancel={handleCancel} | |
| 32 | - width={400} | |
| 33 | - > | |
| 56 | + <Modal title="用户注册" open={userRegisterMode} okText="确认" cancelText="取消" onOk={handleOk} onCancel={handleCancel} width={400}> | |
| 34 | 57 | <Form |
| 35 | 58 | name="basic" |
| 36 | 59 | form={form} |
| ... | ... | @@ -62,11 +85,10 @@ const UserRegistration = ({ _this }) => { |
| 62 | 85 | |
| 63 | 86 | <Form.Item label="公司名称" name="company" rules={[{ required: true, message: "未选择公司!" }]}> |
| 64 | 87 | <Select |
| 65 | - options={[ | |
| 66 | - { value: "xly", label: "上海小羚羊" }, | |
| 67 | - { value: "jinjia", label: "深圳劲嘉" }, | |
| 68 | - { value: "pushi", label: "四川3D" }, | |
| 69 | - ]} | |
| 88 | + fieldNames={{ label: "sCustomerName", value: "sCustomerId" }} | |
| 89 | + options={customerData} | |
| 90 | + showSearch | |
| 91 | + filterOption={(inputValue, option) => option.sCustomerName?.includes(inputValue)} | |
| 70 | 92 | /> |
| 71 | 93 | </Form.Item> |
| 72 | 94 | </Form> | ... | ... |