orgTechCenter.jsx 19 KB

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