|
|
@@ -0,0 +1,176 @@
|
|
|
+const _Http = getApp().globalData.http,
|
|
|
+ currency = require("../../../utils/currency"),
|
|
|
+ CNY = (value, symbol = "¥", precision = 2) => currency(value, {
|
|
|
+ symbol,
|
|
|
+ precision
|
|
|
+ }).format();
|
|
|
+
|
|
|
+Component({
|
|
|
+ properties: {
|
|
|
+
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ addGlobalClass: true
|
|
|
+ },
|
|
|
+ lifetimes: {
|
|
|
+ attached: function () {}
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ tabs: [],
|
|
|
+ salesShow: false,
|
|
|
+ showType: 0,
|
|
|
+ content: {
|
|
|
+ year: new Date().getFullYear(),
|
|
|
+ month: new Date().getMonth() + 1,
|
|
|
+ sa_saleareaid: 0,
|
|
|
+ "type": 1, //1:人员,2:医院,3:经销商
|
|
|
+ "month_start": 9,
|
|
|
+ "month_end": 12,
|
|
|
+ "userid": wx.getStorageSync('userMsg').userid,
|
|
|
+ "sa_customersid": 0,
|
|
|
+ "sa_agentsid": 0,
|
|
|
+ where: {}
|
|
|
+ },
|
|
|
+ areaList: [],
|
|
|
+ active: "",
|
|
|
+ details: {}
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getList(init = false) {
|
|
|
+ if (init) this.getData()
|
|
|
+ },
|
|
|
+ //查询当前账号的营销区域
|
|
|
+ getArea() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ _Http.basic({
|
|
|
+ "content": {},
|
|
|
+ "id": 2026010513574702
|
|
|
+ }).then(res => {
|
|
|
+ console.log("营销区域", res)
|
|
|
+ const areaList = res.code != 1 ? [] : res.data.map(v => {
|
|
|
+ v.value = v.areaname
|
|
|
+ return v
|
|
|
+ });
|
|
|
+ resolve(areaList);
|
|
|
+ this.setData({
|
|
|
+ areaList,
|
|
|
+ active: areaList[0].areaname
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ changeArea({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ active: detail,
|
|
|
+ "content.sa_saleareaid": this.data.areaList.find(v => v.areaname == 'detail').sa_saleareaid
|
|
|
+ });
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ async getData() {
|
|
|
+ let content = this.data.content
|
|
|
+ if (content.sa_saleareaid == 0) await this.getArea().then(res => {
|
|
|
+ if (res.length > 0) {
|
|
|
+ content.sa_saleareaid = res[0].sa_saleareaid
|
|
|
+ }
|
|
|
+ })
|
|
|
+ _Http.basic({
|
|
|
+ "id": 2026010714131502,
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log("产品目标", res)
|
|
|
+ if (res.code != 1) return wx.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ let tabs = [],
|
|
|
+ details = {};
|
|
|
+
|
|
|
+ res.data.forEach((item, index) => {
|
|
|
+ tabs.push({
|
|
|
+ name: item.itemclassname,
|
|
|
+ index: index,
|
|
|
+ key: 'm_'
|
|
|
+ })
|
|
|
+ item.m_balanceamount = CNY(item.m_balanceamount)
|
|
|
+ item.m_saleamount = CNY(item.m_saleamount)
|
|
|
+ item.m_targetamount = CNY(item.m_targetamount)
|
|
|
+ details[item.itemclassname] = item;
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ tabs,
|
|
|
+ details
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ changeDate({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let date = detail.split("-")
|
|
|
+ this.setData({
|
|
|
+ "content.year": date[0],
|
|
|
+ "content.month": date[1] - 0
|
|
|
+ })
|
|
|
+ this.getData()
|
|
|
+ },
|
|
|
+ changeType(e) {
|
|
|
+ const {
|
|
|
+ item
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ this.setData({
|
|
|
+ showType: item.index
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取营销类别
|
|
|
+ getSales() {
|
|
|
+ _Http.basic({
|
|
|
+ "content": {},
|
|
|
+ "id": 2025123014533002
|
|
|
+ }).then(res => {
|
|
|
+ console.log("营销类别", res)
|
|
|
+ const tabs = res.code != 1 ? [] : res.data.map((v, i) => {
|
|
|
+ return {
|
|
|
+ name: v,
|
|
|
+ index: i,
|
|
|
+ key: 'm_'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ tabs
|
|
|
+ })
|
|
|
+ this.closeSelect()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ selectSale() {
|
|
|
+ this.setData({
|
|
|
+ salesShow: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSelect(e) {
|
|
|
+ this.setData({
|
|
|
+ showType: e.detail.index
|
|
|
+ })
|
|
|
+ this.closeSelect();
|
|
|
+ },
|
|
|
+ swiperChange(e) {
|
|
|
+ this.setData({
|
|
|
+ showType: e.detail.current
|
|
|
+ })
|
|
|
+ this.closeSelect()
|
|
|
+ },
|
|
|
+ closeSelect() {
|
|
|
+ this.setData({
|
|
|
+ salesShow: false
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ tabs: this.data.tabs.map(v => {
|
|
|
+ v.color = v.index == this.data.showType ? '#3874F6' : ''
|
|
|
+ return v
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+})
|