|
@@ -13,7 +13,6 @@ function AddModal(props) {
|
|
|
visible,
|
|
|
onClose,
|
|
|
onOk,
|
|
|
- form,
|
|
|
data,
|
|
|
currentUser,
|
|
|
depUserTree,
|
|
@@ -23,6 +22,7 @@ function AddModal(props) {
|
|
|
disabled,
|
|
|
loading,
|
|
|
} = props;
|
|
|
+ const [form] = Form.useForm();
|
|
|
const [codes, setCodes] = useState({
|
|
|
type: '',
|
|
|
industry: '',
|
|
@@ -33,8 +33,7 @@ function AddModal(props) {
|
|
|
const [type, setType] = useState({});
|
|
|
|
|
|
const handleOk = () => {
|
|
|
- form.validateFields((err, fieldsValue) => {
|
|
|
- if (err) return;
|
|
|
+ form.validateFields().then(fieldsValue => {
|
|
|
let values = { ...fieldsValue, id: data.id };
|
|
|
values.project_name = fieldsValue.project_name;
|
|
|
values.flow_id = Number(fieldsValue.flow_id);
|
|
@@ -50,8 +49,8 @@ function AddModal(props) {
|
|
|
values.project_full_code = `${codes.type}${codes.industry}${codes.location}${codes.name}${codes.version}`;
|
|
|
}
|
|
|
if (fieldsValue.author) {
|
|
|
- values.author = Number(fieldsValue.author.split("||")[0]);
|
|
|
- values.author_dep_id = Number(fieldsValue.author.split("||")[1]);
|
|
|
+ values.author = Number(fieldsValue.author.split('||')[0]);
|
|
|
+ values.author_dep_id = Number(fieldsValue.author.split('||')[1]);
|
|
|
} else {
|
|
|
values.author = null;
|
|
|
}
|
|
@@ -146,68 +145,67 @@ function AddModal(props) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const onChangeManager = (e) => {
|
|
|
+ const onChangeManager = e => {
|
|
|
console.log(e);
|
|
|
};
|
|
|
|
|
|
const renderDetail = () => {
|
|
|
return (
|
|
|
<>
|
|
|
- <Form.Item label="行业名称">
|
|
|
- {form.getFieldDecorator('industry_id', {
|
|
|
- initialValue: String(data.industry_id || ''),
|
|
|
- rules: [{ required: true, message: '请选择行业名称' }],
|
|
|
- })(
|
|
|
- <Select style={{ width: '100%' }} onChange={changeIndustry}>
|
|
|
- {industryList.map(item => (
|
|
|
- <Option key={item.id}>
|
|
|
- {item.name}({item.code})
|
|
|
- </Option>
|
|
|
- ))}
|
|
|
- </Select>
|
|
|
- )}
|
|
|
+ <Form.Item
|
|
|
+ label="行业名称"
|
|
|
+ name="industry_id"
|
|
|
+ initialValue={String(data.industry_id || '')}
|
|
|
+ rules={[{ required: true, message: '请选择行业名称' }]}
|
|
|
+ >
|
|
|
+ <Select style={{ width: '100%' }} onChange={changeIndustry}>
|
|
|
+ {industryList.map(item => (
|
|
|
+ <Option key={item.id}>
|
|
|
+ {item.name}({item.code})
|
|
|
+ </Option>
|
|
|
+ ))}
|
|
|
+ </Select>
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="项目地区">
|
|
|
- {form.getFieldDecorator('location', {
|
|
|
- initialValue: data.location,
|
|
|
- rules: [{ required: true, message: '请选择项目地区' }],
|
|
|
- })(
|
|
|
- <TreeSelect
|
|
|
- dropdownStyle={{ maxHeight: 300, overflow: 'auto' }}
|
|
|
- onChange={changeLocation}
|
|
|
- >
|
|
|
- {renderTreeNodes(provinces)}
|
|
|
- </TreeSelect>
|
|
|
- )}
|
|
|
+ <Form.Item
|
|
|
+ label="项目地区"
|
|
|
+ name="location"
|
|
|
+ initialValue={data.location}
|
|
|
+ rules={[{ required: true, message: '请选择项目地区' }]}
|
|
|
+ >
|
|
|
+ <TreeSelect
|
|
|
+ dropdownStyle={{ maxHeight: 300, overflow: 'auto' }}
|
|
|
+ onChange={changeLocation}
|
|
|
+ >
|
|
|
+ {renderTreeNodes(provinces)}
|
|
|
+ </TreeSelect>
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="项目简称">
|
|
|
- {form.getFieldDecorator('name', {
|
|
|
- initialValue: data.name,
|
|
|
- rules: [
|
|
|
- { required: true, message: '请输入项目简称' },
|
|
|
- {
|
|
|
- validator: (rule, value, callback) => {
|
|
|
- if (value.match(/[^A-Za-z]/g)) {
|
|
|
- callback('项目简称只能是英文字符');
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- },
|
|
|
+ <Form.Item
|
|
|
+ label="项目简称"
|
|
|
+ name="name"
|
|
|
+ initialValue={data.name}
|
|
|
+ rules={[
|
|
|
+ { required: true, message: '请输入项目简称' },
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value.match(/[^A-Za-z]/g)) callback('项目简称只能是英文字符');
|
|
|
+ else callback();
|
|
|
},
|
|
|
- ],
|
|
|
- })(<Input maxLength={3} onBlur={onBlurName} />)}
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ <Input maxLength={3} onBlur={onBlurName} />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="项目期数">
|
|
|
- {form.getFieldDecorator('version', {
|
|
|
- initialValue: data.version,
|
|
|
- rules: [{ required: true, message: '请选择项目期数' }],
|
|
|
- })(
|
|
|
- <Select style={{ width: '100%' }} onChange={changeVersion}>
|
|
|
- {['一期', '二期', '三期', '四期', '五期'].map((item, index) => (
|
|
|
- <Option key={index + 1}>{item}</Option>
|
|
|
- ))}
|
|
|
- </Select>
|
|
|
- )}
|
|
|
+ <Form.Item
|
|
|
+ label="项目期数"
|
|
|
+ name="version"
|
|
|
+ initialValue={data.version}
|
|
|
+ rules={[{ required: true, message: '请选择项目期数' }]}
|
|
|
+ >
|
|
|
+ <Select style={{ width: '100%' }} onChange={changeVersion}>
|
|
|
+ {['一期', '二期', '三期', '四期', '五期'].map((item, index) => (
|
|
|
+ <Option key={index + 1}>{item}</Option>
|
|
|
+ ))}
|
|
|
+ </Select>
|
|
|
</Form.Item>
|
|
|
<Form.Item label="项目编号">
|
|
|
{codes.type || '***'}-{codes.industry || '***'}-{codes.location || '***'}-
|
|
@@ -261,59 +259,63 @@ function AddModal(props) {
|
|
|
onCancel={onClose}
|
|
|
onOk={handleOk}
|
|
|
>
|
|
|
- <Form labelCol={{ span: 5 }} wrapperCol={{ span: 15 }}>
|
|
|
- <Form.Item label="项目名称">
|
|
|
- {form.getFieldDecorator('project_name', {
|
|
|
- initialValue: String(data.project_name || ''),
|
|
|
- rules: [{ required: true, message: '请输入项目名称' }],
|
|
|
- })(<Input style={{ width: '100%' }} />)}
|
|
|
+ <Form labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} form={form}>
|
|
|
+ <Form.Item
|
|
|
+ label="项目名称"
|
|
|
+ name="project_name"
|
|
|
+ initialValue={String(data.project_name || '')}
|
|
|
+ rules={[{ required: true, message: '请输入项目名称' }]}
|
|
|
+ >
|
|
|
+ <Input style={{ width: '100%' }} />
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="项目类别">
|
|
|
- {form.getFieldDecorator('type_id', {
|
|
|
- initialValue: String(data.type_id || ''),
|
|
|
- rules: [{ required: true, message: '请选择项目类别' }],
|
|
|
- })(
|
|
|
- <Select style={{ width: '100%' }} onChange={changeType}>
|
|
|
- {typeList.map(item => (
|
|
|
- <Option key={item.id}>
|
|
|
- {item.name}({item.code})
|
|
|
- </Option>
|
|
|
- ))}
|
|
|
- </Select>
|
|
|
- )}
|
|
|
+ <Form.Item
|
|
|
+ label="项目类别"
|
|
|
+ name="type_id"
|
|
|
+ initialValue={String(data.type_id || '')}
|
|
|
+ rules={[{ required: true, message: '请选择项目类别' }]}
|
|
|
+ >
|
|
|
+ <Select style={{ width: '100%' }} onChange={changeType}>
|
|
|
+ {typeList.map(item => (
|
|
|
+ <Option key={item.id}>
|
|
|
+ {item.name}({item.code})
|
|
|
+ </Option>
|
|
|
+ ))}
|
|
|
+ </Select>
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="流程">
|
|
|
- {form.getFieldDecorator('flow_id', {
|
|
|
- initialValue: String(data.flow_id || ''),
|
|
|
- rules: [{ required: true, message: '请选择流程' }],
|
|
|
- })(
|
|
|
- <Select style={{ width: '100%' }} disabled>
|
|
|
- {flowList
|
|
|
- .filter(item => item && item.id != 2 && item.id != 3)
|
|
|
- .map(item => (
|
|
|
- <Option key={item.id}>{item.name}</Option>
|
|
|
- ))}
|
|
|
- </Select>
|
|
|
- )}
|
|
|
+ <Form.Item
|
|
|
+ label="流程"
|
|
|
+ name="flow_id"
|
|
|
+ initialValue={String(data.flow_id || '')}
|
|
|
+ rules={[{ required: true, message: '请选择流程' }]}
|
|
|
+ >
|
|
|
+ <Select style={{ width: '100%' }} disabled>
|
|
|
+ {flowList
|
|
|
+ .filter(item => item && item.id != 2 && item.id != 3)
|
|
|
+ .map(item => (
|
|
|
+ <Option key={item.id}>{item.name}</Option>
|
|
|
+ ))}
|
|
|
+ </Select>
|
|
|
</Form.Item>
|
|
|
{currentUser.IsSuper && (
|
|
|
- <Form.Item label="售前经理">
|
|
|
- {form.getFieldDecorator('author', {
|
|
|
- initialValue: String((data.author && data.author_dep_id) ? `${data.author}||${data.author_dep_id}` : '')
|
|
|
- })(
|
|
|
- <TreeSelect
|
|
|
- showSearch
|
|
|
- allowClear
|
|
|
- style={{ width: '100%' }}
|
|
|
- multiple={false}
|
|
|
- filterTreeNode={(input, option) => {
|
|
|
- return option.props.title === input;
|
|
|
- }}
|
|
|
- onChange={onChangeManager}
|
|
|
- >
|
|
|
- {renderUserSelectTreeNodes(depUserTree)}
|
|
|
- </TreeSelect>
|
|
|
+ <Form.Item
|
|
|
+ label="售前经理"
|
|
|
+ name="author"
|
|
|
+ initialValue={String(
|
|
|
+ data.author && data.author_dep_id ? `${data.author}||${data.author_dep_id}` : ''
|
|
|
)}
|
|
|
+ >
|
|
|
+ <TreeSelect
|
|
|
+ showSearch
|
|
|
+ allowClear
|
|
|
+ style={{ width: '100%' }}
|
|
|
+ multiple={false}
|
|
|
+ filterTreeNode={(input, option) => {
|
|
|
+ return option.props.title === input;
|
|
|
+ }}
|
|
|
+ onChange={onChangeManager}
|
|
|
+ >
|
|
|
+ {renderUserSelectTreeNodes(depUserTree)}
|
|
|
+ </TreeSelect>
|
|
|
</Form.Item>
|
|
|
)}
|
|
|
{type?.id != 7 && renderDetail()}
|
|
@@ -321,4 +323,4 @@ function AddModal(props) {
|
|
|
</Modal>
|
|
|
);
|
|
|
}
|
|
|
-export default Form.create()(AddModal);
|
|
|
+export default AddModal;
|