| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <template>
- <view>
- <view v-for="(item,index) in list" :key="index" class="flex padding justify-between">
- <view class="flex align-center">
- <view class="text-bold text-xl">{{index+1}}.</view>
- <view class="margin-left-xs">{{item.classifyName}}</view>
- </view>
- <view class="flex align-center">
- <view class="btn margin-right-sm" @click="addtype(2,item)">修改</view>
- <view class="btn" @click="bindupdata(item)">删除</view>
- </view>
- </view>
- <empty v-if="list.length == 0" content="暂无数据"></empty>
- <view class="addguige text-bold" @click="addtype(1)">添加</view>
- <!-- 添加规格弹框 -->
- <u-popup v-model="show" mode="center" border-radius="14" width="500rpx" height="400rpx">
- <view>
- <view class="padding" style="margin-bottom: 20rpx;">
- <view>商品分类</view>
- <view class="flex align-center" style="margin-top: 15rpx;">
- <label style="margin-right: 10rpx;">分类名称</label><u-input v-model="typeName" placeholder="请填写分类名称" clearable="false" />
- </view>
- <view class="flex align-center" style="margin-top: 15rpx;">
- <label style="margin-right: 10rpx;">分类排序</label><u-number-box v-model="sort" placeholder="请填写分类排序"></u-number-box>
- </view>
- </view>
- <view class="addguiges" @click="bindAdd()">确定</view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import empty from '@/components/empty.vue'
- export default {
- components: {
- empty
- },
- data() {
- return {
- list: [{
- id: 1,
- name: '清爽夏日',
- }, {
- id: 2,
- name: '牛奶系列',
- }, {
- id: 3,
- name: '鲜榨果汁',
- }],
- show: false,
- typeName: '',
- sort:0,
- classifyId: '',
- shopId: '',
- shopName: '',
- }
- },
- onLoad() {
- uni.showLoading({
- title: '数据加载中...',
- mask: false
- })
- this.shopId = this.$queue.getData("shopId")
- this.shopName = this.$queue.getData("shopUserName")
- this.getlist()
- },
- methods: {
- addtype(index, item) {
- console.log(index, item)
- if (index == 1) {
- this.show = true
- this.typeName = ''
- this.classifyId = ''
- this.sort = 0
- } else if (index == 2) {
- this.show = true
- this.typeName = item.classifyName
- this.classifyId = item.classifyId
- if(item.sort){
- this.sort = item.sort
- }else{
- this.sort = 0
- }
- }
- },
- //添加商品类型
- bindAdd() {
- if (!this.typeName) {
- uni.showToast({
- title: '请填写商品类型',
- icon: 'none',
- duration: 1000
- })
- return
- }
- console.log(this.classifyId)
- if (this.classifyId) {
- let data = {
- classifyId: this.classifyId,
- classifyName: this.typeName,
- shopId: this.shopId,
- shopName: this.shopName,
- sort:this.sort,
- }
- this.$Request.postJson("/admin/goods/updateClassify", data).then(res => {
- if (res.code == 0) {
- // this.list = res.data
- this.show = false
- this.typeName = ''
- this.classifyId = ''
- this.sort = 0
- this.getlist()
- }
- })
- } else {
- let data = {
- classifyName: this.typeName,
- shopId: this.shopId,
- shopName: this.shopName,
- sort:this.sort
- }
- this.$Request.postJson("/admin/goods/insertClassify", data).then(res => {
- if (res.code == 0) {
- // this.list = res.data
- this.show = false
- this.typeName = ''
- this.classifyId = ''
- this.sort = 0
- this.getlist()
- }
- })
- }
- },
- //获取分类列表
- getlist() {
- let data = {
- shopId: this.shopId
- }
- this.$Request.getA("/admin/goods/selectAllClassify", data).then(res => {
- uni.hideLoading()
- if (res.code == 0) {
- this.list = res.data
- }
- })
- },
- //删除商品类型
- bindupdata(e) {
- console.log(e)
- uni.showModal({
- title: '提示',
- content: '确定要删除当前类型吗?',
- cancelText: "取消", // 取消按钮的文字
- confirmText: "确定", // 确认按钮文字
- showCancel: true, // 是否显示取消按钮,默认为 true
- confirmColor: '#f55850',
- cancelColor: '#39B54A',
- success: (res) => {
- if (res.confirm) {
- let data = {
- classifyId: e.classifyId
- }
- this.$Request.getA("/admin/goods/deleteClassify", data).then(res => {
- if (res.code == 0) {
- uni.showToast({
- title: "删除成功",
- icon: 'none'
- })
- this.getlist();
- } else {
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- });
- }
- });
- }
- }
- })
- }
- }
- }
- </script>
- <style>
- page {
- background: #FFFFFF;
- }
- .btn {
- border: 2upx solid #999999;
- border-radius: 24px;
- color: #333333;
- padding: 5rpx 30rpx;
- }
- .addguige {
- width: 90%;
- margin: 0 auto;
- background: #FCD202;
- box-shadow: 0px 10upx 20upx 0px #FFD9B3;
- border-radius: 16upx;
- text-align: center;
- height: 88upx;
- line-height: 88upx;
- position: fixed;
- bottom: 25upx;
- left: 0;
- right: 0;
- }
- .addguiges {
- width: 90%;
- margin: 0 auto;
- background: #FCD202;
- box-shadow: 0px 10upx 20upx 0px #FFD9B3;
- border-radius: 16upx;
- text-align: center;
- height: 88upx;
- line-height: 88upx;
- /* position: fixed;
- bottom: 25upx;
- left: 0;
- right: 0; */
- }
- </style>
|