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