copyright.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, DatePicker, message, Cascader, Switch } from 'antd';
  3. import { provinceArr, copyrightStateList } from '../../../dataDic.js';
  4. import { getTime, companySearch, getCopyrightState, getInUrgentTime, getSearchUrl } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. import PatentAdd from './comPatentAdd.jsx';
  8. import PatentChange from './comPatentChange.jsx';
  9. import moment from 'moment';
  10. import './copyright.less';
  11. const copyright = React.createClass({
  12. loadData(pageNo) {
  13. this.state.data = [];
  14. this.setState({
  15. loading: true
  16. });
  17. $.ajax({
  18. method: "get",
  19. dataType: "json",
  20. crossDomain: false,
  21. url: globalConfig.context + "/api/admin/copyright/list",
  22. data: {
  23. pageNo: pageNo || 1,
  24. pageSize: this.state.pagination.pageSize,
  25. province: this.state.province,
  26. uid: this.state.unitName,
  27. copyrightName: this.state.copyrightName,
  28. status: this.state.status,
  29. createTime: this.state.createTime,
  30. acceptTime: this.state.acceptTime,
  31. authTime: this.state.authTime
  32. },
  33. success: function (data) {
  34. if (data.error.length || !data.data || !data.data.list) {
  35. message.warning(data.error[0].message);
  36. return;
  37. };
  38. for (let i = 0; i < data.data.list.length; i++) {
  39. let thisdata = data.data.list[i];
  40. this.state.data.push({
  41. key: i,
  42. id: thisdata.id,
  43. uid: thisdata.uid,
  44. province: thisdata.province,
  45. unitName: thisdata.unitName,
  46. serialNumber: thisdata.serialNumber,
  47. createTime: thisdata.createTime,
  48. acceptTime: thisdata.acceptTime,
  49. principal: thisdata.principal,
  50. contact: thisdata.contact,
  51. copyrightName: thisdata.copyrightName,
  52. copyrightNumber: thisdata.copyrightNumber,
  53. status: thisdata.status,
  54. comment: thisdata.comment,
  55. workIssue: thisdata.workIssue,
  56. outsource: thisdata.outsource,
  57. inUrgent: thisdata.inUrgent,
  58. expectTime: [thisdata.acceptTime, thisdata.inUrgent],
  59. authorizedDate: thisdata.authorizedDate,
  60. fisrtContact: thisdata.fisrtContact,
  61. secondContact: thisdata.secondContact,
  62. thirdContact: thisdata.thirdContact,
  63. authorizedDateFormattedDate: thisdata.authorizedDateFormattedDate,
  64. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  65. acceptTimeFormattedDate: thisdata.acceptTimeFormattedDate,
  66. founder: thisdata.founder
  67. });
  68. };
  69. this.state.pagination.defaultCurrent = data.data.pageNo;
  70. this.state.pagination.total = data.data.totalCount;
  71. this.setState({
  72. dataSource: this.state.data,
  73. pagination: this.state.pagination
  74. });
  75. }.bind(this),
  76. }).always(function () {
  77. this.setState({
  78. loading: false
  79. });
  80. }.bind(this));
  81. },
  82. getAuthorList() {
  83. this.setState({
  84. loading: true
  85. });
  86. $.ajax({
  87. method: "get",
  88. dataType: "json",
  89. crossDomain: false,
  90. url: globalConfig.context + "/api/admin/copyright/getPrincipal",
  91. success: function (data) {
  92. if (!data.data) {
  93. if (data.error && data.error.length) {
  94. message.warning(data.error[0].message);
  95. }
  96. return;
  97. };
  98. let _me = this;
  99. for (var item in data.data) {
  100. _me.state.authorOption.push(
  101. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  102. )
  103. };
  104. }.bind(this),
  105. }).always(function () {
  106. this.setState({
  107. loading: false
  108. });
  109. }.bind(this));
  110. },
  111. getCompanyList() {
  112. this.setState({
  113. loading: true
  114. });
  115. $.ajax({
  116. method: "get",
  117. dataType: "json",
  118. crossDomain: false,
  119. url: globalConfig.context + "/api/admin/getUnitNames",
  120. success: function (data) {
  121. if (data.error.length || !data.data) {
  122. return;
  123. };
  124. let _me = this;
  125. for (var item in data.data) {
  126. _me.state.companyOption.push(
  127. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  128. )
  129. };
  130. }.bind(this),
  131. }).always(function () {
  132. this.setState({
  133. loading: false
  134. });
  135. }.bind(this));
  136. },
  137. getInitialState() {
  138. return {
  139. visible: false,
  140. provinceOption: [],
  141. stateOption: [],
  142. companyOption: [],
  143. authorOption: [],
  144. consultantOption: [],
  145. data: [],
  146. selectedRowKeys: [],
  147. selectedRows: [],
  148. loading: false,
  149. showAdd: false,
  150. showDesc: false,
  151. searchMore: true,
  152. createTime: [],
  153. acceptTime: [],
  154. authTime: [],
  155. pagination: {
  156. defaultCurrent: 1,
  157. defaultPageSize: 10,
  158. showQuickJumper: true,
  159. pageSize: 10,
  160. onChange: function (page) {
  161. this.loadData(page);
  162. }.bind(this),
  163. showTotal: function (total) {
  164. return '共' + total + '条数据';
  165. }
  166. },
  167. columns: [
  168. {
  169. title: '编号',
  170. dataIndex: 'serialNumber',
  171. key: 'serialNumber',
  172. }, {
  173. title: '省份',
  174. dataIndex: 'province',
  175. key: 'province',
  176. }, {
  177. title: '外包公司',
  178. dataIndex: 'outsource',
  179. key: 'outsource',
  180. }, {
  181. title: '公司名称',
  182. dataIndex: 'unitName',
  183. key: 'unitName',
  184. }, {
  185. title: '认证状态',
  186. dataIndex: 'status',
  187. key: 'status',
  188. render: (text) => { return getCopyrightState(text) }
  189. }, {
  190. title: '软著名称',
  191. dataIndex: 'copyrightName',
  192. key: 'copyrightName',
  193. }, {
  194. title: '加急天数',
  195. dataIndex: 'inUrgent',
  196. key: 'inUrgent',
  197. render: (text) => {
  198. switch (text) {
  199. case 0:
  200. return '不加急(45个工作日)';
  201. case 3:
  202. return '3个工作日';
  203. case 5:
  204. return '5个工作日';
  205. case 10:
  206. return '6-10个工作日';
  207. case 15:
  208. return '11-15个工作日';
  209. case 20:
  210. return '16-20个工作日';
  211. case 25:
  212. return '21-25个工作日';
  213. case 30:
  214. return '26-30个工作日';
  215. case 35:
  216. return '31-35个工作日';
  217. }
  218. }
  219. }, {
  220. title: '负责人',
  221. dataIndex: 'principal',
  222. key: 'principal',
  223. }, {
  224. title: '派单日',
  225. dataIndex: 'createTimeFormattedDate',
  226. key: 'createTimeFormattedDate',
  227. }, {
  228. title: '受理日',
  229. dataIndex: 'acceptTimeFormattedDate',
  230. key: 'acceptTimeFormattedDate',
  231. }, {
  232. title: '(预计)下证时间',
  233. dataIndex: 'expectTime',
  234. key: 'expectTime',
  235. render: (text) => {
  236. if (text[0]) {
  237. if (text[1]) {
  238. return getTime(getInUrgentTime(moment(text[0]), text[1]))
  239. } else {
  240. return getTime(getInUrgentTime(moment(text[0]), 45))
  241. }
  242. };
  243. return;
  244. }
  245. }, {
  246. title: '创建人',
  247. dataIndex: 'founder',
  248. key: 'founder'
  249. }
  250. ],
  251. dataSource: []
  252. };
  253. },
  254. componentWillMount() {
  255. let _me = this;
  256. provinceArr.map(function (item) {
  257. _me.state.provinceOption.push(
  258. <Select.Option value={item} key={item}>{item}</Select.Option>
  259. )
  260. });
  261. copyrightStateList.map(function (item) {
  262. _me.state.stateOption.push(
  263. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  264. )
  265. });
  266. this.loadData();
  267. this.getAuthorList();
  268. this.getCompanyList();
  269. if (window.location.search) {
  270. let theArr = getSearchUrl(window.location.search);
  271. let theObj = {};
  272. theObj.id = theArr[0];
  273. theObj.uid = theArr[1];
  274. if (theObj.id != 'null' && theObj.uid != 'null') {
  275. this.tableRowClick(theObj);
  276. };
  277. };
  278. },
  279. tableRowClick(record, index) {
  280. this.state.RowData = record;
  281. this.setState({
  282. showDesc: true
  283. });
  284. },
  285. delectRow() {
  286. let deletedIds = [];
  287. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  288. let rowItem = this.state.selectedRows[idx];
  289. if (rowItem.id) {
  290. deletedIds.push(rowItem.id)
  291. }
  292. }
  293. this.setState({
  294. selectedRowKeys: [],
  295. loading: deletedIds.length > 0
  296. });
  297. $.ajax({
  298. method: "POST",
  299. dataType: "json",
  300. crossDomain: false,
  301. url: globalConfig.context + "/api/admin/copyright/delete",
  302. data: {
  303. id: deletedIds
  304. }
  305. }).done(function (data) {
  306. if (!data.error.length) {
  307. message.success('保存成功!');
  308. this.setState({
  309. loading: false,
  310. });
  311. } else {
  312. message.warning(data.error[0].message);
  313. };
  314. this.loadData();
  315. }.bind(this));
  316. },
  317. closeDesc(e, s) {
  318. this.state.showDesc = e;
  319. if (s) {
  320. this.loadData();
  321. };
  322. },
  323. addClick() {
  324. this.setState({
  325. showAdd: true
  326. });
  327. },
  328. closeAdd(e, s) {
  329. this.state.showAdd = e;
  330. if (s) {
  331. this.loadData();
  332. };
  333. },
  334. searchSwitch() {
  335. this.setState({
  336. searchMore: !this.state.searchMore
  337. });
  338. },
  339. search() {
  340. this.loadData();
  341. },
  342. reset() {
  343. this.state.province = undefined;
  344. this.state.unitName = undefined;
  345. this.state.copyrightName = undefined;
  346. this.state.status = undefined;
  347. this.state.createTime = [];
  348. this.state.acceptTime = [];
  349. this.state.authTime = [];
  350. this.loadData();
  351. },
  352. render() {
  353. const rowSelection = {
  354. selectedRowKeys: this.state.selectedRowKeys,
  355. onChange: (selectedRowKeys, selectedRows) => {
  356. this.setState({
  357. selectedRows: selectedRows,
  358. selectedRowKeys: selectedRowKeys
  359. });
  360. }
  361. };
  362. const hasSelected = this.state.selectedRowKeys.length > 0;
  363. const { MonthPicker, RangePicker } = DatePicker;
  364. return (
  365. <div className="foster-box">
  366. <div className="foster-content">
  367. <div className="content-title">
  368. <span>软著申请管理</span>
  369. <PatentAdd
  370. companyOption={this.state.companyOption}
  371. onClick={this.addClick}
  372. closeAdd={this.closeAdd} />
  373. </div>
  374. <div className="foster-query">
  375. <Select placeholder="选择省份"
  376. style={{ width: 100 }}
  377. value={this.state.province}
  378. showSearch
  379. filterOption={companySearch}
  380. onChange={(e) => { this.setState({ province: e }) }}>
  381. {this.state.provinceOption}
  382. </Select>
  383. <Select placeholder="选择公司"
  384. style={{ width: 200 }}
  385. value={this.state.unitName}
  386. showSearch
  387. filterOption={companySearch}
  388. onChange={(e) => { this.setState({ unitName: e }) }}>
  389. {this.state.companyOption}
  390. </Select>
  391. <Input style={{ width: 160 }}
  392. placeholder="请输入软著名称"
  393. value={this.state.copyrightName}
  394. onChange={(e) => { this.setState({ copyrightName: e.target.value }); }} />
  395. <Select style={{ width: 120 }}
  396. value={this.state.status}
  397. onChange={(e) => { this.setState({ status: e }) }}
  398. placeholder="选择一个状态">{this.state.stateOption}</Select>
  399. <span>更多搜索 <Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  400. <Button type="primary" onClick={this.search}>搜索</Button>
  401. <Button onClick={this.reset}>重置</Button>
  402. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  403. disabled={!hasSelected}
  404. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  405. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  406. <span>派单时间:</span>
  407. <RangePicker style={{ width: '240px' }}
  408. allowClear={false}
  409. value={[this.state.createTime[0] ? moment(this.state.createTime[0]) : null,
  410. this.state.createTime[1] ? moment(this.state.createTime[1]) : null]}
  411. onChange={(date, dateString) => { this.setState({ createTime: dateString }) }} />
  412. <span>受理时间:</span>
  413. <RangePicker style={{ width: '240px' }}
  414. allowClear={false}
  415. value={[this.state.acceptTime[0] ? moment(this.state.acceptTime[0]) : null,
  416. this.state.acceptTime[1] ? moment(this.state.acceptTime[1]) : null]}
  417. onChange={(date, dateString) => { this.setState({ acceptTime: dateString }) }} />
  418. <span>下证时间:</span>
  419. <RangePicker style={{ width: '240px' }}
  420. allowClear={false}
  421. value={[this.state.authTime[0] ? moment(this.state.authTime[0]) : null,
  422. this.state.authTime[1] ? moment(this.state.authTime[1]) : null]}
  423. onChange={(date, dateString) => { this.setState({ authTime: dateString }) }} />
  424. </div>
  425. </div>
  426. <div className="foster-table">
  427. <Spin spinning={this.state.loading}>
  428. <Table columns={this.state.columns}
  429. rowSelection={rowSelection}
  430. dataSource={this.state.dataSource}
  431. pagination={this.state.pagination}
  432. onRowClick={this.tableRowClick} />
  433. </Spin>
  434. </div>
  435. <PatentChange
  436. data={this.state.RowData}
  437. authorOption={this.state.authorOption}
  438. showDesc={this.state.showDesc}
  439. closeDesc={this.closeDesc} />
  440. </div >
  441. </div>
  442. );
  443. }
  444. });
  445. export default copyright;