wangfukang 1 month ago
parent
commit
cf9315ba53
  1. 90
      package1/myCenter/addGoods.vue
  2. 324
      package1/myCenter/attributeList.vue

90
package1/myCenter/addGoods.vue

@ -171,6 +171,7 @@
formData: {
id: '',
shopId: '',
attrId:'',
categoryId: '', //id
categoryName: '', //
productPicture: '', //
@ -212,6 +213,7 @@
},
onShow() {
this.attrId = uni.getStorageSync('attrId');
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
uni.authorize({
scope: 'scope.writePhotosAlbum',
@ -230,7 +232,7 @@
},
onLoad(option) {
this.getGategoryList()
if (option.dataList) {
if (option.dataList != undefined && option.dataList != null && option.dataList != 'undefined') {
this.dataList = JSON.parse(option.dataList)
this.tui.request("/app/product/getById/" + this.dataList.id, "POST", {
@ -640,73 +642,69 @@
})
},
checkSpec(type){
let that = this
this.$refs.addTypeDialog.open()
this.modalclassType = type
this.tui.request("/dictData/getByCondition", "GET", {
name: "",
status: "",
pageNumber: 1,
pageSize: 100000,
sort: 'sortOrder',
order: 'asc',
dictId: '2026945661353725952'
}, false, true).then((res) => {
if(res.code == 200){
this.categoryData = res.result.content
for (var i = 0; i < this.categoryData.length; i++) {
if (i == this.categoryIndex) {
this.categoryData[i].parentId = true
that.tui.request("/app/productAttribute/selectByCategoryId", "post", {categoryId:that.attrId}, false, true).then((res) => {
if (res.code == 200) {
that.categoryData = res.result
for (var i = 0; i < that.categoryData.length; i++) {
that.categoryData[i].title = that.categoryData[i].attributeName
if (i == that.categoryIndex) {
that.categoryData[i].parentId = true
} else {
this.categoryData[i].parentId = false
that.categoryData[i].parentId = false
}
}
//parent
this.typeToAttrName = res.result.content[this.categoryIndex].title
that.typeToAttrName = res.result[that.categoryIndex].title
// canbuy
this.currentCanbuy = this.canbuyMap[this.typeToAttrName] || 1
this.getCateGorySon(res.result.content[this.categoryIndex].id)
that.currentCanbuy = that.canbuyMap[that.typeToAttrName] || 1
that.getCateGorySon(res.result[that.categoryIndex].id)
} else {
this.tui.toast(res.message)
}
}).catch(() => {});
}).catch((res) => {})
},
getCateGorySon(id){
this.tui.request("/dictData/getByCondition", "GET", {
name: "",
status: "",
pageNumber: 1,
pageSize: 100000,
sort: 'sortOrder',
order: 'asc',
dictId: id
let that = this
that.tui.request("/app/productAttributeValue/selectByAttributeId", "get", {
id: id,
}, false, true).then((res) => {
if(res.code == 200){
this.categorySonData = res.result.content
// checkedfalseVue
console.log("111111",this.specValueArr)
console.log("22222",this.attrValueArr)
for (var i = 0; i < this.categorySonData.length; i++) {
this.$set(this.categorySonData[i], 'checked', false)
if (res.code == 200) {
that.categorySonData = res.result
for (var i = 0; i < that.categorySonData.length; i++) {
that.categorySonData[i].title = that.categorySonData[i].value
that.$set(that.categorySonData[i], 'checked', false)
}
if(this.modalclassType == 'shuxing'){
for (var i = 0; i < this.categorySonData.length; i++) {
for (var m = 0; m < this.attrValueArr.length; m++) {
if(this.attrValueArr[m].title == this.categorySonData[i].title && this.attrValueArr[m].parentName == this.typeToAttrName){
this.$set(this.categorySonData[i], 'checked', true)
if(that.modalclassType == 'shuxing'){
for (var i = 0; i < that.categorySonData.length; i++) {
for (var m = 0; m < that.attrValueArr.length; m++) {
if(that.attrValueArr[m].title == that.categorySonData[i].title && that.attrValueArr[m].parentName == that.typeToAttrName){
that.$set(that.categorySonData[i], 'checked', true)
}
}
}
}else{
//guige
for (var i = 0; i < this.categorySonData.length; i++) {
for (var m = 0; m < this.specValueArr.length; m++) {
if(this.specValueArr[m].id == this.categorySonData[i].id){
this.$set(this.categorySonData[i], 'checked', true)
for (var i = 0; i < that.categorySonData.length; i++) {
for (var m = 0; m < that.specValueArr.length; m++) {
if(that.specValueArr[m].id == that.categorySonData[i].id){
that.$set(that.categorySonData[i], 'checked', true)
}
}
}
}
this.$forceUpdate()
console.log()
that.$forceUpdate(that.categorySonData)
that.$forceUpdate(that.categoryData)
} else {
uni.showToast({
title: "删除失败",
icon: 'none'
})
}
}).catch(() => {});
}).catch((res) => {})
},
deldantiaoguige(index){
for (var m = 0; m < this.specValueArr.length; m++) {

324
package1/myCenter/attributeList.vue

@ -6,69 +6,79 @@
<uni-icons type="left" size="28"></uni-icons>
</view>
<view class="title-name" :style="{'padding-top': menuButtonInfo.top +'px'}">
代买饭
规格管理
</view>
</view>
</view>
<view style="width: 100%;position: fixed;bottom: 10px;background: #fff;z-index: 99;">
<button size="default" type="default" @tap="inputDialogToggle('add')" hover-class="is-hover">添加分类</button>
<button size="default" type="default" @tap="inputDialogToggle('add')" hover-class="is-hover">添加规格</button>
</view>
<view class="card-list">
<ul>
<li v-for="(item, index) in indexList" :key="index" @tap="clickList(item)">
<view class="name">
<text>{{item.categoryName}}</text>
<u-icon name="edit-pen-fill" size="22" v-if="item.categoryName != '默认分类'" @tap.stop="inputDialogToggle('edit', item)"></u-icon>
<text>{{item.attributeName}}</text>
<u-icon name="edit-pen-fill" size="22" v-if="item.attributeName != '默认规格'" @tap.stop="inputDialogToggle('edit', item)"></u-icon>
</view>
<button class="bj-btn" @tap.stop="goGategoryLow(item.id)">编辑规格</button>
<button class="bj-btn" @tap.stop="goGategoryLow(item)">管理属性</button>
</li>
</ul>
</view>
<u-modal :show="show" :title="'删除'" :content="'是否确认删除此分类?'" showCancelButton="true" @cancel="show = false"
<u-modal :show="show" :title="'删除'" :content="'是否确认删除此规格?'" showCancelButton="true" @cancel="show = false"
@confirm="delItemModal"></u-modal>
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog ref="inputClose" mode="input" :title="dialogTit" :value="inputVal" placeholder="请输入名称"
@confirm="dialogInputConfirm" @close="dialogClose">
</uni-popup-dialog>
</uni-popup>
<uni-popup ref="delDialog" type="dialog">
<view class="type-popup" style="width:100%;margin-bottom: 0;border-radius: 0;height: 650rpx;border-radius: 10px;">
<view style="height: 120rpx;font-size: 36rpx;font-weight: bold;line-height: 120rpx;text-align: center;">
编辑分类
</view>
<view style="height: 80rpx;font-size: 28rpx;line-height: 80rpx;text-align: center;">
请在下方输入框中输入分类名
</view>
<view style="width: 90%;margin: 40rpx auto 0;">
分类名称
<uni-easyinput type="text" v-model="inputVal" @blur="handleBlur" placeholder="请输入规格值" />
</view>
<view style="width: 90%;margin: 40rpx auto 0;">
排序<uni-easyinput type="text" v-model="sortTextEdit" @blur="handleBlurSort" placeholder="可设置排序" />
<uni-popup ref="delDialog" background-color="#fff">
<view class="add-popup-content">
<view class="add-popup-title">
<text>编辑规格</text>
<uni-icons @tap='close' type="closeempty" color='red' size="16"
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
</view>
<view style="width: 100%;height: 90rpx;line-height: 90rpx;text-align: center;border-radius: 0;color: #fff;display: flex;position: absolute;bottom: 0;">
<view style="flex: 1;background: linear-gradient(90deg, #60F3FF, #088FEB);" v-if="inputVal != '默认分类'" @tap="dialogDel">删除</view>
<view style="flex: 1;background: linear-gradient(90deg, #FF9797, #FFC1E0);" @tap="dialogInputConfirm">确认</view>
<view class="add-popup-container">
<view style="width: 90%;margin: 40rpx auto 0;">
规格名称
<uni-easyinput type="text" v-model="inputVal" @blur="handleBlur" placeholder="请输入规格值" />
</view>
<view style="width: 100%;height: 90rpx;line-height: 90rpx;text-align: center;border-radius: 0;color: #fff;display: flex;position: absolute;bottom: 0;">
<view style="flex: 1;background: linear-gradient(90deg, #60F3FF, #088FEB);" v-if="inputVal != '默认规格'" @tap="dialogDel">删除</view>
<view style="flex: 1;background: linear-gradient(90deg, #FF9797, #FFC1E0);" @tap="dialogInputConfirm">确认</view>
</view>
<!-- <ul>
<li v-for="(item,index) in defaultList" :key="index">
<view class="title-fur">
<view class="name">{{item.name}}</view>
<u-icon size="20" name="plus" color="#5fd9ee"
@tap="toggle(index) "></u-icon>
</view>
<view class="content-fur">
<view class="content-low" :class="item1.checked?'checked':''" v-for="(item1,index1) in item.list" :key="index1"
@tap.stop="addMultipleType(item,item1.value,index1)">{{item1.value}}</view>
</view>
</li>
</ul> -->
</view>
</view>
</uni-popup>
<!-- 添加分类弹出层 -->
<!-- 添加规格弹出层 -->
<uni-popup ref="addTypeDialog" background-color="#fff">
<view class="add-popup-content">
<view class="add-popup-title">
<text>新增分类</text>
<text>新增规格</text>
<uni-icons @tap='close' type="closeempty" color='red' size="16"
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
</view>
<view class="add-popup-container">
<view>
<text style="color:red;font-size:22rpx;">*您可以点击默认项快捷添加分类,如没有想要的快捷项可以手动输入</text>
<text style="color:red;font-size:22rpx;">*您可以点击默认项快捷添加规格,如没有想要的快捷项可以手动输入</text>
</view>
<input type="text" v-model="typeText" style="width: 100%;border: 1px solid #eee;height: 80rpx;padding-left: 20rpx;margin:20rpx 0;font-size: 25rpx;line-height: 80rpx;"
placeholder="请输入分类名称">
<input type="text" v-model="sortText" style="width: 100%;border: 1px solid #eee;height: 80rpx;padding-left: 20rpx;margin:20rpx 0;font-size: 25rpx;line-height: 80rpx;"
placeholder="可设置分类排序">
<ul>
placeholder="请输入规格名称">
<!-- <ul>
<li v-for="(item,index) in defaultList" :key="index">
<view class="title-fur">
<view class="name">{{item.name}}</view>
@ -80,20 +90,47 @@
@tap.stop="addMultipleType(item,item1.value,index1)">{{item1.value}}</view>
</view>
</li>
</ul>
</ul> -->
<view class="add-popup-bottom">
<view class="add-popup-btn" @tap="dialogInputConfirm(typeText)">确认</view>
</view>
</view>
</view>
</uni-popup>
<uni-popup ref="attrValueDialog" background-color="#fff">
<view class="add-popup-content">
<view class="add-popup-title">
<text>管理属性</text>
<uni-icons @tap='close' type="closeempty" color='red' size="16"
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
</view>
<view class="add-popup-container">
<view>
<text style="color:red;font-size:22rpx;">*您可以点击默认项快捷添加属性,如没有想要的快捷项可以手动输入</text>
</view>
<u-icon size="20" name="plus" color="#5fd9ee"
@tap="toggle() "></u-icon>
<ul>
<li v-for="(item,index) in defaultList" :key="index">
<view class="title-fur">
<view class="name">{{item.value}}</view>
<view style="flex: 1;background: linear-gradient(90deg, #60F3FF, #088FEB);" v-if="inputVal != '默认规格'" @tap="editValue(item)">修改</view>
<view style="flex: 1;background: linear-gradient(90deg, #60F3FF, #088FEB);" v-if="inputVal != '默认规格'" @tap="delValue(item)">删除</view>
</view>
</li>
</ul>
</view>
</view>
</uni-popup>
<!-- 查看商品库存弹出层 -->
<uni-popup ref="carPopup" background-color="#fff">
<view class="popup-content" style="height:auto !important;">
<view style="font-size: 36rpx;font-weight: bold;text-align: center;">提示</view>
<view v-if="goodsList !=''"
style="width:100%;font-weight:bold;text-align: center;font-size: 28rpx;margin: 20rpx 0;">
{{goodsList[0].productName}}分类下有以下库存确认继续删除吗
{{goodsList[0].productName}}规格下有以下库存确认继续删除吗
</view>
<view class="tui-order-item boxbg">
<view style="display: flex;border-bottom: 1px solid #eee;height: 50rpx;line-height: 50rpx;">
@ -124,8 +161,14 @@
</view>
</uni-popup>
<uni-popup ref="addDialog" type="dialog">
<uni-popup-dialog ref="addClose" mode="input" :title="'请输入规格名'" :value="specVal" placeholder="请输入规格名称"
@confirm="addSpec" @close="dialogClose">
<uni-popup-dialog
ref="addClose"
mode="input"
:title="'请输入属性名'"
v-model="specVal"
placeholder="请输入属性名称"
@confirm="addSpec"
@close="dialogClose">
</uni-popup-dialog>
</uni-popup>
</view>
@ -148,7 +191,7 @@
isOpenId: '',
delType: '',
goodsList: [],
dialogTit: '输入分类名',
dialogTit: '输入规格名',
typeText:'',
sortText:'',
sortTextEdit:'',
@ -279,6 +322,9 @@
checked:false
}]
}],
attrId:'',
valueEditId:'',
isEdieValue:false,
multipleList:[]
}
},
@ -298,21 +344,34 @@
}
},
onShow() {
this.attrId = uni.getStorageSync('attrId');
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.getGategoryList()
},
methods: {
//
getGategoryList() {
this.tui.request("/dictData/getByCondition", "get", {
name: "",
status: "",
pageNumber: 1,
pageSize: 100000,
sort: sortOrder,
order: asc,
dictId: 2026945661353725952
editValue(item){
this.isEdieValue = true
this.valueEditId = item.id
this.specVal = item.value
this.$refs.addDialog.open()
},
delValue(item){
this.tui.request("/app/productAttributeValue/delById", "post", {
id: item.id
}, false, true).then((res) => {
if (res.code == 200) {
this.tui.toast("删除成功")
this.goGategoryLow(this.editItem)
this.$forceUpdate()
} else {
this.tui.toast("添加失败")
}
}).catch((res) => {})
},
//
getGategoryList() {
this.tui.request("/app/productAttribute/selectByCategoryId", "post", {categoryId:this.attrId}, false, true).then((res) => {
if (res.code == 200) {
this.indexList = res.result;
} else {
@ -324,14 +383,13 @@
inputDialogToggle(type, item, parent) {
this.typeModel = type;
if (type == 'edit') {
this.inputVal = item.categoryName;
this.inputVal = item.attributeName;
this.editItem = item;
this.sortTextEdit = (this.editItem.sort == null || this.editItem.sort == 'null') ? '' : this.editItem.sort
this.$refs.delDialog.open('bottom')
} else if (type == 'add') {
this.inputVal = '';
this.isOpenId = item;
this.dialogTit = '输入分类名'
this.dialogTit = '输入规格名'
this.$refs.addTypeDialog.open('bottom')
}
@ -345,7 +403,7 @@
handleBlurSort(e){
this.sortTextEdit = e.detail.value
},
//
//
getTypeToNum(id) {
let that = this;
this.tui.request("/app/stock/getlistByAttributeList", "post", {
@ -363,7 +421,7 @@
if (res1.result.length > 0) {
uni.showModal({
title: "提示",
content: "此分类已经维护了子分类,确定继续删除吗?",
content: "此规格已经维护了子规格,确定继续删除吗?",
success: function(res2) {
if (res2.confirm) {
that.delItemModal()
@ -391,26 +449,50 @@
back() {
uni.navigateBack()
},
toggle(index){
this.addIndex = index
toggle(){
this.specVal = ''
this.isEdieValue = false
this.$refs.addDialog.open()
},
addSpec(e){
let data = {
value:e,
checked:false
let that = this;
if(this.isEdieValue){
that.tui.request("/app/productAttributeValue/edit", "post", {
id: that.valueEditId,
value:e
}, false, true).then((res) => {
if (res.code == 200) {
that.tui.toast("修改成功")
that.goGategoryLow(that.editItem)
that.$forceUpdate()
} else {
that.tui.toast("添加失败")
}
}).catch((res) => {})
}else{
that.tui.request("/app/productAttributeValue/save", "post", {
attributeId: that.editItem.id,
value:e
}, false, true).then((res) => {
if (res.code == 200) {
that.tui.toast("添加成功")
that.goGategoryLow(that.editItem)
that.$forceUpdate()
} else {
that.tui.toast("添加失败")
}
}).catch((res) => {})
}
this.defaultList[this.addIndex].list.push(data)
this.$refs.addClose.val = ''
},
//
//
dialogInputConfirm(e) {
let that = this;
switch (that.typeModel) {
case 'add':
for (let i = 0; i < that.indexList.length; i++) {
if (that.indexList[i].categoryName == e) {
if (that.indexList[i].attributeName == e) {
uni.showToast({
title: "请勿重复添加!",
icon: 'error'
@ -419,72 +501,16 @@
}
}
if(e == ''){
that.tui.toast("请输入分类名")
that.tui.toast("请输入规格名")
return
}
if(e != '' && that.multipleList == ''){
that.multipleList = [{
attributeName:'颜色',
productAttributeValueVoList:[{
checked: true,
value: "均色"
}]
},{
attributeName:'尺码',
productAttributeValueVoList:[{
checked: true,
value: "均码"
}]
}]
}else if(e != '' && that.multipleList != ''){
for(let i=0;i<that.multipleList.length;i++){
if(that.multipleList[i].productAttributeValueVoList == ''){
if(that.multipleList[i].attributeName == '颜色'){
that.multipleList[i].productAttributeValueVoList = [{
checked: true,
value: "均色"
}]
}else{
that.multipleList[i].productAttributeValueVoList = [{
checked: true,
value: "均码"
}]
}
}else{
if(that.multipleList.length != 2){
if(that.multipleList[i].attributeName == '颜色'){
let data = {
attributeName:'尺码',
productAttributeValueVoList:[{
checked: true,
value: "均码"
}]
}
that.multipleList.push(data)
}else{
let data = {
attributeName:'颜色',
productAttributeValueVoList:[{
checked: true,
value: "均码"
}]
}
that.multipleList.push(data)
}
}
}
}
}
that.tui.request("/app/productCategory/batchSaveCategoryAndAttribute", "post", {
categoryName: e,
sort: that.sortText,
productAttributeOfAddVos:that.multipleList
}, false, false).then((res) => {
that.tui.request("/app/productAttribute/save", "post", {
categoryId: that.attrId,
attributeName:e
}, false, true).then((res) => {
if (res.code == 200) {
that.tui.toast("添加成功")
that.$refs.addTypeDialog.close()
that.sortText = ''
that.getGategoryList()
} else {
that.tui.toast("添加失败")
@ -492,18 +518,17 @@
}).catch((res) => {})
// that.$refs.addTypeDialog.val = ''
for(var i=0;i<that.defaultList.length;i++){
/* for(var i=0;i<that.defaultList.length;i++){
for(var m=0;m<that.defaultList[i].list.length;m++){
that.defaultList[i].list[m].checked = false
}
}
} */
that.typeText = ''
that.multipleList = []
break;
case 'edit':
that.tui.request("/app/productCategory/edit", "post", {
categoryName: this.inputVal,
sort: that.sortTextEdit,
that.tui.request("/app/productAttribute/edit", "post", {
attributeName: this.inputVal,
id: that.editItem.id
}, false, true).then((res) => {
if (res.code == 200) {
@ -537,7 +562,24 @@
},
//
dialogDel() {
this.delItem(this.editItem, 'del')
this.tui.request("/app/productAttribute/delById", "post", {
id: this.editItem.id,
}, false, true).then((res) => {
if (res.code == 200) {
this.getGategoryList()
uni.showToast({
title: "删除成功",
icon: 'none'
})
this.$refs.carPopup.close()
this.$refs.delDialog.close()
} else {
uni.showToast({
title: "删除失败",
icon: 'none'
})
}
}).catch((res) => {})
},
delItemModal() {
this.show = false;
@ -568,11 +610,23 @@
this.delItems = item;
this.getTypeToNum(this.delItems.id)
},
//
goGategoryLow(id) {
uni.navigateTo({
url: '/package1/inventory/gategoryLow?id=' + id
})
//
goGategoryLow(item) {
this.editItem = item
this.tui.request("/app/productAttributeValue/selectByAttributeId", "get", {
id: item.id,
}, false, true).then((res) => {
if (res.code == 200) {
this.defaultList = res.result;
this.$refs.attrValueDialog.open();
} else {
uni.showToast({
title: "删除失败",
icon: 'none'
})
}
}).catch((res) => {})
},
//
addMultipleType(item,item1,index){
@ -590,7 +644,7 @@
this.multipleList.push(data)
}else{
for(var i=0;i<this.multipleList.length;i++){
if(this.multipleList[i].attributeName == item.name){ //
if(this.multipleList[i].attributeName == item.name){ //
for(var m=0;m<this.multipleList[i].productAttributeValueVoList.length;m++){
@ -608,7 +662,7 @@
}
}
}
}else{ //
}else{ //
if(this.multipleList.length == i+1){
@ -847,7 +901,7 @@
justify-content: center;
padding: 30rpx;
width: 100%;
height: 1300rpx;
height: 400rpx;
background-color: #fff;
overflow: scroll;
}

Loading…
Cancel
Save