basicPerson.jsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. import React from 'react';
  2. import { Radio, Icon, Button, AutoComplete, Cascader, layout, Input, Select, Tabs, Spin, Popconfirm, Popover, Table, Switch, message, DatePicker, Modal, Upload, Form, Row, Col, TimePicker } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import { citySelect, provinceList, areaSelect } from '@/NewDicProvinceList';
  7. import { socialAttribute, industry, newFollow, auditStatusL, lvl, currentMember, cityArr, statuslist, customerStatus, intentionalService, sex } from '@/dataDic.js';
  8. import { getCompanyIntention, splitUrl, getIndustry, getStatuslist, getAuditStatus, getContactType, getSocialAttribute, getfllowSituation, beforeUploadFile, getWhether, getcityArr, getcustomerStatue, getfllowSituationOn, getCertification, getcustomerTyp, getLvl, getCurrentMember, getprovince } from '@/tools.js';
  9. const FormItem = Form.Item;
  10. const monthFormat = 'YYYY/MM';
  11. //图片组件
  12. const PicturesWall = React.createClass({
  13. getInitialState() {
  14. return {
  15. previewVisible: false,
  16. previewImage: '',
  17. fileList: [],
  18. }
  19. },
  20. handleCancel() {
  21. this.setState({
  22. previewVisible: false
  23. })
  24. },
  25. handlePreview(file) {
  26. this.setState({
  27. previewImage: file.url || file.thumbUrl,
  28. previewVisible: true,
  29. });
  30. },
  31. handleChange(info) {
  32. let fileList = info.fileList;
  33. this.setState({
  34. fileList
  35. });
  36. this.props.fileList(fileList);
  37. },
  38. componentWillReceiveProps(nextProps) {
  39. this.state.fileList = nextProps.pictureUrl;
  40. },
  41. render() {
  42. const {
  43. previewVisible,
  44. previewImage,
  45. fileList
  46. } = this.state;
  47. const uploadButton = (
  48. <div>
  49. <Icon type="plus" />
  50. <div className="ant-upload-text">点击上传</div>
  51. </div>
  52. );
  53. return(
  54. <div style={{display:"inline-block"}}>
  55. <Upload
  56. action={globalConfig.context + "/api/admin/customer/uploadCustomerImg"}
  57. data={{ 'sign': '' }}
  58. listType="picture-card"
  59. fileList={fileList}
  60. onPreview={this.handlePreview}
  61. onChange={this.handleChange} >
  62. {fileList.length >= 1 ? null : uploadButton}
  63. </Upload>
  64. <Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel}>
  65. <img alt="example" style={{ width: '100%' }} src={previewImage} />
  66. </Modal>
  67. </div>
  68. );
  69. }
  70. });
  71. const Basic = React.createClass({
  72. getInitialState() {
  73. return {
  74. loading: false,
  75. orgCodeUrl: [],
  76. companyLogoUrl: [],
  77. headPortraitUrl: [],
  78. positiveIdUrl: [],
  79. oppositeIdUrl: []
  80. }
  81. },
  82. loadInformation(record) {
  83. this.setState({
  84. loading: true
  85. });
  86. $.ajax({
  87. method: "get",
  88. dataType: "json",
  89. crossDomain: false,
  90. url: globalConfig.context + '/api/admin/customer/findPersonalCustomerDetail',
  91. data: {
  92. uid: record
  93. },
  94. success: function(data) {
  95. let thisData = data.data;
  96. if(!thisData) {
  97. if(data.error && data.error.length) {
  98. message.warning(data.error[0].message);
  99. };
  100. thisData = {};
  101. };
  102. let ProvinceCityArr = [];
  103. let ProvinceS = thisData.province; //getprovince
  104. let citys = thisData.city;
  105. let Areas = thisData.area;
  106. ProvinceCityArr.push(ProvinceS, citys, Areas);
  107. let month = thisData.dateOfBirthYear ? thisData.dateOfBirthYear + '/' + thisData.dateOfBirthMonth : undefined;
  108. this.setState({
  109. InformationId: thisData.id,
  110. InformationUid: thisData.uid,
  111. identifyName: thisData.identifyName,
  112. listed: thisData.listed,
  113. highTechZone: thisData.highTechZone,
  114. headPortraitUrl: thisData.headPortraitUrl ? splitUrl(thisData.headPortraitUrl, ',', globalConfig.avatarHost + '/upload') : [],
  115. positiveIdUrl: thisData.positiveIdUrl ? splitUrl(thisData.positiveIdUrl, ',', globalConfig.avatarHost + '/upload') : [],
  116. oppositeIdUrl: thisData.oppositeIdUrl ? splitUrl(thisData.oppositeIdUrl, ',', globalConfig.avatarHost + '/upload') : [],
  117. dataInformation: thisData,
  118. idNumber: thisData.idNumber,
  119. contacts: thisData.contacts,
  120. contactMobile: thisData.contactMobile,
  121. ProvinceCity: ProvinceCityArr[0]!=null?ProvinceCityArr:undefined,
  122. industry: thisData.industry ? String(thisData.industry) : undefined,
  123. societyTag: thisData.societyTag||undefined,
  124. sex: thisData.sex,
  125. yearMonth: month,
  126. postalAddress: thisData.postalAddress,
  127. fixedTel: thisData.fixedTel,
  128. consultationPrice: thisData.consultationPrice,
  129. email: thisData.email,
  130. qq: thisData.qq,
  131. introduction: thisData.introduction,
  132. expert: thisData.expert,
  133. celebrity: thisData.celebrity,
  134. consultant: thisData.consultant,
  135. international: thisData.international,
  136. investment: thisData.investment,
  137. professionalTitle: thisData.professionalTitle,
  138. workUnit: thisData.workUnit,
  139. education: thisData.education,
  140. graduateSchool: thisData.graduateSchool,
  141. majorCategory: thisData.majorCategory,
  142. qualification: thisData.qualification,
  143. businessAudit: thisData.businessAudit,
  144. auditStatus: thisData.auditStatus ? String(thisData.auditStatus) : undefined,
  145. });
  146. }.bind(this),
  147. }).always(function() {
  148. this.setState({
  149. loading: false
  150. });
  151. }.bind(this));
  152. },
  153. //图片
  154. getOrgCodeUrl(e) {
  155. this.setState({
  156. orgCodeUrl: e
  157. });
  158. },
  159. getCompanyLogoUrl(e) {
  160. this.setState({
  161. companyLogoUrl: e
  162. });
  163. },
  164. //基本信息提交
  165. newSubmit(e) {
  166. e.preventDefault();
  167. if(!this.state.industry) {
  168. message.warning('请选择行业');
  169. return false;
  170. };
  171. if(!this.state.societyTag) {
  172. message.warning('请选择社会性质');
  173. return false;
  174. };
  175. if(!this.state.ProvinceCity[1]) {
  176. message.warning('请选择地区');
  177. return false;
  178. };
  179. var reg = /^[1-9]\d*$|^0$/;
  180. if(this.state.consultationPrice) {
  181. if(this.state.consultationPrice.length > 6) {
  182. message.warning('咨询费用不超过6位数');
  183. this.refs.consul.focus();
  184. return false;
  185. };
  186. if(!reg.test(this.state.consultationPrice)) {
  187. message.warning('咨询费用只能输入数字');
  188. this.refs.consul.focus();
  189. return false;
  190. }
  191. }
  192. this.state.data = [];
  193. this.setState({
  194. selectedRowKeys: [],
  195. });
  196. let theorgCodeUrl = [];
  197. if(this.state.headPortraitUrl.length) {
  198. let picArr = [];
  199. this.state.headPortraitUrl.map(function(item) {
  200. if(item.response && item.response.data && item.response.data.length) {
  201. picArr.push(item.response.data);
  202. }
  203. });
  204. theorgCodeUrl = picArr.join(",");
  205. };
  206. let thecompanyLogoUrl = [];
  207. if(this.state.positiveIdUrl.length) {
  208. let picArr = [];
  209. this.state.positiveIdUrl.map(function(item) {
  210. if(item.response && item.response.data && item.response.data.length) {
  211. picArr.push(item.response.data);
  212. }
  213. });
  214. thecompanyLogoUrl = picArr.join(",");
  215. };
  216. let thecompanyLogoUrls = [];
  217. if(this.state.oppositeIdUrl.length) {
  218. let picArr = [];
  219. this.state.oppositeIdUrl.map(function(item) {
  220. if(item.response && item.response.data && item.response.data.length) {
  221. picArr.push(item.response.data);
  222. }
  223. });
  224. thecompanyLogoUrls = picArr.join(",");
  225. };
  226. let years = [];
  227. let yearMonth = this.state.yearMonth != undefined ? new Date(this.state.yearMonth).toLocaleDateString() : '';
  228. years = yearMonth.split('/');
  229. this.setState({
  230. loading: true
  231. });
  232. $.ajax({
  233. method: "post",
  234. dataType: "json",
  235. url: globalConfig.context + '/api/admin/customer/updatePersonalCustomer',
  236. data: {
  237. id: this.state.InformationId,
  238. uid: this.state.InformationUid,
  239. societyTag: this.state.societyTag,
  240. identifyName: this.state.identifyName,
  241. industry: this.state.industry,
  242. dateOfBirthYear: years[0], //出生年
  243. dateOfBirthMonth: years[1], //出生月
  244. province: (this.state.ProvinceCity)[0], //省-
  245. city: (this.state.ProvinceCity)[1], //市
  246. area: (this.state.ProvinceCity)[2], //区
  247. sex: this.state.sex,
  248. expert: this.state.expert,
  249. celebrity: this.state.celebrity,
  250. consultant: this.state.consultant,
  251. international: this.state.international,
  252. fixedTel: this.state.fixedTel,
  253. consultationPrice: this.state.consultationPrice ? this.state.consultationPrice : '',
  254. qq: this.state.qq,
  255. contacts: this.state.contacts,
  256. contactMobile: this.state.contactMobile,
  257. idNumber: this.state.idNumber,
  258. email: this.state.email,
  259. isMember: this.state.isMember,
  260. postalAddress: this.state.postalAddress,
  261. introduction: this.state.introduction,
  262. positiveIdUrl: thecompanyLogoUrl.length != 0 ? thecompanyLogoUrl : '',
  263. oppositeIdUrl: thecompanyLogoUrls.length != 0 ? thecompanyLogoUrls : '',
  264. headPortraitUrl: theorgCodeUrl.length != 0 ? theorgCodeUrl : '',
  265. investment: this.state.investment,
  266. professionalTitle: this.state.professionalTitle,
  267. workUnit: this.state.workUnit,
  268. education: this.state.education,
  269. graduateSchool: this.state.graduateSchool,
  270. majorCategory: this.state.majorCategory,
  271. qualification: this.state.qualification,
  272. businessAudit: this.state.businessAudit,
  273. auditStatus: this.state.auditStatus,
  274. }
  275. }).done(function(data) {
  276. this.setState({
  277. loading: false
  278. });
  279. if(!data.error.length) {
  280. message.success('保存成功!');
  281. this.props.closeDetail(false, true)
  282. } else {
  283. message.warning(data.error[0].message);
  284. }
  285. }.bind(this));
  286. },
  287. //取消
  288. detailsModal() {
  289. this.props.closeDetail(false, false)
  290. },
  291. getHeadPortraitUrl(e) {
  292. this.setState({ headPortraitUrl: e });
  293. },
  294. getPositiveIdUrl(e) {
  295. this.setState({ positiveIdUrl: e });
  296. },
  297. getOppositeIdUrl(e) {
  298. this.setState({ oppositeIdUrl: e });
  299. },
  300. componentWillMount() {
  301. this.loadInformation(this.props.data.id)
  302. },
  303. componentWillReceiveProps(nextProps) {
  304. if(nextProps.data && nextProps.basicState) {
  305. this.loadInformation(nextProps.data.id)
  306. }
  307. },
  308. render() {
  309. const {
  310. RangePicker,
  311. MonthPicker
  312. } = DatePicker;
  313. const formItemLayout = {
  314. labelCol: {
  315. span: 8
  316. },
  317. wrapperCol: {
  318. span: 14
  319. },
  320. };
  321. return(
  322. <div>
  323. <Form layout="horizontal" onSubmit={this.newSubmit} id="demand-form">
  324. <Spin spinning={this.state.loading}>
  325. <div className="clearfix" >
  326. <FormItem className="half-item"
  327. {...formItemLayout}
  328. label="客户姓名"
  329. >
  330. <span>{this.state.identifyName}</span>
  331. </FormItem>
  332. </div>
  333. <div className="clearfix" >
  334. <FormItem className="half-item"
  335. {...formItemLayout}
  336. label="行业">
  337. <Select placeholder="选择行业" value={this.state.industry} style={{width:'300px'}}
  338. onChange={(e)=>{this.setState({industry:e})}}>
  339. {
  340. industry.map(function (item) {
  341. return <Select.Option key={item.value} >{item.key}</Select.Option>
  342. })
  343. }
  344. </Select>
  345. <span style={{color:'red',marginLeft:'15px'}}>*</span>
  346. </FormItem>
  347. <FormItem className="half-item"
  348. {...formItemLayout}
  349. label="社会属性"
  350. >
  351. <Select placeholder="客户社会属性" value={this.state.societyTag} style={{width:'300px'}}
  352. onChange={(e)=>{this.setState({societyTag:e})}}>
  353. {
  354. socialAttribute.map(function (item) {
  355. return <Select.Option key={item.value} >{item.key}</Select.Option>
  356. })
  357. }
  358. </Select>
  359. <span style={{color:'red',marginLeft:'15px'}}>*</span>
  360. </FormItem>
  361. <FormItem className="half-item"
  362. {...formItemLayout}
  363. label="省-市-区"
  364. >
  365. <Cascader options={areaSelect()} value={this.state.ProvinceCity} placeholder="选择城市" style={{width:'300px'}}
  366. onChange={(e,pre) => { this.setState({ ProvinceCity: e }) }} />
  367. <span style={{color:'red',marginLeft:'15px'}}>*</span>
  368. </FormItem>
  369. <FormItem className="half-item"
  370. {...formItemLayout}
  371. label="出生日期"
  372. >
  373. {!this.state.yearMonth?<MonthPicker placeholder="选择出生年月" value={this.state.yearMonth} onChange={(time) => {this.setState({yearMonth: time});}}/>
  374. :<MonthPicker value={moment(this.state.yearMonth, monthFormat)} format={monthFormat} onChange={(time) => {this.setState({yearMonth: time});}}/>
  375. }
  376. </FormItem>
  377. <FormItem className="half-item"
  378. {...formItemLayout}
  379. label="身份证号码"
  380. >
  381. <Input placeholder="身份证号码" value={this.state.idNumber} onChange={(e) => {
  382. this.setState({ idNumber: e.target.value })}}/>
  383. </FormItem>
  384. <FormItem className="half-item"
  385. {...formItemLayout}
  386. label="主要联系人"
  387. >
  388. <Input placeholder="主要联系人" value={this.state.contacts} onChange={(e) => {
  389. this.setState({ contacts: e.target.value })}}/>
  390. </FormItem>
  391. <FormItem className="half-item"
  392. {...formItemLayout}
  393. label="主要联系人号码"
  394. >
  395. <Input placeholder="主要联系人号码" value={this.state.contactMobile} onChange={(e) => {
  396. this.setState({ contactMobile: e.target.value })}}/>
  397. </FormItem>
  398. <div className="clearfix">
  399. <FormItem className="half-item"
  400. {...formItemLayout}
  401. label="职称名字"
  402. >
  403. <Input placeholder="职称名字" value={this.state.professionalTitle} onChange={(e) => {
  404. this.setState({ professionalTitle: e.target.value })}}/>
  405. </FormItem>
  406. <FormItem className="half-item"
  407. {...formItemLayout}
  408. label="就业单位"
  409. >
  410. <Input placeholder="就业单位" value={this.state.workUnit} onChange={(e) => {
  411. this.setState({ workUnit: e.target.value })}}/>
  412. </FormItem>
  413. <FormItem className="half-item"
  414. {...formItemLayout}
  415. label="学历"
  416. >
  417. <Input placeholder="学历" value={this.state.education} onChange={(e) => {
  418. this.setState({ education: e.target.value })}}/>
  419. </FormItem>
  420. <FormItem className="half-item"
  421. {...formItemLayout}
  422. label="毕业院校"
  423. >
  424. <Input placeholder="学历" value={this.state.graduateSchool} onChange={(e) => {
  425. this.setState({ graduateSchool: e.target.value })}}/>
  426. </FormItem>
  427. <FormItem className="half-item"
  428. {...formItemLayout}
  429. label="专业类别"
  430. >
  431. <Input placeholder="专业类别" value={this.state.majorCategory} onChange={(e) => {
  432. this.setState({ majorCategory: e.target.value })}}/>
  433. </FormItem>
  434. <FormItem className="half-item"
  435. {...formItemLayout}
  436. label="职业资格"
  437. >
  438. <Input placeholder="职业资格" value={this.state.qualification} onChange={(e) => {
  439. this.setState({ qualification: e.target.value })}}/>
  440. </FormItem>
  441. <FormItem className="half-item"
  442. {...formItemLayout}
  443. label="通信地址"
  444. >
  445. <Input placeholder="客户通信地址" value={this.state.postalAddress}
  446. onChange={(e,pre) => { this.setState({ postalAddress: e.target.value }) }}/>
  447. </FormItem>
  448. <FormItem className="half-item"
  449. {...formItemLayout}
  450. label="固定电话"
  451. >
  452. <Input placeholder="客户固定电话" value={this.state.fixedTel}
  453. onChange={(e) => { this.setState({ fixedTel: e.target.value }) }}/>
  454. </FormItem>
  455. <FormItem className="half-item"
  456. {...formItemLayout}
  457. label="客户QQ"
  458. >
  459. <Input placeholder="客户QQ" value={this.state.qq}
  460. onChange={(e) => { this.setState({ qq: e.target.value })}}/>
  461. </FormItem>
  462. <FormItem className="half-item"
  463. {...formItemLayout}
  464. label="电子邮箱"
  465. >
  466. <Input placeholder="客户电子邮箱" value={this.state.email}
  467. onChange={(e) => {this.setState({email: e.target.value })}}/>
  468. </FormItem>
  469. <FormItem className="half-item"
  470. {...formItemLayout}
  471. label="咨询费用"
  472. >
  473. <Input ref='consul' placeholder="请输入咨询费用" value={this.state.consultationPrice}
  474. onChange={(e) => {this.setState({consultationPrice: e.target.value })}}/>
  475. </FormItem>
  476. </div>
  477. <div className="clearfix">
  478. <FormItem className="half-item"
  479. {...formItemLayout}
  480. label="性别"
  481. >
  482. <Radio.Group value={this.state.sex} onChange={(e) => {
  483. this.setState({sex:e.target.value})
  484. }}>
  485. <Radio value={'男'}>男</Radio>
  486. <Radio value={'女'}>女</Radio>
  487. </Radio.Group>
  488. </FormItem>
  489. </div>
  490. <div className='clearfix'>
  491. <FormItem
  492. labelCol={{ span:4 }}
  493. wrapperCol={{ span: 18 }}
  494. label="客户简介" >
  495. <Input type="textarea" rows={4} value={this.state.introduction}
  496. onChange={(e,pre) => { this.setState({ introduction: e.target.value })}}/>
  497. </FormItem>
  498. </div>
  499. <div className="clearfix pictures">
  500. <FormItem style={{display:'inline-block',width:'350px',marginTop:'20px',marginLeft:'95px'}}
  501. labelCol={{ span: 8 }}
  502. wrapperCol={{ span: 10 }}
  503. label="身份证正面" >
  504. <PicturesWall
  505. fileList={this.getPositiveIdUrl}
  506. pictureUrl={this.state.positiveIdUrl} />
  507. <p>建议:图片要清晰。</p>
  508. </FormItem>
  509. <FormItem style={{display:'inline-block',width:'350px',marginTop:'20px'}}
  510. labelCol={{ span: 8 }}
  511. wrapperCol={{ span: 10 }}
  512. label="身份证反面" >
  513. <PicturesWall
  514. fileList={this.getOppositeIdUrl}
  515. pictureUrl={this.state.oppositeIdUrl} />
  516. <p>建议:图片要清晰。</p>
  517. </FormItem>
  518. <FormItem style={{display:'inline-block' ,width:'350px',marginTop:'20px'}}
  519. labelCol={{ span: 8 }}
  520. wrapperCol={{ span: 10 }}
  521. label="客户照片" >
  522. <PicturesWall
  523. fileList={this.getHeadPortraitUrl}
  524. pictureUrl={this.state.headPortraitUrl} />
  525. <p>建议:图片要清晰。</p>
  526. </FormItem>
  527. </div>
  528. <Button className="setSubmit" type="primary" htmlType="submit">保存</Button>
  529. <Button type="ghost" onClick={this.detailsModal}>取消</Button>
  530. </div>
  531. </Spin>
  532. </Form>
  533. </div>
  534. )
  535. }
  536. })
  537. export default Basic;