orgTechCenter.jsx 19 KB

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