yxBonus.jsx 18 KB

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