copyright.jsx 18 KB

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