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.
281 lines
6.2 KiB
281 lines
6.2 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="goGategoryLow(item.id)">
|
|
<view class="name">{{item.categoryName}}</view>
|
|
<button class="bj-btn" @tap.stop="inputDialogToggle('edit', item)">编辑</button>
|
|
<uni-icons type="forward" size="25"></uni-icons>
|
|
</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>
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
indexList: [],
|
|
show: false,
|
|
inputVal:'',
|
|
typeModel:'',
|
|
editItem:{},
|
|
delItems:{},
|
|
isOpenId:'',
|
|
attrList:[],
|
|
openIndex:'',
|
|
delType:'',
|
|
showList:{},
|
|
dialogTit:'输入分类名'
|
|
// type: 'center',
|
|
}
|
|
},
|
|
computed: {
|
|
|
|
},
|
|
onLoad() {
|
|
this.getGategoryList()
|
|
},
|
|
methods: {
|
|
//初始化获取分类列表
|
|
getGategoryList() {
|
|
this.tui.request("/app/productCategory/list", "get", {
|
|
// shopId: 1,
|
|
}, false, true).then((res) => {
|
|
console.log(res, '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;
|
|
}
|
|
|
|
},
|
|
//分类编辑(新增,修改)
|
|
dialogInputConfirm(e) {
|
|
switch (this.typeModel) {
|
|
case 'add':
|
|
if(e== ""){
|
|
uni.showToast({
|
|
title:"不能为空",
|
|
icon: 'none'
|
|
})
|
|
return;
|
|
}
|
|
this.tui.request("/app/productCategory/save", "post", {
|
|
categoryName: e
|
|
}, false, true).then((res) => {
|
|
console.log(res, '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) => {
|
|
console.log(res, 'res');
|
|
if (res.code == 200) {
|
|
this.getGategoryList()
|
|
uni.showToast({
|
|
title:"删除成功",
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title:"删除失败",
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}).catch((res) => {})
|
|
}
|
|
},
|
|
delItem(item, type) {
|
|
this.delType = type;
|
|
this.delItems = item;
|
|
this.show = true;
|
|
},
|
|
//跳转子分类页
|
|
goGategoryLow(id) {
|
|
// console.log(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: 95rpx;
|
|
height: 60rpx;
|
|
font-size: 26rpx;
|
|
background: red;
|
|
margin: 0;
|
|
margin: 20rpx;
|
|
float: left;
|
|
padding: 0;
|
|
line-height: 60rpx;
|
|
}
|
|
.name{
|
|
width: 70%;
|
|
float: left;
|
|
}
|
|
.data-v-5ff5d986{
|
|
|
|
}
|
|
</style>
|
|
|