orgTechCenter.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Spin, Table, message, Modal, Upload, DatePicker } from 'antd';
  3. import './techProduct.less';
  4. import { beforeUploadFile, downloadFile } from '../../../../tools.js';
  5. import moment from 'moment';
  6. import ajax from 'jquery/src/ajax/xhr.js';
  7. import $ from 'jquery/src/ajax';
  8. const CenterListDescFrom = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. loading: false
  12. };
  13. },
  14. handleSubmit(e) {
  15. e.preventDefault();
  16. this.props.form.validateFields((err, values) => {
  17. if (!err) {
  18. this.props.spinState(true);
  19. $.ajax({
  20. method: "POST",
  21. dataType: "json",
  22. crossDomain: false,
  23. url: globalConfig.context + "/techservice/cognizance/disposeCenterDetail",
  24. data: {
  25. id: this.props.data.id,
  26. uid: this.props.uid,
  27. projectName: values.projectName,
  28. projectTimeFormattedDate: values.projectTime.format("YYYY-MM-DD"),
  29. institution: values.institution,
  30. termTimeFormattedDate: values.termTime.format("YYYY-MM-DD"),
  31. protocolUrl: this.state.protocolUrl
  32. }
  33. }).done(function (data) {
  34. if (!data.error.length) {
  35. message.success('保存成功!');
  36. this.props.clickOk();
  37. this.props.spinState(false);
  38. this.props.form.resetFields();
  39. } else {
  40. message.warning(data.error[0].message);
  41. this.props.spinState(false);
  42. }
  43. }.bind(this));
  44. }
  45. });
  46. },
  47. render() {
  48. const FormItem = Form.Item;
  49. const { getFieldDecorator } = this.props.form;
  50. const theData = this.props.data;
  51. const formItemLayout = {
  52. labelCol: { span: 4 },
  53. wrapperCol: { span: 12 },
  54. };
  55. const _me = this;
  56. return (
  57. <Form onSubmit={this.handleSubmit} className="activityCost-form">
  58. <div className="clearfix">
  59. <FormItem className="half-item"
  60. {...formItemLayout}
  61. label="时间"
  62. >
  63. {getFieldDecorator('projectTimeFormattedDate', {
  64. rules: [{ type: 'object', required: true, message: '此项为必填项!' }],
  65. initialValue: theData.projectTimeFormattedDate ? moment(theData.projectTimeFormattedDate) : null
  66. })(
  67. <DatePicker />
  68. )}
  69. </FormItem>
  70. <FormItem className="half-item"
  71. {...formItemLayout}
  72. label="名称"
  73. >
  74. {getFieldDecorator('projectName', {
  75. rules: [{ required: true, message: '此项为必填项!' }],
  76. initialValue: theData.projectName
  77. })(
  78. <Input />
  79. )}
  80. </FormItem>
  81. <FormItem className="half-item"
  82. {...formItemLayout}
  83. label="期限"
  84. >
  85. {getFieldDecorator('termTimeFormattedDate', {
  86. rules: [{ type: 'object', required: true, message: '此项为必填项!' }],
  87. initialValue: theData.termTimeFormattedDate ? moment(theData.termTimeFormattedDate) : null
  88. })(
  89. <DatePicker />
  90. )}
  91. </FormItem>
  92. <FormItem className="half-item"
  93. {...formItemLayout}
  94. label="大学机构"
  95. >
  96. {getFieldDecorator('institution', {
  97. rules: [{ required: true, message: '此项为必填项!' }],
  98. initialValue: theData.institution
  99. })(
  100. <Input />
  101. )}
  102. </FormItem>
  103. </div>
  104. <div className="hrSituation-roster">
  105. <Upload
  106. name="ratepay"
  107. action={globalConfig.context + "/techservice/cognizance/upload"}
  108. data={{ 'sign': 'protocol' }}
  109. beforeUpload={beforeUploadFile}
  110. showUploadList={false}
  111. onChange={(info) => {
  112. if (info.file.status !== 'uploading') {
  113. console.log(info.file, info.fileList);
  114. }
  115. if (info.file.status === 'done') {
  116. if (!info.file.response.error.length) {
  117. message.success(`${info.file.name} 文件上传成功!`);
  118. } else {
  119. message.warning(info.file.response.error[0].message);
  120. return;
  121. };
  122. this.state.protocolUrl = info.file.response.data;
  123. } else if (info.file.status === 'error') {
  124. message.error(`${info.file.name} 文件上传失败。`);
  125. }
  126. }}
  127. >
  128. <Button><Icon type="upload" /> 上传研发费用台账 </Button>
  129. </Upload>
  130. <p style={{ marginTop: '10px' }}>{theData.protocolUrl ? <a onClick={downloadFile.bind(null, theData.protocolUrl, theData.protocolDownloadFileName)}>{theData.protocolDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  131. </div>
  132. <FormItem style={{ marginTop: '20px' }}>
  133. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  134. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  135. </FormItem>
  136. </Form >
  137. );
  138. },
  139. }));
  140. const CenterListDesc = React.createClass({
  141. getInitialState() {
  142. return {
  143. visible: false,
  144. loading: false
  145. };
  146. },
  147. componentWillReceiveProps(nextProps) {
  148. this.state.visible = nextProps.showDesc
  149. },
  150. showModal() {
  151. this.setState({
  152. visible: true,
  153. });
  154. },
  155. handleOk() {
  156. this.setState({
  157. visible: false,
  158. });
  159. this.props.closeDesc(false, true);
  160. },
  161. handleCancel(e) {
  162. this.setState({
  163. visible: false,
  164. });
  165. this.props.closeDesc(false);
  166. },
  167. spinChange(e) {
  168. this.setState({
  169. loading: e
  170. });
  171. },
  172. render() {
  173. return (
  174. <div className="patent-addNew">
  175. <Spin spinning={this.state.loading} className='spin-box'>
  176. <Modal title="产学研情况详情" visible={this.state.visible}
  177. onOk={this.handleOk} onCancel={this.handleCancel}
  178. width='800px'
  179. footer=''
  180. >
  181. <CenterListDescFrom data={this.props.data}
  182. spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  183. </Modal>
  184. </Spin>
  185. </div>
  186. );
  187. },
  188. });
  189. const CenterList = React.createClass({
  190. loadOrgTechCenterDetail() {
  191. this.setState({
  192. loading: true
  193. });
  194. $.ajax({
  195. method: "post",
  196. dataType: "json",
  197. crossDomain: false,
  198. url: globalConfig.context + "/api/admin/center",
  199. data: {
  200. uid: this.props.data.uid
  201. }
  202. }).done((data) => {
  203. let theData = data.data;
  204. if (!theData) {
  205. if (data.error.length) {
  206. message.warning(data.error[0].message);
  207. };
  208. theData = {};
  209. };
  210. this.state.cid = theData.id;
  211. this.state.foundingTime = theData.foundingTimeFormattedDate;
  212. this.state.principal = theData.principal;
  213. this.state.systemCatalog = theData.systemCatalog;
  214. this.state.systemUrl = theData.systemUrl;
  215. this.state.systemDownloadFileName = theData.systemDownloadFileName;
  216. this.state.centerName = theData.centerName;
  217. this.state.comment = theData.comment;
  218. this.loadData();
  219. }).always(function () {
  220. this.setState({
  221. loading: false
  222. });
  223. }.bind(this));
  224. },
  225. loadData(pageNo) {
  226. this.state.data = [];
  227. this.setState({
  228. loading: true
  229. });
  230. $.ajax({
  231. method: "post",
  232. dataType: "json",
  233. crossDomain: false,
  234. url: globalConfig.context + "/techservice/cognizance/centerDetail",
  235. data: {
  236. pageNo: pageNo || 1,
  237. pageSize: this.state.pagination.pageSize,
  238. cid: this.state.cid,
  239. }
  240. }).done((data) => {
  241. if (!data.data || !data.data.list) {
  242. if (data.error.length) {
  243. message.warning(data.error[0].message);
  244. }
  245. return;
  246. };
  247. for (let i = 0; i < data.data.list.length; i++) {
  248. let thisdata = data.data.list[i];
  249. this.state.data.push({
  250. key: i,
  251. id: thisdata.id,
  252. cid: thisdata.cid,
  253. projectTimeFormattedDate: thisdata.projectTimeFormattedDate,
  254. projectName: thisdata.projectName,
  255. protocolDownloadFileName: thisdata.protocolDownloadFileName,
  256. protocolUrl: thisdata.protocolUrl,
  257. protocol: [thisdata.protocolUrl, thisdata.protocolDownloadFileName],
  258. institution: thisdata.institution,
  259. termTimeFormattedDate: thisdata.termTimeFormattedDate
  260. });
  261. };
  262. this.state.pagination.current = data.data.pageNo;
  263. this.state.pagination.total = data.data.totalCount;
  264. this.setState({
  265. dataSource: this.state.data,
  266. pagination: this.state.pagination
  267. });
  268. }).always(function () {
  269. this.setState({
  270. loading: false
  271. });
  272. }.bind(this));
  273. },
  274. getInitialState() {
  275. return {
  276. selectedRowKeys: [],
  277. selectedRows: [],
  278. loading: false,
  279. pagination: {
  280. defaultCurrent: 1,
  281. defaultPageSize: 10,
  282. showQuickJumper: true,
  283. pageSize: 10,
  284. onChange: function (page) {
  285. this.loadData(page);
  286. }.bind(this),
  287. showTotal: function (total) {
  288. return '共' + total + '条数据';
  289. }
  290. },
  291. columns: [
  292. {
  293. title: '时间',
  294. dataIndex: 'projectTimeFormattedDate',
  295. key: 'projectTimeFormattedDate'
  296. }, {
  297. title: '名称',
  298. dataIndex: 'projectName',
  299. key: 'projectName'
  300. }, {
  301. title: '期限',
  302. dataIndex: 'termTimeFormattedDate',
  303. key: 'termTimeFormattedDate'
  304. }, {
  305. title: '大学机构',
  306. dataIndex: 'institution',
  307. key: 'institution'
  308. }, {
  309. title: '协议附件',
  310. dataIndex: 'protocol',
  311. key: 'protocol',
  312. render: (text) => {
  313. return <a onClick={downloadFile.bind(null, text[0], text[1])}>{text[1]}</a>
  314. }
  315. }
  316. ],
  317. dataSource: []
  318. };
  319. },
  320. componentWillMount() {
  321. this.loadOrgTechCenterDetail();
  322. },
  323. componentWillReceiveProps(nextProps) {
  324. if (this.props.data.uid !== nextProps.data.uid) {
  325. this.props.data.uid = nextProps.data.uid;
  326. this.loadOrgTechCenterDetail();
  327. };
  328. },
  329. tableRowClick(record, index) {
  330. this.state.RowData = record;
  331. this.setState({
  332. showDesc: true
  333. });
  334. },
  335. delectRow() {
  336. let deletedIds = [];
  337. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  338. let rowItem = this.state.selectedRows[idx];
  339. if (rowItem.id) {
  340. deletedIds.push(rowItem.id)
  341. }
  342. }
  343. this.setState({
  344. selectedRowKeys: [],
  345. loading: deletedIds.length > 0
  346. });
  347. $.ajax({
  348. method: "POST",
  349. dataType: "json",
  350. crossDomain: false,
  351. url: globalConfig.context + "/techservice/cognizance/deleteOrgTechCenterDetail",
  352. data: {
  353. ids: deletedIds
  354. }
  355. }).done(function (data) {
  356. if (!data.error.length) {
  357. message.success('保存成功!');
  358. this.setState({
  359. loading: false,
  360. });
  361. } else {
  362. message.warning(data.error[0].message);
  363. };
  364. this.loadData();
  365. }.bind(this));
  366. },
  367. closeDesc(e, s) {
  368. this.state.showDesc = e;
  369. if (s) {
  370. this.loadData();
  371. };
  372. },
  373. saveCenterDetail() {
  374. this.setState({
  375. loading: true
  376. });
  377. $.ajax({
  378. method: "post",
  379. dataType: "json",
  380. crossDomain: false,
  381. url: globalConfig.context + "/api/admin/disposeCenter",
  382. data: {
  383. uid: this.props.data.uid,
  384. id: this.state.cid,
  385. principal: this.state.principal,
  386. systemUrl: this.state.systemUrl,
  387. systemCatalog: this.state.systemCatalog,
  388. foundingTimeFormattedDate: this.state.foundingTime,
  389. comment: this.state.comment,
  390. centerName: this.state.centerName
  391. }
  392. }).done((data) => {
  393. if (!data.error.length) {
  394. message.success('保存成功!');
  395. this.loadOrgTechCenterDetail();
  396. } else {
  397. message.warning(data.error[0].message);
  398. };
  399. this.setState({
  400. loading: false,
  401. });
  402. });
  403. },
  404. render() {
  405. const rowSelection = {
  406. selectedRowKeys: this.state.selectedRowKeys,
  407. onChange: (selectedRowKeys, selectedRows) => {
  408. this.setState({
  409. selectedRows: selectedRows,
  410. selectedRowKeys: selectedRowKeys
  411. });
  412. }
  413. };
  414. const hasSelected = this.state.selectedRowKeys.length > 0;
  415. return (
  416. <div className="user-content" >
  417. <div className="content-title">
  418. <span>研发部门</span>
  419. </div>
  420. <div className="clearfix">
  421. <div className="orgTech-item">
  422. <span>研发部门名称: </span>
  423. <Input
  424. value={this.state.centerName}
  425. onChange={(e) => { this.setState({ centerName: e.target.value }); }}
  426. />
  427. <span>成立时间: </span>
  428. <DatePicker
  429. allowClear={false}
  430. value={moment(this.state.foundingTime)}
  431. onChange={(date, dateString) => { this.setState({ foundingTime: dateString }); }}
  432. />
  433. <span>负责人: </span>
  434. <Input
  435. value={this.state.principal}
  436. onChange={(e) => { this.setState({ principal: e.target.value }); }}
  437. />
  438. </div>
  439. <div className="orgTech-item">
  440. <span>制度目录: </span>
  441. <Input type='textarea' rows={6}
  442. value={this.state.systemCatalog}
  443. onChange={(e) => { this.setState({ systemCatalog: e.target.value }); }}
  444. />
  445. </div>
  446. <div className="orgTech-item">
  447. <span>备注: </span>
  448. <Input type='textarea' rows={3}
  449. value={this.state.comment}
  450. onChange={(e) => { this.setState({ comment: e.target.value }); }}
  451. />
  452. </div>
  453. </div>
  454. <div className="half-item">
  455. <p>制度上传: (上传 zip 或者 rar 文件)</p>
  456. <div style={{ margin: '10px 0' }}>
  457. <Upload
  458. name="ratepay"
  459. action={globalConfig.context + "/techservice/cognizance/upload"}
  460. data={{ 'sign': 'institution' }}
  461. beforeUpload={beforeUploadFile}
  462. showUploadList={false}
  463. onChange={(info) => {
  464. if (info.file.status !== 'uploading') {
  465. console.log(info.file, info.fileList);
  466. }
  467. if (info.file.status === 'done') {
  468. if (!info.file.response.error.length) {
  469. message.success(`${info.file.name} 文件上传成功!`);
  470. } else {
  471. message.warning(info.file.response.error[0].message);
  472. return;
  473. };
  474. this.state.systemUrl = info.file.response.data;
  475. } else if (info.file.status === 'error') {
  476. message.error(`${info.file.name} 文件上传失败。`);
  477. }
  478. }}
  479. >
  480. <Button><Icon type="upload" /> 上传研发部门制度 </Button>
  481. </Upload>
  482. <p style={{ marginTop: '10px' }}>{this.state.systemUrl ? <a onClick={downloadFile.bind(null, this.state.systemUrl, this.state.systemDownloadFileName)}>{this.state.systemDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  483. </div>
  484. </div>
  485. <Button type='primary' onClick={this.saveCenterDetail} style={{ marginBottom: '10px' }}>保存</Button>
  486. <div className="content-title">
  487. <span>产学研情况</span>
  488. </div>
  489. <div className="user-search">
  490. <p>
  491. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  492. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  493. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  494. disabled={!hasSelected}
  495. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  496. </p>
  497. </div>
  498. <div className="patent-table">
  499. <Spin spinning={this.state.loading}>
  500. <Table columns={this.state.columns}
  501. dataSource={this.state.dataSource}
  502. pagination={this.state.pagination}
  503. rowSelection={rowSelection}
  504. onRowClick={this.tableRowClick} />
  505. </Spin>
  506. </div>
  507. <CenterListDesc data={this.state.RowData}
  508. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  509. </div >
  510. );
  511. }
  512. });
  513. export default CenterList;