detailedList.jsx 22 KB

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