|
|
@@ -0,0 +1,709 @@
|
|
|
+/*******************************************************************************
|
|
|
+ * Copyright(c) 2022 dongke All rights reserved. / Confidential
|
|
|
+ * 类的信息:
|
|
|
+ * 1.程序名称:
|
|
|
+ * 2.功能描述:授权登录
|
|
|
+ * 编辑履历:
|
|
|
+ * 作者 日期 版本 修改内容
|
|
|
+ * 于继渤 2022-04-25 1.00 首页
|
|
|
+ *******************************************************************************/
|
|
|
+import * as echarts from '../../../pages/ec-canvas/echarts.min';
|
|
|
+import { getOpData } from '../echarts-data.js'
|
|
|
+const app = getApp()
|
|
|
+const api = require('../../../utils/api.js');
|
|
|
+const config = require('../../../config/config.js');
|
|
|
+const Constants = require('../../../utils/Constants.js');
|
|
|
+const common = require('../../../utils/common');
|
|
|
+const chooseGoodsCommon = require('../../../utils/chooseGoodsCommon.js');
|
|
|
+const util = require('../../../utils/util.js')
|
|
|
+const mixins = require('@/mixins/index.js')
|
|
|
+
|
|
|
+Page({
|
|
|
+ mixins: [mixins],
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ service: app.globalData['reportService'],
|
|
|
+ // 查询条件
|
|
|
+ searchContent: [{
|
|
|
+ code: 'makeTime',
|
|
|
+ title: mixins.$t('currentMonth'),
|
|
|
+ defaultValue: 3,
|
|
|
+ searchType: Constants.searchType.date
|
|
|
+ }],
|
|
|
+ menuBtnInfo: null,
|
|
|
+
|
|
|
+ skuloading: false,
|
|
|
+
|
|
|
+ statusItem: { text: '张三', value: "0" },
|
|
|
+
|
|
|
+ statusItem1: { text: '佛山居然店', value: "0" },
|
|
|
+
|
|
|
+ //用户信息
|
|
|
+ userInfo: {},
|
|
|
+
|
|
|
+ functionItem: {
|
|
|
+ text: '功能分区'
|
|
|
+ },
|
|
|
+ functionRegion: [{ text: '常用功能', checked: true }, { text: '待办工作', checked: true }],
|
|
|
+ functionRegions: [' ', '待办工作'],
|
|
|
+
|
|
|
+ //功能分类
|
|
|
+ regions: [{
|
|
|
+ FunctionName: ' ',
|
|
|
+ FunctionCodeOrder: '01'
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+
|
|
|
+ functionItems: [],
|
|
|
+ functionItems_two: [],
|
|
|
+ accountTimeType: {
|
|
|
+ text: '本日',
|
|
|
+ value: 3
|
|
|
+ },
|
|
|
+ createTimeType: {
|
|
|
+ text: '本月',
|
|
|
+ value: 3
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ pageInfo: {
|
|
|
+ pageSize: 8,
|
|
|
+ currentPage: 1,
|
|
|
+ lastPage: 0,
|
|
|
+ },
|
|
|
+ promotionList_left: [],
|
|
|
+ promotionList_right: [],
|
|
|
+ windowHeight: 0,
|
|
|
+ choosedGoodsList: [],
|
|
|
+
|
|
|
+ currentDate: new Date().getTime() + 100,
|
|
|
+
|
|
|
+ //报表
|
|
|
+
|
|
|
+ lastDate: { text: '本月', value: 3 },
|
|
|
+ option1: [
|
|
|
+ { text: '本日', value: 1 },
|
|
|
+ { text: '本周', value: 2 },
|
|
|
+ { text: '本月', value: 3 },
|
|
|
+ // { text: '本季', value: 4 },
|
|
|
+ { text: '本年', value: 5 },
|
|
|
+ { text: '自定义', value: 0 },
|
|
|
+
|
|
|
+ ],
|
|
|
+ value1: 3,
|
|
|
+
|
|
|
+ orderAnalysis: {},
|
|
|
+ repayAnalysis: {},
|
|
|
+ csmAnalysisHome: {},
|
|
|
+
|
|
|
+ /** 报表数据 */
|
|
|
+
|
|
|
+ ec: {},
|
|
|
+ monthName: util.formatDayYm(new Date()),
|
|
|
+ monthFlag: false,
|
|
|
+ month: new Date().getTime(),
|
|
|
+ monthOnChoose: new Date().getTime(),
|
|
|
+ orgFlag: false,
|
|
|
+ orgIds: [],
|
|
|
+ orgNames: null,
|
|
|
+ formatter(type, value) {
|
|
|
+ if (type === 'year') {
|
|
|
+ return `${value}年`;
|
|
|
+ }
|
|
|
+ if (type === 'month') {
|
|
|
+ return `${value}月`;
|
|
|
+ }
|
|
|
+ if (type === 'day') {
|
|
|
+ return `${value}日`;
|
|
|
+ }
|
|
|
+ if (type === 'hour') {
|
|
|
+ return `${value}时`;
|
|
|
+ }
|
|
|
+ if (type === 'minute') {
|
|
|
+ return `${value}分`;
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ // 设置
|
|
|
+ onClickSet() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: './home-page-setting'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 去公告页
|
|
|
+ toNotice() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/package2/pages/notice/notice'
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择下拉后查询
|
|
|
+ */
|
|
|
+ dropdowncommit(e) {
|
|
|
+ this.setData({
|
|
|
+ functionRegions: e.detail.dataList
|
|
|
+ })
|
|
|
+ this.selectComponent('#functionItem').toggle();
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 非标商品选择事件
|
|
|
+ * @author : 于继渤
|
|
|
+ * @date : 2022/8/24 13:16
|
|
|
+ */
|
|
|
+ nonGlassSpuItemsTap(e) {
|
|
|
+ chooseGoodsCommon.nonGlassSpuItemsTap(e, this)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+* @desc : 切换sku商品规格
|
|
|
+* @author : 周兴
|
|
|
+* @date : 2022/6/1 10:16
|
|
|
+*/
|
|
|
+ changeSkuSpecs(e) {
|
|
|
+ chooseGoodsCommon.changeSkuSpecsCommon(e, this);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 切换组合促销明细
|
|
|
+ * @date : 2022/7/5 16:49
|
|
|
+ * @author : 周兴
|
|
|
+ */
|
|
|
+ changeCombinedItem(e) {
|
|
|
+ chooseGoodsCommon.changeCombinedItemCommon(e, this)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 销售价格编辑
|
|
|
+ * @author : 常皓宁
|
|
|
+ * @date : 2022/5/31 14:45
|
|
|
+ */
|
|
|
+ changeSalesPriceField(e) {
|
|
|
+ let priceSale = e.detail.value;
|
|
|
+ chooseGoodsCommon.changeSalesPriceCommon(priceSale, this)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 修改销售金额
|
|
|
+ * @author : 周兴
|
|
|
+ * @date : 2022/7/4 14:45
|
|
|
+ */
|
|
|
+ changeItemAmountField(e) {
|
|
|
+ chooseGoodsCommon.changeItemAmountFieldCommon(e, this)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+* @desc : 改变标识
|
|
|
+* @author : 周兴
|
|
|
+* @date : 2022/8/6 17:16
|
|
|
+*/
|
|
|
+ changeAllReadyCheckBox(e) {
|
|
|
+ chooseGoodsCommon.changeAllReadyCheckBoxCommon(e, this)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 修改销售价格
|
|
|
+ * @author : 周兴
|
|
|
+ * @date : 2022/7/6 14:45
|
|
|
+ */
|
|
|
+ changeSalesPrice(priceSale) {
|
|
|
+ chooseGoodsCommon.changeSalesPriceCommon(priceSale, this)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭产品
|
|
|
+ * @param {*} e
|
|
|
+ */
|
|
|
+ closeAddItemInfo() {
|
|
|
+ chooseGoodsCommon.closeAddItemInfoCommon(this)
|
|
|
+ },
|
|
|
+
|
|
|
+ getCode() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ wx.qy.getQrCode({
|
|
|
+ success: function (res) {
|
|
|
+ var qrCode = res.qrCode
|
|
|
+ resolve(qrCode)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ this.setData({
|
|
|
+ menuBtnInfo: wx.getMenuButtonBoundingClientRect()
|
|
|
+ })
|
|
|
+
|
|
|
+ let _this = this;
|
|
|
+ wx.getSystemInfo({
|
|
|
+ success: function (res) {
|
|
|
+ _this.setData({
|
|
|
+ windowHeight: res.windowHeight,
|
|
|
+ windowWidth: res.windowWidth
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (app.globalData.user) {
|
|
|
+ this.setData({
|
|
|
+ userInfo: app.globalData.user,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ wx.setStorageSync('choosedGoodsList', [])
|
|
|
+
|
|
|
+ // 报表查询数据
|
|
|
+ this.getSaleProfit()
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+ //调用刷新时将执行的方法
|
|
|
+ this.onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefresh() {
|
|
|
+ //在当前页面显示导航条加载动画
|
|
|
+ wx.showNavigationBarLoading()
|
|
|
+ //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
|
|
|
+ //报表查询数据
|
|
|
+ this.getSaleProfit()
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 打开商品
|
|
|
+ * @author : 周兴
|
|
|
+ * @date : 2022/7/2 20:16
|
|
|
+ */
|
|
|
+ openAddItemInfo(e) {
|
|
|
+ // chooseGoodsCommon.openAddItemInfoCommon(e,this,'home-page')
|
|
|
+ this.setData({
|
|
|
+ goodsSkuList: []
|
|
|
+ })
|
|
|
+
|
|
|
+ let item = e.currentTarget.dataset.item
|
|
|
+ //促销类型
|
|
|
+ let promotionType = e.currentTarget.dataset.promotiontype
|
|
|
+ //促销类型
|
|
|
+ item.promotionTypeName = e.currentTarget.dataset.promotiontype == 2 ? '组合促销' : '单品促销'
|
|
|
+ item.itemQuantity = 1
|
|
|
+
|
|
|
+ item.activityId = e.currentTarget.dataset.item.activityId
|
|
|
+ item.warehouseId = app.globalData.user.whId
|
|
|
+ item.whId = app.globalData.user.whId
|
|
|
+ item.warehouseName = app.globalData.user.whName
|
|
|
+ item.wh_Name = app.globalData.user.whName
|
|
|
+ // if (item.activityIds && item.activityIds.length > 0) {
|
|
|
+ // item.activityId = item.activityIds[0] ? item.activityIds[0] : null
|
|
|
+ // }
|
|
|
+ item.activityName = item.activityNames
|
|
|
+ item.orderItemQuantity = item.itemQuantity
|
|
|
+
|
|
|
+ item.pricePromotionName = item.priceName
|
|
|
+ item.promotionId = item.priceId
|
|
|
+ delete item['apvResult']
|
|
|
+ delete item['apvResultName']
|
|
|
+ delete item['apvUserIds']
|
|
|
+ // delete item['combinedTypeList']
|
|
|
+ delete item['flgValid']
|
|
|
+
|
|
|
+ // 组合促销
|
|
|
+ if (promotionType == "2") {
|
|
|
+
|
|
|
+ //促销价
|
|
|
+ item.pricePromotion = e.currentTarget.dataset.item.pricePromotion ? e.currentTarget.dataset.item.pricePromotion : e.currentTarget.dataset.item.sumPrice
|
|
|
+ item.priceSale = item.pricePromotion
|
|
|
+ item.promotionType = Constants.PROMOTION_TYPE.COMBINED
|
|
|
+ if (item.imageInfo.length > 0) {
|
|
|
+ item.iconThumPath = item.imageInfo[0].path
|
|
|
+ }
|
|
|
+ delete item['imageInfo']
|
|
|
+
|
|
|
+ chooseGoodsCommon.getCombinedByPriceId(e, this);
|
|
|
+ this.setData({
|
|
|
+ show1: false,
|
|
|
+ show2: false,
|
|
|
+ show3: false,
|
|
|
+ show4: true,
|
|
|
+ show5: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // item.titleTag = '单品促销'
|
|
|
+ // item.title = item.skuModel
|
|
|
+ // item.desc = item.skuName
|
|
|
+ item.promotionType = Constants.PROMOTION_TYPE.PRMOTION
|
|
|
+ item.itemAmount = item.sumPrice
|
|
|
+
|
|
|
+ item.pricePromotion = e.currentTarget.dataset.item.pricePromotion ?
|
|
|
+ e.currentTarget.dataset.item.pricePromotion : item.sumPrice
|
|
|
+ item.priceSale = item.sumPrice
|
|
|
+ // 根据spuId获取sku相关信息
|
|
|
+ chooseGoodsCommon.getSkuBySpuId(e, this);
|
|
|
+ this.setData({
|
|
|
+ show1: true,
|
|
|
+ show2: false,
|
|
|
+ show3: false,
|
|
|
+ show4: false,
|
|
|
+ show5: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ currentChoosedItem: item,
|
|
|
+ showAdd: true,
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 选择数据
|
|
|
+ * @date : 2022/7/4 16:49
|
|
|
+ * @author : 周兴
|
|
|
+ */
|
|
|
+ chooseSkuInfo() {
|
|
|
+ let currentChoosedItem = this.data.currentChoosedItem
|
|
|
+ currentChoosedItem.goodsSkuList = this.data.goodsSkuList
|
|
|
+ //校验选择商品数量不能为0
|
|
|
+ if (currentChoosedItem.itemQuantity === 0 || !currentChoosedItem.itemQuantity) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '数量不能为0',
|
|
|
+ image: '/static/image/warning.png',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //校验除赠品标识外价格不能为0
|
|
|
+ else if (!currentChoosedItem.flgGift && currentChoosedItem.priceSale == 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '销售价格未填写',
|
|
|
+ image: '/static/image/warning.png',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 如果是组合需要判断bom中子件是否有标价
|
|
|
+ else if (currentChoosedItem.combinedList && currentChoosedItem.combinedList.length > 0) {
|
|
|
+ // currentChoosedItem.combinedList.forEach(it => {
|
|
|
+ // if (!it.priceStandard && it.priceStandard != 0) {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '商品标价未设置',
|
|
|
+ // image: '/static/image/warning.png',
|
|
|
+ // duration: 1000
|
|
|
+ // })
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ // 如果标价为0 不允许加入购物车
|
|
|
+ else if (!currentChoosedItem.priceStandard && currentChoosedItem.priceStandard != 0) {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '商品标价未设置',
|
|
|
+ // image: '/static/image/warning.png',
|
|
|
+ // duration: 1000
|
|
|
+ // })
|
|
|
+ // return;
|
|
|
+ }
|
|
|
+ // 如果没有sku 那么不允许
|
|
|
+ if (currentChoosedItem.promotionType != Constants.PROMOTION_TYPE.COMBINED && (!currentChoosedItem.skuId || currentChoosedItem.skuId == 0)) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '未选择商品规格',
|
|
|
+ image: '/static/image/warning.png',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 已选商品列表
|
|
|
+ let choosedGoodsList = this.data.choosedGoodsList
|
|
|
+
|
|
|
+
|
|
|
+ // 判断商品是否在已选列表中存在
|
|
|
+ let filterRows = choosedGoodsList.filter(it => it.id == currentChoosedItem.id);
|
|
|
+ let currentChoosedItemTemp = { ...currentChoosedItem }
|
|
|
+ if (!filterRows || filterRows.length == 0) {
|
|
|
+ if (!this.data.showChoosedFlag) {
|
|
|
+ choosedGoodsList.push(currentChoosedItemTemp)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ choosedGoodsList: choosedGoodsList,
|
|
|
+ showAdd: false
|
|
|
+ })
|
|
|
+
|
|
|
+ choosedGoodsList.forEach(res => {
|
|
|
+ res.id = util.getGuid()
|
|
|
+ })
|
|
|
+
|
|
|
+ let choosedGoodsListSync = wx.getStorageSync('choosedGoodsList')
|
|
|
+ if (choosedGoodsListSync.length > 0) {
|
|
|
+ let filterRows = choosedGoodsListSync.filter(it => it.priceId + '_' + it.spuId
|
|
|
+ == currentChoosedItem.priceId + '_' + currentChoosedItem.spuId);
|
|
|
+ if (!filterRows || filterRows.length == 0) {
|
|
|
+ choosedGoodsListSync.push(currentChoosedItem)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ choosedGoodsListSync.push(currentChoosedItem)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ wx.setStorageSync('choosedGoodsList', choosedGoodsListSync)
|
|
|
+ wx.setStorageSync('homeData', {
|
|
|
+ skuData: this.data.skuData ? this.data.skuData : [],
|
|
|
+ skuSpecsData: this.data.skuSpecsData ? this.data.skuSpecsData : [],
|
|
|
+ skuSpecsList: this.data.skuSpecsList ? this.data.skuSpecsList : [],
|
|
|
+ })
|
|
|
+
|
|
|
+ let cartNum = choosedGoodsListSync.length //默认数据
|
|
|
+ if (cartNum != 0) {
|
|
|
+ //设置角标
|
|
|
+ wx.setTabBarBadge({
|
|
|
+ index: 2, //第几个tab
|
|
|
+ text: cartNum.toString()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ //移除角标
|
|
|
+ wx.removeTabBarBadge({
|
|
|
+ index: 2,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算合计金额
|
|
|
+ chooseGoodsCommon.getSumAmount(this);
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数量的变化事件
|
|
|
+ * @param {*} e
|
|
|
+ */
|
|
|
+ changeAllreadyChooseQuantityPop(e) {
|
|
|
+ let currentChoosedItem = this.data.currentChoosedItem
|
|
|
+ currentChoosedItem.itemQuantity = e.detail
|
|
|
+ currentChoosedItem.itemAmount = Number(currentChoosedItem.priceSale * currentChoosedItem.itemQuantity).toFixed(2)
|
|
|
+ currentChoosedItem.itemAmount = isNaN(currentChoosedItem.itemAmount) ? 0 : currentChoosedItem.itemAmount
|
|
|
+ this.setData({
|
|
|
+ currentChoosedItem: currentChoosedItem
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ //触底分页函数
|
|
|
+ paging() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 页面滚动时执行
|
|
|
+ * @date : 2022/5/12 16:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ onPageScroll: function () {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 关闭下拉
|
|
|
+ * @date : 2022/5/12 16:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ //TODO 有ID同名问题记得修改
|
|
|
+ // this.selectComponent('#statusItem').onClosed()
|
|
|
+ // this.selectComponent('#statusItem').rerender()
|
|
|
+
|
|
|
+ // this.selectComponent('#statusItem1').onClosed()
|
|
|
+ // this.selectComponent('#statusItem1').rerender()
|
|
|
+
|
|
|
+ // this.selectComponent('#accountTimeType').onClosed()
|
|
|
+ // this.selectComponent('#accountTimeType').rerender()
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ // 报表相关
|
|
|
+ dateClick(e) {
|
|
|
+ if (e.detail === 0) {
|
|
|
+ this.selectComponent("#month-components").toggle(true)
|
|
|
+ this.dropdowncommit({ currentTarget: { dataset: { type: 'month' } } })
|
|
|
+ } else {
|
|
|
+ this.getSaleProfit()
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /** 去详细 */
|
|
|
+ toDetail(e) {
|
|
|
+ console.log(e, '/package-business-analysis/pages/profit-report/' + e.currentTarget.dataset.url)
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/package-business-analysis/pages/profit-report/' + e.currentTarget.dataset.url
|
|
|
+ // + '?orgIds=' + encodeURIComponent(JSON.stringify(this.data.orgIds)) + '&orgNames=' + encodeURIComponent(JSON.stringify(this.data.orgNames))
|
|
|
+ // + '&dateType=' + this.data.value1 + '&date=' + this.data.month
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ 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.getSaleProfit()
|
|
|
+ },
|
|
|
+
|
|
|
+ onCloseChooseDate(e) {
|
|
|
+ this.setData({
|
|
|
+ // monthOnChoose: this.data.month
|
|
|
+ value1: 3,
|
|
|
+
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ monthFlag: false
|
|
|
+ })
|
|
|
+ this.selectComponent("#month-components").toggle()
|
|
|
+ this.getSaleProfit()
|
|
|
+ },
|
|
|
+
|
|
|
+ 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.getSaleProfit()
|
|
|
+ },
|
|
|
+
|
|
|
+ onShow() {
|
|
|
+ this.echartsProfitDate = this.selectComponent("#echartsProfitDate")
|
|
|
+ this.echartsProfitStaff = this.selectComponent("#echartsProfitStaff")
|
|
|
+ this.echartsProfitOrg = this.selectComponent("#echartsProfitOrg")
|
|
|
+ this.echartsProfitSku = this.selectComponent("#echartsProfitSku")
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 设置echarts */
|
|
|
+ setEcharts(name, { data, labelKey, valueKey, type }) {
|
|
|
+ this[name].init((canvas, width, height, dpr) => {
|
|
|
+ const chart = echarts.init(canvas, null, {
|
|
|
+ width: width,
|
|
|
+ height: height,
|
|
|
+ devicePixelRatio: dpr
|
|
|
+ });
|
|
|
+ canvas.setChart(chart);
|
|
|
+ chart.setOption(getOpData(data, labelKey, valueKey, type));
|
|
|
+ return chart;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 根据月份查出第一天和最后一天 参数是时间戳*/
|
|
|
+ getBeginDateAndEndDate(timestamp) {
|
|
|
+ // let date = new Date(timestamp)
|
|
|
+ // let year = date.getFullYear();
|
|
|
+ // let month = date.getMonth() + 1;
|
|
|
+ // let yearAndMonth = year + '-' + (month >= 10 ? month : '0' + month);
|
|
|
+ // return { beginDate: yearAndMonth + '-01', endDate: yearAndMonth + '-' + new Date(year, month, 0).getDate() }
|
|
|
+ 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 }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 销售毛利点击按日或按月查询
|
|
|
+ */
|
|
|
+ clickProfitDate(e) {
|
|
|
+ this.setData({
|
|
|
+ byDate: e.currentTarget.dataset.value
|
|
|
+ })
|
|
|
+ this.getSaleProfit()
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 查询所有报表信息 */
|
|
|
+ /** 查询页面展示的所有 */
|
|
|
+ getSaleProfit() {
|
|
|
+ this.excute(this.data.service, this.data.service.getSaleProfit, Object.assign({
|
|
|
+ byDate: this.data.byDate
|
|
|
+ }, JSON.parse(this.data.searchForm))).then(res => {
|
|
|
+ if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
+ this.setData({
|
|
|
+ profit: res.data.data.profit,
|
|
|
+ })
|
|
|
+
|
|
|
+ /** 图形重新渲染 */
|
|
|
+ setTimeout(() => {
|
|
|
+ this.setEcharts('echartsProfitDate', { data: res.data.data.dateProfit, labelKey: 'accDate', valueKey: 'profit', type: 1 })
|
|
|
+ this.setEcharts('echartsProfitOrg', { data: res.data.data.orgProfit, labelKey: 'orgName', valueKey: 'profit', type: 3 })
|
|
|
+ this.setEcharts('echartsProfitStaff', { data: res.data.data.staffProfit, labelKey: 'staffName', valueKey: 'profit', type: 3 })
|
|
|
+ this.setEcharts('echartsProfitSku', { data: res.data.data.skuProfit, labelKey: 'skuName', valueKey: 'profit', type: 3 })
|
|
|
+ }, 1000)
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示tip
|
|
|
+ */
|
|
|
+ showTip(e) {
|
|
|
+ console.log(e)
|
|
|
+ let item = e.currentTarget.dataset.item
|
|
|
+ if (item) {
|
|
|
+ util.showToast(item);
|
|
|
+ }
|
|
|
+ },
|
|
|
+})
|
|
|
+
|