myClientDesc.jsx 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import React from 'react';
  2. import { Tabs, Table, Icon, Tooltip, Modal, message, AutoComplete, Spin, DatePicker,Upload, Input, InputNumber, Select,TimePicker, Button, Radio, Form, Cascader, Tag, Switch } from 'antd';
  3. import './myClient.less';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import moment from 'moment';
  6. import $ from 'jquery/src/ajax';
  7. import { areaSelect } from '../../../NewDicProvinceList';
  8. import { maturityList, innovationList, transferModeList,cityArr ,newFollow,customerStatus,intentionalService,tag} from '../../../dataDic';
  9. import { IndustryObject, getIndustryCategory } from '../../../DicIndustryList.js';
  10. import { beforeUploadFile, splitUrl, companySearch, getTransferMode, getAchievementCategory, getTechAuditStatus, getDemandType, getMaturity, getInnovation,beforeUpload, getBase64,getsex,getCompanyIntention,getcityArr,getfllowSituation,getcustomerStatue} from '../../../tools.js';
  11. import throttle from '../../../throttle.js';
  12. const PicturesWall = React.createClass({
  13. getInitialState() {
  14. return {
  15. previewVisible: false,
  16. previewImage: '',
  17. fileList: [],
  18. }
  19. },
  20. handleCancel() {
  21. this.setState({ previewVisible: false })
  22. },
  23. handlePreview(file) {
  24. this.setState({
  25. previewImage: file.url || file.thumbUrl,
  26. previewVisible: true,
  27. });
  28. },
  29. handleChange(info) {
  30. let fileList = info.fileList;
  31. this.setState({ fileList });
  32. this.props.fileList(fileList);
  33. },
  34. componentWillReceiveProps(nextProps) {
  35. this.state.fileList = nextProps.pictureUrl;
  36. },
  37. render() {
  38. const { previewVisible, previewImage, fileList } = this.state;
  39. const uploadButton = (
  40. <div>
  41. <Icon type="plus" />
  42. <div className="ant-upload-text">点击上传</div>
  43. </div>
  44. );
  45. return (
  46. <div className="clearfix">
  47. <Upload
  48. action={globalConfig.context + "/api/admin/achievement/uploadPicture"}
  49. data={{ 'sign': this.props.pictureSign }}
  50. listType="picture-card"
  51. fileList={fileList}
  52. onPreview={this.handlePreview}
  53. onChange={this.handleChange} >
  54. {fileList.length >= 5 ? null : uploadButton}
  55. </Upload>
  56. <Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel}>
  57. <img alt="example" style={{ width: '100%' }} src={previewImage} />
  58. </Modal>
  59. </div>
  60. );
  61. }
  62. });
  63. const AchievementDetailForm = Form.create()(React.createClass({
  64. getInitialState() {
  65. return {
  66. loading: false,
  67. data: {},
  68. tags: [],
  69. technicalPictureUrl:[],
  70. technicalPictureUrls:[],
  71. };
  72. },
  73. handleSubmit(e) {
  74. e.preventDefault();
  75. this.props.form.validateFields((err, values) => {
  76. if (!err) {
  77. this.setState({
  78. loading: true
  79. });
  80. $.ajax({
  81. method: "POST",
  82. dataType: "json",
  83. crossDomain: false,
  84. url: globalConfig.context + '/api/admin/customer/addCustomer',
  85. data: {
  86. name: this.state.companyNamet,
  87. contacts:this.state.content ,
  88. contactMobile: this.state.telnum,
  89. type:'1'
  90. }
  91. }).done(function (data) {
  92. this.setState({
  93. loading: false
  94. });
  95. if (!data.error.length) {
  96. message.success('保存成功!');
  97. this.props.handleOk();
  98. } else {
  99. message.warning(data.error[0].message);
  100. }
  101. }.bind(this));
  102. }
  103. });
  104. },
  105. //去完善
  106. addContent(){
  107. let telnum=this.state.telnum;
  108. let companyName=this.state.companyNamet;
  109. let content=this.state.content;
  110. if(!telnum||!companyName||!content){
  111. message.warning('此3项都要填');
  112. }else{
  113. this.props.newmodal(true);
  114. this.props.closeDesc(false);
  115. }
  116. },
  117. componentWillMount() {
  118. this.state.therottleSearch = throttle(this.handleSearch, 1000, { leading: false }).bind(this);
  119. if (this.props.data && this.props.data.id) {
  120. this.loadData(this.props.data.id, this.props.detailApiUrl);
  121. };
  122. },
  123. componentWillReceiveProps(nextProps) {
  124. if (!this.props.visible && nextProps.visible) {
  125. if (nextProps.data && nextProps.data.id) {
  126. this.loadData(nextProps.data.id, nextProps.detailApiUrl);
  127. };
  128. this.state.data = {};
  129. this.state.tags = [];
  130. this.state.switchValue = false;
  131. this.state.radios = false;
  132. this.state.technicalPictureUrl = [];
  133. this.state.coverImg = [];
  134. this.state.textFileList = [];
  135. this.state.techPlanFileList = [];
  136. this.state.businessPlanFileList = [];
  137. this.props.form.resetFields();
  138. this.state.technicalPictureUrl = [];
  139. this.state.technicalPictureUrls = [];
  140. };
  141. },
  142. render() {
  143. const theData = this.state.data || {};
  144. const { getFieldDecorator } = this.props.form;
  145. const FormItem = Form.Item
  146. const formItemLayout = {
  147. labelCol: { span: 8 },
  148. wrapperCol: { span: 14 },
  149. };
  150. return (
  151. <div>
  152. <Form horizontal onSubmit={this.handleSubmit} id="demand-form">
  153. <Spin spinning={this.state.loading}>
  154. <div className="clearfix">
  155. <FormItem className="half-item"
  156. {...formItemLayout}
  157. label="公司名称" >
  158. <Input value={this.state.companyNamet} onChange={(e) => { this.setState({ companyNamet: e.target.value }); }} required="required"/>
  159. </FormItem>
  160. </div>
  161. <div className="clearfix">
  162. <FormItem className="half-item"
  163. {...formItemLayout}
  164. label="联系人" >
  165. <Input value={this.state.content} onChange={(e) => { this.setState({ content: e.target.value }); }} required="required"/>
  166. </FormItem>
  167. </div>
  168. <div className="clearfix">
  169. <FormItem className="half-item"
  170. {...formItemLayout}
  171. label="联系电话" >
  172. <Input value={this.state.telnum} onChange={(e) => { this.setState({ telnum: e.target.value }); }} required="required"/>
  173. </FormItem>
  174. </div>
  175. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  176. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  177. {/*<Button className="set-submit" type="primary" onClick={(e)=>{this.addContent();this.props.closeDesc}}>去完善</Button>*/}
  178. <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>
  179. </FormItem>
  180. </Spin>
  181. </Form >
  182. </div>
  183. )
  184. }
  185. }));
  186. const CustomerDetail = React.createClass({
  187. getInitialState() {
  188. return {
  189. visible: false,
  190. tabsKey: 1,
  191. loading: false,
  192. dataSource: [],
  193. };
  194. },
  195. handleCancel(e) {
  196. this.setState({
  197. visible: false,
  198. });
  199. this.props.closeDesc(false);
  200. },
  201. handleOk(e) {
  202. this.setState({
  203. visible: false,
  204. });
  205. this.props.closeDesc(false, true);
  206. },
  207. componentWillReceiveProps(nextProps) {
  208. if (!this.state.visible && nextProps.showDesc) {
  209. this.state.tabsKey = "1";
  210. };
  211. this.state.visible = nextProps.showDesc;
  212. },
  213. render() {
  214. return (
  215. <div className="patent-desc">
  216. <Modal maskClosable={false} visible={this.state.visible}
  217. onOk={this.checkPatentProcess} onCancel={this.handleCancel}
  218. width='800px'
  219. title='新建客户'
  220. footer=''
  221. className="admin-desc-content">
  222. <Spin spinning={this.state.loading}>
  223. <AchievementDetailForm
  224. data={this.props.data}
  225. newmodal={this.props.newmodal}
  226. closeDesc={this.handleCancel}
  227. visible={this.state.visible}
  228. handleOk={this.handleOk} />
  229. </Spin>
  230. </Modal>
  231. </div>
  232. );
  233. },
  234. });
  235. export default CustomerDetail;