detailedList.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. import React,{ Component } from 'react';
  2. import {
  3. AutoComplete,
  4. Button,
  5. DatePicker,
  6. Input,
  7. message,
  8. Modal,
  9. Select,
  10. Spin,
  11. Table,
  12. Tabs,
  13. Tag,
  14. Form,
  15. Upload, Tooltip
  16. } from "antd";
  17. import {ShowModal,splitUrl,getClockState} from "@/tools";
  18. import {clockState} from "@/dataDic";
  19. import {ChooseList} from "../../../order/orderNew/chooseList";
  20. import $ from "jquery/src/ajax";
  21. import './index.less';
  22. import moment from "moment";
  23. import ImgList from "../../../../common/imgList";
  24. import TabelContent from "../../../../common/tabelContent";
  25. const {TabPane} = Tabs;
  26. const { RangePicker } = DatePicker;
  27. class DetailedList extends Component{
  28. constructor(props) {
  29. super(props);
  30. this.state={
  31. pageNo:1,
  32. loading:false,
  33. changeList:[],
  34. annexUrlArr:[],
  35. photoUrlArr:[],
  36. imgListVisible:false,
  37. columns: [
  38. {
  39. title: "编号",
  40. dataIndex: "key",
  41. key: "key",
  42. },
  43. {
  44. title: "客户名称",
  45. dataIndex: "nickname",
  46. key: "nickname",
  47. width: 150,
  48. onCellClick :(record, event)=>{
  49. event.stopPropagation();
  50. this.setState({
  51. status:2,
  52. visible1:true,
  53. aid:record.aid
  54. })
  55. },
  56. render: (text) => {
  57. return (
  58. <Tooltip title={text}>
  59. <div style={{
  60. maxWidth:'150px',
  61. overflow:'hidden',
  62. textOverflow: "ellipsis",
  63. whiteSpace:'nowrap',
  64. }}>{text}</div>
  65. </Tooltip>
  66. )
  67. },
  68. },
  69. {
  70. title: "公出申请人",
  71. dataIndex: "aname",
  72. key: "aname",
  73. },
  74. {
  75. title: "申请时间",
  76. dataIndex: "createTimes",
  77. key: "createTimes",
  78. },
  79. {
  80. title: "公出时间",
  81. dataIndex: "releaseStarts",
  82. key: "releaseStarts",
  83. render: (text, record) => (
  84. text+'至'+record.releaseEnds
  85. )
  86. },
  87. {
  88. title: "公出地点",
  89. dataIndex: "userName",
  90. key: "userName",
  91. width: 120,
  92. render: (text) => {
  93. return (
  94. <Tooltip title={text}>
  95. <div style={{
  96. maxWidth:'120px',
  97. overflow:'hidden',
  98. textOverflow: "ellipsis",
  99. whiteSpace:'nowrap',
  100. }}>{text}</div>
  101. </Tooltip>
  102. )
  103. },
  104. },
  105. {
  106. title: "公出时长(时)",
  107. dataIndex: "duration",
  108. key: "duration",
  109. },
  110. {
  111. title: "打卡时间",
  112. dataIndex: "clockInTimes",
  113. key: "clockInTimes",
  114. },
  115. {
  116. title: "审核状态",
  117. dataIndex: "status",
  118. key: "status",
  119. render: (text) => (
  120. <Tag color={getClockState(text).color}>{getClockState(text).title}</Tag>
  121. )
  122. },
  123. {
  124. title: "打卡状态",
  125. dataIndex: "clockIn",
  126. key: "clockIn",
  127. render: (text) => (
  128. text === 1 ? '已打卡' :
  129. text === 0 ? '未打卡' : ''
  130. )
  131. },
  132. {
  133. title: "操作",
  134. dataIndex: "annexUrl",
  135. key: "annexUrl",
  136. render: (text,record) => (
  137. <div>
  138. <Button
  139. style={{marginRight:'15px'}}
  140. type={"primary"}
  141. onClick={(e) => {
  142. e.stopPropagation();
  143. let arr1 = text || [];
  144. let arr2 = record.photoUrl || [];
  145. this.setState({
  146. annexUrlArr:splitUrl(arr1, ",", globalConfig.avatarHost + "/upload"),
  147. photoUrlArr:splitUrl(arr2, ",", globalConfig.avatarHost + "/upload"),
  148. },()=>{
  149. this.setState({
  150. imgListVisible:true
  151. })
  152. })
  153. }}
  154. >
  155. 查看公出附件
  156. </Button>
  157. </div>
  158. )
  159. },
  160. ],
  161. pagination: {
  162. defaultCurrent: 1,
  163. defaultPageSize: 10,
  164. showQuickJumper: true,
  165. pageSize: 10,
  166. onChange: function(page) {
  167. this.loadData(page);
  168. }.bind(this),
  169. showTotal: function(total) {
  170. return "共" + total + "条数据";
  171. }
  172. },
  173. dataSource: [],
  174. releaseDate:[],
  175. status:props.status,
  176. clockIn:props.clockIn,
  177. theTypes:props.aid,
  178. theCustomerTypes:undefined,
  179. }
  180. this.loadData = this.loadData.bind(this);
  181. this.resetAll = this.resetAll.bind(this);
  182. this.changeList = this.changeList.bind(this);
  183. this.selectSuperId = this.selectSuperId.bind(this);
  184. this.supervisor = this.supervisor.bind(this);
  185. this.httpChange = this.httpChange.bind(this);
  186. this.blurChange = this.blurChange.bind(this);
  187. this.selectAuto = this.selectAuto.bind(this);
  188. this.getCustomer = this.getCustomer.bind(this);
  189. this.selectCustomerAuto = this.selectCustomerAuto.bind(this);
  190. this.httpCustomerChange = this.httpCustomerChange.bind(this);
  191. this.blurCustomerChange = this.blurCustomerChange.bind(this);
  192. this.exportExec = this.exportExec.bind(this);
  193. }
  194. //获取上级组织
  195. selectSuperId() {
  196. $.ajax({
  197. method: "get",
  198. dataType: "json",
  199. crossDomain: false,
  200. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  201. data:{},
  202. success: function (data) {
  203. let theArr = [];
  204. if (data.error && data.error.length === 0) {
  205. for(let i=0;i<data.data.length;i++){
  206. let theData = data.data[i];
  207. theArr.push(
  208. <Select.Option value={theData.id} key={theData.id}>{theData.name}</Select.Option>
  209. );
  210. };
  211. this.setState({
  212. contactsOption: theArr,
  213. });
  214. }else{
  215. message.warning(data.error[0].message);
  216. }
  217. }.bind(this),
  218. }).always(function () {
  219. this.setState({
  220. loading: false
  221. });
  222. }.bind(this));
  223. }
  224. changeList(arr) {
  225. const newArr = [];
  226. this.state.columns.forEach(item => {
  227. arr.forEach(val => {
  228. if (val === item.title) {
  229. newArr.push(item);
  230. }
  231. });
  232. });
  233. this.setState({
  234. changeList: newArr
  235. });
  236. }
  237. loadData(pageNo) {
  238. this.setState({
  239. loading:true
  240. })
  241. $.ajax({
  242. method: "get",
  243. dataType: "json",
  244. crossDomain: false,
  245. url: globalConfig.context + "/api/admin/release/publicReleaseDtails",
  246. data: {
  247. pageNo: pageNo || 1,
  248. pageSize: this.state.pagination.pageSize,
  249. releaseStart:this.state.releaseDate[0] || undefined,
  250. releaseEnd:this.state.releaseDate[1] || undefined,
  251. aid:this.state.theTypes,
  252. uid:this.state.theCustomerTypes,
  253. status:this.state.status,
  254. clockIn:this.state.clockIn,
  255. },
  256. success: function(data) {
  257. ShowModal(this);
  258. let theArr = [];
  259. this.setState({
  260. loading:false
  261. })
  262. if (data.error && data.error.length === 0) {
  263. for (let i = 0; i < data.data.list.length; i++) {
  264. let thisdata = data.data.list[i];
  265. thisdata.key=(data.data.pageNo - 1) * data.data.pageSize + i + 1;
  266. theArr.push(thisdata);
  267. }
  268. this.state.pagination.current = data.data.pageNo;
  269. this.state.pagination.total = data.data.totalCount;
  270. if (data.data && data.data.list && !data.data.list.length) {
  271. this.state.pagination.current = 0;
  272. this.state.pagination.total = 0;
  273. }
  274. this.setState({
  275. dataSource: theArr,
  276. pagination: this.state.pagination,
  277. pageNo:data.data.pageNo
  278. });
  279. }else{
  280. message.warning(data.error[0].message);
  281. }
  282. }.bind(this)
  283. }).always(
  284. function() {
  285. this.setState({
  286. loading: false
  287. });
  288. }.bind(this)
  289. );
  290. }
  291. resetAll() {
  292. this.setState({
  293. releaseDate:[],
  294. theCustomerTypes:undefined,
  295. status:this.props.status,
  296. clockIn:this.props.clockIn,
  297. auto:'',
  298. customer:''
  299. },()=>{
  300. this.loadData();
  301. })
  302. }
  303. supervisor(e) {
  304. $.ajax({
  305. method: "get",
  306. dataType: "json",
  307. crossDomain: false,
  308. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  309. data: {
  310. adminName: e,
  311. },
  312. success: function (data) {
  313. if (data.error && data.error.length === 0) {
  314. this.setState({
  315. customerArr: data.data,
  316. });
  317. }else{
  318. message.warning(data.error[0].message);
  319. }
  320. }.bind(this),
  321. }).always(
  322. function () {
  323. }.bind(this)
  324. );
  325. }
  326. httpChange(e) {
  327. if (e.length >= 1) {
  328. this.supervisor(e);
  329. }
  330. this.setState({
  331. auto: e,
  332. });
  333. }
  334. selectAuto(value, options) {
  335. this.setState({
  336. auto: value,
  337. });
  338. }
  339. httpCustomerChange(e) {
  340. if (e.length >= 1) {
  341. this.getCustomer(e);
  342. }
  343. this.setState({
  344. customer: e,
  345. });
  346. }
  347. selectCustomerAuto(value, options) {
  348. this.setState({
  349. customer: value,
  350. });
  351. }
  352. getCustomer(e) {
  353. $.ajax({
  354. method: "get",
  355. dataType: "json",
  356. crossDomain: false,
  357. url: globalConfig.context + "/api/admin/customer/getUserByName",
  358. data: {
  359. name: e,
  360. },
  361. success: function (data) {
  362. if (data.error && data.error.length === 0) {
  363. this.setState({
  364. customerList: data.data,
  365. });
  366. }else{
  367. message.warning(data.error[0].message);
  368. }
  369. }.bind(this),
  370. }).always(
  371. function () {
  372. }.bind(this)
  373. );
  374. }
  375. blurCustomerChange(e) {
  376. let theType = "";
  377. let contactLists = this.state.customerList || [];
  378. if (e) {
  379. contactLists.map(function (item) {
  380. if (item.name == e.toString()) {
  381. theType = item.id;
  382. }
  383. });
  384. }
  385. this.setState({
  386. theCustomerTypes: theType,
  387. });
  388. }
  389. blurChange(e) {
  390. let theType = "";
  391. let contactLists = this.state.customerArr || [];
  392. if (e) {
  393. contactLists.map(function (item) {
  394. if (item.name == e.toString()) {
  395. theType = item.id;
  396. }
  397. });
  398. }
  399. this.setState({
  400. theTypes: theType,
  401. });
  402. }
  403. componentWillMount() {
  404. this.loadData();
  405. this.selectSuperId();
  406. }
  407. exportExec(){
  408. let data = {
  409. releaseStart:this.state.releaseDate[0],
  410. releaseEnd:this.state.releaseDate[1],
  411. aid:this.state.theTypes,
  412. uid:this.state.theCustomerTypes,
  413. status:this.state.status,
  414. clockIn:this.state.clockIn,
  415. };
  416. for(let i of Object.keys(data)){
  417. if(i === 'status' || i === 'clockIn'){
  418. if(isNaN(parseInt(data[i]))){
  419. delete data[i]
  420. }
  421. }else if(!data[i]){
  422. delete data[i]
  423. }
  424. }
  425. window.location.href =
  426. globalConfig.context +
  427. "/api/admin/release/publicReleaseDtails/export?" +
  428. $.param(data);
  429. }
  430. render() {
  431. const dataSources = this.state.customerArr || [];
  432. const options = dataSources.map((group) => (
  433. <Select.Option key={group.id} value={group.name}>
  434. {group.name}
  435. </Select.Option>
  436. ));
  437. const customerList = this.state.customerList || [];
  438. const customerOptions = customerList.map((group) => (
  439. <Select.Option key={group.id} value={group.name}>
  440. {group.name}
  441. </Select.Option>
  442. ));
  443. return (
  444. <div>
  445. <Modal
  446. maskClosable={false}
  447. visible={this.props.visible}
  448. onOk={this.props.onCancel}
  449. onCancel={this.props.onCancel}
  450. width='1200px'
  451. title='内蒙签单统计表'
  452. footer=''
  453. className="admin-desc-content">
  454. <div className="user-content">
  455. <TabelContent
  456. searchList={this.props.searchList}
  457. columns={this.state.columns}
  458. tabelApi={'/api/admin/release/publicReleaseDtails'}
  459. exportApi={'/api/admin/release/publicReleaseDtails/export'}
  460. dataProcessing={(data)=>{
  461. let theArr = [];
  462. for (let i = 0; i < data.data.list.length; i++) {
  463. let thisdata = data.data.list[i];
  464. thisdata.key=(data.data.pageNo - 1) * data.data.pageSize + i + 1;
  465. theArr.push(thisdata);
  466. }
  467. return theArr;
  468. }}
  469. />
  470. </div>
  471. <Modal
  472. maskClosable={false}
  473. visible={this.state.visible1}
  474. onOk={()=>{
  475. this.setState({
  476. visible1:false
  477. })
  478. }}
  479. onCancel={()=>{
  480. this.setState({
  481. visible1:false
  482. })
  483. }}
  484. width='1200px'
  485. title='部门订单'
  486. footer=''
  487. className="admin-desc-content">
  488. <div className="user-content">
  489. <TabelContent
  490. columns={this.state.columns}
  491. tabelApi={'/api/admin/release/publicReleaseDtails'}
  492. exportApi={'/api/admin/release/publicReleaseDtails/export'}
  493. dataProcessing={(data)=>{
  494. let theArr = [];
  495. for (let i = 0; i < data.data.list.length; i++) {
  496. let thisdata = data.data.list[i];
  497. thisdata.key=(data.data.pageNo - 1) * data.data.pageSize + i + 1;
  498. theArr.push(thisdata);
  499. }
  500. return theArr;
  501. }}
  502. />
  503. </div>
  504. </Modal>
  505. </Modal>
  506. </div>
  507. )
  508. }
  509. }
  510. export default DetailedList;