lilei 2 năm trước cách đây
mục cha
commit
be62f1c8f0
6 tập tin đã thay đổi với 233 bổ sung47 xóa
  1. 1 1
      App.vue
  2. 9 0
      api/sales.js
  3. 1 1
      config/index.js
  4. 139 0
      libs/getDate.js
  5. 13 13
      pages/statistics/chooseShelf.vue
  6. 70 32
      pages/statistics/index.vue

+ 1 - 1
App.vue

@@ -7,7 +7,7 @@
 			token: '',
 			changeOrg:'',
 			version: '', // 当前版本号
-			buildType: 'uat', // 打包环境对应类型,pro 生产 uat 预发布 dev 本地开发
+			buildType: 'dev', // 打包环境对应类型,pro 生产 uat 预发布 dev 本地开发
 			envTips: '', // 环境文字提示
 			theme: 'default', // 主题,default
 			isIphoneXup: false //是否iphonex以及以上的版本

+ 9 - 0
api/sales.js

@@ -174,4 +174,13 @@ export const salesRecordlList = (params) => {
     data: params,
     method: 'post'
   })
+}
+
+// 销售统计
+export const salesStatistics = (params) => {
+  return axios.request({
+    url: 'sales/appStatistics',
+    data: params,
+    method: 'post'
+  })
 }

+ 1 - 1
config/index.js

@@ -6,7 +6,7 @@ const getConfig = (theme) => {
 			themePath: 'default',
 			pro_URL: 'https://iscm.360arrow.com/qpls-md/', // 生产地址
 			uat_URL: 'http://p.iscm.360arrow.com/qpls-md/', // 预发布地址
-			dev_URL: 'http://192.168.0.103:8503/qpls-md/', // 本地地址
+			dev_URL: 'http://192.168.0.182:8503/qpls-md/', // 本地地址
 			appName: 'iSCM智慧供应链', // app 名称
 			company: '陕西山海高科信息技术有限公司',
 			loadText:{

+ 139 - 0
libs/getDate.js

@@ -0,0 +1,139 @@
+// 引入 moment 时间插件
+import moment from 'moment'
+moment.updateLocale('en', { week: {
+  dow: 1, // 星期的第一天是星期一
+  doy: 7 // 年份的第一周必须包含1月1日 (7 + 1 - 1)
+} })
+// 获取今日/昨日/本周/上周/本月/上月 时间
+export default {
+  // 获取今日的开始结束时间
+  getToday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().startOf('day').valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取今日的开始结束时间  年月日时分秒
+  getTodayTime () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().startOf('day').valueOf()).format('YYYY-MM-DD HH:mm:ss')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD HH:mm:ss')
+    return obj
+  },
+  //  近7天
+  getRecentday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment().subtract('days', 6).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  //  近7天  年月日时分秒
+  getRecentTime () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment().subtract('days', 6).format('YYYY-MM-DD HH:mm:ss')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD HH:mm:ss')
+    return obj
+  },
+  //  近3天
+  getThreeday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment().subtract('days', 2).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取昨日的开始结束时间
+  getYesterday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().add(-1, 'days').startOf('day').valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().add(-1, 'days').endOf('day').valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取当前周的开始到当天结束时间
+  getCurrWeekDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().week(moment().week()).startOf('week').add('days').valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取上一周的开始结束时间
+  getLastWeekDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().week(moment().week() - 1).startOf('week').add('days').valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().week(moment().week() - 1).endOf('week').add('days').valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取上一月的今天到当月的今天
+  getCurrMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month() - 1).valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取当前月的开始到当天结束时间
+  getCurrLastMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month()).startOf('month').valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取上一个月的开始结束时间
+  getLastMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month() - 1).startOf('month').valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().month(moment().month() - 1).endOf('month').valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取三月前的今天到当月的今天
+  getThreeMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month() - 3).valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().month(moment().month() - 3).endOf('month').valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  },
+  // 获取近三个月的开始结束时间
+  getThreeMonthCurrDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month() - 2).startOf('month').valueOf()).format('YYYY-MM-DD 00:00:00')
+    obj.endtime = moment(moment().month(moment().month() - 2).endOf('month').valueOf()).format('YYYY-MM-DD 23:59:59')
+    return obj
+  }
+}

+ 13 - 13
pages/statistics/chooseShelf.vue

@@ -2,8 +2,8 @@
 	<view class="moreShelfPart flex flex_column">
 		<view class="moreShelfPart-search">
 			<u-search
-			placeholder="请输入货架名称搜索" 
-			v-model="shelfName" 
+			placeholder="请输入客户名称搜索" 
+			v-model="customerName" 
 			:show-action="isGobleSearch" 
 			@input="change"
 			@focus="isGobleSearch=true"
@@ -22,10 +22,10 @@
 				<view class="nav-right-item" v-for="(item, index) in shelfList" :key="item.id" @click="viewDetail(item)">
 					<view class="item-info uni-col-10">
 						<view class="item-name">
