shouKuang.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. import React,{Component} from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import moment from 'moment';
  5. import './public.less';
  6. import { Button,Form, Input, Spin, Table, Switch, message, DatePicker, Modal } from 'antd';
  7. import OrderDesc from '../orderDetail/orderDesc'
  8. import Receivable from './receivable';
  9. import {getLiquidationStatus,getNewOrderStatus} from '@/tools';
  10. const FormItem = Form.Item;
  11. const ShouKuang = React.createClass({
  12. loadData(pageNo) {
  13. this.state.data = [];
  14. this.setState({
  15. selectedRowKeys:[],
  16. selectedRowKey:[],
  17. page:pageNo,
  18. loading: true
  19. });
  20. $.ajax({
  21. method: "get",
  22. dataType: "json",
  23. crossDomain: false,
  24. url: globalConfig.context + "/api/admin/financial/financeList",
  25. data: {
  26. pageNo: pageNo || 1,
  27. pageSize: this.state.pagination.pageSize,
  28. buyerName: this.state.nameSearch,//客户名称
  29. orderNo:this.state.orderNoSearch,
  30. startTime: this.state.releaseDate[0],
  31. endTime: this.state.releaseDate[1],
  32. },
  33. success: function (data) {
  34. let theArr = [];
  35. if (!data.data || !data.data.list) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. };
  39. } else {
  40. for (let i = 0; i < data.data.list.length; i++) {
  41. let thisdata = data.data.list[i];
  42. theArr.push({
  43. key: i,
  44. orderNo: thisdata.orderNo,
  45. orderType:thisdata.orderType,
  46. orderStatus:thisdata.orderStatus,
  47. sellerName:thisdata.sellerName,
  48. liquidationStatus:thisdata.liquidationStatus,
  49. approval:thisdata.approval,
  50. buyerName:thisdata.buyerName,
  51. actuallyTotalAmount:thisdata.actuallyTotalAmount,
  52. signTime:thisdata.signTime,
  53. companyId:thisdata.companyId,
  54. companyName:thisdata.companyName,
  55. buyerId:thisdata.buyerId,
  56. buyerName:thisdata.buyerName
  57. });
  58. };
  59. }
  60. this.state.pagination.current = data.data.pageNo;
  61. this.state.pagination.total = data.data.totalCount;
  62. if(data.data&&data.data.list&&!data.data.list.length){
  63. this.state.pagination.current=0
  64. this.state.pagination.total=0
  65. }
  66. this.setState({
  67. totalPage:data.data.totalPage,
  68. dataSource: theArr,
  69. pagination: this.state.pagination
  70. });
  71. }.bind(this),
  72. }).always(function () {
  73. this.setState({
  74. loading: false
  75. });
  76. }.bind(this));
  77. },
  78. getInitialState() {
  79. return {
  80. searchMore: true,
  81. assignVisible:false,
  82. releaseDate: [],
  83. assignData:[],
  84. totalPage:0,
  85. boHuivisible:false,
  86. selectedRowKeys: [],
  87. selectedRows: [],
  88. loading: false,
  89. pagination: {
  90. defaultCurrent: 1,
  91. defaultPageSize: 10,
  92. showQuickJumper: true,
  93. pageSize: 10,
  94. onChange: function (page) {
  95. this.loadData(page);
  96. }.bind(this),
  97. showTotal: function (total) {
  98. return '共' + total + '条数据';
  99. }
  100. },
  101. columns: [
  102. {
  103. title: '订单编号',
  104. dataIndex: 'orderNo',
  105. key: 'orderNo',
  106. },
  107. {
  108. title: '订单日期',
  109. dataIndex: 'signTime',
  110. key: 'signTime',
  111. },
  112. {
  113. title: '已收款(万元)',
  114. dataIndex: 'actuallyTotalAmount',
  115. key: 'actuallyTotalAmount',
  116. },
  117. {
  118. title: '客户名称',
  119. dataIndex: 'buyerName',
  120. key: 'buyerName',
  121. },
  122. {
  123. title: '订单状态',
  124. dataIndex: 'orderStatus',
  125. key: 'orderStatus',
  126. render: text => { return getNewOrderStatus(text)}
  127. },
  128. {
  129. title: '订单负责人',
  130. dataIndex: 'sellerName',
  131. key: 'sellerName'
  132. },
  133. {
  134. title: '结算状态',
  135. dataIndex: 'liquidationStatus',
  136. key: 'liquidationStatus',
  137. render: text => { return getLiquidationStatus(text)}
  138. },
  139. {
  140. title:'操作',
  141. dataIndex: 'caozuo',
  142. key: 'caouzo',
  143. render:(text,recard)=>{
  144. return <div>
  145. {recard.liquidationStatus<2&&<Button type="primary" style={{margin:'0 10px'}} onClick={(e)=>{e.stopPropagation(),this.evaluate(recard)}}>添加收款记录</Button>}
  146. {!(recard.actuallyTotalAmount&&Number(recard.actuallyTotalAmount)>0)&&<Button type="danger" onClick={(e)=>{e.stopPropagation(),this.reject(recard)}}>驳回</Button>}
  147. </div>
  148. }
  149. }
  150. ],
  151. dataSource: [],
  152. searchTime: [,]
  153. }
  154. },
  155. /* 添加收款记录 */
  156. evaluate(recard){
  157. this.state.assignData=recard;
  158. this.setState({
  159. assignVisible:true
  160. })
  161. },
  162. /* 驳回 */
  163. reject(recard){
  164. this.setState({
  165. bohuiData:recard,
  166. boHuiVisible:true,
  167. content:''
  168. })
  169. },
  170. boHuiOk(){
  171. this.setState({
  172. boHuiVisible:false
  173. })
  174. if((this.state.pagination.current==this.state.totalPage)&&(this.state.pagination.total)%10==1){
  175. this.loadData((this.state.page)-1);
  176. }else{
  177. this.loadData(this.state.page);
  178. }
  179. },
  180. boHuiCancel(e){
  181. this.setState({
  182. boHuiVisible:false
  183. })
  184. },
  185. componentWillMount() {
  186. this.loadData();
  187. },
  188. tableRowClick(record, index) {
  189. this.state.RowData = record;
  190. this.setState({
  191. showDesc: true,
  192. });
  193. },
  194. closeDesc(e, s) {
  195. this.state.showDesc = e;
  196. if (s) {
  197. this.loadData(this.state.page);
  198. };
  199. },
  200. closeAssign(e, s) {
  201. this.state.assignData={};
  202. this.state.assignVisible = e;
  203. if (s) {
  204. this.loadData(this.state.page);
  205. };
  206. },
  207. search() {
  208. this.loadData();
  209. },
  210. reset() {
  211. this.state.nameSearch = '';
  212. this.state.releaseDate = [];
  213. this.state.orderNoSearch='';
  214. this.loadData();
  215. },
  216. //驳回
  217. boHuiSubmit(e){
  218. e.preventDefault();
  219. if(!this.state.content){
  220. message.warning('请填写驳回原因');
  221. return false;
  222. }
  223. this.setState({
  224. loading:true
  225. })
  226. $.ajax({
  227. method: "POST",
  228. dataType: "json",
  229. crossDomain: false,
  230. url: globalConfig.context + "/api/admin/financial/reject",
  231. data: {
  232. orderNo: this.state.bohuiData.orderNo,
  233. reason:this.state.content
  234. }
  235. }).done(function (data) {
  236. if (!data.error.length) {
  237. message.success('驳回成功!');
  238. this.setState({
  239. loading: false,
  240. });
  241. this.boHuiOk();
  242. } else {
  243. message.warning(data.error[0].message);
  244. };
  245. }.bind(this));
  246. },
  247. searchSwitch() {
  248. this.setState({
  249. searchMore: !this.state.searchMore
  250. });
  251. },
  252. render() {
  253. const rowSelection = {
  254. selectedRowKeys: this.state.selectedRowKeys,
  255. onChange: (selectedRowKeys, selectedRows) => {
  256. this.setState({
  257. selectedRows: selectedRows.slice(-1),
  258. selectedRowKeys: selectedRowKeys.slice(-1)
  259. });
  260. }
  261. };
  262. const hasSelected = this.state.selectedRowKeys.length > 0;
  263. const { RangePicker } = DatePicker;
  264. const hasSelect = this.state.selectedRowKeys.length;
  265. return ( <div className="user-content">
  266. <div className="content-title">
  267. <span>收款结算</span>
  268. </div>
  269. <div className="user-search">
  270. <Input placeholder="订单编号"
  271. value={this.state.orderNoSearch}
  272. onChange={(e) => { this.setState({ orderNoSearch: e.target.value }); }} />
  273. <Input placeholder="客户名称"
  274. value={this.state.nameSearch}
  275. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  276. <Button type="primary" onClick={this.search}>搜索</Button>
  277. <Button onClick={this.reset}>重置</Button>
  278. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch.bind(this)} /></span>
  279. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  280. <span>订单时间 :</span>
  281. <RangePicker
  282. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  283. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  284. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  285. </div>
  286. </div>
  287. <div className="patent-table">
  288. <Spin spinning={this.state.loading}>
  289. <Table columns={this.state.columns}
  290. dataSource={this.state.dataSource}
  291. rowSelection={false}
  292. pagination={this.state.pagination}
  293. onRowClick={this.tableRowClick.bind(this)} />
  294. </Spin>
  295. </div>
  296. <OrderDesc
  297. data={this.state.RowData}
  298. showDesc={this.state.showDesc}
  299. closeDesc={this.closeDesc.bind(this)}
  300. />
  301. <Receivable
  302. title='收款记录'
  303. api='/api/admin/financial/addReceiptsFlow'
  304. data={this.state.assignData}
  305. showDesc={this.state.assignVisible}
  306. closeDesc={this.closeAssign.bind(this)}
  307. />
  308. <Modal visible={this.state.boHuiVisible}
  309. width="400px"
  310. title="驳回备注"
  311. footer=''
  312. onOk={this.boHuiOk}
  313. onCancel={this.boHuiCancel}
  314. >
  315. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  316. <Spin spinning={this.state.loading}>
  317. <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label={<span><strong style={{color:'#f00'}}>*</strong>驳回原因</span>}>
  318. <Input
  319. type="textarea"
  320. rows={4}
  321. placeholder="请输入驳回原因"
  322. value={this.state.content}
  323. onChange={(e) => {
  324. this.setState({ content: e.target.value });
  325. }}
  326. />
  327. </FormItem>
  328. <FormItem wrapperCol={{ span: 12, offset:5 }}>
  329. <Button type="primary" htmlType="submit" style={{marginRight:20}}>驳回</Button>
  330. <Button type="default" onClick={()=>{this.boHuiCancel()}}>取消</Button>
  331. </FormItem>
  332. </Spin>
  333. </Form>
  334. </Modal>
  335. </div> )
  336. }
  337. })
  338. export default ShouKuang;