detailedList.jsx 21 KB

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