<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="roomWatch"
      >
        <textarea
          class="textarea"
          v-model="form.roomWatch"
          placeholder-style="color:#C7C7C7"
          placeholder="请输入需求文字"
          :disabled="isDisable"
        />

       <view >
        <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>
       </view>
      </uni-forms-item>
    </uni-forms>
  </view>
</template>
<script>
import { pad_room_type } from "@/utils/dict.js";

/**
 * 机房值班
 */
export default {
  props: {
    isDisable: {
      type: Boolean,
    },
  },
  data() {
    return {
      list: [],
      rules: {
        // 对notes字段进行必填验证
        roomWatch: {
          rules: [
            {
              required: true,
              errorMessage: "请输入内容",
            },
          ],
        },
      },
      form: {
        roomWatch: "", // 机房值班
      },
      quickTextList: [
        {
          text: "进出总人数：",
        },
        {
          text: "访客记录：",
        },
        {
          text: "有",
        },
        {
          text: "无",
        },
      ],
      roomTypeLabel: "机房值班", // 用于获取类型值
    };
  },
  mounted() {
    const roomTypeLabel = this.roomTypeLabel;
    const roomType = pad_room_type.rows.filter(
      (item) => item.dictLabel == roomTypeLabel
    )[0].dictValue;

    this.form.roomType = roomType;
  },
  methods: {
    // 回显数据
    setForm(componentData) {
      this.form = componentData;
    },

    clickQuick(item) {
      this.form.roomWatch = `${this.form.roomWatch}${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;
      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;
    }
  }

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