agentIndex.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <el-row>
  3. <el-col :span="24">
  4. <basic-container>
  5. <avue-form :option="agentInfo.accountInfo.option" v-model="agentInfo.accountInfo.agentData">
  6. <template slot-scope="scope" slot="avatar">
  7. <avue-avatar :size="50" shape="circle" icon="el-icon-circle-plus-outline"
  8. :src="agentInfo.accountInfo.agentData.avatar"
  9. style="border: 1px solid #eee"/>
  10. <span class="mallName">{{ agentInfo.accountInfo.agentData.accountName }}</span>
  11. </template>
  12. <template slot-scope="scope" slot="totalBalance">
  13. <span>{{ agentInfo.accountInfo.agentData.totalBalance }} 元</span>
  14. </template>
  15. <template slot-scope="scope" slot="availableValance">
  16. <span>{{ agentInfo.accountInfo.agentData.availableValance }} 元</span>
  17. </template>
  18. </avue-form>
  19. </basic-container>
  20. </el-col>
  21. <el-col :span="24">
  22. <basic-container>
  23. <avue-data-panel :option="optionTotal"></avue-data-panel>
  24. </basic-container>
  25. </el-col>
  26. <el-col :span="24">
  27. <basic-container>
  28. <div>
  29. <h3>今日新增</h3>
  30. <avue-data-display :option="optionToday"></avue-data-display>
  31. </div>
  32. </basic-container>
  33. </el-col>
  34. <el-col :span="24">
  35. <basic-container>
  36. <div>
  37. <h3>新增趋势
  38. <el-date-picker
  39. size="mini"
  40. :picker-options="tenantAddTrend.pickerOptions"
  41. v-model="tenantAddTrend.time"
  42. type="month"
  43. @change="getTenantAddTrend"
  44. value-format="yyyy-MM"
  45. placeholder="选择月"
  46. style="float: right">
  47. </el-date-picker>
  48. </h3>
  49. <div ref="tenantAddTrend" style="height: 500px;width: 100%"></div>
  50. </div>
  51. </basic-container>
  52. </el-col>
  53. <el-col :span="24">
  54. <basic-container>
  55. <div>
  56. <h3>代理账单
  57. <el-date-picker
  58. size="mini"
  59. :picker-options="tenantPlatformBills.pickerOptions"
  60. v-model="tenantPlatformBills.time"
  61. type="month"
  62. @change="getTenantPlatformBills"
  63. value-format="yyyy-MM"
  64. placeholder="选择月"
  65. style="float: right">
  66. </el-date-picker>
  67. </h3>
  68. <div ref="tenantPlatformBills" style="height: 500px;width: 100%"></div>
  69. </div>
  70. </basic-container>
  71. </el-col>
  72. </el-row>
  73. </template>
  74. <script>
  75. import moment from "moment";
  76. import {mapGetters} from "vuex";
  77. import * as echarts from 'echarts';
  78. import {
  79. getAgentInfo,
  80. getAgentTenantAddTrend,
  81. getAgentTenantCensusCount,
  82. getTenantAgentBills,
  83. getAgentTenantTodayCensusCount,
  84. } from '@/api/census/census';
  85. export default {
  86. data() {
  87. return {
  88. agentInfo: {
  89. isLimitHeight: true,
  90. accountInfo: {
  91. agentData: {},
  92. option: {
  93. detail: true,
  94. labelPosition: "left",
  95. group: [
  96. {
  97. label: '代理信息',
  98. prop: 'agentInfo',
  99. icon: 'el-icon-s-custom',
  100. column: [
  101. {
  102. prop: "avatar",
  103. span: 24,
  104. slot: true,
  105. labelWidth: 0,
  106. },
  107. {
  108. label: '账户总余额',
  109. span: 8,
  110. prop: 'totalBalance',
  111. slot: true,
  112. },
  113. {
  114. label: '可提现余额',
  115. span: 8,
  116. prop: 'availableValance',
  117. slot: true,
  118. },
  119. {
  120. label: '用户身份',
  121. span: 8,
  122. prop: 'userType',
  123. },
  124. ]
  125. }
  126. ]
  127. }
  128. },
  129. },
  130. optionTotal: {
  131. span: 12,
  132. data: [
  133. {
  134. click: () => {
  135. this.$router.push({path: "/ldt_agent/agentrecord"});
  136. },
  137. title: '商店总数',
  138. count: 0,
  139. icon: 'el-icon-s-shop',
  140. color: 'rgb(27, 201, 142)',
  141. },
  142. {
  143. click: () => {
  144. this.$router.push({path: "/ldt_agent/agentbills"});
  145. },
  146. title: '收入总额',
  147. count: 0,
  148. decimals: 2,
  149. icon: 'el-icon-s-marketing',
  150. color: '#f37b1d',
  151. },
  152. ]
  153. },
  154. optionToday: {
  155. span: 12,
  156. data: [
  157. {
  158. click: () => {
  159. this.$router.push({path: "/ldt_agent/agentrecord"});
  160. },
  161. count: 0,
  162. title: '新增商户',
  163. },
  164. {
  165. click: () => {
  166. this.$router.push({path: "/ldt_agent/agentbills"});
  167. },
  168. count: 0,
  169. decimals: 2,
  170. title: '今日收入',
  171. },
  172. ]
  173. },
  174. tenantAddTrend: {
  175. dom: null,
  176. time: moment(Date.now()).format("yyyy-MM"),
  177. pickerOptions: {
  178. disabledDate(time) {
  179. return time.getTime() > Date.now()
  180. }
  181. },
  182. option: {
  183. legend: {},
  184. tooltip: {
  185. trigger: 'axis',
  186. showContent: false
  187. },
  188. dataset: {
  189. source: [
  190. ['trend'],
  191. ['商户新增'],
  192. ],
  193. path: ["/ldt_agent/agentrecord"]
  194. },
  195. xAxis: {type: 'category'},
  196. yAxis: {gridIndex: 0, splitNumber: 2},
  197. // grid: {top: '55%'},
  198. series: [
  199. {
  200. type: 'line',
  201. smooth: true,
  202. seriesLayoutBy: 'row',
  203. emphasis: {focus: 'series'},
  204. },
  205. // {
  206. // type: 'pie',
  207. // id: 'pie',
  208. // radius: '30%',
  209. // center: ['50%', '25%'],
  210. // emphasis: {
  211. // focus: 'self'
  212. // },
  213. // label: {
  214. // formatter: '{b}: {@2012} ({d}%)'
  215. // },
  216. // encode: {
  217. // itemName: 'trend',
  218. // value: moment(Date.now()).format("yyyy-MM-DD"),
  219. // tooltip: moment(Date.now()).format("yyyy-MM-DD")
  220. // }
  221. // }
  222. ]
  223. }
  224. },
  225. tenantPlatformBills: {
  226. dom: null,
  227. time: moment(Date.now()).format("yyyy-MM"),
  228. pickerOptions: {
  229. disabledDate(time) {
  230. return time.getTime() > Date.now()
  231. }
  232. },
  233. option: {
  234. legend: {},
  235. tooltip: {
  236. trigger: 'axis',
  237. showContent: true
  238. },
  239. xAxis: [{
  240. data: []
  241. }],
  242. yAxis: {gridIndex: 0, splitNumber: 10},
  243. grid: {top: '15%'},
  244. series: [
  245. {
  246. name: '代理收益',
  247. type: 'line',
  248. smooth: true,
  249. seriesLayoutBy: 'row',
  250. data: []
  251. },
  252. ]
  253. }
  254. },
  255. }
  256. },
  257. computed: {
  258. ...
  259. mapGetters(["userInfo"]),
  260. },
  261. mounted() {
  262. this.init();
  263. },
  264. methods: {
  265. //初始化方法
  266. init() {
  267. this.getAgentInfo();
  268. this.getTenantCensusCount();
  269. this.getTenantTodayCensusCount();
  270. this.getTenantAddTrend();
  271. this.getTenantPlatformBills();
  272. },
  273. //删除数组的某个元素
  274. deleteArrayByObj(arr, attrName, ...value) {
  275. value.forEach(ele => {
  276. for (let i = 0; i < arr.length; i++) {
  277. const column = arr[i];
  278. if (ele === column[attrName]) {
  279. arr.splice(i, 1);
  280. }
  281. }
  282. });
  283. },
  284. //获取租户数据统计
  285. getTenantCensusCount() {
  286. //获取租户数量
  287. getAgentTenantCensusCount().then(res => {
  288. this.setArrayObjAttrByObj(this.optionTotal.data, "title", "商店总数", "count", res.data.data.shopCount);
  289. this.setArrayObjAttrByObj(this.optionTotal.data, "title", "收入总额", "count", res.data.data.incomeTotal);
  290. });
  291. },
  292. //获取租户当日数据统计
  293. getTenantTodayCensusCount() {
  294. //获取租户数量
  295. getAgentTenantTodayCensusCount().then(res => {
  296. this.setArrayObjAttrByObj(this.optionToday.data, "title", "新增商户", "count", res.data.data.shopCount);
  297. this.setArrayObjAttrByObj(this.optionToday.data, "title", "今日收入", "count", res.data.data.incomeTotal);
  298. });
  299. },
  300. //设置数组对象属性值
  301. setArrayObjAttrByObj(arr, attrName, attrValue, key, value) {
  302. arr.forEach(ele => {
  303. if (ele[attrName] === attrValue) {
  304. ele[key] = value;
  305. return;
  306. }
  307. });
  308. },
  309. //获取租户平台新增趋势
  310. getTenantAddTrend() {
  311. let time = moment(this.tenantAddTrend.time);
  312. //获取租户数量
  313. getAgentTenantAddTrend({
  314. time: time.format("yyyy-MM-DD HH:mm:ss")
  315. }).then(res => {
  316. //清空内容
  317. for (let i = 0; i < this.tenantAddTrend.option.dataset.source.length; i++) {
  318. this.tenantAddTrend.option.dataset.source[i].splice(1);
  319. }
  320. //获取某月总天数
  321. const day = time.format("yyyy-MM") === moment(Date.now()).format("yyyy-MM") ? Number(moment(Date.now()).format("DD"))
  322. : new Date(time.format("yyyy"), time.format("MM"), 0).getDate();
  323. for (let i = 0; i < day; i++) {
  324. //添加日期X坐标
  325. const date = time.format("yyyy-MM-DD");
  326. this.tenantAddTrend.option.dataset.source[0].push(date);
  327. //添加Y坐标
  328. //添加商户新增
  329. this.setAddTrend(res.data.data.shopAddCount, date, "商户新增");
  330. //加上一天
  331. time.add(1, 'days');
  332. }
  333. //第一次渲染
  334. if (this.tenantAddTrend.dom === null) {
  335. this.tenantAddTrend.dom = echarts.init(this.$refs.tenantAddTrend);
  336. //添加坐标点击
  337. this.tenantAddTrend.dom.on('updateAxisPointer', (event) => {
  338. const xAxisInfo = event.axesInfo[0];
  339. if (xAxisInfo) {
  340. const dimension = xAxisInfo.value + 1;
  341. this.tenantAddTrend.dom.setOption({
  342. series: {
  343. id: 'pie',
  344. label: {
  345. formatter: '{b}: {@[' + dimension + ']} ({d}%)'
  346. },
  347. encode: {
  348. value: dimension,
  349. tooltip: dimension
  350. }
  351. }
  352. });
  353. }
  354. });
  355. //添加饼图点击
  356. this.tenantAddTrend.dom.on('click', (params) => {
  357. if (params.componentSubType === "pie") {
  358. this.$router.push({path: this.tenantAddTrend.option.dataset.path[params.dataIndex]});
  359. }
  360. });
  361. //适应屏幕变化
  362. window.addEventListener("resize", () => {
  363. this.tenantAddTrend.dom.resize()
  364. });
  365. }
  366. this.tenantAddTrend.dom.setOption(this.tenantAddTrend.option);
  367. });
  368. },
  369. //设置趋势
  370. setAddTrend(arr, date, attrName) {
  371. //添加Y坐标
  372. let count = 0;
  373. //添加用户新增
  374. arr.forEach(ele => {
  375. if (ele.time === date) {
  376. count = ele.count;
  377. }
  378. });
  379. this.tenantAddTrend.option.dataset.source.forEach(ele => {
  380. if (ele[0] === attrName) {
  381. ele.push(count);
  382. }
  383. });
  384. },
  385. //获取租户代理收益趋势
  386. getTenantPlatformBills() {
  387. let time = moment(this.tenantPlatformBills.time);
  388. //获取租户数量
  389. getTenantAgentBills({
  390. time: time.format("yyyy-MM-DD HH:mm:ss")
  391. }).then(res => {
  392. //清空内容
  393. this.tenantPlatformBills.option.xAxis[0].data = [];
  394. this.tenantPlatformBills.option.series.forEach(ele => {
  395. ele.data = [];
  396. });
  397. //获取某月总天数
  398. const day = time.format("yyyy-MM") === moment(Date.now()).format("yyyy-MM") ? Number(moment(Date.now()).format("DD"))
  399. : new Date(time.format("yyyy"), time.format("MM"), 0).getDate();
  400. for (let i = 0; i < day; i++) {
  401. //添加日期X坐标
  402. const date = time.format("yyyy-MM-DD");
  403. this.tenantPlatformBills.option.xAxis[0].data.push(date);
  404. //添加金额Y坐标
  405. this.tenantPlatformBills.option.series[0].data.push(this.getPriceByDate(res.data.data.agentIncomeBills, date));
  406. //加上一天
  407. time.add(1, 'days');
  408. }
  409. //第一次渲染
  410. if (this.tenantPlatformBills.dom === null) {
  411. this.tenantPlatformBills.dom = echarts.init(this.$refs.tenantPlatformBills);
  412. //适应屏幕变化
  413. window.addEventListener("resize", () => {
  414. this.tenantPlatformBills.dom.resize()
  415. });
  416. }
  417. this.tenantPlatformBills.dom.setOption(this.tenantPlatformBills.option);
  418. });
  419. },
  420. /**
  421. * 根据日期获取金额
  422. */
  423. getPriceByDate(array, date) {
  424. let price = 0;
  425. array.forEach(ele => {
  426. if (ele.time === date) {
  427. price = ele.price;
  428. }
  429. });
  430. return price;
  431. }
  432. ,
  433. getAgentInfo() {
  434. getAgentInfo({}).then(res => {
  435. this.agentInfo.accountInfo.agentData = res.data.data;
  436. });
  437. },
  438. changeAccountType(res) {
  439. switch (res) {
  440. case 'SETTLE_ACCOUNT':
  441. return "待结算账户";
  442. case 'FUND_ACCOUNT':
  443. return "商户资金账户";
  444. case 'MARKET_ACCOUNT':
  445. return "营销账户";
  446. case 'DIVIDE_ACCOUNT':
  447. return "待分账账户";
  448. case 'FEE_ACCOUNT':
  449. return "手续费账户";
  450. default:
  451. return "";
  452. }
  453. },
  454. changeAccountStatus(res) {
  455. switch (res) {
  456. case 'AVAILABLE':
  457. return "可用";
  458. case 'FROZEN':
  459. return "冻结";
  460. case 'FROZEN_CREDIT':
  461. return "冻结止收";
  462. case 'FROZEN_DEBIT':
  463. return "冻结止付";
  464. case 'CANCELLATION':
  465. return "销户";
  466. default:
  467. return "";
  468. }
  469. },
  470. handleClose(done) {
  471. this.$confirm('确认关闭?')
  472. .then(_ => {
  473. done();
  474. })
  475. .catch(_ => {
  476. });
  477. },
  478. rechargeSubmit(row, done) {
  479. rechargeSubmit(row).then((res) => {
  480. //回显账单
  481. this.rechargeTable.data = res.data.data;
  482. this.rechargeTable.data.remark = row.remark;
  483. this.rechargeTable.status = true;
  484. this.onLoad(this.page);
  485. this.$message({
  486. type: "success",
  487. message: "操作成功!"
  488. });
  489. done();
  490. }, error => {
  491. done();
  492. });
  493. },
  494. }
  495. }
  496. </script>
  497. <style scoped="scoped">
  498. .recharge-btn {
  499. color: deepskyblue;
  500. margin-left: 10px;
  501. }
  502. .recharge-btn:hover {
  503. cursor: pointer;
  504. color: red;
  505. text-decoration: underline;
  506. font-weight: bold;
  507. font-size: medium;
  508. }
  509. .mallName {
  510. font-family: inherit;
  511. font-size: inherit;
  512. border-color: #E4E7ED;
  513. color: #606266;
  514. margin-left: 15px;
  515. text-align: center;
  516. }
  517. </style>