yxBonus.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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 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. deps: this.state.departmenttList,
  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 = undefined;
  378. this.state.releaseDate = [];
  379. this.state.createDate = [];
  380. this.state.orderNoSearch = undefined
  381. this.state.departmenttList = undefined;
  382. this.state.grantStatus = undefined;
  383. this.Cascaders.empty();
  384. this.loadData();
  385. },
  386. searchSwitch() {
  387. this.setState({
  388. searchMore: !this.state.searchMore
  389. });
  390. },
  391. changeList(arr) {
  392. const newArr = [];
  393. this.state.columns.forEach(item => {
  394. arr.forEach(val => {
  395. if (val === item.title) {
  396. newArr.push(item);
  397. }
  398. });
  399. });
  400. this.setState({
  401. changeList: newArr
  402. });
  403. },
  404. render() {
  405. const rowSelection = {
  406. selectedRowKeys: this.state.selectedRowKeys,
  407. onChange: (selectedRowKeys, selectedRows) => {
  408. this.setState({
  409. selectedRows: selectedRows.slice(-1),
  410. selectedRowKeys: selectedRowKeys.slice(-1)
  411. });
  412. }
  413. };
  414. const hasSelected = this.state.selectedRowKeys.length > 0;
  415. const { RangePicker } = DatePicker;
  416. let departmentArr = this.state.departmentArr || [];
  417. return (
  418. <div className="user-content">
  419. {/* <ShowModalDiv ShowModal={this.state.showModal} /> */}
  420. <div className="content-title" style={{ marginBottom: 10 }}>
  421. <span style={{ fontWeight: 900, fontSize: 16 }}>营销员奖金</span>
  422. </div>
  423. <Tabs
  424. defaultActiveKey="1"
  425. onChange={this.callback}
  426. className="test">
  427. <TabPane tab="搜索" key="1">
  428. <div className="user-search" style={{ padding: "0 10px" }}>
  429. <Cascaders
  430. ref={ref => this.Cascaders = ref}
  431. placeholder="订单部门"
  432. id="id"
  433. name="name"
  434. children="list"
  435. height={28}
  436. onSel={(e) => {
  437. this.setState({
  438. departmenttList: e,
  439. });
  440. }}
  441. />
  442. {/* <Select
  443. placeholder="订单部门"
  444. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  445. value={this.state.departmenttList}
  446. onChange={e => {
  447. this.setState({ departmenttList: e });
  448. }}
  449. >
  450. {departmentArr.map(function (item) {
  451. return (
  452. <Select.Option key={item.id}>{item.name}</Select.Option>
  453. );
  454. })}
  455. </Select> */}
  456. <Input
  457. placeholder="订单编号"
  458. value={this.state.orderNoSearch}
  459. onChange={e => {
  460. this.setState({ orderNoSearch: e.target.value });
  461. }}
  462. />
  463. <Input
  464. placeholder="订单负责人"
  465. value={this.state.orderRefundSearch}
  466. onChange={e => {
  467. this.setState({ orderRefundSearch: e.target.value });
  468. }}
  469. />
  470. <Select
  471. placeholder="发放状态"
  472. style={{ width: 150, marginRight: 10 }}
  473. value={this.state.grantStatus}
  474. onChange={e => {
  475. this.setState({ grantStatus: e });
  476. }}
  477. >
  478. <Option value="0">未发放</Option>
  479. <Option value="1">已发放</Option>
  480. </Select>
  481. <Button type="primary" onClick={this.search}>
  482. 搜索
  483. </Button>
  484. <Button onClick={this.reset}>重置</Button>
  485. <span>
  486. 更多搜索
  487. <Switch
  488. defaultChecked={false}
  489. onChange={this.searchSwitch.bind(this)}
  490. />
  491. </span>
  492. <div
  493. className="search-more"
  494. style={this.state.searchMore ? { display: "none" } : {}}
  495. >
  496. <span>签单时间 :</span>
  497. <RangePicker
  498. format="YYYY-MM"
  499. value={[
  500. this.state.releaseDate[0]
  501. ? moment(this.state.releaseDate[0])
  502. : null,
  503. this.state.releaseDate[1]
  504. ? moment(this.state.releaseDate[1])
  505. : null
  506. ]}
  507. onChange={(data, dataString) => {
  508. this.setState({ releaseDate: dataString });
  509. }}
  510. />
  511. <span>创建时间 :</span>
  512. <RangePicker
  513. format="YYYY-MM-DD"
  514. value={[
  515. this.state.createDate[0]
  516. ? moment(this.state.createDate[0])
  517. : null,
  518. this.state.createDate[1]
  519. ? moment(this.state.createDate[1])
  520. : null
  521. ]}
  522. onChange={(data, dataString) => {
  523. this.setState({ createDate: dataString });
  524. }}
  525. />
  526. </div>
  527. </div>
  528. </TabPane>
  529. <TabPane tab="导出" key="2">
  530. <div style={{ float: "left" }}>
  531. <Button onClick={this.exportExec} style={{ margin: 10 }}>导出excel</Button>
  532. </div>
  533. </TabPane>
  534. <TabPane tab="更改表格显示数据" key="3">
  535. <div style={{ marginLeft: 10 }}>
  536. <ChooseList
  537. columns={this.state.columns}
  538. changeFn={this.changeList}
  539. changeList={this.state.changeList}
  540. top={55}
  541. margin={11}
  542. />
  543. </div>
  544. </TabPane>
  545. </Tabs>
  546. <div className="patent-table" id="table">
  547. <Spin spinning={this.state.loading}>
  548. <Table
  549. size="small"
  550. bordered
  551. columns={
  552. this.state.changeList
  553. ? this.state.changeList
  554. : this.state.columns
  555. }
  556. dataSource={this.state.dataSource}
  557. scroll={{ x: 1500, y: 0 }}
  558. rowSelection={false}
  559. pagination={this.state.pagination}
  560. onRowClick={this.tableRowClick}
  561. />
  562. </Spin>
  563. </div>
  564. <BonuseDetail
  565. data={this.state.RowData}
  566. showDesc={this.state.showDesc}
  567. closeDesc={this.closeDesc.bind(this)}
  568. />
  569. <Modal
  570. visible={this.state.boHuiVisible}
  571. width="400px"
  572. title={this.state.proofreadState ? "校对" : "发放"}
  573. footer=""
  574. onOk={this.boHuiOk}
  575. onCancel={this.boHuiCancel}
  576. >
  577. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  578. <Spin spinning={this.state.loading}>
  579. {this.state.proofreadState ? (
  580. <div>
  581. <FormItem
  582. labelCol={{ span: 8 }}
  583. wrapperCol={{ span: 10 }}
  584. label={
  585. <span>
  586. <strong style={{ color: "#f00" }}>*</strong>
  587. 单量校对结果
  588. </span>
  589. }
  590. >
  591. <InputNumber
  592. min={0}
  593. max={1}
  594. placeholder="输入单量"
  595. value={this.state.result}
  596. onChange={e => {
  597. this.setState({ result: e });
  598. }}
  599. />
  600. </FormItem>
  601. <FormItem
  602. labelCol={{ span: 8 }}
  603. wrapperCol={{ span: 10 }}
  604. label="校对人"
  605. >
  606. <span>{this.state.proofData.byName}</span>
  607. </FormItem>
  608. </div>
  609. ) : (
  610. <div>
  611. <FormItem
  612. labelCol={{ span: 8 }}
  613. wrapperCol={{ span: 10 }}
  614. label="应收人"
  615. >
  616. <span>{this.state.proofData.salesName}</span>
  617. </FormItem>
  618. <FormItem
  619. labelCol={{ span: 8 }}
  620. wrapperCol={{ span: 10 }}
  621. label="发放人"
  622. >
  623. <span>{this.state.proofData.byName}</span>
  624. </FormItem>
  625. </div>
  626. )}
  627. <FormItem wrapperCol={{ span: 12, offset: 8 }}>
  628. <Button
  629. type="primary"
  630. htmlType="submit"
  631. style={{ marginRight: 20 }}
  632. >
  633. 保存
  634. </Button>
  635. <Button
  636. type="default"
  637. onClick={() => {
  638. this.boHuiCancel();
  639. }}
  640. >
  641. 取消
  642. </Button>
  643. </FormItem>
  644. </Spin>
  645. </Form>
  646. </Modal>
  647. </div>
  648. );
  649. }
  650. });
  651. export default YxBonus;