Browse Source

开单

master
tianyi@bogon 3 years ago
parent
commit
b175889284
  1. 182
      pages/inventory/addinventory.vue
  2. 228
      pages/inventory/changeGoods1.vue

182
pages/inventory/addinventory.vue

@ -26,22 +26,27 @@
</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-box" style="border-top:5px solid #eee;" v-for="(value,key) in Array.from(carList)"
:key="key">
<view class="shop-name">
<img :src="item.productPicture" alt=""
<img :src="value[1].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 style="color:#FF5809;">品名:{{value[1].productName}}</view>
<view>货号:{{value[1].productSn}}</view>
<view>总价:{{value[1].price}} 数量:{{value[1].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 class="shop-collapse" v-for="(item,index) in value[1].saleDetailQueryDTO"
@tap="clickCollapse(key,index)">
<text>{{item.name}}</text>
<!-- <text style="color: red;">单价:¥{{item.price}}</text> -->
<text>数量:{{item.productCount}}</text>
</view>
<view class="" style="position: absolute;top:0;right:0;" @tap="clickCollapse(value[1].id)">
采购价
</view>
</view>
</view>
@ -115,7 +120,8 @@
single: ''
},
khName: [],
carList: [],
carList: new Map(),
lsList: new Map(),
remask: '',
otherPay: 0,
noPay: 0,
@ -128,37 +134,53 @@
}
},
onShow() {
let that = this;
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])
}
}
}
}
//this.carList1 //上个页回来的
//this.carList //这个页的最终数组
//this.lsList //这个页的规格数组
console.log(this.carList1)
for (let i = 0; i < this.carList1.length; i++) {
if (this.carList.size == 0) { //当前页没有数据
console.log("没有数据")
this.carList.set(this.carList1[i].id, this.carList1[i])
this.lsList.set(this.carList1[i].id, this.carList1[i].saleDetailQueryDTO)
} else { //当前页有数据
//商品id是相同的
if (that.carList.has(that.carList1[i].id) == true) {
console.log("商品相同")
that.lsList.get(that.carList1[i].id).forEach(function(value, key) {
for (let m = 0; m <= that.carList1[i].saleDetailQueryDTO.length; m++) {
if (value.name == that.carList1[i].saleDetailQueryDTO[m].name) {
console.log("规格相同")
that.lsList.get(that.carList1[i].id)[key].productCount = that.lsList.get(that
.carList1[i].id)[key].productCount + value.productCount
} else {
console.log('key', key)
console.log("规格不同")
console.log(that.carList1[i].saleDetailQueryDTO[m])
if (key + 1 == that.lsList.size) {
that.lsList.set(that.carList1[i].id, that.carList1[i].saleDetailQueryDTO[
m])
}
}
}
})
} else { //商品id不同
console.log("商品不同")
this.carList.set(this.carList1[i].id, this.carList1[i])
this.lsList.set(this.carList1[i].id, this.carList1[i].saleDetailQueryDTO)
}
}
}
console.log(this.carList)
console.log(lsList)
console.log('carList', this.carList)
console.log('lsList', this.lsList)
for (let i = 0; i < this.carList.length; i++) {
this.totalAmount += this.carList[i].num
this.shouldPay += this.carList[i].price
@ -219,22 +241,37 @@
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", {
let purchaseDetails = []
that.carList.forEach(function(value, key) {
for (let i=0;i<value.saleDetailQueryDTO.length;i++) {
let obj = {
purchasePrice: value.price,//进货价
productCount: value.num,
productId: key,
productName:value.productName,
productPicture: value.productPicture,
stockLogList:value.saleDetailQueryDTO
}
purchaseDetails.push(obj)
}
})
// 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/putInOfProduct", "post", {
purchase: purchase,
purchaseDetails: purchaseDetails
}, false, false).then((res) => {
@ -255,24 +292,31 @@
})
},
//编辑每一个的单价
clickCollapse(index, index1) {
clickCollapse(index) {
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
}
changePrice(val) {
let that = this;
that.shouldPay = 0
console.log(that.carList.get(that.index))
that.carList.get(that.index).price = val * that.carList.get(that.index).num;
that.carList.forEach(function(value, key) {
that.shouldPay += value.price
})
// this.carList.get(this.index)
// 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
// }
}
}
}

