平板端快衣店
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.
 
 
 
 
 

470 lines
12 KiB

<!-- 新增库存页 -->
<template>
<view class="page1">
<view class="content">
<view class="content-box">
<view class="content-list">
<view class="list-name">供应商</view>
<view class="list-val">
<input type="text" placeholder="请选择供应商" disabled
style="border-bottom: 1px solid #fff;text-align: center;" :value="khName.consigneeName"
@tap="goPopleList('gysName')">
<uni-icons type="right" size="16" style="margin-left: 80rpx;line-height: 80rpx;"></uni-icons>
</view>
</view>
</view>
<view class="content-box">
<view class="shop-box" style="border-bottom: 1px solid #eee;margin-bottom: 20rpx;">
<u-grid :col="2" border>
<u-grid-item index="add" @tap.stop="scanCodeAdd">
<u-icon name="scan" size="36"></u-icon>
<text>扫一扫</text>
</u-grid-item>
<u-grid-item @tap.stop="goodsAdd">
<u-icon name="plus" size="28"></u-icon>
<text>添加商品</text>
</u-grid-item>
</u-grid>
</view>
<view class="shop-box" style="border-top:5px solid #eee;" v-for="(item,index) in carList" :key="item">
<view class="shop-name">
<img :src="item.productPicture" alt=""
style="width: 140rpx;height: 140rpx;margin: 30rpx 0 0 30rpx;">
<view class="shop-productName">
<view style="color:#FF5809;">品名:{{item.productName}}</view>
<view>货号:{{item.productSn}}</view>
<view>总价:{{item.price}} 数量:{{item.num}}</view>
</view>
</view>
<view class="shop-type">
<view class="shop-collapse" v-for="(items,index1) in item.saleDetailQueryDTO"
@tap="clickCollapse(index,index1)">
<text>{{items.name}}</text>
<text style="color: red;">单价:¥{{items.price}}</text>
<text>数量:{{items.productCount}}</text>
</view>
</view>
</view>
</view>
<view class="content-box">
<!-- 账号权限是否可以维护成本价格(主账号和被授权的账号可以维护),参数名:shop_admin_cost,维护在用户表中,存在前后端缓存里,把备注栏挪出来,谁都可以备注 -->
<view class="price-box-list">
<view class="content-list">
<view class="list-name">应付金额</view>
<view class="list-val">
<input type="text" v-model="shouldPay">
</view>
</view>
<view class="content-list">
<view class="list-name">已付金额</view>
<view class="list-val">
<input type="text" v-model="alreadyPay" @blur="changePay">
</view>
</view>
<view class="content-list">
<view class="list-name">欠款</view>
<view class="list-val">
<input type="text" v-model="noPay" disabled>
</view>
</view>
<view class="content-list">
<view class="list-name">其他费用</view>
<view class="list-val">
<input type="text" v-model="otherPay">
</view>
</view>
<view class="content-list">
<view class="list-name">备注</view>
<view class="">
<textarea v-model="remask" />
</view>
</view>
</view>
</view>
</view>
<view class="bottom-box">
<view class="bottom-left">
<text>合计:{{totalAmount}}</text>
<text style="color: #ffa200;">¥{{shouldPay}}</text>
</view>
<view class="bottom-right">
<button class="bottom-btn" @tap='inventorySubmit'>入库</button>
</view>
</view>
<!-- 弹出输入框 -->
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog ref="inputClose" mode="input" title="采购价" placeholder="请输入采购价"
@confirm="changePrice"></uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
import {
mapState
} from 'vuex';
export default {
computed: mapState(['shopName']),
data() {
return {
// 表单数据
formData: {
name: '',
manufacturer: '',
price: '',
single: ''
},
khName: [],
carList: [],
remask: '',
otherPay: 0,
noPay: 0,
alreadyPay: 0,
realAmount: 0,
shouldPay: 0,
totalAmount: 0,
index: '',
index1: ''
}
},
onShow() {
this.khName = JSON.parse(JSON.stringify(this.khName)) || ''
let lsList = this.carList;
if (lsList.length == 0) {
this.carList = this.carList1 || []
} else { //111 222
for (var i = 0; i < lsList.length; i++) {
for (var s = 0; s < lsList[i].saleDetailQueryDTO.length; s++) {
for (var m = 0; m < this.carList1.length; m++) {
if (lsList[i].id == this.carList1[m].id) { //是相同商品
for (var v = 0; v < this.carList1[m].saleDetailQueryDTO.length; v++) { //不是相同规格
if (lsList[i].saleDetailQueryDTO[s].name != this.carList1[m].saleDetailQueryDTO[v].name) {
//已经是最后一项循环
if (s + 1 == lsList[i].saleDetailQueryDTO.length) {
this.carList[i].saleDetailQueryDTO.push(this.carList1[m].saleDetailQueryDTO[v])
}
} else { //是相同规格
this.carList[i].saleDetailQueryDTO[s].productCount += this.carList1[m].saleDetailQueryDTO[v].productCount
}
}
}else{
if (i + 1 == lsList.length) { //已经是最后一项循环
this.carList.push(this.carList1[m])
}
}
}
}
}
}
console.log(this.carList)
console.log(lsList)
for (let i = 0; i < this.carList.length; i++) {
this.totalAmount += this.carList[i].num
this.shouldPay += this.carList[i].price
}
this.noPay = this.shouldPay
},
onLoad() {
},
methods: {
scanCodeAdd() {
uni.scanCode({
success: (res) => {
uni.showToast({
title: res.result,
icon: 'none'
})
},
fail: (res) => {
uni.showToast({
title: '扫描失败',
icon: 'none'
})
}
})
},
goodsAdd() {
uni.navigateTo({
url: "/pages/inventory/changeGoods1"
})
},
//计算欠款
changePay() {
this.noPay = this.shouldPay - this.alreadyPay
},
//跳转选择供应商
goPopleList(popleType) {
uni.navigateTo({
url: '/pages/index/peopleList?popleType=' + popleType
})
},
inventorySubmit() {
console.log(this.khName)
console.log(this.carList)
if (this.khName == '' || this.carList == '') {
uni.showToast({
title: "信息填写完成后入库!",
icon: 'none'
})
}
let that = this;
let purchase = {
alreadyPay: this.alreadyPay, //已付金额
noPay: this.noPay, //欠款
shouldPay: this.shouldPay, //应付金额
totalAmount: this.totalAmount, //总数量
remask: this.remask,
supplierId: this.khName.id, //供应商id和姓名
supplierName: this.khName.consigneeName
}
let purchaseDetails = []
for (let i = 0; i < this.carList.length; i++) {
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) {
let obj = {
allPrice: this.carList[i].saleDetailQueryDTO[m].price * this.carList[i].saleDetailQueryDTO[
m].productCount,
attributeList: this.carList[i].saleDetailQueryDTO[m].attributeList,
productCount: this.carList[i].saleDetailQueryDTO[m].productCount,
productId: this.carList[i].id,
purchasePrice: this.carList[i].saleDetailQueryDTO[m].price, //进货价
}
purchaseDetails.push(obj)
}
}
this.tui.request("/app/stock/putIn", "post", {
purchase: purchase,
purchaseDetails: purchaseDetails
}, false, false).then((res) => {
if (res.code == 200) {
uni.showToast({
title: "入库成功",
icon: 'none'
})
uni.navigateBack({
delta: 2
})
} else {
uni.showToast({
title: "入库失败",
icon: 'none'
})
}
})
},
//编辑每一个的单价
clickCollapse(index, index1) {
this.index = index
this.index1 = index1
this.$refs.inputDialog.open()
},
//计算价格
changePrice(val) {
this.shouldPay = 0
this.carList[this.index].price = 0
this.carList[this.index].saleDetailQueryDTO[this.index1].price = val;
console.log(this.carList)
for (let m = 0; m < this.carList[this.index].saleDetailQueryDTO.length; m++) {
this.carList[this.index].price += this.carList[this.index].saleDetailQueryDTO[m].productCount * this
.carList[this.index].saleDetailQueryDTO[m].price
}
for (let i = 0; i < this.carList.length; i++) {
this.shouldPay += this.carList[i].price
}
}
}
}
</script>
<style lang="scss" scoped>
page,
.page1 {
height: 100%;
}
.content {
border-top: 1px solid #eee;
overflow-y: scroll;
max-height: 100vh;
}
.content-box {
width: 100%;
height: auto;
background: #fff;
margin-bottom: 20rpx;
}
.content-list {
width: 95%;
margin: 0 auto;
display: flex;
height: 80rpx;
border-bottom: 1px solid #eee;
}
.content-list:last-child {
border-bottom: none;
height: auto;
}
.list-name {
width: 200rpx;
text-align: left;
line-height: 40px;
height: 80rpx;
padding-left: 20rpx;
}
.list-val {
width: 560rpx;
height: 80rpx;
line-height: 80rpx;
}
.list-val input {
width: 400rpx;
height: 60rpx;
display: inline-block;
line-height: 60rpx;
float: left;
margin-top: 10rpx;
padding-left: 20rpx;
border-bottom: 1px solid #088FEB;
}
.uni-data-select {
width: 80%;
text-align: center;
}
.uni-select {
border: none !important;
border-radius: 0 !important;
}
.uni-select__input-placeholder {
color: #6a6a6a;
font-size: 28rpx !important;
width: 400rpx;
}
.uni-select__input-box {
.uni-icons {
margin-left: 100rpx;
}
}
.shop-box {
width: 95%;
margin: 0 auto;
}
.shop-name {
width: 100%;
height: 200rpx;
line-height: 80rpx;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
font-size: 28rpx;
font-weight: bold;
display: flex;
}
.shop-name {
.uni-icons {
color: #088FEB !important;
}
}
.shop-productName {
flex: 1;
display: flex;
flex-direction: column;
padding-left: 20rpx;
}
.shop-productName view {
height: 55rpx;
}
.shop-collapse {
display: flex;
height: 80rpx;
font-size: 26rpx;
line-height: 80rpx;
}
.shop-collapse text {
flex: 1;
text-align: center;
padding-right: 40rpx;
border-right: 1px solid #eee;
}
.price-box-title {
width: 95%;
height: 80rpx;
line-height: 80rpx;
margin: 0 auto;
display: flex;
text-align: center;
border-bottom: 1px solid #eee;
}
.price-box-title text {
flex: 1;
}
.uni-list-cell {
display: flex;
margin-right: 20rpx;
}
.bottom-box {
width: 100%;
position: absolute;
bottom: 0rpx;
display: flex;
background: #fff;
border-top: 1px solid #eee;
height: 110rpx;
}
.bottom-left {
flex: 1;
height: 110rpx;
line-height: 110rpx;
}
.bottom-right {
flex: 1;
height: 110rpx;
line-height: 110rpx;
}
.bottom-left text {
line-height: 84rpx;
display: inline-block;
padding-left: 20rpx;
}
.bottom-btn {
width: 320rpx;
background: linear-gradient(90deg, #60F3FF, #088FEB);
color: #fff;
border-radius: 50rpx;
height: 85rpx;
margin-top: 15rpx;
}
textarea {
margin: 20rpx;
border: 1px solid #eee;
height: 150rpx;
width: 500rpx;
}
</style>