<template>
  <van-popup :show="show" @close="onClose" round closeable>
    <div class="height554rpx width622rpx allpd32rpx" style="margin-top: 70rpx">
      <div class="width100 height35px marginb16 mt32rpx">
        <div class="handlefont width20 float_left height35px l35pxheight">
          处理人:
        </div>
        <div class="width80 float_left">
          <uni-easyinput
            :inputBorder="true"
            v-model="form.handleUserName"
            placeholder="请输入"
          ></uni-easyinput>
        </div>
      </div>
      <div class="width100 mb32rpx">
        <div class="handlefont width100 mb32rpx">处理说明</div>
        <div class="width100">
          <uni-easyinput
            v-model="form.handleResult"
            autoHeight
            type="textarea"
            placeholder="请输入"
          ></uni-easyinput>
        </div>
      </div>
      <div class="width100">
        <div class="button_row cancel_btn" @click="onClose()">取消</div>
        <div class="button_row ok_btn" @click="dialogInputConfirm()">确认</div>
      </div>
    </div>
  </van-popup>
</template>

<script>
import vanPopup from "../../../../wxcomponents/weapp/dist/popup/index";
import vanField from "../../../../wxcomponents/weapp/dist/field/index";
import { editInterview } from "@/js_sdk/http.js";
export default {
  name: "handlereport",
  data() {
    return {
      show: false,
      form: {
        name: "",
        message: "",
      },
    };
  },
  components: {
    vanPopup,
    vanField,
  },
  methods: {
    openDianlog(item) {
      this.form = { ...item };
      this.show = true;
    },
    onClose() {
      this.show = false;
    },
    getNowDate() {
      var date = new Date();
      var sign2 = ":";
      var year = date.getFullYear(); // 年
      var month = date.getMonth() + 1; // 月
      var day = date.getDate(); // 日
      var hour = date.getHours(); // 时
      var minutes = date.getMinutes(); // 分
      var seconds = date.getSeconds(); //秒
      var weekArr = [
        "星期一",
        "星期二",
        "星期三",
        "星期四",
        "星期五",
        "星期六",
        "星期天",
      ];
      var week = weekArr[date.getDay()];
      // 给一位数的数据前面加 “0”
      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (day >= 0 && day <= 9) {
        day = "0" + day;
      }
      if (hour >= 0 && hour <= 9) {
        hour = "0" + hour;
      }
      if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
      }
      if (seconds >= 0 && seconds <= 9) {
        seconds = "0" + seconds;
      }
      return (
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hour +
        sign2 +
        minutes +
        sign2 +
        seconds
      );
    },
    async dialogInputConfirm() {
      if (!this.form.handleUserName || this.form.handleUserName.length == 0) {
        this.$showToast("请填写处理人名称");
        return;
      }
      if (!this.form.handleResult || this.form.handleResult.length == 0) {
        this.$showToast("请填写处理说明");
        return;
      }
      this.form.handleTime = this.getNowDate();
      let data = await editInterview({ ...this.form });
      if (data.code == 200) {
        this.$showToast("登记完成");

        this.show = false;
        this.$emit("changeActive");
      }
    },
  },
};
</script>

<style scoped>
.handlefont {
  font-size: 28rpx;
  font-family: Segoe UI-Regular, Segoe UI;
  font-weight: 400;
  color: #777777;
}
.button_row {
  color: #ffffff;
  background: #1d18bc;
  width: 140rpx;
  height: 50rpx;
  border-radius: 8rpx 8rpx 8rpx 8rpx;
  opacity: 1;
  text-align: center;
  line-height: 50rpx;
  font-size: 24rpx;
  border: 2rpx solid #1d18bc;
}
.cancel_btn {
  position: absolute;
  top: 545rpx;
  left: 20rpx;
}
.ok_btn {
  position: absolute;
  right: 20rpx;
  top: 545rpx;
}
</style>
