|
|
@@ -0,0 +1,210 @@
|
|
|
+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(),
|
|
|
+ sa_saleareaid: 0,
|
|
|
+ "type": 1, //1:人员,2:医院,3:经销商
|
|
|
+ "month_start": 1,
|
|
|
+ "month_end": 12,
|
|
|
+ "userid": 0,
|
|
|
+ "sa_customersid": 0,
|
|
|
+ "sa_agentsid": 0,
|
|
|
+ where: {}
|
|
|
+ },
|
|
|
+ areaList: [],
|
|
|
+ active: "",
|
|
|
+ details: {},
|
|
|
+ showFiltrate: false,
|
|
|
+ areaname: "",
|
|
|
+ userName: ""
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getList(init = false) {
|
|
|
+ if (init) this.getData()
|
|
|
+ },
|
|
|
+ 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) {
|
|
|
+ let organization = this.selectComponent("#organization");
|
|
|
+ await organization.initDepAndUser().then(res => {
|
|
|
+ if (res.sa_saleareaid) {
|
|
|
+ this.data.content.sa_saleareaid = res.sa_saleareaid
|
|
|
+ this.setData({
|
|
|
+ areaname: res.areaname
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ _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
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ "content.year": detail.year,
|
|
|
+ "content.month_start": detail.startMonth,
|
|
|
+ "content.month_end": detail.endMonth,
|
|
|
+ })
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ openFiltrate() {
|
|
|
+ this.setData({
|
|
|
+ showFiltrate: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async handleFilter({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let organization = this.selectComponent("#organization");
|
|
|
+
|
|
|
+ if (detail.name == "close") return;
|
|
|
+ if (detail.name == 'reset') {
|
|
|
+ organization.setData({
|
|
|
+ isleave: "0"
|
|
|
+ })
|
|
|
+ await organization.initDepAndUser().then(res => {
|
|
|
+ if (res.sa_saleareaid) {
|
|
|
+ this.data.content.sa_saleareaid = res.sa_saleareaid
|
|
|
+ this.data.content.userid = ''
|
|
|
+ this.setData({
|
|
|
+ areaname: res.areaname,
|
|
|
+ userName: ""
|
|
|
+ })
|
|
|
+ this.getData()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let res = organization.data.result;
|
|
|
+ if (res.userid) {
|
|
|
+ let dep = organization.data.selectDepObj;
|
|
|
+ this.data.content.sa_saleareaid = dep.sa_saleareaid;
|
|
|
+ this.data.content.userid = res.userid;
|
|
|
+ this.setData({
|
|
|
+ areaname: dep.areaname,
|
|
|
+ userName: res.name
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.data.content.sa_saleareaid = res.sa_saleareaid
|
|
|
+ this.data.content.userid = 0
|
|
|
+ this.setData({
|
|
|
+ areaname: res.areaname,
|
|
|
+ userName: ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.getData()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+})
|