detailedList.jsx 30 KB

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