orgTechCenter.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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. projectTime: values.projectTime.format("YYYY-MM-DD"),
  29. institution: values.institution,
  30. termTime: 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.closeModal();
  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>未上传!</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);
  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} />
  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. if (!data.data) {
  204. if (data.error.length) {
  205. message.warning(data.error[0].message);
  206. };
  207. return;
  208. };
  209. this.state.cid = data.data.id;
  210. this.state.foundingTime = data.data.foundingTime;
  211. this.state.principal = data.data.principal;
  212. this.state.systemCatalog = data.data.systemCatalog;
  213. this.state.systemUrl = data.data.systemUrl;
  214. this.state.systemDownloadFileName = data.data.systemDownloadFileName;
  215. this.state.centerName = data.data.centerName;
  216. this.state.comment = data.data.comment;
  217. this.loadData();
  218. }).always(function () {
  219. this.setState({
  220. loading: false
  221. });
  222. }.bind(this));
  223. },
  224. loadData(pageNo) {
  225. this.state.data = [];
  226. this.setState({
  227. loading: true
  228. });
  229. $.ajax({
  230. method: "post",
  231. dataType: "json",
  232. crossDomain: false,
  233. url: globalConfig.context + "/techservice/cognizance/centerDetail",
  234. data: {
  235. pageNo: pageNo || 1,
  236. pageSize: this.state.pagination.pageSize,
  237. cid: this.state.cid,
  238. }
  239. }).done((data) => {
  240. if (!data.data || !data.data.list) {
  241. if(data.error.length) {
  242. message.warning(data.error[0].message);
  243. }
  244. return;
  245. };
  246. for (let i = 0; i < data.data.list.length; i++) {
  247. let thisdata = data.data.list[i];
  248. this.state.data.push({
  249. key: i,
  250. id: thisdata.id,
  251. cid: thisdata.cid,
  252. projectTimeFormattedDate: thisdata.projectTimeFormattedDate,
  253. projectName: thisdata.projectName,
  254. protocolDownloadFileName: thisdata.protocolDownloadFileName,
  255. protocolUrl: thisdata.protocolUrl,
  256. protocol: [thisdata.protocolUrl, thisdata.protocolDownloadFileName],
  257. institution: thisdata.institution,
  258. termTimeFormattedDate: thisdata.termTimeFormattedDate
  259. });
  260. };
  261. this.state.pagination.current = data.data.pageNo;
  262. this.state.pagination.total = data.data.totalCount;
  263. this.setState({
  264. dataSource: this.state.data,
  265. pagination: this.state.pagination
  266. });
  267. }).always(function () {
  268. this.setState({
  269. loading: false
  270. });
  271. }.bind(this));
  272. },
  273. getInitialState() {
  274. return {
  275. selectedRowKeys: [],
  276. selectedRows: [],
  277. loading: false,
  278. pagination: {
  279. defaultCurrent: 1,
  280. defaultPageSize: 10,
  281. showQuickJumper: true,
  282. pageSize: 10,
  283. onChange: function (page) {
  284. this.loadData(page);
  285. }.bind(this),
  286. showTotal: function (total) {
  287. return '共' + total + '条数据';
  288. }
  289. },
  290. columns: [
  291. {
  292. title: '时间',
  293. dataIndex: 'projectTimeFormattedDate',
  294. key: 'projectTimeFormattedDate'
  295. }, {
  296. title: '名称',
  297. dataIndex: 'projectName',
  298. key: 'projectName'
  299. }, {
  300. title: '期限',
  301. dataIndex: 'termTimeFormattedDate',
  302. key: 'termTimeFormattedDate'
  303. }, {
  304. title: '大学机构',
  305. dataIndex: 'institution',
  306. key: 'institution'
  307. }, {
  308. title: '协议附件',
  309. dataIndex: 'protocolUrl',
  310. key: 'protocolUrl',
  311. render: (text) => {
  312. return <a onClick={downloadFile.bind(null, text[0], text[1])}>{text[1]}</a>
  313. }
  314. }
  315. ],
  316. dataSource: []
  317. };
  318. },
  319. componentWillMount() {
  320. this.loadOrgTechCenterDetail();
  321. },
  322. tableRowClick(record, index) {
  323. this.state.RowData = record;
  324. this.setState({
  325. showDesc: true
  326. });
  327. },
  328. delectRow() {
  329. let deletedIds = [];
  330. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  331. let rowItem = this.state.selectedRows[idx];
  332. if (rowItem.id) {
  333. deletedIds.push(rowItem.id)
  334. }
  335. }
  336. this.setState({
  337. selectedRowKeys: [],
  338. loading: deletedIds.length > 0
  339. });
  340. $.ajax({
  341. method: "POST",
  342. dataType: "json",
  343. crossDomain: false,
  344. url: globalConfig.context + "/techservice/cognizance/deleteOrgTechCenterDetail",
  345. data: {
  346. ids: deletedIds
  347. }
  348. }).done(function (data) {
  349. if (!data.error.length) {
  350. message.success('保存成功!');
  351. this.setState({
  352. loading: false,
  353. });
  354. } else {
  355. message.warning(data.error[0].message);
  356. };
  357. this.loadData();
  358. }.bind(this));
  359. },
  360. closeDesc(e) {
  361. this.state.showDesc = e;
  362. this.loadData();
  363. },
  364. saveCenterDetail() {
  365. this.setState({
  366. loading: true
  367. });
  368. $.ajax({
  369. method: "post",
  370. dataType: "json",
  371. crossDomain: false,
  372. url: globalConfig.context + "/api/admin/disposeCenter",
  373. data: {
  374. uid: this.props.data.uid,
  375. principal: this.state.principal,
  376. systemUrl: this.state.systemUrl,
  377. systemCatalog: this.state.systemCatalog,
  378. foundingTimeFormattedDate: this.state.foundingTime,
  379. comment: this.state.comment,
  380. centerName: this.state.centerName
  381. }
  382. }).done((data) => {
  383. if (!data.error.length) {
  384. message.success('保存成功!');
  385. this.loadOrgTechCenterDetail();
  386. this.setState({
  387. loading: false,
  388. });
  389. } else {
  390. message.warning(data.error[0].message);
  391. };
  392. });
  393. },
  394. render() {
  395. const rowSelection = {
  396. selectedRowKeys: this.state.selectedRowKeys,
  397. onChange: (selectedRowKeys, selectedRows) => {
  398. this.setState({
  399. selectedRows: selectedRows,
  400. selectedRowKeys: selectedRowKeys
  401. });
  402. }
  403. };
  404. const hasSelected = this.state.selectedRowKeys.length > 0;
  405. return (
  406. <div className="user-content" >
  407. <div className="content-title">
  408. <span>研发部门</span>
  409. </div>
  410. <div className="clearfix">
  411. <div className="orgTech-item">
  412. <span>研发部门名称: </span>
  413. <Input
  414. value={this.state.centerName}
  415. onChange={(e) => { this.setState({ centerName: e.target.value }); }}
  416. />
  417. <span>成立时间: </span>
  418. <DatePicker
  419. value={moment(this.state.foundingTime)}
  420. onChange={(date, dateString) => { this.setState({ foundingTime: dateString }); }}
  421. />
  422. <span>负责人: </span>
  423. <Input
  424. value={this.state.principal}
  425. onChange={(e) => { this.setState({ principal: e.target.value }); }}
  426. />
  427. </div>
  428. <div className="orgTech-item">
  429. <span>制度目录: </span>
  430. <Input type='textarea' rows={6}
  431. value={this.state.systemCatalog}
  432. onChange={(e) => { this.setState({ systemCatalog: e.target.value }); }}
  433. />
  434. </div>
  435. <div className="orgTech-item">
  436. <span>备注: </span>
  437. <Input type='textarea' rows={3}
  438. value={this.state.comment}
  439. onChange={(e) => { this.setState({ comment: e.target.value }); }}
  440. />
  441. </div>
  442. </div>
  443. <div className="half-item">
  444. <p>制度上传: (上传 zip 或者 rar 文件)</p>
  445. <div style={{ margin: '10px 0' }}>
  446. <Upload
  447. name="ratepay"
  448. action={globalConfig.context + "/techservice/cognizance/upload"}
  449. data={{ 'sign': 'institution' }}
  450. beforeUpload={beforeUploadFile}
  451. showUploadList={false}
  452. onChange={(info) => {
  453. if (info.file.status !== 'uploading') {
  454. console.log(info.file, info.fileList);
  455. }
  456. if (info.file.status === 'done') {
  457. if (!info.file.response.error.length) {
  458. message.success(`${info.file.name} 文件上传成功!`);
  459. } else {
  460. message.warning(info.file.response.error[0].message);
  461. return;
  462. };
  463. this.state.systemUrl = info.file.response.data;
  464. } else if (info.file.status === 'error') {
  465. message.error(`${info.file.name} 文件上传失败。`);
  466. }
  467. }}
  468. >
  469. <Button><Icon type="upload" /> 上传研发费用台账 </Button>
  470. </Upload>
  471. <p style={{ marginTop: '10px' }}>{this.state.systemUrl ? <a onClick={downloadFile.bind(null, this.state.systemUrl, this.state.systemDownloadFileName)}>{this.state.systemDownloadFileName}</a> : <span>未上传!</span>}</p>
  472. </div>
  473. </div>
  474. <Button type='primary' onClick={this.saveCenterDetail} style={{ marginBottom: '10px' }}>保存</Button>
  475. <div className="content-title">
  476. <span>产学研情况</span>
  477. </div>
  478. <div className="user-search">
  479. <p>
  480. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  481. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  482. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  483. disabled={!hasSelected}
  484. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  485. </p>
  486. </div>
  487. <div className="patent-table">
  488. <Spin spinning={this.state.loading}>
  489. <Table columns={this.state.columns}
  490. dataSource={this.state.dataSource}
  491. pagination={this.state.pagination}
  492. rowSelection={rowSelection}
  493. onRowClick={this.tableRowClick} />
  494. </Spin>
  495. </div>
  496. <CenterListDesc data={this.state.RowData}
  497. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  498. </div >
  499. );
  500. }
  501. });
  502. export default CenterList;