<template>
  <view class="gather-dataCenter">
    <uni-forms
      :modelValue="form"
      label-width="82px"
      class="inspection-item"
      ref="forms"
      :rules="rules"
      label-position="top"
    >
      <uni-forms-item
        class="row-item"
        required
        label="值班交接"
        name="dutyHandover"
      >
        <textarea
          class="textarea"
          v-model="form.dutyHandover"
          placeholder-style="color:#C7C7C7"
          placeholder="请输入"
          :disabled="isDisable"

        />

        <text v-if="!isDisable" class="quick-input"> 快捷输入 </text>

        <text v-if="!isDisable">
          <text
            class="qucik-text"
            v-for="item in quickTextList"
            :key="item.text"
            @click="clickQuick(item)"
            >{{ item.text }}</text
          >
        </text>
      </uni-forms-item>

      <view class="user-info">
        <uni-forms-item class="row-item" label="交班人">
          <text class="text">{{ form.handoverPerson }}</text>
        </uni-forms-item>

        <uni-forms-item
          class="row-item"
          required
          label="接班人"
          name="successor"
        >
          <uni-easyinput
          :disabled="isDisable"

            type="text"
            v-model="form.successor"
            placeholder="请输入"
          />
        </uni-forms-item>
      </view>
    </uni-forms>
  </view>
</template>
<script>
import { pad_room_type } from "@/utils/dict.js";

/**
 * 值班交接
 */
export default {
  props: {
    isDisable: {
      type: Boolean,
    },
  },
  data() {
    return {
      rules: {
        // 对notes字段进行必填验证

        dutyHandover: {
          rules: [
            {
              required: true,
              errorMessage: "请输入内容",
            },
          ],
        },
        successor: {
          rules: [
            {
              required: true,
              errorMessage: "请输入内容",
            },
          ],
        },
      },
      form: {
        dutyHandover: "", // 机房值班
        handoverPerson: "", //交班人
        successor: "", // 接班人
      },
      quickTextList: [
        {
          text: "未完成事项：",
         
        },
        {
          text: "有",
         
        },
        {
          text: "无",
         
        },
      ],
      roomTypeLabel: "值班交接", // 用于获取类型值
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      const roomTypeLabel = this.roomTypeLabel;
      const roomType = pad_room_type.rows.filter(
        (item) => item.dictLabel == roomTypeLabel
      )[0].dictValue;

      this.form.roomType = roomType;
      this.form.handoverPerson = this.$store.state.now_user.user;
    },
    // 回显数据
    setForm(componentData) {
      this.form = componentData;
    },
    clickQuick(item) {
      this.form.dutyHandover = `${this.form.dutyHandover}${item.text}`;
    },

    // 校验数据 所有表单
    async vaildForm() {
      return new Promise((resolve, reject) => {
        this.$refs.forms
          .validate()
          .then((res) => {
            resolve({
              vaild: true,
              formData: this.form,
            });
          })
          .catch((error) => {
            resolve({
              vaild: false,
              formData: this.form,
            });
          });
      });
    },
  },
};
</script>

<style lang="less" scoped>
.gather-dataCenter {
  .inspection-item {
    border: 1px solid;
    margin-bottom: 12px;
    background: #ffffff;
    border: 0.4px solid rgba(224, 224, 224, 1);
    border-radius: 12px;
    padding: 24px 24px 8px 24px;
    .text {
      font-size: 16px;
      color: #000000;
      line-height: 24px;
      font-weight: bold;
    }
    .textarea {
      width: 100%;
      min-height: 96px;
      background: #f7f7f7;
      border-radius: 12px;
      font-size: 14px;
      color: #4a4a4a;
      padding: 16px;
      font-weight: 400;
      margin-bottom: 14px;

    }
    .quick-input {
      margin: 16px 18px 18px 0 ;
      font-size: 14px;
      color: #7c7c7c;
      font-weight: 400;
    }
    .qucik-text {
      display: inline-block;
      border: 1px solid rgba(242, 242, 242, 1);
      border-radius: 8px;
      // width: 72px;
      padding: 0 10px;
      height: 32px;
      font-size: 12px;
      color: #4a4a4a;
      line-height: 20px;
      font-weight: 400;
      margin-right: 12px;
      line-height: 32px;
      text-align: center;
    }
  }

  .user-info {
    display: flex;
    .uni-forms-item {
      flex: 1;
      display: flex;
      flex-direction: row;
    }
  }

  // /deep/ .uni-forms-item__content {
  //   display: flex;
  //   align-items: center;
  // }
}
</style>
