|
|
@@ -0,0 +1,194 @@
|
|
|
+const _Http = getApp().globalData.http,
|
|
|
+ currency = require("../../utils/currency"),
|
|
|
+ CNY = (value, symbol = "¥", precision = 2) => currency(value, {
|
|
|
+ symbol,
|
|
|
+ precision
|
|
|
+ }).format();
|
|
|
+
|
|
|
+import * as echarts from '../ec-canvas/echarts';
|
|
|
+Component({
|
|
|
+ properties: {
|
|
|
+ mode: {
|
|
|
+ type: String
|
|
|
+ }
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ addGlobalClass: true
|
|
|
+ },
|
|
|
+ lifetimes: {
|
|
|
+ attached: function () {
|
|
|
+ getApp().globalData.Language.getLanguagePackage(this)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ year: new Date().getFullYear().toString(),
|
|
|
+ "content": {
|
|
|
+ dataid: wx.getStorageSync('userMsg').userid,
|
|
|
+ username: wx.getStorageSync('userMsg').name,
|
|
|
+ year: new Date().getFullYear().toString(),
|
|
|
+ where: {}
|
|
|
+ },
|
|
|
+ isbooked: 0,
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getList(init = false) {
|
|
|
+ let content = this.data.content
|
|
|
+ const {
|
|
|
+ dataid,
|
|
|
+ type,
|
|
|
+ username,
|
|
|
+ isleave
|
|
|
+ } = getCurrentPages()[getCurrentPages().length - 1].data;
|
|
|
+ if (content.dataid != dataid || content.type != type || isleave != isleave) init = true
|
|
|
+ content.dataid = dataid;
|
|
|
+ content.type = type;
|
|
|
+ content.username = username;
|
|
|
+ content.where.isleave = isleave;
|
|
|
+ if (this.properties.mode == '出货趋势分析') content.isbooked = this.data.isbooked;
|
|
|
+ let ids = {
|
|
|
+ '订单趋势分析': 20231012094804,
|
|
|
+ '出货趋势分析': 20231012152004,
|
|
|
+ '开票金额趋势分析': 20231016095304
|
|
|
+ }
|
|
|
+ _Http.basic({
|
|
|
+ "id": ids[this.properties.mode],
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log(this.properties.mode, res)
|
|
|
+ if (res.code != '1') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ this.initChart(res.data)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onCheckboxChange(e) {
|
|
|
+ this.setData({
|
|
|
+ isbooked: this.data.isbooked == 0 ? 1 : 0
|
|
|
+ })
|
|
|
+ this.getList(true)
|
|
|
+ },
|
|
|
+ initChart(data) {
|
|
|
+ const dividend = wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000,
|
|
|
+ colors = ['#6CD2A1', '#5F9DFC', '#ECB937', '#F69240'],
|
|
|
+ getMapText = getApp().globalData.Language.getMapText;
|
|
|
+ let legend = [`${getMapText('去年同期金额')}(${getMapText('万元')})`, `${getMapText('本期金额')}(${getMapText('万元')})`, `${getMapText('同比增长率')}`],
|
|
|
+ series = [{
|
|
|
+ name: `${getMapText('去年同期金额')}(${getMapText('万元')})`,
|
|
|
+ type: 'bar',
|
|
|
+ data: data.map(v => (v.amount / dividend).toFixed(2)),
|
|
|
+ smooth: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: `${getMapText('本期金额')}(${getMapText('万元')})`,
|
|
|
+ type: 'bar',
|
|
|
+ yAxisIndex: 1,
|
|
|
+ data: data.map(v => (v.oldamount / dividend).toFixed(2)),
|
|
|
+ smooth: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: getMapText('同比增长率'),
|
|
|
+ type: 'line',
|
|
|
+ yAxisIndex: 2,
|
|
|
+ data: data.map(v => (v.tbzzl * 100).toFixed(2)),
|
|
|
+ smooth: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ if (this.properties.mode == '出货趋势分析') {
|
|
|
+ legend.push(getMapText('准交率'))
|
|
|
+ series.push({
|
|
|
+ name: getMapText('准交率'),
|
|
|
+ type: 'line',
|
|
|
+ yAxisIndex: 2,
|
|
|
+ data: data.map(v => (v.zjl * 100).toFixed(2)),
|
|
|
+ smooth: true
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ const option = {
|
|
|
+ color: colors,
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis',
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ data: legend
|
|
|
+ },
|
|
|
+ xAxis: [{
|
|
|
+ type: 'category',
|
|
|
+ axisTick: {
|
|
|
+ alignWithLabel: true
|
|
|
+ },
|
|
|
+ data: data.map(v => v.date),
|
|
|
+ axisLabel: {
|
|
|
+ interval: 0,
|
|
|
+ rotate: 45
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ yAxis: [{
|
|
|
+ type: 'value',
|
|
|
+ name: '',
|
|
|
+ position: 'right',
|
|
|
+ offset: 80,
|
|
|
+ alignTicks: true,
|
|
|
+ axisLine: {
|
|
|
+ show: true,
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value}'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ name: '',
|
|
|
+ position: 'left',
|
|
|
+ alignTicks: true,
|
|
|
+ axisLine: {
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value}',
|
|
|
+ rotate: 45
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ name: '',
|
|
|
+ position: 'right',
|
|
|
+ alignTicks: true,
|
|
|
+ offset: 80,
|
|
|
+ axisLine: {
|
|
|
+ show: false,
|
|
|
+ lineStyle: {
|
|
|
+ color: colors[1]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: '{value}'
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ series
|
|
|
+ };
|
|
|
+ this.chartComponent = this.selectComponent('#mychart');
|
|
|
+ this.chartComponent.init((canvas, width, height, dpr) => {
|
|
|
+ const chart = echarts.init(canvas, null, {
|
|
|
+ width,
|
|
|
+ height,
|
|
|
+ devicePixelRatio: dpr
|
|
|
+ });
|
|
|
+ chart.setOption(option);
|
|
|
+ return chart;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ changeDate({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ "content.year": detail
|
|
|
+ })
|
|
|
+ this.getList(true)
|
|
|
+ },
|
|
|
+ }
|
|
|
+})
|