accountStatistics.jsx 9.6 KB

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