浏览代码

库存详情、出入库详情页

chenrui 3 年之前
父节点
当前提交
e74ffc48ab
共有 5 个文件被更改,包括 285 次插入27 次删除
  1. 23 0
      libs/tools.js
  2. 46 17
      pages/stock/detaiList.vue
  3. 89 1
      pages/stock/stockDetail.vue
  4. 9 8
      pages/stock/stockSearch.vue
  5. 118 1
      pages/stock/warehouseDetail.vue

+ 23 - 0
libs/tools.js

@@ -1,6 +1,29 @@
 let carmera = uni.requireNativePlugin('ziteng-maskcamera')
 let cameraModule = uni.requireNativePlugin("SMUniPlugin-CameraModule")
 
+// 处理数字千位分隔符  num 数值,decimal要保留的小数位数
+export const toThousands = (num, decimal) => {
+  if (decimal) {
+    num = formatDecimal(num, decimal)
+  }
+  return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
+    return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) {
+      return $1 + ','
+    })
+  })
+}
+// 保留decimal位小数(不四舍五入)  num 数值,decimal要保留的小数位数
+export const formatDecimal = function (num, decimal) {
+  num = num.toString()
+  const index = num.indexOf('.')
+  if (index !== -1) {
+    num = num.substring(0, decimal + index + 1)
+  } else {
+    num = num.substring(0)
+  }
+  return parseFloat(num).toFixed(decimal)
+}
+
 export function objToUrl(obj) {
   let uri = '';
   let keys = Object.keys(obj);

+ 46 - 17
pages/stock/detaiList.vue

@@ -6,23 +6,22 @@
 			</view>
 			<view class="st-detailList-info">
 				<view class="st-detailList-tit">
-					<view class="u-line" :style="{backgroundColor: $config('primaryColor')}"></view>{{stockInfo&&stockInfo.productName ? stockInfo.productName : '--'}}
+					<view class="u-line" :style="{backgroundColor: $config('primaryColor')}"></view>{{stockInfo&&stockInfo.productName || '--'}}
 				</view>
 				<view class="st-detailList-info-con flex align_center">
 					<view class="pimgs">
-						<u-image :src="stockInfo&&stockInfo.product&&stockInfo&&stockInfo.product.productMsg?stockInfo&&stockInfo.product.productMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+						<u-image :src="stockInfo&&stockInfo.productMsg||`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
 					</view>
 					<view class="flex_1">
-						<view>产品编码:{{stockInfo&&stockInfo.productCode ? stockInfo.productCode : '--'}}</view>
-						<view class="padding_3">原厂编码:{{stockInfo&&stockInfo.productOrigCode ? stockInfo.productOrigCode : '--'}}</view>
+						<view>产品编码:{{stockInfo&&stockInfo.productCode || '--'}}</view>
+						<view class="padding_3">原厂编码:{{stockInfo&&stockInfo.productOrigCode || '--'}}</view>
 						<view class="flex align_center justify_between">
 							<view class="font_13">
-								可用数量:
-								<u-count-to :end-val="stockInfo&&stockInfo.currentStockQty ? stockInfo&&stockInfo.currentStockQty : 0" separator="," font-size="26"></u-count-to>个
+								可用数量:{{toThousands(stockInfo&&stockInfo.currentStockQty||0)}}{{stockInfo&&stockInfo.productUnit||''}}
 							</view>
 							<view class="font_13">
 								库存成本:
-								¥<u-count-to :end-val="stockInfo&&stockInfo.currentStockCost ? stockInfo&&stockInfo.currentStockCost : 0" separator="," font-size="26" :decimals="2"></u-count-to>
+								¥{{toThousands(stockInfo&&stockInfo.currentStockCost||0, 2)}}
 							</view>
 						</view>
 					</view>
@@ -36,23 +35,26 @@
 				<view v-if="curNow==0" class="st-detailList-main-item" v-for="(item, index) in listData" :key="item.id" @click="getDetail(item)">
 					<view class="flex align_center justify_between margin-b20">
 						<view :style="{color: $config('infoColor')}">{{item.putTime || '--'}}</view>
-						<u-tag :text="item.putBizTypeDictValue" :border-color="$config('primaryColor')" shape="circle" size="mini" />
+						<u-tag v-if="item.putBizTypeDictValue" :text="item.putBizTypeDictValue" :border-color="$config('primaryColor')" shape="circle" size="mini" />
 					</view>
 					<view class="flex align_center justify_between">
 						<view v-if="item.warehouseName || item.warehouseLocationName">{{item.warehouseName}} > {{item.warehouseLocationName}}</view>
 						<view v-else>--</view>
-						<view>¥{{item.putCost}} * {{item.currentQty}}{{item.productUnit}}</view>
+						<view>¥{{toThousands(item.putCost||0, 2)}} * {{toThousands(item.currentQty||0)}}{{item.unit}}</view>
 					</view>
 				</view>
 				<!-- 出入库明细 -->
 				<view v-if="curNow==1" class="st-detailList-main-item" v-for="(item, index) in listData" :key="item.id" @click="getDetail(item)">
 					<view class="flex align_center justify_between margin-b20">
 						<view :style="{color: $config('infoColor')}">{{item.auditTime || '--'}}</view>
-						<u-tag :text="item.bizTypeDictValue" :border-color="$config('primaryColor')" shape="circle" size="mini" />
+						<u-tag v-if="item.bizTypeDictValue" :text="item.bizTypeDictValue" :border-color="$config('primaryColor')" shape="circle" size="mini" />
 					</view>
 					<view class="flex align_center justify_between">
 						<view>{{item.unitName || '--'}}</view>
-						<view :style="{color: item.flowType=='PUT' ? 'green':'red'}"><text v-if="item.qty!=0">{{ item.flowType=='PUT' ? '+':'-' }}</text>{{ item.qty }}{{item.productUnit}}</view>
+						<view>
+							<view :style="{color: item.qty && item.qty!=0 ? (item.flowType=='PUT' ? 'green':'red'):'', display:'inline-block'}"><text v-if="item.qty && item.qty!=0">{{ item.flowType=='PUT' ? '+':'-' }}</text>{{ toThousands(item.qty||0) }}</view>
+							{{item.product && item.product.unit}}
+						</view>
 					</view>
 				</view>
 				<view v-if="listData && listData.length == 0">
@@ -64,6 +66,7 @@
 </template>
 
 <script>
+	import { toThousands } from '@/libs/tools'
 	import { stockDetailList, stockFlowList } from '@/api/stock'
 	export default{
 		data(){
@@ -80,7 +83,8 @@
 				stockInfo: null,
 				noDataText: '暂无数据',
 				curNow: 0,
-				theme: ''
+				theme: '',
+				toThousands
 			}
 		},
 		onLoad(option) {
@@ -95,20 +99,45 @@
 				if (pageNo) {
 					this.pageNo = pageNo
 				}
+				let params = {}
 				let url = stockDetailList
 				if(this.curNow == 0){  // 库存详情
 					url = stockDetailList
+					params = {
+						pageNo: this.pageNo,
+						pageSize: this.pageSize,
+						stockSn: this.stockInfo && this.stockInfo.stockSn || '',
+						isSellOut: '0'
+					}
 				}else if(this.curNow == 1){  // 出入库明细
 					url = stockFlowList
+					params = {
+						pageNo: this.pageNo,
+						pageSize: this.pageSize,
+						productSn: this.stockInfo && this.stockInfo.productSn || ''
+					}
 				}
-				url({ pageNo: this.pageNo, pageSize: this.pageSize }).then(res => {
+				url(params).then(res => {
 					if (res.status == 200) {
-						if(this.pageNo>1){
-							this.listData = this.listData.concat(res.data.list || [])
+						if(res.data && res.data.list){
+							if(this.curNow == 1){  // 出入库明细
+								res.data.list.map(item => {
+									if(item.flowType == 'PUT'){
+										item.qty = item.putQty || 0
+									}else if(item.flowType == 'OUT'){
+										item.qty = item.outQty || 0
+									}
+								})
+							}
+							if(this.pageNo>1){
+								this.listData = this.listData.concat(res.data && res.data.list || [])
+							}else{
+								this.listData = res.data.list || []
+							}
 						}else{
-							this.listData = res.data.list || []
+							this.listData = []
 						}
-						this.totalNum = res.data.count || 0
+						this.totalNum = res.data && res.data.count || 0
 					} else {
 						this.listData = []
 						this.totalNum = 0

+ 89 - 1
pages/stock/stockDetail.vue

@@ -1,8 +1,96 @@
 <template>
+	<view class="stockDetail-wrap">
+		<view class="panel-box flex align_center justify_between">
+			<view class="pimgs">
+				<u-image :src="productData && productData.productMsg||`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+			</view>
+			<view class="info-con flex_1">
+				<view>{{productData && productData.productCode || '--'}}</view>
+				<view class="padding_7">{{productData && productData.productName || '--'}}</view>
+			</view>
+		</view>
+		<view class="stockDetail-info">
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">仓库</view>
+				<view>{{paramsData && paramsData.warehouseName || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">仓位</view>
+				<view>{{paramsData && paramsData.warehouseLocationName || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">入库时间</view>
+				<view>{{paramsData && paramsData.putTime || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">入库类型</view>
+				<view>{{paramsData && paramsData.putBizTypeDictValue || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">库存数量</view>
+				<view>{{toThousands(paramsData && paramsData.currentQty || 0)}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">成本单价</view>
+				<view>{{toThousands(paramsData && paramsData.putCost || 0, 2)}}</view>
+			</view>
+		</view>
+	</view>
 </template>
 
 <script>
+	import { toThousands } from '@/libs/tools'
+	import { stockList, stockCount } from '@/api/stock'
+	export default{
+		data(){
+			return {
+				productData: null,
+				paramsData: null,
+				theme: '',
+				toThousands
+			}
+		},
+		onLoad(option) {
+			this.theme = getApp().globalData.theme
+			this.productData = option.productData ? JSON.parse(option.productData) : null
+			this.paramsData = option.data ? JSON.parse(option.data) : null
+		},
+		methods: {}
+	}
 </script>
 
-<style>
+<style lang="scss">
+	.stockDetail-wrap{
+		width: 100%;
+		padding: 30upx;
+		.panel-box {
+			background-color: #ffffff;
+			padding: 20upx 20upx;
+			border-radius: 20upx;
+			box-shadow: 3upx 2upx 6upx #eee;
+			margin-bottom: 30upx;
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			.info-con{
+				margin-left: 20upx;
+				.padding_7{
+					padding: 14upx 0 0;
+				}
+			}
+		}
+		.stockDetail-info{
+			background-color: #ffffff;
+			padding: 10upx 20upx 20upx;
+			border-radius: 20upx;
+			box-shadow: 3upx 2upx 6upx #eee;
+			.info-item{
+				border-bottom: 1px dashed #e4e7ed;
+				padding: 20upx 0;
+				.info-name{
+					color: #464646;
+				}
+			}
+		}
+	}
 </style>

+ 9 - 8
pages/stock/stockSearch.vue

@@ -4,15 +4,15 @@
 		<view class="panel-box">
 			<view class="item-box">
 				<view>查询结果</view>
-				<u-count-to :end-val="totalNum ? totalNum : 0" separator="," font-size="30"></u-count-to>条
+				<view>{{toThousands(totalNum||0)}}条</view>
 			</view>
 			<view class="item-box">
 				<view>可用库存数量</view>
-				<u-count-to :end-val="totalData&&totalData.totalCurrentStockQty ? totalData.totalCurrentStockQty : 0" separator="," font-size="30"></u-count-to>个
+				<view>{{toThousands(totalData&&totalData.totalCurrentStockQty||0)}}个</view>
 			</view>
 			<view class="item-box">
 				<view>可用库存成本</view>
-				¥<u-count-to :end-val="totalData&&totalData.totalCurrentStockCost ? totalData.totalCurrentStockCost : 0" separator="," font-size="30" :decimals="2"></u-count-to>
+				<view>¥{{toThousands(totalData&&totalData.totalCurrentStockCost||0, 2)}}</view>
 			</view>
 		</view>
 		<!-- 查询结果 -->
@@ -24,19 +24,18 @@
 					</view>
 					<view class="stockSearch-item-con flex align_center">
 						<view class="pimgs">
-							<u-image :src="item.product&&item.product.productMsg?item.product.productMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+							<u-image :src="item.productMsg?item.productMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
 						</view>
 						<view class="flex_1">
 							<view>产品编码:{{item.productCode || '--'}}</view>
 							<view class="padding_3">原厂编码:{{item.productOrigCode || '--'}}</view>
 							<view class="flex align_center justify_between">
 								<view class="font_13">
-									可用数量:
-									<u-count-to :end-val="item.currentStockQty ? item.currentStockQty : 0" separator="," font-size="26"></u-count-to>{{item.productUnit}}
+									可用数量:{{toThousands(item.currentStockQty||0)}}{{item.productUnit}}
 								</view>
 								<view class="font_13">
 									库存成本:
-									¥<u-count-to :end-val="item.currentStockCost ? item.currentStockCost : 0" separator="," font-size="26" :decimals="2"></u-count-to>
+									¥{{toThousands(item.currentStockCost||0, 2)}}
 								</view>
 							</view>
 						</view>
@@ -51,6 +50,7 @@
 </template>
 
 <script>
+	import { toThousands } from '@/libs/tools'
 	import { stockList, stockCount } from '@/api/stock'
 	export default{
 		data(){
@@ -62,7 +62,8 @@
 				pageSize: 6,
 				params: {},
 				noDataText: '暂无数据',
-				theme: ''
+				theme: '',
+				toThousands
 			}
 		},
 		onLoad(option) {

+ 118 - 1
pages/stock/warehouseDetail.vue

@@ -1,8 +1,125 @@
 <template>
+	<view class="warehouseDetail-wrap">
+		<view class="panel-box flex align_center justify_between">
+			<view class="pimgs">
+				<u-image :src="productData && productData.productMsg||`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+			</view>
+			<view class="info-con flex_1">
+				<view>{{productData && productData.productCode || '--'}}</view>
+				<view class="padding_7">{{productData && productData.productName || '--'}}</view>
+			</view>
+		</view>
+		<view class="warehouseDetail-info">
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">变动类型</view>
+				<view v-if="paramsData && paramsData.flowType">{{paramsData.flowType=='OUT'?'出库':paramsData.flowType=='PUT'?'入库':'--'}}</view>
+				<view v-else>--</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">变动数量</view>
+				<view v-if="paramsData && paramsData.flowType && paramsData.flowType=='PUT'">
+					<view style="color: green;display: inline-block">
+						<text v-if="paramsData && paramsData.putQty && paramsData.putQty!=0">+</text>{{ toThousands(paramsData && paramsData.putQty||0) }}
+					</view>
+					{{paramsData && paramsData.product && paramsData.product.unit}}
+				</view>
+				<view v-if="paramsData && paramsData.flowType && paramsData.flowType=='OUT'">
+					<view style="color: red;display: inline-block">
+						<text v-if="paramsData && paramsData.outQty && paramsData.outQty!=0">-</text>{{ toThousands(paramsData && paramsData.outQty||0) }}
+					</view>
+					{{paramsData && paramsData.product && paramsData.product.unit}}
+				</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">单据类型</view>
+				<view>{{paramsData && paramsData.bizTypeDictValue || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">单据审核时间</view>
+				<view>{{paramsData && paramsData.auditTime || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">单位名称</view>
+				<view>{{paramsData && paramsData.unitName || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">批次号</view>
+				<view>{{paramsData && paramsData.stockBatchNo || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">仓库</view>
+				<view>{{paramsData && paramsData.warehouseName || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">仓位</view>
+				<view>{{paramsData && paramsData.warehouseLocationName || '--'}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">总成本</view>
+				<view>{{toThousands(paramsData && paramsData.totalCost || 0, 2)}}</view>
+			</view>
+			<view class="info-item flex align_center justify_between">
+				<view class="info-name">总售价</view>
+				<view>{{toThousands(paramsData && paramsData.totalPrice || 0, 2)}}</view>
+			</view>
+		</view>
+	</view>
 </template>
 
 <script>
+	import { toThousands } from '@/libs/tools'
+	import { stockList, stockCount } from '@/api/stock'
+	export default{
+		data(){
+			return {
+				productData: null,
+				paramsData: null,
+				theme: '',
+				toThousands
+			}
+		},
+		onLoad(option) {
+			this.theme = getApp().globalData.theme
+			this.productData = option.productData ? JSON.parse(option.productData) : null
+			this.paramsData = option.data ? JSON.parse(option.data) : null
+			console.log(this.paramsData)
+		},
+		methods: {}
+	}
 </script>
 
-<style>
+<style lang="scss">
+	.warehouseDetail-wrap{
+		width: 100%;
+		padding: 30upx;
+		.panel-box {
+			background-color: #ffffff;
+			padding: 20upx 20upx;
+			border-radius: 20upx;
+			box-shadow: 3upx 2upx 6upx #eee;
+			margin-bottom: 30upx;
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			.info-con{
+				margin-left: 20upx;
+				.padding_7{
+					padding: 14upx 0 0;
+				}
+			}
+		}
+		.warehouseDetail-info{
+			background-color: #ffffff;
+			padding: 10upx 20upx 20upx;
+			border-radius: 20upx;
+			box-shadow: 3upx 2upx 6upx #eee;
+			.info-item{
+				border-bottom: 1px dashed #e4e7ed;
+				padding: 20upx 0;
+				.info-name{
+					color: #464646;
+				}
+			}
+		}
+	}
 </style>