agentIndex.vue 15 KB

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