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.
432 lines
9.9 KiB
432 lines
9.9 KiB
<template>
|
|
<view class="u-wrap">
|
|
<view>
|
|
<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" @tap.stop="inputDialogToggle('edit', item)"></u-icon>
|
|
</view>
|
|
<button class="bj-btn" @tap.stop="goGategoryLow(item.id)">编辑规格</button>
|
|
</li>
|
|
</ul>
|
|
</view>
|
|
<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">
|
|
<uni-popup-dialog ref="inputClose" mode="input" :title="dialogTit" :value="inputVal" placeholder="请输入名称"
|
|
cancelText="删除" @confirm="dialogInputConfirm" @close="dialogDel">
|
|
</uni-popup-dialog>
|
|
</uni-popup>
|
|
<!-- 查看商品库存弹出层 -->
|
|
<uni-popup ref="carPopup" background-color="#fff">
|
|
<view class="popup-content">
|
|
<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}}商品有以下库存,确认继续删除吗?</view>
|
|
<view v-for="(item,index) in goodsList" :key="index" style="position: relative;">
|
|
<view style="padding-bottom: 100rpx;">
|
|
<view class="checkList">
|
|
<view class="checkList-box">
|
|
{{item.attributeList | sliceMsg}} {{item.stockCount}}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="popup-bottom">
|
|
<view class="popup-bottom-left">
|
|
<view class="bottom-btn" @tap="this.$refs.carPopup.close()"
|
|
style="background: linear-gradient(90deg, #FF9797, #FFC1E0);">再想想</view>
|
|
</view>
|
|
<view class="popup-bottom-right">
|
|
<view class="bottom-btn" @tap="this.show = true">确认删除</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</uni-popup>
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
indexList: [],
|
|
show: false,
|
|
inputVal: '',
|
|
typeModel: '',
|
|
editItem: {},
|
|
delItems: {},
|
|
isOpenId: '',
|
|
delType: '',
|
|
goodsList: [],
|
|
dialogTit: '输入分类名'
|
|
}
|
|
},
|
|
computed: {
|
|
|
|
},
|
|
onShow() {
|
|
this.getGategoryList()
|
|
},
|
|
methods: {
|
|
//初始化获取分类列表
|
|
getGategoryList() {
|
|
this.tui.request("/app/productCategory/list", "get", {
|
|
// shopId: 1,
|
|
}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
this.indexList = res.result;
|
|
} else {
|
|
this.tui.toast(res.message)
|
|
}
|
|
}).catch((res) => {})
|
|
},
|
|
//判断需要打开哪个弹窗(删除弹窗、取消弹窗)
|
|
inputDialogToggle(type, item, parent) {
|
|
this.typeModel = type;
|
|
if (type == 'edit') {
|
|
this.inputVal = item.categoryName;
|
|
this.editItem = item;
|
|
this.$refs.delDialog.open()
|
|
} else if (type == 'add') {
|
|
this.inputVal = '';
|
|
this.isOpenId = item;
|
|
this.dialogTit = '输入分类名'
|
|
this.$refs.inputDialog.open()
|
|
} else if (type == 'attrEdit') {
|
|
this.inputVal = item.attributeName;
|
|
this.editItem = item;
|
|
}
|
|
|
|
},
|
|
//查询分类下有没有库存
|
|
getTypeToNum(id) {
|
|
let that = this;
|
|
this.tui.request("/app/stock/getlistByAttributeList", "post", {
|
|
categoryId: id,
|
|
}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
if (res.result != '') {
|
|
this.goodsList = res.result
|
|
this.$refs.carPopup.open('bottom')
|
|
} else {
|
|
this.tui.request("/app/productAttribute/selectByCategoryId", "POST", {
|
|
categoryId: this.delItems.id
|
|
}, false, true).then((res1) => {
|
|
if (res1.code == 200) {
|
|
if(res1.result.length > 0){
|
|
uni.showModal({
|
|
title: "提示",
|
|
content: "此分类已经维护了子分类,确定继续删除吗?",
|
|
success: function(res2) {
|
|
if (res2.confirm) {
|
|
that.delItemModal()
|
|
}
|
|
}
|
|
})
|
|
}else{
|
|
that.show = true
|
|
}
|
|
}
|
|
}).catch((res) => {})
|
|
}
|
|
}
|
|
}).catch((res) => {})
|
|
},
|
|
//点击选择列表,带参数 返回上一页
|
|
clickList(item) {
|
|
let pages = getCurrentPages();
|
|
let prevPage = pages[pages.length - 2];
|
|
prevPage.$vm.typeItem = item
|
|
uni.navigateBack({
|
|
delta: 1
|
|
})
|
|
},
|
|
//分类编辑(新增,修改)
|
|
dialogInputConfirm(e) {
|
|
switch (this.typeModel) {
|
|
case 'add':
|
|
if (e == "") {
|
|
uni.showToast({
|
|
title: "不能为空",
|
|
icon: 'none'
|
|
})
|
|
return;
|
|
}
|
|
for (let i = 0; i < this.indexList.length; i++) {
|
|
if (this.indexList[i].categoryName == e) {
|
|
uni.showToast({
|
|
title: "请勿重复添加!",
|
|
icon: 'error'
|
|
})
|
|
return
|
|
}
|
|
}
|
|
this.tui.request("/app/productCategory/save", "post", {
|
|
categoryName: e
|
|
}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
this.getGategoryList()
|
|
uni.showToast({
|
|
title: "添加成功",
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title: "添加失败",
|
|
icon: 'none'
|
|
})
|
|
}
|
|
|
|
}).catch((res) => {})
|
|
break;
|
|
case 'edit':
|
|
this.tui.request("/app/productCategory/edit", "post", {
|
|
categoryName: e,
|
|
id: this.editItem.id
|
|
}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
this.getGategoryList()
|
|
uni.showToast({
|
|
title: "修改成功",
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title: "修改失败",
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}).catch((res) => {})
|
|
break;
|
|
default:
|
|
}
|
|
this.$refs.inputClose.val = ''
|
|
},
|
|
//点击取消按钮
|
|
dialogClose() {
|
|
this.inputVal = '';
|
|
this.$refs.inputClose.val = ''
|
|
},
|
|
//带删除按钮的弹窗
|
|
dialogDel() {
|
|
this.delItem(this.editItem, 'del')
|
|
},
|
|
delItemModal() {
|
|
this.show = false;
|
|
if (this.delType == 'del') {
|
|
this.tui.request("/app/productCategory/delById", "post", {
|
|
id: this.delItems.id,
|
|
}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
this.getGategoryList()
|
|
uni.showToast({
|
|
title: "删除成功",
|
|
icon: 'none'
|
|
})
|
|
this.$refs.carPopup.close()
|
|
} else {
|
|
uni.showToast({
|
|
title: "删除失败",
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}).catch((res) => {})
|
|
}
|
|
},
|
|
delItem(item, type) {
|
|
this.delType = type;
|
|
this.delItems = item;
|
|
this.getTypeToNum(this.delItems.id)
|
|
},
|
|
//跳转子分类页
|
|
goGategoryLow(id) {
|
|
uni.navigateTo({
|
|
url: '/pages/inventory/gategoryLow?id=' + id
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.u-wrap {
|
|
height: calc(100vh);
|
|
/* #ifdef H5 */
|
|
height: calc(100vh - var(--window-top));
|
|
/* #endif */
|
|
display: flex;
|
|
flex-direction: column;
|
|
|
|
.top {
|
|
line-height: 70rpx;
|
|
margin: 20rpx 0;
|
|
padding: 0 20rpx;
|
|
background-color: #fff;
|
|
|
|
.u-collapse-content {
|
|
.icon {
|
|
display: flex;
|
|
float: right;
|
|
|
|
.u-icon {
|
|
flex: 1;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
.name {
|
|
font-size: 14px;
|
|
|
|
.rightBox {
|
|
display: flex;
|
|
float: right;
|
|
}
|
|
}
|
|
|
|
.attr {
|
|
line-height: 28px;
|
|
margin-left: 20rpx;
|
|
|
|
.attrName {
|
|
color: #767a82;
|
|
font-size: 12px;
|
|
display: flex;
|
|
box-sizing: border-box;
|
|
width: 100%;
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.attrs {
|
|
margin-left: 20rpx;
|
|
|
|
.u-tag-wrapper {
|
|
width: 20%;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
button {
|
|
color: #ffffff;
|
|
background: #5fd9ee;
|
|
width: 90%;
|
|
margin-top: 20upx;
|
|
}
|
|
|
|
.card-list {
|
|
width: 95%;
|
|
border-radius: 10upx;
|
|
background: #fff;
|
|
height: auto;
|
|
margin: 20upx auto;
|
|
|
|
}
|
|
|
|
.card-list ul {}
|
|
|
|
.card-list li {
|
|
width: 95%;
|
|
height: 100rpx;
|
|
line-height: 100rpx;
|
|
padding-left: 20rpx;
|
|
font-size: 37rpx;
|
|
border-bottom: 0.5px solid #eee;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.bj-btn {
|
|
width: 120rpx;
|
|
height: 60rpx;
|
|
font-size: 26rpx;
|
|
background: red;
|
|
margin: 20rpx 0;
|
|
float: left;
|
|
padding: 0;
|
|
line-height: 60rpx;
|
|
}
|
|
|
|
.name {
|
|
width: 75%;
|
|
float: left;
|
|
display: flex;
|
|
}
|
|
|
|
.data-v-5ff5d986 {}
|
|
|
|
.popup-content {
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 15px;
|
|
height: 1200rpx;
|
|
background-color: #fff;
|
|
margin-bottom: 30rpx;
|
|
overflow: scroll;
|
|
}
|
|
|
|
.popup-container {
|
|
width: 100%;
|
|
background: #fff;
|
|
height: 50rpx;
|
|
}
|
|
|
|
.checkList {
|
|
display: flex;
|
|
height: 50rpx;
|
|
font-size: 28rpx;
|
|
line-height: 50rpx;
|
|
margin: 20rpx 0;
|
|
}
|
|
|
|
.checkList-box {
|
|
height: 50rpx;
|
|
width: 60%;
|
|
}
|
|
|
|
.popup-bottom {
|
|
width: 95%;
|
|
height: 100rpx;
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 2.5%;
|
|
display: flex;
|
|
z-index: 99;
|
|
background: #fff;
|
|
}
|
|
|
|
.popup-bottom-left {
|
|
width: 50%;
|
|
line-height: 80rpx;
|
|
}
|
|
|
|
.popup-bottom-right {
|
|
width: 50%;
|
|
line-height: 100rpx;
|
|
}
|
|
|
|
.bottom-btn {
|
|
width: 70%;
|
|
line-height: 35px;
|
|
height: 70rpx;
|
|
text-align: center;
|
|
/* margin-top: 10rpx; */
|
|
color: #fff;
|
|
font-size: 28rpx;
|
|
margin: 0 auto;
|
|
background: linear-gradient(90deg, #60F3FF, #088FEB);
|
|
border-radius: 70rpx;
|
|
}
|
|
</style>
|