technologyChange.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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.state.approvalUrl = undefined;
  156. this.state.subsidy = undefined;
  157. this.props.form.resetFields();
  158. };
  159. },
  160. subsidyCheck(e) {
  161. if (e.target.value == 1) {
  162. this.state.subsidy = 1;
  163. this.state.projectMode = 0;
  164. } else if (e.target.value == 2) {
  165. this.state.subsidy = 0;
  166. this.state.projectMode = 1;
  167. };
  168. this.setState({
  169. moneyType: e.target.value
  170. });
  171. },
  172. render() {
  173. const FormItem = Form.Item;
  174. const { getFieldDecorator } = this.props.form;
  175. const theData = this.state.data;
  176. const formItemLayout = {
  177. labelCol: { span: 6 },
  178. wrapperCol: { span: 12 },
  179. };
  180. const _me = this;
  181. if (this.state.data) {
  182. return (
  183. <Form onSubmit={this.handleSubmit} id="highTechApply-form">
  184. <div className="clearfix">
  185. <div className="half-item">
  186. <span className="item-title">公司名称: </span>
  187. <span>{theData.unitName}</span>
  188. </div>
  189. <div className="half-item">
  190. <span className="item-title">公司组织机构代码: </span>
  191. <span>{theData.orgCode}</span>
  192. </div>
  193. <div className="half-item">
  194. <span className="item-title">公司地址: </span>
  195. <span>{getProvince(theData.province, theData.city, theData.area)}</span>
  196. </div>
  197. <div className="half-item">
  198. <FormItem
  199. labelCol={{ span: 4 }}
  200. wrapperCol={{ span: 10 }}
  201. label="联系人:"
  202. >
  203. {getFieldDecorator('contacts', {
  204. initialValue: theData.contacts
  205. })(
  206. <Select>{this.props.contactsOption}</Select>
  207. )}
  208. </FormItem>
  209. </div>
  210. </div>
  211. <div className="clearfix">
  212. <FormItem className="third-item"
  213. {...formItemLayout}
  214. label="科技部门"
  215. >
  216. {getFieldDecorator('department', {
  217. initialValue: theData.department
  218. })(
  219. <Select placeholder="请选择申报部门"
  220. style={{ width: 300 }}
  221. notFoundContent="未获取到申报部门列表"
  222. showSearch
  223. filterOption={companySearch} >
  224. {this.props.departmentOption}
  225. </Select>
  226. )}
  227. </FormItem>
  228. </div>
  229. <div className="clearfix">
  230. <div className="half-item">
  231. <FormItem
  232. labelCol={{ span: 4 }}
  233. wrapperCol={{ span: 12 }}
  234. label="项目名称"
  235. >
  236. {getFieldDecorator('projectName', {
  237. initialValue: theData.projectName
  238. })(
  239. <Input />
  240. )}
  241. </FormItem>
  242. </div>
  243. </div>
  244. <div className="clearfix">
  245. <div className="half-item">
  246. <FormItem
  247. labelCol={{ span: 4 }}
  248. wrapperCol={{ span: 12 }}
  249. label="项目类型"
  250. >
  251. {getFieldDecorator('projectCatagory', {
  252. initialValue: theData.projectCatagory
  253. })(
  254. <Input />
  255. )}
  256. </FormItem>
  257. </div>
  258. </div>
  259. <div className="clearfix">
  260. <div className="half-item">
  261. <FormItem
  262. labelCol={{ span: 4 }}
  263. wrapperCol={{ span: 12 }}
  264. label="技术领域"
  265. >
  266. {getFieldDecorator('techField', {
  267. initialValue: theData.techField
  268. })(
  269. <Input />
  270. )}
  271. </FormItem>
  272. </div>
  273. </div>
  274. <div className="clearfix">
  275. <span className="item-title">项目简介: </span>
  276. {getFieldDecorator('projectDes', {
  277. initialValue: theData.projectDes
  278. })(
  279. <Input type="textarea"
  280. placeholder="多行输入"
  281. rows={6} />
  282. )}
  283. </div>
  284. <div className="clearfix">
  285. <div className="half-item">
  286. <span className="item-title">立项/后补助: </span>
  287. <Radio.Group value={this.state.moneyType} onChange={this.subsidyCheck}>
  288. <Radio value={1}>立项</Radio>
  289. <Radio value={2}>后补助</Radio>
  290. </Radio.Group>
  291. </div>
  292. <div className="half-item">
  293. <FormItem
  294. {...formItemLayout}
  295. label='金额'
  296. >
  297. {getFieldDecorator('projectApproval', {
  298. initialValue: theData.projectApproval
  299. })(
  300. <Input style={{ width: 200 }} />
  301. )}
  302. <span>万元</span>
  303. </FormItem>
  304. </div>
  305. </div>
  306. <div className="hrSituation-roster">
  307. <Upload
  308. name="avatar"
  309. action={globalConfig.context + "/api/user/techproject/upload"}
  310. data={{ 'id': this.props.data.pid, 'sign': 'tech_project' }}
  311. beforeUpload={beforeUploadFile}
  312. fileList={this.state.fileList}
  313. onChange={(info) => {
  314. if (info.file.status !== 'uploading') {
  315. console.log(info.file, info.fileList);
  316. }
  317. if (info.file.status === 'done') {
  318. if (!info.file.response.error.length) {
  319. message.success(`${info.file.name} 文件上传成功!`);
  320. } else {
  321. message.warning(info.file.response.error[0].message);
  322. return;
  323. };
  324. this.state.approvalUrl = info.file.response.data;
  325. } else if (info.file.status === 'error') {
  326. message.error(`${info.file.name} 文件上传失败。`);
  327. };
  328. this.setState({ fileList: info.fileList.slice(-1) });
  329. }}
  330. >
  331. <Button><Icon type="upload" /> 项目材料上传 </Button>
  332. </Upload>
  333. <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>
  334. </div>
  335. <div className="form-title">状态流转记录: </div>
  336. <Table pagination={false} dataSource={this.state.stateTable} columns={this.state.stateColumns} />
  337. <FormItem style={{ marginTop: '20px' }}>
  338. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  339. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  340. </FormItem>
  341. </Form >
  342. );
  343. } else {
  344. return (<div></div>)
  345. };
  346. },
  347. }));
  348. const ApplyChange = React.createClass({
  349. getInitialState() {
  350. return {
  351. visible: false,
  352. loading: false
  353. };
  354. },
  355. componentWillReceiveProps(nextProps) {
  356. this.state.visible = nextProps.showDesc
  357. },
  358. showModal() {
  359. this.setState({
  360. visible: true,
  361. });
  362. },
  363. handleOk() {
  364. this.setState({
  365. visible: false,
  366. });
  367. this.props.closeDesc(false);
  368. },
  369. handleCancel(e) {
  370. this.setState({
  371. visible: false,
  372. });
  373. this.props.closeDesc(false);
  374. },
  375. spinChange(e) {
  376. this.setState({
  377. loading: e
  378. });
  379. },
  380. render() {
  381. return (
  382. <div className="patent-addNew">
  383. <Modal maskClosable={false} title="编辑科技项目" visible={this.state.visible}
  384. onOk={this.handleOk} onCancel={this.handleCancel}
  385. width='1000px'
  386. footer='' >
  387. <Spin spinning={this.state.loading} className='spin-box'>
  388. <ApplyChangeFrom
  389. visible={this.state.visible}
  390. data={this.props.data}
  391. contactsOption={this.props.contactsOption}
  392. departmentOption={this.props.departmentOption}
  393. spinState={this.spinChange}
  394. closeModal={this.handleCancel} />
  395. </Spin>
  396. </Modal>
  397. </div>
  398. );
  399. }
  400. });
  401. export default ApplyChange;