123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- active: "业绩目标",
- targetYear: null,
- "year": new Date().getFullYear().toString(),
- "content": {
- "nocache": true,
- "year": new Date().getFullYear().toString(), //年
- "targettype": "人员目标", //1
- "type": 1, //
- "where": {
- "condition": ""
- }
- },
- target: null, //目标
- showActions: false,
- actionSheet: "开票金额",
- actions: [{
- name: '开票金额',
- value: "1"
- }, {
- name: '订单金额',
- value: "2"
- }, {
- name: '出货金额',
- value: "3"
- }],
- },
- onLoad(options) {
- this.getData();
- },
- toDetail() {
- if (this.data.active == "业绩目标") {
- wx.navigateTo({
- url: './person',
- })
- } else {
- }
- },
- getData() {
- _Http.basic({
- "id": 20220920133102,
- "content": this.data.content
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- let lineData = [],
- histogram = [];
- res.data.month.forEach(v => {
- lineData = lineData.concat([{
- label: v.month + '月',
- value: v.l,
- type: "基本目标金额"
- },
- {
- label: v.month + '月',
- value: v.h,
- type: "挑战目标金额"
- },
- {
- label: v.month + '月',
- value: v.a,
- type: "实际订单金额"
- }
- ])
- histogram = histogram.concat([{
- label: v.month + '月',
- value: v.pl,
- type: "基础目标实际完成率"
- },
- {
- label: v.month + '月',
- value: v.ph,
- type: "挑战目标实际完成率"
- }
- ])
- });
- //绘制线图
- this.selectComponent("#line").render(lineData);
- this.selectComponent("#histogram").render(histogram);
- this.setData({
- targetYear: {
- yl: res.data.y1l,
- yh: res.data.y1h,
- ya: res.data.y1a,
- }
- });
- if (this.data.year == this.data.content.year) {
- const m = new Date().getMonth() + 1;
- let s = [
- [1, 2, 3],
- [4, 5, 6],
- [7, 8, 9],
- [10, 11, 12]
- ].findIndex(v => v.some(va => va == m)) + 1;
- this.setData({
- targetSeason: {
- sl: res.data[`s${s}l`],
- sh: res.data[`s${s}h`],
- sa: res.data[`s${s}a`],
- },
- targetMonth: {
- ml: res.data[`m${m}l`],
- mh: res.data[`m${m}h`],
- ma: res.data[`m${m}a`]
- }
- })
- }
- })
- },
- /* 弹出选择 */
- select({
- detail
- }) {
- if (this.data.actionSheet == detail.name) return;
- this.setData({
- actionSheet: detail.name,
- "content.type": detail.value,
- showActions: false
- });
- this.getData();
- },
- cancelActions() {
- this.setData({
- showActions: false
- })
- },
- openActions() {
- this.setData({
- showActions: true
- })
- },
- /* 选择年份 */
- bindDateChange({
- detail
- }) {
- if (this.data.content.year == detail.value) return;
- this.setData({
- "content.year": detail.value
- });
- this.getData();
- },
- /* tabs切换 */
- tabsChange({
- detail
- }) {
- this.setData({
- "content.targettype": detail.title == '业绩目标' ? '人员目标' : '项目目标',
- active: detail.title
- });
- this.getData();
- },
- onShareAppMessage() {}
- })
|