shish 3 лет назад
Родитель
Сommit
2519343a4e

+ 3 - 2
ghsPad/src/pages.json

@@ -1,13 +1,14 @@
 {
 	"pages": [
-		{"path": "pages/home/cash","style": {"navigationBarTitleText": "收银"}},
+		{"path": "pages/home/selectCustom","style": {"navigationBarTitleText": "选客户"}},
 		{"path": "pages/home/order","style": {"navigationBarTitleText": "订单"}},
 		{"path": "pages/home/mt","style": {"navigationBarTitleText": "美团单"}},
 		{"path": "pages/home/sh","style": {"navigationBarTitleText": "散花"}},
 		{"path": "pages/home/work","style": {"navigationBarTitleText": "门店单"}},
 		{"path": "pages/home/modify","style": {"navigationBarTitleText": "修改"}},
 		{"path": "pages/home/make","style": {"navigationBarTitleText": "制作"}},
-		{"path": "pages/home/selectCustom","style": {"navigationBarTitleText": "选客户"}},
+		{"path": "pages/home/cash","style": {"navigationBarTitleText": "选花材"}},
+		{"path": "pages/home/waste","style": {"navigationBarTitleText": "选花材"}},
 		{"path": "pages/home/selectMake","style": {"navigationBarTitleText": "选款"}},
 		{"path": "pages/home/blue","style": {"navigationBarTitleText": "连接标签机"}}
 	],

+ 2 - 2
ghsPad/src/pages/home/cash.vue

@@ -9,7 +9,7 @@
 
 		<view class="app-casher-area">
 			<view class="nav-left">
-				<navComponent navType="casher"></navComponent>
+				<navComponent navType="casher" :showMenu="false"></navComponent>
 			</view>
 			<!-- 已选花材列表 -->
 			<view class="itemList-box">
@@ -41,7 +41,7 @@ import { mapGetters } from "vuex";
 import autoUpdateApp from "@/mixins/autoUpdate";
 import rightItem from './components/rightItem.vue'
 import rightGoods from './components/rightGoods.vue'
-import consoleButton from './components/console.vue'
+import consoleButton from './components/cashConsole.vue'
 import leftArea from './components/leftArea.vue'
 import leftGroup from './components/leftGroup.vue'
 import navComponent from './components/nav.vue'

+ 368 - 0
ghsPad/src/pages/home/components/cashConsole.vue

@@ -0,0 +1,368 @@
+<template>
+<view class="button-area">
+	<view class="active" @click="openBox">开箱</view>
+	 <view class="active" 
+ style="background-color:orange;color:white;border-color:orange;position:fixed;left:135upx;bottom:13upx;width:84upx;height:50upx;line-height:30upx;font-size:16upx;" 
+ @click="goSettleCommit">结算</view>
+	 <view class="active" 
+ style="position:fixed;left:36upx;bottom:13upx;width:84upx;height:50upx;line-height:30upx;font-size:15upx;" 
+ @click="gatheringFn()">收款</view>
+    <view class="active" @click="clearItemFn">清空</view>
+	<view class="active" @click="closeFn">取消</view>
+
+	<view v-if="Number(customId)>0" style="position:fixed;left:32upx;bottom:66upx;width:189upx;height:20upx;line-height:5upx;font-size:13upx;background-color:white;color:#3385FF;font-weight:bold;border:none;">{{customName}}</view>
+
+    <!-- 清空 -->
+    <uni-popup ref="clearItemRef" type="dialog">
+        <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="提示" content="确认清空?" @confirm="confirmClearItem"></uni-popup-dialog>
+    </uni-popup>
+
+    <uni-popup ref="logoutRef" type="dialog">
+        <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="提示" content="确认退出?" @confirm="confirmLogout"></uni-popup-dialog>
+    </uni-popup>
+
+    <!-- 结算弹框 -->
+    <uni-popup ref="settlePopRef" background-color="#fff" type="center" :animation="false">
+        <settlePop @settleCommit="settleCommit" @cancelSettle="cancelSettle" ref="settlePop" :settleOpenStatus.sync="settleOpenStatus"></settlePop>
+    </uni-popup>
+
+    <!-- 扫码付款 -->
+    <uni-popup ref="toPayRef" background-color="#fff" type="center" :animation="false" :is-mask-click="false">
+        <toPayWay @cancelPay="cancelPay()" @payFinish="payFinish()" @selectPayWayBack="selectPayWayBack" :orderId.sync="orderId" :price.sync="price"></toPayWay>
+    </uni-popup>
+
+	<!-- 临时收款 -->
+	<uni-popup ref="gatheringRef" background-color="#fff" type="center" :animation="false">
+		<selectPrice @confirmSelectPrice="confirmSelectPrice" @cancelSelectPrice="cancelSelectPrice"></selectPrice>
+	</uni-popup>
+
+	<!-- 开单选花材输入数量和金额 -->
+	<uni-popup ref="selectNumPriceRef" background-color="#fff" type="center" :animation="false">
+		<selectNumPrice @confirmAddItemModel="confirmAddItemModel" :customData.sync="customData"
+		@addToClear="addToClear" @cancelKdSelectNumPrice="addItemModelHidden"></selectNumPrice>
+	</uni-popup>
+
+</view>
+</template>
+<script>
+import settlePop from './settlePop'
+import toPayWay from './toPay'
+import { wastageCreateOrder } from '@/api/home/index'
+import { createOrder} from '@/api/order'
+import {goodsWastage} from '@/api/wastage'
+import productMins from "@/mixins/product"
+import selectPrice from './selectPrice'
+import selectNumPrice from './selectNumPrice'
+// #ifdef APP-PLUS
+let sunmiCashboxPlugin = uni.requireNativePlugin('Tellsea-SunmiCashboxPlugin')
+// #endif
+export default {
+    name:'console',
+	mixins: [productMins],
+    components:{ settlePop,toPayWay,selectPrice,selectNumPrice},
+	props: {
+		customId: {
+			type: Number,
+			default: 0
+		},
+        customName:{
+            type:String,
+            default:''
+        },
+        changeCurrentJobType:{
+            type:String,
+            default:'bill'
+        },
+        changeCurrentJobId:{
+            type:Number,
+            default:0
+        }
+    },
+    data(){
+        return {
+            totalShop:{ bigUnit: 0, smallUnit:0, totalPrice: 0 },
+			orderId:0,
+            currentJobType:'bill',
+            currentJobId:0,
+			calc:'add',
+			settleOpenStatus:0,
+			price:0
+        }
+    },
+    watch:{
+        changeCurrentJobType:{
+            handler(str){
+                this.currentJobType = str
+            },
+            immediate:true
+        },
+        changeCurrentJobId:{
+            handler(id){
+                this.currentJobId = Number(id)
+            },
+            immediate:true
+        }
+    },
+	created(){
+		this.listenScanItem()
+	},
+	destroyed(){
+		// #ifdef APP-PLUS
+		//避免重复,每次进来先移除全局自定义事件监听器
+		uni.$off('listenGetScanCode')
+		// #endif
+	},
+    methods:{
+		closeFn(){
+			this.$util.hitVoice()
+			uni.navigateBack()
+		},
+        addToClear(){
+			let params = {
+                hasPay: 0,
+                payWay:0,
+                needPrint:2,
+                freight: '',
+                groupName:'',
+                remark:'',
+                sendCost:0,
+                modifyPrice:0,
+                getStaffName:''
+            }
+			if(this.$util.isEmpty(this.selectList)){
+				this.$msg('请选择商品')
+				return false
+			}
+			let price = 0
+			for (const ele of this.selectList) {
+				let currentPrice = Number(ele.currentNum) * Number(ele.unitPrice)
+				currentPrice = currentPrice.toFixed(2)
+				price = Number(currentPrice) + Number(price)
+				price = price.toFixed(2)
+			}
+			params.modifyPrice = price
+            this.settleCommit(params)
+        },
+		cancelSelectPrice(){
+			this.$refs.gatheringRef.close()
+		},
+		confirmSelectPrice(params){
+			uni.showLoading({mask:true})
+			//isCashier=1时收银台播放 总金额139元,请扫码付款
+			createOrder({orderName:params.name,lsGoodsPrice:params.price,modifyPrice:params.price,isCashier:1,cash:params.cash}).then(res=>{
+				uni.hideLoading()
+				if(res.code == 1){
+					if(res.data.status == 1){
+						this.$refs.toPayRef.open('center')
+						this.$refs.gatheringRef.close()
+						this.orderId = res.data.id
+						this.price = res.data.mainPay ? Number(res.data.mainPay) : 0
+					}else{
+						this.$refs.gatheringRef.close()
+						uni.showToast({title: '操作成功' })
+					}
+					if(params.cash && parseFloat(params.cash)>0){
+						this.openBox()
+					}
+				}
+			})
+		},
+		gatheringFn(){
+			this.$util.hitVoice()
+			this.$refs.gatheringRef.open('center')
+		},
+		payFinish(){
+			this.$util.hitVoice()
+			this.$refs.toPayRef.close()
+			this.removeFromSaveDirect()
+			this.customId =0
+			this.customName=''
+			//继续监听花材扫码
+			this.listenScanItem()
+			//开单完成之后更新花材库存
+			this.$emit('rightItemRefresh')
+		},
+		calcFn(){
+			this.calc = this.calc == 'add' ? 'sub' : 'add'
+		},
+		changeProperty(num){
+			this.$emit('changeProperty',num)
+		},
+		settleCommit(params){
+			if(this.$util.isEmpty(this.selectList)) {
+				this.$msg('请选择商品')
+				return false
+			}
+			uni.showLoading({mask:true})
+			let product = this.selectList.map(i=>({ productId:i.id, unitType: i.unitType||0, num: i.currentNum, property: i.property, unitPrice: i.unitPrice }))
+			//isCashier=1时收银台播放 总金额139元,请扫码付款
+			createOrder({...params,product:JSON.stringify(product),isCashier:1,customId:this.customId}).then(res=>{
+				uni.hideLoading()
+				if(res.code == 1){
+					if(res.data.status == 1){
+						this.orderId = res.data.id
+						this.price = res.data.mainPay ? Number(res.data.mainPay) : 0
+						this.$refs.toPayRef.open('center')
+					}else{
+						this.removeFromSaveDirect()
+						this.$emit('clearAll')
+						//开单完成之后更新花材库存
+						this.$emit('rightItemRefresh')
+						uni.showToast({ title: '操作成功', duration: 1000 })
+					}
+					this.settleOpenStatus = 0
+					this.$refs.settlePopRef.close()
+					if(params.cash && parseFloat(params.cash)>0){
+						this.openBox()
+					}
+				}
+			})
+		},
+		cancelPay(){
+			this.$util.hitVoice()
+			this.$refs.toPayRef.close()
+			this.listenScanItem()
+		},
+		cancelSettle(){
+			this.$util.hitVoice()
+			this.settleOpenStatus = 0
+			this.$refs.settlePopRef.close()
+		},
+		async settleReturn(){
+			this.$util.hitVoice()
+			this.setCreateOrder()
+		},
+		selectPayWayBack(price){
+			this.$util.hitVoice()
+		},
+		toWastage(){
+			this.$util.hitVoice()
+			if(this.$util.isEmpty(this.selectList)) {
+				this.$msg('请选择报损花材')
+				return false
+			}
+			this.$refs.wastageRef.open('center')
+		},
+		confirmWastage(){
+			this.$util.hitVoice()
+			if(this.$util.isEmpty(this.selectList)) {
+				this.$msg('请选择报损花材')
+				return false
+			}
+			let hasGoods = this.selectList.some((item) => {
+			  return item.property  == 0
+			})
+			let hasItem = this.selectList.some((item) => {
+			  return item.property  == 1
+			})
+			if(hasGoods == true && hasItem == true){
+				this.$msg('商品和花材要分别进行报损')
+				return false
+			}
+			if(hasItem == true){
+				let product = this.selectList.map(i=>({ 
+					productId:i.id, unitType: i.unitType||0, num: i.currentNum, property: i.property, unitPrice: i.unitPrice,
+				}))
+				wastageCreateOrder({ product: JSON.stringify(product) }).then(res=>{
+					if(res.code == 1){
+						this.removeFromSaveDirect()
+						this.$refs.wastageRef.close()
+						this.$msg("报损成功!")
+					}
+				})
+			}else{
+				let goodsList = this.selectList.map(i=>({ 
+					goodsId:i.id, num: i.currentNum, property: i.property, unitPrice: i.unitPrice,name:i.name,cover:i.shortCover
+				}))
+				goodsWastage({ goodsList: JSON.stringify(goodsList) }).then(res=>{
+					if(res.code == 1){
+						this.removeFromSaveDirect()
+						this.$refs.wastageRef.close()
+						this.$msg("报损成功!")
+					}
+				})
+			}
+		},
+		goSettleCommit(){
+			this.$util.hitVoice()
+			if(this.$util.isEmpty(this.selectList)) {
+				this.$msg('请选择结算花材')
+				return false
+			}
+			if(this.$util.isEmpty(this.customId)) {
+				this.$msg('请选择客户')
+				return false
+			}
+			this.settleOpenStatus = 1
+			this.$refs.settlePopRef.open('center')
+		},
+		//清空花材弹框
+		clearItemFn(){
+			this.$util.hitVoice()
+			this.$refs.clearItemRef.open()
+		},
+		openBox(){
+			// #ifdef APP-PLUS
+			sunmiCashboxPlugin.connect((e) => {
+				let res = JSON.parse(e)
+				if (res.code == 200) {
+					sunmiCashboxPlugin.openDrawer((e) => {
+						let res = JSON.parse(e)
+						if (res.code == 200) {
+							//that.$msg(res.msg)
+						}
+					});
+				}
+			})
+			// #endif
+		},
+		//确认清空花材
+		confirmClearItem(){
+			this.$util.hitVoice()
+			this.removeFromSaveDirect()
+			this.$emit('clearAll')
+		},
+		confirmLogout(){
+			this.$util.hitVoice()
+			uni.clearStorage()
+			this.$store.commit("setLoginInfo", {})
+			// #ifdef APP-PLUS
+			plus.runtime.restart()
+			// #endif
+		},
+		logoutFn(){
+			this.$util.hitVoice()
+			this.$refs.logoutRef.open()
+		},
+		delSelectItem(){
+			this.$util.hitVoice()
+		}
+    }
+}
+</script>
+<style lang="scss" scoped>
+.button-area {
+    height: 100vh;
+    display: flex;
+    flex-direction: column;
+	justify-content: space-around;
+    padding: 5upx;
+    padding-top: 12upx;
+    & > view {
+        border: 1upx solid #CCCCCC;
+        border-radius: 5upx;
+        text-align: center;
+        padding: 10upx 0;
+        color: #666666;
+        margin-bottom: 12upx;
+        font-size: 10upx;
+        text-align: center;
+    }
+	& .active {
+		color: #3385FF;
+		border-color: #3385FF;
+		font-size: 10upx;
+		font-weight:bold;
+	}
+}
+</style>

+ 1 - 2
ghsPad/src/pages/home/components/customerList.vue

@@ -4,7 +4,6 @@
     <view class="app-userList_box">
       <view :key="item.id" @click="selectCustomer(item)" class="userList-item_box" v-for="item in list">
         <view class="head-box">
-          <image class="img" :src="item.avatar" mode="" ></image>
           <view class="name">{{item.name}}</view>
         </view>
         <view class="footer-box">
@@ -77,7 +76,7 @@ export default {
   background-color: #ffffff;
   padding: 5upx;
   height: 99vh;
-  width:100vw;
+  width:96vw;
   display: flex;
   flex-direction: column;
   box-sizing: border-box;

+ 2 - 1
ghsPad/src/pages/home/components/nav.vue

@@ -28,7 +28,8 @@ export default {
   data() {
     return {
       nav: [
-        { name: "收银", page: "/pages/home/cash",flag:'casher' },
+        { name: "选客", page: "/pages/home/selectCustom",flag:'selectCustom' },
+        { name: "损耗", page: "/pages/home/waste",flag:'waste' },
         { name: "订单", page: "/pages/home/order",flag:'order' }
       ],
       device:''

+ 53 - 15
ghsPad/src/pages/home/selectCustom.vue

@@ -1,25 +1,69 @@
 <template>
 <view>
-    <customerList @selectCustomer="selectCustomer" @cancelChooseCustomer="cancelSelect"> </customerList>
+
+	<template v-if="isLogin == 2">
+	</template>
+	<template v-else-if="isLogin == 0">
+		<loginComponent></loginComponent>
+	</template>
+	<template v-else>
+
+        <view class="app-casher-area">
+            <view class="nav-left">
+                <casherNav navType="selectCustom"></casherNav>
+            </view>
+			<view class="select-custom">
+				<customerList @selectCustomer="selectCustomer" @cancelChooseCustomer="cancelSelect"> </customerList>
+			</view>
+        </view>
+
+	</template>
+
 </view>
 </template>
 <script>
+import { mapGetters } from "vuex";
+import casherNav from './components/nav.vue'
 import customerList from './components/customerList.vue'
+import loginComponent from './login.vue'
 export default {
 	name: "selectCustom",
-	components: { customerList},
+	components: { customerList,casherNav,loginComponent},
 	mixins: [],
 	data() {
 		return {
+			isLogin:2,
 			customId:0,
+			customName:'',
+            currentJobType:'bill',
+            currentJobId:0
+		}
+	},
+	computed: {
+		...mapGetters(["getLoginInfo"])
+	},
+	mounted() {
+		if(this.$util.isEmpty(this.getLoginInfo.admin) || this.getLoginInfo.admin.currentShopId == 0){
+			this.isLogin = 0
+		}else{
+			this.isLogin = 1
+		}
+	},
+	watch:{
+		getLoginInfo: {
+			handler(newValue) {
+				if(this.$util.isEmpty(newValue.admin) == false && newValue.admin.currentShopId > 0){
+					this.isLogin = 1
+				}else{
+					this.isLogin = 0
+				}			
+			}
 		}
 	},
 	methods: {
 		selectCustomer(info){
-			let pages = getCurrentPages();
-			let prevPage = pages[ pages.length - 2 ];
-			prevPage.$vm.customerInfo = {hasSelect:1,customId:info.id,customName:info.name}
-			uni.navigateBack({})
+			this.$util.hitVoice()
+			this.$util.pageTo({url:'/pages/home/cash?customId='+info.id+'&customName='+info.name})
 		},
 		cancelSelect(){
 			let pages = getCurrentPages();
@@ -34,18 +78,12 @@ export default {
 .app-casher-area {
 	display: flex;
 	height: 100vh;
-	& .all-item-area {
-		flex: 76;
-	}
 	& .nav-left {
 		flex: 5;
 		background-color: rgba(72, 91, 107, 1);
 	}
-	& .itemList-box {
-		flex: 30;
-	}
-	& .open-box {
-		flex: 8;
-	}
+    & .select-custom{
+        flex: 121;
+    }
 }
 </style>

+ 164 - 0
ghsPad/src/pages/home/waste.vue

@@ -0,0 +1,164 @@
+<template>
+<view>
+	<template v-if="isLogin == 2">
+	</template>
+	<template v-else-if="isLogin == 0">
+		<loginComponent></loginComponent>
+	</template>
+	<template v-else>
+
+		<view class="app-casher-area">
+			<view class="nav-left">
+				<navComponent navType="waste"></navComponent>
+			</view>
+			<!-- 已选花材列表 -->
+			<view class="itemList-box">
+				<leftArea v-if="!$util.isEmpty(selectList)" :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId"></leftArea>
+				<leftGroup v-else :customId.sync="customId"></leftGroup>
+			</view>
+			<!-- 分类和花材图片 -->
+			<view class="all-item-area">
+				<rightGoods v-if="currentProperty == 0" ref="rightItemRef" :customId.sync="customId" :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId"> </rightGoods>
+				<rightItem v-else ref="rightItemRef" :customId.sync="customId" :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId"> </rightItem>
+			</view>
+			<!-- 按钮操作 -->
+			<view class="open-box">
+				<consoleButton :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId" @clearAll="clearAll"
+				:customId.sync="customId" :customName.sync="customName" @changeProperty="changeProperty" @rightItemRefresh="rightItemRefresh"></consoleButton>
+			</view>
+		</view>
+
+	</template>
+
+    <uni-popup ref="refrshRef" type="dialog">
+        <uni-popup-dialog type="info" cancelText="取消" @close="cancelRefresh" confirmText="确认" title="提示" content="花材价格库存已修改,请刷新" @confirm="confirmRefresh"></uni-popup-dialog>
+    </uni-popup>
+
+</view>
+</template>
+<script>
+import { mapGetters } from "vuex";
+import autoUpdateApp from "@/mixins/autoUpdate";
+import rightItem from './components/rightItem.vue'
+import rightGoods from './components/rightGoods.vue'
+import consoleButton from './components/console.vue'
+import leftArea from './components/leftArea.vue'
+import leftGroup from './components/leftGroup.vue'
+import navComponent from './components/nav.vue'
+import loginComponent from './login.vue'
+import { checkRefresh } from '@/api/item'
+import productMins from "@/mixins/product";
+export default {
+	name: "cash",
+	components: { rightItem,consoleButton,  loginComponent, leftArea,leftGroup, rightGoods,navComponent},
+	mixins: [autoUpdateApp,productMins],
+	data() {
+		return {
+			//0成品 1花材
+			currentProperty:1,
+			itemList:[],
+			currenSelectShop:{},
+			selectItem: {},
+			selectItemUser:{},
+			isLogin:2,
+			customId:0,
+			customName:'',
+            currentJobType:'bill',
+            currentJobId:0,
+			hasChooseCustomer:true,
+			T:null,
+			customerInfo:{hasSelect:0,customId:0,customName:''}
+		}
+	},
+	computed: {
+		...mapGetters(["getLoginInfo"])
+	},
+	onLoad() {
+		this.initDataFromStorage()
+
+		this.beginRemind()
+	},
+	onShow(){
+		if(this.customerInfo.hasSelect == 1){
+			this.customId = this.customerInfo.customId
+			this.customName = this.customerInfo.customName
+		}
+	},
+	onUnload(){
+		clearInterval(this.T)
+	},
+	onPullDownRefresh() {
+	},
+	mounted() {
+		if(this.$util.isEmpty(this.getLoginInfo.admin) || this.getLoginInfo.admin.currentShopId == 0){
+			this.isLogin = 0
+		}else{
+			this.isLogin = 1
+		}
+	},
+	watch:{
+		getLoginInfo: {
+			handler(newValue) {
+				if(this.$util.isEmpty(newValue.admin) == false && newValue.admin.currentShopId > 0){
+					this.isLogin = 1
+				}else{
+					this.isLogin = 0
+				}			
+			}
+		}
+	},
+	methods: {
+		clearAll(){
+			this.customId = 0
+			this.customName = ''
+		},
+		cancelRefresh(){
+			this.beginRemind()
+		},
+		confirmRefresh(){
+			clearInterval(this.T)
+        	this.$util.pageTo({ url: "/pages/home/cash",type:2})
+		},
+		beginRemind(){
+			let that = this
+			clearInterval(that.T)
+			that.T = setInterval(function(){
+				checkRefresh().then(res=>{
+					if(res.code == 1){
+						if(res.data.remind && res.data.remind == 1){
+							clearInterval(that.T)
+							that.$refs.refrshRef.open('center')
+						}
+					}
+				})
+			}, 8000); 
+		},
+		//开单完成之后更新花材的库存
+		rightItemRefresh(){
+			this.$refs.rightItemRef.itemRefresh()
+		},
+		changeProperty(property){
+			this.currentProperty = property
+		}
+	}
+};
+</script>
+<style lang="scss" scoped>
+.app-casher-area {
+	display: flex;
+	height: 100vh;
+	& .all-item-area {
+		flex: 76;
+	}
+	& .nav-left {
+		flex: 5;
+		background-color: rgba(72, 91, 107, 1);
+	}
+	& .itemList-box {
+		flex: 30;
+	}
+	& .open-box {
+		flex: 8;
+	}
+}
+</style>