orgTechCenter.jsx 19 KB

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