| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 | 
							- import React from 'react';
 
- import { Button, Input, Select, message, Modal, Checkbox, Radio, Spin } from 'antd';
 
- import { companySearch } from '../../../tools.js';
 
- import ajax from 'jquery/src/ajax/xhr.js';
 
- import $ from 'jquery/src/ajax';
 
- const ApplyAdd = React.createClass({
 
-     getInitialState() {
 
-         return {
 
-             visible: false,
 
-             loading: false
 
-         };
 
-     },
 
-     getContactsList(theUid) {
 
-         $.ajax({
 
-             method: "get",
 
-             dataType: "json",
 
-             crossDomain: false,
 
-             url: globalConfig.context + "/api/admin/customer/findAllContacts",
 
-             data: { "uid": theUid },
 
-             success: function (data) {
 
-                 let theOption = [];
 
-                 if (data.error.length || !data.data) {
 
-                     return;
 
-                 };
 
-                 for (let item in data.data) {
 
-                     let theData = data.data[item];
 
-                     theOption.push(
 
-                         <Select.Option value={item} key={item.name}>{theData.name}</Select.Option>
 
-                     );
 
-                 };
 
-                 this.setState({
 
-                     contactsOption: theOption
 
-                 });
 
-             }.bind(this),
 
-         });
 
-     },
 
-     getDepartmentList(id) {
 
-         $.ajax({
 
-             method: "get",
 
-             dataType: "json",
 
-             crossDomain: false,
 
-             url: globalConfig.context + "/api/admin/techproject/getDepartment",
 
-             data: { "uid": id || this.props.data.uid },
 
-             success: function (data) {
 
-                 let theOption = [];
 
-                 if (!data.data) {
 
-                     if (data.error && data.error.length) {
 
-                         message.warning(data.error[0].message);
 
-                     };
 
-                     return;
 
-                 };
 
-                 for (let item in data.data) {
 
-                     let theData = data.data[item];
 
-                     theOption.push(
 
-                         <Select.Option value={item} key={item}>{theData}</Select.Option>
 
-                     );
 
-                 };
 
-                 this.setState({
 
-                     departmentOption: theOption,
 
-                 });
 
-             }.bind(this),
 
-         });
 
-     },
 
-     componentWillReceiveProps(nextProps) {
 
-         this.state.visible = nextProps.showAdd
 
-     },
 
-     showModal() {
 
-         this.setState({
 
-             visible: true,
 
-         });
 
-     },
 
-     handleOk() {
 
-         this.setState({
 
-             loading: true
 
-         });
 
-         if (!this.state.uid) {
 
-             message.warning('请选择公司!');
 
-             this.setState({
 
-                 loading: false
 
-             });
 
-             return;
 
-         }
 
-         if (!this.state.contacts) {
 
-             message.warning('请选择一个联系人!');
 
-             this.setState({
 
-                 loading: false
 
-             });
 
-             return;
 
-         };
 
-         if (!this.state.salesman) {
 
-             message.warning('请选择一个营销员!');
 
-             this.setState({
 
-                 loading: false
 
-             });
 
-             return;
 
-         };
 
-         $.ajax({
 
-             method: "POST",
 
-             dataType: "json",
 
-             crossDomain: false,
 
-             url: globalConfig.context + "/api/admin/techproject/applyTechProject",
 
-             data: {
 
-                 uid: this.state.uid,
 
-                 contacts: this.state.contacts,
 
-                 department: this.state.department,
 
-                 dispatchInfo: this.state.dispatchInfo,
 
-                 projectName: this.state.projectName,
 
-                 projectCatagory: this.state.projectCatagory,
 
-                 techField: this.state.techField,
 
-                 projectDes: this.state.projectDes,
 
-                 projectMode: this.state.projectMode,
 
-                 projectApproval: this.state.projectApproval,
 
-                 subsidy: this.state.subsidy,
 
-                 consultant: this.state.consultant,
 
-                 salesman: this.state.salesman
 
-             }
 
-         }).done(function (data) {
 
-             if (!data.error.length) {
 
-                 message.success('保存成功!');
 
-                 this.setState({
 
-                     visible: false
 
-                 });
 
-                 this.props.closeAdd(false);
 
-             } else {
 
-                 message.warning(data.error[0].message);
 
-                 this.setState({
 
-                     loading: false
 
-                 });
 
-             }
 
-         }.bind(this));
 
-     },
 
-     handleCancel(e) {
 
-         this.setState({
 
-             visible: false,
 
-         });
 
-         this.props.closeAdd(false);
 
-     },
 
-     spinChange(e) {
 
-         this.setState({
 
-             loading: e
 
-         });
 
-     },
 
-     subsidyCheck(e) {
 
-         if (e.target.value == 1) {
 
-             this.state.subsidy = 1;
 
-         } else if (e.target.value == 2) {
 
-             this.state.projectMode = 1;
 
-         };
 
-         this.setState({
 
-             moneyType: e.target.value
 
-         });
 
-     },
 
-     render() {
 
-         return (
 
-             <div className="cognizance-add">
 
-                 <Modal maskClosable={false} title="新科技项目申请" visible={this.state.visible}
 
-                     onOk={this.handleOk} onCancel={this.handleCancel}
 
-                     width='800px'
 
-                     footer={[
 
-                         <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleOk}>
 
-                             确认
 
-                             </Button>,
 
-                         <Button key="back" onClick={this.handleCancel}>
 
-                             取消
 
-                             </Button>,
 
-                     ]} >
 
-                     <Spin spinning={this.state.loading} className='spin-box'>
 
-                         <div className="clearfix" style={{ marginBottom: '10px' }}>
 
-                             <div className="half-item">
 
-                                 <span className="item-title">选择公司:  </span>
 
-                                 <Select
 
-                                     placeholder="请选择公司"
 
-                                     style={{ width: 260 }}
 
-                                     showSearch
 
-                                     filterOption={companySearch}
 
-                                     onSelect={(e, n) => { this.state.uid = e; this.getContactsList(e); this.getDepartmentList(e); }}>
 
-                                     {this.props.companyAddOption}
 
-                                 </Select>
 
-                             </div>
 
-                             <div className="half-item">
 
-                                 <span className="item-title">选择联系人:  </span>
 
-                                 <Select placeholder="请选择联系人" style={{ width: 200 }}
 
-                                     onSelect={(e, n) => { this.state.contacts = e }}>
 
-                                     {this.state.contactsOption}
 
-                                 </Select>
 
-                             </div>
 
-                         </div>
 
-                         <div className="clearfix">
 
-                             <div className="half-item">
 
-                                 <span className="item-title">申报科技部门:  </span>
 
-                                 <Select
 
-                                     placeholder="请填写申报部门"
 
-                                     style={{ width: 260 }}
 
-                                     onChange={(e) => { this.state.department = e; }}>
 
-                                     {this.state.departmentOption}
 
-                                 </Select>
 
-                             </div>
 
-                         </div>
 
-                         <div className="clearfix">
 
-                             <div>
 
-                                 <span className="item-title">派单信息:  </span>
 
-                             </div>
 
-                             <Input type="textarea" rows={6} onChange={(e) => { this.state.dispatchInfo = e.target.value; }} />
 
-                         </div>
 
-                         <div className="clearfix">
 
-                             <div className="half-item">
 
-                                 <span className="item-title">项目名称:  </span>
 
-                                 <Input style={{ width: 200 }} onChange={(e) => { this.state.projectName = e.target.value; }} />
 
-                             </div>
 
-                         </div>
 
-                         <div className="clearfix">
 
-                             <div className="half-item">
 
-                                 <span className="item-title">项目类型:  </span>
 
-                                 <Input style={{ width: 200 }} onChange={(e) => { this.state.projectCatagory = e.target.value; }} />
 
-                             </div>
 
-                         </div>
 
-                         <div className="clearfix">
 
-                             <div className="half-item">
 
-                                 <span className="item-title">技术领域:  </span>
 
-                                 <Input style={{ width: 200 }} onChange={(e) => { this.state.techField = e.target.value; }} />
 
-                             </div>
 
-                         </div>
 
-                         <div className="clearfix">
 
-                             <div>
 
-                                 <span className="item-title">项目介绍:  </span>
 
-                             </div>
 
-                             <Input type="textarea" rows={6} onChange={(e) => { this.state.projectDes = e.target.value; }} />
 
-                         </div>
 
-                         <div className="clearfix">
 
-                             <div className="half-item">
 
-                                 <span className="item-title">立项/后补助: </span>
 
-                                 <Radio.Group onChange={this.subsidyCheck}>
 
-                                     <Radio value={1}>立项</Radio>
 
-                                     <Radio value={2}>后补助</Radio>
 
-                                 </Radio.Group>
 
-                             </div>
 
-                             <div className="half-item">
 
-                                 <span className="item-title">金额: </span>
 
-                                 <Input style={{ width: 200 }} onChange={(e) => { this.state.projectApproval = e.target.value; }} />
 
-                                 <span>万元</span>
 
-                             </div>
 
-                             <div className="half-item">
 
-                                 <span className="item-title">营销员:  </span>
 
-                                 <Select
 
-                                     placeholder="请填写营销员"
 
-                                     style={{ width: 260 }}
 
-                                     onChange={(e) => { this.state.salesman = e; }}>
 
-                                     {this.props.salesmanOption}
 
-                                 </Select>
 
-                             </div>
 
-                         </div>
 
-                     </Spin>
 
-                 </Modal>
 
-             </div>
 
-         );
 
-     }
 
- });
 
- export default ApplyAdd;
 
 
  |