| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- 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: {
- idname: {
- type: [String || Number]
- },
- keyName: {
- type: String
- }
- },
- 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: {
- dateTypes: ["全部", "本年"],
- "content": {
- pageNumber: 1,
- pageTotal: 1,
- dateType: "本年",
- type: 0,
- where: {
- begdate: "",
- enddate: "",
- isleave: "1",
- }
- },
- filterShow: false,
- filtratelist: [{
- label: "项目状态",
- index: null,
- showName: "value", //显示字段
- valueKey: "status", //返回Key
- selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
- value: "", //选中值
- type: "checkbox",
- list: [{
- value: "跟进中"
- }, {
- value: "已成交"
- }, {
- value: "已失败"
- }, {
- value: "已结案"
- }]
- }]
- },
- methods: {
- async getList(init = false) {
- console.log(13123)
- if (init.detail != undefined) init = init.detail;
- 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 (init) {
- content.pageNumber = 1;
- content.pageTotal = 1;
- content.where[this.data.keyName] = "";
- }
- if (content.pageNumber > content.pageTotal) return;
- _Http.basic({
- "id": 20231019090104,
- content
- }).then(res => {
- this.selectComponent('#ListBox').automaticSetHei();
- this.selectComponent('#ListBox').RefreshToComplete();
- console.log('项目列表', res)
- if (res.code != '1') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- res.data = res.data.map(v => {
- v.signamount_due = CNY(v.signamount_due)
- v.dealamount = CNY(v.dealamount)
- return v
- })
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- "content.pageNumber": res.pageNumber + 1,
- "content.pageSize": res.pageSize,
- })
- this.selectComponent("#TimeRange").onCancel()
- if (init) _Http.basic({
- id: this.data.idname,
- content
- }).then(res1 => {
- console.log("图标", res1)
- this.initChart(res1.data, res.total);
- })
- })
- },
- initChart(data, total) {
- const getMapText = getApp().globalData.Language.getMapText;
- let countDown = null,
- that = this;
- function changeUnwriteoffamounttype(index) {
- if (countDown) return;
- countDown = setTimeout(() => {
- clearTimeout(countDown)
- countDown = null;
- let value = data[index].key,
- keyName = that.data.keyName;
- if (keyName == 'projecttype') {
- value = value.split("-")[0]
- }
- if (data[index].key != that.data.content.where[keyName]) that.setData({
- [`content.where.${keyName}`]: value || "",
- "content.pageNumber": 1,
- });
- that.getList()
- }, 200)
- };
- let option = {
- tooltip: {
- trigger: 'item',
- confine: true, // Ensure tooltip stays within chart boundaries
- formatter: function (params) {
- changeUnwriteoffamounttype(params.dataIndex)
- return `${getMapText(params.name)}: ${params.value} (${params.percent}%)`;
- },
- },
- legend: {
- type: 'scroll', // Enable scrollable legend
- bottom: '5%', // Moved legend to the bottom
- left: 'center',
- pageIconColor: '#333', // Customize page icon color
- pageTextStyle: {
- color: '#333' // Customize page text style
- }
- },
- series: [{
- type: 'pie',
- radius: ['40%', '70%'],
- center: ['50%', '42%'], // Adjusted to align with the new legend position
- endAngle: 360,
- data: data.map(v => {
- return {
- name: getMapText(v.key),
- value: (v.ratio).toFixed(2),
- }
- }),
- label: {
- normal: {
- show: true,
- position: 'outside',
- formatter: '{b}: {c} ({d}%)',
- textStyle: {
- fontSize: 12,
- color: '#333'
- }
- },
- emphasis: {
- show: true,
- textStyle: {
- fontSize: 14,
- fontWeight: 'bold'
- }
- },
- rich: {
- total: {
- fontSize: 20,
- fontWeight: 'bold',
- color: '#333'
- },
- desc: {
- fontSize: 12,
- color: '#999'
- }
- }
- },
- labelLine: {
- normal: {
- show: true,
- length: 10,
- length2: 10
- }
- }
- }]
- };
- option.graphic = {
- type: 'text',
- left: 'center',
- top: '35%', // Adjusted to align with the new series position
- style: {
- text: `${getMapText('项目总数')}\n\n${total}`,
- textAlign: 'center',
- fill: '#333',
- fontSize: 16,
- fontWeight: 'bold'
- }
- };
- 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;
- });
- },
- upDateList() {
- _Http.updateList = () => {
- let content = JSON.parse(JSON.stringify(this.data.content));
- console.log("content", content)
- try {
- content.pageSize = (content.pageNumber - 1) * content.pageSize;
- content.pageNumber = 1;
- } catch (error) {
- console.log("error", error)
- }
- _Http.basic({
- id: '20231019090104',
- content
- }).then(res => {
- console.log("更新列表", res);
- if (res.code == '1') {
- this.setData({
- list: res.data
- })
- }
- })
- }
- },
- toDetail(e) {
- console.log(e)
- wx.navigateTo({
- url: '/packageA/project/detail?id=' + e.currentTarget.dataset.item.sa_projectid,
- })
- this.upDateList();
- },
- changeDate({
- detail
- }) {
- this.setData({
- "content.dateType": detail.dateType,
- "content.where.begdate": detail.begdate || "",
- "content.where.enddate": detail.enddate || ""
- })
- this.getList(true)
- },
- clickOpen() {
- this.setData({
- filterShow: true
- })
- },
- /* 处理筛选 */
- handleFilter({
- detail
- }) {
- if (detail.name == "confirm") {
- this.setData({
- "content.where.status": detail.status
- })
- this.selectComponent('#Filtrate').setShowArrText(detail.status)
- this.getList(true)
- } else if (detail.name == 'reset') {
- this.setData({
- "content.where.status": []
- })
- this.selectComponent('#Filtrate').setShowArrText([])
- this.getList(true)
- }
- },
- }
- })
|