yxBonus.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. import React from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import moment from 'moment';
  5. import '../distribute/public.less';
  6. import { Button, Input, Spin, Table,Select, Switch, message, DatePicker,Modal ,Form } from 'antd';
  7. import {getNewOrderStatus,getProjectStatus,getPaymentType,getTransactionProject,getBonusState} from '@/tools';
  8. import BonuseDetail from './bonusDetail';
  9. const FormItem= Form.Item;
  10. const YxBonus = React.createClass({
  11. departmentList() {
  12. this.setState({
  13. loading: true
  14. });
  15. $.ajax({
  16. method: "post",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + "/api/admin/organization/listOrganizationManagement",
  20. data: {
  21. pageNo:1,
  22. pageSize:999,
  23. type:1
  24. },
  25. success: function(data) {
  26. let thedata = data.data.list;
  27. let theArr=[];
  28. if(!thedata) {
  29. if(data.error && data.error.length) {
  30. message.warning(data.error[0].message);
  31. };
  32. thedata = {};
  33. }else{
  34. thedata.map(function(item,index){
  35. theArr.push({
  36. key:index,
  37. name:item.name,
  38. id:item.id,
  39. })
  40. })
  41. }
  42. this.setState({
  43. departmentArr:theArr,
  44. })
  45. }.bind(this),
  46. }).always(function() {
  47. this.setState({
  48. loading: false
  49. });
  50. }.bind(this));
  51. },
  52. loadData(pageNo) {
  53. this.state.data = [];
  54. this.setState({
  55. selectedRowKeys:[],
  56. selectedRowKey:[],
  57. page:pageNo,
  58. loading: true
  59. });
  60. $.ajax({
  61. method: "post",
  62. dataType: "json",
  63. crossDomain: false,
  64. url: globalConfig.context + "/api/admin/order/listAllSettlement",
  65. data: {
  66. pageNo: pageNo || 1,
  67. pageSize:this.state.pagination.pageSize,
  68. ownerName: this.state.nameSearch,//客户名称
  69. departmentId:this.state.departmenttList,
  70. startDate: this.state.releaseDate[0],
  71. endDate: this.state.releaseDate[1],
  72. },
  73. success: function (data) {
  74. let theArr = [];
  75. if (!data.data || !data.data.list) {
  76. if (data.error && data.error.length) {
  77. message.warning(data.error[0].message);
  78. };
  79. } else {
  80. for (let i = 0; i < data.data.list.length; i++) {
  81. let thisdata = data.data.list[i];
  82. theArr.push({
  83. key: i,
  84. orderNo: thisdata.orderNo,
  85. orderType:thisdata.orderType,
  86. orderStatus:thisdata.orderStatus,
  87. processStatus:thisdata.processStatus,
  88. projectStage:thisdata.projectStage,
  89. approval:thisdata.approval,
  90. creater:thisdata.creater,
  91. createTime:thisdata.createTime?(new Date(thisdata.createTime)).toLocaleString():'',
  92. signTime:thisdata.signTime?(new Date(thisdata.signTime)).toLocaleString():''
  93. });
  94. };
  95. }
  96. this.state.pagination.current = data.data.pageNo;
  97. this.state.pagination.total = data.data.totalCount;
  98. if(data.data&&data.data.list&&!data.data.list.length){
  99. this.state.pagination.current=0
  100. this.state.pagination.total=0
  101. }
  102. this.setState({
  103. dataSource: theArr,
  104. pagination: this.state.pagination
  105. });
  106. }.bind(this),
  107. }).always(function () {
  108. this.setState({
  109. loading: false
  110. });
  111. }.bind(this));
  112. },
  113. getInitialState() {
  114. return {
  115. searchMore: true,
  116. releaseDate: [],
  117. RowData:{},
  118. execState:false,
  119. selectedRowKeys: [],
  120. selectedRows: [],
  121. proofData:{},
  122. loading: false,
  123. pagination: {
  124. defaultCurrent: 1,
  125. defaultPageSize: 10,
  126. showQuickJumper: true,
  127. pageSize: 10,
  128. onChange: function (page) {
  129. this.loadData(page);
  130. }.bind(this),
  131. showTotal: function (total) {
  132. return '共' + total + '条数据';
  133. }
  134. },
  135. columns: [
  136. {
  137. title: '订单编号',
  138. dataIndex: 'orderNo',
  139. key: 'orderNo',
  140. },
  141. {
  142. title: '订单负责人',
  143. dataIndex: 'sellerName',
  144. key: 'sellerName',
  145. },
  146. {
  147. title: '签单日期',
  148. dataIndex: 'signTime',
  149. key: 'signTime',
  150. },
  151. {
  152. title: '客户名称',
  153. dataIndex: 'buyerName',
  154. key: 'buyerName',
  155. render:text=>{
  156. return text&&text>8?text.substr(0,8)+'...':text
  157. }
  158. },
  159. {
  160. title: '订单金额',
  161. dataIndex: 'transactionAmount',
  162. key: 'transactionAmount'
  163. },
  164. {
  165. title: '流水科目',
  166. dataIndex: 'transactionSubject',
  167. key: 'transactionSubject',
  168. render:(text)=>{
  169. return getTransactionProject(text)
  170. }
  171. },
  172. {
  173. title: '订单状态',
  174. dataIndex: 'orderStatus',
  175. key: 'orderStatus',
  176. render:(text)=>{
  177. return getNewOrderStatus(text)
  178. }
  179. },
  180. {
  181. title: '项目状态',
  182. dataIndex: 'projectStatus',
  183. key: 'projectStatus',
  184. render:(text)=>{
  185. return getProjectStatus(text)
  186. }
  187. },
  188. {
  189. title: '发放状态',
  190. dataIndex: 'creater11',
  191. key: 'creater11',
  192. render:(text)=>{
  193. return getBonusState(text)
  194. }
  195. },
  196. {
  197. title: '发放类型',
  198. dataIndex: 'creater11t',
  199. key: 'creater11t',
  200. render:text=>{
  201. return getPaymentType(text)
  202. }
  203. },
  204. {
  205. title: '已收',
  206. dataIndex: 'creater22',
  207. key: 'creater22'
  208. },{
  209. title: '已退',
  210. dataIndex: 'creater33',
  211. key: 'creater33'
  212. },
  213. {
  214. title: '操作',
  215. dataIndex: 'state11',
  216. key: 'state11',
  217. render:(text,recard)=>{
  218. return <div>
  219. <Button type="primary" style={{margin:'0 10px'}} onClick={(e)=>{e.stopPropagation(),this.proofread(recard,0)}}>发放</Button>
  220. <Button type="primary" onClick={(e)=>{e.stopPropagation(),this.proofread(recard,1)}}>校对</Button>
  221. </div>
  222. }
  223. },
  224. ],
  225. dataSource: [],
  226. searchTime: [,]
  227. }
  228. },
  229. proofread(recard,index){
  230. this.setState({
  231. proofreadState:index,
  232. boHuiVisible:true,
  233. proofData: recard,
  234. result:''
  235. })
  236. },
  237. tableRowClick(record, index) {
  238. this.state.RowData = record;
  239. this.setState({
  240. showDesc: true,
  241. });
  242. },
  243. closeDesc(e, s) {
  244. this.state.RowData={};
  245. this.state.showDesc = e;
  246. if (s) {
  247. this.loadData(this.state.page);
  248. };
  249. },
  250. componentWillMount() {
  251. this.loadData();
  252. this.departmentList();
  253. },
  254. search() {
  255. this.loadData();
  256. },
  257. boHuiOk(){
  258. this.setState({
  259. boHuiVisible:false
  260. })
  261. this.loadData(this.state.page);
  262. },
  263. boHuiCancel(e){
  264. this.setState({
  265. boHuiVisible:false
  266. })
  267. },
  268. //导出
  269. exportExec(){
  270. let departmentName='',
  271. depart =this.state.departmentArr || [];
  272. depart.map(item=>{
  273. if(this.state.departmentId==item.id){
  274. departmentName=item.name;
  275. return;
  276. }
  277. });
  278. let data = {
  279. departmentId:this.state.departmentId,
  280. departmentName:departmentName,
  281. ownerName: this.state.nameSearch,//订单负责人
  282. startDate: this.state.releaseDate[0],
  283. endDate: this.state.releaseDate[1],
  284. }
  285. window.location.href=(globalConfig.context+'/api/admin/financial/exportBillData?'+$.param(data));
  286. },
  287. //保存发放状态
  288. boHuiSubmit(e){
  289. e.preventDefault();
  290. if(this.state.proofreadState&&!this.state.result){
  291. message.warning('请填写校对结果');
  292. return false;
  293. }
  294. this.setState({
  295. loading:true
  296. });
  297. $.ajax({
  298. method: "POST",
  299. dataType: "json",
  300. crossDomain: false,
  301. url: globalConfig.context + "/api/user/achievement/delete",
  302. data: {
  303. id: this.state.proofData.id,
  304. index:this.state.proofreadState, //0-发放 1-校对
  305. result:this.state.result //校对结果
  306. }
  307. }).done(function (data) {
  308. if (!data.error.length) {
  309. message.success('操作成功!');
  310. this.boHuiOk()
  311. } else {
  312. message.warning(data.error[0].message);
  313. };
  314. this.setState({
  315. loading: false
  316. });
  317. }.bind(this));
  318. },
  319. reset() {
  320. this.state.orderRefundSearch='';
  321. this.state.releaseDate = [];
  322. this.state.departmenttList=undefined;
  323. this.state.orderNoSearch='';
  324. this.loadData();
  325. },
  326. searchSwitch() {
  327. this.setState({
  328. searchMore: !this.state.searchMore
  329. });
  330. },
  331. render() {
  332. const rowSelection = {
  333. selectedRowKeys: this.state.selectedRowKeys,
  334. onChange: (selectedRowKeys, selectedRows) => {
  335. this.setState({
  336. selectedRows: selectedRows.slice(-1),
  337. selectedRowKeys: selectedRowKeys.slice(-1)
  338. });
  339. }
  340. };
  341. const hasSelected = this.state.selectedRowKeys.length > 0;
  342. const { RangePicker } = DatePicker;
  343. let departmentArr = this.state.departmentArr || [];
  344. return ( <div className="user-content">
  345. <div className="content-title">
  346. <span>营销员奖金</span>
  347. </div>
  348. <div className="user-search">
  349. <Select placeholder="订单部门"
  350. style={{ width: 150 ,marginRight:10}}
  351. value={this.state.departmenttList}
  352. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  353. {
  354. departmentArr.map(function (item) {
  355. return <Select.Option key={item.id} >{item.name}</Select.Option>
  356. })
  357. }
  358. </Select>
  359. <Input placeholder="订单负责人"
  360. value={this.state.orderRefundSearch}
  361. onChange={(e) => { this.setState({ orderRefundSearch: e.target.value }); }} />
  362. <Button type="primary" onClick={this.search}>搜索</Button>
  363. <Button onClick={this.reset}>重置</Button>
  364. <div style={{float:'right'}}>
  365. <Button onClick={this.exportExec}>导出exec</Button>
  366. </div>
  367. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch.bind(this)} /></span>
  368. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  369. <span>签单时间 :</span>
  370. <RangePicker
  371. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  372. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  373. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  374. </div>
  375. </div>
  376. <div className="patent-table" id="table">
  377. <Spin spinning={this.state.loading}>
  378. <Table columns={this.state.columns}
  379. dataSource={this.state.dataSource}
  380. rowSelection={rowSelection}
  381. pagination={this.state.pagination}
  382. onRowClick={this.tableRowClick}
  383. />
  384. </Spin>
  385. </div>
  386. <BonuseDetail
  387. data={this.state.RowData}
  388. showDesc={this.state.showDesc}
  389. closeDesc={this.closeDesc.bind(this)}
  390. />
  391. <Modal visible={this.state.boHuiVisible}
  392. width="400px"
  393. title={this.state.proofreadState?"校对":'发放'}
  394. footer=''
  395. onOk={this.boHuiOk}
  396. onCancel={this.boHuiCancel}
  397. >
  398. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  399. <Spin spinning={this.state.loading}>
  400. {this.state.proofreadState?<div>
  401. <FormItem labelCol={{ span: 8 }} wrapperCol={{ span: 10 }} label={<span><strong style={{color:'#f00'}}>*</strong>单量校对结果</span>}>
  402. <Input
  403. placeholder="请输入单量校对结果"
  404. value={this.state.result}
  405. onChange={(e) => {
  406. this.setState({ result: e.target.value });
  407. }}
  408. />
  409. </FormItem>
  410. <FormItem labelCol={{ span: 8 }} wrapperCol={{ span: 10 }} label='校对人'>
  411. <span>{this.state.proofData.name}</span>
  412. </FormItem>
  413. </div>:
  414. <div>
  415. <FormItem labelCol={{ span: 8 }} wrapperCol={{ span: 10 }} label='应收人'>
  416. <span>{this.state.proofData.name}</span>
  417. </FormItem>
  418. <FormItem labelCol={{ span: 8 }} wrapperCol={{ span: 10 }} label='发放人'>
  419. <span>{this.state.proofData.name}</span>
  420. </FormItem>
  421. <FormItem labelCol={{ span: 8 }} wrapperCol={{ span: 10 }} label='发放日期'>
  422. <span>{this.state.proofData.time}</span>
  423. </FormItem>
  424. </div>
  425. }
  426. <FormItem wrapperCol={{ span: 12, offset:8 }}>
  427. <Button type="primary" htmlType="submit" style={{marginRight:20}}>保存</Button>
  428. <Button type="default" onClick={()=>{this.boHuiCancel()}}>取消</Button>
  429. </FormItem>
  430. </Spin>
  431. </Form>
  432. </Modal>
  433. </div> )
  434. }
  435. })
  436. export default YxBonus;