orgTechCenter.jsx 19 KB

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