|
|
@@ -1,54 +1,40 @@
|
|
|
<template>
|
|
|
<div class="app-content">
|
|
|
- <!-- list -->
|
|
|
<div class="list-wrap">
|
|
|
<block v-if="!$util.isEmpty(list.data)">
|
|
|
<div class="list" v-for="(item, index) in list.data" :key="index">
|
|
|
- <div class="list-index">{{ item.inTurn }}</div>
|
|
|
<div class="list-img">
|
|
|
- <img :src="item.img" alt="分类图" mode="center" />
|
|
|
+ <img :src="item.img" alt="" mode="aspectFit" />
|
|
|
</div>
|
|
|
- <div class="list-det">
|
|
|
- <div class="app-size-28 app-color-0">{{ item.categoryName || '暂无' }}</div>
|
|
|
- <div>{{ item.description || '暂无' }}</div>
|
|
|
+ <div class="list-det" @click="edit(item)">
|
|
|
+ <div class="app-size-28 app-color-0">{{ item.categoryName}}</div>
|
|
|
+ <div><text style="color:green;" v-if="item.status == 1">启用</text><text v-else>停用</text></div>
|
|
|
<div class="list-operate">
|
|
|
<div class="operate-det">
|
|
|
- <span>商品数: {{ item.goodsNum }}</span>
|
|
|
- <span>销量: {{ item.sold }}</span>
|
|
|
- <span :style="{color: item.status == 1 ? '#049E2C' : '#ff6900'}">{{ item.status == 1? '启用' : '停用' }}</span>
|
|
|
- </div>
|
|
|
- <div class="operate-icon-wrap" @click="operateFn(item, index)">
|
|
|
- <div class="operate-icon">
|
|
|
- <i class="iconfont" :class="[ index == operateIndex ? 'iconcaozuojihuo' : 'iconcaozuo']" style="font-size:38rpx;"></i>
|
|
|
- </div>
|
|
|
+ <span @click.stop="edit(item)">编辑</span>
|
|
|
+ <span @click.stop="changeStatus(item)"><text v-if="item.status == 1">停用</text><text v-else>启用</text></span>
|
|
|
+ <span @click.stop="delCategory(item.id)">删除</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <!-- operate -->
|
|
|
- <operate-module
|
|
|
- v-if="operateShow"
|
|
|
- :top="operateTop"
|
|
|
- :right="30"
|
|
|
- @clickFn="operateList"
|
|
|
- :btnData="btnData" />
|
|
|
</block>
|
|
|
<block v-else>
|
|
|
<app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
|
|
|
</block>
|
|
|
</div>
|
|
|
- <!-- button -->
|
|
|
+
|
|
|
<div class="app-footer">
|
|
|
<button class="admin-button-com middle blue" @click="addCategoryFn">添加分类</button>
|
|
|
</div>
|
|
|
- <!-- modify -->
|
|
|
+
|
|
|
<modal-module :show="modifyModal" :maskClosable="false" @cancel="modalCancel" @click="modifyModalClick" width="92%" :title="modifyTitle" padding="30rpx 30rpx">
|
|
|
<template v-slot:content>
|
|
|
<div class="app-modal-input-wrap modify-modal">
|
|
|
<div class="inp-list-line">
|
|
|
- <div class="line-label">分类名称</div>
|
|
|
+ <div class="line-label">名称</div>
|
|
|
<div class="line-input">
|
|
|
- <input type="text" v-model="modifyForm.categoryName" :adjust-position="false" class="inp-input" placeholder="请填写分类名称" />
|
|
|
+ <input type="text" v-model="modifyForm.categoryName" :adjust-position="false" class="inp-input" placeholder="请填写" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="inp-list-line">
|
|
|
@@ -57,15 +43,14 @@
|
|
|
<app-uploader :multiple="false" ref="appUploader" :imgList.sync="modifyForm.img" />
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="prompt-text">建议尺寸 500X500</div>
|
|
|
<div class="inp-list-line">
|
|
|
<div class="line-label">排序</div>
|
|
|
<div class="line-input">
|
|
|
- <input type="text" v-model="modifyForm.inTurn" :adjust-position="false" class="inp-input" placeholder="默认排序最新在前面" />
|
|
|
+ <input type="text" v-model="modifyForm.inTurn" :adjust-position="false" class="inp-input" placeholder="越大越靠前" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="inp-list-line switch-wrap">
|
|
|
- <div class="line-label">启用状态</div>
|
|
|
+ <div class="line-label">启用</div>
|
|
|
<div class="line-input flex-strat">
|
|
|
<switch :checked="modifyForm.status == '0' ? false : true" @change="switchChangeFn" />
|
|
|
</div>
|
|
|
@@ -73,8 +58,6 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</modal-module>
|
|
|
- <!-- 删除提示 -->
|
|
|
- <modal-module :show="delModal" :maskClosable="false" @cancel="modalCancel" @click="delModalClick" content="确定删除该分类吗?" color="#333" :size="32" padding="30rpx 30rpx"></modal-module>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -101,61 +84,16 @@ export default {
|
|
|
modifyForm: {
|
|
|
categoryName: '',
|
|
|
img: [],
|
|
|
- inTurn: 0,
|
|
|
+ inTurn: 100,
|
|
|
status: 1
|
|
|
},
|
|
|
- // 删除弹窗
|
|
|
delModal: false,
|
|
|
- // operate
|
|
|
- operateShow: false,
|
|
|
operateData: {},
|
|
|
operateIndex: null,
|
|
|
operateTop: 0
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- btnData() {
|
|
|
- return [
|
|
|
- {
|
|
|
- text: '编辑',
|
|
|
- icon: 'iconbianji',
|
|
|
- click: () => {
|
|
|
- // this.operateShow = false
|
|
|
- this.modifyModal = true
|
|
|
- this.modifyTitle = '编辑'
|
|
|
-
|
|
|
- this.modifyForm = {
|
|
|
- categoryName: this.operateData.categoryName,
|
|
|
- img: [this.operateData.img],
|
|
|
- inTurn: this.operateData.inTurn,
|
|
|
- status: this.operateData.status
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- text: this.operateData.status == 1 ? '停用' : '启用',
|
|
|
- icon: this.operateData.status == 1 ? 'iconjinyong' : 'iconqiyong',
|
|
|
- click: () => {
|
|
|
- this.changeStatusFn()
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- text: '删除',
|
|
|
- icon: 'iconshanchu1',
|
|
|
- click: () => {
|
|
|
- // this.operateCancle()
|
|
|
- this.delModal = true
|
|
|
- }
|
|
|
- }
|
|
|
- // {
|
|
|
- // text: '分享',
|
|
|
- // icon: 'iconfenxiang1',
|
|
|
- // click: () => {
|
|
|
- // this.$msg('功能开发中...')
|
|
|
- // }
|
|
|
- // }
|
|
|
- ]
|
|
|
- }
|
|
|
},
|
|
|
onPullDownRefresh() {
|
|
|
this.resetList()
|
|
|
@@ -173,24 +111,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
- // this.init()
|
|
|
},
|
|
|
methods: {
|
|
|
- operateList(index){
|
|
|
- if(index === 0){
|
|
|
- this.modifyModal = true
|
|
|
- this.modifyTitle = '编辑'
|
|
|
-
|
|
|
- this.modifyForm = {
|
|
|
- categoryName: this.operateData.categoryName,
|
|
|
- img: [this.operateData.img],
|
|
|
- inTurn: this.operateData.inTurn,
|
|
|
- status: this.operateData.status
|
|
|
- }
|
|
|
- }else if(index === 1) {
|
|
|
- this.changeStatusFn()
|
|
|
- }else if(index === 2) {
|
|
|
- this.delModal = true
|
|
|
+ edit(item){
|
|
|
+ this.modifyModal = true
|
|
|
+ this.modifyTitle = '编辑'
|
|
|
+ this.modifyForm = {
|
|
|
+ categoryId:item.id,
|
|
|
+ categoryName: item.categoryName,
|
|
|
+ img: [item.img],
|
|
|
+ inTurn: item.inTurn,
|
|
|
+ status: item.status
|
|
|
}
|
|
|
},
|
|
|
async init() {
|
|
|
@@ -208,32 +139,30 @@ export default {
|
|
|
this.completes(data)
|
|
|
})
|
|
|
},
|
|
|
- // modal
|
|
|
_categoryAddOrEditB() {
|
|
|
if (!this.modifyForm.categoryName) {
|
|
|
- this.$msg('请输入分类名称!')
|
|
|
+ this.$msg('请输入分类名称')
|
|
|
return false
|
|
|
}
|
|
|
- let host = this.modifyTitle == '编辑' ? categoryUpdateB : categoryAddB
|
|
|
let form = JSON.parse(JSON.stringify(this.modifyForm))
|
|
|
+
|
|
|
+ let host = categoryAddB
|
|
|
+ if(form.categoryId && form.categoryId > 0){
|
|
|
+ host = categoryUpdateB
|
|
|
+ }
|
|
|
form.img = this.$util.imgSubstr(form.img)
|
|
|
form.img = form.img.join()
|
|
|
- if (this.modifyTitle == '编辑') {
|
|
|
- form.categoryId = this.operateData.id
|
|
|
- }
|
|
|
host({
|
|
|
...form
|
|
|
}).then(res => {
|
|
|
this.$msg('操作成功!')
|
|
|
this.modalCancel()
|
|
|
- this.operateCancle()
|
|
|
setTimeout(() => {
|
|
|
this.resetList()
|
|
|
this._list()
|
|
|
}, 1000)
|
|
|
})
|
|
|
},
|
|
|
- // 操作
|
|
|
addCategoryFn() {
|
|
|
this.resetForm()
|
|
|
this.modifyModal = true
|
|
|
@@ -261,45 +190,34 @@ export default {
|
|
|
switchChangeFn(e) {
|
|
|
this.modifyForm.status = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
- delModalClick(e) {
|
|
|
- if (e.index === 0) {
|
|
|
- this.modalCancel()
|
|
|
- } else {
|
|
|
- console.log('this.operateData', this.operateData)
|
|
|
- categoryDelB({ categoryId: this.operateData.id }).then(res => {
|
|
|
- this.modalCancel()
|
|
|
- this.operateCancle()
|
|
|
- this.$msg('删除成功!')
|
|
|
- this.resetList()
|
|
|
- this._list()
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- // operate
|
|
|
- operateFn(item, index) {
|
|
|
- if (this.operateIndex == index) {
|
|
|
- this.operateCancle()
|
|
|
- } else {
|
|
|
- this.operateData = item
|
|
|
- this.operateIndex = index
|
|
|
- this.operateShow = true
|
|
|
- this.operateTop = (index + 1) * 191
|
|
|
- }
|
|
|
- },
|
|
|
- operateCancle() {
|
|
|
- this.operateData = {}
|
|
|
- this.operateIndex = null
|
|
|
- this.operateShow = false
|
|
|
+ delCategory(id) {
|
|
|
+ let that = this
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确认删除?',
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ categoryDelB({ categoryId: id }).then(res => {
|
|
|
+ if(res.code == 1){
|
|
|
+ that.$msg('已删除')
|
|
|
+ that.resetList()
|
|
|
+ that._list()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
- changeStatusFn() {
|
|
|
- let status = this.operateData.status == 1 ? 0 : 1
|
|
|
+ changeStatus(item) {
|
|
|
+ let status = item.status == 1 ? 0 : 1
|
|
|
categoryStatusB({
|
|
|
- categoryId: this.operateData.id,
|
|
|
+ categoryId: item.id,
|
|
|
status: status
|
|
|
}).then(res => {
|
|
|
- this.list.data[this.operateIndex].status = status
|
|
|
- this.operateCancle()
|
|
|
- this.$msg('操作成功!')
|
|
|
+ if(res.code == 1){
|
|
|
+ item.status = status
|
|
|
+ this.$msg('修改成功')
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -307,77 +225,79 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
- .app-content {
|
|
|
- min-height: calc(100vh - 100px);
|
|
|
- padding-bottom: 100px;
|
|
|
- }
|
|
|
- // list
|
|
|
- .list-wrap {
|
|
|
- position: relative;
|
|
|
- background-color: #fff;
|
|
|
- .list {
|
|
|
+.app-content {
|
|
|
+ min-height: calc(100vh - 100px);
|
|
|
+ padding-bottom: 100px;
|
|
|
+}
|
|
|
+.list-wrap {
|
|
|
+ position: relative;
|
|
|
+ background-color: #fff;
|
|
|
+ .list {
|
|
|
+ height: 160px;
|
|
|
+ @include disFlex(center, flex-start);
|
|
|
+ padding: 30px 0;
|
|
|
+ margin: 0 30px;
|
|
|
+ color: $fontColor3;
|
|
|
+ border-bottom: 1px solid $borderColor;
|
|
|
+ .list-index {
|
|
|
+ width: 50px;
|
|
|
+ }
|
|
|
+ .list-img {
|
|
|
+ width: 130px;
|
|
|
height: 130px;
|
|
|
- @include disFlex(center, flex-start);
|
|
|
- padding: 30px 0;
|
|
|
- margin: 0 30px;
|
|
|
- color: $fontColor3;
|
|
|
- border-bottom: 1px solid $borderColor;
|
|
|
- .list-index {
|
|
|
- width: 50px;
|
|
|
+ img {
|
|
|
+ height: 100%;
|
|
|
}
|
|
|
- .list-img {
|
|
|
- width: 130px;
|
|
|
- height: 130px;
|
|
|
- img {
|
|
|
- height: 100%;
|
|
|
+ }
|
|
|
+ .list-det {
|
|
|
+ width: calc(100% - 200px);
|
|
|
+ margin-left: 20px;
|
|
|
+ & > div {
|
|
|
+ margin-top: 14px;
|
|
|
+ &:first-child {
|
|
|
+ margin-top: 0;
|
|
|
}
|
|
|
}
|
|
|
- .list-det {
|
|
|
- width: calc(100% - 200px);
|
|
|
- margin-left: 20px;
|
|
|
- & > div {
|
|
|
- margin-top: 14px;
|
|
|
- &:first-child {
|
|
|
- margin-top: 0;
|
|
|
- }
|
|
|
- }
|
|
|
- .list-operate {
|
|
|
- @include disFlex(center, space-between);
|
|
|
- .operate-det {
|
|
|
- & > span {
|
|
|
- margin-left: 60px;
|
|
|
- &:first-child {
|
|
|
- margin-left: 0;
|
|
|
- }
|
|
|
+ .list-operate {
|
|
|
+ @include disFlex(center, space-between);
|
|
|
+ .operate-det {
|
|
|
+ padding-left:160rpx;
|
|
|
+ & > span {
|
|
|
+ border:1px solid #ccc;
|
|
|
+ border-radius: 30rpx;
|
|
|
+ padding:5rpx 20rpx 5rpx 20rpx;
|
|
|
+ font-size:20rpx;
|
|
|
+ margin-left: 40px;
|
|
|
+ &:first-child {
|
|
|
+ margin-left: 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // button
|
|
|
- .app-footer {
|
|
|
- justify-content: flex-end;
|
|
|
- .admin-button-com {
|
|
|
- width: 200px;
|
|
|
- margin-right: 30px;
|
|
|
- }
|
|
|
+}
|
|
|
+.app-footer {
|
|
|
+ justify-content: flex-end;
|
|
|
+ .admin-button-com {
|
|
|
+ width: 200px;
|
|
|
+ margin-right: 30px;
|
|
|
}
|
|
|
- // 编辑弹窗
|
|
|
- .modify-modal {
|
|
|
- .prompt-text {
|
|
|
- color: red;
|
|
|
- position: relative;
|
|
|
- right: 52px;
|
|
|
- bottom: 24px;
|
|
|
- // margin-bottom: 10px;
|
|
|
- }
|
|
|
- .line-label {
|
|
|
- width: 140px;
|
|
|
- flex-shrink: 0;
|
|
|
- }
|
|
|
- .switch-wrap {
|
|
|
- margin-top: 30px;
|
|
|
- }
|
|
|
+}
|
|
|
+.modify-modal {
|
|
|
+ .prompt-text {
|
|
|
+ color: red;
|
|
|
+ position: relative;
|
|
|
+ right: 52px;
|
|
|
+ bottom: 24px;
|
|
|
+ // margin-bottom: 10px;
|
|
|
}
|
|
|
-</style>
|
|
|
+ .line-label {
|
|
|
+ width: 140px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+ .switch-wrap {
|
|
|
+ margin-top: 30px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|