index.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. import React, { Component } from 'react';
  2. import { AutoComplete, Button, DatePicker, Input, message, Select, Spin, Table, Tabs } from "antd";
  3. import {
  4. ShowModal,
  5. } from "@/tools";
  6. import { ChooseList } from "../../order/orderNew/chooseList";
  7. import $ from "jquery/src/ajax";
  8. import './index.less';
  9. import moment from "moment";
  10. import DetailedList from './detailedList';
  11. import { object } from "prop-types";
  12. const { TabPane } = Tabs;
  13. const { RangePicker } = DatePicker;
  14. class ProjecCount extends Component {
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. pageNo: 1,
  19. loading: false,
  20. changeList: undefined,
  21. columns: [
  22. {
  23. title: "编号",
  24. dataIndex: "key",
  25. key: "key",
  26. },
  27. {
  28. title: "公出人员",
  29. dataIndex: "name",
  30. key: "name",
  31. },
  32. {
  33. title: "公出次数",
  34. dataIndex: "tg",
  35. key: "tg",
  36. className: 'projectTable',
  37. onCellClick: (record, event) => {
  38. event.stopPropagation();
  39. this.setState({
  40. status: 2,
  41. visible: true,
  42. aid: record.aid,
  43. title: '公出次数',
  44. aName: record.name,
  45. })
  46. }
  47. },
  48. {
  49. title: "总时长(时)",
  50. dataIndex: "duration",
  51. key: "duration",
  52. className: 'projectTable',
  53. onCellClick: (record, event) => {
  54. event.stopPropagation();
  55. this.setState({
  56. status: 2,
  57. visible: true,
  58. aid: record.aid,
  59. title: '总时长(时)',
  60. aName: record.name,
  61. })
  62. }
  63. },
  64. {
  65. title: "未审核次数",
  66. dataIndex: "wsh",
  67. key: "wsh",
  68. className: 'projectTable',
  69. onCellClick: (record, event) => {
  70. event.stopPropagation();
  71. this.setState({
  72. status: 1,
  73. visible: true,
  74. aid: record.aid,
  75. title: '未审核次数',
  76. aName: record.name,
  77. })
  78. }
  79. },
  80. {
  81. title: "驳回次数",
  82. dataIndex: "bh",
  83. key: "bh",
  84. className: 'projectTable',
  85. onCellClick: (record, event) => {
  86. event.stopPropagation();
  87. this.setState({
  88. status: 0,
  89. visible: true,
  90. aid: record.aid,
  91. title: '驳回次数',
  92. aName: record.name,
  93. })
  94. }
  95. },
  96. {
  97. title: "已打卡次数",
  98. dataIndex: "dk",
  99. key: "dk",
  100. className: 'projectTable',
  101. onCellClick: (record, event) => {
  102. event.stopPropagation();
  103. this.setState({
  104. status: undefined,
  105. clockIn: 1,
  106. visible: true,
  107. aid: record.aid,
  108. title: '已打卡次数',
  109. aName: record.name,
  110. })
  111. }
  112. },
  113. ],
  114. pagination: {
  115. defaultCurrent: 1,
  116. defaultPageSize: 10,
  117. showQuickJumper: true,
  118. pageSize: 10,
  119. onChange: function (page) {
  120. this.loadData(page);
  121. }.bind(this),
  122. showTotal: function (total) {
  123. return "共" + total + "条数据";
  124. }
  125. },
  126. dataSource: [],
  127. releaseDate: [],
  128. createReleaseDate: [],
  129. superId: undefined,
  130. clockIn: 0,
  131. }
  132. this.loadData = this.loadData.bind(this);
  133. this.resetAll = this.resetAll.bind(this);
  134. this.changeList = this.changeList.bind(this);
  135. this.selectSuperId = this.selectSuperId.bind(this);
  136. this.supervisor = this.supervisor.bind(this);
  137. this.httpChange = this.httpChange.bind(this);
  138. this.blurChange = this.blurChange.bind(this);
  139. this.selectAuto = this.selectAuto.bind(this);
  140. this.exportExec = this.exportExec.bind(this);
  141. }
  142. //获取上级组织
  143. selectSuperId() {
  144. $.ajax({
  145. method: "get",
  146. dataType: "json",
  147. crossDomain: false,
  148. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  149. data: {},
  150. success: function (data) {
  151. let theArr = [];
  152. if (data.error && data.error.length === 0) {
  153. for (let i = 0; i < data.data.length; i++) {
  154. let theData = data.data[i];
  155. theArr.push(
  156. <Select.Option value={theData.id} key={theData.id}>{theData.name}</Select.Option>
  157. );
  158. };
  159. this.setState({
  160. contactsOption: theArr,
  161. });
  162. } else {
  163. message.warning(data.error[0].message);
  164. }
  165. }.bind(this),
  166. }).always(function () {
  167. this.setState({
  168. loading: false
  169. });
  170. }.bind(this));
  171. }
  172. changeList(arr) {
  173. const newArr = [];
  174. this.state.columns.forEach(item => {
  175. arr.forEach(val => {
  176. if (val === item.title) {
  177. newArr.push(item);
  178. }
  179. });
  180. });
  181. this.setState({
  182. changeList: newArr
  183. });
  184. }
  185. loadData(pageNo) {
  186. this.setState({
  187. loading: true
  188. })
  189. $.ajax({
  190. method: "get",
  191. dataType: "json",
  192. crossDomain: false,
  193. url: globalConfig.context + "/api/admin/release/publicReleaseStatistics",
  194. data: {
  195. pageNo: pageNo || 1,
  196. pageSize: this.state.pagination.pageSize,
  197. clockStart: this.state.releaseDate[0] || undefined,
  198. clockEnd: this.state.releaseDate[1] || undefined,
  199. createStart: this.state.createReleaseDate[0] || undefined,
  200. createEnd: this.state.createReleaseDate[1] || undefined,
  201. depId: this.state.superId || undefined,
  202. aid: this.state.theTypes || undefined,
  203. },
  204. success: function (data) {
  205. ShowModal(this);
  206. this.setState({
  207. loading: false
  208. })
  209. let theArr = [];
  210. if (data.error && data.error.length === 0) {
  211. for (let i = 0; i < data.data.list.length; i++) {
  212. let thisdata = data.data.list[i];
  213. thisdata.key = (data.data.pageNo - 1) * data.data.pageSize + i + 1;
  214. theArr.push(thisdata);
  215. }
  216. this.state.pagination.current = data.data.pageNo;
  217. this.state.pagination.total = data.data.totalCount;
  218. if (data.data && data.data.list && !data.data.list.length) {
  219. this.state.pagination.current = 0;
  220. this.state.pagination.total = 0;
  221. }
  222. this.setState({
  223. dataSource: theArr,
  224. pagination: this.state.pagination,
  225. pageNo: data.data.pageNo
  226. });
  227. } else {
  228. message.warning(data.error[0].message);
  229. }
  230. }.bind(this)
  231. }).always(
  232. function () {
  233. this.setState({
  234. loading: false
  235. });
  236. }.bind(this)
  237. );
  238. }
  239. resetAll() {
  240. this.setState({
  241. releaseDate: [],
  242. createReleaseDate: [],
  243. superId: undefined,
  244. theTypes: undefined,
  245. auto: ''
  246. }, () => {
  247. this.loadData();
  248. })
  249. }
  250. supervisor(e) {
  251. $.ajax({
  252. method: "get",
  253. dataType: "json",
  254. crossDomain: false,
  255. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  256. data: {
  257. adminName: e,
  258. },
  259. success: function (data) {
  260. let thedata = data.data;
  261. if (!thedata) {
  262. if (data.error && data.error.length) {
  263. message.warning(data.error[0].message);
  264. }
  265. thedata = {};
  266. }
  267. this.setState({
  268. customerArr: thedata,
  269. });
  270. }.bind(this),
  271. }).always(
  272. function () {
  273. }.bind(this)
  274. );
  275. }
  276. httpChange(e) {
  277. if (e.length >= 1) {
  278. this.supervisor(e);
  279. }
  280. this.setState({
  281. auto: e,
  282. });
  283. }
  284. selectAuto(value, options) {
  285. this.setState({
  286. auto: value,
  287. });
  288. }
  289. blurChange(e) {
  290. let theType = "";
  291. let contactLists = this.state.customerArr || [];
  292. if (e) {
  293. contactLists.map(function (item) {
  294. if (item.name == e.toString()) {
  295. theType = item.id;
  296. }
  297. });
  298. }
  299. this.setState({
  300. theTypes: theType,
  301. });
  302. }
  303. componentWillMount() {
  304. this.loadData();
  305. this.selectSuperId();
  306. }
  307. // 导出
  308. exportExec() {
  309. //debugger
  310. let data = {
  311. clockStart: this.state.releaseDate[0],
  312. clockEnd: this.state.releaseDate[1],
  313. createStart: this.state.createReleaseDate[0],
  314. createEnd: this.state.createReleaseDate[1],
  315. depId: this.state.superId,
  316. aid: this.state.theTypes
  317. };
  318. for (let i of Object.keys(data)) {
  319. if (!data[i]) {
  320. delete data[i]
  321. }
  322. }
  323. window.location.href =
  324. globalConfig.context +
  325. "/api/admin/release/publicReleaseStatistics/export?" +
  326. $.param(data);
  327. }
  328. render() {
  329. const dataSources = this.state.customerArr || [];
  330. const options = dataSources.map((group) => (
  331. <Select.Option key={group.id} value={group.name}>
  332. {group.name}
  333. </Select.Option>
  334. ));
  335. return (
  336. <div className="user-content">
  337. <div className="content-title">
  338. <span>
  339. 公出统计
  340. </span>
  341. </div>
  342. <Tabs defaultActiveKey="1" className="test">
  343. <TabPane tab="搜索" key="1">
  344. <div className="user-search" style={{
  345. marginTop: '10px',
  346. marginLeft: '10px',
  347. marginRight: '10px'
  348. }}>
  349. <span style={{ marginRight: "10px" }}>
  350. <Select
  351. placeholder="请选择部门"
  352. style={{ width: 200, marginLeft: 10 }}
  353. value={this.state.superId}
  354. onChange={(e) => { this.setState({ superId: e }) }}
  355. notFoundContent="未获取到上级组织列表">
  356. {this.state.contactsOption}
  357. </Select>
  358. </span>
  359. <span style={{ marginRight: "10px" }}>
  360. <AutoComplete
  361. className="certain-category-search"
  362. dropdownClassName="certain-category-search-dropdown"
  363. dropdownMatchSelectWidth={false}
  364. style={{ width: "120px" }}
  365. dataSource={options}
  366. placeholder='输入公出申请人'
  367. value={this.state.auto}
  368. onChange={this.httpChange}
  369. filterOption={true}
  370. onBlur={this.blurChange}
  371. onSelect={this.selectAuto}
  372. >
  373. <Input />
  374. </AutoComplete>
  375. </span>
  376. <span style={{ marginRight: "10px" }}>
  377. <span style={{ marginRight: '10px', marginBottom: '10px' }}>打卡时间 :</span>
  378. <RangePicker
  379. style={{ marginRight: '10px', marginBottom: '10px' }}
  380. value={[
  381. this.state.releaseDate[0]
  382. ? moment(this.state.releaseDate[0])
  383. : null,
  384. this.state.releaseDate[1]
  385. ? moment(this.state.releaseDate[1])
  386. : null,
  387. ]}
  388. onChange={(data, dataString) => {
  389. this.setState({ releaseDate: dataString });
  390. }}
  391. />
  392. </span>
  393. <span style={{ marginRight: "10px" }}>
  394. <span style={{ marginRight: '10px', marginBottom: '10px' }}>创建时间 :</span>
  395. <RangePicker
  396. style={{ marginRight: '10px', marginBottom: '10px' }}
  397. value={[
  398. this.state.createReleaseDate[0]
  399. ? moment(this.state.createReleaseDate[0])
  400. : null,
  401. this.state.createReleaseDate[1]
  402. ? moment(this.state.createReleaseDate[1])
  403. : null,
  404. ]}
  405. onChange={(data, dataString) => {
  406. this.setState({ createReleaseDate: dataString });
  407. }}
  408. />
  409. </span>
  410. <Button type="primary" onClick={() => {
  411. this.loadData();
  412. }} style={{ marginRight: '10px', marginBottom: '10px' }}>搜索</Button>
  413. <Button onClick={this.resetAll} style={{ marginRight: '10px', marginBottom: '10px' }}>重置</Button>
  414. </div>
  415. </TabPane>
  416. <TabPane tab="更改表格显示数据" key="2">
  417. <div style={{ marginLeft: 10 }}>
  418. <ChooseList
  419. columns={this.state.columns}
  420. changeFn={this.changeList}
  421. changeList={this.state.changeList}
  422. top={55}
  423. margin={11}
  424. />
  425. </div>
  426. </TabPane>
  427. <TabPane tab="导出" key="3">
  428. <div style={{ float: "left" }}>
  429. <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
  430. </div>
  431. </TabPane>
  432. </Tabs>
  433. <div className="patent-table">
  434. <Spin spinning={this.state.loading}>
  435. <Table
  436. bordered
  437. size="middle"
  438. scroll={{ x: 800, y: 0 }}
  439. columns={
  440. this.state.changeList
  441. ? this.state.changeList
  442. : this.state.columns
  443. }
  444. dataSource={this.state.dataSource}
  445. pagination={this.state.pagination}
  446. />
  447. </Spin>
  448. </div>
  449. {this.state.visible &&
  450. <DetailedList
  451. status={this.state.status}
  452. title={this.state.title}
  453. aid={this.state.aid}
  454. aName={this.state.aName}
  455. depId={this.state.depId}
  456. createReleaseDate={this.state.createReleaseDate}
  457. releaseDate={this.state.releaseDate}
  458. clockIn={this.state.clockIn || undefined}
  459. visible={this.state.visible}
  460. onCancel={() => {
  461. this.setState({
  462. visible: false,
  463. clockIn: 0,
  464. })
  465. }}
  466. />
  467. }
  468. </div>
  469. )
  470. }
  471. }
  472. export default ProjecCount;