import React, { Component } from "react";
|
import { Form, Input, Modal, Select } from "antd";
|
import {expertFuncMap, expertTypeMap} from "../../common/constants";
|
import BaseForm from "../../common/edit-form-base";
|
const { Option } = Select
|
class EditSystemExpertForm extends BaseForm {
|
|
initEditableData () {
|
return {
|
name: '',
|
type: expertTypeMap.firstKey,
|
model: null,
|
contact: '',
|
expertFuncs: null,
|
matrixWeight: 1,
|
membershipWeight: 1,
|
expertInquiryWeight: 1
|
}
|
}
|
render() {
|
const { visible, onCancel, onOk, form, systemList } = this.props;
|
// console.log(this.props)
|
const { getFieldDecorator } = form;
|
const { name, model, expertFuncs, contact, matrixWeight, membershipWeight, expertInquiryWeight } = this.state.editableData;
|
return (
|
<Modal
|
title={this.state.isEdit ? "编辑专家信息" : "添加专家"}
|
visible={visible}
|
onCancel={onCancel}
|
onOk={onOk}
|
destroyOnClose
|
>
|
<Form>
|
<Form.Item style={{marginBottom: '2px'}} label="模型:">
|
{getFieldDecorator("model", {
|
initialValue: model ? {key: model.id, label: model.name} : undefined,
|
onChange: this.handleEntitySelectChange('model'),
|
rules: [{ required: true, message: "请选择体系" }]
|
})(
|
<Select
|
labelInValue
|
disabled={this.state.isEdit}
|
>
|
{systemList.map((item, index) => (
|
<Option value={item.value} key={index}>{item.label}</Option>
|
))}
|
</Select>
|
)}
|
</Form.Item>
|
<Form.Item style={{marginBottom: '2px'}} label="专家名称:">
|
{getFieldDecorator("name", {
|
initialValue: name,
|
onChange: this.handleFieldChange('name'),
|
rules: [{ required: true, message: '请输入专家名称!'}]
|
})(<Input placeholder="请输入专家名称" />)}
|
</Form.Item>
|
<Form.Item style={{marginBottom: '2px'}} label="联系方式:">
|
{getFieldDecorator("contact", {
|
initialValue: contact,
|
onChange: this.handleFieldChange('contact'),
|
})(<Input placeholder="请输入联系方式" />)}
|
</Form.Item>
|
<Form.Item style={{marginBottom: '2px'}} label="专家类型:">
|
{getFieldDecorator("expertFuncs", {
|
initialValue: expertFuncs ? expertFuncs.map(item => ({key: item, label: expertFuncMap[item]})) : undefined,
|
onChange: this.handleMultipleSelectChange('expertFuncs'),
|
rules: [{ required: true, message: "请选择专家类型" }]
|
})(
|
<Select
|
labelInValue
|
mode={"multiple"}
|
>
|
{expertFuncMap.toOptions().map((item, index) => (
|
<Option value={item.value} key={index}>{item.label}</Option>
|
))}
|
</Select>
|
)}
|
</Form.Item>
|
<Form.Item style={{marginBottom: '2px'}} label="矩阵权重:">
|
{getFieldDecorator("matrixWeight", {
|
initialValue: matrixWeight,
|
onChange: this.handleFieldChange('matrixWeight'),
|
rules: [{ required: true, message: '请输入矩阵权重!'}]
|
})(<Input placeholder="请输入矩阵权重" />)}
|
</Form.Item>
|
<Form.Item style={{marginBottom: '2px'}} label="隶属度权重:">
|
{getFieldDecorator("membershipWeight", {
|
initialValue: membershipWeight,
|
onChange: this.handleFieldChange('membershipWeight'),
|
rules: [{ required: true, message: '请输入隶属度权重!'}]
|
})(<Input placeholder="请输入隶属度权重" />)}
|
</Form.Item>
|
<Form.Item style={{marginBottom: '2px'}} label="专家调查权重:">
|
{getFieldDecorator("expertInquiryWeight", {
|
initialValue: expertInquiryWeight,
|
onChange: this.handleFieldChange('expertInquiryWeight'),
|
rules: [{ required: true, message: '请输入专家调查权重!'}]
|
})(<Input placeholder="请输入专家调查权重" />)}
|
</Form.Item>
|
</Form>
|
</Modal>
|
);
|
}
|
}
|
|
export default Form.create({ name: "EditSystemExpertForm" })(EditSystemExpertForm);
|