陶杰
2024-09-11 8840efb29d8818afcfd2176914bcf4811d9c60fe
sub_pages/supplier/flower-manage/flower-manage.vue
@@ -7,19 +7,38 @@
         <view @click.stop="clickButton('inpass')" class="button button-search-inpass" style="flex:5"></view>
         <view @click.stop="clickButton('delete')" class="button button-search-delete" style="margin-top: -1rpx;">
         </view>
      </view>
      <view class="p15" style="min-height: calc(100vh - 160rpx);">
      <view class="recycle-button"  v-if="type==='delete'">
      <view class="buttons" >
            <view v-if="type === 'delete'" class="button t-red"  @click.stop="deleteSelected()">删除</view>
            <view v-if="type === 'delete'" class="button"  @click.stop="recoverSelected()">恢复</view>
      </view>
      </view>
      <view class="p15" style="min-height: calc(100vh - 500rpx);">
         <no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
         <view v-for="(item,index) in list" :key="index" class="m-b-24 flow-manage-list">
         <!--    <view v-if="type === 'delete'"><checkbox  class="checkbox" :value="item.id" v-model="selectedFlowers" /> </view>
          -->
            <view class="flow-manage-list-item-radio" v-if="type === 'delete'"><radio :checked="isSelected(item.id)" @click="changeItem(item)"></radio></view>
            <view class="flow-manage-list-item">
               <view class="flex">
                  <image class="flower-img img100 m-r-6" :src="item.cover" @click="previewImg(item.cover)">
                  </image>
               <view class="flex m-r-6">
                  <view class="img flower-img m-r-6">
                     <image class="flower-img img100 " :src="item.cover"
                        :class="[!item.stock?'component-stock-zero':'']" @click="previewImg(item.cover)">
                     </image>
                     <view class="status" :class="[!item.stock?'zero':'']" v-if="item.statusStr">
                        {{ item.statusStr}}
                     </view>
                  </view>
                  <view class="flex1">
                     <view class=" flex">
                        <view class="title">{{item.name}}<span class="level">{{item.levelStr}}</span></view>
                        <view class="m-l-a m-r-0" ><span class="label">排名</span><span class="value">{{item.typeRank || '-'}}</span></view>
                        <view class="m-l-a m-r-0">
                           {{item.categoryStr || '-'}}
                        </view>
@@ -70,7 +89,7 @@
                  <view class="button" @click.stop="openValue(item,'stock')">库存</view>
                  <view class="button" @click.stop="toDetailAdd(item)">复制</view>
                  <view class="button t-red" @click.stop="buttonDelete(item)">删除</view>
                  <view v-if="type !== 'delete' && (item.status==='OFF' || item.status==='FORCE_OFF')  " class="button t-red" @click.stop="buttonDelete(item)">删除</view>
               </view>
            </view>
