index.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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:[],
  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
  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. exportExec(){
  308. let data = {
  309. clockStart:this.state.releaseDate[0],
  310. clockEnd:this.state.releaseDate[1],
  311. createStart:this.state.createReleaseDate[0],
  312. createEnd:this.state.createReleaseDate[1],
  313. depId:this.state.superId,
  314. aid:this.state.theTypes
  315. };
  316. for(let i of Object.keys(data)){
  317. if(!data[i]){
  318. delete data[i]
  319. }
  320. }
  321. window.location.href =
  322. globalConfig.context +
  323. "/api/admin/release/publicReleaseStatistics/export?" +
  324. $.param(data);
  325. }
  326. render() {
  327. const dataSources = this.state.customerArr || [];
  328. const options = dataSources.map((group) => (
  329. <Select.Option key={group.id} value={group.name}>
  330. {group.name}
  331. </Select.Option>
  332. ));
  333. return (
  334. <div className="user-content">
  335. <div className="content-title">
  336. <span>
  337. 公出统计
  338. </span>
  339. </div>
  340. <Tabs defaultActiveKey="1" className="test">
  341. <TabPane tab="搜索" key="1">
  342. <div className="user-search" style={{
  343. marginTop:'10px',
  344. marginLeft:'10px',
  345. marginRight:'10px'
  346. }}>
  347. <span style={{ marginRight: "10px" }}>
  348. <Select
  349. placeholder="请选择部门"
  350. style={{ width:200,marginLeft:10}}
  351. value={this.state.superId}
  352. onChange={(e) => { this.setState({ superId: e }) }}
  353. notFoundContent="未获取到上级组织列表">
  354. {this.state.contactsOption}
  355. </Select>
  356. </span>
  357. <span style={{ marginRight: "10px" }}>
  358. <AutoComplete
  359. className="certain-category-search"
  360. dropdownClassName="certain-category-search-dropdown"
  361. dropdownMatchSelectWidth={false}
  362. style={{ width: "120px" }}
  363. dataSource={options}
  364. placeholder='输入公出申请人'
  365. value={this.state.auto}
  366. onChange={this.httpChange}
  367. filterOption={true}
  368. onBlur={this.blurChange}
  369. onSelect={this.selectAuto}
  370. >
  371. <Input />
  372. </AutoComplete>
  373. </span>
  374. <span style={{ marginRight: "10px" }}>
  375. <span style={{marginRight:'10px',marginBottom:'10px'}}>打卡时间 :</span>
  376. <RangePicker
  377. style={{marginRight:'10px',marginBottom:'10px'}}
  378. value={[
  379. this.state.releaseDate[0]
  380. ? moment(this.state.releaseDate[0])
  381. : null,
  382. this.state.releaseDate[1]
  383. ? moment(this.state.releaseDate[1])
  384. : null,
  385. ]}
  386. onChange={(data, dataString) => {
  387. this.setState({ releaseDate: dataString });
  388. }}
  389. />
  390. </span>
  391. <span style={{ marginRight: "10px" }}>
  392. <span style={{marginRight:'10px',marginBottom:'10px'}}>创建时间 :</span>
  393. <RangePicker
  394. style={{marginRight:'10px',marginBottom:'10px'}}
  395. value={[
  396. this.state.createReleaseDate[0]
  397. ? moment(this.state.createReleaseDate[0])
  398. : null,
  399. this.state.createReleaseDate[1]
  400. ? moment(this.state.createReleaseDate[1])
  401. : null,
  402. ]}
  403. onChange={(data, dataString) => {
  404. this.setState({ createReleaseDate: dataString });
  405. }}
  406. />
  407. </span>
  408. <Button type="primary" onClick={()=>{
  409. this.loadData();
  410. }} style={{marginRight:'10px',marginBottom:'10px'}}>搜索</Button>
  411. <Button onClick={this.resetAll} style={{marginRight:'10px',marginBottom:'10px'}}>重置</Button>
  412. </div>
  413. </TabPane>
  414. <TabPane tab="更改表格显示数据" key="2">
  415. <div style={{ marginLeft: 10 }}>
  416. <ChooseList
  417. columns={this.state.columns}
  418. changeFn={this.changeList}
  419. changeList={this.state.changeList}
  420. top={55}
  421. margin={11}
  422. />
  423. </div>
  424. </TabPane>
  425. <TabPane tab="导出" key="3">
  426. <div style={{ float: "left" }}>
  427. <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
  428. </div>
  429. </TabPane>
  430. </Tabs>
  431. <div className="patent-table">
  432. <Spin spinning={this.state.loading}>
  433. <Table
  434. bordered
  435. size="middle"
  436. scroll={{ x: 800, y: 0 }}
  437. columns={
  438. this.state.changeList.length > 0
  439. ? this.state.changeList
  440. : this.state.columns
  441. }
  442. dataSource={this.state.dataSource}
  443. pagination={this.state.pagination}
  444. />
  445. </Spin>
  446. </div>
  447. {this.state.visible ? <DetailedList
  448. status={this.state.status}
  449. title={this.state.title}
  450. aName={this.state.aName}
  451. clockIn={this.state.clockIn || undefined}
  452. visible={this.state.visible}
  453. aid={this.state.aid}
  454. onCancel={()=>{
  455. this.setState({
  456. visible:false,
  457. clockIn:0,
  458. })
  459. }}/> : null}
  460. </div>
  461. )
  462. }
  463. }
  464. export default ProjecCount;