mySettlement.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. "use strict";
  2. import React from 'react';
  3. import $ from 'jquery/src/ajax';
  4. import { Form,Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Popconfirm} from 'antd';
  5. import MySettlementDetaile from "./mySettlementDetaile.jsx";
  6. import moment from 'moment';
  7. import '../../userMangagement.less';
  8. import {paymentState ,orderState} from '../../../../dataDic.js';
  9. import {getProjectState,getOrderType,getOrderState,getPaymentState,getApprovedState} from '../../../../tools.js';
  10. const MySettlement=Form.create()(React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "post",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + '/api/admin/order/listMySettlement',
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. buyerName:this.state.buyerNameSearch,
  25. depId:this.state.departmenttSearch,//部门
  26. salesmanName:this.state.salesmanNameSearch,//负责人
  27. startDate: this.state.releaseDate[0],
  28. endDate: this.state.releaseDate[1],
  29. liquidationStatus:this.state.liquidationStatusSearch, //结算
  30. approval:this.state.orderChannelSearch,//特批
  31. orderNo:this.state.orderNoSearch,
  32. orderStatus:this.state.orderStatusSearch,
  33. },
  34. success: function (data) {
  35. let theArr = [];
  36. if (!data.data) {
  37. if (data.error && data.error.length) {
  38. message.warning(data.error[0].message);
  39. };
  40. } else {
  41. for (let i = 0; i < data.data.list.length; i++) {
  42. let thisdata = data.data.list[i];
  43. theArr.push({
  44. key: i,
  45. id: thisdata.id,
  46. orderNo: thisdata.orderNo,//订单编号
  47. orderType:thisdata.orderType,//订单类型
  48. orderStatus:thisdata.orderStatus,
  49. liquidationStatus:thisdata.liquidationStatus,
  50. createTime:thisdata.createTime,
  51. buyerName:thisdata.buyerName,
  52. signTotalAmount:thisdata.signTotalAmount,
  53. projectStage:thisdata.projectStage,
  54. approval:thisdata.approval,
  55. orderChannel:thisdata.orderChannel,
  56. salesmanName:thisdata.salesmanName,
  57. active:thisdata.active,
  58. departmentName:thisdata.departmentName,
  59. salesmanName:thisdata.salesmanName,
  60. financeName:thisdata.financeName,
  61. technicianName:thisdata.technicianName,
  62. });
  63. };
  64. this.state.pagination.current = data.data.pageNo;
  65. this.state.pagination.total = data.data.totalCount;
  66. };
  67. if(!data.data.list.length){
  68. this.state.pagination.current=0
  69. this.state.pagination.total=0
  70. }
  71. this.setState({
  72. pageNo:pageNo,
  73. dataSource: theArr,
  74. pagination: this.state.pagination,
  75. selectedRowKeys:[],
  76. signBillVisible:false
  77. });
  78. }.bind(this),
  79. }).always(function () {
  80. this.setState({
  81. loading: false
  82. });
  83. }.bind(this));
  84. },
  85. //部门
  86. departmentList() {
  87. this.setState({
  88. loading: true
  89. });
  90. $.ajax({
  91. method: "get",
  92. dataType: "json",
  93. crossDomain: false,
  94. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  95. data: {
  96. },
  97. success: function(data) {
  98. let thedata = data.data;
  99. let theArr=[];
  100. if(!thedata) {
  101. if(data.error && data.error.length) {
  102. message.warning(data.error[0].message);
  103. };
  104. thedata = {};
  105. }else{
  106. thedata.map(function(item,index){
  107. theArr.push({
  108. key:index,
  109. name:item.name,
  110. id:item.id,
  111. })
  112. })
  113. }
  114. this.setState({
  115. departmentArr:theArr,
  116. })
  117. this.loadData('1',theArr);
  118. }.bind(this),
  119. }).always(function() {
  120. this.setState({
  121. loading: false
  122. });
  123. }.bind(this));
  124. },
  125. getInitialState() {
  126. return {
  127. datauser:{},
  128. selectedRowKeys: [],
  129. releaseDate: [],
  130. departmentArr:[],
  131. selectedRows: [],
  132. searchMore: true,
  133. loading: false,
  134. visible:false,
  135. showDesc:false,
  136. pagination: {
  137. defaultCurrent: 1,
  138. defaultPageSize: 10,
  139. showQuickJumper: true,
  140. pageSize: 10,
  141. onChange: function (page) {
  142. this.loadData(page);
  143. }.bind(this),
  144. showTotal: function (total) {
  145. return '共' + total + '条数据';
  146. }
  147. },
  148. columns: [
  149. {
  150. title: '订单编号',
  151. dataIndex: 'orderNo',
  152. key: 'orderNo'
  153. }, {
  154. title: '订单类型',
  155. dataIndex: 'orderType',
  156. key: 'orderType',
  157. render:text=>{return getOrderType(text)}
  158. }, {
  159. title: '下单时间',
  160. dataIndex: 'createTime',
  161. key: 'createTime'
  162. },{
  163. title: '订单客户',
  164. dataIndex: 'buyerName',
  165. key: 'buyerName',
  166. render:(text)=>{
  167. return (text&&text.length>9?text.substr(0,9)+'...':text)
  168. }
  169. }, {
  170. title: '实际下单金额(万元)',
  171. dataIndex: 'signTotalAmount',
  172. key: 'signTotalAmount'
  173. }, {
  174. title: '订单状态',
  175. dataIndex: 'orderStatus',
  176. key: 'orderStatus',
  177. render:(text)=>{return getOrderState(text) }
  178. },{
  179. title: '项目进度',
  180. dataIndex: 'projectStage',
  181. key: 'projectStage',
  182. render:(text)=>{return getProjectState(text) }
  183. }, {
  184. title: '结算状态',
  185. dataIndex: 'liquidationStatus',
  186. key: 'liquidationStatus',
  187. render:text=>{return getPaymentState(text)}
  188. },{
  189. title: '是否特批',
  190. dataIndex: 'approval',
  191. key: 'approval',
  192. render:text=>{return getApprovedState(text)}
  193. },{
  194. title: '订单负责人',
  195. dataIndex: 'salesmanName',
  196. key: 'salesmanName',
  197. },
  198. {
  199. title: '操作',
  200. dataIndex: 'zhifu',
  201. key: 'zhifu',
  202. render:(text,record)=>{
  203. return <div>
  204. {record.liquidationStatus<2&&<Button onClick={(e) =>{ e.stopPropagation(),this.paymentMoney(record)}} type="dashed">支付</Button>}
  205. <Button style={{margin:'0 5px'}} onClick={(e) =>{ e.stopPropagation(),this.confirmDelet(record)}} type="primary">转交</Button>
  206. {record.liquidationStatus==4&&<Button onClick={(e) =>{ e.stopPropagation(),this.refundMoney(record)}} type="danger">退款</Button>}
  207. </div>
  208. }
  209. }
  210. ],
  211. userList:[
  212. {
  213. title: '编号',
  214. dataIndex: 'userNo',
  215. key: 'userNo'
  216. }, {
  217. title: '姓名',
  218. dataIndex: 'name',
  219. key: 'name'
  220. },{
  221. title: '部门机构',
  222. dataIndex: 'departmentName',
  223. key: 'departmentName'
  224. }, {
  225. title: '职务',
  226. dataIndex: 'position',
  227. key: 'position'
  228. },{
  229. title: '联系手机',
  230. dataIndex: 'mobile',
  231. key: 'mobile'
  232. }, {
  233. title: '操作',
  234. dataIndex: 'abc',
  235. key: 'abc',
  236. render:(text,record)=>{
  237. return (
  238. <Popconfirm title={'您确认将订单 【'+ this.state.orderNot+'】 转交给【'+record.departmentName+'-'+record.name+'】进行业务跟进?'} onConfirm={()=>{this.confirmSelect(record)}} okText="确认" cancelText="取消">
  239. <Button style={{marginRight:'5px'}} type="primary">转交</Button>
  240. </Popconfirm>
  241. )
  242. }
  243. }
  244. ],
  245. dataSource: [],
  246. };
  247. },
  248. //测试用支付
  249. //支付
  250. paymentMoney(record){
  251. this.setState({
  252. kid:record.orderNo,
  253. payment:'',
  254. paymentVisible:true,
  255. paymentMoneyState:true
  256. })
  257. },
  258. //退款
  259. refundMoney(record){
  260. this.setState({
  261. kid:record.orderNo,
  262. payment:'',
  263. paymentVisible:true,
  264. paymentMoneyState:false
  265. })
  266. },
  267. paymentCancel(){
  268. this.setState({
  269. paymentVisible:false
  270. })
  271. },
  272. //支付保存
  273. payment(){
  274. if(!this.state.payment){
  275. message.warning('请输入金额!');
  276. return;
  277. };
  278. this.setState({
  279. selectedRowKeys: [],
  280. loading: true,
  281. showDesc:false
  282. });
  283. let api = this.state.paymentMoneyState?'/api/admin/order/testPay':'/api/admin/order/testRefund';
  284. $.ajax({
  285. method: "POST",
  286. dataType: "json",
  287. crossDomain: false,
  288. url: globalConfig.context + api,
  289. data: this.state.paymentMoneyState?{
  290. orderNo:this.state.kid,
  291. payAmount:this.state.payment
  292. }:{
  293. orderNo:this.state.kid,
  294. refundAmount:this.state.payment
  295. }
  296. }).done(function (data) {
  297. if (!data.error.length) {
  298. message.success(this.state.paymentMoneyState?'支付成功!':'退款成功!');
  299. this.paymentCancel();
  300. this.loadData(this.state.pageNo);
  301. this.setState({
  302. loading: false,
  303. });
  304. } else {
  305. message.warning(data.error[0].message);
  306. };
  307. }.bind(this));
  308. },
  309. componentWillMount() {
  310. this.departmentList();
  311. let data=localStorage.getItem('newData');
  312. if(data!='{}'&&data){
  313. var newData = JSON.parse(data);
  314. this.tableRowClick(newData);
  315. };
  316. },
  317. tableRowClick(record) {
  318. this.state.userDetaile=true;
  319. this.state.datauser = record;
  320. this.setState({
  321. showDesc: true
  322. });
  323. },
  324. closeDesc(e, s) {
  325. this.state.userDetaile=false;
  326. this.state.showDesc = e;
  327. if (s) {
  328. this.loadData();
  329. };
  330. },
  331. searchSwitch() {
  332. this.setState({
  333. searchMore: !this.state.searchMore
  334. });
  335. },
  336. search() {
  337. this.loadData();
  338. },
  339. //分配时搜索
  340. searchOrder() {
  341. this.contactList();
  342. },
  343. //分配时重置
  344. resetOrder() {
  345. this.setState({
  346. departmenttList:undefined,
  347. financeNameSearch:''
  348. })
  349. },
  350. //操作分配
  351. confirmDelet(index){
  352. this.setState({
  353. orderNot:index.orderNo,
  354. userDetaile:false,
  355. distributionVisible:true
  356. });
  357. },
  358. distributionCancel(){
  359. this.setState({
  360. distributionVisible:false
  361. })
  362. },
  363. distributionOk(){
  364. this.setState({
  365. distributionVisible:false
  366. })
  367. },
  368. //分配对象列表
  369. contactList(){
  370. $.ajax({
  371. method: "get",
  372. dataType: "json",
  373. crossDomain: false,
  374. url: globalConfig.context + '/api/admin/superviser/adminList',
  375. data: {
  376. pageNo: 1,
  377. pageSize: 99,
  378. departmentId:this.state.departmenttList,
  379. name:this.state.financeNameSearch,
  380. },
  381. success: function (data) {
  382. let theArr = [];
  383. if (!data.data) {
  384. if (data.error && data.error.length) {
  385. message.warning(data.error[0].message);
  386. };
  387. } else {
  388. for (let i = 0; i < data.data.list.length; i++) {
  389. let thisdata = data.data.list[i];
  390. theArr.push({
  391. key: i,
  392. id: thisdata.id,
  393. userNo: thisdata.userNo,
  394. name:thisdata.name,
  395. departmentName:thisdata.departmentName,
  396. departmentId:thisdata.departmentId,
  397. position:thisdata.position,
  398. mobile:thisdata.mobile,
  399. });
  400. };
  401. };
  402. this.setState({
  403. distributionList: theArr,
  404. });
  405. }.bind(this),
  406. }).always(function () {
  407. this.setState({
  408. loading: false
  409. });
  410. }.bind(this));
  411. },
  412. //选定对象
  413. confirmSelect(record){
  414. this.setState({
  415. loading: true
  416. });
  417. $.ajax({
  418. method: "POST",
  419. dataType: "json",
  420. crossDomain: false,
  421. url: globalConfig.context + "/api/admin/order/transferOrder",
  422. data: {
  423. orderNo:this.state.orderNot,
  424. aid:record.id,
  425. targetType:1
  426. }
  427. }).done(function (data) {
  428. if (!data.error.length) {
  429. message.success('转交成功!');
  430. this.setState({
  431. loading: false,
  432. });
  433. this.distributionOk();
  434. } else {
  435. message.warning(data.error[0].message);
  436. };
  437. this.loadData(this.state.pageNo);
  438. }.bind(this));
  439. },
  440. reset() {
  441. this.state.buyerNameSearch='';
  442. this.state.orderNoSearch='';
  443. this.state.releaseDate[0] = undefined;
  444. this.state.releaseDate[1] = undefined;
  445. this.state.orderStatusSearch = undefined;
  446. this.state.orderChannelSearch = undefined;
  447. this.state.liquidationStatusSearch = undefined;
  448. this.state.salesmanNameSearch = undefined;
  449. this.state.departmenttSearch = undefined;
  450. this.state.approved = undefined;
  451. this.state.orderChannel = undefined;
  452. this.loadData();
  453. },
  454. render() {
  455. const rowSelection = {
  456. selectedRowKeys: this.state.selectedRowKeys,
  457. onChange: (selectedRowKeys, selectedRows) => {
  458. this.setState({
  459. selectedRows: selectedRows.slice(-1),
  460. selectedRowKeys: selectedRowKeys.slice(-1)
  461. });
  462. },
  463. onSelectAll: () => {
  464. this.setState({
  465. selectedRowKeys:[]
  466. })
  467. },
  468. };
  469. let departmentArr = this.state.departmentArr || [];
  470. const { RangePicker } = DatePicker;
  471. return (
  472. <div className="user-content" >
  473. <div className="content-title">
  474. <span style={{fontSize:'16px'}}>我的结算订单</span>
  475. <div className="user-search">
  476. <Input placeholder="客户名称" style={{width:'150px'}}
  477. value={this.state.buyerNameSearch}
  478. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  479. <RangePicker
  480. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  481. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  482. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  483. <Select placeholder="部门机构"
  484. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  485. value={this.state.departmenttSearch}
  486. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  487. {
  488. departmentArr.map(function (item) {
  489. return <Select.Option key={item.id} >{item.name}</Select.Option>
  490. })
  491. }
  492. </Select>
  493. <Input placeholder="订单负责人" style={{width:'150px'}}
  494. value={this.state.salesmanNameSearch}
  495. onChange={(e) => { this.setState({ salesmanNameSearch: e.target.value }); }} />
  496. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  497. <Button onClick={this.reset}>重置</Button>
  498. <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  499. </div>
  500. <div className='clearfix' style={{marginTop:'5px'}}>
  501. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  502. <Input placeholder="订单编号" style={{width:'150px',marginRight:'10px'}}
  503. value={this.state.orderNoSearch}
  504. onChange={(e) => { this.setState({ orderNoSearch: e.target.value }); }} />
  505. <Select placeholder="结算状态"
  506. style={{ width: 150 ,marginRight:'10px'}}
  507. value={this.state.liquidationStatusSearch}
  508. onChange={(e) => { this.setState({ liquidationStatusSearch: e }) }}>
  509. {
  510. paymentState.map(function (item) {
  511. return <Select.Option key={item.value} >{item.key}</Select.Option>
  512. })
  513. }
  514. </Select>
  515. <Select placeholder="订单状态"
  516. style={{ width: 150 ,marginRight:'10px'}}
  517. value={this.state.orderStatusSearch}
  518. onChange={(e) => { this.setState({ orderStatusSearch: e }) }}>
  519. {
  520. orderState.map(function (item) {
  521. return <Select.Option key={item.value} >{item.key}</Select.Option>
  522. })
  523. }
  524. </Select>
  525. <Select placeholder="是否特批"
  526. style={{ width: 150,marginRight:'10px',marginBottom:'10px' }}
  527. value={this.state.orderChannelSearch}
  528. onChange={(e) => { this.setState({ orderChannelSearch: e }) }}>
  529. <Select.Option value='0'>非特批</Select.Option>
  530. <Select.Option value='2'>特批通过</Select.Option>
  531. <Select.Option value='3'>特批驳回</Select.Option>
  532. </Select>
  533. </div>
  534. </div>
  535. <div className="patent-table">
  536. <Spin spinning={this.state.loading}>
  537. <Table columns={this.state.columns}
  538. dataSource={this.state.dataSource}
  539. rowSelection={rowSelection}
  540. pagination={this.state.pagination}
  541. onRowClick={this.tableRowClick} />
  542. </Spin>
  543. </div>
  544. <MySettlementDetaile
  545. confirmDelet={this.confirmDelet}
  546. userDetaile={this.state.userDetaile}
  547. datauser={this.state.datauser}
  548. showDesc={this.state.showDesc}
  549. closeDesc={this.closeDesc} />
  550. </div >
  551. <Modal maskClosable={false} visible={this.state.paymentVisible}
  552. onOk={this.paymentCancel} onCancel={this.paymentCancel}
  553. width='600px'
  554. title= {this.state.paymentMoneyState?'支付详情':'退款详情'}
  555. footer=''
  556. className="admin-desc-content">
  557. <Form layout="horizontal" id="demand-form">
  558. <Spin spinning={this.state.loading}>
  559. <div className="clearfix">
  560. <Form.Item className="half-middle"
  561. labelCol={{ span: 8 }}
  562. wrapperCol={{ span: 14 }}
  563. label={this.state.paymentMoneyState?"支付金额(万元)":'退款金额'} >
  564. <Input value={this.state.payment} onChange={(e)=>{this.setState({payment:e.target.value})}} style={{width:'150px'}} />
  565. <span className="mandatory">*</span>
  566. </Form.Item>
  567. <Button type="primary" onClick={this.payment} style={{marginRight:'20px',marginLeft:'210px'}}>{this.state.paymentMoneyState?'支付':'退款'}</Button>
  568. <Button onClick={this.paymentCancel}>取消</Button>
  569. </div>
  570. </Spin>
  571. </Form >
  572. </Modal>
  573. <Modal maskClosable={false} visible={this.state.distributionVisible}
  574. onOk={this.distributionOk} onCancel={this.distributionCancel}
  575. width='800px'
  576. title='转交订单'
  577. footer=''
  578. className="admin-desc-content">
  579. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  580. <Spin spinning={this.state.loading}>
  581. <div>
  582. <Select placeholder="部门"
  583. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  584. value={this.state.departmenttList}
  585. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  586. {
  587. departmentArr.map(function (item) {
  588. return <Select.Option key={item.id} >{item.name}</Select.Option>
  589. })
  590. }
  591. </Select>
  592. <Input placeholder="订单负责人" style={{width:'150px',marginLeft:'10px'}}
  593. value={this.state.financeNameSearch}
  594. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  595. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  596. <Button onClick={this.resetOrder}>重置</Button>
  597. </div>
  598. <div className="patent-table" style={{marginTop:'10px'}}>
  599. <Spin spinning={this.state.loading}>
  600. <Table columns={this.state.userList}
  601. dataSource={this.state.distributionList}
  602. pagination={false}
  603. />
  604. </Spin>
  605. </div>
  606. </Spin>
  607. </Form>
  608. </Modal>
  609. </div>
  610. );
  611. }
  612. }));
  613. export default MySettlement;