|
@@ -1,11 +1,8 @@
|
|
import React, { useState, useEffect } from 'react';
|
|
import React, { useState, useEffect } from 'react';
|
|
-import { Form } from '@ant-design/compatible';
|
|
|
|
-import '@ant-design/compatible/assets/index.css';
|
|
|
|
-import { Select, Modal, Input, TreeSelect } from 'antd';
|
|
|
|
|
|
+import { Form, Select, Modal, Input, TreeSelect } from 'antd';
|
|
import moment from 'moment';
|
|
import moment from 'moment';
|
|
import provinces from './provinces';
|
|
import provinces from './provinces';
|
|
import { queryApproval } from '@/services/approval';
|
|
import { queryApproval } from '@/services/approval';
|
|
-// import project from '@/pages/ProjectAdmin/ProjectAdmin/models/project';
|
|
|
|
const { Option } = Select;
|
|
const { Option } = Select;
|
|
const { TreeNode } = TreeSelect;
|
|
const { TreeNode } = TreeSelect;
|
|
// 新建
|
|
// 新建
|
|
@@ -18,6 +15,8 @@ function AddModal(props) {
|
|
onOk,
|
|
onOk,
|
|
form,
|
|
form,
|
|
data,
|
|
data,
|
|
|
|
+ currentUser,
|
|
|
|
+ depUserTree,
|
|
flowList = [],
|
|
flowList = [],
|
|
industryList = [],
|
|
industryList = [],
|
|
typeList = [],
|
|
typeList = [],
|
|
@@ -37,48 +36,26 @@ function AddModal(props) {
|
|
form.validateFields((err, fieldsValue) => {
|
|
form.validateFields((err, fieldsValue) => {
|
|
if (err) return;
|
|
if (err) return;
|
|
let values = { ...fieldsValue, id: data.id };
|
|
let values = { ...fieldsValue, id: data.id };
|
|
- //项目分类为研发时
|
|
|
|
- if (fieldsValue.type_id == 7) {
|
|
|
|
- values.project_name = fieldsValue.project_name;
|
|
|
|
- values.flow_id = Number(fieldsValue.flow_id);
|
|
|
|
- values.type_id = Number(fieldsValue.type_id);
|
|
|
|
- // 获得flow下第一个node的id
|
|
|
|
- values.node_id = flowList.find(item => item.id == values.flow_id).Nodes[0].id;
|
|
|
|
- //以下为测试用默认值
|
|
|
|
- // values.industry_id = 0;
|
|
|
|
- // values.location = '';
|
|
|
|
- // values.location_code = '';
|
|
|
|
- // values.project_full_code = '';
|
|
|
|
- // values.name = '';
|
|
|
|
- // values.version = '';
|
|
|
|
-
|
|
|
|
- //通过当前项目数生成项目编号
|
|
|
|
- // dispatch({
|
|
|
|
- // type: 'approval/queryApproval',
|
|
|
|
- // callback: data => {
|
|
|
|
- // let project_full_code = '';
|
|
|
|
- // if (total < 10) {
|
|
|
|
- // project_full_code = '00' + data.pagination.total;
|
|
|
|
- // } else if (total < 100) project_full_code = '0' + data.pagination.total;
|
|
|
|
- // else project_full_code = data.pagination.total;
|
|
|
|
- // values.project_full_code = `RD${moment().format('YYYYMM')}${project_full_code}`;
|
|
|
|
- // onOk(values);
|
|
|
|
- // },
|
|
|
|
- // });
|
|
|
|
- onOk(values);
|
|
|
|
- } else {
|
|
|
|
- values.project_name = fieldsValue.project_name;
|
|
|
|
- values.type_id = Number(fieldsValue.type_id);
|
|
|
|
|
|
+ values.project_name = fieldsValue.project_name;
|
|
|
|
+ values.flow_id = Number(fieldsValue.flow_id);
|
|
|
|
+ values.type_id = Number(fieldsValue.type_id);
|
|
|
|
+ // 获得flow下第一个node的id
|
|
|
|
+ values.node_id = flowList.find(item => item.id == values.flow_id).Nodes[0].id;
|
|
|
|
+ //项目分类为不为研发时
|
|
|
|
+ if (fieldsValue.type_id != 7) {
|
|
values.industry_id = Number(fieldsValue.industry_id);
|
|
values.industry_id = Number(fieldsValue.industry_id);
|
|
- values.flow_id = Number(fieldsValue.flow_id);
|
|
|
|
- // 获得flow下第一个node的id
|
|
|
|
- values.node_id = flowList.find(item => item.id == values.flow_id).Nodes[0].id;
|
|
|
|
let [location, location_code] = fieldsValue.location.split('##');
|
|
let [location, location_code] = fieldsValue.location.split('##');
|
|
values.location = location;
|
|
values.location = location;
|
|
values.location_code = location_code;
|
|
values.location_code = location_code;
|
|
values.project_full_code = `${codes.type}${codes.industry}${codes.location}${codes.name}${codes.version}`;
|
|
values.project_full_code = `${codes.type}${codes.industry}${codes.location}${codes.name}${codes.version}`;
|
|
- onOk(values);
|
|
|
|
}
|
|
}
|
|
|
|
+ if (fieldsValue.author) {
|
|
|
|
+ values.author = Number(fieldsValue.author.split("||")[0]);
|
|
|
|
+ values.author_dep_id = Number(fieldsValue.author.split("||")[1]);
|
|
|
|
+ } else {
|
|
|
|
+ values.author = null;
|
|
|
|
+ }
|
|
|
|
+ onOk(values);
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
@@ -88,7 +65,6 @@ function AddModal(props) {
|
|
let code = item.code || '';
|
|
let code = item.code || '';
|
|
if (code.length == 4) {
|
|
if (code.length == 4) {
|
|
code = code.substr(1);
|
|
code = code.substr(1);
|
|
- console.log(code);
|
|
|
|
}
|
|
}
|
|
if (code) {
|
|
if (code) {
|
|
title += `(${code})`;
|
|
title += `(${code})`;
|
|
@@ -108,7 +84,7 @@ function AddModal(props) {
|
|
type: item.code,
|
|
type: item.code,
|
|
});
|
|
});
|
|
setType(item);
|
|
setType(item);
|
|
- form.setFieldsValue({ flow_id: id == 7 ? '4' : '1'});
|
|
|
|
|
|
+ form.setFieldsValue({ flow_id: id == 7 ? '4' : '1' });
|
|
};
|
|
};
|
|
const changeIndustry = id => {
|
|
const changeIndustry = id => {
|
|
const item = industryList.find(item => item.id == id);
|
|
const item = industryList.find(item => item.id == id);
|
|
@@ -133,7 +109,7 @@ function AddModal(props) {
|
|
const onBlurName = e => {
|
|
const onBlurName = e => {
|
|
let value = e.target.value.toUpperCase();
|
|
let value = e.target.value.toUpperCase();
|
|
while (value.length < 3) {
|
|
while (value.length < 3) {
|
|
- value = value + "V";
|
|
|
|
|
|
+ value = value + 'V';
|
|
}
|
|
}
|
|
form.setFieldsValue({
|
|
form.setFieldsValue({
|
|
name: value,
|
|
name: value,
|
|
@@ -144,69 +120,101 @@ function AddModal(props) {
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
- 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>
|
|
|
|
- <Form.Item label="项目地区">
|
|
|
|
- {form.getFieldDecorator('location', {
|
|
|
|
- initialValue: data.location,
|
|
|
|
- rules: [{ required: true, message: '请选择项目地区' }],
|
|
|
|
- })(
|
|
|
|
- <TreeSelect
|
|
|
|
- dropdownStyle={{ maxHeight: 300, overflow: 'auto' }}
|
|
|
|
- onChange={changeLocation}
|
|
|
|
|
|
+ const renderUserSelectTreeNodes = data => {
|
|
|
|
+ return data.map(item => {
|
|
|
|
+ if (item.children) {
|
|
|
|
+ return (
|
|
|
|
+ <TreeNode
|
|
|
|
+ title={item.title}
|
|
|
|
+ key={item.key}
|
|
|
|
+ value={item.manage || item.value}
|
|
|
|
+ dataRef={item}
|
|
|
|
+ selectable={item.selectable}
|
|
>
|
|
>
|
|
- {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();
|
|
|
|
- }
|
|
|
|
|
|
+ {renderUserSelectTreeNodes(item.children)}
|
|
|
|
+ </TreeNode>
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ return (
|
|
|
|
+ <TreeNode
|
|
|
|
+ title={item.title}
|
|
|
|
+ key={item.ID}
|
|
|
|
+ value={item.manage || item.value}
|
|
|
|
+ selectable={item.selectable}
|
|
|
|
+ />
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ 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>
|
|
|
|
+ <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>
|
|
|
|
+ <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();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
- },
|
|
|
|
- ],
|
|
|
|
- })(<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>
|
|
|
|
- <Form.Item label="项目编号">
|
|
|
|
- {codes.type || '***'}-{codes.industry || '***'}-{codes.location || '***'}-
|
|
|
|
- {codes.name || '***'}-{codes.version || '*'}
|
|
|
|
- </Form.Item>
|
|
|
|
- </>;
|
|
|
|
|
|
+ ],
|
|
|
|
+ })(<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>
|
|
|
|
+ <Form.Item label="项目编号">
|
|
|
|
+ {codes.type || '***'}-{codes.industry || '***'}-{codes.location || '***'}-
|
|
|
|
+ {codes.name || '***'}-{codes.version || '*'}
|
|
|
|
+ </Form.Item>
|
|
|
|
+ </>
|
|
|
|
+ );
|
|
};
|
|
};
|
|
|
|
|
|
// const renderCode = () => {
|
|
// const renderCode = () => {
|
|
@@ -258,9 +266,7 @@ function AddModal(props) {
|
|
{form.getFieldDecorator('project_name', {
|
|
{form.getFieldDecorator('project_name', {
|
|
initialValue: String(data.project_name || ''),
|
|
initialValue: String(data.project_name || ''),
|
|
rules: [{ required: true, message: '请输入项目名称' }],
|
|
rules: [{ required: true, message: '请输入项目名称' }],
|
|
- })(
|
|
|
|
- <Input style={{ width: '100%' }}/>
|
|
|
|
- )}
|
|
|
|
|
|
+ })(<Input style={{ width: '100%' }} />)}
|
|
</Form.Item>
|
|
</Form.Item>
|
|
<Form.Item label="项目类别">
|
|
<Form.Item label="项目类别">
|
|
{form.getFieldDecorator('type_id', {
|
|
{form.getFieldDecorator('type_id', {
|
|
@@ -283,13 +289,33 @@ function AddModal(props) {
|
|
})(
|
|
})(
|
|
<Select style={{ width: '100%' }} disabled>
|
|
<Select style={{ width: '100%' }} disabled>
|
|
{flowList
|
|
{flowList
|
|
- .filter(item => item && (item.id != 2 && item.id != 3))
|
|
|
|
|
|
+ .filter(item => item && item.id != 2 && item.id != 3)
|
|
.map(item => (
|
|
.map(item => (
|
|
<Option key={item.id}>{item.name}</Option>
|
|
<Option key={item.id}>{item.name}</Option>
|
|
))}
|
|
))}
|
|
</Select>
|
|
</Select>
|
|
)}
|
|
)}
|
|
</Form.Item>
|
|
</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>
|
|
|
|
+ )}
|
|
{type?.id != 7 && renderDetail()}
|
|
{type?.id != 7 && renderDetail()}
|
|
</Form>
|
|
</Form>
|
|
</Modal>
|
|
</Modal>
|