pfs.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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. this.props.spinState(true);
  100. $.ajax({
  101. method: "POST",
  102. dataType: "json",
  103. crossDomain: false,
  104. url: globalConfig.context + "/api/user/userCareer",
  105. data: {
  106. "id": this.state.id,
  107. "engagedField": values.field ? values.field.join(',') : '',
  108. "workingAge": values.gongling,
  109. "professionalTitle": values.zhichengname,
  110. "professionalTitleGettime": this.state.zhichengyear,
  111. "professionalCertificateUrl": this.state.zhichengPicUrl,
  112. "qualification": values.zigename,
  113. "qualificationGettime": this.state.zigeyear,
  114. "qualificationCertificateUrl": this.state.zigePicUrl,
  115. "workUnit": values.danwei,
  116. "position": values.touxian,
  117. "experiences": values.jingli,
  118. "achievement": values.chengjiu
  119. }
  120. }).done(function (data) {
  121. if (!data.error.length) {
  122. message.success('保存成功!');
  123. this.getData();
  124. } else {
  125. message.warning(data.error[0].message);
  126. }
  127. }.bind(this)).always(function () {
  128. this.props.spinState(false);
  129. }.bind(this));
  130. }
  131. });
  132. },
  133. zhichengPic(e) {
  134. this.state.zhichengPicUrl = e;
  135. },
  136. zhichengyear(e) {
  137. this.state.zhichengyear = e;
  138. },
  139. zigePic(e) {
  140. this.state.zigePicUrl = e;
  141. },
  142. zigeyear(e) {
  143. this.state.zigeyear = e;
  144. },
  145. jingliChange(e) {
  146. if (e.target.value == "a") {
  147. this.props.form.setFieldsValue({ 'jingli': this.state.jingli || '' })
  148. } else if (e.target.value == "b") {
  149. this.props.form.setFieldsValue({
  150. 'jingli': jingli_yuanxiao
  151. })
  152. } else if (e.target.value == "c") {
  153. this.props.form.setFieldsValue({
  154. 'jingli': jingli_shehui
  155. })
  156. }
  157. },
  158. chengjiuChange(e) {
  159. if (e.target.value == "a") {
  160. this.props.form.setFieldsValue({ 'chengjiu': this.state.chengjiu || '' })
  161. } else if (e.target.value == "b") {
  162. this.props.form.setFieldsValue({
  163. 'chengjiu': chengjiu_yuanxiao
  164. })
  165. } else if (e.target.value == "c") {
  166. this.props.form.setFieldsValue({
  167. 'chengjiu': chengjiu_shehui
  168. })
  169. }
  170. },
  171. downloadPic(type) {
  172. window.open(globalConfig.context + "/open/downLoadPicture?path=" + type)
  173. },
  174. render() {
  175. const { getFieldDecorator } = this.props.form;
  176. const formItemLayout = {
  177. labelCol: { span: 3 },
  178. wrapperCol: { span: 12 },
  179. };
  180. const _me = this;
  181. return (
  182. <Form horizontal onSubmit={this.handleSubmit} className="pfs-form">
  183. <FormItem className="half-item"
  184. {...formItemLayout}
  185. label="从事领域" >
  186. {getFieldDecorator('field', {
  187. initialValue: this.state.field
  188. })(
  189. <Cascader placeholder="请选择一个领域" options={techFieldList} />
  190. )}
  191. </FormItem>
  192. <FormItem
  193. labelCol={{ span: 3 }}
  194. wrapperCol={{ span: 4 }}
  195. label="从业工龄"
  196. >
  197. {getFieldDecorator('gongling', {
  198. initialValue: this.state.gongling
  199. })(
  200. <InputNumber />
  201. )}
  202. <span>年</span>
  203. </FormItem>
  204. <FormItem
  205. {...formItemLayout}
  206. label="职称名字"
  207. >
  208. {getFieldDecorator('zhichengname', {
  209. initialValue: this.state.zhichengname || null
  210. })(
  211. <Input />
  212. )}
  213. </FormItem>
  214. <FormItem
  215. labelCol={{ span: 3 }}
  216. wrapperCol={{ span: 6 }}
  217. label="取得时间"
  218. hasFeedback
  219. >
  220. {getFieldDecorator('zhichengyear')(
  221. <YearSelect defValue={this.state.zhichengyear} handleyear={this.zhichengyear} />
  222. )}
  223. </FormItem>
  224. <FormItem
  225. {...formItemLayout}
  226. label="职称证书"
  227. hasFeedback
  228. >
  229. {getFieldDecorator('zhichengPic')(
  230. <Avatar name="zhichengPic" urlData={this.zhichengPic} picUrl={this.state.zhichengPicUrl} />
  231. )}
  232. </FormItem>
  233. <div className="set-explain">
  234. <p>要求2M 以下的jpg、jpeg格式的图片。该资料不会公开展示,仅作为审核材料使用。</p>
  235. <p>{this.state.zhichengPicUrl !== "" ? <Button onClick={this.downloadPic.bind(this, this.state.zhichengPicUrl)}>下载证书</Button> : ""}</p>
  236. </div>
  237. <FormItem
  238. {...formItemLayout}
  239. label="执业资格"
  240. >
  241. {getFieldDecorator('zigename', {
  242. initialValue: this.state.zigename
  243. })(
  244. <Input />
  245. )}
  246. </FormItem>
  247. <FormItem
  248. labelCol={{ span: 3 }}
  249. wrapperCol={{ span: 6 }}
  250. label="取得时间"
  251. hasFeedback
  252. >
  253. {getFieldDecorator('zigeyear')(
  254. <YearSelect defValue={this.state.zigeyear} handleyear={this.zigeyear} />
  255. )}
  256. </FormItem>
  257. <FormItem
  258. {...formItemLayout}
  259. label="资格证明"
  260. hasFeedback
  261. >
  262. {getFieldDecorator('zigePic')(
  263. <Avatar name="zigePic" urlData={this.zigePic} picUrl={this.state.zigePicUrl} />
  264. )}
  265. </FormItem>
  266. <div className="set-explain">
  267. <p>要求2M 以下的jpg、jpeg格式的图片。该资料不会公开展示,仅作为审核材料使用。</p>
  268. <p>{this.state.zigePicUrl !== "" ? <Button onClick={this.downloadPic.bind(this, this.state.zigePicUrl)}>下载证书</Button> : ""}</p>
  269. </div>
  270. <FormItem
  271. {...formItemLayout}
  272. label="工作单位"
  273. >
  274. {getFieldDecorator('danwei', {
  275. initialValue: this.state.danwei || null
  276. })(
  277. <Input />
  278. )}
  279. </FormItem>
  280. <FormItem
  281. {...formItemLayout}
  282. label="职位头衔"
  283. >
  284. {getFieldDecorator('touxian', {
  285. initialValue: this.state.touxian || null
  286. })(
  287. <Input />
  288. )}
  289. </FormItem>
  290. <div className="textarea-title">
  291. <span>从业经历</span>
  292. <RadioGroup className="set-radio-button" onChange={this.jingliChange} defaultValue="a">
  293. <RadioButton value="a">自定义</RadioButton>
  294. <RadioButton value="b">院校专家模板</RadioButton>
  295. <RadioButton value="c">企业或社会专家模板</RadioButton>
  296. </RadioGroup>
  297. </div>
  298. <div className="set-explain">
  299. <p>您可使用模板直接编辑调整!</p>
  300. </div>
  301. <FormItem
  302. labelCol={{ span: 3 }}
  303. wrapperCol={{ span: 20, offset: 3 }}
  304. help={
  305. <div>
  306. <p>还可输入{
  307. (() => {
  308. if (_me.props.form.getFieldValue('jingli') && _me.props.form.getFieldValue('jingli').length) {
  309. return 1000 - _me.props.form.getFieldValue('jingli').length;
  310. } else {
  311. return 1000;
  312. }
  313. })()
  314. }字/1000</p>
  315. <p>描述您主要的从业履历,包括职业,最有亮点的社会兼职。可自定义或选择模板后直接编辑</p>
  316. </div>
  317. }
  318. label=""
  319. >
  320. {getFieldDecorator('jingli', {
  321. initialValue: this.state.jingli || null
  322. })(
  323. <Input type="textarea"
  324. rows={6} />
  325. )}
  326. </FormItem>
  327. <div className="textarea-title">
  328. <span>个人成就</span>
  329. <RadioGroup className="set-radio-button" onChange={this.chengjiuChange} defaultValue="a">
  330. <RadioButton value="a">自定义</RadioButton>
  331. <RadioButton value="b">院校专家模板</RadioButton>
  332. <RadioButton value="c">企业或社会专家模板</RadioButton>
  333. </RadioGroup>
  334. </div>
  335. <div className="set-explain">
  336. <p>您可使用模板直接编辑调整!</p>
  337. </div>
  338. <FormItem
  339. labelCol={{ span: 3 }}
  340. wrapperCol={{ span: 20, offset: 3 }}
  341. help={
  342. <div>
  343. <p>还可输入{
  344. (() => {
  345. if (_me.props.form.getFieldValue('chengjiu') && _me.props.form.getFieldValue('chengjiu').length) {
  346. return 1000 - _me.props.form.getFieldValue('chengjiu').length;
  347. } else {
  348. return 1000;
  349. }
  350. })()
  351. }字/1000</p>
  352. <p>描述您主要的从业履历,包括职业,最有亮点的社会兼职。可自定义或选择模板后直接编辑</p>
  353. </div>
  354. }
  355. label=""
  356. >
  357. {getFieldDecorator('chengjiu', {
  358. initialValue: this.state.chengjiu || null
  359. })(
  360. <Input type="textarea"
  361. rows={6} />
  362. )}
  363. </FormItem>
  364. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  365. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  366. </FormItem>
  367. </Form >
  368. );
  369. },
  370. }));
  371. const Pfs = React.createClass({
  372. getInitialState() {
  373. return {
  374. loading: false
  375. };
  376. },
  377. spinChange(e) {
  378. this.setState({
  379. loading: e
  380. });
  381. },
  382. render() {
  383. return (
  384. <Spin spinning={this.state.loading} className='spin-box'>
  385. <div className="set-pfs">
  386. <div className="acc-detail">
  387. <p className="acc-title">职业信息</p>
  388. <PfsFrom spinState={this.spinChange} />
  389. </div>
  390. </div>
  391. </Spin>
  392. )
  393. }
  394. });
  395. export default Pfs;