detailedList.jsx 21 KB

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