<template>
  <div>
    <LHeader text="备注"></LHeader>
    <van-field
      v-model="messageText"
      rows="10"
      autosize
      label="备注信息"
      type="textarea"
      maxlength="500"
      placeholder="请输入备注信息"
      show-word-limit
    />
    <div
      style="display: flex;
        justify-content: space-around;
        background-color: #fff;
        border-top: 1px solid #e3e3e3;
        height: 1.5rem;
        width: 100%;
        text-align: center;
        position: fixed;
        bottom: 0;"
    >
      <div
        @click="appvore"
        style="color: #4bced0;font-size: 14px;font-weight: 600;"
      >
        <div style="font-size: 22px;"><van-icon name="success" /></div>
        <div>保存</div>
      </div>
    </div>
  </div>
</template>

<script>
import LHeader from "@/components/header.vue";
import { getFun, postFun } from "@/service/table.js";
export default {
  name: "risk-appvore-text",
  components: {
    LHeader
  },

  data() {
    return {
      messageText: null,
      result: null,
      buildingIds: [],
      planId: 0
    };
  },
  created() {
    this.result = this.$route.params.result;
    this.buildingIds = this.$route.params.buildingIds;
    this.planId = this.$route.params.planId;
  },
  methods: {
    //审批
    appvore() {
      var buildingDtos = [];
      for (let i = 0; i < this.buildingIds.length; i++) {
        var buildingDto = {
          buildingId: this.buildingIds[0],
          taskResult: this.result,
          taskOpinion: this.messageText
        };
        buildingDtos[i] = buildingDto;
      }
      console.log(buildingDtos);
      var params = {
        id: this.planId,
        taskResult: this.result,
        taskOpinion: this.messageText,
        buildingDtos: buildingDtos
      };
      postFun("/risk/plan/approve", params)
        .then(res => {
          console.log(res);
        })
        .catch(() => {
          this.$toast.clear();
          this.$toast.fail("加载失败,请稍后再试");
        });
      this.$router.replace({
        name: "riskApprove",
        params: {}
      });
    }
  },
  watch: {}
};
</script>