-							<text>{{item.shelfName}}</text>
+							<text>{{item.customerName}}</text>
 						</view>
 					</view>
-					<view class="arrow" v-if="item.shelfSn == checkedSn">
+					<view class="arrow" v-if="item.customerSn == checkedSn">
 						<u-icon name="checkbox-mark" color="#3dc50b" size="28"></u-icon>
 					</view>
 				</view>
@@ -41,11 +41,11 @@
 </template>
 
 <script>
-	import { getShelfList } from '@/api/shelf'
+	import { customerList } from '@/api/customer.js'
 	export default {
 		data() {
 			return {
-				shelfName: '',
+				customerName: '',
 				isGobleSearch: false,
 				shelfList: [],
 				pageNo:1,
@@ -58,12 +58,12 @@
 			}
 		},
 		onLoad(opts) {
-			this.checkedSn = opts.shelfSn
+			this.checkedSn = opts.customerSn
 			this.getShelfList()
 		},
 		methods: {
 			clearSearch(){
-				this.shelfName = ''
+				this.customerName = ''
 				this.search()
 			},
 			change(v){
@@ -82,10 +82,10 @@
 				let params = {
 				    pageNo: this.pageNo,
 				    pageSize: this.pageSize,
-					shelfName: this.shelfName
+					customerName: this.customerName
 				}
 				_this.status = 'loading'
-				getShelfList(params).then(res => {
+				customerList(params).then(res => {
 					uni.hideLoading()
 					if(res.status == 200){
 						let list = res.data.list
@@ -96,8 +96,8 @@
 							}else{
 								_this.shelfList = res.data.list || []
 								_this.shelfList.unshift({
-									shelfSn: '',
-									shelfName: '全部客户'
+									customerSn: '',
+									customerName: '全部客户'
 								})
 							}
 							_this.total = res.data.count
@@ -123,7 +123,7 @@
 			// 加载更多
 			onreachBottom () {
 				if(this.shelfList.length < this.total ){
-					if(this.isGobleSearch&&this.shelfName==''){
+					if(this.isGobleSearch&&this.customerName==''){
 						return
 					}
 					this.pageNo++

+ 70 - 32
pages/statistics/index.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="content flex flex_column">
 		<div class="p-header" @click="openShlef">
-			<text>{{curShelfName||'全部客户'}}</text>
+			<text>{{curCustomerName||'全部客户'}}</text>
 			<u-icon name="arrow-right"></u-icon>
 		</div>
 		<div class="e-chart">
@@ -13,13 +13,13 @@
 					<div class="data-box flex">
 						<div>
 							<div class="data-amount">
-								60
+								{{allData&&allData.salesTotalQty||0}}
 							</div>
 							<div class="data-label">销售产品数量(个)</div>
 						</div>
 						<div>
 							<div class="data-amount">
-								<u-count-to :end-val="1235.65" separator="," :decimals="2"></u-count-to>
+								<u-count-to :end-val="allData&&allData.salesTotalAmount||0" separator="," :decimals="2"></u-count-to>
 							</div>
 							<div class="data-label">销售金额(元)</div>
 						</div>
@@ -30,7 +30,7 @@
 					    />
 				</div>
 			</div>
-			<div class="card-box">
+			<div class="card-box" v-if="allData&&allData.xprhFlag">
 				<div class="card-tits">
 					货架订单
 				</div>
@@ -38,24 +38,24 @@
 					<div class="data-box flex">
 						<div>
 							<div class="data-amount">
-								60
+								{{allData&&allData.orderTotalQty||0}}
 							</div>
 							<div class="data-label">取货产品数量(个)</div>
 						</div>
 						<div>
 							<div class="data-amount">
-								<u-count-to :end-val="1235.65" separator="," :decimals="2"></u-count-to>
+								<u-count-to :end-val="allData&&allData.orderTotalAmount||0" separator="," :decimals="2"></u-count-to>
 							</div>
 							<div class="data-label">取货产品金额(元)</div>
 						</div>
 					</div>
 					<qiun-data-charts 
 					      type="line"
-					      :chartData="chartData"
+					      :chartData="chartData1"
 					    />
 				</div>
 			</div>
-			<div class="card-box">
+			<div class="card-box" v-if="allData&&allData.xprhFlag">
 				<div class="card-tits">
 					急送订单
 				</div>
@@ -63,20 +63,20 @@
 					<div class="data-box flex">
 						<div>
 							<div class="data-amount">
-								60
+								{{allData&&allData.tempTotalQty||0}}
 							</div>
 							<div class="data-label">急送产品数量(个)</div>
 						</div>
 						<div>
 							<div class="data-amount">
-								<u-count-to :end-val="1235.65" separator="," :decimals="2"></u-count-to>
+								<u-count-to :end-val="allData&&allData.tempTotalAmount||0" separator="," :decimals="2"></u-count-to>
 							</div>
 							<div class="data-label">急送产品金额(元)</div>
 						</div>
 					</div>
 					<qiun-data-charts 
 					      type="line"
-					      :chartData="chartData"
+					      :chartData="chartData2"
 					    />
 				</div>
 			</div>
@@ -106,13 +106,18 @@
 
 <script>
 	import chooseShelf from './chooseShelf.vue'
+	import { salesStatistics } from '@/api/sales.js'
+	import getDate from '@/libs/getDate.js'
 	export default {
 		components: { chooseShelf },
 		data() {
 			return {
-				shelfSn: '',
-				curShelfName: '',
+				customerSn: '',
+				curCustomerName: '',
 				chartData: {},
+				chartData1: {},
+				chartData2: {},
+				allData: null,
 				showSearch: false,
 				showDate: false,
 				dateArray: '',
@@ -123,7 +128,8 @@
 				},
 				queryPramas:{
 					beginDate: '',
-					endDate: ''
+					endDate: '',
+					buyerSn: ''
 				},
 				placeTab: [
 					{
@@ -156,20 +162,23 @@
 						val: '6'
 					}
 				],
-				curTab: '',
+				curTab: '4',
 				webView: null
 			}
 		},
 		onLoad() {
 			uni.$on('chooseShelfOk',(data)=>{
-				this.shelfSn = data.shelfSn
-				this.curShelfName = data.shelfName
+				this.customerSn = data.customerSn
+				this.curCustomerName = data.customerName
+				this.queryPramas.buyerSn = data.customerSn
 			})
-			this.getServerData()
 			this.webView = this.$mp.page.$getAppWebview(); 
 			// 默认数据
 			this.tabChange(this.placeTab[2])
 		},
+		onShow() {
+			this.getServerData()
+		},
 		onUnload() {
 			uni.$off("chooseShelfOk")
 		},
@@ -186,8 +195,8 @@
 			// 时间  change
 			dateChange(date){
 				this.dateArray = date.startDate + ' ~ ' + date.endDate
-				this.queryPramas.beginDate = date.startDate
-				this.queryPramas.endDate = date.endDate
+				this.queryPramas.beginDate = date.startDate + ' 00:00:00'
+				this.queryPramas.endDate = date.endDate + ' 23:59:59'
 				this.webView.setTitleNViewButtonStyle(0, {
 					"text":"\ue626 "+date.startDate+"~"+date.endDate,
 					"color": "#00aaff",
@@ -212,6 +221,7 @@
 				this.tabChange(this.placeTab[2])
 				this.showSearch = false
 			},
+			// 查询
 			handleSearch(){
 				if(this.curTab == 6){
 					if(this.queryPramas.beginDate&&this.queryPramas.endDate){
@@ -228,28 +238,56 @@
 					this.showSearch = false
 				}
 			},
-			getServerData() {
-			  //模拟从服务器获取数据时的延时
-			  setTimeout(() => {
-				//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
-				let res = {
-					categories: ["8-7","8-6","8-9","8-10","8-11","8-12"],
+			// 格式化折线图数据
+			getFormatData(categories,data,name){
+				if(data){
+					data.map(item => Number(item))
+				}
+				return {
+					categories: categories,
 					series: [
 					  {
-						name: "销售金额",
-						data: [35,8,25,37,4,20],
+						name: name,
+						data: data||[],
 						label:{
 							position: 'top'
 						}
 					  },
 					]
-				  };
-				this.chartData = JSON.parse(JSON.stringify(res));
-			  }, 500);
+			  }
+			},
+			getQueryDate(){
+				const fun = [
+					getDate.getToday,
+					getDate.getYesterday,
+					getDate.getCurrWeekDays,
+					getDate.getLastWeekDays,
+					getDate.getCurrLastMonthDays,
+					getDate.getCurrMonthDays
+					];
+				return {
+					beginDate: fun[this.curTab]().starttime,
+					endDate: fun[this.curTab]().endtime
+				}
+			},
+			getServerData() {
+			  let params = {}
+			  // 不是自定义时间段
+			  if(this.curTab != 6){
+				  params = this.getQueryDate()
+			  }
+			  salesStatistics(Object.assign(this.queryPramas,params)).then(res => {
+				  if(res.status == 200){
+					  this.allData = res.data
+					  this.chartData = this.getFormatData(res.data.salesDateList,res.data.salesAmountList,"销售金额")
+					  this.chartData1 = this.getFormatData(res.data.orderDateList,res.data.orderAmountList,"取货产品金额")
+					  this.chartData2 = this.getFormatData(res.data.tempDateList,res.data.tempAmountList,"急送产品金额")
+				  }
+			  })
 			},
 			openShlef(){
 				uni.navigateTo({
-					url: "/pages/statistics/chooseShelf?shelfSn="+this.shelfSn
+					url: "/pages/statistics/chooseShelf?customerSn="+this.customerSn
 				})
 			}
 		}