yxBonus.jsx 18 KB

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