publicityAccount.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import moment from "moment";
  4. import {
  5. Button,
  6. Form,
  7. Input,
  8. Spin,
  9. Table,
  10. Select,
  11. message,
  12. Tabs,
  13. DatePicker,
  14. AutoComplete,
  15. Modal,
  16. Tooltip,
  17. Tag,
  18. } from "antd";
  19. import { ChooseList } from "../../order/orderNew/chooseList";
  20. import { ShowModal, getAccountName, getSecondaryAccountName, getClockState } from "../../../tools"
  21. import { accountType, accountStatus } from "@/dataDic";
  22. import ShowModalDiv from "@/showModal.jsx";
  23. import OrderDetail from '../../order/orderNew/changeComponent/orderDetail';
  24. import './index.less';
  25. const FormItem = Form.Item;
  26. const { RangePicker } = DatePicker;
  27. const { TabPane } = Tabs;
  28. const PublicityAccount = React.createClass({
  29. getInitialState() {
  30. return {
  31. searchValues: {
  32. allStatus: "0"
  33. }, // 列表筛选条件
  34. loading: false, //加载动画
  35. changeList: undefined, // 更改后的表格显示数据
  36. dataSource: [], // 列表数据
  37. departmentArr: [], // 部门信息
  38. pagination: {
  39. defaultCurrent: 1,
  40. defaultPageSize: 10,
  41. showQuickJumper: true,
  42. pageSize: 10,
  43. onChange: function (page) {
  44. this.loadData(page);
  45. }.bind(this),
  46. showTotal: function (total) {
  47. return "共" + total + "条数据";
  48. },
  49. },
  50. columns: [
  51. {
  52. title: "合同/客户",
  53. dataIndex: "contractNo",
  54. key: "contractNo",
  55. width: 300,
  56. render: (text, record) => {
  57. return (
  58. <span>
  59. <span>{text}</span>
  60. {" / " + record.buyerName}
  61. </span>
  62. );
  63. },
  64. },
  65. {
  66. title: "营销所属部门",
  67. dataIndex: "depName",
  68. key: "depName",
  69. render: (text, record) => {
  70. return (
  71. <div>
  72. {text}
  73. </div>
  74. );
  75. },
  76. },
  77. {
  78. title: "营销员",
  79. dataIndex: "salesmanName",
  80. key: "salesmanName",
  81. render: (text, record) => {
  82. return (
  83. <div>
  84. {text}
  85. </div>
  86. );
  87. },
  88. },
  89. {
  90. title: "公出/实际/超出(时)",
  91. dataIndex: "maxDuration",
  92. key: "maxDuration",
  93. render: (text, record) => {
  94. return (
  95. <div>
  96. {text + " / " + record.actualDuration + " / "}
  97. <span style={{ color: record.exceedType == 1 && "red" }}>{record.exceedDuration}</span>
  98. </div>
  99. );
  100. },
  101. },
  102. {
  103. title: "合同总额/已收款(万元)",
  104. dataIndex: "totalAmount",
  105. key: "totalAmount",
  106. render: (text, record) => {
  107. return (
  108. <div>
  109. {text + " / " + record.settlementAmount}
  110. </div>
  111. );
  112. },
  113. },
  114. {
  115. title: "报销总额(元)",
  116. dataIndex: "expenseAmount",
  117. key: "expenseAmount",
  118. render: (text, record) => {
  119. return (
  120. <div>
  121. {text}
  122. </div>
  123. );
  124. },
  125. },
  126. {
  127. title: "已付成本(万元)",
  128. dataIndex: "paymentAmount",
  129. key: "paymentAmount",
  130. render: (text, record) => {
  131. return (
  132. <div>
  133. {text}
  134. </div>
  135. );
  136. },
  137. },
  138. {
  139. title: "报销人数/天数/报销次数",
  140. dataIndex: "peopleCount",
  141. key: "peopleCount",
  142. render: (text, record) => {
  143. return (
  144. <div>
  145. {text + " / " + record.days + " / " + record.expenseCount}
  146. </div>
  147. );
  148. },
  149. },
  150. {
  151. title: "报销未审核/驳回次数",
  152. dataIndex: "notExamine",
  153. key: "notExamine",
  154. render: (text, record) => {
  155. return (
  156. <div>
  157. {text + " / " + record.rejectCount}
  158. </div>
  159. );
  160. },
  161. },
  162. ],
  163. };
  164. },
  165. componentWillMount() {
  166. this.departmentList();
  167. this.loadData();
  168. },
  169. // 列表接口
  170. loadData(pageNo) {
  171. const { searchValues, pagination } = this.state;
  172. this.setState({
  173. loading: true,
  174. });
  175. let datas = Object.assign(searchValues, {
  176. // pageNo: pageNo || 1,
  177. // pageSize: pagination.pageSize,
  178. });
  179. $.ajax({
  180. method: "get",
  181. dataType: "json",
  182. crossDomain: false,
  183. url: globalConfig.context + "/api/admin/release/releaseAndExpenseCount",
  184. data: datas,
  185. success: function (data) {
  186. ShowModal(this);
  187. this.setState({
  188. loading: false,
  189. });
  190. if (data.error && data.error.length === 0) {
  191. if (data.data) {
  192. pagination.current = data.data.pageNo;
  193. pagination.total = data.data.totalCount;
  194. if (data.data && data.data && !data.data.length) {
  195. pagination.current = 0;
  196. pagination.total = 0;
  197. }
  198. this.setState({
  199. dataSource: data.data,
  200. pagination: this.state.pagination,
  201. pageNo: data.data.pageNo,
  202. totalAmount: data.data.totalAmount,
  203. });
  204. }
  205. } else {
  206. message.warning(data.error[0].message);
  207. }
  208. }.bind(this),
  209. }).always(
  210. function () {
  211. this.setState({
  212. loading: false,
  213. });
  214. }.bind(this)
  215. );
  216. },
  217. departmentList() {
  218. $.ajax({
  219. method: "get",
  220. dataType: "json",
  221. crossDomain: false,
  222. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  223. data: {},
  224. success: function (data) {
  225. let thedata = data.data;
  226. let theArr = [];
  227. if (!thedata) {
  228. if (data.error && data.error.length) {
  229. message.warning(data.error[0].message);
  230. }
  231. } else {
  232. thedata.map(function (item, index) {
  233. theArr.push({
  234. key: index,
  235. name: item.name,
  236. id: item.id
  237. });
  238. });
  239. }
  240. this.setState({
  241. departmentArr: theArr
  242. });
  243. }.bind(this)
  244. }).always(
  245. function () {
  246. }.bind(this)
  247. );
  248. },
  249. // 搜索
  250. search() {
  251. this.loadData();
  252. },
  253. // 重置
  254. reset() {
  255. this.setState({
  256. searchValues: {
  257. allStatus: "0"
  258. },
  259. }, () => {
  260. this.loadData();
  261. })
  262. },
  263. changeList(arr) {
  264. const newArr = [];
  265. this.state.columns.forEach((item) => {
  266. arr.forEach((val) => {
  267. if (val === item.title) {
  268. newArr.push(item);
  269. }
  270. });
  271. });
  272. this.setState({
  273. changeList: newArr,
  274. });
  275. },
  276. // 导出
  277. export() {
  278. this.setState({
  279. exportExecLoading: true
  280. })
  281. let loading = message.loading('加载中...');
  282. let data = this.state.searchValues;
  283. $.ajax({
  284. method: "get",
  285. dataType: "json",
  286. crossDomain: false,
  287. url: globalConfig.context + "/api/admin/release/releaseAndExpenseCount/Export",
  288. data,
  289. success: function (data) {
  290. if (data.error.length === 0) {
  291. this.download(data.data);
  292. } else {
  293. message.warning(data.error[0].message);
  294. }
  295. }.bind(this),
  296. }).always(function () {
  297. loading();
  298. this.setState({
  299. exportExecLoading: false
  300. })
  301. }.bind(this));
  302. },
  303. // 下载
  304. download(fileName) {
  305. window.location.href = globalConfig.context + "/open/download?fileName=" + fileName
  306. },
  307. // 清理缓存
  308. getCountsClear() {
  309. this.setState({
  310. loading: true,
  311. });
  312. $.ajax({
  313. method: "get",
  314. dataType: "json",
  315. crossDomain: false,
  316. url: globalConfig.context + "/api/admin/release/releaseAndExpenseCountClear",
  317. data: {},
  318. success: function (data) {
  319. ShowModal(this);
  320. this.setState({
  321. loading: false,
  322. });
  323. if (data.error && data.error.length === 0) {
  324. message.success("清除成功!")
  325. } else {
  326. message.warning(data.error[0].message);
  327. }
  328. }.bind(this),
  329. }).always(
  330. function () {
  331. this.setState({
  332. loading: false,
  333. });
  334. }.bind(this)
  335. );
  336. },
  337. followUp(e) {
  338. this.setState({
  339. aname: e
  340. });
  341. $.ajax({
  342. method: "get",
  343. dataType: "json",
  344. crossDomain: false,
  345. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  346. data: {
  347. adminName: e,
  348. },
  349. success: function (data) {
  350. let thedata = data.data || [];
  351. if (!thedata) {
  352. if (data.error && data.error.length) {
  353. message.warning(data.error[0].message);
  354. }
  355. thedata = {};
  356. }
  357. this.setState({
  358. fjlist: thedata,
  359. });
  360. }.bind(this),
  361. }).always(
  362. function () {
  363. this.setState({
  364. loading: false,
  365. });
  366. }.bind(this)
  367. );
  368. },
  369. selectF(value) {
  370. const { searchValues, fjlist } = this.state;
  371. const newdataSources = JSON.stringify(fjlist) == "{}" ? [] : fjlist;
  372. this.setState({
  373. searchValues: Object.assign(searchValues, {
  374. aid: newdataSources.find((item) => item.name == value).id,
  375. }),
  376. });
  377. },
  378. render() {
  379. const { searchValues, } = this.state
  380. const dataSources = this.state.fjlist || [];
  381. const options = dataSources.map((group) => (
  382. <Select.Option key={group.id} value={group.name}>
  383. {group.name}
  384. </Select.Option>
  385. ));
  386. return (
  387. <div className="user-content">
  388. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  389. <div className="content-title" style={{ marginBottom: 10 }}>
  390. <span style={{ fontWeight: 900, fontSize: 16 }}>公出&报销</span>
  391. </div>
  392. <Tabs defaultActiveKey="2" className="test">
  393. <TabPane tab="搜索" key="2">
  394. <div className="user-search" style={{ marginLeft: 10 }}>
  395. <Input
  396. placeholder="合同编号"
  397. value={searchValues["contractNo"]
  398. ? searchValues["contractNo"]
  399. : ""}
  400. onChange={(e) => {
  401. searchValues["contractNo"] = e.target.value;
  402. this.setState({
  403. searchValues: searchValues,
  404. });
  405. }}
  406. />
  407. <Input
  408. placeholder="客户名称"
  409. value={searchValues["buyerName"]
  410. ? searchValues["buyerName"]
  411. : ""}
  412. onChange={(e) => {
  413. searchValues["buyerName"] = e.target.value;
  414. this.setState({
  415. searchValues: searchValues,
  416. });
  417. }}
  418. />
  419. <Select
  420. placeholder="所属部门"
  421. style={{ width: 200, marginRight: 10 }}
  422. value={searchValues["depId"]
  423. ? searchValues["depId"]
  424. : undefined}
  425. onChange={e => {
  426. searchValues["depId"] = e;
  427. this.setState({
  428. searchValues: searchValues,
  429. });
  430. }}
  431. >
  432. {this.state.departmentArr.map(function (item) {
  433. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  434. })}
  435. </Select>
  436. <AutoComplete
  437. className="certain-category-search"
  438. dropdownClassName="certain-category-search-dropdown"
  439. dropdownMatchSelectWidth={false}
  440. style={{ width: 140 }}
  441. dataSource={options}
  442. placeholder="营销员名称"
  443. value={this.state.aname}
  444. onChange={this.followUp.bind(this)}
  445. filterOption={true}
  446. onSelect={this.selectF.bind(this)}
  447. >
  448. <Input />
  449. </AutoComplete>
  450. <Select
  451. style={{ width: 140 }}
  452. placeholder=""
  453. value={searchValues["allStatus"]
  454. ? searchValues["allStatus"]
  455. : undefined}
  456. onChange={(e) => {
  457. searchValues["allStatus"] = e;
  458. this.setState({
  459. searchValues: searchValues,
  460. });
  461. }}
  462. >
  463. <Option value="0">全部公出</Option>
  464. <Option value="1">未超出</Option>
  465. <Option value="2">已超出</Option>
  466. </Select>
  467. <span>报销时间:</span>
  468. <RangePicker
  469. style={{ width: 300 }}
  470. value={[
  471. searchValues.startTime ? moment(searchValues.startTime) : null,
  472. searchValues.endTime ? moment(searchValues.endTime) : null,
  473. ]}
  474. onChange={(data, dataString) => {
  475. this.setState({
  476. searchValues: Object.assign(searchValues, {
  477. startTime: dataString[0],
  478. endTime: dataString[1],
  479. }),
  480. });
  481. }}
  482. />
  483. <Button
  484. type="primary"
  485. onClick={this.search}
  486. style={{ margin: "0 10px" }}
  487. >搜索</Button>
  488. <Button onClick={this.reset}>重置</Button>
  489. <Button
  490. type="primary"
  491. onClick={this.getCountsClear}
  492. style={{ marginLeft: 10 }}
  493. >清理缓存</Button>
  494. </div>
  495. </TabPane>
  496. <TabPane tab="更改表格显示数据" key="1">
  497. <div style={{ marginLeft: 10 }}>
  498. <ChooseList
  499. columns={this.state.columns}
  500. changeFn={this.changeList}
  501. changeList={this.state.changeList}
  502. top={55}
  503. margin={11}
  504. />
  505. </div>
  506. </TabPane>
  507. <TabPane tab="导出" key="3">
  508. <div style={{ float: "left" }}>
  509. <Button
  510. type="primary"
  511. loading={this.state.exportPendingLoading}
  512. onClick={this.export}
  513. style={{ margin: 10 }}
  514. >
  515. 导出excel
  516. </Button>
  517. </div>
  518. </TabPane>
  519. </Tabs>
  520. <div className="patent-table">
  521. <Spin spinning={this.state.loading}>
  522. <Table
  523. bordered
  524. columns={
  525. this.state.changeList == undefined
  526. ? this.state.columns
  527. : this.state.changeList
  528. }
  529. dataSource={this.state.dataSource}
  530. pagination={false}
  531. size="small"
  532. />
  533. </Spin>
  534. </div>
  535. </div>
  536. );
  537. },
  538. });
  539. export default PublicityAccount;