copyright.jsx 17 KB

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