<template>
  <div class="perfectStoreSku">
    <van-nav-bar class="navBar" title="拜访任务详情" left-arrow @click-left="onClickLeft">
      <template #right> </template>
    </van-nav-bar>
    <div class="content" v-if="detail">
      <div class="container">
        <div class="headline">
          <span class="headlineIcon"></span>
          <span class="headlineTitle">生动化陈列</span>
        </div>
        <div style="padding: 10px">
          <div class="imgBox" v-for="(urls, index) in detail.fileUrlList" :key="index">
            <img :src="urls" @click="previewsImg(index)" />
          </div>
          <!-- <van-row gutter="5" class="imgEow">
            <van-col span="6" v-for="(urls, index) in detail.fileUrlList" :key="index">
              <div class="img-box">
                <img :src="urls" @click="previewsImg(index)" />
              </div>
            </van-col>
          </van-row> -->
        </div>
      </div>
      <div class="skuDeatil" v-if="skuList">
        <div class="headline" style="margin-top: 10px">
          <span class="headlineIcon"></span>
          <span class="headlineTitle">SKU图像识别结果：{{ detail.skuNum }}个</span>
        </div>
        <el-table
          :data="skuList"
          style="width: 100%; border-radius: 10px"
          border
          class="table-headermd1">
          <el-table-column label="序号" type="index" align="center" width="40"> </el-table-column>
          <el-table-column
            label="品类"
            prop="skuProductType"
            align="center"
            width="60"></el-table-column>
          <el-table-column label="SKU名称" prop="name" align="center">
            <template slot-scope="scope">
              <span class="tipTitle">{{ scope.row.name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="排面数" prop="count" align="center" width="50"></el-table-column>
        </el-table>
      </div>
      <div class="skuDeatil" v-if="daojuList">
        <div class="headline" style="margin-top: 10px">
          <span class="headlineIcon"></span>
          <span class="headlineTitle">道具识别结果：{{ daojuNum }}个</span>
        </div>
        <el-table
          :data="daojuList"
          style="width: 100%; border-radius: 10px"
          border
          class="table-headermd1">
          <el-table-column label="序号" type="index" align="center" width="40"> </el-table-column>
          <el-table-column
            label="品类"
            prop="skuProductType"
            align="center"
            width="60"></el-table-column>
          <el-table-column label="道具名称" prop="name" align="center">
            <template slot-scope="scope">
              <span class="tipTitle">{{ scope.row.name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="count" align="center" width="50"></el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import deleteUploadImg from '@/components/deleteUploadImg';
import { photoSkuImgSummary, photoSkuFeedback } from '@/api/historicalVisit.js';
import { ImagePreview } from 'vant';
export default {
  name: 'perfectStoreSku',
  components: { deleteUploadImg },
  data() {
    return {
      visitsId: '',
      detail: null,
      daojuNum: 0,
      skuList: [],
      daojuList: [],
    };
  },
  activated() {
    this.visitsId = this.$route.query.visitId || '';
    this.detail = null;
    this.getDetail();
  },
  methods: {
    getDetail() {
      this.toastLoading(0, '加载中...', true);
      photoSkuImgSummary({ visitsId: this.visitsId })
        .then((res) => {
          this.toastLoading().clear();
          if (res.code == 200) {
            this.detail = res.data;
            this.skuList = [];
            this.daojuList = [];
            this.detail.skuList.forEach((val) => {
              if (val.skuProductType == '道具') {
                this.daojuList.push(val);
              } else {
                this.skuList.push(val);
              }
            });
            if (this.detail.skuTotal != null && this.detail.skuNum != null) {
              this.daojuNum = this.detail.skuTotal - this.detail.skuNum;
            } else {
              this.daojuNum = 0;
            }
          } else {
            this.$dialog.alert({
              message: res.msg,
            });
          }
        })
        .catch((err) => {
          this.$dialog.alert({
            message: err.msg,
          });
        });
    },
    previewsImg(index) {
      ImagePreview({
        images: this.detail.fileUrlList,
        startPosition: index,
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang="scss" scoped>
.perfectStoreSku {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .content {
    flex: 1;
    overflow-y: auto;
    // background: #fff;
    padding: 10px 15px;
    // margin-top: 10px;
    .container {
      background: #fff;
      width: 100%;
      border-radius: 6px;
      // padding: 10px;
      padding: 0 10px 10px 0px;
      .imgEow {
        .van-col {
          &:last-child {
          }
        }
      }
      .imgBox {
        width: 22%;
        height: 80px;
        position: relative;
        display: inline-block;
        border-radius: 6px;
        overflow: hidden;
        margin: 3px 1.5%;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
    .title {
      font-size: 16px;
      padding-bottom: 10px;
      font-weight: bold;
    }
    .tipsTitle {
      font-size: 12px;
      padding-bottom: 10px;
    }
    .tableTitle {
      padding: 10px 0;
      font-size: 16px;
      font-weight: bold;
      background: #f5f5f5;
      margin: 15px 0;
    }
    .skuDeatil {
    }
    .feedbackHistorical {
      .historicalContent {
        flex: 1;
        overflow-y: auto;
        .rejectMsgItem {
          margin-bottom: 20px;
          border: 1px solid #ccc;
          padding: 10px;
          .item {
            padding: 5px 0;
            span {
              display: inline-block;
            }
          }
          .label {
            width: 80px;
            font-size: 14px;
            font-weight: 600;
          }
          .value {
            font-size: 14px;
          }
        }
      }
    }
    .img-box {
      width: 100%;
      height: 80px;
      position: relative;
      display: inline-block;
      border-radius: 6px;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
  .feedbackMsgBox {
    min-height: 30%;
    width: 90%;
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .feedbackTitle {
      padding: 10px 0;
      text-align: center;
      font-size: 16px;
      font-weight: 600px;
    }
    .feedbackContent {
      flex: 1;
      overflow-y: auto;
      .van-field__control {
        color: #666 !important;
      }
    }
    .btnBox {
      margin-bottom: 10px;
      height: 44px;
      display: flex;
      justify-content: space-between;
      button {
        width: 45%;
        border-radius: 10px;
      }
    }
  }
  .headline {
    font-weight: 600;
    font-size: 16px;
    position: relative;
    display: flex;
    align-items: center;
    padding-top: 10px;
    .headlineIcon {
      display: inline-block;
      position: absolute;
      width: 3px;
      height: 60%;
      background: #3875c6;
      border-radius: 5px;
    }
    .headlineTitle {
      display: inline-block;
      padding: 0px 20px;
      background: #eef5ff;
      border-radius: 0 18px 18px 0;
      height: 36px;
      line-height: 36px;
    }
  }
}
</style>
<style lang="scss">
.skuDeatil {
  width: 100%;
  margin-top: 10px;
  background: #fff;
  border-radius: 6px;
  .table-headermd1 {
    font-size: 14px;
    text-align: center;
    position: initial;
    width: 96% !important;
    margin: 0 auto;
    border-right: 0;
    border-radius: 8px;
    margin-top: 10px;
    th {
      color: #000;
      font-weight: bold;
    }
    td {
      color: #000;
    }
    .el-table__cell {
      padding: 6px 0 !important;
      .cell {
        padding: 0;
      }
    }
  }
  .table-headermd1 th.el-table__cell {
    background-color: #f5f5f5;
  }
}
.feedbackMsgBox {
  .van-cell {
    border: 1px solid #ccc;
  }
  .van-field__control {
    color: #666;
  }
}
</style>
