Browse Source

规格多选

master
wangfukang 3 years ago
parent
commit
4d18396bb5
  1. BIN
      pages/.DS_Store
  2. 375
      pages/billing/changeGoods1.vue
  3. 29
      pages/index/downStearmList.vue
  4. 1025
      pages/inventory/addinventory.vue
  5. 964
      pages/inventory/changeGoods1.vue

BIN
pages/.DS_Store

Binary file not shown.

375
pages/billing/changeGoods1.vue

@ -73,7 +73,8 @@
<view class="popup-title-right-box">{{goodsDetail.productSn}}</view> <view class="popup-title-right-box">{{goodsDetail.productSn}}</view>
</view> </view>
</view> </view>
<view class="popup-container"> <view class="popup-container" style="position: relative;">
<view @tap="saveCheck" style="position: absolute;top: 20rpx;right: 20rpx;color: #088FEB;text-decoration: underline;">保存已选</view>
<ul style="border-top:20rpx;"> <ul style="border-top:20rpx;">
<li v-for="(items,index) in goodsDetail.attributeList" :key="index"> <li v-for="(items,index) in goodsDetail.attributeList" :key="index">
<view class="title-fur"> <view class="title-fur">
@ -83,7 +84,7 @@
<uni-data-checkbox v-model="value" :localdata="range" <uni-data-checkbox v-model="value" :localdata="range"
@change="change"></uni-data-checkbox> @change="change"></uni-data-checkbox>
<text v-for="(itemTag, index1) in items.value" :key="index1" <text v-for="(itemTag, index1) in items.value" :key="index1"
@tap.stop="attrNameChange(index,index1) " @tap.stop="attrNameChange(index,itemTag.value,index1) "
:class="itemTag.isChecked ? 'checkedText' : '' "> {{itemTag.value}}</text> :class="itemTag.isChecked ? 'checkedText' : '' "> {{itemTag.value}}</text>
</view> </view>
</li> </li>
@ -192,7 +193,12 @@
productId:'', productId:'',
productNum:0, productNum:0,
height:0, height:0,
pecsList:[] pecsList:[],
pageOldTemList:[],
oldTemList:[],
goodsList:[],
newTemList:[],
dataObj :new Map()
} }
}, },
filters: { filters: {
@ -239,85 +245,155 @@
} }
}).catch((res) => {}) }).catch((res) => {})
}, },
//库存商品详情 combination(arr) {
getStockList(id) { let result = [
this.tui.request("/app/stock/productCount", "GET", { []
productId: id ]
}, false, true).then((res) => {
if (res.code == 200) { arr.map(x => {
this.pecsList = res.result var res = []
} else { result.map(y => {
this.tui.toast(res.message) x.specs.map(z => {
res.push([...y, z])
})
})
result = res
})
return result;
},
//保存已选
saveCheck(){
this.pageOldTemList = this.temporaryList
for(var i=0;i<this.goodsDetail.attributeList.length;i++){
this.goodsList[i].specs = []
for(var m=0;m<this.goodsDetail.attributeList[i].value.length;m++){
this.goodsDetail.attributeList[i].value[m].isChecked = false
} }
}).catch((res) => {}) }
}, },
attrNameChange(index, index1) { attrNameChange(index, data1,index1) {
this.goodsDetail.attributeList[index].isChecked = !this.goodsDetail.attributeList[index].isChecked;
// this.goodsDetail.attributeList[index].value.forEach(item => { this.goodsDetail.attributeList[index].value[index1].isChecked = !this.goodsDetail.attributeList[index].value[index1].isChecked;
// item.isChecked = false; if(this.goodsList[index].specs.indexOf(data1) != -1){
// }) this.goodsList[index].specs.splice(this.goodsList[index].specs.indexOf(data1),1)
this.goodsDetail.attributeList[index].isChecked = true; }else{
this.goodsDetail.attributeList[index].value[index1].isChecked = true; this.goodsList[index].specs.push(data1)
var name = '', }
evalue = [], let jishuqi = 0
obj = {} for(var i = 0; i < this.goodsList.length; i++){
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { if(this.goodsList[i].specs.length > 0){
for (var m = 0, Ien = this.goodsDetail.attributeList[i].value; m < Ien.length; m++) { jishuqi++
if (Ien[m].isChecked == true) { }
evalue.push(Ien[m].value) }
name += Ien[m].value + '/' var resultList = []
} if(jishuqi == this.goodsList.length){
}
} resultList = this.combination(this.goodsList);
this.keyList.map((item, index) => { }
obj[item] = evalue[index] var evalue = []
}) var value = []
let jishuqi = 0; for (var m = 0; m < resultList.length; m++) {
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { var name = ''
if (this.goodsDetail.attributeList[i].isChecked == true) { let value1 = "{"
jishuqi++ for (var j = 0; j < resultList[m].length; j++) {
} if(j != resultList[m].length - 1){
} name += resultList[m][j] + '/'
if (this.goodsDetail.attributeList.length == jishuqi) { value1 += '"'+this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '",'
this.tui.request("/app/stock/productCount", "post", { }else{
productId: this.productId, name += resultList[m][j]
attributeList: JSON.stringify(obj) value1 += '"'+this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '"'
}, false, true).then((res) => { }
if (res.code == 200) { }
this.productNum = res.result value1 += "}"
value.push(value1)
evalue.push(name)
}
if(jishuqi == 0){
this.oldTemList = []
}
if(this.temporaryList.length == 0){
if(jishuqi == this.goodsList.length){
for (var i = 0; i < value.length; i++) {
this.attributeList = { this.attributeList = {
attributeList: JSON.stringify(obj), attributeList: value[i],
productCount: this.temporaryNum, productCount: this.temporaryNum,
productNum:this.productNum, productNum:this.productNum,
name: name, name: evalue[i],
price: this.purchasePrice price: this.purchasePrice
} }
for (let i = 0; i < this.goodsDetail.attributeList.length; i++) { this.temporaryList.push(this.attributeList);
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 }else{
} let newProductCount = 0;
for (var i = 0; i < value.length; i++) {
for (var m = 0; m < this.temporaryList.length; m++) {
if(this.temporaryList[m].attributeList == value[i]){
newProductCount = this.temporaryList[m].productCount
} }
if (this.temporaryList.length == 0) { }
this.temporaryList.push(this.attributeList); this.attributeList = {
} else { attributeList: value[i],
for (var i = 0; i < this.temporaryList.length; i++) { productCount: newProductCount,
if (this.temporaryList[i].name.indexOf(this.attributeList.name) == -1 || this.temporaryList[i].name.indexOf(this.attributeList.name) == 1) { productNum:this.productNum,
if (this.temporaryList.length == (i + 1)) { name: evalue[i],
this.temporaryList.push(this.attributeList); price: this.purchasePrice
return }
}
} else { this.newTemList.push(this.attributeList);
return newProductCount = 0;
} }
} for (var i = 0; i < this.oldTemList.length; i++) {
let oldAttributeList = '';
let oldProductCount = '';
let notChcek = true;
for (var m = 0; m < this.newTemList.length; m++) {
if(this.oldTemList[i].attributeList == this.newTemList[m].attributeList){
this.newTemList[m].productCount = this.oldTemList[i].productCount
notChcek = false;
} }
} else {
this.tui.toast(res.message)
} }
}).catch((res) => {}) if(this.newTemList.length > 0 && notChcek){
this.newTemList.push(this.oldTemList[i]);
}
}
for (var i = 0; i < this.pageOldTemList.length; i++) {
let oldAttributeList = '';
let oldProductCount = '';
let notChcek = true;
for (var m = 0; m < this.newTemList.length; m++) {
if(this.pageOldTemList[i].attributeList == this.newTemList[m].attributeList){
this.newTemList[m].productCount = this.pageOldTemList[i].productCount
notChcek = false;
}
}
if(this.newTemList.length > 0 && notChcek){
this.newTemList.push(this.pageOldTemList[i]);
}
}
}
this.$nextTick(()=>{
for(var i=0;i<this.temporaryList.length;i++){
for(var m=0;m<this.pecsList.length;m++){
if(this.temporaryList[i].attributeList == this.pecsList[m].attributeList){
this.temporaryList[i].productNum = this.pecsList[m].stockCount
}
}
}
})
if(jishuqi != this.goodsList.length){
if(this.oldTemList.length ==0 && this.pageOldTemList.length ==0){
this.newTemList = []
this.temporaryList = []
}
}
if(this.newTemList.length != 0 && jishuqi == this.goodsList.length){
this.temporaryList = this.newTemList;
this.oldTemList = []
this.newTemList = []
} }
}, },
@ -387,52 +463,117 @@
}, },
//选择商品查询商品规格 //选择商品查询商品规格
checkGoods(item) { checkGoods(item) {
this.goodsDetail = item; let that = this;
this.temporaryList = [] this.goodsDetail = item;
this.columns = [] this.temporaryList = []
this.keyList = [] this.columns = []
if (this.carList != '') { this.keyList = []
this.zNum = 0 if (this.carList != '') {
for (let i = 0; i < this.carList.length; i++) { this.zNum = 0
for (let i = 0; i < this.carList.length; i++) {
if (item.id == this.carList[i].id) {
this.zNum = this.carList[i].num if (item.id == this.carList[i].id) {
this.temporaryList = this.carList[i].saleDetailQueryDTO this.zNum = this.carList[i].num
} this.temporaryList = this.carList[i].saleDetailQueryDTO
} this.pageOldTemList = this.carList[i].saleDetailQueryDTO
this.oldTemList = this.carList[i].saleDetailQueryDTO
}
}
} }
this.getStockList(this.goodsDetail.id) this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", {
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { categoryId: this.goodsDetail.categoryId
categoryId: this.goodsDetail.categoryId }, false, true).then((res1) => {
}, false, true).then((res1) => { if (res1.code == 200) {
if (res1.code == 200) { if (typeof(res1.result) == 'string') {
if (typeof(res1.result) == 'string') { let newObj = JSON.parse(res1.result)
let newObj = JSON.parse(res1.result) let newArr = []
let newArr = [] let dataArr = []
for (let val in newObj) { for (let val in newObj) {
let valueObj = []; let valueObj = [];
for (var i = 0; i < newObj[val].length; i++) { let isTrue = false
valueObj.push({ for (var i = 0; i < newObj[val].length; i++) {
value: newObj[val][i], for (var m = 0; m < this.oldTemList.length; m++) {
isChecked: false var data = this.oldTemList[m].name.split('/')
}) for(var j = 0; j < data.length; j++){
} if(data[j] == newObj[val][i]){
newArr.push({ isTrue = true
name: val, }
value: valueObj }
}) }
} for (var m = 0; m < this.pageOldTemList.length; m++) {
this.goodsDetail.attributeList = newArr; var data = this.pageOldTemList[m].name.split('/')
this.goodsDetail.attributeList.forEach((item, index) => { for(var j = 0; j < data.length; j++){
this.columns[index] = item.value; if(data[j] == newObj[val][i]){
this.keyList[index] = item.name; isTrue = true
}) }
} }
}
} else { valueObj.push({
this.tui.toast(res.message) value: newObj[val][i],
} isChecked: isTrue
}).catch((res) => {}) })
that.dataObj.set(newObj[val][i],val)
isTrue = false
}
newArr.push({
name: val,
value: valueObj
})
}
console.log(that.dataObj)
this.goodsDetail.attributeList = newArr;
this.goodsDetail.attributeList.forEach((item, index) => {
this.columns[index] = item.value;
this.keyList[index] = item.name;
})
console.log('看看看看',this.goodsDetail.attributeList)
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) {
let oldCheck = false
let oldValue = []
for (var m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) {
if(this.goodsDetail.attributeList[i].value[m].isChecked == true){
oldCheck = true
oldValue.push(this.goodsDetail.attributeList[i].value[m].value)
}
}
if(oldCheck){
let specs1 = {
specs:[]
}
specs1.specs = oldValue
this.goodsList.push(specs1)
}else{
let specs1 = {
specs:[]
}
this.goodsList.push(specs1)
}
oldCheck = false
oldValue = []
}
console.log(this.goodsList)
}
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
this.getKCList(item.id);
},
//库存商品详情
getKCList(id) {
this.tui.request("/app/stock/productCount", "GET", {
productId: id
}, false, true).then((res) => {
if (res.code == 200) {
this.pecsList = res.result
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
}, },
//顶部搜索框 //顶部搜索框
search(res) { search(res) {

29
pages/index/downStearmList.vue

@ -985,21 +985,24 @@
} }
.attrs { .attrs {
text { text {
display: inline-block; display: inline-block;
border: 1px solid #5fd9ee; border: 1px solid #5fd9ee;
margin: 20rpx; margin: 20rpx;
background-color: #fff; background-color: #fff;
color: #5fd9ee; color: #5fd9ee;
width: 100rpx; padding: 0 10px;
line-height: 70rpx; min-width: 100rpx;
height: 70rpx; line-height: 35px;
text-align: center; height: 70rpx;
text-align: center;
border-radius: 20rpx;
} }
.checkedText { .checkedText {
background-color: $u-primary; background-color: #5fd9ee;
color: #fff; color: #fff;
border-radius: 20rpx;
} }
} }
</style> </style>

1025
pages/inventory/addinventory.vue

File diff suppressed because it is too large

964
pages/inventory/changeGoods1.vue

File diff suppressed because it is too large
Loading…
Cancel
Save