yxy.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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/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/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. const list = [
  141. { color: "#99FFFF", title: "全部签单客户数:", sum: info.signSum, tit: "签单客户数", number: info.rangeSignSum, url: this.getNewUrl("/admin/customer.html", "companySign") },
  142. { color: "#FFFFCC", title: "全部私有客户数:", sum: info.privateSum, tit: "私有客户数", number: info.rangePrivateSum, url: this.getNewUrl("/admin/customer.html", "companyIntention") },
  143. { color: "#FFCCCC", title: "全部渠道数:", sum: info.channelSum, tit: "私有渠道数", number: info.rangeChannelSum, url: this.getNewUrl("/admin/channelList.html", "channelunit") },
  144. { color: "#99CCFF", title: "全部公出数:", sum: info.publicReleaseSum, tit: "公出企业数", number: info.rangePublicReleaseSum, url: "" },
  145. { color: "#99FFCC", title: "全部跟进客户数:", sum: info.followSum, tit: "跟进客户数", number: info.rangeFollowSum, url: this.getNewUrl("/admin/customer.html", "followUpSummaryOrdinary") },
  146. { color: "#CC99CC", title: "全部订单数:", sum: info.orderSum, tit: "订单数", number: info.rangeOrderSum, url: this.getNewUrl("/admin/order.html", "billing") },
  147. { color: "#99CCCC", title: "全部应收款:", sum: info.receivables, tit: "应收款", number: info.rangeReceivables, url: this.getNewUrl("/admin/order.html", "press") },
  148. {
  149. color: "#FFCC99", title: "待紧急处理事项",
  150. list: [
  151. { key: "被驳回订单:", value: info.rejectSum, url: this.getNewUrl("/admin/order.html", "reject") },
  152. { key: "待变更订单:", value: info.changeSum, url: this.getNewUrl("/admin/order.html", "contractChangeYxy") },
  153. { key: "待核对专利:", value: info.projectCheckSum, url: this.getNewUrl("/admin/project.html", "businessManagement") },
  154. { key: "暂停项目:", value: info.projectStopSum, url: this.getNewUrl("/admin/order.html", "mysuspend") },]
  155. },
  156. ]
  157. const option = {
  158. title: {
  159. text: ''
  160. },
  161. tooltip: {
  162. trigger: 'axis'
  163. },
  164. legend: {
  165. data: ['签单客户数', '私有客户数', '私有渠道数', '公出企业数', '跟进客户数', '订单数',]
  166. },
  167. grid: {
  168. left: '3%',
  169. right: '4%',
  170. bottom: '3%',
  171. containLabel: true
  172. },
  173. toolbox: {
  174. feature: {
  175. saveAsImage: {}
  176. }
  177. },
  178. xAxis: {
  179. type: 'category',
  180. boundaryGap: false,
  181. // axisLabel: {
  182. // interval: 0, // 设置X轴刻度间隔为0
  183. // },
  184. data: data.dates
  185. },
  186. yAxis: {
  187. type: 'value'
  188. },
  189. color: ['#99FFFF', '#cccca3', '#FFCCCC', '#99CCFF', '#99FFCC', '#CC99CC'],
  190. series: [
  191. {
  192. name: '签单客户数',
  193. type: 'line',
  194. data: data.signList,
  195. },
  196. {
  197. name: '私有客户数',
  198. type: 'line',
  199. data: data.privateList,
  200. },
  201. {
  202. name: '私有渠道数',
  203. type: 'line',
  204. data: data.channelList,
  205. },
  206. {
  207. name: '公出企业数',
  208. type: 'line',
  209. data: data.publicReleaseList,
  210. },
  211. {
  212. name: '跟进客户数',
  213. type: 'line',
  214. data: data.userFollowList,
  215. },
  216. {
  217. name: '订单数',
  218. type: 'line',
  219. data: data.orderList,
  220. }
  221. ]
  222. }
  223. return (
  224. <div className="user-content">
  225. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  226. <div className="content-title" style={{ marginBottom: 10 }}>
  227. <span style={{ fontWeight: 900, fontSize: 16 }}>数据统计</span>
  228. </div>
  229. <div className="user-search">
  230. <RadioGroup value={status}
  231. onChange={e => {
  232. this.setState({
  233. status: e.target.value
  234. })
  235. if (e.target.value == 0) {
  236. this.setState({
  237. releaseDate: []
  238. })
  239. } else {
  240. this.setState({
  241. releaseDate: getToday(e.target.value)
  242. }, () => {
  243. this.loadData()
  244. })
  245. }
  246. }}
  247. >
  248. <RadioButton value={1}>今日</RadioButton>
  249. <RadioButton value={2}>昨日</RadioButton>
  250. <RadioButton value={3}>近7日</RadioButton>
  251. <RadioButton value={4}>近15日</RadioButton>
  252. <RadioButton value={5}>近30日</RadioButton>
  253. <RadioButton value={0}>自定义</RadioButton>
  254. </RadioGroup>
  255. {
  256. status == 0 &&
  257. <span>
  258. <RangePicker
  259. style={{ width: 200, marginLeft: 15 }}
  260. value={[
  261. this.state.releaseDate[0]
  262. ? moment(this.state.releaseDate[0])
  263. : null,
  264. this.state.releaseDate[1]
  265. ? moment(this.state.releaseDate[1])
  266. : null,
  267. ]}
  268. onChange={(data, dataString) => {
  269. this.setState({ releaseDate: dataString })
  270. }}
  271. />
  272. <Button style={{ margin: "0 15px" }} type="primary" onClick={this.search}>搜索</Button>
  273. <Button onClick={this.reset}>重置</Button>
  274. </span>
  275. }
  276. </div>
  277. <div className="patent-table">
  278. <Spin spinning={this.state.loading}>
  279. <div className='plist'>
  280. {
  281. list.map((item, index) =>
  282. <div className='plitem' style={{ background: item.color }} key={index}>
  283. <div className='plititle'>
  284. <span style={{ fontWeight: item.title == "待紧急处理事项" && "bold" }}>{item.title}</span>
  285. {/* <span className='plisum'>{item.sum}</span> */}
  286. <a href={globalConfig.context + item.url}>
  287. <span className='plisum'>{item.sum}</span>
  288. </a>
  289. </div>
  290. {
  291. item.title == "待紧急处理事项"
  292. ? <div className='list'>
  293. {
  294. item.list.map((t, i) =>
  295. <div key={i}>
  296. <span>{t.key}</span>
  297. <a href={globalConfig.context + t.url}>
  298. <span style={{ textDecoration: "underline", color: "#0000FF" }}>{t.value}</span>
  299. </a>
  300. </div>
  301. )
  302. }
  303. </div>
  304. : <div className='count'>
  305. <a href={globalConfig.context + item.url}><div className='plinum'>{item.number}</div></a>
  306. <div className='plitit'>{item.tit}</div>
  307. </div>
  308. }
  309. </div>
  310. )
  311. }
  312. </div>
  313. </Spin>
  314. <ReactEcharts option={option} echarts={echarts} />
  315. </div>
  316. </div>
  317. );
  318. },
  319. });
  320. export default Statistics;