yxBonus.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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 style={{
  143. maxWidth:'100px',
  144. overflow:'hidden',
  145. textOverflow: "ellipsis",
  146. whiteSpace:'nowrap',
  147. }}>{text}</div>
  148. </Tooltip>
  149. )
  150. }
  151. },
  152. {
  153. title: '订单负责人',
  154. dataIndex: 'salesName',
  155. key: 'salesName',
  156. },
  157. {
  158. title: '签单日期',
  159. dataIndex: 'signTime',
  160. key: 'signTime',
  161. },
  162. {
  163. title: '订单金额(万元)',
  164. dataIndex: 'totalAmount',
  165. key: 'totalAmount'
  166. },
  167. {
  168. title: '订单状态',
  169. dataIndex: 'orderStatus',
  170. key: 'orderStatus',
  171. render: (text) => {
  172. return getNewOrderStatus(text)
  173. }
  174. },
  175. {
  176. title: '项目状态',
  177. dataIndex: 'projectStatus',
  178. key: 'projectStatus',
  179. render: (text) => {
  180. return getProjectName(text)
  181. }
  182. },
  183. {
  184. title: '发放状态',
  185. dataIndex: 'grantStatus',
  186. key: 'grantStatus',
  187. render: (text) => {
  188. return getBonusState(text)
  189. }
  190. },
  191. {
  192. title: '发放类型',
  193. dataIndex: 'bonusSubject',
  194. key: 'bonusSubject',
  195. render: text => {
  196. return getJsyPaymentType(text)
  197. }
  198. },
  199. {
  200. title: '校对后单量',
  201. dataIndex: 'proofCount',
  202. key: 'proofCount'
  203. },
  204. {
  205. title: '已收(万元)',
  206. dataIndex: 'settlementAmount',
  207. key: 'settlementAmount'
  208. }, {
  209. title: '已退(万元)',
  210. dataIndex: 'refundAmount',
  211. key: 'refundAmount'
  212. }
  213. ],
  214. dataSource: [],
  215. searchTime: [,]
  216. }
  217. },
  218. tableRowClick(record, index) {
  219. this.state.RowData = record;
  220. this.setState({
  221. showDesc: true,
  222. });
  223. },
  224. closeDesc(e, s) {
  225. this.state.RowData = {};
  226. this.state.showDesc = e;
  227. if (s) {
  228. this.loadData(this.state.page);
  229. };
  230. },
  231. componentWillMount() {
  232. this.loadData();
  233. this.departmentList();
  234. },
  235. search() {
  236. this.loadData();
  237. },
  238. //导出
  239. exportExec() {
  240. let departmentName = '',
  241. depart = this.state.departmentArr || [];
  242. depart.map(item => {
  243. if (this.state.departmentId == item.id) {
  244. departmentName = item.name;
  245. return;
  246. }
  247. });
  248. let data = {
  249. departmentId: this.state.departmentId,
  250. departmentName: departmentName,
  251. salesName: this.state.orderRefundSearch,//订单负责人
  252. startTime: this.state.releaseDate[0],
  253. endTime: this.state.releaseDate[1],
  254. grantStatus: this.state.grantStatus,
  255. startTime1: this.state.createDate[0],
  256. endTime1: this.state.createDate[1],
  257. }
  258. window.location.href = (globalConfig.context + '/api/admin/bonus/exportAllSaleBonusData?' + $.param(data));
  259. },
  260. reset() {
  261. this.state.orderRefundSearch = '';
  262. this.state.releaseDate = [];
  263. this.state.createDate = [];
  264. this.state.orderNoSearch = '';
  265. this.state.departmenttList = undefined;
  266. this.state.grantStatus = undefined
  267. this.loadData();
  268. },
  269. searchSwitch() {
  270. this.setState({
  271. searchMore: !this.state.searchMore
  272. });
  273. },
  274. changeList(arr) {
  275. const newArr = [];
  276. this.state.columns.forEach(item => {
  277. arr.forEach(val => {
  278. if (val === item.title) {
  279. newArr.push(item);
  280. }
  281. });
  282. });
  283. this.setState({
  284. changeList: newArr
  285. });
  286. },
  287. render() {
  288. const rowSelection = {
  289. selectedRowKeys: this.state.selectedRowKeys,
  290. onChange: (selectedRowKeys, selectedRows) => {
  291. this.setState({
  292. selectedRows: selectedRows.slice(-1),
  293. selectedRowKeys: selectedRowKeys.slice(-1)
  294. });
  295. }
  296. };
  297. const hasSelected = this.state.selectedRowKeys.length > 0;
  298. const { RangePicker } = DatePicker;
  299. let departmentArr = this.state.departmentArr || [];
  300. return (
  301. <div className="user-content">
  302. <ShowModalDiv ShowModal={this.state.showModal} />
  303. <div className="content-title">
  304. <span>营销员奖金</span>
  305. </div>
  306. <Tabs
  307. defaultActiveKey="1"
  308. onChange={this.callback}
  309. className="test">
  310. <TabPane tab="搜索" key="1">
  311. <div className="user-search">
  312. <Select
  313. placeholder="订单部门"
  314. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  315. value={this.state.departmenttList}
  316. onChange={e => {
  317. this.setState({ departmenttList: e });
  318. }}
  319. >
  320. {departmentArr.map(function (item) {
  321. return (
  322. <Select.Option key={item.id}>{item.name}</Select.Option>
  323. );
  324. })}
  325. </Select>
  326. <Input
  327. placeholder="订单编号"
  328. value={this.state.orderNoSearch}
  329. onChange={e => {
  330. this.setState({ orderNoSearch: e.target.value });
  331. }}
  332. />
  333. <Input
  334. placeholder="订单负责人"
  335. value={this.state.orderRefundSearch}
  336. onChange={e => {
  337. this.setState({ orderRefundSearch: e.target.value });
  338. }}
  339. />
  340. <Select
  341. placeholder="发放状态"
  342. style={{ width: 150, marginRight: 10 }}
  343. value={this.state.grantStatus}
  344. onChange={e => {
  345. this.setState({ grantStatus: e });
  346. }}
  347. >
  348. <Option value="0">未发放</Option>
  349. <Option value="1">已发放</Option>
  350. </Select>
  351. <Button type="primary" onClick={this.search}>
  352. 搜索
  353. </Button>
  354. <Button onClick={this.reset}>重置</Button>
  355. <span>
  356. 更多搜索
  357. <Switch
  358. defaultChecked={false}
  359. onChange={this.searchSwitch.bind(this)}
  360. />
  361. </span>
  362. <div
  363. className="search-more"
  364. style={this.state.searchMore ? { display: "none" } : {}}
  365. >
  366. <span>签单时间 :</span>
  367. <RangePicker
  368. format="YYYY-MM"
  369. value={[
  370. this.state.releaseDate[0]
  371. ? moment(this.state.releaseDate[0])
  372. : null,
  373. this.state.releaseDate[1]
  374. ? moment(this.state.releaseDate[1])
  375. : null
  376. ]}
  377. onChange={(data, dataString) => {
  378. this.setState({ releaseDate: dataString });
  379. }}
  380. />
  381. <span>创建时间 :</span>
  382. <RangePicker
  383. format="YYYY-MM-DD"
  384. value={[
  385. this.state.createDate[0]
  386. ? moment(this.state.createDate[0])
  387. : null,
  388. this.state.createDate[1]
  389. ? moment(this.state.createDate[1])
  390. : null
  391. ]}
  392. onChange={(data, dataString) => {
  393. this.setState({ createDate: dataString });
  394. }}
  395. />
  396. </div>
  397. </div>
  398. </TabPane>
  399. <TabPane tab="导出" key="2">
  400. <div style={{ float: "left" }}>
  401. <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
  402. </div>
  403. </TabPane>
  404. <TabPane tab="更改表格显示数据" key="3">
  405. <div style={{ marginLeft: 10 }}>
  406. <ChooseList
  407. columns={this.state.columns}
  408. changeFn={this.changeList}
  409. changeList={this.state.changeList}
  410. top={55}
  411. margin={11}
  412. />
  413. </div>
  414. </TabPane>
  415. </Tabs>
  416. <div className="patent-table" id="table">
  417. <Spin spinning={this.state.loading}>
  418. <Table
  419. columns={
  420. this.state.changeList
  421. ? this.state.changeList
  422. : this.state.columns
  423. }
  424. dataSource={this.state.dataSource}
  425. rowSelection={false}
  426. pagination={this.state.pagination}
  427. onRowClick={this.tableRowClick}
  428. bordered
  429. size="small"
  430. />
  431. </Spin>
  432. </div>
  433. <BonuseDetail
  434. data={this.state.RowData}
  435. showDesc={this.state.showDesc}
  436. closeDesc={this.closeDesc.bind(this)}
  437. />
  438. </div>
  439. );
  440. }
  441. })
  442. export default YxBonus;