index.jsx 17 KB

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