detailedList.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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. const {TabPane} = Tabs;
  25. const { RangePicker } = DatePicker;
  26. class DetailedList extends Component{
  27. constructor(props) {
  28. super(props);
  29. this.state={
  30. pageNo:1,
  31. loading:false,
  32. changeList:[],
  33. annexUrlArr:[],
  34. photoUrlArr:[],
  35. imgListVisible:false,
  36. columns: [
  37. {
  38. title: "编号",
  39. dataIndex: "key",
  40. key: "key",
  41. },
  42. {
  43. title: "客户名称",
  44. dataIndex: "nickname",
  45. key: "nickname",
  46. width: 150,
  47. render: (text) => {
  48. return (
  49. <Tooltip title={text}>
  50. <div style={{
  51. maxWidth:'150px',
  52. overflow:'hidden',
  53. textOverflow: "ellipsis",
  54. whiteSpace:'nowrap',
  55. }}>{text}</div>
  56. </Tooltip>
  57. )
  58. },
  59. },
  60. {
  61. title: "公出申请人",
  62. dataIndex: "aname",
  63. key: "aname",
  64. },
  65. {
  66. title: "申请时间",
  67. dataIndex: "createTimes",
  68. key: "createTimes",
  69. },
  70. {
  71. title: "公出时间",
  72. dataIndex: "releaseStarts",
  73. key: "releaseStarts",
  74. render: (text, record) => (
  75. text+'至'+record.releaseEnds
  76. )
  77. },
  78. {
  79. title: "公出地点",
  80. dataIndex: "userName",
  81. key: "userName",
  82. width: 120,
  83. render: (text) => {
  84. return (
  85. <Tooltip title={text}>
  86. <div style={{
  87. maxWidth:'120px',
  88. overflow:'hidden',
  89. textOverflow: "ellipsis",
  90. whiteSpace:'nowrap',
  91. }}>{text}</div>
  92. </Tooltip>
  93. )
  94. },
  95. },
  96. {
  97. title: "公出时长(时)",
  98. dataIndex: "duration",
  99. key: "duration",
  100. },
  101. {
  102. title: "打卡时间",
  103. dataIndex: "clockInTimes",
  104. key: "clockInTimes",
  105. },
  106. {
  107. title: "审核状态",
  108. dataIndex: "status",
  109. key: "status",
  110. render: (text) => (
  111. <Tag color={getClockState(text).color}>{getClockState(text).title}</Tag>
  112. )
  113. },
  114. {
  115. title: "打卡状态",
  116. dataIndex: "clockIn",
  117. key: "clockIn",
  118. render: (text) => (
  119. text === 1 ? '已打卡' :
  120. text === 0 ? '未打卡' : ''
  121. )
  122. },
  123. {
  124. title: "操作",
  125. dataIndex: "annexUrl",
  126. key: "annexUrl",
  127. render: (text,record) => (
  128. <div>
  129. <Button
  130. style={{marginRight:'15px'}}
  131. type={"primary"}
  132. onClick={(e) => {
  133. e.stopPropagation();
  134. let arr1 = text || [];
  135. let arr2 = record.photoUrl || [];
  136. this.setState({
  137. annexUrlArr:splitUrl(arr1, ",", globalConfig.avatarHost + "/upload"),
  138. photoUrlArr:splitUrl(arr2, ",", globalConfig.avatarHost + "/upload"),
  139. },()=>{
  140. this.setState({
  141. imgListVisible:true
  142. })
  143. })
  144. }}
  145. >
  146. 查看公出附件
  147. </Button>
  148. </div>
  149. )
  150. },
  151. ],
  152. pagination: {
  153. defaultCurrent: 1,
  154. defaultPageSize: 10,
  155. showQuickJumper: true,
  156. pageSize: 10,
  157. onChange: function(page) {
  158. this.loadData(page);
  159. }.bind(this),
  160. showTotal: function(total) {
  161. return "共" + total + "条数据";
  162. }
  163. },
  164. dataSource: [],
  165. releaseDate:[],
  166. status:props.status,
  167. clockIn:props.clockIn,
  168. theTypes:props.aid,
  169. theCustomerTypes:undefined,
  170. }
  171. this.loadData = this.loadData.bind(this);
  172. this.resetAll = this.resetAll.bind(this);
  173. this.changeList = this.changeList.bind(this);
  174. this.selectSuperId = this.selectSuperId.bind(this);
  175. this.supervisor = this.supervisor.bind(this);
  176. this.httpChange = this.httpChange.bind(this);
  177. this.blurChange = this.blurChange.bind(this);
  178. this.selectAuto = this.selectAuto.bind(this);
  179. this.getCustomer = this.getCustomer.bind(this);
  180. this.selectCustomerAuto = this.selectCustomerAuto.bind(this);
  181. this.httpCustomerChange = this.httpCustomerChange.bind(this);
  182. this.blurCustomerChange = this.blurCustomerChange.bind(this);
  183. this.exportExec = this.exportExec.bind(this);
  184. }
  185. //获取上级组织
  186. selectSuperId() {
  187. $.ajax({
  188. method: "get",
  189. dataType: "json",
  190. crossDomain: false,
  191. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  192. data:{},
  193. success: function (data) {
  194. let theArr = [];
  195. if (data.error && data.error.length === 0) {
  196. for(let i=0;i<data.data.length;i++){
  197. let theData = data.data[i];
  198. theArr.push(
  199. <Select.Option value={theData.id} key={theData.id}>{theData.name}</Select.Option>
  200. );
  201. };
  202. this.setState({
  203. contactsOption: theArr,
  204. });
  205. }else{
  206. message.warning(data.error[0].message);
  207. }
  208. }.bind(this),
  209. }).always(function () {
  210. this.setState({
  211. loading: false
  212. });
  213. }.bind(this));
  214. }
  215. changeList(arr) {
  216. const newArr = [];
  217. this.state.columns.forEach(item => {
  218. arr.forEach(val => {
  219. if (val === item.title) {
  220. newArr.push(item);
  221. }
  222. });
  223. });
  224. this.setState({
  225. changeList: newArr
  226. });
  227. }
  228. loadData(pageNo) {
  229. this.setState({
  230. loading:true
  231. })
  232. $.ajax({
  233. method: "get",
  234. dataType: "json",
  235. crossDomain: false,
  236. url: globalConfig.context + "/api/admin/release/publicReleaseDtails",
  237. data: {
  238. pageNo: pageNo || 1,
  239. pageSize: this.state.pagination.pageSize,
  240. releaseStart:this.state.releaseDate[0] || undefined,
  241. releaseEnd:this.state.releaseDate[1] || undefined,
  242. aid:this.state.theTypes,
  243. uid:this.state.theCustomerTypes,
  244. status:this.state.status,
  245. clockIn:this.state.clockIn,
  246. },
  247. success: function(data) {
  248. ShowModal(this);
  249. let theArr = [];
  250. this.setState({
  251. loading:false
  252. })
  253. if (data.error && data.error.length === 0) {
  254. for (let i = 0; i < data.data.list.length; i++) {
  255. let thisdata = data.data.list[i];
  256. thisdata.key=(data.data.pageNo - 1) * data.data.pageSize + i + 1;
  257. theArr.push(thisdata);
  258. }
  259. this.state.pagination.current = data.data.pageNo;
  260. this.state.pagination.total = data.data.totalCount;
  261. if (data.data && data.data.list && !data.data.list.length) {
  262. this.state.pagination.current = 0;
  263. this.state.pagination.total = 0;
  264. }
  265. this.setState({
  266. dataSource: theArr,
  267. pagination: this.state.pagination,
  268. pageNo:data.data.pageNo
  269. });
  270. }else{
  271. message.warning(data.error[0].message);
  272. }
  273. }.bind(this)
  274. }).always(
  275. function() {
  276. this.setState({
  277. loading: false
  278. });
  279. }.bind(this)
  280. );
  281. }
  282. resetAll() {
  283. this.setState({
  284. releaseDate:[],
  285. theCustomerTypes:undefined,
  286. status:this.props.status,
  287. clockIn:this.props.clockIn,
  288. auto:'',
  289. customer:''
  290. },()=>{
  291. this.loadData();
  292. })
  293. }
  294. supervisor(e) {
  295. $.ajax({
  296. method: "get",
  297. dataType: "json",
  298. crossDomain: false,
  299. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  300. data: {
  301. adminName: e,
  302. },
  303. success: function (data) {
  304. if (data.error && data.error.length === 0) {
  305. this.setState({
  306. customerArr: data.data,
  307. });
  308. }else{
  309. message.warning(data.error[0].message);
  310. }
  311. }.bind(this),
  312. }).always(
  313. function () {
  314. }.bind(this)
  315. );
  316. }
  317. httpChange(e) {
  318. if (e.length >= 1) {
  319. this.supervisor(e);
  320. }
  321. this.setState({
  322. auto: e,
  323. });
  324. }
  325. selectAuto(value, options) {
  326. this.setState({
  327. auto: value,
  328. });
  329. }
  330. httpCustomerChange(e) {
  331. if (e.length >= 1) {
  332. this.getCustomer(e);
  333. }
  334. this.setState({
  335. customer: e,
  336. });
  337. }
  338. selectCustomerAuto(value, options) {
  339. this.setState({
  340. customer: value,
  341. });
  342. }
  343. getCustomer(e) {
  344. $.ajax({
  345. method: "get",
  346. dataType: "json",
  347. crossDomain: false,
  348. url: globalConfig.context + "/api/admin/customer/getUserByName",
  349. data: {
  350. name: e,
  351. },
  352. success: function (data) {
  353. if (data.error && data.error.length === 0) {
  354. this.setState({
  355. customerList: data.data,
  356. });
  357. }else{
  358. message.warning(data.error[0].message);
  359. }
  360. }.bind(this),
  361. }).always(
  362. function () {
  363. }.bind(this)
  364. );
  365. }
  366. blurCustomerChange(e) {
  367. let theType = "";
  368. let contactLists = this.state.customerList || [];
  369. if (e) {
  370. contactLists.map(function (item) {
  371. if (item.name == e.toString()) {
  372. theType = item.id;
  373. }
  374. });
  375. }
  376. this.setState({
  377. theCustomerTypes: theType,
  378. });
  379. }
  380. blurChange(e) {
  381. let theType = "";
  382. let contactLists = this.state.customerArr || [];
  383. if (e) {
  384. contactLists.map(function (item) {
  385. if (item.name == e.toString()) {
  386. theType = item.id;
  387. }
  388. });
  389. }
  390. this.setState({
  391. theTypes: theType,
  392. });
  393. }
  394. componentWillMount() {
  395. this.loadData();
  396. this.selectSuperId();
  397. }
  398. exportExec(){
  399. let data = {
  400. releaseStart:this.state.releaseDate[0],
  401. releaseEnd:this.state.releaseDate[1],
  402. aid:this.state.theTypes,
  403. uid:this.state.theCustomerTypes,
  404. status:this.state.status,
  405. clockIn:this.state.clockIn,
  406. };
  407. for(let i of Object.keys(data)){
  408. if(i === 'status' || i === 'clockIn'){
  409. if(isNaN(parseInt(data[i]))){
  410. delete data[i]
  411. }
  412. }else if(!data[i]){
  413. delete data[i]
  414. }
  415. }
  416. window.location.href =
  417. globalConfig.context +
  418. "/api/admin/release/publicReleaseDtails/export?" +
  419. $.param(data);
  420. }
  421. render() {
  422. const dataSources = this.state.customerArr || [];
  423. const options = dataSources.map((group) => (
  424. <Select.Option key={group.id} value={group.name}>
  425. {group.name}
  426. </Select.Option>
  427. ));
  428. const customerList = this.state.customerList || [];
  429. const customerOptions = customerList.map((group) => (
  430. <Select.Option key={group.id} value={group.name}>
  431. {group.name}
  432. </Select.Option>
  433. ));
  434. return (
  435. <div>
  436. <Modal
  437. maskClosable={false}
  438. visible={this.props.visible}
  439. onOk={this.props.onCancel}
  440. onCancel={this.props.onCancel}
  441. width='1200px'
  442. title='公出详细列表'
  443. footer=''
  444. className="admin-desc-content">
  445. <div className="user-content">
  446. <Tabs defaultActiveKey="1" className="test">
  447. <TabPane tab="搜索" key="1">
  448. <div className="user-search" style={{
  449. marginTop:'10px',
  450. marginLeft:'10px',
  451. marginRight:'10px'
  452. }}>
  453. <span style={{ marginRight: "10px" }}>
  454. <AutoComplete
  455. className="certain-category-search"
  456. dropdownClassName="certain-category-search-dropdown"
  457. dropdownMatchSelectWidth={false}
  458. dropdownStyle={{ width: 120 }}
  459. style={{ width: "120px" }}
  460. dataSource={customerOptions}
  461. placeholder='输入客户名称'
  462. value={this.state.customer}
  463. onChange={this.httpCustomerChange}
  464. filterOption={true}
  465. onBlur={this.blurCustomerChange}
  466. onSelect={this.selectCustomerAuto}
  467. >
  468. <Input />
  469. </AutoComplete>
  470. </span>
  471. <span style={{ marginRight: "10px" }}>
  472. <Select
  473. placeholder="请选择审核状态"
  474. style={{ width:200,marginLeft:10}}
  475. value={this.state.status}
  476. onChange={(e) => { this.setState({ status: e }) }}>
  477. {
  478. clockState.map((v,k) => (
  479. <Select.Option key={k} value={v.id} >{v.title}</Select.Option>
  480. ))
  481. }
  482. </Select>
  483. </span>
  484. <span style={{ marginRight: "10px" }}>
  485. <Select
  486. placeholder="请选择打卡状态"
  487. style={{ width:200,marginLeft:10}}
  488. value={this.state.clockIn}
  489. onChange={(e) => { this.setState({ clockIn: e }) }}>
  490. <Select.Option value={1} >已打卡</Select.Option>
  491. <Select.Option value={0} >未打卡</Select.Option>
  492. </Select>
  493. </span>
  494. <span style={{ marginRight: "10px" }}>
  495. <AutoComplete
  496. className="certain-category-search"
  497. dropdownClassName="certain-category-search-dropdown"
  498. dropdownMatchSelectWidth={false}
  499. dropdownStyle={{ width: 120 }}
  500. style={{ width: "120px" }}
  501. dataSource={options}
  502. placeholder='输入公出申请人'
  503. value={this.state.auto}
  504. onChange={this.httpChange}
  505. filterOption={true}
  506. onBlur={this.blurChange}
  507. onSelect={this.selectAuto}
  508. >
  509. <Input />
  510. </AutoComplete>
  511. </span>
  512. <span style={{ marginRight: "10px" }}>
  513. <span style={{marginRight:'5px',marginBottom:'10px'}}>公出时间 :</span>
  514. <RangePicker
  515. style={{marginRight:'10px',marginBottom:'10px'}}
  516. value={[
  517. this.state.releaseDate[0]
  518. ? moment(this.state.releaseDate[0])
  519. : null,
  520. this.state.releaseDate[1]
  521. ? moment(this.state.releaseDate[1])
  522. : null,
  523. ]}
  524. onChange={(data, dataString) => {
  525. this.setState({ releaseDate: dataString });
  526. }}
  527. />
  528. </span>
  529. <Button type="primary" onClick={()=>{
  530. this.loadData();
  531. }} style={{marginRight:'10px',marginBottom:'10px'}}>搜索</Button>
  532. <Button onClick={this.resetAll} style={{marginRight:'10px',marginBottom:'10px'}}>重置</Button>
  533. </div>
  534. </TabPane>
  535. <TabPane tab="更改表格显示数据" key="2">
  536. <div style={{ marginLeft: 10 }}>
  537. <Spin spinning={this.state.loading}>
  538. <ChooseList
  539. columns={this.state.columns}
  540. changeFn={this.changeList}
  541. changeList={this.state.changeList}
  542. top={55}
  543. margin={11}
  544. />
  545. </Spin>
  546. </div>
  547. </TabPane>
  548. <TabPane tab="导出" key="3">
  549. <div style={{ float: "left" }}>
  550. <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
  551. </div>
  552. </TabPane>
  553. </Tabs>
  554. <div className="patent-table">
  555. <Spin spinning={this.state.loading}>
  556. <Table
  557. bordered
  558. size="middle"
  559. scroll={{ x: 800, y: 0 }}
  560. columns={
  561. this.state.changeList.length > 0
  562. ? this.state.changeList
  563. : this.state.columns
  564. }
  565. dataSource={this.state.dataSource}
  566. pagination={this.state.pagination}
  567. />
  568. </Spin>
  569. </div>
  570. </div>
  571. </Modal>
  572. {this.state.imgListVisible ? <Modal
  573. maskClosable={false}
  574. visible={this.state.imgListVisible}
  575. onOk={()=>{this.setState({
  576. imgListVisible:false
  577. })}}
  578. onCancel={()=>{this.setState({
  579. imgListVisible:false
  580. })}}
  581. width='500px'
  582. title='图片'
  583. footer=''>
  584. <div>
  585. <div>申请附件</div>
  586. <ImgList fileList={this.state.annexUrlArr} domId='publicStatistics'/>
  587. <div style={{paddingTop:'35px'}}>打卡照片</div>
  588. <ImgList fileList={this.state.photoUrlArr} domId='publicStatistics1'/>
  589. </div>
  590. </Modal> : null}
  591. </div>
  592. )
  593. }
  594. }
  595. export default DetailedList;