detailedList.jsx 22 KB

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