technologyChange.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Select, Spin, Table, message, Modal, Radio, Upload } from 'antd';
  3. import { cognizanceStateList } from '../../dataDic.js';
  4. import { getProvince } from '../../NewDicProvinceList';
  5. import { getTechnologyState, beforeUploadFile, downloadFile, companySearch } from '../../tools.js';
  6. import ajax from 'jquery/src/ajax/xhr.js';
  7. import $ from 'jquery/src/ajax';
  8. const ApplyChangeFrom = Form.create()(React.createClass({
  9. loadData(id) {
  10. this.setState({
  11. loading: true
  12. });
  13. $.ajax({
  14. method: "post",
  15. dataType: "json",
  16. crossDomain: false,
  17. url: globalConfig.context + "/api/user/techproject/techProjectDetial",
  18. data: {
  19. pid: id || this.props.data.pid
  20. },
  21. success: function (data) {
  22. if (data.error.length || !data.data) {
  23. message.warning(data.error[0].message);
  24. return;
  25. };
  26. this.state.data = data.data;
  27. this.state.moneyType = undefined;
  28. if (data.data.projectMode == 1) {
  29. this.state.projectMode = data.data.projectMode;
  30. this.setState({ moneyType: 2 });
  31. };
  32. if (data.data.subsidy == 1) {
  33. this.state.subsidy = data.data.subsidy;
  34. this.setState({ moneyType: 1 });
  35. };
  36. }.bind(this),
  37. }).always(function () {
  38. this.setState({
  39. loading: false
  40. });
  41. }.bind(this));
  42. },
  43. getStateData(id) {
  44. this.setState({
  45. loading: true
  46. });
  47. $.ajax({
  48. method: "post",
  49. dataType: "json",
  50. crossDomain: false,
  51. url: globalConfig.context + "/api/user/techproject/techProjectLog",
  52. data: {
  53. pid: id || this.props.data.pid
  54. },
  55. success: function (data) {
  56. if (data.error.length || !data.data) {
  57. message.warning(data.error[0].message);
  58. return;
  59. };
  60. this.state.stateTable = [];
  61. for (let i = 0; i < data.data.length; i++) {
  62. this.state.stateTable.push({
  63. key: i,
  64. state: data.data[i].state,
  65. recordTime: data.data[i].recordTimeFormattedDate,
  66. principal: data.data[i].principal,
  67. comment: data.data[i].comment
  68. });
  69. };
  70. }.bind(this),
  71. }).always(function () {
  72. this.setState({
  73. loading: false
  74. });
  75. }.bind(this));
  76. },
  77. getInitialState() {
  78. return {
  79. loading: false,
  80. departmentOption: [],
  81. projectDes: '',
  82. projectMode: 0,
  83. subsidy: 0,
  84. projectModeState: false,
  85. subsidyState: false,
  86. stateColumns: [{
  87. title: '科技项目状态',
  88. dataIndex: 'state',
  89. key: 'state',
  90. render: (text) => { return getTechnologyState(text) }
  91. }, {
  92. title: '处理时间',
  93. dataIndex: 'recordTime',
  94. key: 'recordTime'
  95. }, {
  96. title: '负责人',
  97. dataIndex: 'principal',
  98. key: 'principal',
  99. }, {
  100. title: '备注',
  101. dataIndex: 'comment',
  102. key: 'comment',
  103. }],
  104. stateTable: []
  105. };
  106. },
  107. componentWillMount() {
  108. this.loadData();
  109. this.getStateData();
  110. },
  111. handleSubmit(e) {
  112. e.preventDefault();
  113. this.props.form.validateFields((err, values) => {
  114. if (!err) {
  115. this.props.spinState(true);
  116. let contacts = !isNaN(values.contacts) ? values.contacts : this.state.data.contacts;
  117. $.ajax({
  118. method: "POST",
  119. dataType: "json",
  120. crossDomain: false,
  121. url: globalConfig.context + "/api/user/techproject/updateTechProject",
  122. data: {
  123. id: this.props.data.pid,
  124. contacts: contacts,
  125. department: values.department,
  126. projectName: values.projectName,
  127. projectCatagory: values.projectCatagory,
  128. techField: values.techField,
  129. projectDes: values.projectDes,
  130. projectMode: this.state.projectMode,
  131. projectApproval: values.projectApproval,
  132. subsidy: this.state.subsidy,
  133. approvalUrl: this.state.approvalUrl,
  134. }
  135. }).done(function (data) {
  136. if (!data.error.length) {
  137. message.success('保存成功!');
  138. this.props.closeModal();
  139. this.props.form.resetFields();
  140. this.props.spinState(false);
  141. } else {
  142. message.warning(data.error[0].message);
  143. this.props.spinState(false);
  144. }
  145. }.bind(this));
  146. }
  147. });
  148. },
  149. componentWillReceiveProps(nextProps) {
  150. if (!this.props.visible && nextProps.visible) {
  151. this.loadData(nextProps.data.pid);
  152. this.getStateData(nextProps.data.pid);
  153. this.state.fileList = [];
  154. this.state.approvalUrl = undefined;
  155. this.state.subsidy = undefined;
  156. this.props.form.resetFields();
  157. };
  158. },
  159. subsidyCheck(e) {
  160. if (e.target.value == 1) {
  161. this.state.subsidy = 1;
  162. this.state.projectMode = 0;
  163. } else if (e.target.value == 2) {
  164. this.state.subsidy = 0;
  165. this.state.projectMode = 1;
  166. };
  167. this.setState({
  168. moneyType: e.target.value
  169. });
  170. },
  171. render() {
  172. const FormItem = Form.Item;
  173. const { getFieldDecorator } = this.props.form;
  174. const theData = this.state.data;
  175. const formItemLayout = {
  176. labelCol: { span: 6 },
  177. wrapperCol: { span: 12 },
  178. };
  179. const _me = this;
  180. if (this.state.data) {
  181. return (
  182. <Form onSubmit={this.handleSubmit} id="highTechApply-form">
  183. <div className="clearfix">
  184. <div className="half-item">
  185. <span className="item-title">公司名称: </span>
  186. <span>{theData.unitName}</span>
  187. </div>
  188. <div className="half-item">
  189. <span className="item-title">公司组织机构代码: </span>
  190. <span>{theData.orgCode}</span>
  191. </div>
  192. <div className="half-item">
  193. <span className="item-title">公司地址: </span>
  194. <span>{getProvince(theData.province, theData.city, theData.area)}</span>
  195. </div>
  196. <div className="half-item">
  197. <FormItem
  198. labelCol={{ span: 4 }}
  199. wrapperCol={{ span: 10 }}
  200. label="联系人:"
  201. >
  202. {getFieldDecorator('contacts', {
  203. initialValue: theData.contacts
  204. })(
  205. <Select>{this.props.contactsOption}</Select>
  206. )}
  207. </FormItem>
  208. </div>
  209. </div>
  210. <div className="clearfix">
  211. <FormItem className="third-item"
  212. {...formItemLayout}
  213. label="科技部门"
  214. >
  215. {getFieldDecorator('department', {
  216. initialValue: theData.department
  217. })(
  218. <Select placeholder="请选择申报部门"
  219. style={{ width: 300 }}
  220. notFoundContent="未获取到申报部门列表"
  221. showSearch
  222. filterOption={companySearch} >
  223. {this.props.departmentOption}
  224. </Select>
  225. )}
  226. </FormItem>
  227. </div>
  228. <div className="clearfix">
  229. <div className="half-item">
  230. <FormItem
  231. labelCol={{ span: 4 }}
  232. wrapperCol={{ span: 12 }}
  233. label="项目名称"
  234. >
  235. {getFieldDecorator('projectName', {
  236. initialValue: theData.projectName
  237. })(
  238. <Input />
  239. )}
  240. </FormItem>
  241. </div>
  242. </div>
  243. <div className="clearfix">
  244. <div className="half-item">
  245. <FormItem
  246. labelCol={{ span: 4 }}
  247. wrapperCol={{ span: 12 }}
  248. label="项目类型"
  249. >
  250. {getFieldDecorator('projectCatagory', {
  251. initialValue: theData.projectCatagory
  252. })(
  253. <Input />
  254. )}
  255. </FormItem>
  256. </div>
  257. </div>
  258. <div className="clearfix">
  259. <div className="half-item">
  260. <FormItem
  261. labelCol={{ span: 4 }}
  262. wrapperCol={{ span: 12 }}
  263. label="技术领域"
  264. >
  265. {getFieldDecorator('techField', {
  266. initialValue: theData.techField
  267. })(
  268. <Input />
  269. )}
  270. </FormItem>
  271. </div>
  272. </div>
  273. <div className="clearfix">
  274. <span className="item-title">项目简介: </span>
  275. {getFieldDecorator('projectDes', {
  276. initialValue: theData.projectDes
  277. })(
  278. <Input type="textarea"
  279. placeholder="多行输入"
  280. rows={6} />
  281. )}
  282. </div>
  283. <div className="clearfix">
  284. <div className="half-item">
  285. <span className="item-title">立项/后补助: </span>
  286. <Radio.Group value={this.state.moneyType} onChange={this.subsidyCheck}>
  287. <Radio value={1}>立项</Radio>
  288. <Radio value={2}>后补助</Radio>
  289. </Radio.Group>
  290. </div>
  291. <div className="half-item">
  292. <FormItem
  293. {...formItemLayout}
  294. label='金额'
  295. >
  296. {getFieldDecorator('projectApproval', {
  297. initialValue: theData.projectApproval
  298. })(
  299. <Input style={{ width: 200 }} />
  300. )}
  301. <span>万元</span>
  302. </FormItem>
  303. </div>
  304. </div>
  305. <div className="hrSituation-roster">
  306. <Upload
  307. name="avatar"
  308. action={globalConfig.context + "/api/user/techproject/upload"}
  309. data={{ 'id': this.props.data.pid, 'sign': 'tech_project' }}
  310. beforeUpload={beforeUploadFile}
  311. fileList={this.state.fileList}
  312. onChange={(info) => {
  313. if (info.file.status !== 'uploading') {
  314. // console.log(info.file, info.fileList);
  315. }
  316. if (info.file.status === 'done') {
  317. if (!info.file.response.error.length) {
  318. message.success(`${info.file.name} 文件上传成功!`);
  319. } else {
  320. message.warning(info.file.response.error[0].message);
  321. return;
  322. };
  323. this.state.approvalUrl = info.file.response.data;
  324. } else if (info.file.status === 'error') {
  325. message.error(`${info.file.name} 文件上传失败。`);
  326. };
  327. this.setState({ fileList: info.fileList.slice(-1) });
  328. }}
  329. >
  330. <Button><Icon type="upload" /> 项目材料上传 </Button>
  331. </Upload>
  332. <p style={{ marginTop: '10px' }}>{theData.approvalUrl ? <a onClick={downloadFile.bind(null, theData.approvalUrl, theData.approvalDownloadFileName)}>{theData.approvalDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  333. </div>
  334. <div className="form-title">状态流转记录: </div>
  335. <Table pagination={false} dataSource={this.state.stateTable} columns={this.state.stateColumns} />
  336. <FormItem style={{ marginTop: '20px' }}>
  337. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  338. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  339. </FormItem>
  340. </Form >
  341. );
  342. } else {
  343. return (<div></div>)
  344. };
  345. },
  346. }));
  347. const ApplyChange = React.createClass({
  348. getInitialState() {
  349. return {
  350. visible: false,
  351. loading: false
  352. };
  353. },
  354. componentWillReceiveProps(nextProps) {
  355. this.state.visible = nextProps.showDesc
  356. },
  357. showModal() {
  358. this.setState({
  359. visible: true,
  360. });
  361. },
  362. handleOk() {
  363. this.setState({
  364. visible: false,
  365. });
  366. this.props.closeDesc(false);
  367. },
  368. handleCancel(e) {
  369. this.setState({
  370. visible: false,
  371. });
  372. this.props.closeDesc(false);
  373. },
  374. spinChange(e) {
  375. this.setState({
  376. loading: e
  377. });
  378. },
  379. render() {
  380. return (
  381. <div className="patent-addNew">
  382. <Modal maskClosable={false} title="编辑科技项目" visible={this.state.visible}
  383. onOk={this.handleOk} onCancel={this.handleCancel}
  384. width='1200px'
  385. footer='' >
  386. <Spin spinning={this.state.loading} className='spin-box'>
  387. <ApplyChangeFrom
  388. visible={this.state.visible}
  389. data={this.props.data}
  390. contactsOption={this.props.contactsOption}
  391. departmentOption={this.props.departmentOption}
  392. spinState={this.spinChange}
  393. closeModal={this.handleCancel} />
  394. </Spin>
  395. </Modal>
  396. </div>
  397. );
  398. }
  399. });
  400. export default ApplyChange;