accountStatistics.jsx 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. Tag,
  14. Tooltip,
  15. DatePicker,
  16. Modal,
  17. } from "antd";
  18. import { ChooseList } from "../../order/orderNew/chooseList";
  19. import { ShowModal, commonAdd } from "../../../tools"
  20. import ShowModalDiv from "@/showModal.jsx";
  21. const FormItem = Form.Item;
  22. const { RangePicker } = DatePicker;
  23. const { TabPane } = Tabs;
  24. const AccountReview = React.createClass({
  25. getInitialState() {
  26. return {
  27. searchValues: {}, // 列表筛选条件
  28. loading: false, //加载动画
  29. changeList: undefined, // 更改后的表格显示数据
  30. dataSource: [], // 列表数据
  31. departmentArr: [],
  32. columns: [
  33. {
  34. title: "报销人员",
  35. dataIndex: "aname",
  36. key: "aname",
  37. },
  38. {
  39. title: "报销/借支/抵扣次数",
  40. dataIndex: "bx",
  41. key: "bx",
  42. render: (text, record) => {
  43. return (
  44. <div>
  45. <div>{text + "/" + record.jz + "/" + record.dk}</div>
  46. </div>
  47. );
  48. },
  49. },
  50. {
  51. title: "报销/借支/抵扣金额(元)",
  52. dataIndex: "bxAmount",
  53. key: "bxAmount",
  54. render: (text, record) => {
  55. return (
  56. <div>{text + "/" + record.jzAmount + "/" + record.dkAmount}</div>
  57. );
  58. },
  59. },
  60. {
  61. title: "报销总金额(元)",
  62. dataIndex: "sum",
  63. key: "sum",
  64. render: (text, record) => {
  65. return (
  66. <div>{commonAdd(commonAdd(record.bxAmount, record.jzAmount), record.dkAmount)}</div>
  67. );
  68. },
  69. },
  70. {
  71. title: "固定费用总金额(元)",
  72. dataIndex: "gdfyAmount",
  73. key: "gdfyAmount",
  74. },
  75. {
  76. title: "报销至订单金额(元)",
  77. dataIndex: "bxddAmount",
  78. key: "bxddAmount",
  79. },
  80. {
  81. title: "未审核次数",
  82. dataIndex: "wshs",
  83. key: "wshs",
  84. },
  85. {
  86. title: "驳回次数",
  87. dataIndex: "bhs",
  88. key: "bhs",
  89. },
  90. ],
  91. };
  92. },
  93. componentWillMount() {
  94. this.departmentList();
  95. this.loadData();
  96. },
  97. // 列表接口
  98. loadData() {
  99. const { searchValues } = this.state;
  100. this.setState({
  101. loading: true,
  102. });
  103. let datas = searchValues;
  104. $.ajax({
  105. method: "get",
  106. dataType: "json",
  107. crossDomain: false,
  108. url: globalConfig.context + "/api/admin/expenseAccount/statistics",
  109. data: datas,
  110. success: function (data) {
  111. ShowModal(this);
  112. this.setState({
  113. loading: false,
  114. });
  115. if (data.error && data.error.length === 0) {
  116. if (data.data.list) {
  117. this.setState({
  118. dataSource: data.data.list,
  119. });
  120. } else {
  121. this.setState({
  122. dataSource: data.data,
  123. });
  124. }
  125. } else {
  126. message.warning(data.error[0].message);
  127. }
  128. }.bind(this),
  129. }).always(
  130. function () {
  131. this.setState({
  132. loading: false,
  133. });
  134. }.bind(this)
  135. );
  136. },
  137. // 部门信息
  138. departmentList() {
  139. $.ajax({
  140. method: "get",
  141. dataType: "json",
  142. crossDomain: false,
  143. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  144. data: {},
  145. success: function (data) {
  146. let thedata = data.data;
  147. let theArr = [];
  148. if (!thedata) {
  149. if (data.error && data.error.length) {
  150. message.warning(data.error[0].message);
  151. }
  152. } else {
  153. thedata.map(function (item, index) {
  154. theArr.push({
  155. key: index,
  156. name: item.name,
  157. id: item.id
  158. });
  159. });
  160. }
  161. this.setState({
  162. departmentArr: theArr
  163. });
  164. }.bind(this)
  165. }).always(
  166. function () {
  167. }.bind(this)
  168. );
  169. },
  170. // 搜索
  171. search() {
  172. this.loadData();
  173. },
  174. // 重置
  175. reset() {
  176. this.setState({
  177. searchValues: JSON.parse(JSON.stringify({})),
  178. }, () => {
  179. this.loadData();
  180. })
  181. },
  182. // 清除缓存
  183. evict() {
  184. this.setState({
  185. loading: true,
  186. });
  187. $.ajax({
  188. method: "get",
  189. dataType: "json",
  190. crossDomain: false,
  191. url: globalConfig.context + "/api/admin/expenseAccount/statistics/evict",
  192. data: {},
  193. success: function (data) {
  194. ShowModal(this);
  195. this.setState({
  196. loading: false,
  197. });
  198. if (data.error && data.error.length === 0) {
  199. message.success("清除成功!")
  200. } else {
  201. message.warning(data.error[0].message);
  202. }
  203. }.bind(this),
  204. }).always(
  205. function () {
  206. this.setState({
  207. loading: false,
  208. });
  209. }.bind(this)
  210. );
  211. },
  212. // 导出
  213. export() {
  214. this.setState({
  215. exportExecLoading: true
  216. })
  217. let loading = message.loading('加载中...');
  218. let data = this.state.searchValues;
  219. $.ajax({
  220. method: "get",
  221. dataType: "json",
  222. crossDomain: false,
  223. url: globalConfig.context + "/api/admin/expenseAccount/statistics/export",
  224. data,
  225. success: function (data) {
  226. if (data.error.length === 0) {
  227. this.download(data.data);
  228. } else {
  229. message.warning(data.error[0].message);
  230. }
  231. }.bind(this),
  232. }).always(function () {
  233. loading();
  234. this.setState({
  235. exportExecLoading: false
  236. })
  237. }.bind(this));
  238. },
  239. // 下载
  240. download(fileName) {
  241. window.location.href = globalConfig.context + "/open/download?fileName=" + fileName
  242. },
  243. changeList(arr) {
  244. const newArr = [];
  245. this.state.columns.forEach((item) => {
  246. arr.forEach((val) => {
  247. if (val === item.title) {
  248. newArr.push(item);
  249. }
  250. });
  251. });
  252. this.setState({
  253. changeList: newArr,
  254. });
  255. },
  256. render() {
  257. const { searchValues, } = this.state
  258. return (
  259. <div className="user-content">
  260. <ShowModalDiv ShowModal={this.state.showModal} />
  261. <div className="content-title" style={{ marginBottom: 10 }}>
  262. <span style={{ fontWeight: 900, fontSize: 16 }}>费用统计</span>
  263. </div>
  264. <Tabs defaultActiveKey="2" className="test">
  265. <TabPane tab="更改表格显示数据" key="1">
  266. <div style={{ marginLeft: 10 }}>
  267. <ChooseList
  268. columns={this.state.columns}
  269. changeFn={this.changeList}
  270. changeList={this.state.changeList}
  271. top={55}
  272. margin={11}
  273. />
  274. </div>
  275. </TabPane>
  276. <TabPane tab="搜索" key="2">
  277. <div className="user-search" style={{ marginLeft: 10 }}>
  278. <Input
  279. placeholder="请输入报销人员"
  280. value={searchValues["name"]
  281. ? searchValues["name"]
  282. : ""}
  283. onChange={(e) => {
  284. searchValues["name"] = e.target.value;
  285. this.setState({
  286. searchValues: searchValues,
  287. });
  288. }}
  289. />
  290. <Select
  291. placeholder="所属部门"
  292. style={{ width: 200, marginRight: 10 }}
  293. value={searchValues["depId"]
  294. ? searchValues["depId"]
  295. : undefined}
  296. onChange={e => {
  297. searchValues["depId"] = e;
  298. this.setState({
  299. searchValues: searchValues,
  300. });
  301. }}
  302. >
  303. {this.state.departmentArr.map(function (item) {
  304. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  305. })}
  306. </Select>
  307. <span>报销时间:</span>
  308. <RangePicker
  309. style={{ width: 300 }}
  310. value={[
  311. searchValues.startTime ? moment(searchValues.startTime) : null,
  312. searchValues.endTime ? moment(searchValues.endTime) : null,
  313. ]}
  314. onChange={(data, dataString) => {
  315. this.setState({
  316. searchValues: Object.assign(searchValues, {
  317. startTime: dataString[0],
  318. endTime: dataString[1],
  319. }),
  320. });
  321. }}
  322. />
  323. <Button
  324. type="primary"
  325. onClick={this.search}
  326. style={{ marginLeft: 10 }}
  327. >
  328. 搜索
  329. </Button>
  330. <Button style={{ marginLeft: 10 }} onClick={this.reset}>重置</Button>
  331. <Button
  332. type="primary"
  333. onClick={this.evict}
  334. style={{ marginLeft: 10 }}
  335. >
  336. 清除缓存
  337. </Button>
  338. </div>
  339. </TabPane>
  340. <TabPane tab="导出Excel" key="3">
  341. <Button type="primary" style={{ float: "left", margin: 10 }} onClick={this.export}>
  342. 导出excel
  343. </Button>
  344. </TabPane>
  345. </Tabs>
  346. <div className="patent-table">
  347. <Spin spinning={this.state.loading}>
  348. <Table
  349. bordered
  350. columns={
  351. this.state.changeList == undefined
  352. ? this.state.columns
  353. : this.state.changeList
  354. }
  355. dataSource={this.state.dataSource}
  356. pagination={false}
  357. size="small"
  358. />
  359. </Spin>
  360. </div>
  361. </div>
  362. );
  363. },
  364. });
  365. export default AccountReview;