yxBonus.jsx 19 KB

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