index.jsx 17 KB

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