pfs.jsx 16 KB

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