index.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. import React, { Component } from "react";
  2. import {
  3. AutoComplete,
  4. Button,
  5. DatePicker,
  6. Input,
  7. message,
  8. Select,
  9. Spin,
  10. Table,
  11. Tabs,
  12. } from "antd";
  13. import { ShowModal } from "@/tools";
  14. import { ChooseList } from "../../order/orderNew/chooseList";
  15. import $ from "jquery/src/ajax";
  16. import "./index.less";
  17. import moment from "moment";
  18. import Cascaders from "../../../common/cascaders";
  19. import { assistTypeOptions, assistContentOptions } from "../../../dataDic"
  20. const { TabPane } = Tabs;
  21. const { RangePicker } = DatePicker;
  22. const ALL_TYPE = {
  23. 0: '公出协单',
  24. 1: '非公出协单'
  25. }
  26. class NoPublicStatistics extends Component {
  27. constructor(props) {
  28. super(props);
  29. this.state = {
  30. pageNo: 1,
  31. loading: false,
  32. changeList: undefined,
  33. columns: [
  34. {
  35. title: "序号",
  36. dataIndex: "key",
  37. key: "key",
  38. width: 45,
  39. },
  40. {
  41. title: "协单类型",
  42. dataIndex: "type",
  43. key: "type",
  44. width: 80,
  45. },
  46. {
  47. title: "内容",
  48. dataIndex: "content",
  49. key: "content",
  50. width: 140,
  51. },
  52. {
  53. title: "发起人员",
  54. dataIndex: "aname",
  55. key: "aname",
  56. width: 75,
  57. },
  58. {
  59. title: "协单人员",
  60. dataIndex: "assistAidName",
  61. key: "assistAidName",
  62. width: 120,
  63. },
  64. {
  65. title: "客户名称",
  66. dataIndex: "userNames",
  67. key: "userNames",
  68. width: 140,
  69. },
  70. {
  71. title: "签单次数",
  72. dataIndex: "signNumber",
  73. key: "signNumber",
  74. width: 70,
  75. textAlign: 'center'
  76. },
  77. {
  78. title: "公出次数(累计数)",
  79. dataIndex: "publicCount",
  80. key: "publicCount",
  81. width: 80,
  82. },
  83. {
  84. title: "协单数总数/协单/非公出协单",
  85. dataIndex: "xdcs",
  86. key: "xdcs",
  87. width: 95,
  88. render(text, record) {
  89. let assistCEle = <span>{ record.assistCount }</span>
  90. if ( record.assistCount > 5 ) {
  91. assistCEle = <span style={{ color: 'red' }}>{ record.assistCount }</span>
  92. }
  93. return <div>
  94. { assistCEle }
  95. <span>/{ record.publicAssistCount }</span>
  96. <span>/{ record.nonPublicCount }</span>
  97. </div>
  98. },
  99. },
  100. {
  101. title: "协单时间",
  102. dataIndex: "releaseStart",
  103. key: "releaseStart ",
  104. width: 140,
  105. },
  106. {
  107. title: "协单项目",
  108. dataIndex: "assistType",
  109. key: "assistType",
  110. width: 260,
  111. },
  112. {
  113. title: "已签项目",
  114. dataIndex: "taskNames",
  115. key: "taskNames ",
  116. minWidth: 300,
  117. },
  118. ],
  119. pagination: {
  120. defaultCurrent: 1,
  121. defaultPageSize: 10,
  122. showQuickJumper: true,
  123. pageSize: 10,
  124. onChange: function (page) {
  125. this.loadData(page);
  126. }.bind(this),
  127. showTotal: function (total) {
  128. return "共" + total + "条数据";
  129. },
  130. },
  131. dataSource: [],
  132. type: undefined, // 协单类型
  133. contentType: [], // 协单内容
  134. assistType: [], // 协单项目类型
  135. releaseDate: [moment(Date.now() - 777600000).format('YYYY-MM-DD'), moment(Date.now()).format('YYYY-MM-DD')],
  136. deptId: undefined, // 公出部门
  137. theTypes: undefined,
  138. theTypes1: undefined,
  139. theCustomerTypes: undefined,
  140. assistCount: undefined, // 协单总数
  141. };
  142. this.loadData = this.loadData.bind(this);
  143. this.resetAll = this.resetAll.bind(this);
  144. this.changeList = this.changeList.bind(this);
  145. this.httpChange = this.httpChange.bind(this);
  146. this.blurChange = this.blurChange.bind(this);
  147. this.selectAuto = this.selectAuto.bind(this);
  148. this.httpChange1 = this.httpChange1.bind(this);
  149. this.blurChange1 = this.blurChange1.bind(this);
  150. this.selectAuto1 = this.selectAuto1.bind(this);
  151. this.getCustomer = this.getCustomer.bind(this);
  152. this.selectCustomerAuto = this.selectCustomerAuto.bind(this);
  153. this.httpCustomerChange = this.httpCustomerChange.bind(this);
  154. this.blurCustomerChange = this.blurCustomerChange.bind(this);
  155. this.exportExec = this.exportExec.bind(this);
  156. }
  157. changeList(arr) {
  158. const newArr = [];
  159. this.state.columns.forEach((item) => {
  160. arr.forEach((val) => {
  161. if (val === item.title) {
  162. newArr.push(item);
  163. }
  164. });
  165. });
  166. this.setState({
  167. changeList: newArr,
  168. });
  169. }
  170. getSearchParams() {
  171. const { type, contentType, assistType, theTypes, theTypes1, deptId, releaseDate, assistCount } = this.state
  172. return {
  173. type,
  174. contentType: contentType && contentType.length ? contentType.join(',') : undefined,
  175. assistType: assistType && assistType.length ? assistType.join(',') : undefined,
  176. aid: theTypes || undefined, // 公出人员
  177. assistAid: theTypes1 || undefined, // 协单人员
  178. deptId,
  179. startTime: releaseDate[0] || undefined,
  180. endTime: releaseDate[1] || undefined,
  181. assistCount,
  182. }
  183. }
  184. loadData(pageNo) {
  185. this.setState({
  186. loading: true,
  187. });
  188. const paramsData = Object.assign({
  189. pageNo: pageNo || 1,
  190. pageSize: this.state.pagination.pageSize
  191. }, this.getSearchParams())
  192. $.ajax({
  193. method: "get",
  194. dataType: "json",
  195. crossDomain: false,
  196. url: globalConfig.context + "/api/admin/release/listAssist",
  197. data: paramsData,
  198. success: function (data) {
  199. ShowModal(this);
  200. let theArr = [];
  201. this.setState({
  202. loading: false,
  203. });
  204. if (data.error && data.error.length === 0) {
  205. for (let i = 0; i < data.data.list.length; i++) {
  206. let thisdata = data.data.list[i];
  207. thisdata.key = (data.data.pageNo - 1) * data.data.pageSize + i + 1;
  208. theArr.push(thisdata);
  209. }
  210. this.state.pagination.current = data.data.pageNo;
  211. this.state.pagination.total = data.data.totalCount;
  212. if (data.data && data.data.list && !data.data.list.length) {
  213. this.state.pagination.current = 0;
  214. this.state.pagination.total = 0;
  215. }
  216. this.setState({
  217. dataSource: theArr,
  218. pagination: this.state.pagination,
  219. pageNo: data.data.pageNo,
  220. });
  221. } else {
  222. message.warning(data.error[0].message);
  223. }
  224. }.bind(this),
  225. }).always(
  226. function () {
  227. this.setState({
  228. loading: false,
  229. });
  230. }.bind(this)
  231. );
  232. }
  233. resetAll() {
  234. this.setState(
  235. {
  236. releaseDate: [moment(Date.now() - 777600000).format('YYYY-MM-DD'), moment(Date.now()).format('YYYY-MM-DD')],
  237. type: undefined,
  238. contentType: [],
  239. assistType: [],
  240. theTypes: undefined,
  241. theTypes1: undefined,
  242. deptId: undefined,
  243. assistCount: undefined
  244. },
  245. () => {
  246. this.Cascaders.empty();
  247. this.loadData();
  248. }
  249. );
  250. }
  251. getSupervisorList(e, succCallback) {
  252. $.ajax({
  253. method: "get",
  254. dataType: "json",
  255. crossDomain: false,
  256. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  257. data: {
  258. adminName: e,
  259. status: "2",
  260. },
  261. success: function (data) {
  262. if (data.error && data.error.length === 0) {
  263. succCallback && succCallback(data.data)
  264. } else {
  265. message.warning(data.error[0].message);
  266. }
  267. }.bind(this),
  268. });
  269. }
  270. httpChange(e) {
  271. if (e.length >= 1) {
  272. this.getSupervisorList(e, (data) => {
  273. this.setState({
  274. customerArr: data
  275. })
  276. })
  277. }
  278. this.setState({
  279. auto: e,
  280. });
  281. }
  282. httpChange1(e) {
  283. if (e.length >= 1) {
  284. this.getSupervisorList(e, (data) => {
  285. this.setState({
  286. customerArr1: data
  287. })
  288. })
  289. }
  290. this.setState({
  291. auto1: e,
  292. });
  293. }
  294. selectAuto(value, options) {
  295. this.setState({
  296. auto: value,
  297. });
  298. }
  299. selectAuto1(value, options) {
  300. this.setState({
  301. auto1: value,
  302. });
  303. }
  304. httpCustomerChange(e) {
  305. if (e.length >= 1) {
  306. this.getCustomer(e);
  307. }
  308. this.setState({
  309. customer: e,
  310. });
  311. }
  312. selectCustomerAuto(value, options) {
  313. this.setState({
  314. customer: value,
  315. });
  316. }
  317. getCustomer(e) {
  318. $.ajax({
  319. method: "get",
  320. dataType: "json",
  321. crossDomain: false,
  322. url: globalConfig.context + "/api/admin/customer/getUserByName",
  323. data: {
  324. name: e,
  325. },
  326. success: function (data) {
  327. if (data.error && data.error.length === 0) {
  328. this.setState({
  329. customerList: data.data,
  330. });
  331. } else {
  332. message.warning(data.error[0].message);
  333. }
  334. }.bind(this),
  335. });
  336. }
  337. findDataIdByName(e, list = []) {
  338. if (list && list.length) {
  339. return list.find(item => item.name == e.toString()).id
  340. }
  341. return
  342. }
  343. blurCustomerChange(e) {
  344. const { contactLists } = this.state
  345. this.setState({
  346. theCustomerTypes: this.findDataIdByName.bind(this, e, contactLists),
  347. });
  348. }
  349. blurChange(e) {
  350. const { customerArr } = this.state
  351. this.setState({
  352. theTypes: this.findDataIdByName.bind(this, e, customerArr),
  353. });
  354. }
  355. blurChange1(e) {
  356. const { customerArr1 } = this.state
  357. this.setState({
  358. theTypes1: this.findDataIdByName.bind(this, e, customerArr1),
  359. });
  360. }
  361. componentWillMount() {
  362. this.loadData();
  363. }
  364. exportExec() {
  365. this.setState({
  366. exportPendingLoading: true,
  367. });
  368. message.config({
  369. duration: 20,
  370. });
  371. let loading = message.loading("下载中...");
  372. const paramsData = this.getSearchParams()
  373. let newParams = {}
  374. Object.keys(paramsData).map(key => {
  375. if (paramsData[key]) {
  376. newParams[key] = paramsData[key]
  377. }
  378. })
  379. $.ajax({
  380. method: "get",
  381. dataType: "json",
  382. crossDomain: false,
  383. url:
  384. globalConfig.context + "/api/admin/release/listAssistExprot",
  385. data: newParams,
  386. success: function (data) {
  387. if (data.error.length === 0) {
  388. this.download(data.data);
  389. } else {
  390. message.warning(data.error[0].message);
  391. }
  392. }.bind(this),
  393. }).always(
  394. function () {
  395. loading();
  396. this.setState({
  397. exportPendingLoading: false,
  398. });
  399. }.bind(this)
  400. );
  401. }
  402. download(fileName) {
  403. window.location.href =
  404. globalConfig.context + "/open/download?fileName="+fileName;
  405. }
  406. render() {
  407. const dataSources = this.state.customerArr || [];
  408. const dataSources1 = this.state.customerArr1 || [];
  409. const options = dataSources.map((group) => (
  410. <Select.Option key={group.id} value={group.name}>
  411. {group.name}
  412. </Select.Option>
  413. ));
  414. const options1 = dataSources1.map((group) => (
  415. <Select.Option key={group.id} value={group.name}>
  416. {group.name}
  417. </Select.Option>
  418. ));
  419. const customerList = this.state.customerList || [];
  420. const customerOptions = customerList.map((group) => (
  421. <Select.Option key={group.id} value={group.name}>
  422. {group.name}
  423. </Select.Option>
  424. ));
  425. return (
  426. <div>
  427. <div className="user-content">
  428. <div className="content-title">
  429. <span>协单统计</span>
  430. </div>
  431. <Tabs defaultActiveKey="1" className="test">
  432. <TabPane tab="搜索" key="1">
  433. <div
  434. className="user-search"
  435. style={{
  436. marginTop: "10px",
  437. marginLeft: "10px",
  438. marginRight: "10px",
  439. }}
  440. >
  441. <span>
  442. <Select
  443. placeholder="全部协单类型"
  444. style={{ width: 120 }}
  445. value={this.state.type}
  446. onChange={(e) => {
  447. this.setState({ type: e });
  448. }}
  449. >
  450. {
  451. Object.keys(ALL_TYPE).map(key =>
  452. <Select.Option value={key}>{ ALL_TYPE[key] }</Select.Option>
  453. )
  454. }
  455. </Select>
  456. </span>
  457. <span>
  458. <Select
  459. placeholder="请选择协单内容"
  460. style={{ width: 120 }}
  461. value={this.state.contentType}
  462. onChange={(e) => {
  463. this.setState({ contentType: e });
  464. }}
  465. multiple
  466. >
  467. {
  468. assistContentOptions.map(item =>
  469. <Select.Option value={item.value}>{item.label}</Select.Option>
  470. )
  471. }
  472. </Select>
  473. </span>
  474. <span>
  475. <AutoComplete
  476. className="certain-category-search"
  477. dropdownClassName="certain-category-search-dropdown"
  478. dropdownMatchSelectWidth={false}
  479. style={{ width: "120px" }}
  480. dataSource={options}
  481. placeholder="输入公出发起人"
  482. value={this.state.auto}
  483. onChange={this.httpChange}
  484. filterOption={true}
  485. onBlur={this.blurChange}
  486. onSelect={this.selectAuto}
  487. >
  488. <Input />
  489. </AutoComplete>
  490. </span>
  491. <span>
  492. <AutoComplete
  493. className="certain-category-search"
  494. dropdownClassName="certain-category-search-dropdown"
  495. dropdownMatchSelectWidth={false}
  496. style={{ width: "120px" }}
  497. dataSource={options1}
  498. placeholder="输入协单人员"
  499. value={this.state.auto1}
  500. onChange={this.httpChange1}
  501. filterOption={true}
  502. onBlur={this.blurChange1}
  503. onSelect={this.selectAuto1}
  504. >
  505. <Input />
  506. </AutoComplete>
  507. </span>
  508. <span>
  509. <AutoComplete
  510. className="certain-category-search"
  511. dropdownClassName="certain-category-search-dropdown"
  512. dropdownMatchSelectWidth={false}
  513. style={{ width: "160px" }}
  514. dataSource={customerOptions}
  515. placeholder="输入客户名称"
  516. value={this.state.customer}
  517. onChange={this.httpCustomerChange}
  518. filterOption={true}
  519. onBlur={this.blurCustomerChange}
  520. onSelect={this.selectCustomerAuto}
  521. >
  522. <Input />
  523. </AutoComplete>
  524. </span>
  525. <span>
  526. <Select
  527. placeholder="请选择协单项目"
  528. style={{ width: 180 }}
  529. value={this.state.assistType}
  530. onChange={(e) => {
  531. this.setState({ assistType: e });
  532. }}
  533. multiple
  534. >
  535. {
  536. assistTypeOptions.map(item =>
  537. <Select.Option value={item.value}>{item.label}</Select.Option>
  538. )
  539. }
  540. </Select>
  541. </span>
  542. <span style={{ marginRight: "10px" }}>
  543. <span style={{ marginRight: "5px", marginBottom: "10px" }}>
  544. 协单时间:
  545. </span>
  546. <RangePicker
  547. allowClear={window.adminData.shiroList.indexOf("11") == -1}
  548. disabledDate={(current) => {//“运营管理”角色只能查看部分时间段(暂时10天)的数据
  549. let iskeep = window.adminData.shiroList.indexOf("11") != -1
  550. return iskeep && current && current.valueOf() < Date.now() - 864000000;
  551. }}
  552. style={{ marginRight: "10px", marginBottom: "10px", width: 200 }}
  553. value={[
  554. this.state.releaseDate[0]
  555. ? moment(this.state.releaseDate[0])
  556. : null,
  557. this.state.releaseDate[1]
  558. ? moment(this.state.releaseDate[1])
  559. : null,
  560. ]}
  561. onChange={(data, dataString) => {
  562. this.setState({ releaseDate: dataString });
  563. }}
  564. />
  565. </span>
  566. <Cascaders
  567. ref={node => this.Cascaders = node}
  568. placeholder="请选择公出部门"
  569. id="id"
  570. name="name"
  571. children="list"
  572. height={28}
  573. onSel={(e) => {
  574. this.setState({
  575. deptId: JSON.stringify(e),
  576. });
  577. }}
  578. />
  579. <span>
  580. <Select
  581. placeholder="请选择协单总数"
  582. style={{ width: 120 }}
  583. value={this.state.assistCount}
  584. onChange={(e) => {
  585. this.setState({ assistCount: e });
  586. }}
  587. >
  588. <Select.Option value={1}>小于5</Select.Option>
  589. <Select.Option value={2}>5-9</Select.Option>
  590. <Select.Option value={3}>10-14</Select.Option>
  591. <Select.Option value={4}>大于14</Select.Option>
  592. </Select>
  593. </span>
  594. <Button
  595. type="primary"
  596. onClick={() => {
  597. this.loadData();
  598. }}
  599. style={{ marginRight: "10px", marginBottom: "10px" }}
  600. >
  601. 搜索
  602. </Button>
  603. <Button
  604. onClick={this.resetAll}
  605. style={{ marginRight: "10px", marginBottom: "10px" }}
  606. >
  607. 重置
  608. </Button>
  609. </div>
  610. </TabPane>
  611. <TabPane tab="更改表格显示数据" key="2">
  612. <div style={{ marginLeft: 10 }}>
  613. <Spin spinning={this.state.loading}>
  614. <ChooseList
  615. columns={this.state.columns}
  616. changeFn={this.changeList}
  617. changeList={this.state.changeList}
  618. top={55}
  619. margin={11}
  620. />
  621. </Spin>
  622. </div>
  623. </TabPane>
  624. <TabPane tab="导出" key="3">
  625. <div style={{ float: "left" }}>
  626. <Button
  627. loading={this.state.exportPendingLoading}
  628. onClick={this.exportExec}
  629. style={{ margin: 10 }}
  630. >
  631. 导出excel
  632. </Button>
  633. </div>
  634. </TabPane>
  635. </Tabs>
  636. <div className="patent-table">
  637. <Spin spinning={this.state.loading}>
  638. <Table
  639. bordered
  640. size="middle"
  641. columns={
  642. this.state.changeList
  643. ? this.state.changeList
  644. : this.state.columns
  645. }
  646. dataSource={this.state.dataSource}
  647. pagination={this.state.pagination}
  648. />
  649. </Spin>
  650. </div>
  651. </div>
  652. </div>
  653. );
  654. }
  655. }
  656. export default NoPublicStatistics;