@@ -126,6 +145,8 @@
            currentInputDto: {},
            currentInputKey: '',
            inputplaceholder: '',
            selectedFlowers: [], // 存储选中的花的 ID
            ids: [],
         }
      },
      onShow() {
@@ -137,6 +158,7 @@
      async onLoad(options) {
         this.type = options.type || 'all'
         var title = ''
         this.page.size = 5
         //todo 根据type切换查询条件
         if (this.type === 'delete') {
            this.listApi = '/api/supplier/flower/list/rc'
@@ -171,7 +193,7 @@
         this.getList()
      },
      onReachBottom() {
         this.page.current += 1
         console.log('onReachBottom')
         this.getMore()
      },
      async onPullDownRefresh() {
@@ -241,21 +263,22 @@
            })
         },
         async buttonStatus(item, status) {
            await this.$message.confirm(`确定${status==='off'?'下降':'上架'}此商品吗`)
            await this.$message.confirm(`确定${status==='off'?'下架':'上架'}此商品吗`)
            this.$message.showLoading()
            this.$http.request('get', '/api/supplier/flower/list/' + status, {
               params: {
                  id: item.id
               }
            }).then(res => {
               this.$message.hideLoading()
               if (res.code == 0) {
                  this.$message.showToast('操作成功')
                  item.status = status
                  item.status = (status == 'off' ? 'OFF' : 'UP')
                  item.statusStr = (status == 'off' ? '下架' : '上架')
               }
            }).finally(() => {
            }).catch(e => {
               this.$message.hideLoading()
            })
            }).finally(() => {})
         },
         async buttonDelete(item) {
            await this.$message.confirm('确定删除此商品吗')
@@ -295,21 +318,99 @@
               })
            }
         },
            // 删除选中的花卉
       async deleteSelected() {
           if (this.selectedFlowers.length === 0) {
               this.$message.showToast('请选择要删除的商品');
               return;
           }
           // 确认框
         await this.$message.confirm('确定删除此商品吗')
         var dto = {
            ids: this.selectedFlowers,
         }
         this.$message.showLoading()
         this.$http.request('post', '/api/supplier/flower/list/delete/batch' , {
            data: dto
         }).then(res => {
            if (res.code == 0) {
               this.$message.showToast('操作成功')
               this.refreshList()
            }
         }).finally(() => {
            this.$message.hideLoading()
         })
       },
      async recoverSelected() {
          if (this.selectedFlowers.length === 0) {
              this.$message.showToast('请选择恢复的商品');
              return;
          }
          // 确认框
         await this.$message.confirm('确定恢复此商品吗')
         var dto = {
            ids: this.selectedFlowers,
         }
         this.$message.showLoading()
         this.$http.request('post', '/api/supplier/flower/list/restore/batch' , {
            data: dto
         }).then(res => {
            if (res.code == 0) {
               this.$message.showToast('操作成功')
               this.refreshList()
            }
         }).finally(() => {
            this.$message.hideLoading()
         })
      },
      changeItem(item) {
          const id = item.id;
           // 判断selectedFlowers里面是否有item.id, 如果有则去掉,没有就加入
           if (this.selectedFlowers.includes(id)) {
             // 移除选中的ID
             this.selectedFlowers = this.selectedFlowers.filter(flowerId => flowerId !== id);
           } else {
             // 添加选中的ID
             this.selectedFlowers.push(id);
           }
      },
       isSelected(id) {
         // 检查ID是否在selectedFlowers中
         return this.selectedFlowers.includes(id);
       }
      }
   }
</script>
<style lang="scss" scoped>
   .flow-manage {
      overflow-y: scroll;
      // min-height: ;
      .flow-manage-list {
         // padding: 20rpx 30rpx;
         padding: 22rpx 22rpx 20rpx 22rpx;
         background-color: #fff;
         display: flex;
         .flow-manage-list-item-radio{
            width: 50rpx;
            height: 50rpx;
         }
         .flow-manage-list-item {
            // margin-bottom: 20rpx;
            .title {
               font-weight: 600;
               font-size: 28rpx;
@@ -323,6 +424,25 @@
                  line-height: 40rpx;
                  margin-left: 20rpx;
               }
            }
            .label {
               font-weight: 400;
               font-size: 24rpx;
               color: #666666;
               text-align: left;
               // padding-left: 10rpx;
               // padding-right: 10rpx;
            }
            .label::after {
               content: ": "
            }
            .value {
               font-weight: 400;
               font-size: 24rpx;
               color: #666666;
            }
            .buttons {
@@ -346,6 +466,28 @@
               height: 118rpx;
               min-width: 128rpx;
               min-height: 118rpx;
               position: relative;
               .status {
                  position: absolute;
                  min-width: 66rpx;
                  height: 34rpx;
                  background: #20613D;
                  left: 0;
                  top: 0;
                  border-top-left-radius: 8rpx;
                  border-bottom-right-radius: 8rpx;
                  color: #FFFFFF;
                  line-height: 34rpx;
                  font-size: 22rpx;
                  text-align: center;
               }
               .status.zero {
                  // background: unset;
                  // font-size: 24rpx;
               }
            }
            .each-list {
@@ -382,7 +524,7 @@
            }
         }
      }
      .top-buttons {
         display: flex;
         padding: 22rpx 42rpx;
@@ -437,5 +579,33 @@
         }
      }
      .recycle-button{
         min-height: 50rpx;
         background-color: #fff;
         .buttons {
            display: flex;
            justify-content: flex-end;
            background-color: #fff;
            padding: 22rpx 42rpx;
            .button {
               margin: 0 auto;
               width: 98rpx;
               line-height: 48rpx;
               border-radius: 24rpx;
               border: 2rpx solid #CECECE;
               text-align: center;
               font-size: 24rpx;
               color: #666666;
               line-height: 34rpx;
            }
         }
      }
   }
</style>