| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- import * as echarts from '../../../pages/ec-canvas/echarts.min';
- import { getOpData } from '../echarts-data.js'
- const app = getApp()
- const Constants = require('../../../utils/Constants.js');
- const util = require('../../../utils/util.js')
- const mixins = require('@/mixins/index.js')
- Page({
- mixins: [mixins],
- /**
- * 页面的初始数据
- */
- data: {
- service: app.globalData['reportService'],
- // 查询条件
- searchContent: [{
- code: 'makeTime',
- title: mixins.$t('currentMonth'),
- defaultValue: 3,
- searchType: Constants.searchType.date
- }],
- loading: false,
- ec: {},
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // 报表查询数据
- this.getSaleProfit()
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- //调用刷新时将执行的方法
- this.onRefresh();
- },
- onRefresh() {
- //在当前页面显示导航条加载动画
- wx.showNavigationBarLoading()
- //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
- //报表查询数据
- this.getSaleProfit()
- },
- /** 去详细 */
- toDetail(e) {
- console.log(e, '/package-business-analysis/pages/profit-report/' + e.currentTarget.dataset.url)
- wx.navigateTo({
- url: '/package-business-analysis/pages/profit-report/' + e.currentTarget.dataset.url
- })
- },
- onShow() {
- this.echartsProfitDate = this.selectComponent("#echartsProfitDate")
- this.echartsProfitStaff = this.selectComponent("#echartsProfitStaff")
- this.echartsProfitOrg = this.selectComponent("#echartsProfitOrg")
- this.echartsProfitSku = this.selectComponent("#echartsProfitSku")
- },
- /** 设置echarts */
- setEcharts(name, { data, labelKey, valueKey, type }) {
- this[name].init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr
- });
- canvas.setChart(chart);
- chart.setOption(getOpData(data, labelKey, valueKey, type));
- return chart;
- });
- },
- /**
- * 销售毛利点击按日或按月查询
- */
- clickProfitDate(e) {
- this.setData({
- byDate: e.currentTarget.dataset.value
- })
- this.getSaleProfit()
- },
- /** 查询所有报表信息 */
- /** 查询页面展示的所有 */
- getSaleProfit() {
- this.setData({
- loading: true
- })
- this.excute(this.data.service, this.data.service.getSaleProfit, Object.assign({
- byDate: this.data.byDate
- }, JSON.parse(this.data.searchForm))).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- this.setData({
- profit: res.data.data.profit,
- })
- /** 图形重新渲染 */
- setTimeout(() => {
- this.setEcharts('echartsProfitDate', { data: res.data.data.dateProfit, labelKey: 'accDate', valueKey: 'profit', type: 1 })
- this.setEcharts('echartsProfitOrg', { data: res.data.data.orgProfit, labelKey: 'orgName', valueKey: 'profit', type: 3 })
- this.setEcharts('echartsProfitStaff', { data: res.data.data.staffProfit, labelKey: 'staffName', valueKey: 'profit', type: 3 })
- this.setEcharts('echartsProfitSku', { data: res.data.data.skuProfit, labelKey: 'skuName', valueKey: 'profit', type: 3 })
- }, 1000)
- }
- this.setData({
- loading: false
- })
- })
- },
- /**
- * 显示tip
- */
- showTip(e) {
- let item = e.currentTarget.dataset.item
- if (item) {
- util.showToast(item);
- }
- },
- })
|