228
pages/inventory/changeGoods1.vue

@ -90,14 +90,14 @@
</view>
</li>
</ul>
<view class="checkList" v-for="item in Array.from(temporaryList)" :key="key">
<view class="checkList" v-for="item in temporaryList">
<view class="checkList-box">
{{item[0]}}
{{item.name}}
</view>
<uni-number-box v-model="item[1].productCount" @change="temporaryChange" />
<uni-number-box v-model="item.productCount" @change="temporaryChange" />
</view>
</view>
<view class="popup-bottom">
<view class="popup-bottom" v-for="item in temporaryList">
<view class="popup-bottom-left">
<text>数量:{{zNum}} 件</text>
<!-- <text>¥{{zPrice}}</text> -->
@ -171,22 +171,22 @@
temporaryNum: 0,
goodsDetail: [],
attrNameList: [],
temporaryList: new Map(),
carList: new Map(),
temporaryList: [],
carList: [],
columns: [],
keyList: [],
evalue: [],
attributeList: [],
purchasePrice: 0,
zPrice: 0,
zNum: 0,
storageType: 0,
carNum: 0,
carType: 0
purchasePrice: 0,
zPrice:0,
zNum:0,
storageType:0,
carNum:0,
carType:0
}
},
onLoad() {
this.getGategoryList()
this.getGategoryList()
this.storageType = uni.getStorageSync('type')
},
methods: {
@ -236,43 +236,46 @@
jishuqi++
}
}
// this.temporaryList = new Map();
if (this.goodsDetail.attributeList.length == jishuqi) {
let data = {}
this.attributeList = {
attributeList: JSON.stringify(obj),
productCount: this.temporaryNum,
name: name,
price: this.purchasePrice
productCount: this.temporaryNum,
name:name,
price:this.purchasePrice
}
for(let i=0;i<this.goodsDetail.attributeList.length;i++){
this.goodsDetail.attributeList[i].isChecked = false;
for (let m=0;m<this.goodsDetail.attributeList[i].value.length;m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
}
for (let i = 0; i < this.goodsDetail.attributeList.length; i++) {
this.goodsDetail.attributeList[i].isChecked = false;
for (let m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
if (this.temporaryList.length == 0) {
this.temporaryList.push(this.attributeList);
} else {
for (var i = 0; i < this.temporaryList.length; i++) {
if (this.temporaryList[i].name.indexOf(this.attributeList.name) != -1) {
this.temporaryList[i] = this.attributeList
return
} else {
if (this.temporaryList.length == (i+1)) {
this.temporaryList.push(this.attributeList);
return
}
}
}
}
// if (this.temporaryList.size == 0) {
this.temporaryList.set(name, this.attributeList);
// } else {
// console.log(this.carList)
// console.log(this.goodsDetail.id)
console.log(Array.from(this.temporaryList))
// if (this.carList.get(this.goodsDetail.id).saleDetailQueryDTO.has(this.attributeList.name)) {
// this.carList.get(this.goodsDetail.id).saleDetailQueryDTO.get(this.attributeList.name).value = this.attributeList
// } else {
// this.temporaryList.set(name, this.attributeList);
// // this.temporaryList.push(this.attributeList);
// }
// }
}
}
},
temporaryChange(val) {
temporaryChange(val) {
this.zNum = 0
for (var i = 0; i < this.temporaryList.length; i++) {
this.zNum += this.temporaryList[i].productCount
}
for (var i=0;i<this.temporaryList.length;i++) {
this.zNum += this.temporaryList[i].productCount
}
this.zPrice = this.zNum * this.purchasePrice
},
//点击底部选好了,返回上一页
@ -309,10 +312,10 @@
this.type = type
// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
if (type == 'carPopup') {
this.$refs.carPopup.open('bottom')
for (let i = 0; i < this.carList.length; i++) {
this.carNum += this.carList[i].num
}
this.$refs.carPopup.open('bottom')
for (let i=0;i<this.carList.length;i++) {
this.carNum += this.carList[i].num
}
this.carType = this.carList.length
} else {
this.checkGoods(item);
@ -380,78 +383,73 @@
},
//弹窗选择规格后,点击弹窗中选好了按钮
temporaryCheck() {
let that = this;
let data = {
id: this.goodsDetail.id,
price: this.zPrice,
num: this.zNum,
productName: this.goodsDetail.productName,
productSn: this.goodsDetail.productSn,
productPicture: this.goodsDetail.productPicture,
supplierName: this.goodsDetail.supplierName,
saleDetailQueryDTO: this.temporaryList
}
if(that.carList.has(that.goodsDetail.id)== true){ //新增的商品在list里面有了
console.log("有了")
console.log(that.carList.get(that.goodsDetail.id).saleDetailQueryDTO)
data.saleDetailQueryDTO.forEach (function(value, key) {
console.log(value)
console.log(key)
if(that.carList.get(that.goodsDetail.id).saleDetailQueryDTO.has(key) ==true){
console.log("有规格")
that.carList.get(that.goodsDetail.id).saleDetailQueryDTO.get(key).productCount += value.productCount
}else{
console.log("没有规格")
that.carList.get(that.goodsDetail.id).saleDetailQueryDTO.set(key,value)
// if(this.storageType == 0 && this.purchasePrice == 0){
// uni.showToast({
// title: "请输入采购价!",
// icon: 'none'
// })
// }else{
let data = {
id: this.goodsDetail.id,
price: this.zPrice,
num: this.zNum,
productName: this.goodsDetail.productName,
productSn: this.goodsDetail.productSn,
productPicture: this.goodsDetail.productPicture,
supplierName: this.goodsDetail.supplierName,
saleDetailQueryDTO:this.temporaryList
}
this.carList.push(data)
console.log(this.carList)
this.temporaryList = []
this.purchasePrice = 0
this.zPrice = ''
this.zNum = ''
for(let i=0;i<this.goodsDetail.attributeList.length;i++){
this.goodsDetail.attributeList[i].isChecked = false;
for (let m=0;m<this.goodsDetail.attributeList[i].value.length;m++) {
this.goodsDetail.attributeList[i].value[m].isChecked = false
}
})
console.log(that.carList.get(that.goodsDetail.id).saleDetailQueryDTO)
}else{ //商品在list中没有
this.carList.set(this.goodsDetail.id, data)
}
}
this.$refs.popup.close()
// }
console.log(this.carList)
console.log(this.carList)
this.temporaryList = new Map();
this.purchasePrice = 0
this.zPrice = ''
this.zNum = ''
this.$refs.popup.close()
},
//删除整条商品
delShop(id) {
var that = this;
for (let i = 0; i < this.carList.length; i++) {
if (this.carList[i].id == id) {
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
that.carList.splice(i, 1)
}
})
}
}
},
//删除商品下的某一个规格
delShopSpec(name) {
var that = this;
for (let i = 0; i < this.carList.length; i++) {
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) {
if (this.carList[i].saleDetailQueryDTO[m].name == name) {
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
that.carList[i].saleDetailQueryDTO.splice(m, 1)
if (that.carList[i].saleDetailQueryDTO.length == 0) {
that.carList.splice(i, 1)
}
}
})
}
}
}
},
//删除整条商品
delShop(id){
var that = this;
for (let i=0;i<this.carList.length;i++) {
if(this.carList[i].id == id){
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
that.carList.splice(i,1)
}
})
}
}
},
//删除商品下的某一个规格
delShopSpec(name){
var that = this;
for (let i=0;i<this.carList.length;i++) {
for (let m=0;m<this.carList[i].saleDetailQueryDTO.length;m++) {
if(this.carList[i].saleDetailQueryDTO[m].name == name){
uni.showModal({
title: "提示",
content: "确定删除此条商品吗?",
success: function(res) {
that.carList[i].saleDetailQueryDTO.splice(m,1)
if(that.carList[i].saleDetailQueryDTO.length == 0){
that.carList.splice(i,1)
}
}
})
}
}
}
}
}
}

Loading…
Cancel
Save