basic.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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. //图片组件
  11. const PicturesWall = React.createClass({
  12. getInitialState() {
  13. return {
  14. previewVisible: false,
  15. previewImage: '',
  16. fileList: [],
  17. }
  18. },
  19. handleCancel() {
  20. this.setState({
  21. previewVisible: false
  22. })
  23. },
  24. handlePreview(file) {
  25. this.setState({
  26. previewImage: file.url || file.thumbUrl,
  27. previewVisible: true,
  28. });
  29. },
  30. handleChange(info) {
  31. let fileList = info.fileList;
  32. this.setState({
  33. fileList
  34. });
  35. this.props.fileList(fileList);
  36. },
  37. componentWillReceiveProps(nextProps) {
  38. this.state.fileList = nextProps.pictureUrl;
  39. },
  40. render() {
  41. const {
  42. previewVisible,
  43. previewImage,
  44. fileList
  45. } = this.state;
  46. const uploadButton = (
  47. <div>
  48. <Icon type="plus" />
  49. <div className="ant-upload-text">点击上传</div>
  50. </div>
  51. );
  52. return(
  53. <div style={{display:"inline-block"}}>
  54. <Upload
  55. action={globalConfig.context + "/api/admin/customer/uploadCustomerImg"}
  56. data={{ 'sign': '' }}
  57. listType="picture-card"
  58. fileList={fileList}
  59. onPreview={this.handlePreview}
  60. onChange={this.handleChange} >
  61. {fileList.length >= 1 ? null : uploadButton}
  62. </Upload>
  63. <Modal maskClosable={false} visible={previewVisible} footer={null} onCancel={this.handleCancel}>
  64. <img alt="example" style={{ width: '100%' }} src={previewImage} />
  65. </Modal>
  66. </div>
  67. );
  68. }
  69. });
  70. const Basic = React.createClass({
  71. getInitialState() {
  72. return {
  73. loading: false,
  74. orgCodeUrl: [],
  75. companyLogoUrl: [],
  76. }
  77. },
  78. loadInformation(record) {
  79. $.ajax({
  80. method: "get",
  81. dataType: "json",
  82. url: globalConfig.context + '/api/admin/customer/findOrganizationCustomerDetail',
  83. data: {
  84. uid: record
  85. },
  86. success: function(data) {
  87. let thisData = data.data;
  88. if(!thisData) {
  89. if(data.error && data.error.length) {
  90. message.warning(data.error[0].message);
  91. };
  92. thisData = {};
  93. };
  94. let ProvinceCityArr = [];
  95. let ProvinceS = thisData.locationProvince; //getprovince
  96. let citys = thisData.locationCity;
  97. let Areas = thisData.locationArea;
  98. ProvinceCityArr.push(ProvinceS, citys, Areas);
  99. this.setState({
  100. InformationId: thisData.id,
  101. InformationUid: thisData.uid,
  102. identifyName: thisData.identifyName,
  103. listed: thisData.listed,
  104. highTechZone: thisData.highTechZone,
  105. orgCodeUrl: thisData.orgCodeUrl ? splitUrl(thisData.orgCodeUrl, ',', globalConfig.avatarHost + '/upload') : [],
  106. companyLogoUrl: thisData.companyLogoUrl ? splitUrl(thisData.companyLogoUrl, ',', globalConfig.avatarHost + '/upload') : [],
  107. dataInformation: thisData,
  108. ProvinceCity: ProvinceCityArr[0]!=null?ProvinceCityArr:undefined,
  109. contacts: thisData.contacts,
  110. contactMobile: thisData.contactMobile,
  111. industry: String(thisData.industry) == 'null' ? undefined : String(thisData.industry),
  112. international: thisData.international,
  113. societyTag: thisData.societyTag||undefined,
  114. introduction: thisData.introduction,
  115. postalAddress: thisData.postalAddress,
  116. contactsFixedTel: thisData.contactsFixedTel,
  117. contactsFax: thisData.contactsFax,
  118. registeredCapital: thisData.registeredCapital,
  119. enterpriseScale: thisData.enterpriseScale,
  120. legalPerson: thisData.legalPerson,
  121. legalPersonIdCard: thisData.legalPersonIdCard,
  122. legalPersonTel: thisData.legalPersonTel,
  123. legalPersonEmail: thisData.legalPersonEmail,
  124. businessScope: thisData.businessScope,
  125. orgCode: thisData.orgCode,
  126. investment: thisData.investment,
  127. auditStatus: thisData.auditStatus ? String(thisData.auditStatus) : undefined,
  128. businessAudit: thisData.businessAudit
  129. });
  130. }.bind(this),
  131. }).always(function() {
  132. this.setState({
  133. loading: false
  134. });
  135. }.bind(this));
  136. },
  137. //图片
  138. getOrgCodeUrl(e) {
  139. this.setState({
  140. orgCodeUrl: e
  141. });
  142. },
  143. getCompanyLogoUrl(e) {
  144. this.setState({
  145. companyLogoUrl: e
  146. });
  147. },
  148. //基本信息提交
  149. newSubmit(e) {
  150. e.preventDefault();
  151. if(!this.state.industry) {
  152. message.warning('请选择行业');
  153. return false;
  154. };
  155. if(!this.state.societyTag) {
  156. message.warning('请选择社会性质');
  157. return false;
  158. };
  159. if(!this.state.ProvinceCity[1]) {
  160. message.warning('请选择地区');
  161. return false;
  162. };
  163. if(isNaN(this.state.registeredCapital)) {
  164. message.warning('注册资本只能输入数字')
  165. return false;
  166. };
  167. if(isNaN(this.state.enterpriseScale)) {
  168. message.warning('单位规模只能输入数字')
  169. return false;
  170. }
  171. this.setState({
  172. selectedRowKeys: [],
  173. });
  174. let theorgCodeUrl = [];
  175. if(this.state.orgCodeUrl.length) {
  176. let picArr = [];
  177. this.state.orgCodeUrl.map(function(item) {
  178. if(item.response && item.response.data && item.response.data.length) {
  179. picArr.push(item.response.data);
  180. }
  181. });
  182. theorgCodeUrl = picArr.join(",");
  183. };
  184. let thecompanyLogoUrl = [];
  185. if(this.state.companyLogoUrl.length) {
  186. let picArr = [];
  187. this.state.companyLogoUrl.map(function(item) {
  188. if(item.response && item.response.data && item.response.data.length) {
  189. picArr.push(item.response.data);
  190. }
  191. });
  192. thecompanyLogoUrl = picArr.join(",");
  193. };
  194. this.setState({
  195. loading: true
  196. });
  197. $.ajax({
  198. method: "post",
  199. dataType: "json",
  200. url: globalConfig.context + '/api/admin/customer/updateOrganizationCustomer',
  201. data: {
  202. id: this.state.InformationId,
  203. uid: this.state.InformationUid,
  204. societyTag: this.state.societyTag,
  205. introduction: this.state.introduction,
  206. unitName: this.state.unitName,
  207. industry: this.state.industry,
  208. locationProvince: (this.state.ProvinceCity)[0], //省-
  209. locationCity: (this.state.ProvinceCity)[1], //市
  210. locationArea: (this.state.ProvinceCity)[2], //区
  211. postalAddress: this.state.postalAddress,
  212. contactsFixedTel: this.state.contactsFixedTel,
  213. contactsFax: this.state.contactsFax,
  214. registeredCapital: this.state.registeredCapital ? this.state.registeredCapital : 0,
  215. enterpriseScale: this.state.enterpriseScale ? this.state.enterpriseScale : 0,
  216. legalPerson: this.state.legalPerson,
  217. legalPersonIdCard: this.state.legalPersonIdCard,
  218. legalPersonTel: this.state.legalPersonTel,
  219. legalPersonEmail: this.state.legalPersonEmail,
  220. highTechZone: this.state.highTechZone,
  221. listed: this.state.listed,
  222. contacts: this.state.contacts,
  223. contactMobile: this.state.contactMobile,
  224. international: this.state.international,
  225. orgCode: this.state.orgCode,
  226. businessScope: this.state.businessScope,
  227. introduction: this.state.introduction,
  228. companyLogoUrl: thecompanyLogoUrl != 0 ? thecompanyLogoUrl : '',
  229. orgCodeUrl: theorgCodeUrl != 0 ? theorgCodeUrl : '',
  230. businessAudit: this.state.businessAudit,
  231. auditStatus: this.state.auditStatus
  232. }
  233. }).done(function(data) {
  234. this.setState({
  235. loading: false
  236. });
  237. if(!data.error.length) {
  238. message.success('保存成功!');
  239. this.props.closeDetail(false, true)
  240. } else {
  241. message.warning(data.error[0].message);
  242. }
  243. }.bind(this));
  244. },
  245. //取消
  246. detailsModal() {
  247. this.props.closeDetail(false, false)
  248. },
  249. componentWillMount(){
  250. this.loadInformation(this.props.data.id)
  251. },
  252. componentWillReceiveProps(nextProps) {
  253. if(nextProps.data&&nextProps.basicState){
  254. this.loadInformation(nextProps.data.id)
  255. }
  256. },
  257. render() {
  258. return(
  259. <div>
  260. <Form layout="horizontal" onSubmit={this.newSubmit} id="demand-form">
  261. <Spin spinning={this.state.loading}>
  262. <div className="clearfix" style={{paddingLeft:'60px'}}>
  263. <FormItem className="half-item"
  264. labelCol={{ span: 4 }}
  265. wrapperCol={{ span: 18 }}
  266. label="客户名称"
  267. >
  268. <span>{this.state.identifyName}</span>
  269. </FormItem>
  270. </div>
  271. <div className="clearfix" style={{paddingLeft:'60px'}}>
  272. <FormItem className="half-item"
  273. labelCol={{ span: 4 }}
  274. wrapperCol={{ span: 18 }}
  275. label="行业">
  276. <Select placeholder="选择行业" value={this.state.industry} style={{width:'300px'}}
  277. onChange={(e)=>{this.setState({industry:e})}}>
  278. {
  279. industry.map(function (item) {
  280. return <Select.Option key={item.value} >{item.key}</Select.Option>
  281. })
  282. }
  283. </Select>
  284. <span style={{color:'red',marginLeft:'15px'}}>*</span>
  285. </FormItem>
  286. <FormItem className="half-item"
  287. labelCol={{ span: 4 }}
  288. wrapperCol={{ span: 18 }}
  289. label="社会属性"
  290. >
  291. <Select placeholder="客户社会属性(必填项)" value={this.state.societyTag} style={{width:'300px'}}
  292. onChange={(e)=>{this.setState({societyTag:e})}}>
  293. {
  294. socialAttribute.map(function (item) {
  295. return <Select.Option key={item.value} >{item.key}</Select.Option>
  296. })
  297. }
  298. </Select>
  299. <span style={{color:'red',marginLeft:'15px'}}>*</span>
  300. </FormItem>
  301. <FormItem className="half-item"
  302. labelCol={{ span: 4 }}
  303. wrapperCol={{ span: 18 }}
  304. label="省-市-区"
  305. >
  306. <Cascader options={areaSelect()} value={this.state.ProvinceCity} placeholder="选择城市" style={{width:'300px'}}
  307. onChange={(e,pre) => { this.setState({ ProvinceCity: e }) }} />
  308. <span style={{color:'red',marginLeft:'15px'}}>*</span>
  309. </FormItem>
  310. <FormItem className="half-item"
  311. labelCol={{ span: 4 }}
  312. wrapperCol={{ span: 18 }}
  313. label="通信地址"
  314. >
  315. <Input placeholder="客户通信地址" value={this.state.postalAddress}
  316. onChange={(e)=>{this.setState({postalAddress:e.target.value})}}/>
  317. </FormItem>
  318. <FormItem className="half-item"
  319. labelCol={{ span: 4 }}
  320. wrapperCol={{ span: 18 }}
  321. label="固定电话"
  322. >
  323. <Input placeholder="客户固定电话" value={this.state.contactsFixedTel}
  324. onChange={(e)=>{this.setState({contactsFixedTel:e.target.value})}}/>
  325. </FormItem>
  326. <FormItem className="half-item"
  327. labelCol={{ span: 4 }}
  328. wrapperCol={{ span: 18 }}
  329. label="客户传真"
  330. >
  331. <Input placeholder="客户传真" value={this.state.contactsFax}
  332. onChange={(e)=>{this.setState({contactsFax:e.target.value})}}/>
  333. </FormItem>
  334. <FormItem className="half-item"
  335. labelCol={{ span: 4 }}
  336. wrapperCol={{ span: 18 }}
  337. label="注册资本"
  338. >
  339. <Input placeholder="注册资本" value={this.state.registeredCapital} maxLength='6'
  340. onChange={(e)=>{this.setState({registeredCapital:e.target.value})}}/>
  341. </FormItem>
  342. <FormItem className="half-item"
  343. labelCol={{ span: 4 }}
  344. wrapperCol={{ span: 18 }}
  345. label="单位规模"
  346. >
  347. <Input placeholder="单位规模" value={this.state.enterpriseScale} maxLength='1'
  348. onChange={(e)=>{this.setState({enterpriseScale:e.target.value})}}/>
  349. </FormItem>
  350. <FormItem className="half-item"
  351. labelCol={{ span: 4 }}
  352. wrapperCol={{ span: 18 }}
  353. label="法人名称"
  354. >
  355. <Input placeholder="法人名称" value={this.state.legalPerson}
  356. onChange={(e)=>{this.setState({legalPerson:e.target.value})}}/>
  357. </FormItem>
  358. <FormItem className="half-item"
  359. labelCol={{ span: 4 }}
  360. wrapperCol={{ span: 18 }}
  361. label="身份证号码"
  362. >
  363. <Input placeholder="法人身份证号码" value={this.state.legalPersonIdCard}
  364. onChange={(e)=>{this.setState({legalPersonIdCard:e.target.value})}}/>
  365. </FormItem>
  366. <FormItem className="half-item"
  367. labelCol={{ span: 4 }}
  368. wrapperCol={{ span: 18 }}
  369. label="主要联系人"
  370. >
  371. <Input placeholder="主要联系人" value={this.state.contacts} onChange={(e) => {
  372. this.setState({ contacts: e.target.value })}}/>
  373. </FormItem>
  374. <FormItem className="half-item"
  375. labelCol={{ span: 4 }}
  376. wrapperCol={{ span: 18 }}
  377. label="主要联系人号码"
  378. >
  379. <Input placeholder="主要联系人号码" value={this.state.contactMobile} onChange={(e) => {
  380. this.setState({ contactMobile: e.target.value })}}/>
  381. </FormItem>
  382. <FormItem className="half-item"
  383. labelCol={{ span: 4 }}
  384. wrapperCol={{ span: 18 }}
  385. label="法人电话"
  386. >
  387. <Input placeholder="法人电话" value={this.state.legalPersonTel}
  388. onChange={(e)=>{this.setState({legalPersonTel:e.target.value})}}/>
  389. </FormItem>
  390. <FormItem className="half-item"
  391. labelCol={{ span: 4 }}
  392. wrapperCol={{ span: 18 }}
  393. label="电子邮箱"
  394. >
  395. <Input placeholder="法人电子邮箱" value={this.state.legalPersonEmail}
  396. onChange={(e)=>{this.setState({legalPersonEmail:e.target.value})}}/>
  397. </FormItem>
  398. <FormItem className="half-item"
  399. labelCol={{ span: 4 }}
  400. wrapperCol={{ span: 18 }}
  401. label="机构代码"
  402. >
  403. <Input placeholder="社会同意机构代码" value={this.state.orgCode}
  404. onChange={(e)=>{this.setState({orgCode:e.target.value})}}/>
  405. </FormItem>
  406. <div className="clearfix pictures">
  407. <FormItem
  408. labelCol={{ span: 6 }}
  409. wrapperCol={{ span: 18 }}
  410. style={{marginTop:15}}
  411. label="机构证(PIC)" >
  412. <PicturesWall
  413. pictureSign="PIC"
  414. fileList={this.getOrgCodeUrl}
  415. pictureUrl={this.state.orgCodeUrl} />
  416. <p>图片建议:图片要清晰。</p>
  417. </FormItem>
  418. <FormItem
  419. labelCol={{ span: 6 }}
  420. wrapperCol={{ span: 18 }}
  421. label="单位logo" >
  422. <PicturesWall
  423. pictureSign="logo"
  424. fileList={this.getCompanyLogoUrl}
  425. pictureUrl={this.state.companyLogoUrl} />
  426. <p>图片建议:图片要清晰。</p>
  427. </FormItem>
  428. </div>
  429. <div className="clearfix">
  430. <FormItem
  431. labelCol={{ span: 2 }}
  432. wrapperCol={{ span: 18 }}
  433. label="业务范围" >
  434. <Input type="textarea" rows={4} value={this.state.businessScope}
  435. onChange={(e)=>{this.setState({businessScope:e.target.value})}}/>
  436. </FormItem>
  437. <FormItem
  438. labelCol={{ span: 2 }}
  439. wrapperCol={{ span: 18 }}
  440. label="单位简介" >
  441. <Input type="textarea" rows={4} value={this.state.introduction}
  442. onChange={(e)=>{this.setState({introduction:e.target.value})}}/>
  443. </FormItem>
  444. </div>
  445. <Button className="set-submit" type="primary" htmlType="submit" >保存</Button>
  446. <Button type="ghost" onClick={this.detailsModal}>取消</Button>
  447. </div>
  448. </Spin>
  449. </Form>
  450. </div>
  451. )
  452. }
  453. })
  454. export default Basic;