<template>
  <view>
    <u-navbar
      class="u-navbar"
      title="现场监护记录"
      placeholder
      @leftClick="leftClick"
      leftIconColor="#fff"
      bgColor="#00337A"
      :titleStyle="{ color: '#FFF', fontSize: '32rpx' }"
    />

    <view class="change-today">
      <view class="today-title">
        <view class="title-bold">日计划风险</view>
      </view>

      <uni-forms label-position="top" label-width="200">
        <uni-forms-item label="作业风险内容" required name="zynr">
          <u--textarea autoHeight v-model="riskDetailsInfo.zynr" disabled></u--textarea>
        </uni-forms-item>
        <uni-forms-item label="风险等级" required name="fxdjName">
          <u--input type="text" v-model="riskDetailsInfo.fxdjName" disabled />
        </uni-forms-item>
        <uni-forms-item label="工程名称" required name="proName">
          <u--textarea type="text" autoHeight v-model="riskDetailsInfo.proName" disabled />
        </uni-forms-item>
      </uni-forms>
    </view>

    <view class="scene-container">
      <view class="title-bold">现场监护</view>
      <uni-forms label-position="top" label-width="200">
        <uni-forms-item label="位置" required name="address">
          <view class="address-content">
            <u--input type="text" v-model="riskDetailsInfo.address" disabled />
            <view class="address-info">
              <text>
                {{ riskDetailsInfo.lat }}
              </text>
              <text>
                {{ riskDetailsInfo.lon }}
              </text>
            </view>
          </view>
        </uni-forms-item>
        <uni-forms-item label="附件" required>
          <view class="autograph">
            <view class="autograph-img-box">
              <view v-for="(item, index) in fileList" :key="index">
                <image
                  :src="`http://192.168.0.14:19191/ynPlanApp/${item}`"
                  mode="scaleToFill"
                  class="view-autograph"
                ></image>
              </view>
            </view>
          </view>
        </uni-forms-item>
        <uni-forms-item label="电子签名" required>
          <view class="autograph">
            <view class="autograph-img-box">
              <view v-for="(item, index) in autographList" :key="index">
                <image
                  :src="`http://192.168.0.14:19191/ynPlanApp/${item}`"
                  mode="scaleToFill"
                  class="view-autograph"
                ></image>
              </view>
            </view>
          </view>
        </uni-forms-item>
        <uni-forms-item label="备注" required name="remark">
          <u--textarea autoHeight v-model="riskDetailsInfo.remark" disabled></u--textarea>
        </uni-forms-item>
      </uni-forms>
    </view>
  </view>
</template>

<script>
import { getMySceneDataApi } from '../../../api/workPlan/riskDay'
export default {
  data() {
    return {
      riskDetailsInfo: {},
      fileList: [],
      autographList: []
    }
  },
  methods: {
    leftClick() {
      uni.navigateBack()
    },
    /* 获取详情数据 */
    async getMySceneListData(id) {
      const res = await getMySceneDataApi({ id })

      if (res.resMsg == 'success') {
        this.riskDetailsInfo = res.obj[0]
        this.fileList = res.obj[0].photoPath.split(',')
        this.autographList = res.obj[0].signPath.split(',')
      }
      console.log('风险详情数据---', res)
    }
  },
  onLoad(options) {
    const id = options.id
    this.getMySceneListData(id)
  }
}
</script>

<style lang="scss" scoped>
.custody-container {
  //   background-color: #ccc;

  .header-btn {
    display: flex;
    background-color: #fff;

    view {
      flex: 1;
      padding: 30rpx 0;
      color: #a8a8ad;
      font-size: 36rpx;
      text-align: center;
      transition: all 0.3s ease;
    }

    .active {
      color: #043372;
      border-bottom: 2px solid #043372;
    }
  }

  .swiper-item-content {
    background-color: #efefef;
  }

  .scroll-view-y {
    width: 100%;
    background-color: #efefef;

    .risk-header {
      width: 94%;
      margin: 16rpx auto;
      display: flex;
      align-items: center;
      background-color: #fff;
      padding: 2rpx 14rpx;
      border: 1px solid #ccc;
      border-radius: 6rpx;

      .risk-left {
        padding: 10rpx;
        border-radius: 10rpx;
        background-color: #da0019;
        color: #fff;
      }

      .risk-right {
        margin-left: 6rpx;
      }
    }
  }
}

