Browse Source

查询销售记录

lilei 3 năm trước cách đây
mục cha
commit
cae27d6bc7
5 tập tin đã thay đổi với 261 bổ sung11 xóa
  1. 11 0
      api/sales.js
  2. 9 0
      pages.json
  3. 19 9
      pages/sales/chooseCustomer.vue
  4. 8 2
      pages/sales/productPricing.vue
  5. 214 0
      pages/sales/salesRecord.vue

+ 11 - 0
api/sales.js

@@ -164,3 +164,14 @@ export const settleStyleQueryAll = (params) => {
   })
 }
 
+// 销售记录
+export const salesRecordlList = (params) => {
+  const url = `salesDetail/querySalesRecord/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}

+ 9 - 0
pages.json

@@ -304,6 +304,15 @@
 		        "enablePullDownRefresh": false
 		    }
 		}
+        ,{
+            "path" : "pages/sales/salesRecord",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "销售记录",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

+ 19 - 9
pages/sales/chooseCustomer.vue

@@ -3,7 +3,7 @@
 		<view class="search">
 			<view class="flex justify_between align_center search-title">
 				<text class="search-label">客户名称</text>
-				<view class="search-btn">
+				<view class="search-btn" v-if="backPage == 'addSales'">
 					<text>没有搜索到?</text>
 					<text>点击</text>
 					<text @click="addCustomer">新增客户</text>
@@ -22,7 +22,7 @@
 		</view>
 		<scroll-view class="picker-content flex_1" scroll-y >
 			<view class="picker-main">
-				<view class="picker-main-item" v-for="(item, index) in listData" :key="item.id" @click="chooseItem(index)">
+				<view class="picker-main-item" v-for="(item, index) in listData" :key="item.id" @click="chooseItem(item)">
 					<view class="item-name">{{item.customerName}}</view>
 				</view>
 				<view v-if="listData&&listData.length>=20" style="color:#999;font-size: 26upx;text-align: center;padding: 10upx;">最多显示前20条匹配客户,请尝试输入更多内容</view>
@@ -44,10 +44,12 @@
 				pageSize:20,
 				pageNo:1,
 				scrollH:300,
+				backPage:''
 			}
 		},
-		onLoad() {
+		onLoad(opts) {
 			uni.$on('clear',this.clearSearch)
+			this.backPage = opts.backPage
 		},
 		onShow() {
 			this.init()
@@ -91,12 +93,20 @@
 				this.queryWord = ''
 				this.listData = []
 			},
-			chooseItem(val){
-				console.log(val)
-				this.queryWord=this.listData[val].customerName
-				uni.navigateTo({
-					url:'/pages/sales/addSales?pageType=edit&nowId='+this.listData[val].id
-				})
+			chooseItem(item){
+				console.log(item)
+				this.queryWord=item.customerName
+				// 新增销售单
+				if(this.backPage == 'addSales'){
+					uni.navigateTo({
+						url:'/pages/sales/addSales?pageType=edit&nowId='+item.id
+					})
+				}
+				// 销售记录
+				if(this.backPage == 'salesRecord'){
+					uni.$emit("searchSalesRecord",item)
+					uni.navigateBack()
+				}
 			}
 		},
 	}

+ 8 - 2
pages/sales/productPricing.vue

@@ -26,8 +26,8 @@
 							<view class="padding_3">原厂编码:{{(item.origCode&&item.origCode!=' ')?item.origCode:'--'}} </view>
 							<view class="padding_3">品牌:{{item.productBrandName || '--'}} </view>
 							<view class="flex align_center justify_between">
-								<view class="font_13">
-									库存数:<text>{{toThousands(item.stockQty|| 0)}}</text>
+								<view class="font_13" @click="toViewDetail(item)">
+									库存数:<text style="text-decoration: underline;color: dodgerblue;">{{toThousands(item.stockQty|| 0)}}</text>
 								</view>
 								<view class="font_13">
 									车主价:<text class="red">¥{{toThousands(item.carOwnersPrice|| 0,2)}} </text>
@@ -150,6 +150,12 @@
 					this.getList()
 				}
 			},
+			// 查看销售记录
+			toViewDetail(row){
+				uni.navigateTo({
+					url: "/pages/sales/salesRecord?productSn="+row.productSn + "&productName="+row.name+ "&productCode="+row.code
+				})
+			}
 		}
 	}
 </script>

+ 214 - 0
pages/sales/salesRecord.vue

@@ -0,0 +1,214 @@
+<template>
+	<view class="salesRecord-box flex flex_column">
+		<view class="sales-productInfo" v-if="baseData">
+			<view>产品名称:{{ baseData.productName }}</view>
+			<view>产品编码:{{ baseData.productCode }}</view>
+		</view>
+		<view class="product-list">
+			<view class="search-box">
+				<u-cell-group>
+					<u-cell-item value="去选择" @click="toChooseCust">
+						<view slot="title">
+							选择客户:
+							<u-tag v-if="buyerName" :text="buyerName" closeable :show="show" @close="tagClick" shape="circle" />
+							<u-tag v-else :text="'全部'" shape="circle" />
+						</view>
+					</u-cell-item>
+				</u-cell-group>
+			</view>
+			<scroll-view class="sales-list-con" :style="{height: scrollH+'upx'}" scroll-y @scrolltolower="onreachBottom">
+				<view class="sales-list-main">
+					<view class="sales-list-item" v-for="(item, index) in listData" :key="item.id">
+						<view class="list-item-tit flex align_center">
+							<view class="u-line" :style="{background: $config('primaryColor')}"></view>
+							<view class="buyer">{{item.salesBillEntity.buyerName}}</view>
+						</view>
+						<view class="list-item-con">
+							<view class="list-item-line flex align_center justify_between">
+								<view>销售时间:<text>{{item.salesBillEntity.createDate}}</text></view>
+							</view>
+							<view class="list-item-line flex align_center justify_between">
+								<view>销售数量:<text>{{toThousands(item.qty||0)}}</text></view>
+								<view>销售价:<text>¥{{toThousands(item.price||0, 2)}}</text></view>
+							</view>
+						</view>
+					</view>
+					<view v-if="listData && listData.length == 0 && status!='loading'">
+						<u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="150"></u-empty>
+					</view>
+					<view style="padding: 60upx;">
+						<u-loadmore v-if="totalNum>listData.length || status=='loading'" :status="status" />
+					</view>
+				</view>
+			</scroll-view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import {salesRecordlList} from "@/api/sales.js"
+	import { toThousands } from '@/libs/tools'
+	export default {
+		data() {
+			return {
+				listData: [],
+				pageNo: 1,
+				pageSize: 10,
+				totalNum: 0,
+				status: 'loadmore',
+				noDataText: '暂无销售记录',
+				scrollH: 300,
+				queryparams: {
+					buyerSn: undefined,
+					productSn: undefined
+				},
+				buyerName: '',
+				baseData: null,
+				show:false
+			}
+		},
+		onLoad(opts) {
+			this.queryparams.productSn = opts ? opts.productSn : undefined
+			this.baseData ={productName:opts.productName,productCode:opts.productCode}
+			uni.$on("searchSalesRecord",(data)=>{
+				this.queryparams.buyerSn = data.customerSn
+				this.buyerName = data.customerName
+				this.show = true
+				this.getList(1)
+			})
+		},
+		onUnload() {
+			uni.$off("searchSalesRecord")
+		},
+		onReady() {
+			const sys = uni.getSystemInfoSync()
+			if(sys.platform == 'android'){
+				this.scrollH = (sys.windowHeight - sys.statusBarHeight - 120) * 2
+			}else{
+				if(sys.safeArea.top){
+					this.scrollH = (sys.windowHeight - 120) * 2 + sys.statusBarHeight - 34
+				}else{
+					this.scrollH = (sys.windowHeight - 120) * 2 - 14
+				}
+			}
+			this.getList()
+		},
+		methods: {
+			toThousands:toThousands,
+			toChooseCust(){
+				uni.navigateTo({
+					url:"/pages/sales/chooseCustomer?backPage=salesRecord"
+				})
+			},
+			tagClick(){
+				this.show = false
+				this.buyerName = undefined
+				this.queryparams.buyerSn = undefined
+				this.getList(1)
+			},
+			// 列表
+			getList(pageNo){
+				const _this = this
+				if (pageNo) {
+					if(pageNo==1){
+						this.listData = []
+					}
+					this.pageNo = pageNo
+				}
+				let params = {
+					pageNo: this.pageNo,
+					pageSize: this.pageSize
+				}
+				this.status = "loading"
+				salesRecordlList(Object.assign(params, this.queryparams)).then(res => {
+					if (res.status == 200) {
+						if(this.pageNo>1){
+							this.listData = this.listData.concat(res.data.list || [])
+						}else{
+							this.listData = res.data.list || []
+						}
+						this.totalNum = res.data.count || 0
+					} else {
+						this.listData = []
+						this.totalNum = 0
+						this.noDataText = res.message
+					}
+					this.status = "loadmore"
+				})
+			},
+			// scroll-view到底部加载更多
+			onreachBottom() {
+				if(this.listData.length < this.totalNum){
+					this.pageNo += 1
+					this.getList()
+				}
+			},
+		}
+	}
+</script>
+
+<style lang="less">
+.salesRecord-box{
+	width: 100%;
+	height: 100vh;
+	.sales-productInfo{
+		padding: 20upx 30upx;
+		background: #fff;
+		> view{
+			padding: 5upx 0;
+		}
+	}
+	.product-list{
+		flex-grow: 1;
+		.search-box{
+			background: #fff;
+		}
+		.sales-list-con{
+			height: 100%;
+			.sales-list-main{
+				height: 100%;
+				.sales-list-item{
+					background: #ffffff;
+					padding: 20upx;
+					margin: 25upx;
+					border-radius: 25upx;
+					box-shadow: 1px 1px 3px #EEEEEE;
+					.list-item-tit{
+						padding-bottom: 18upx;
+						padding-top: 10upx;
+						border-bottom: 1px solid #e4e7ed;
+						.u-line{
+							display: inline-block;
+							width: 6upx;
+							height: 30upx;
+							vertical-align: bottom;
+							margin: 0 10upx;
+							border-radius: 5upx;
+						}
+						.buyer{
+							flex-grow: 1;
+							font-size: 30upx;
+							font-weight: bold;
+						}
+						>view{
+							&:last-child{
+								width: 150upx;
+								color: #666;
+							}
+						}
+					}
+					.list-item-con{
+						padding: 10upx 0;
+						.list-item-line{
+							padding: 8upx 0;
+						}
+						text{
+							color: #666;
+						}
+					}
+				}
+			}
+		}
+	}
+}
+</style>