shouKuang.jsx 12 KB

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