::v-deep .address-content {
  position: relative;

  .address-info {
    position: absolute;
    right: 0;
    top: -30px;

    text {
      margin-right: 46rpx;
    }
  }
}
.autograph {
  position: relative;

  .autograph-img-box {
    width: 100%;
    display: flex;
    flex-wrap: wrap;

    .view-autograph {
      width: 100%;
      height: 180rpx;
    }

    view {
      width: 30%;
      margin-left: 5%;
      margin-top: 20rpx !important;
      height: 200rpx;
      // background-color: #eee;
      border: 1px solid #ccc;
      box-sizing: border-box;
      position: relative;

      .delete-icon {
        position: absolute;
        top: 3rpx;
        right: 3rpx;
      }
    }
  }
  .autograph-img-box view:nth-child(3n + 1) {
    margin: 0;
  }
}
.open-box {
  position: absolute;
  right: 0;
  top: -68rpx;
  // width: 140rpx;
  height: 68rpx;
  padding: 0 10rpx;
  line-height: 68rpx;
  text-align: center;
  background-color: #003777;
  color: #fff;
}

.autograph-container {
  width: 95vw;
  height: 50vh;
  padding-bottom: 18rpx;
  background-color: #fff;
  display: flex;
  flex-direction: column;

  .autograph-btn {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 12rpx 0;

    view {
      width: 15%;
      height: 62rpx;
      border-radius: 12rpx;
      border: 1px solid $u-primary;
      color: $u-primary;
      line-height: 62rpx;
      text-align: center;
    }
  }
  .autograph-area {
    width: 94%;
    margin: 0 auto;
    padding: 10rpx 0;
  }

  .autograph-area-box {
    margin: 0 auto;
    width: 94%;
    flex: 1;
    border: 1px solid #fa3534;
  }
}

.submit-btn {
  width: 96%;
  height: 78rpx;
  margin: 0 auto;
  border-radius: 14rpx;
  background-color: #003777;
  font-size: 26rpx;
  text-align: center;
  line-height: 78rpx;
  color: #fff;
}

.my-data-header-container,
.my-data-container {
  width: 96%;
  margin: 16rpx auto 20rpx;
  padding: 12rpx 0;
  border: 1px solid #ccc;
  background-color: #fff;
  border-radius: 10prx;
}

.my-data-header {
  width: 96%;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.my-data-content {
  width: 96%;
  margin: 0 auto 15rpx;
  padding: 15rpx 0;
  border: 1px solid #ccc;
  border-radius: 6prx;

  .data-risk {
    display: flex;
    justify-content: space-between;
    padding: 10rpx;
  }

  .pro-name-box {
    padding: 10rpx;
  }

  .pro-content {
    width: 98%;
    margin: 0 auto;
    // padding: 15rpx 10rpx;
    border: 1px solid #ccc;
    border-radius: 6rpx;
  }
}

.change-today {
  width: 94%;
  margin: 16rpx auto;
  padding: 26rpx;
  border: 1px solid #ccc;
  background-color: #fff;
  border-radius: 6rpx;

  .today-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  // .today-title view:last-child {
  //   padding: 26rpx 6rpx;
  //   background-color: #d6001a;
  //   border-radius: 20rpx;
  //   color: #fff;
  // }

  ::v-deep .uni-forms-item__label {
    font-weight: bold;
    color: #000;
    font-size: 26rpx;
  }
}
.scene-container {
  width: 94%;
  margin: 16rpx auto;
  padding: 26rpx;
  border: 1px solid #ccc;
  background-color: #fff;
  border-radius: 6rpx;

  ::v-deep .uni-forms-item__label {
    font-weight: bold;
    color: #000;
    font-size: 26rpx;
  }
}
.title-bold {
  font-size: 32rpx;
  font-weight: bold;
}
</style>
