|
|
@@ -0,0 +1,373 @@
|
|
|
+// package5/pages/report/detail/detail.js
|
|
|
+
|
|
|
+const api = require('../../../utils/api.js');
|
|
|
+const util = require('../../../utils/util.js')
|
|
|
+const app = getApp()
|
|
|
+const Constants = require('../../../utils/Constants.js');
|
|
|
+
|
|
|
+
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data:{
|
|
|
+ active: 0,
|
|
|
+ createTimeType: {
|
|
|
+ "text": "本月",
|
|
|
+ "value": 3
|
|
|
+ },
|
|
|
+ month: [
|
|
|
+ "2024-01-01",
|
|
|
+ "2024-01-31"
|
|
|
+ ],
|
|
|
+ monthFlag: false,
|
|
|
+ monthName: "2024年1月",
|
|
|
+ monthOnChoose: 1706679819270,
|
|
|
+ option1: [
|
|
|
+ {
|
|
|
+ "text": "本日",
|
|
|
+ "value": 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "text": "本周",
|
|
|
+ "value": 2
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "text": "本月",
|
|
|
+ "value": 3
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "text": "本年",
|
|
|
+ "value": 5
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "text": "自定义",
|
|
|
+ "value": 0
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ orgFlag: false,
|
|
|
+ orgIds: [],
|
|
|
+ orgNames: null,
|
|
|
+ tab1Columns: [
|
|
|
+ {
|
|
|
+ "name": "fromName",
|
|
|
+ "title": "客户来源",
|
|
|
+ "width": "25%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "orderAmount",
|
|
|
+ "title": "成交金额",
|
|
|
+ "type": "amount",
|
|
|
+ "width": "35%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "customerQty",
|
|
|
+ "title": "成交客户",
|
|
|
+ "width": "20%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "after": "%",
|
|
|
+ "name": "rate",
|
|
|
+ "title": "占比",
|
|
|
+ "width": "20%"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tab1TopData: [
|
|
|
+ {
|
|
|
+ "title": "成交额(总额:万)",
|
|
|
+ "type": "amount",
|
|
|
+ "value": "98.17"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "成交额(均值:万)",
|
|
|
+ "type": "amount",
|
|
|
+ "value": "32.72"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tab2Columns: [
|
|
|
+ {
|
|
|
+ "name": "fromName",
|
|
|
+ "title": "客户来源",
|
|
|
+ "width": "25%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "orderAmount",
|
|
|
+ "title": "报价金额",
|
|
|
+ "type": "amount",
|
|
|
+ "width": "35%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "customerQty",
|
|
|
+ "title": "报价客户",
|
|
|
+ "width": "20%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "after": "%",
|
|
|
+ "name": "rate",
|
|
|
+ "title": "占比",
|
|
|
+ "width": "20%"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tab2TableData: [
|
|
|
+ {
|
|
|
+ "customerQty": 2,
|
|
|
+ "fromName": "自然客流",
|
|
|
+ "kpiIndex": 1,
|
|
|
+ "orderAmount": "10.55",
|
|
|
+ "rate": 82.26
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "customerQty": 1,
|
|
|
+ "fromName": "自然进店",
|
|
|
+ "kpiIndex": 2,
|
|
|
+ "orderAmount": "2.28",
|
|
|
+ "rate": 17.74
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tab3Columns: [
|
|
|
+ {
|
|
|
+ "name": "fromName",
|
|
|
+ "title": "客户来源",
|
|
|
+ "width": "25%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "csmCount",
|
|
|
+ "title": "潜在客户",
|
|
|
+ "width": "25%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "orderCsmCount",
|
|
|
+ "title": "成交客户",
|
|
|
+ "width": "25%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "designCsmCount",
|
|
|
+ "title": "设计制图",
|
|
|
+ "width": "25%"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tab3TableData: [
|
|
|
+ {
|
|
|
+ "csmCount": 0,
|
|
|
+ "designCsmCount": 1,
|
|
|
+ "fromName": "自然客流",
|
|
|
+ "kpiIndex": 1,
|
|
|
+ "orderCsmCount": 11
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "csmCount": 0,
|
|
|
+ "designCsmCount": 0,
|
|
|
+ "fromName": "自然进店",
|
|
|
+ "kpiIndex": 1,
|
|
|
+ "orderCsmCount": 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "csmCount": 0,
|
|
|
+ "designCsmCount": 0,
|
|
|
+ "fromName": "选用1",
|
|
|
+ "kpiIndex": 1,
|
|
|
+ "orderCsmCount": 1
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tab3TopData: [
|
|
|
+ {
|
|
|
+ "title": "新增潜客",
|
|
|
+ "value": 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "新增成交",
|
|
|
+ "value": 13
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "设计制图",
|
|
|
+ "value": 1
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ value1: 3,
|
|
|
+ tab1TableData: [
|
|
|
+ {
|
|
|
+ "customerQty": 11,
|
|
|
+ "fromName": "自然客流",
|
|
|
+ "kpiIndex": 1,
|
|
|
+ "orderAmount": "67.13",
|
|
|
+ "rate": 68.38
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "customerQty": 1,
|
|
|
+ "fromName": "选用1",
|
|
|
+ "kpiIndex": 2,
|
|
|
+ "orderAmount": "16.48",
|
|
|
+ "rate": 16.79
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "customerQty": 1,
|
|
|
+ "fromName": "自然进店",
|
|
|
+ "kpiIndex": 3,
|
|
|
+ "orderAmount": "14.56",
|
|
|
+ "rate": 14.83
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tab2TopData: [
|
|
|
+ {
|
|
|
+ "title": "报价(总额:万)",
|
|
|
+ "type": "amount",
|
|
|
+ "value": "12.82"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "title": "报价额(均值:万)",
|
|
|
+ "type": "amount",
|
|
|
+ "value": "6.41"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ dateClick(e){
|
|
|
+ if(e.detail === 0){
|
|
|
+ this.selectComponent("#month-components").toggle(true)
|
|
|
+ this.dropdowncommit({currentTarget:{dataset:{type:'month'}}})
|
|
|
+ }else{
|
|
|
+ this.getReportData()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onConfirmChooseDate(e) {
|
|
|
+ this.setData({
|
|
|
+ month: this.data.monthOnChoose,
|
|
|
+ monthName: this.formatDate(this.data.monthOnChoose)
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ monthFlag: false
|
|
|
+ })
|
|
|
+ let option1 = this.data.option1
|
|
|
+ option1[option1.length-1].text = this.data.monthName
|
|
|
+ this.setData({
|
|
|
+ option1: option1
|
|
|
+ })
|
|
|
+ this.selectComponent("#month-components").toggle(false)
|
|
|
+ this.getReportData()
|
|
|
+ },
|
|
|
+ onCloseChooseDate(e) {
|
|
|
+ this.setData({
|
|
|
+ // monthOnChoose: this.data.month
|
|
|
+ value1: 3,
|
|
|
+
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ monthFlag: false
|
|
|
+ })
|
|
|
+ this.selectComponent("#month-components").toggle()
|
|
|
+ this.getReportData()
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad(options) {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /** 查询页面展示的所有 */
|
|
|
+ getReportData() {
|
|
|
+ let params = {
|
|
|
+ tab1: Object.assign(this.getBeginDateAndEndDate(this.data.month), { userId:app.globalData.user.userId,type: 'f_report_s001_csm_from_order', cpId: app.globalData.user.ascpId, orgIds: this.data.orgIds,dateType:this.data.value1 }),
|
|
|
+ tab2: Object.assign(this.getBeginDateAndEndDate(this.data.month), { userId:app.globalData.user.userId,type: 'f_report_s001_csm_from_offer', cpId: app.globalData.user.ascpId, orgIds: this.data.orgIds,dateType:this.data.value1 }),
|
|
|
+ tab3: Object.assign(this.getBeginDateAndEndDate(this.data.month), { userId:app.globalData.user.userId,type: 'f_report_s001_csm_from_filing', cpId: app.globalData.user.ascpId, orgIds: this.data.orgIds,dateType:this.data.value1 }),
|
|
|
+ };
|
|
|
+ api.request(Constants.WX_REPORT + 'select_report_batch', 'POST', params).then(res => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ this.setData({
|
|
|
+ tab1TopData: [{ title: '成交额(总额:万)', type: 'amount', value: util.parseFloatFixed2(res.data.data.tab1.sumAmount/10000) }, { title: '成交额(均值:万)', type: 'amount', value: util.parseFloatFixed2(res.data.data.tab1.avgAmount/10000) }],
|
|
|
+ tab1TableData: util.calc10000(res.data.data.tab1.items,['orderAmount']),
|
|
|
+ tab2TopData: [{ title: '报价(总额:万)',type: 'amount', value: util.parseFloatFixed2(res.data.data.tab2.sumAmount/10000) }, { title: '报价额(均值:万)',type: 'amount', value: util.parseFloatFixed2(res.data.data.tab2.avgAmount/10000) }],
|
|
|
+ tab2TableData: util.calc10000(res.data.data.tab2.items,['orderAmount']),
|
|
|
+ tab3TopData: [{ title: '新增潜客', value: res.data.data.tab3.csmCount }, { title: '新增成交', value: res.data.data.tab3.orderCsmCount }, { title: '设计制图', value: res.data.data.tab3.designCsmCount }],
|
|
|
+ tab3TableData: res.data.data.tab3.items
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.error("获取报表失败", res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 日期组件后的回调
|
|
|
+ * @author : 于继渤
|
|
|
+ * @date : 2022/5/24 12:16
|
|
|
+ */
|
|
|
+ dateCommit(e) {
|
|
|
+ let dateType = e.detail.dateType
|
|
|
+ if (dateType === 'accountdate') {
|
|
|
+ if(e.detail.dateDefault.text === '自定义'){
|
|
|
+ this.setData({
|
|
|
+ value1: 0,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(e.detail.dateDefault.text === '本月'){
|
|
|
+ this.setData({
|
|
|
+ value1: 3,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ let data = e.detail.date
|
|
|
+ console.log(e)
|
|
|
+ this.setData({
|
|
|
+ month: data,
|
|
|
+ createTimeType: e.detail.dateDefault
|
|
|
+ })
|
|
|
+ this.selectComponent('#create-time-type').toggle();
|
|
|
+ }
|
|
|
+ this.getReportData()
|
|
|
+ },
|
|
|
+ //#region 基础内容
|
|
|
+ /** 根据月份查出第一天和最后一天 参数是时间戳*/
|
|
|
+ getBeginDateAndEndDate(timestamp) {
|
|
|
+ let month = this.data.month
|
|
|
+ let monthStart = month[0] ? month[0] : ''
|
|
|
+ let monthEnd = month[1] ? month[1] : ''
|
|
|
+ if (month && month[0] && (month[0].indexOf('/') != -1)) {
|
|
|
+ monthStart = month[0].replaceAll('/', '-')
|
|
|
+ }
|
|
|
+ if (month && month[1] && (month[1].indexOf('/') != -1)) {
|
|
|
+ monthEnd = month[1].replaceAll('/', '-')
|
|
|
+ }
|
|
|
+ return { beginDate: monthStart, endDate: monthEnd }
|
|
|
+ },
|
|
|
+ formatDate(value) {
|
|
|
+ var time = new Date(value);
|
|
|
+ var year = time.getFullYear();
|
|
|
+ var month = time.getMonth() + 1;
|
|
|
+ return year + "年" + month + "月"
|
|
|
+ },
|
|
|
+ onInput(e) {
|
|
|
+ this.setData({
|
|
|
+ monthOnChoose: e.detail
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ dropdowncommit(e) {
|
|
|
+ this.setData({
|
|
|
+ [e.currentTarget.dataset.type + 'Flag']: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 下拉多选关闭 */
|
|
|
+ muticloseAll(e) {
|
|
|
+ this.setData({
|
|
|
+ orgFlag: false
|
|
|
+ })
|
|
|
+ this.selectComponent("#org-components").toggle()
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 下拉多选确定 */
|
|
|
+ mutiSearchAll(e) {
|
|
|
+ this.setData({
|
|
|
+ orgIds: e.detail.idList,
|
|
|
+ orgNames: e.detail.names,
|
|
|
+ orgFlag: false
|
|
|
+ })
|
|
|
+ this.selectComponent("#org-components").toggle(false)
|
|
|
+ this.getReportData()
|
|
|
+ },
|
|
|
+ //#endregion
|
|
|
+})
|