|
|
@@ -1,33 +1,28 @@
|
|
|
import { ProFormText } from '@ant-design/pro-form'
|
|
|
import { Button, Form, Input, InputNumber, Modal, Select, Space } from 'antd'
|
|
|
-import React, { useEffect } from 'react'
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
import { useDispatch, connect } from 'umi'
|
|
|
+import { useDebounceFn } from 'ahooks'
|
|
|
+import EnterpriseSelect from './EnterpriseSelect'
|
|
|
+import EnterpriseFormItem from './EnterpriseFormItem'
|
|
|
+import { queryRoadcompanyList } from '@/services/product'
|
|
|
+import { validateEnum } from '@/pages/Customer/Company/components/AddCompany/CompanyFormItem'
|
|
|
|
|
|
-const AddEnterprise = ({ visible, onCancel, onConfirm, compilationv2, ...resetModalProps }) => {
|
|
|
- console.log(compilationv2)
|
|
|
+const AddEnterprise = ({ visible, onCancel, onConfirm, ...resetModalProps }) => {
|
|
|
const layout = {
|
|
|
layout: 'horizontal',
|
|
|
labelCol: { flex: '100px' }
|
|
|
}
|
|
|
- const options = []
|
|
|
- const selectProps = {
|
|
|
- mode: 'multiple',
|
|
|
- style: { width: '100%' },
|
|
|
- placeholder: '请选择授权定额',
|
|
|
- maxTagCount: 'responsive'
|
|
|
- }
|
|
|
- const [formRef] = Form.useForm()
|
|
|
- const dispatch = useDispatch()
|
|
|
- useEffect(() => {
|
|
|
- if (!compilationv2?.length) {
|
|
|
- dispatch({
|
|
|
- type: 'personal/fetchCompilationv2',
|
|
|
- payload: {
|
|
|
- projectType: 1
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ const [state, setState] = useState({
|
|
|
+ visible: false,
|
|
|
+ list: null
|
|
|
})
|
|
|
+ const [formRef] = Form.useForm()
|
|
|
+ // 重置到默认值,包括表单
|
|
|
+ const initData = () => {
|
|
|
+ tRef.current.reset()
|
|
|
+ }
|
|
|
+ const [validStatusFcn, setValidStatusFcn] = useState('')
|
|
|
const handleOnOk = () => {
|
|
|
formRef
|
|
|
?.validateFields()
|
|
|
@@ -50,13 +45,34 @@ const AddEnterprise = ({ visible, onCancel, onConfirm, compilationv2, ...resetMo
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ const queryRoadcompanyList = async search => {
|
|
|
+ if (!search) return
|
|
|
+ const { code = -1, data } = await queryRoadcompanyList({
|
|
|
+ current: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ search,
|
|
|
+ waiver: true
|
|
|
+ })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ const { list = [] } = data
|
|
|
+ setState({ ...state, data: list, visible: !!list?.length })
|
|
|
+ if (list?.length) {
|
|
|
+ validStatusFcn(validateEnum.Error)
|
|
|
+ } else {
|
|
|
+ validStatusFcn(validateEnum.Success)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const { run: handleQueryList, cancel: cancelQuerying } = useDebounceFn(queryRoadcompanyList, {
|
|
|
+ wait: 600
|
|
|
+ })
|
|
|
return (
|
|
|
<Modal
|
|
|
{...resetModalProps}
|
|
|
visible={visible}
|
|
|
onCancel={onCancel}
|
|
|
title="创建企业"
|
|
|
- width="35vw"
|
|
|
+ width="40vw"
|
|
|
footer={
|
|
|
<div>
|
|
|
<Button type="default" className="mr-2" onClick={onCancel}>
|
|
|
@@ -68,19 +84,26 @@ const AddEnterprise = ({ visible, onCancel, onConfirm, compilationv2, ...resetMo
|
|
|
</div>
|
|
|
}>
|
|
|
<Form {...layout} form={formRef}>
|
|
|
- <ProFormText
|
|
|
+ <Form.Item
|
|
|
+ label="创建企业"
|
|
|
+ hasFeedback
|
|
|
+ validateStatus={validStatusFcn}
|
|
|
+ help="当前企业名称已存在,请重新输入">
|
|
|
+ <Input placeholder="请输入企业" id="validating" />
|
|
|
+ </Form.Item>
|
|
|
+ {/* <Form.Item
|
|
|
name="companyName"
|
|
|
+ validateStatus={validStatusFcn}
|
|
|
+ hasFeedback
|
|
|
label="创建企业"
|
|
|
- placeholder="请输入企业"
|
|
|
- rules={[{ required: true, message: '请输入企业' }]}
|
|
|
- />
|
|
|
+ rules={[{ required: true }]}>
|
|
|
+ <EnterpriseFormItem validateFn={status => setValidStatusFcn(status)} />
|
|
|
+ </Form.Item> */}
|
|
|
<Form.Item name="licenceNum" label="授权数量" rules={[{ required: true }]}>
|
|
|
- <InputNumber />
|
|
|
+ <InputNumber min={1} max={99} />
|
|
|
</Form.Item>
|
|
|
<Form.Item name="licenceNum" label="授权定额" rules={[{ required: true }]}>
|
|
|
- <Space direction="vertical" style={{ width: '100%' }}>
|
|
|
- <Select {...selectProps} />
|
|
|
- </Space>
|
|
|
+ <EnterpriseSelect />
|
|
|
</Form.Item>
|
|
|
<ProFormText name="adminID" label="管理员名称" rules={[{ required: true }]} />
|
|
|
</Form>
|
|
|
@@ -88,6 +111,4 @@ const AddEnterprise = ({ visible, onCancel, onConfirm, compilationv2, ...resetMo
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-export default connect(({ personal }) => ({
|
|
|
- compilationv2: personal.compilationv2
|
|
|
-}))(AddEnterprise)
|
|
|
+export default AddEnterprise
|