index.jsx 16 KB

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