pfs.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. import React from 'react';
  2. import { Input, Button, Form, Select, Upload, Icon, Spin, message, Radio, InputNumber } 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. const FormItem = Form.Item;
  10. const RadioButton = Radio.Button;
  11. const RadioGroup = Radio.Group;
  12. class Avatar extends React.Component {
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. imageUrl: '',
  17. propsbool: true,
  18. }
  19. }
  20. handleChange(info) {
  21. if (info.file.status === 'done') {
  22. // Get this url from response in real world.
  23. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
  24. this.props.urlData(info.file.response.data);
  25. }
  26. }
  27. componentWillReceiveProps(nextProps) {
  28. if (nextProps.picUrl && this.state.propsbool) {
  29. this.state.imageUrl = globalConfig.avatarHost + "/upload" + nextProps.picUrl;
  30. this.state.propsbool = false;
  31. }
  32. }
  33. render() {
  34. const imageUrl = this.state.imageUrl;
  35. return (
  36. <Upload
  37. className="avatar-uploader"
  38. name="avatar"
  39. showUploadList={false}
  40. action={globalConfig.context + "/api/user/avatar/uploadReplace"}
  41. data={{ 'sign': this.props.name }}
  42. beforeUpload={beforeUpload}
  43. onChange={this.handleChange.bind(this)}
  44. >
  45. {
  46. imageUrl ?
  47. <img src={imageUrl} role="presentation" className="avatar" /> :
  48. <Icon type="plus" className="avatar-uploader-trigger" />
  49. }
  50. </Upload>
  51. );
  52. }
  53. };
  54. const PfsFrom = Form.create()(React.createClass({
  55. getData() {
  56. this.props.spinState(true);
  57. $.ajax({
  58. method: "get",
  59. dataType: "json",
  60. url: globalConfig.context + "/api/user/job",
  61. success: function (data) {
  62. if (data.data) {
  63. this.setState({
  64. id: data.data.id,
  65. lingyu: data.data.engagedField,
  66. gongling: data.data.workingAge,
  67. zhichengname: data.data.professionalTitle,
  68. zhichengyear: data.data.professionalTitleGettime,
  69. zhichengPicUrl: data.data.professionalCertificateUrl,
  70. zigename: data.data.qualification,
  71. zigeyear: data.data.qualificationGettime,
  72. zigePicUrl: data.data.qualificationCertificateUrl,
  73. danwei: data.data.workUnit,
  74. touxian: data.data.position,
  75. jingli: data.data.experiences,
  76. chengjiu: data.data.achievement
  77. });
  78. };
  79. }.bind(this),
  80. }).always(function () {
  81. this.props.spinState(false);
  82. }.bind(this));
  83. },
  84. getInitialState() {
  85. return {
  86. loading: false,
  87. zigePicUrl: '',
  88. zhichengPicUrl: ''
  89. };
  90. },
  91. componentWillMount() {
  92. this.getData();
  93. },
  94. handleSubmit(e) {
  95. e.preventDefault();
  96. this.props.form.validateFields((err, values) => {
  97. if (!err) {
  98. this.props.spinState(true);
  99. $.ajax({
  100. method: "POST",
  101. dataType: "json",
  102. crossDomain: false,
  103. url: globalConfig.context + "/api/user/userCareer",
  104. data: {
  105. "id": this.state.id,
  106. "engagedField": values.lingyu,
  107. "workingAge": values.gongling,
  108. "professionalTitle": values.zhichengname,
  109. "professionalTitleGettime": this.state.zhichengyear,
  110. "professionalCertificateUrl": this.state.zhichengPicUrl,
  111. "qualification": values.zigename,
  112. "qualificationGettime": this.state.zigeyear,
  113. "qualificationCertificateUrl": this.state.zigePicUrl,
  114. "workUnit": values.danwei,
  115. "position": values.touxian,
  116. "experiences": values.jingli,
  117. "achievement": values.chengjiu
  118. }
  119. }).done(function (data) {
  120. if (!data.error.length) {
  121. message.success('保存成功!');
  122. } else {
  123. message.warning(data.error[0].message);
  124. }
  125. }.bind(this)).always(function () {
  126. this.props.spinState(false);
  127. }.bind(this));
  128. }
  129. });
  130. },
  131. zhichengPic(e) {
  132. this.state.zhichengPicUrl = e;
  133. },
  134. zhichengyear(e) {
  135. this.state.zhichengyear = e;
  136. },
  137. zigePic(e) {
  138. this.state.zigePicUrl = e;
  139. },
  140. zigeyear(e) {
  141. this.state.zigeyear = e;
  142. },
  143. jingliChange(e) {
  144. if (e.target.value == "a") {
  145. this.props.form.setFieldsValue({ 'jingli': this.state.jingli || '' })
  146. } else if (e.target.value == "b") {
  147. this.props.form.setFieldsValue({
  148. 'jingli': jingli_yuanxiao
  149. })
  150. } else if (e.target.value == "c") {
  151. this.props.form.setFieldsValue({
  152. 'jingli': jingli_shehui
  153. })
  154. }
  155. },
  156. chengjiuChange(e) {
  157. if (e.target.value == "a") {
  158. this.props.form.setFieldsValue({ 'chengjiu': this.state.chengjiu || '' })
  159. } else if (e.target.value == "b") {
  160. this.props.form.setFieldsValue({
  161. 'chengjiu': chengjiu_yuanxiao
  162. })
  163. } else if (e.target.value == "c") {
  164. this.props.form.setFieldsValue({
  165. 'chengjiu': chengjiu_shehui
  166. })
  167. }
  168. },
  169. downloadPic(type) {
  170. window.open(globalConfig.context + "/open/downLoadPicture?path=" + type)
  171. },
  172. render() {
  173. const { getFieldDecorator } = this.props.form;
  174. const formItemLayout = {
  175. labelCol: { span: 3 },
  176. wrapperCol: { span: 12 },
  177. };
  178. const _me = this;
  179. return (
  180. <Form horizontal onSubmit={this.handleSubmit} className="pfs-form">
  181. <FormItem
  182. {...formItemLayout}
  183. label="从事领域"
  184. help={'请输入所从事领域的名称,多个领域请以逗号隔开'}
  185. >
  186. {getFieldDecorator('lingyu', {
  187. initialValue: this.state.lingyu || null
  188. })(
  189. <Input />
  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;