applyChange.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Select, Spin, Table, DatePicker, message, Modal, Checkbox, Upload } from 'antd';
  3. import { cognizanceStateList } from '../../../dataDic.js';
  4. import { getCognizanceState, beforeUpload, getBase64 } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. class Avatar extends React.Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. imageUrl: ''
  12. }
  13. }
  14. handleChange(info) {
  15. if (!this.props.oid || this.props.oid === "") {
  16. message.warning('请先选择公司!');
  17. return;
  18. };
  19. if (info.file.status === 'done') {
  20. // Get this url from response in real world.
  21. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
  22. this.props.urlData(info.file.response.data);
  23. }
  24. }
  25. render() {
  26. const imageUrl = this.state.imageUrl;
  27. return (
  28. <Upload
  29. className="avatar-uploader"
  30. name="avatar"
  31. showUploadList={false}
  32. action={globalConfig.context + "/techservice/patent/patentFile"}
  33. data={{ 'sign': this.props.name, 'oid': this.props.oid }}
  34. beforeUpload={beforeUpload}
  35. onChange={this.handleChange.bind(this)}
  36. >
  37. {
  38. imageUrl ?
  39. <img src={imageUrl} role="presentation" className="avatar" /> :
  40. <Icon type="plus" className="avatar-uploader-trigger" />
  41. }
  42. </Upload>
  43. );
  44. }
  45. };
  46. const ApplyChangeFrom = Form.create()(React.createClass({
  47. loadData() {
  48. this.setState({
  49. loading: true
  50. });
  51. $.ajax({
  52. method: "post",
  53. dataType: "json",
  54. crossDomain: false,
  55. url: globalConfig.context + "/api/admin/cognizanceDetail",
  56. data: {
  57. cid: this.props.data.cid,
  58. uid: this.props.data.uid,
  59. year: this.props.data.year
  60. },
  61. success: function (data) {
  62. if (data.error.length || !data.data) {
  63. message.warning(data.error[0].message);
  64. return;
  65. };
  66. this.state.data = data.data;
  67. this.state.cid = this.props.data.cid;
  68. this.state.moneyTable = [{
  69. key: 1,
  70. year: '第一年',
  71. netAsset: data.data.netAsset1,
  72. salesRevenue: data.data.salesRevenue1,
  73. grossProfit: data.data.grossProfit1
  74. }, {
  75. key: 2,
  76. year: '第二年',
  77. netAsset: data.data.netAsset2,
  78. salesRevenue: data.data.salesRevenue2,
  79. grossProfit: data.data.grossProfit2
  80. }, {
  81. key: 3,
  82. year: '第三年',
  83. netAsset: data.data.netAsset3,
  84. salesRevenue: data.data.salesRevenue3,
  85. grossProfit: data.data.grossProfit3
  86. }];
  87. }.bind(this),
  88. }).always(function () {
  89. this.setState({
  90. loading: false
  91. });
  92. }.bind(this));
  93. },
  94. getStateData() {
  95. this.setState({
  96. loading: true
  97. });
  98. $.ajax({
  99. method: "post",
  100. dataType: "json",
  101. crossDomain: false,
  102. url: globalConfig.context + "/api/admin/cognizanceLog",
  103. data: {
  104. cid: this.props.data.cid
  105. },
  106. success: function (data) {
  107. if (data.error.length || !data.data) {
  108. message.warning(data.error[0].message);
  109. return;
  110. };
  111. this.state.stateTable = [];
  112. for (let i = 0; i < data.data.length; i++) {
  113. this.state.stateTable.push({
  114. key: i,
  115. recordTimeFormattedDate: data.data[i].recordTimeFormattedDate,
  116. state: data.data[i].state,
  117. principal: data.data[i].principal,
  118. comment: data.data[i].comment
  119. });
  120. };
  121. }.bind(this),
  122. }).always(function () {
  123. this.setState({
  124. loading: false
  125. });
  126. }.bind(this));
  127. },
  128. getInitialState() {
  129. return {
  130. loading: false,
  131. stateOption: [],
  132. introduce:'',
  133. projectCheck: 0,
  134. subsidy: 0,
  135. stateColumns: [{
  136. title: '专利状态',
  137. dataIndex: 'state',
  138. key: 'state',
  139. render: (text) => { return getCognizanceState(text) }
  140. }, {
  141. title: '处理时间',
  142. dataIndex: 'recordTimeFormattedDate',
  143. key: 'recordTimeFormattedDate',
  144. }, {
  145. title: '负责人',
  146. dataIndex: 'principal',
  147. key: 'principal',
  148. }, {
  149. title: '备注',
  150. dataIndex: 'comment',
  151. key: 'comment',
  152. }],
  153. stateTable: []
  154. };
  155. },
  156. componentWillMount() {
  157. let _me = this;
  158. cognizanceStateList.map(function (item) {
  159. _me.state.stateOption.push(
  160. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  161. )
  162. });
  163. this.loadData();
  164. this.getStateData();
  165. },
  166. handleSubmit(e) {
  167. e.preventDefault();
  168. this.props.form.validateFields((err, values) => {
  169. if (values.state || values.principal || values.recordTime || values.comment) {
  170. if (!values.state && !values.principal && !values.recordTime) {
  171. message.warning("请填写完整的状态流转信息!");
  172. return;
  173. };
  174. };
  175. if (!err) {
  176. this.props.spinState(true);
  177. $.ajax({
  178. method: "POST",
  179. dataType: "json",
  180. crossDomain: false,
  181. url: globalConfig.context + "/api/admin/disposeCognizanceDetail",
  182. data: {
  183. id: this.props.data.cid,
  184. technicalField: values.technicalField,
  185. basicResearchCost: values.basicResearchCost,
  186. accident: values.accident,
  187. recordTimeFormattedDate: values.recordTime ? values.recordTime.format("YYYY-MM-DD") : undefined,
  188. state: values.state,
  189. principal: values.principal,
  190. comment: values.comment,
  191. }
  192. }).done(function (data) {
  193. if (!data.error.length) {
  194. message.success('保存成功!');
  195. this.props.closeModal();
  196. this.props.form.resetFields();
  197. this.state.targetKeys = [];
  198. this.state.selectedKeys = [];
  199. this.props.spinState(false);
  200. } else {
  201. message.warning(data.error[0].message);
  202. this.props.spinState(false);
  203. }
  204. }.bind(this));
  205. }
  206. });
  207. },
  208. componentWillReceiveProps(nextProps) {
  209. if (!this.props.visible && nextProps.visible) {
  210. this.getStateData();
  211. this.loadData();
  212. };
  213. if (nextProps.data) {
  214. this.state.xid = nextProps.data.pid;
  215. }
  216. },
  217. projectEstablishmentCheck(e) {
  218. if (e.target.checked == true) {
  219. this.state.projectCheck = 1;
  220. } else if (e.target.checked == false) {
  221. this.state.projectCheck = 0;
  222. };
  223. },
  224. subsidyCheck(e) {
  225. if (e.target.checked == true) {
  226. this.state.subsidy = 1;
  227. } else if (e.target.checked == false) {
  228. this.state.subsidy = 0;
  229. };
  230. },
  231. avatarUrl(e) {
  232. this.state.avatarUrl = e;
  233. },
  234. render() {
  235. const FormItem = Form.Item;
  236. const { getFieldDecorator } = this.props.form;
  237. const theData = this.state.data;
  238. const formItemLayout = {
  239. labelCol: { span: 6 },
  240. wrapperCol: { span: 12 },
  241. };
  242. const _me = this;
  243. if (this.state.data) {
  244. return (
  245. <Form onSubmit={this.handleSubmit} id="highTechApply-form">
  246. <div className="clearfix">
  247. <div className="half-item">
  248. <span className="item-title">公司名称: </span>
  249. <span>{theData.unitName}</span>
  250. </div>
  251. <div className="half-item">
  252. <span className="item-title">公司组织机构代码: </span>
  253. <span>{theData.orgCode}</span>
  254. </div>
  255. <div className="half-item">
  256. <span className="item-title">公司地址: </span>
  257. <span>{theData.postalAddress}</span>
  258. </div>
  259. <div className="half-item">
  260. <span className="item-title">联系人: </span>
  261. <span>{theData.contacts}</span>
  262. </div>
  263. </div>
  264. <div className="clearfix">
  265. <FormItem className="third-item"
  266. {...formItemLayout}
  267. label="科技部门"
  268. >
  269. {getFieldDecorator('technicalDepartment')(
  270. <Select placeholder="选择科技部门">{this.props.authorOption}</Select>
  271. )}
  272. </FormItem>
  273. </div>
  274. <div className="clearfix">
  275. <div className="half-item">
  276. <span className="item-title">派单信息: </span>
  277. <span>{theData.firmTotal}</span>
  278. </div>
  279. </div>
  280. <div className="clearfix">
  281. <div className="half-item">
  282. <FormItem
  283. labelCol={{ span: 4 }}
  284. wrapperCol={{ span: 12 }}
  285. label="项目名称"
  286. >
  287. {getFieldDecorator('projectName')(
  288. <Input />
  289. )}
  290. </FormItem>
  291. </div>
  292. </div>
  293. <div className="clearfix">
  294. <div className="half-item">
  295. <FormItem
  296. labelCol={{ span: 4 }}
  297. wrapperCol={{ span: 12 }}
  298. label="项目类型"
  299. >
  300. {getFieldDecorator('projectType')(
  301. <Input />
  302. )}
  303. </FormItem>
  304. </div>
  305. </div>
  306. <div className="clearfix">
  307. <div className="half-item">
  308. <FormItem
  309. labelCol={{ span: 4 }}
  310. wrapperCol={{ span: 12 }}
  311. label="技术领域"
  312. >
  313. {getFieldDecorator('technicalField')(
  314. <Input />
  315. )}
  316. </FormItem>
  317. </div>
  318. </div>
  319. <div className="clearfix">
  320. <span className="item-title">项目简介: </span>
  321. <Input type="textarea"
  322. placeholder="多行输入"
  323. value={this.state.introduce}
  324. onChange={(e) => { this.setState({ introduce: e.target.value }); } }
  325. rows={6} />
  326. </div>
  327. <div className="clearfix">
  328. <div className="half-item">
  329. <span className="item-title">是否立项: </span>
  330. <Checkbox onChange={this.projectEstablishmentCheck}></Checkbox>
  331. </div>
  332. <div className="half-item">
  333. <FormItem
  334. {...formItemLayout}
  335. label="立项金额"
  336. >
  337. {getFieldDecorator('projectAmounts')(
  338. <Input className="mini-input" />
  339. )}
  340. </FormItem>
  341. </div>
  342. </div>
  343. <div className="clearfix">
  344. <div className="half-item">
  345. <span className="item-title">是否后补助: </span>
  346. <Checkbox onChange={this.subsidyCheck}></Checkbox>
  347. </div>
  348. </div>
  349. <div>
  350. <FormItem
  351. {...formItemLayout}
  352. label="项目材料上传"
  353. labelCol={{ span: 24 }}
  354. wrapperCol={{ span: 12 }}
  355. >
  356. {getFieldDecorator('avatar')(
  357. <Avatar urlData={this.avatarUrl} name='patent_prory_statement' oid={theData.unitName} />
  358. )}
  359. </FormItem>
  360. </div>
  361. <div className="form-title">状态流转记录: </div>
  362. <Table pagination={false} dataSource={this.state.stateTable} columns={this.state.stateColumns} />
  363. <div className="clearfix">
  364. <FormItem className="third-item"
  365. {...formItemLayout}
  366. label="状态流转"
  367. >
  368. {getFieldDecorator('state')(
  369. <Select placeholder="选择一个状态">{this.state.stateOption}</Select>
  370. )}
  371. </FormItem>
  372. <FormItem className="third-item"
  373. labelCol={{ span: 6 }}
  374. wrapperCol={{ span: 12 }}
  375. label="处理时间"
  376. >
  377. {getFieldDecorator('recordTime')(
  378. <DatePicker />
  379. )}
  380. </FormItem>
  381. <FormItem className="third-item"
  382. {...formItemLayout}
  383. label="负责人"
  384. >
  385. {getFieldDecorator('principal')(
  386. <Select placeholder="选择负责人">{this.props.authorOption}</Select>
  387. )}
  388. </FormItem>
  389. </div>
  390. <FormItem
  391. labelCol={{ span: 2 }}
  392. wrapperCol={{ span: 12 }}
  393. label="备注"
  394. >
  395. {getFieldDecorator('comment')(
  396. <Input />
  397. )}
  398. </FormItem>
  399. <FormItem style={{ marginTop: '20px' }}>
  400. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  401. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  402. </FormItem>
  403. </Form >
  404. );
  405. } else {
  406. return (<div></div>)
  407. };
  408. },
  409. }));
  410. const ApplyChange = React.createClass({
  411. getInitialState() {
  412. return {
  413. visible: false,
  414. loading: false
  415. };
  416. },
  417. componentWillReceiveProps(nextProps) {
  418. this.state.visible = nextProps.showDesc
  419. },
  420. showModal() {
  421. this.setState({
  422. visible: true,
  423. });
  424. },
  425. handleOk() {
  426. this.setState({
  427. visible: false,
  428. });
  429. this.props.closeDesc(false);
  430. },
  431. handleCancel(e) {
  432. this.setState({
  433. visible: false,
  434. });
  435. this.props.closeDesc(false);
  436. },
  437. spinChange(e) {
  438. this.setState({
  439. loading: e
  440. });
  441. },
  442. render() {
  443. return (
  444. <div className="patent-addNew">
  445. <Spin spinning={this.state.loading} className='spin-box'>
  446. <Modal title="编辑科技项目" visible={this.state.visible}
  447. onOk={this.handleOk} onCancel={this.handleCancel}
  448. width='1000px'
  449. footer=''
  450. >
  451. <ApplyChangeFrom
  452. visible={this.state.visible}
  453. authorOption={this.props.authorOption}
  454. data={this.props.data}
  455. spinState={this.spinChange} closeModal={this.handleCancel} />
  456. </Modal>
  457. </Spin>
  458. </div>
  459. );
  460. }
  461. });
  462. export default ApplyChange;