| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- 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: {
- },
- options: {
- addGlobalClass: true
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- this.setData({
- "content.dataid": wx.getStorageSync('userMsg').userid,
- "content.username": wx.getStorageSync('userMsg').name,
- })
- }
- },
- data: {
- "content": {
- enddate: new Date().toISOString().split('T')[0],
- where: {}
- },
- },
- 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;
- _Http.basic({
- "id": 20231018161604,
- content
- }).then(res => {
- console.log("近12月项目报价分析", res)
- if (res.code != '1') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.initChart(res.data)
- })
- },
- initChart(data) {
- console.log("data", data)
- let dividend = wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000,
- getMapText = getApp().globalData.Language.getMapText,
- list = [{
- name: "报价项目数",
- color: "#6395F9"
- }, {
- name: "项目报价次数",
- color: "#62DAAB"
- }],
- dates = [...new Set(data.map(v => v.date))]; // Use Set to remove duplicates
- list.map(item => {
- item.data = data.filter(v => v.key == item.name).map(v => v.value)
- return item
- })
- console.log("list", list)
- const option = {
- tooltip: {
- trigger: 'axis',
- confine: true,
- formatter: function (params) {
- let tooltipText = '';
- params.forEach((item, index) => {
- tooltipText += `${index==0?item.axisValue+'\n':''}${item.marker}${item.seriesName}: ${item.seriesName == getMapText('总次数同比增长率') ? (item.value * 100).toFixed(2) :item.value}${item.seriesName == getMapText('总次数同比增长率') ? '%' : ''}\n`;
- });
- return tooltipText;
- },
- textStyle: {
- fontSize: 10,
- }
- },
- legend: {
- data: list.map(v => getMapText(v.name)),
- top: '0rpx', // Moved legend position upwards by 10rpx
- textStyle: {
- fontSize: 12 // Reduced font size for legend text
- }
- },
- grid: {
- top: '15%', // Adjust grid top to leave space for the legend
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: dates,
- axisLabel: {
- interval: 0, // Force display all labels
- rotate: 45, // Rotate labels to prevent overlap
- fontSize: 10 // Reduced font size for X-axis labels
- }
- },
- yAxis: {
- type: 'value',
- axisLabel: {
- fontSize: 10 // Reduced font size for Y-axis labels
- }
- },
- series: list.map(v => {
- return {
- name: getMapText(v.name),
- type: 'line',
- stack: 'Total',
- data: v.data,
- smooth: true, // Enable smooth transition for line charts
- itemStyle: {
- color: v.color
- },
- lineStyle: {
- color: v.color
- }
- }
- })
- };
- 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.enddate": detail
- })
- this.getList(true)
- },
- showExplain(e) {
- const {
- name
- } = e.currentTarget.dataset;
- getApp().globalData.Language.modeBoxPrompts(getApp().globalData.Language.getMapText('统计到当前查询时间为止的') + name + "(" + getApp().globalData.Language.getMapText('审核状态') + ")")
- },
- }
- })
|