yxBonus.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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 {
  7. Button,
  8. Input,
  9. Spin,
  10. Table,
  11. Select,
  12. Switch,
  13. InputNumber,
  14. message,
  15. DatePicker,
  16. Modal,
  17. Form,
  18. Tabs,
  19. Tooltip
  20. } from 'antd';
  21. import { getNewOrderStatus, getProjectName, getJsyPaymentType, getBonusState, ShowModal } from '@/tools';
  22. import BonuseDetail from './bonusDetail';
  23. import { ChooseList } from "../../order/orderNew/chooseList";
  24. const FormItem = Form.Item;
  25. import ShowModalDiv from "@/showModal.jsx";
  26. const { TabPane } = Tabs
  27. const YxBonus = React.createClass({
  28. departmentList() {
  29. this.setState({
  30. loading: true
  31. });
  32. $.ajax({
  33. method: "get",
  34. dataType: "json",
  35. crossDomain: false,
  36. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  37. data: {},
  38. success: function (data) {
  39. let thedata = data.data;
  40. let theArr = [];
  41. if (!thedata) {
  42. if (data.error && data.error.length) {
  43. message.warning(data.error[0].message);
  44. }
  45. } else {
  46. thedata.map(function (item, index) {
  47. theArr.push({
  48. key: index,
  49. name: item.name,
  50. id: item.id
  51. });
  52. });
  53. }
  54. this.setState({
  55. departmentArr: theArr
  56. });
  57. }.bind(this)
  58. }).always(
  59. function () {
  60. this.setState({
  61. loading: false
  62. });
  63. }.bind(this)
  64. );
  65. },
  66. loadData(pageNo) {
  67. this.state.data = [];
  68. this.setState({
  69. selectedRowKeys: [],
  70. selectedRowKey: [],
  71. page: pageNo,
  72. loading: true
  73. });
  74. $.ajax({
  75. method: "get",
  76. dataType: "json",
  77. crossDomain: false,
  78. url: globalConfig.context + "/api/admin/bonus/saleBonusStatistics",
  79. data: {
  80. pageNo: pageNo || 1,
  81. pageSize: this.state.pagination.pageSize,
  82. salesName: this.state.orderRefundSearch, //订单负责人
  83. departmentId: this.state.departmenttList,
  84. orderNo: this.state.orderNoSearch,
  85. startTime: this.state.releaseDate[0],
  86. endTime: this.state.releaseDate[1],
  87. grantStatus: this.state.grantStatus,
  88. startTime1: this.state.createDate[0],
  89. endTime1: this.state.createDate[1]
  90. },
  91. success: function (data) {
  92. ShowModal(this);
  93. let theArr = [];
  94. if (!data.data || !data.data.list) {
  95. if (data.error && data.error.length) {
  96. message.warning(data.error[0].message);
  97. }
  98. }
  99. this.state.pagination.current = data.data.pageNo;
  100. this.state.pagination.total = data.data.totalCount;
  101. if (data.data && data.data.list && !data.data.list.length) {
  102. this.state.pagination.current = 0;
  103. this.state.pagination.total = 0;
  104. }
  105. this.setState({
  106. dataSource: data.data.list,
  107. pagination: this.state.pagination
  108. });
  109. }.bind(this)
  110. }).always(
  111. function () {
  112. this.setState({
  113. loading: false
  114. });
  115. }.bind(this)
  116. );
  117. },
  118. getInitialState() {
  119. return {
  120. searchMore: true,
  121. releaseDate: [],
  122. createDate: [],
  123. RowData: {},
  124. execState: false,
  125. selectedRowKeys: [],
  126. selectedRows: [],
  127. proofData: {},
  128. loading: false,
  129. changeList: undefined,
  130. pagination: {
  131. defaultCurrent: 1,
  132. defaultPageSize: 10,
  133. showQuickJumper: true,
  134. pageSize: 10,
  135. onChange: function (page) {
  136. this.loadData(page);
  137. }.bind(this),
  138. showTotal: function (total) {
  139. return "共" + total + "条数据";
  140. }
  141. },
  142. columns: [
  143. {
  144. title: "订单编号",
  145. dataIndex: "orderNo",
  146. key: "orderNo",
  147. // fixed: "left"
  148. },
  149. {
  150. title: "客户名称",
  151. dataIndex: "buyName",
  152. key: "buyName",
  153. width:150,
  154. render: text => {
  155. return (
  156. <Tooltip title={text}>
  157. <div style={{
  158. maxWidth:'150px',
  159. overflow:'hidden',
  160. textOverflow: "ellipsis",
  161. whiteSpace:'nowrap',
  162. }}>{text}</div>
  163. </Tooltip>
  164. )
  165. }
  166. },
  167. {
  168. title: "订单负责人",
  169. dataIndex: "salesName",
  170. key: "salesName"
  171. },
  172. {
  173. title: "签单日期",
  174. dataIndex: "signTime",
  175. key: "signTime"
  176. },
  177. {
  178. title: "订单金额(万元)",
  179. dataIndex: "totalAmount",
  180. key: "totalAmount"
  181. },
  182. {
  183. title: "订单状态",
  184. dataIndex: "orderStatus",
  185. key: "orderStatus",
  186. render: text => {
  187. return getNewOrderStatus(text);
  188. }
  189. },
  190. {
  191. title: "项目状态",
  192. dataIndex: "projectStatus",
  193. key: "projectStatus",
  194. render: text => {
  195. return getProjectName(text);
  196. }
  197. },
  198. {
  199. title: "发放状态",
  200. dataIndex: "grantStatus",
  201. key: "grantStatus",
  202. render: text => {
  203. return getBonusState(text);
  204. }
  205. },
  206. {
  207. title: "发放类型",
  208. dataIndex: "bonusSubject",
  209. key: "bonusSubject",
  210. render: text => {
  211. return getJsyPaymentType(text);
  212. }
  213. },
  214. {
  215. title: "校对后单量",
  216. dataIndex: "proofCount",
  217. key: "proofCount"
  218. },
  219. {
  220. title: "已收(万元)",
  221. dataIndex: "settlementAmount",
  222. key: "settlementAmount"
  223. },
  224. {
  225. title: "已退(万元)",
  226. dataIndex: "refundAmount",
  227. key: "refundAmount"
  228. },
  229. {
  230. title: "操作",
  231. dataIndex: "state11",
  232. key: "state11",
  233. render: (text, recard) => {
  234. return (
  235. <div>
  236. {recard.proofStatus && !recard.grantStatus ? (
  237. <Button
  238. type="primary"
  239. style={{ marginRight: 10, display: this.props.isLook ? "none" : "inline-block" }}
  240. onClick={e => {
  241. e.stopPropagation(), this.proofread(recard, 0);
  242. }}
  243. >
  244. 发放
  245. </Button>
  246. ) : (
  247. ""
  248. )}
  249. {recard.bonusSubject != "16" && (
  250. <Button
  251. type="primary"
  252. style={{ display: this.props.isLook ? "none" : "inline-block" }}
  253. onClick={e => {
  254. e.stopPropagation(), this.proofread(recard, 1);
  255. }}
  256. >
  257. 校对
  258. </Button>
  259. )}
  260. </div>
  261. );
  262. }
  263. }
  264. ],
  265. dataSource: [],
  266. searchTime: [,]
  267. };
  268. },
  269. proofread(recard, index) {
  270. this.setState({
  271. proofreadState: index,
  272. boHuiVisible: true,
  273. proofData: recard,
  274. result: recard.proofCount
  275. });
  276. },
  277. tableRowClick(record, index) {
  278. this.state.RowData = record;
  279. this.setState({
  280. showDesc: true
  281. });
  282. },
  283. closeDesc(e, s) {
  284. this.state.RowData = {};
  285. this.state.showDesc = e;
  286. if (s) {
  287. this.loadData(this.state.page);
  288. }
  289. },
  290. componentWillMount() {
  291. this.loadData();
  292. this.departmentList();
  293. },
  294. search() {
  295. this.loadData();
  296. },
  297. boHuiOk() {
  298. this.setState({
  299. boHuiVisible: false
  300. });
  301. this.loadData(this.state.page);
  302. },
  303. boHuiCancel(e) {
  304. this.setState({
  305. boHuiVisible: false
  306. });
  307. },
  308. //导出
  309. exportExec() {
  310. let departmentName = "",
  311. depart = this.state.departmentArr || [];
  312. depart.map(item => {
  313. if (this.state.departmentId == item.id) {
  314. departmentName = item.name;
  315. return;
  316. }
  317. });
  318. let data = {
  319. departmentId: this.state.departmentId,
  320. departmentName: departmentName,
  321. salesName: this.state.orderRefundSearch, //订单负责人
  322. startTime: this.state.releaseDate[0],
  323. endTime: this.state.releaseDate[1],
  324. grantStatus: this.state.grantStatus,
  325. startTime1: this.state.createDate[0],
  326. endTime1: this.state.createDate[1]
  327. };
  328. window.location.href =
  329. globalConfig.context +
  330. "/api/admin/bonus/exportSaleBonusData?" +
  331. $.param(data);
  332. },
  333. //保存发放状态
  334. boHuiSubmit(e) {
  335. e.preventDefault();
  336. var resType = typeof this.state.result;
  337. if (this.state.proofreadState && resType != "number") {
  338. message.warning("请填写校对信息");
  339. return false;
  340. }
  341. this.setState({
  342. loading: true
  343. });
  344. var api = !this.state.proofreadState
  345. ? "/api/admin/bonus/bonusPayment"
  346. : "/api/admin/bonus/proofreading";
  347. $.ajax({
  348. method: "POST",
  349. dataType: "json",
  350. crossDomain: false,
  351. url: globalConfig.context + api,
  352. data: !this.state.proofreadState
  353. ? {
  354. //0-发放 1-校对
  355. id: this.state.proofData.id,
  356. orderNo: this.state.proofData.orderNo
  357. }
  358. : {
  359. orderNo: this.state.proofData.orderNo,
  360. proofCount: this.state.result
  361. }
  362. }).done(
  363. function (data) {
  364. if (!data.error.length) {
  365. message.success(!this.state.proofreadState ? "发放成功" : "校对成功");
  366. this.boHuiOk();
  367. } else {
  368. message.warning(data.error[0].message);
  369. }
  370. this.setState({
  371. loading: false
  372. });
  373. }.bind(this)
  374. );
  375. },
  376. reset() {
  377. this.state.orderRefundSearch = "";
  378. this.state.releaseDate = [];
  379. this.state.createDate = [];
  380. this.state.orderNoSearch = "";
  381. this.state.departmenttList = undefined;
  382. this.state.grantStatus = undefined;
  383. this.loadData();
  384. },
  385. searchSwitch() {
  386. this.setState({
  387. searchMore: !this.state.searchMore
  388. });
  389. },
  390. changeList(arr) {
  391. const newArr = [];
  392. this.state.columns.forEach(item => {
  393. arr.forEach(val => {
  394. if (val === item.title) {
  395. newArr.push(item);
  396. }
  397. });
  398. });
  399. this.setState({
  400. changeList: newArr
  401. });
  402. },
  403. render() {
  404. const rowSelection = {
  405. selectedRowKeys: this.state.selectedRowKeys,
  406. onChange: (selectedRowKeys, selectedRows) => {
  407. this.setState({
  408. selectedRows: selectedRows.slice(-1),
  409. selectedRowKeys: selectedRowKeys.slice(-1)
  410. });
  411. }
  412. };
  413. const hasSelected = this.state.selectedRowKeys.length > 0;
  414. const { RangePicker } = DatePicker;
  415. let departmentArr = this.state.departmentArr || [];
  416. return (
  417. <div className="user-content">
  418. <ShowModalDiv ShowModal={this.state.showModal} />
  419. <div className="content-title" style={{ marginBottom: 10 }}>
  420. <span style={{ fontWeight: 900, fontSize: 16 }}>营销员奖金</span>
  421. </div>
  422. <Tabs
  423. defaultActiveKey="1"
  424. onChange={this.callback}
  425. className="test">
  426. <TabPane tab="搜索" key="1">
  427. <div className="user-search">
  428. <Select
  429. placeholder="订单部门"
  430. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  431. value={this.state.departmenttList}
  432. onChange={e => {
  433. this.setState({ departmenttList: e });
  434. }}
  435. >
  436. {departmentArr.map(function (item) {
  437. return (
  438. <Select.Option key={item.id}>{item.name}</Select.Option>
  439. );
  440. })}
  441. </Select>
  442. <Input
  443. placeholder="订单编号"
  444. value={this.state.orderNoSearch}
  445. onChange={e => {
  446. this.setState({ orderNoSearch: e.target.value });
  447. }}
  448. />
  449. <Input
  450. placeholder="订单负责人"
  451. value={this.state.orderRefundSearch}
  452. onChange={e => {
  453. this.setState({ orderRefundSearch: e.target.value });
  454. }}
  455. />
  456. <Select
  457. placeholder="发放状态"
  458. style={{ width: 150, marginRight: 10 }}
  459. value={this.state.grantStatus}
  460. onChange={e => {
  461. this.setState({ grantStatus: e });
  462. }}
  463. >
  464. <Option value="0">未发放</Option>
  465. <Option value="1">已发放</Option>
  466. </Select>
  467. <Button type="primary" onClick={this.search}>
  468. 搜索
  469. </Button>
  470. <Button onClick={this.reset}>重置</Button>
  471. <span>
  472. 更多搜索
  473. <Switch
  474. defaultChecked={false}
  475. onChange={this.searchSwitch.bind(this)}
  476. />
  477. </span>
  478. <div
  479. className="search-more"
  480. style={this.state.searchMore ? { display: "none" } : {}}
  481. >
  482. <span>签单时间 :</span>
  483. <RangePicker
  484. format="YYYY-MM"
  485. value={[
  486. this.state.releaseDate[0]
  487. ? moment(this.state.releaseDate[0])
  488. : null,
  489. this.state.releaseDate[1]
  490. ? moment(this.state.releaseDate[1])
  491. : null
  492. ]}
  493. onChange={(data, dataString) => {
  494. this.setState({ releaseDate: dataString });
  495. }}
  496. />
  497. <span>创建时间 :</span>
  498. <RangePicker
  499. format="YYYY-MM-DD"
  500. value={[
  501. this.state.createDate[0]
  502. ? moment(this.state.createDate[0])
  503. : null,
  504. this.state.createDate[1]
  505. ? moment(this.state.createDate[1])
  506. : null
  507. ]}
  508. onChange={(data, dataString) => {
  509. this.setState({ createDate: dataString });
  510. }}
  511. />
  512. </div>
  513. </div>
  514. </TabPane>
  515. <TabPane tab="导出" key="2">
  516. <div style={{ float: "left" }}>
  517. <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
  518. </div>
  519. </TabPane>
  520. <TabPane tab="更改表格显示数据" key="3">
  521. <div style={{ marginLeft: 10 }}>
  522. <ChooseList
  523. columns={this.state.columns}
  524. changeFn={this.changeList}
  525. changeList={this.state.changeList}
  526. top={55}
  527. margin={11}
  528. />
  529. </div>
  530. </TabPane>
  531. </Tabs>
  532. <div className="patent-table" id="table">
  533. <Spin spinning={this.state.loading}>
  534. <Table
  535. size="small"
  536. bordered
  537. columns={
  538. this.state.changeList
  539. ? this.state.changeList
  540. : this.state.columns
  541. }
  542. dataSource={this.state.dataSource}
  543. scroll={{ x: 1500, y: 0 }}
  544. rowSelection={false}
  545. pagination={this.state.pagination}
  546. onRowClick={this.tableRowClick}
  547. />
  548. </Spin>
  549. </div>
  550. <BonuseDetail
  551. data={this.state.RowData}
  552. showDesc={this.state.showDesc}
  553. closeDesc={this.closeDesc.bind(this)}
  554. />
  555. <Modal
  556. visible={this.state.boHuiVisible}
  557. width="400px"
  558. title={this.state.proofreadState ? "校对" : "发放"}
  559. footer=""
  560. onOk={this.boHuiOk}
  561. onCancel={this.boHuiCancel}
  562. >
  563. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  564. <Spin spinning={this.state.loading}>
  565. {this.state.proofreadState ? (
  566. <div>
  567. <FormItem
  568. labelCol={{ span: 8 }}
  569. wrapperCol={{ span: 10 }}
  570. label={
  571. <span>
  572. <strong style={{ color: "#f00" }}>*</strong>
  573. 单量校对结果
  574. </span>
  575. }
  576. >
  577. <InputNumber
  578. min={0}
  579. max={1}
  580. placeholder="输入单量"
  581. value={this.state.result}
  582. onChange={e => {
  583. this.setState({ result: e });
  584. }}
  585. />
  586. </FormItem>
  587. <FormItem
  588. labelCol={{ span: 8 }}
  589. wrapperCol={{ span: 10 }}
  590. label="校对人"
  591. >
  592. <span>{this.state.proofData.byName}</span>
  593. </FormItem>
  594. </div>
  595. ) : (
  596. <div>
  597. <FormItem
  598. labelCol={{ span: 8 }}
  599. wrapperCol={{ span: 10 }}
  600. label="应收人"
  601. >
  602. <span>{this.state.proofData.salesName}</span>
  603. </FormItem>
  604. <FormItem
  605. labelCol={{ span: 8 }}
  606. wrapperCol={{ span: 10 }}
  607. label="发放人"
  608. >
  609. <span>{this.state.proofData.byName}</span>
  610. </FormItem>
  611. </div>
  612. )}
  613. <FormItem wrapperCol={{ span: 12, offset: 8 }}>
  614. <Button
  615. type="primary"
  616. htmlType="submit"
  617. style={{ marginRight: 20 }}
  618. >
  619. 保存
  620. </Button>
  621. <Button
  622. type="default"
  623. onClick={() => {
  624. this.boHuiCancel();
  625. }}
  626. >
  627. 取消
  628. </Button>
  629. </FormItem>
  630. </Spin>
  631. </Form>
  632. </Modal>
  633. </div>
  634. );
  635. }
  636. });
  637. export default YxBonus;