You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
344 lines
8.7 KiB
344 lines
8.7 KiB
<template>
|
|
<view>
|
|
<view class="search">
|
|
<u-search placeholder="输入商品名称/编号查询" v-model="keyword"
|
|
@search="searchList" bg-color="#fff" :show-action="false" border-color="#afd9ee"></u-search>
|
|
</view>
|
|
<view class="shopBox">
|
|
<ul>
|
|
<li v-for="item in goodsList" :key="item.id" @tap="gotoGoodsDetail(item)">
|
|
<u-icon name="checkmark-circle" color="#5fd9ee" size="20" v-if="purchaseDetails.filter((val)=> { return val.productId == item.id }).length > 0"></u-icon>
|
|
<u-icon name="checkmark-circle" color="#999" size="20" v-else></u-icon>
|
|
<image src="../../static/images/logo.png" mode=""></image>
|
|
<view class="rightBox">
|
|
<view class="title">
|
|
{{item.productName}}
|
|
</view>
|
|
<view class="">
|
|
{{item.productSn}}
|
|
</view>
|
|
<view class="">
|
|
{{item.barcode}}
|
|
</view>
|
|
</view>
|
|
<view class="rightBox2">
|
|
{{item.allPrice ? '¥' + item.allPrice : ''}}
|
|
</view>
|
|
</li>
|
|
</ul>
|
|
</view>
|
|
<view class="price">
|
|
<view class="textBox">
|
|
<view class="text">
|
|
应付: <text>{{ shouldPay.toFixed(2) }}</text>
|
|
</view>
|
|
<view class="text text2">
|
|
折扣:<uni-data-checkbox v-model="purchase.radio1" :localdata="checkBoxData" v-if="purchase.radio1 != 2" @change="checkboxChange"></uni-data-checkbox>
|
|
<u-number-box :min="0.1" :max="10" v-model="purchase.discount" step="0.1" decimal-length="1" v-if="purchase.radio1 == 2"></u-number-box>
|
|
<text v-if="purchase.radio1 == 2" @tap="cancelDisCount">取消</text>
|
|
</view>
|
|
|
|
</view>
|
|
<view class="textBox">
|
|
<view class="text">
|
|
实付: <text>{{ realPrice }}</text>
|
|
</view>
|
|
<view class="text text2">
|
|
已付: <uni-easyinput type="number" v-model="purchase.alreadyPay" placeholder="请输入已付金额" trim="all" @change="getNoPay" />
|
|
</view>
|
|
<view class="text">
|
|
未付: <text>{{ noPay }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
<view class="tui-tabbar">
|
|
<view class="tui-btn-mr">
|
|
<u-button type="error" :plain="true" shape="circle" @tap.stop="goodsAdd()">新增商品</u-button>
|
|
</view>
|
|
<view class="tui-btn-mr">
|
|
<u-button type="primary" :plain="true" shape="circle"
|
|
@tap.stop="sureSubmit()">确认提交</u-button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
mapState
|
|
} from 'vuex';
|
|
export default {
|
|
data() {
|
|
return {
|
|
type:'',
|
|
goodsList:[],
|
|
keyword:'',
|
|
purchaseDetails:[],
|
|
purchase:{
|
|
alreadyPay:0,
|
|
noPay:0,
|
|
totalAmount:0,
|
|
shouldPay:0,
|
|
discount:10,
|
|
},
|
|
checkBoxData:[{
|
|
text: '单品',
|
|
value: 1,
|
|
disable:false
|
|
}, {
|
|
text: '整体',
|
|
value: 2,
|
|
disable:false
|
|
}]
|
|
};
|
|
},
|
|
onShow() {
|
|
this.getProductInfoList()
|
|
this.purchaseDetails = JSON.parse(JSON.stringify(this.purchaseDetails))
|
|
console.log("1111")
|
|
console.log(this.purchaseDetails)
|
|
this.purchase.shouldPay = this.purchase.totalAmount = this.shouldPay;
|
|
if( this.purchaseDetails.length > 0 && this.purchase.radio1 == 1) {
|
|
this.checkBoxData = [{
|
|
text: '单品',
|
|
value: 1,
|
|
disable:true
|
|
}, {
|
|
text: '整体',
|
|
value: 2,
|
|
disable:true
|
|
}]
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.type = options.type;
|
|
},
|
|
computed: {
|
|
...mapState(['shopName', 'userId','shopIndex' ]),
|
|
shouldPay() {
|
|
if(this.type == 'inventory') {
|
|
return this.purchaseDetails.reduce((acc, cur) => acc + cur.allPrice, 0)
|
|
} else {
|
|
return this.purchaseDetails.reduce((acc, cur) => acc + cur.realPrice, 0)
|
|
}
|
|
},
|
|
realPrice() {
|
|
let shouldPay = this.purchaseDetails.reduce((acc, cur) => acc + cur.discountAmount, 0)
|
|
this.purchase.realAmount = (shouldPay * this.purchase.discount * 0.1).toFixed(2)
|
|
return this.purchase.realAmount
|
|
},
|
|
noPay() {
|
|
this.purchase.noPay = (this.realPrice - this.purchase.alreadyPay).toFixed(2);
|
|
return this.purchase.noPay
|
|
}
|
|
},
|
|
methods:{
|
|
checkboxChange(e) {
|
|
console.log(e);
|
|
if(e.detail.value == 2) {
|
|
this.realPrice = this.shouldPay
|
|
}
|
|
},
|
|
cancelDisCount() {
|
|
this.purchase.radio1 = '';
|
|
this.purchase.discount = 10
|
|
},
|
|
getNoPay() {
|
|
if(this.purchase.alreadyPay > this.shouldPay) {
|
|
this.purchase.alreadyPay = 0;
|
|
this.noPay = 0
|
|
return uni.showToast({
|
|
title:'实付金额大于应付金额,请检查',
|
|
icon:'none'
|
|
})
|
|
}
|
|
this.purchase.noPay = this.noPay ;
|
|
this.purchase.shouldPay = this.shouldPay;
|
|
this.purchase.totalAmount = this.shouldPay;
|
|
},
|
|
gotoGoodsDetail(item) {
|
|
console.log(item);
|
|
if(this.type == 'inventory') {
|
|
uni.navigateTo({
|
|
url:"/pages/inventory/changeGoods?info=" + encodeURIComponent(JSON.stringify(item))
|
|
})
|
|
} else {
|
|
console.log(this.purchaseDetails, this.purchase,'this.purchase',item);
|
|
item.radio1 = this.purchase.radio1;
|
|
if( this.purchaseDetails.length > 0 ) {
|
|
let newArr = this.purchaseDetails.filter((items, index) => {
|
|
return item.id == items.productId
|
|
})
|
|
if(newArr.length > 0) {
|
|
uni.navigateTo({
|
|
url:"/pages/billing/changeGoods?info=" + encodeURIComponent(JSON.stringify(item)) + "&listDetail=" + encodeURIComponent(JSON.stringify(newArr[0]))
|
|
})
|
|
return
|
|
}
|
|
}
|
|
uni.navigateTo({
|
|
url:"/pages/billing/changeGoods?info=" + encodeURIComponent(JSON.stringify(item))
|
|
})
|
|
}
|
|
},
|
|
sureSubmit() {
|
|
this.purchase.shopId = this.shopIndex;
|
|
if(this.type == 'inventory') {
|
|
this.tui.request("/app/stock/putIn", "post", {
|
|
purchase: this.purchase ,
|
|
purchaseDetails: this.purchaseDetails
|
|
}, false, false).then((res) => {
|
|
if (res.code == 200) {
|
|
uni.showToast({
|
|
title:"入库成功",
|
|
icon:'none'
|
|
})
|
|
uni.navigateBack({
|
|
delta: 2
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title:"入库失败",
|
|
icon:'none'
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
uni.navigateTo({
|
|
url:"/pages/billing/saveOrder?saleDetailList=" + encodeURIComponent(JSON.stringify(this.purchaseDetails)) + "&purchase=" + encodeURIComponent(JSON.stringify(this.purchase))
|
|
})
|
|
}
|
|
},
|
|
goodsAdd() {
|
|
uni.navigateTo({
|
|
url:"/pages/inventory/addGoods"
|
|
})
|
|
},
|
|
getProductInfoList() {
|
|
this.tui.request("/app/product/list", "get", {
|
|
// shopId: 1,
|
|
}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
this.goodsList = res.result;
|
|
this.goodsList.forEach(item => {
|
|
this.purchaseDetails.forEach(item2 => {
|
|
if (item2.productId == item.id) {
|
|
if(this.type == 'inventory') {
|
|
item.allPrice = item2.allPrice
|
|
} else {
|
|
item.allPrice = item2.discountAmount
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else{
|
|
this.tui.toast(res.message)
|
|
}
|
|
}).catch((res) => {})
|
|
},
|
|
handleAddGoods(item) {
|
|
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.search {
|
|
padding: 20upx;
|
|
background-color: #fff;
|
|
position: fixed;
|
|
top: 0;
|
|
z-index: 100;
|
|
width: 100%;
|
|
background-color: #fff;
|
|
}
|
|
.shopBox {
|
|
background-color: #fff;
|
|
margin: 30upx;
|
|
margin-top: 120upx;
|
|
border-radius: 10upx;
|
|
box-shadow: 0px 1px 10px 2px #e2e2e2;
|
|
height: calc(100vh - 450rpx);;
|
|
overflow: scroll;
|
|
ul {
|
|
li {
|
|
padding: 20rpx;
|
|
display: flex;
|
|
image {
|
|
width: 100rpx;
|
|
height: 100rpx;
|
|
margin-left: 20rpx;
|
|
}
|
|
.rightBox {
|
|
display: inline-block;
|
|
padding-left: 20rpx;
|
|
color: #909399;
|
|
font-size: 12px;
|
|
width: 45%;
|
|
.title {
|
|
color: #303133;
|
|
font-size: 14px
|
|
|
|
}
|
|
}
|
|
.rightBox2 {
|
|
position: relative;
|
|
left: 0;
|
|
line-height: 100rpx;
|
|
color: $u-primary;
|
|
font-size: 24rpx;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
.price {
|
|
width: 100%;
|
|
height: 210rpx;
|
|
background: #fff;
|
|
position: fixed;
|
|
left: 0;
|
|
bottom: 98rpx;
|
|
padding: 20rpx;
|
|
.textBox {
|
|
font-size: 12px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
.text {
|
|
flex: 1;
|
|
display: flex;
|
|
// justify-content: space-around;
|
|
align-items: center;
|
|
margin: 0 15rpx;
|
|
}
|
|
.text2 {
|
|
flex: 2;
|
|
}
|
|
|
|
}
|
|
text {
|
|
color:$u-primary ;
|
|
}
|
|
}
|
|
.tui-tabbar {
|
|
width: 100%;
|
|
height: 98rpx;
|
|
background: #fff;
|
|
position: fixed;
|
|
left: 0;
|
|
bottom: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-end;
|
|
font-size: 26rpx;
|
|
box-shadow: 0 0 1px rgba(0, 0, 0, .3);
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
z-index: 996;
|
|
padding: 0 20rpx;
|
|
.tui-btn-mr {
|
|
margin-right: 30rpx;
|
|
}
|
|
}
|
|
</style>
|
|
|