yxBonus.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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 '@/manageCenter/financialManage/distribute/public.less';
  6. import { Button, Input, Spin, Table, Select, Switch, message, DatePicker, Tabs,Tooltip } from 'antd';
  7. import {
  8. getNewOrderStatus,
  9. getProjectName,
  10. getJsyPaymentType,
  11. getBonusState,
  12. ShowModal
  13. } from "@/tools";
  14. import BonuseDetail from '@/manageCenter/financialManage/bonus/bonusDetail';
  15. import ShowModalDiv from "@/showModal.jsx";
  16. import {ChooseList} from "../orderNew/chooseList";
  17. const { TabPane } = Tabs
  18. const YxBonus = React.createClass({
  19. departmentList() {
  20. this.setState({
  21. loading: true
  22. });
  23. $.ajax({
  24. method: "get",
  25. dataType: "json",
  26. crossDomain: false,
  27. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  28. data: {},
  29. success: function (data) {
  30. let thedata = data.data;
  31. let theArr = [];
  32. if (!thedata) {
  33. if (data.error && data.error.length) {
  34. message.warning(data.error[0].message);
  35. };
  36. } else {
  37. thedata.map(function (item, index) {
  38. theArr.push({
  39. key: index,
  40. name: item.name,
  41. id: item.id,
  42. })
  43. })
  44. }
  45. this.setState({
  46. departmentArr: theArr,
  47. })
  48. }.bind(this),
  49. }).always(function () {
  50. this.setState({
  51. loading: false
  52. });
  53. }.bind(this));
  54. },
  55. loadData(pageNo) {
  56. this.state.data = [];
  57. this.setState({
  58. selectedRowKeys: [],
  59. selectedRowKey: [],
  60. page: pageNo,
  61. loading: true
  62. });
  63. $.ajax({
  64. method: "get",
  65. dataType: "json",
  66. crossDomain: false,
  67. url: globalConfig.context + "/api/admin/bonus/getAllSaleBonus",
  68. data: {
  69. pageNo: pageNo || 1,
  70. pageSize: this.state.pagination.pageSize,
  71. salesName: this.state.orderRefundSearch,//订单负责人
  72. departmentId: this.state.departmenttList,
  73. orderNo: this.state.orderNoSearch,
  74. startTime: this.state.releaseDate[0],
  75. endTime: this.state.releaseDate[1],
  76. grantStatus: this.state.grantStatus,
  77. startTime1: this.state.createDate[0],
  78. endTime1: this.state.createDate[1],
  79. },
  80. success: function (data) {
  81. ShowModal(this);
  82. let theArr = [];
  83. if (!data.data || !data.data.list) {
  84. if (data.error && data.error.length) {
  85. message.warning(data.error[0].message);
  86. };
  87. }
  88. this.state.pagination.current = data.data.pageNo;
  89. this.state.pagination.total = data.data.totalCount;
  90. if (data.data && data.data.list && !data.data.list.length) {
  91. this.state.pagination.current = 0
  92. this.state.pagination.total = 0
  93. }
  94. this.setState({
  95. dataSource: data.data.list,
  96. pagination: this.state.pagination
  97. });
  98. }.bind(this),
  99. }).always(function () {
  100. this.setState({
  101. loading: false
  102. });
  103. }.bind(this));
  104. },
  105. getInitialState() {
  106. return {
  107. searchMore: true,
  108. releaseDate: [],
  109. createDate: [],
  110. RowData: {},
  111. execState: false,
  112. selectedRowKeys: [],
  113. selectedRows: [],
  114. proofData: {},
  115. loading: false,
  116. pagination: {
  117. defaultCurrent: 1,
  118. defaultPageSize: 10,
  119. showQuickJumper: true,
  120. pageSize: 10,
  121. onChange: function (page) {
  122. this.loadData(page);
  123. }.bind(this),
  124. showTotal: function (total) {
  125. return '共' + total + '条数据';
  126. }
  127. },
  128. columns: [
  129. {
  130. title: '订单编号',
  131. dataIndex: 'orderNo',
  132. key: 'orderNo',
  133. },
  134. {
  135. title: '客户名称',
  136. dataIndex: 'buyName',
  137. key: 'buyName',
  138. width:100,
  139. render: text => {
  140. return (
  141. <Tooltip title={text}>
  142. <div
  143. // style={{
  144. // maxWidth:'100px',
  145. // overflow:'hidden',
  146. // textOverflow: "ellipsis",
  147. // whiteSpace:'nowrap',
  148. // }}
  149. >{text}</div>
  150. </Tooltip>
  151. )
  152. }
  153. },
  154. {
  155. title: '订单负责人',
  156. dataIndex: 'salesName',
  157. key: 'salesName',
  158. },
  159. {
  160. title: '签单日期',
  161. dataIndex: 'signTime',
  162. key: 'signTime',
  163. },
  164. {
  165. title: '订单金额(万元)',
  166. dataIndex: 'totalAmount',
  167. key: 'totalAmount'
  168. },
  169. {
  170. title: '订单状态',
  171. dataIndex: 'orderStatus',
  172. key: 'orderStatus',
  173. render: (text) => {
  174. return getNewOrderStatus(text)
  175. }
  176. },
  177. {
  178. title: '项目状态',
  179. dataIndex: 'projectStatus',
  180. key: 'projectStatus',
  181. render: (text) => {
  182. return getProjectName(text)
  183. }
  184. },
  185. {
  186. title: '发放状态',
  187. dataIndex: 'grantStatus',
  188. key: 'grantStatus',
  189. render: (text) => {
  190. return getBonusState(text)
  191. }
  192. },
  193. {
  194. title: '发放类型',
  195. dataIndex: 'bonusSubject',
  196. key: 'bonusSubject',
  197. render: text => {
  198. return getJsyPaymentType(text)
  199. }
  200. },
  201. {
  202. title: '校对后单量',
  203. dataIndex: 'proofCount',
  204. key: 'proofCount'
  205. },
  206. {
  207. title: '已收(万元)',
  208. dataIndex: 'settlementAmount',
  209. key: 'settlementAmount'
  210. }, {
  211. title: '已退(万元)',
  212. dataIndex: 'refundAmount',
  213. key: 'refundAmount'
  214. }
  215. ],
  216. dataSource: [],
  217. searchTime: [,]
  218. }
  219. },
  220. tableRowClick(record, index) {
  221. this.state.RowData = record;
  222. this.setState({
  223. showDesc: true,
  224. });
  225. },
  226. closeDesc(e, s) {
  227. this.state.RowData = {};
  228. this.state.showDesc = e;
  229. if (s) {
  230. this.loadData(this.state.page);
  231. };
  232. },
  233. componentWillMount() {
  234. this.loadData();
  235. this.departmentList();
  236. },
  237. search() {
  238. this.loadData();
  239. },
  240. //导出
  241. exportExec() {
  242. let departmentName = '',
  243. depart = this.state.departmentArr || [];
  244. depart.map(item => {
  245. if (this.state.departmentId == item.id) {
  246. departmentName = item.name;
  247. return;
  248. }
  249. });
  250. let data = {
  251. departmentId: this.state.departmentId,
  252. departmentName: departmentName,
  253. salesName: this.state.orderRefundSearch,//订单负责人
  254. startTime: this.state.releaseDate[0],
  255. endTime: this.state.releaseDate[1],
  256. grantStatus: this.state.grantStatus,
  257. startTime1: this.state.createDate[0],
  258. endTime1: this.state.createDate[1],
  259. }
  260. window.location.href = (globalConfig.context + '/api/admin/bonus/exportAllSaleBonusData?' + $.param(data));
  261. },
  262. reset() {
  263. this.state.orderRefundSearch = '';
  264. this.state.releaseDate = [];
  265. this.state.createDate = [];
  266. this.state.orderNoSearch = '';
  267. this.state.departmenttList = undefined;
  268. this.state.grantStatus = undefined
  269. this.loadData();
  270. },
  271. searchSwitch() {
  272. this.setState({
  273. searchMore: !this.state.searchMore
  274. });
  275. },
  276. changeList(arr) {
  277. const newArr = [];
  278. this.state.columns.forEach(item => {
  279. arr.forEach(val => {
  280. if (val === item.title) {
  281. newArr.push(item);
  282. }
  283. });
  284. });
  285. this.setState({
  286. changeList: newArr
  287. });
  288. },
  289. render() {
  290. const rowSelection = {
  291. selectedRowKeys: this.state.selectedRowKeys,
  292. onChange: (selectedRowKeys, selectedRows) => {
  293. this.setState({
  294. selectedRows: selectedRows.slice(-1),
  295. selectedRowKeys: selectedRowKeys.slice(-1)
  296. });
  297. }
  298. };
  299. const hasSelected = this.state.selectedRowKeys.length > 0;
  300. const { RangePicker } = DatePicker;
  301. let departmentArr = this.state.departmentArr || [];
  302. return (
  303. <div className="user-content">
  304. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  305. <div className="content-title">
  306. <span>营销员奖金</span>
  307. </div>
  308. <Tabs
  309. defaultActiveKey="1"
  310. onChange={this.callback}
  311. className="test">
  312. <TabPane tab="搜索" key="1">
  313. <div className="user-search">
  314. <Select
  315. placeholder="订单部门"
  316. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  317. value={this.state.departmenttList}
  318. onChange={e => {
  319. this.setState({ departmenttList: e });
  320. }}
  321. >
  322. {departmentArr.map(function (item) {
  323. return (
  324. <Select.Option key={item.id}>{item.name}</Select.Option>
  325. );
  326. })}
  327. </Select>
  328. <Input
  329. placeholder="订单编号"
  330. value={this.state.orderNoSearch}
  331. onChange={e => {
  332. this.setState({ orderNoSearch: e.target.value });
  333. }}
  334. />
  335. <Input
  336. placeholder="订单负责人"
  337. value={this.state.orderRefundSearch}
  338. onChange={e => {
  339. this.setState({ orderRefundSearch: e.target.value });
  340. }}
  341. />
  342. <Select
  343. placeholder="发放状态"
  344. style={{ width: 150, marginRight: 10 }}
  345. value={this.state.grantStatus}
  346. onChange={e => {
  347. this.setState({ grantStatus: e });
  348. }}
  349. >
  350. <Option value="0">未发放</Option>
  351. <Option value="1">已发放</Option>
  352. </Select>
  353. <Button type="primary" onClick={this.search}>
  354. 搜索
  355. </Button>
  356. <Button onClick={this.reset}>重置</Button>
  357. <span>
  358. 更多搜索
  359. <Switch
  360. defaultChecked={false}
  361. onChange={this.searchSwitch.bind(this)}
  362. />
  363. </span>
  364. <div
  365. className="search-more"
  366. style={this.state.searchMore ? { display: "none" } : {}}
  367. >
  368. <span>签单时间 :</span>
  369. <RangePicker
  370. format="YYYY-MM"
  371. value={[
  372. this.state.releaseDate[0]
  373. ? moment(this.state.releaseDate[0])
  374. : null,
  375. this.state.releaseDate[1]
  376. ? moment(this.state.releaseDate[1])
  377. : null
  378. ]}
  379. onChange={(data, dataString) => {
  380. this.setState({ releaseDate: dataString });
  381. }}
  382. />
  383. <span>创建时间 :</span>
  384. <RangePicker
  385. format="YYYY-MM-DD"
  386. value={[
  387. this.state.createDate[0]
  388. ? moment(this.state.createDate[0])
  389. : null,
  390. this.state.createDate[1]
  391. ? moment(this.state.createDate[1])
  392. : null
  393. ]}
  394. onChange={(data, dataString) => {
  395. this.setState({ createDate: dataString });
  396. }}
  397. />
  398. </div>
  399. </div>
  400. </TabPane>
  401. <TabPane tab="导出" key="2">
  402. <div style={{ float: "left" }}>
  403. <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
  404. </div>
  405. </TabPane>
  406. <TabPane tab="更改表格显示数据" key="3">
  407. <div style={{ marginLeft: 10 }}>
  408. <ChooseList
  409. columns={this.state.columns}
  410. changeFn={this.changeList}
  411. changeList={this.state.changeList}
  412. top={55}
  413. margin={11}
  414. />
  415. </div>
  416. </TabPane>
  417. </Tabs>
  418. <div className="patent-table" id="table">
  419. <Spin spinning={this.state.loading}>
  420. <Table
  421. columns={
  422. this.state.changeList
  423. ? this.state.changeList
  424. : this.state.columns
  425. }
  426. dataSource={this.state.dataSource}
  427. rowSelection={false}
  428. pagination={this.state.pagination}
  429. onRowClick={this.tableRowClick}
  430. bordered
  431. size="small"
  432. />
  433. </Spin>
  434. </div>
  435. <BonuseDetail
  436. data={this.state.RowData}
  437. showDesc={this.state.showDesc}
  438. closeDesc={this.closeDesc.bind(this)}
  439. />
  440. </div>
  441. );
  442. }
  443. })
  444. export default YxBonus;