pfs.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. import React from 'react';
  2. import { Input, Button, Form, Select, Upload, Icon, Spin, message, Radio, InputNumber, Cascader } from 'antd';
  3. import './pfs.less';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. import YearSelect from '../../yearSelect.jsx';
  7. import { getBase64, beforeUpload } from '../../tools.js';
  8. import { jingli_yuanxiao, jingli_shehui, chengjiu_yuanxiao, chengjiu_shehui } from '../../dataDic.js';
  9. import { techFieldList } from '../../DicTechFieldList';
  10. const FormItem = Form.Item;
  11. const RadioButton = Radio.Button;
  12. const RadioGroup = Radio.Group;
  13. class Avatar extends React.Component {
  14. constructor(props) {
  15. super(props);
  16. this.state = {
  17. imageUrl: '',
  18. propsbool: true,
  19. }
  20. }
  21. handleChange(info) {
  22. if (info.file.status === 'done') {
  23. // Get this url from response in real world.
  24. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
  25. this.props.urlData(info.file.response.data);
  26. }
  27. }
  28. componentWillReceiveProps(nextProps) {
  29. if (nextProps.picUrl && this.state.propsbool) {
  30. this.state.imageUrl = globalConfig.avatarHost + "/upload" + nextProps.picUrl;
  31. this.state.propsbool = false;
  32. }
  33. }
  34. render() {
  35. const imageUrl = this.state.imageUrl;
  36. return (
  37. <Upload
  38. className="avatar-uploader"
  39. name="avatar"
  40. showUploadList={false}
  41. action={globalConfig.context + "/api/user/avatar/uploadReplace"}
  42. data={{ 'sign': this.props.name }}
  43. beforeUpload={beforeUpload}
  44. onChange={this.handleChange.bind(this)}
  45. >
  46. {
  47. imageUrl ?
  48. <img src={imageUrl} role="presentation" className="avatar" /> :
  49. <Icon type="plus" className="avatar-uploader-trigger" />
  50. }
  51. </Upload>
  52. );
  53. }
  54. };
  55. const PfsFrom = Form.create()(React.createClass({
  56. getData() {
  57. this.props.spinState(true);
  58. $.ajax({
  59. method: "get",
  60. dataType: "json",
  61. url: globalConfig.context + "/api/user/job",
  62. success: function (data) {
  63. if (data.data) {
  64. this.setState({
  65. id: data.data.id,
  66. field: data.data.engagedField ? data.data.engagedField.split(',') : [],
  67. gongling: data.data.workingAge,
  68. zhichengname: data.data.professionalTitle,
  69. zhichengyear: data.data.professionalTitleGettime,
  70. zhichengPicUrl: data.data.professionalCertificateUrl,
  71. zigename: data.data.qualification,
  72. zigeyear: data.data.qualificationGettime,
  73. zigePicUrl: data.data.qualificationCertificateUrl,
  74. danwei: data.data.workUnit,
  75. touxian: data.data.position,
  76. jingli: data.data.experiences,
  77. chengjiu: data.data.achievement
  78. });
  79. };
  80. }.bind(this),
  81. }).always(function () {
  82. this.props.spinState(false);
  83. }.bind(this));
  84. },
  85. getInitialState() {
  86. return {
  87. loading: false,
  88. zigePicUrl: '',
  89. zhichengPicUrl: ''
  90. };
  91. },
  92. componentWillMount() {
  93. this.getData();
  94. },
  95. handleSubmit(e) {
  96. e.preventDefault();
  97. this.props.form.validateFields((err, values) => {
  98. if (!err) {
  99. if (values.gongling < 0) {
  100. message.warning('工龄不能小于零!');
  101. return;
  102. };
  103. this.props.spinState(true);
  104. $.ajax({
  105. method: "POST",
  106. dataType: "json",
  107. crossDomain: false,
  108. url: globalConfig.context + "/api/user/userCareer",
  109. data: {
  110. "id": this.state.id,
  111. "engagedField": values.field ? values.field.join(',') : '',
  112. "workingAge": values.gongling,
  113. "professionalTitle": values.zhichengname,
  114. "professionalTitleGettime": this.state.zhichengyear,
  115. "professionalCertificateUrl": this.state.zhichengPicUrl,
  116. "qualification": values.zigename,
  117. "qualificationGettime": this.state.zigeyear,
  118. "qualificationCertificateUrl": this.state.zigePicUrl,
  119. "workUnit": values.danwei,
  120. "position": values.touxian,
  121. "experiences": values.jingli,
  122. "achievement": values.chengjiu
  123. }
  124. }).done(function (data) {
  125. if (!data.error.length) {
  126. message.success('保存成功!');
  127. this.getData();
  128. } else {
  129. message.warning(data.error[0].message);
  130. }
  131. }.bind(this)).always(function () {
  132. this.props.spinState(false);
  133. }.bind(this));
  134. }
  135. });
  136. },
  137. zhichengPic(e) {
  138. this.state.zhichengPicUrl = e;
  139. },
  140. zhichengyear(e) {
  141. this.state.zhichengyear = e;
  142. },
  143. zigePic(e) {
  144. this.state.zigePicUrl = e;
  145. },
  146. zigeyear(e) {
  147. this.state.zigeyear = e;
  148. },
  149. jingliChange(e) {
  150. if (e.target.value == "a") {
  151. this.props.form.setFieldsValue({ 'jingli': this.state.jingli || '' })
  152. } else if (e.target.value == "b") {
  153. this.props.form.setFieldsValue({
  154. 'jingli': jingli_yuanxiao
  155. })
  156. } else if (e.target.value == "c") {
  157. this.props.form.setFieldsValue({
  158. 'jingli': jingli_shehui
  159. })
  160. }
  161. },
  162. chengjiuChange(e) {
  163. if (e.target.value == "a") {
  164. this.props.form.setFieldsValue({ 'chengjiu': this.state.chengjiu || '' })
  165. } else if (e.target.value == "b") {
  166. this.props.form.setFieldsValue({
  167. 'chengjiu': chengjiu_yuanxiao
  168. })
  169. } else if (e.target.value == "c") {
  170. this.props.form.setFieldsValue({
  171. 'chengjiu': chengjiu_shehui
  172. })
  173. }
  174. },
  175. downloadPic(type) {
  176. window.open(globalConfig.context + "/open/downLoadPicture?path=" + type)
  177. },
  178. render() {
  179. const { getFieldDecorator } = this.props.form;
  180. const formItemLayout = {
  181. labelCol: { span: 3 },
  182. wrapperCol: { span: 12 },
  183. };
  184. const _me = this;
  185. return (
  186. <Form horizontal onSubmit={this.handleSubmit} className="pfs-form">
  187. <FormItem className="half-item"
  188. {...formItemLayout}
  189. label="从事领域" >
  190. {getFieldDecorator('field', {
  191. initialValue: this.state.field
  192. })(
  193. <Cascader placeholder="请选择一个领域" options={techFieldList} />
  194. )}
  195. </FormItem>
  196. <FormItem
  197. labelCol={{ span: 3 }}
  198. wrapperCol={{ span: 4 }}
  199. label="从业工龄"
  200. >
  201. {getFieldDecorator('gongling', {
  202. initialValue: this.state.gongling || 0
  203. })(
  204. <InputNumber />
  205. )}
  206. <span>年</span>
  207. </FormItem>
  208. <FormItem
  209. {...formItemLayout}
  210. label="职称名字"
  211. >
  212. {getFieldDecorator('zhichengname', {
  213. initialValue: this.state.zhichengname || null
  214. })(
  215. <Input />
  216. )}
  217. </FormItem>
  218. <FormItem
  219. labelCol={{ span: 3 }}
  220. wrapperCol={{ span: 6 }}
  221. label="取得时间"
  222. hasFeedback
  223. >
  224. {getFieldDecorator('zhichengyear')(
  225. <YearSelect defValue={this.state.zhichengyear} handleyear={this.zhichengyear} />
  226. )}
  227. </FormItem>
  228. <FormItem
  229. {...formItemLayout}
  230. label="职称证书"
  231. hasFeedback
  232. >
  233. {getFieldDecorator('zhichengPic')(
  234. <Avatar name="zhichengPic" urlData={this.zhichengPic} picUrl={this.state.zhichengPicUrl} />
  235. )}
  236. </FormItem>
  237. <div className="set-explain">
  238. <p>要求2M 以下的jpg、jpeg格式的图片。该资料不会公开展示,仅作为审核材料使用。</p>
  239. <p>{this.state.zhichengPicUrl !== "" ? <Button onClick={this.downloadPic.bind(this, this.state.zhichengPicUrl)}>下载证书</Button> : ""}</p>
  240. </div>
  241. <FormItem
  242. {...formItemLayout}
  243. label="执业资格"
  244. >
  245. {getFieldDecorator('zigename', {
  246. initialValue: this.state.zigename
  247. })(
  248. <Input />
  249. )}
  250. </FormItem>
  251. <FormItem
  252. labelCol={{ span: 3 }}
  253. wrapperCol={{ span: 6 }}
  254. label="取得时间"
  255. hasFeedback
  256. >
  257. {getFieldDecorator('zigeyear')(
  258. <YearSelect defValue={this.state.zigeyear} handleyear={this.zigeyear} />
  259. )}
  260. </FormItem>
  261. <FormItem
  262. {...formItemLayout}
  263. label="资格证明"
  264. hasFeedback
  265. >
  266. {getFieldDecorator('zigePic')(
  267. <Avatar name="zigePic" urlData={this.zigePic} picUrl={this.state.zigePicUrl} />
  268. )}
  269. </FormItem>
  270. <div className="set-explain">
  271. <p>要求2M 以下的jpg、jpeg格式的图片。该资料不会公开展示,仅作为审核材料使用。</p>
  272. <p>{this.state.zigePicUrl !== "" ? <Button onClick={this.downloadPic.bind(this, this.state.zigePicUrl)}>下载证书</Button> : ""}</p>
  273. </div>
  274. <FormItem
  275. {...formItemLayout}
  276. label="工作单位"
  277. >
  278. {getFieldDecorator('danwei', {
  279. initialValue: this.state.danwei || null
  280. })(
  281. <Input />
  282. )}
  283. </FormItem>
  284. <FormItem
  285. {...formItemLayout}
  286. label="职位头衔"
  287. >
  288. {getFieldDecorator('touxian', {
  289. initialValue: this.state.touxian || null
  290. })(
  291. <Input />
  292. )}
  293. </FormItem>
  294. <div className="textarea-title">
  295. <span>从业经历</span>
  296. <RadioGroup className="set-radio-button" onChange={this.jingliChange} defaultValue="a">
  297. <RadioButton value="a">自定义</RadioButton>
  298. <RadioButton value="b">院校专家模板</RadioButton>
  299. <RadioButton value="c">企业或社会专家模板</RadioButton>
  300. </RadioGroup>
  301. </div>
  302. <div className="set-explain">
  303. <p>您可使用模板直接编辑调整!</p>
  304. </div>
  305. <FormItem
  306. labelCol={{ span: 3 }}
  307. wrapperCol={{ span: 20, offset: 3 }}
  308. help={
  309. <div>
  310. <p>还可输入{
  311. (() => {
  312. if (_me.props.form.getFieldValue('jingli') && _me.props.form.getFieldValue('jingli').length) {
  313. return 1000 - _me.props.form.getFieldValue('jingli').length;
  314. } else {
  315. return 1000;
  316. }
  317. })()
  318. }字/1000</p>
  319. <p>描述您主要的从业履历,包括职业,最有亮点的社会兼职。可自定义或选择模板后直接编辑</p>
  320. </div>
  321. }
  322. label=""
  323. >
  324. {getFieldDecorator('jingli', {
  325. initialValue: this.state.jingli || null
  326. })(
  327. <Input type="textarea"
  328. rows={6} />
  329. )}
  330. </FormItem>
  331. <div className="textarea-title">
  332. <span>个人成就</span>
  333. <RadioGroup className="set-radio-button" onChange={this.chengjiuChange} defaultValue="a">
  334. <RadioButton value="a">自定义</RadioButton>
  335. <RadioButton value="b">院校专家模板</RadioButton>
  336. <RadioButton value="c">企业或社会专家模板</RadioButton>
  337. </RadioGroup>
  338. </div>
  339. <div className="set-explain">
  340. <p>您可使用模板直接编辑调整!</p>
  341. </div>
  342. <FormItem
  343. labelCol={{ span: 3 }}
  344. wrapperCol={{ span: 20, offset: 3 }}
  345. help={
  346. <div>
  347. <p>还可输入{
  348. (() => {
  349. if (_me.props.form.getFieldValue('chengjiu') && _me.props.form.getFieldValue('chengjiu').length) {
  350. return 1000 - _me.props.form.getFieldValue('chengjiu').length;
  351. } else {
  352. return 1000;
  353. }
  354. })()
  355. }字/1000</p>
  356. <p>描述您主要的从业履历,包括职业,最有亮点的社会兼职。可自定义或选择模板后直接编辑</p>
  357. </div>
  358. }
  359. label=""
  360. >
  361. {getFieldDecorator('chengjiu', {
  362. initialValue: this.state.chengjiu || null
  363. })(
  364. <Input type="textarea"
  365. rows={6} />
  366. )}
  367. </FormItem>
  368. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  369. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  370. </FormItem>
  371. </Form >
  372. );
  373. },
  374. }));
  375. const Pfs = React.createClass({
  376. getInitialState() {
  377. return {
  378. loading: false
  379. };
  380. },
  381. spinChange(e) {
  382. this.setState({
  383. loading: e
  384. });
  385. },
  386. render() {
  387. return (
  388. <Spin spinning={this.state.loading} className='spin-box'>
  389. <div className="set-pfs">
  390. <div className="acc-detail">
  391. <p className="acc-title">职业信息</p>
  392. <PfsFrom spinState={this.spinChange} />
  393. </div>
  394. </div>
  395. </Spin>
  396. )
  397. }
  398. });
  399. export default Pfs;