jiangping
2024-09-02 843d0abd014ec20424844546fc57a9f976f366ba
pda/pages/index/set.vue
@@ -1,33 +1,74 @@
<template>
  <view class="main_app">
    <view class="title">
      <view class="icon"></view>
      <view class="name">安泰物流卸货月台</view>
    </view>
    <div class="data_list">
      <div
        class="item"
        :class="{ active: i == 1 }"
        v-for="(item, i) in 7"
        :key="i"
      >
        {{ i }}号月台
      </div>
    </div>
      <template v-for="item in platformGroupList">
         <view class="title">
           <view class="icon"></view>
           <view class="name">{{item.name}}</view>
         </view>
         <view class="data_list">
           <view
             class="item"
             :class="{ active: platform.showConfig }"
             v-for="(platform, i) in item.platformList"
             :key="platform.id"
               @click="platformClick(platform.id)"
           >
             {{platform.name}}
           </view>
         </view>
      </template>
      <view class="btns">
         <div class="btn" @click="$goBack">取消</div>
         <div class="btn active" @click="updUserPlatform">确定</div>
      </view>
  </view>
</template>
<script>
import { getPlatformGroupList, updUserPlatformConfig } from '@/api'
export default {
  data() {
    return {
         platformGroupList: []
    }
  },
  onLoad() {
      this.getPlatformGroup()
  },
  methods: {
      updUserPlatform(){
         const { platformGroupList } = this
         let ids = []
         platformGroupList.forEach(item => {
            item.platformList.forEach(platform => {
                  if(platform.showConfig){
                     ids.push(platform.id)
                  }
            })
         })
         updUserPlatformConfig({ids}).then(res => {
            this.showToast('更新成功')
            this.$goBack()
         })
      },
      platformClick(id) {
         const { platformGroupList } = this
         platformGroupList.forEach(item => {
            item.platformList.forEach(platform => {
                  if(platform.id === id){
                     platform.showConfig = !platform.showConfig
                  }
            })
         })
      },
      getPlatformGroup() {
         getPlatformGroupList({
            queryData: 1,
            queryType: 1
         }).then(res => {
            this.platformGroupList = res.data || []
         })
      },
  }
}
</script>
@@ -43,6 +84,9 @@
    margin-bottom: 20rpx;
    padding: 30rpx;
     background-color: #fff;
       &:nth-last-child(1){
          margin-bottom: 120rpx;
       }
    .item {
      width: 210rpx;
      height: 80rpx;
@@ -83,4 +127,33 @@
    }
  }
}
.btns{
   position: fixed;
   left: 0;
   bottom: 0;
   width: 750rpx;
   height: 120rpx;
   background: #FFFFFF;
   box-shadow: 0rpx -4rpx 12rpx 0rpx rgba(0,0,0,0.1);
   display: flex;
   justify-content: space-between;
   align-items: center;
   padding: 0 30rpx;
   .btn{
      width: 336rpx;
      height: 88rpx;
      background: #FFFFFF;
      border-radius: 44rpx;
      border: 1rpx solid #999999;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 32rpx;
      color: #333333;
   }
   .active{
      background: $uni-color-primary;
      color: #fff;
   }
}
</style>