cw.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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 '@/manageCenter/financialManage/distribute/public.less';
  6. import { Button, Spin, DatePicker, Radio, message } from 'antd';
  7. import { getToday, ShowModal } from '@/tools';
  8. import ShowModalDiv from "@/showModal.jsx";
  9. import './index.less';
  10. import ReactEcharts from 'echarts-for-react/lib/core';
  11. import echarts from 'echarts/lib/echarts';
  12. import 'echarts/lib/chart/line';
  13. import 'echarts/lib/component/legend';
  14. import 'echarts/lib/component/title';
  15. import 'echarts/lib/component/tooltip';
  16. import 'echarts/lib/component/toolbox';
  17. import 'echarts/lib/component/grid';
  18. const RadioButton = Radio.Button;
  19. const RadioGroup = Radio.Group;
  20. const { RangePicker } = DatePicker
  21. const Statistics = React.createClass({
  22. getInitialState() {
  23. return {
  24. status: 1,
  25. releaseDate: getToday(1),
  26. info: {},
  27. data: {},
  28. htmlMenus: [],
  29. }
  30. },
  31. componentWillMount() {
  32. this.loadData();
  33. this.getData();
  34. this.mainMenu();
  35. },
  36. mainMenu() {
  37. $.ajax({
  38. method: "get",
  39. dataType: "json",
  40. crossDomain: false,
  41. url: globalConfig.context + "/api/admin/selectNavList",
  42. data: {},
  43. success: function (data) {
  44. if (!data.data) {
  45. if (data.error && data.error.length) {
  46. message.warning(data.error[0].message);
  47. return;
  48. }
  49. }
  50. let menu = data.data;
  51. this.setState({
  52. htmlMenus: menu,
  53. });
  54. }.bind(this),
  55. }).always(
  56. function (data) {
  57. this.setState({
  58. loading: false,
  59. });
  60. }.bind(this)
  61. );
  62. },
  63. loadData() {
  64. const { releaseDate } = this.state
  65. this.setState({
  66. loading: true,
  67. });
  68. $.ajax({
  69. method: "get",
  70. dataType: "json",
  71. crossDomain: false,
  72. url: globalConfig.context + "/api/admin/statistics/finance/info",
  73. data: {
  74. startTime: releaseDate[0],
  75. endTime: releaseDate[1],
  76. },
  77. success: function (data) {
  78. ShowModal(this);
  79. this.setState({
  80. loading: false,
  81. });
  82. if (data.error && data.error.length === 0) {
  83. this.setState({
  84. info: data.data
  85. })
  86. } else {
  87. message.warning(data.error[0].message);
  88. }
  89. }.bind(this),
  90. }).always(
  91. function () {
  92. this.setState({
  93. loading: false,
  94. });
  95. }.bind(this)
  96. );
  97. },
  98. getData() {
  99. $.ajax({
  100. method: "get",
  101. dataType: "json",
  102. crossDomain: false,
  103. url: globalConfig.context + "/api/admin/statistics/finance/lists",
  104. success: function (data) {
  105. if (data.error && data.error.length === 0) {
  106. this.setState({
  107. data: data.data,
  108. })
  109. } else {
  110. message.warning(data.error[0].message);
  111. }
  112. }.bind(this),
  113. }).always(
  114. function () {
  115. this.setState({
  116. loading: false,
  117. });
  118. }.bind(this)
  119. );
  120. },
  121. search() {
  122. this.loadData();
  123. },
  124. reset() {
  125. this.state.releaseDate = []
  126. this.loadData();
  127. },
  128. getNewUrl(url, cd) {
  129. const { htmlMenus = [] } = this.state
  130. let id = ''
  131. htmlMenus.map(function (item) {
  132. if (item.url == url) {
  133. id = item.id;
  134. }
  135. });
  136. return `${url}?rid=${id}#${cd}`
  137. },
  138. render() {
  139. const { status, info, data } = this.state
  140. let array = window.adminData.shiroList.split(",");
  141. const list = [
  142. { color: "#99FFFF", title: "总派单审核数:", sum: info.orderCount, tit: "待派单审核数", number: info.orderUnauditedCount, url: this.getNewUrl('/admin/idea.html', 'shouKuang'), type: '' },
  143. { color: "#FFFFCC", title: "总报销数:", sum: info.expenseCount, tit: "待报销审核数", number: info.expenseUnauditedCount, url: this.getNewUrl('/admin/idea.html', 'accountExamine'), type: '' },
  144. { color: "#FFCCCC", title: "总开票数:", sum: info.invoiceCount, tit: "待开票数", number: info.invoiceUnauditedCount, url: this.getNewUrl('/admin/idea.html', 'invoiceApplyList'), type: '' },
  145. { color: "#99CCFF", title: "总会员项目审核数:", sum: info.memberCount, tit: "待会员审核数", number: info.memberUnauditedCount, url: this.getNewUrl('/admin/idea.html', 'projectvip'), type: '' },
  146. { color: "#99FFCC", title: "总应收款(万元):", sum: info.receivables, tit: "应收款", number: info.rangeReceivables, url: this.getNewUrl('/admin/order.html', 'pressList'), type: '' },
  147. { color: "#CC99CC", title: "总成本审核数:", sum: info.paymentCount, tit: "待成本审核数", number: info.paymentUnauditedCount, url: this.getNewUrl('/admin/idea.html', 'costAuditList'), type: '' },
  148. { color: "#99CCCC", title: "总公出数:", sum: info.publicCount, tit: "公出数", number: info.rangePublicCount, url: '', type: '' },
  149. {
  150. color: "#FFCC99", title: "待紧急处理事项",
  151. list: [
  152. { key: "待变更审核:", value: info.changeCount, url: this.getNewUrl('/admin/idea.html', "contractChangeCwzy"), type: '1' },
  153. { key: "待变更退票处理:", value: info.changeInvoiceCount, url: this.getNewUrl('/admin/idea.html', "contractChangeCwzy"), type: '3' }]
  154. },
  155. ]
  156. const option = {
  157. title: {
  158. text: ''
  159. },
  160. tooltip: {
  161. trigger: 'axis'
  162. },
  163. legend: {
  164. data: ['订单数', '报销数', '开票数', '会员审核数', '成本审核数', '公出数',]
  165. },
  166. grid: {
  167. left: '3%',
  168. right: '4%',
  169. bottom: '3%',
  170. containLabel: true
  171. },
  172. toolbox: {
  173. feature: {
  174. saveAsImage: {}
  175. }
  176. },
  177. xAxis: {
  178. type: 'category',
  179. boundaryGap: false,
  180. // axisLabel: {
  181. // interval: 0, // 设置X轴刻度间隔为0
  182. // },
  183. data: data.dates
  184. },
  185. yAxis: {
  186. type: 'value'
  187. },
  188. color: ['#99FFFF', '#cccca3', '#FFCCCC', '#99CCFF', '#99FFCC', '#CC99CC', '#CC99CC', '#99CCCC'],
  189. series: [
  190. {
  191. name: '订单数',
  192. type: 'line',
  193. data: data.orderList,
  194. },
  195. {
  196. name: '报销数',
  197. type: 'line',
  198. data: data.expenseList,
  199. },
  200. {
  201. name: '开票数',
  202. type: 'line',
  203. data: data.invoiceList,
  204. },
  205. {
  206. name: '会员审核数',
  207. type: 'line',
  208. data: data.memberList,
  209. },
  210. {
  211. name: '成本审核数',
  212. type: 'line',
  213. data: data.paymentList,
  214. },
  215. {
  216. name: '公出数',
  217. type: 'line',
  218. data: data.publicList,
  219. },
  220. ]
  221. }
  222. return (
  223. <div className="user-content">
  224. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  225. <div className="content-title" style={{ marginBottom: 10 }}>
  226. <span style={{ fontWeight: 900, fontSize: 16 }}>数据统计</span>
  227. </div>
  228. <div className="user-search">
  229. <RadioGroup value={status}
  230. onChange={e => {
  231. this.setState({
  232. status: e.target.value
  233. })
  234. if (e.target.value == 0) {
  235. this.setState({
  236. releaseDate: []
  237. })
  238. } else {
  239. this.setState({
  240. releaseDate: getToday(e.target.value)
  241. }, () => {
  242. this.loadData()
  243. })
  244. }
  245. }}
  246. >
  247. <RadioButton value={1}>今日</RadioButton>
  248. <RadioButton value={2}>昨日</RadioButton>
  249. <RadioButton value={3}>近7日</RadioButton>
  250. <RadioButton value={4}>近15日</RadioButton>
  251. <RadioButton value={5}>近30日</RadioButton>
  252. <RadioButton value={0}>自定义</RadioButton>
  253. </RadioGroup>
  254. {
  255. status == 0 &&
  256. <span>
  257. <RangePicker
  258. style={{ width: 200, marginLeft: 15 }}
  259. value={[
  260. this.state.releaseDate[0]
  261. ? moment(this.state.releaseDate[0])
  262. : null,
  263. this.state.releaseDate[1]
  264. ? moment(this.state.releaseDate[1])
  265. : null,
  266. ]}
  267. onChange={(data, dataString) => {
  268. this.setState({ releaseDate: dataString })
  269. }}
  270. />
  271. <Button style={{ margin: "0 15px" }} type="primary" onClick={this.search}>搜索</Button>
  272. <Button onClick={this.reset}>重置</Button>
  273. </span>
  274. }
  275. </div>
  276. <div className="patent-table">
  277. <Spin spinning={this.state.loading}>
  278. <div className='plist'>
  279. {
  280. list.map((item, index) =>
  281. <div className='plitem' style={{ background: item.color }} key={index}>
  282. <div className='plititle'>
  283. <span style={{ fontWeight: item.title == "待紧急处理事项" && "bold" }}>{item.title}</span>
  284. <a href={globalConfig.context + item.url}
  285. onClick={() => {
  286. localStorage.setItem('typeZxs', item.type);
  287. }}
  288. >
  289. {item.title != "待紧急处理事项" && <span className='plisum'>{item.sum || 0}</span>}
  290. </a>
  291. </div>
  292. {
  293. item.title == "待紧急处理事项"
  294. ? <div className='list'>
  295. {
  296. item.list.map((t, i) =>
  297. <div key={i}>
  298. <span>{t.key}</span>
  299. <a href={globalConfig.context + t.url}
  300. onClick={() => {
  301. localStorage.setItem('typeCw', t.type);
  302. }}
  303. >
  304. <span style={{ textDecoration: "underline", color: "#0000FF" }}>{t.value}</span>
  305. </a>
  306. </div>
  307. )
  308. }
  309. </div>
  310. : <div className='count'>
  311. <a href={globalConfig.context + item.url}
  312. onClick={() => {
  313. localStorage.setItem('typeCw', item.type);
  314. }}
  315. ><div className='plinum'>{item.number || 0}</div></a>
  316. <div className='plitit'>{item.tit}</div>
  317. </div>
  318. }
  319. </div>
  320. )
  321. }
  322. </div>
  323. </Spin>
  324. <ReactEcharts option={option} echarts={echarts} />
  325. </div>
  326. </div>
  327. );
  328. },
  329. });
  330. export default Statistics;