<template>
  <div class="box">
    <!-- <h1>设置表现形式</h1> -->
    <div class="center">
      <div class="optional" @click="select(PropertyType.Input)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Input,
            iconxingzhuang2: TypeNum === PropertyType.Input,
            iconweixuanze: TypeNum !== PropertyType.Input,
          }"
        ></i>
        <span class="title">输入框</span>
        <input type="text" value disabled />
      </div>
      <div class="optional" @click="select(PropertyType.Date)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Date,
            iconxingzhuang2: TypeNum === PropertyType.Date,
            iconweixuanze: TypeNum !== PropertyType.Date,
          }"
        ></i
        ><span class="title">日期</span>
        <input type="text" disabled />
        <div class="data-box">
          <i class="iconfont iconxingzhuang"></i>
        </div>
      </div>
      <div class="optional" @click="select(PropertyType.Link)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Link,
            iconxingzhuang2: TypeNum === PropertyType.Link,
            iconweixuanze: TypeNum !== PropertyType.Link,
          }"
        ></i>
        <span class="title">外部链接</span>
        <input type="text" value disabled />
      </div>

      <!-- 下拉框 -->
      <div class="optional" @click="select(PropertyType.Select)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Select,
            iconxingzhuang2: TypeNum === PropertyType.Select,
            iconweixuanze: TypeNum !== PropertyType.Select,
          }"
        ></i
        ><span class="title">下拉框</span>
        <input type="text" value disabled />
        <span class="data-box">
          <img
            src="@/assets/img/arrow_down.png"
            class=""
            alt=""
            style="width: 15px; margin-right: 13px"
          />
        </span>
      </div>
      <!--  -->
      <div class="optional" @click="select(PropertyType.Audio)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Audio,
            iconxingzhuang2: TypeNum === PropertyType.Audio,
            iconweixuanze: TypeNum !== PropertyType.Audio,
          }"
        ></i
        ><span class="title">上传音频</span>
        <div class="big-box">
          <div class="pic-box">
            <i class="iconfont iconshangchuanwenjianbeifen"></i>
          </div>
        </div>
      </div>

      <div class="optional" @click="select(PropertyType.TextArea)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.TextArea,
            iconxingzhuang2: TypeNum === PropertyType.TextArea,
            iconweixuanze: TypeNum !== PropertyType.TextArea,
          }"
        ></i
        ><span class="title">文本域</span>
        <input type="text" value disabled />
      </div>
      <!--  -->
      <div class="optional" @click="select(PropertyType.File)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.File,
            iconxingzhuang2: TypeNum === PropertyType.File,
            iconweixuanze: TypeNum !== PropertyType.File,
          }"
        ></i
        ><span class="title">上传PDF</span>
        <div class="big-box">
          <div class="pic-box">
            <i class="iconfont iconshangchuanwenjianbeifen"></i>
          </div>
        </div>
      </div>

      <div class="optional" @click="select(PropertyType.Video)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Video,
            iconxingzhuang2: TypeNum === PropertyType.Video,
            iconweixuanze: TypeNum !== PropertyType.Video,
          }"
        ></i
        ><span class="title">上传视频</span>
        <div class="big-box" style="width: 138px !important">
          <div class="pic-box">
            <i class="iconfont iconshangchuanwenjianbeifen"></i>
          </div>
        </div>
      </div>
      <div class="optional" @click="select(PropertyType.Image)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Image,
            iconxingzhuang2: TypeNum === PropertyType.Image,
            iconweixuanze: TypeNum !== PropertyType.Image,
          }"
        ></i
        ><span class="title">上传图片</span>
        <div class="big-box">
          <div class="pic-box">+</div>
        </div>
      </div>
      <div class="optional" @click="select(PropertyType.ImageUrl)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.ImageUrl,
            iconxingzhuang2: TypeNum === PropertyType.ImageUrl,
            iconweixuanze: TypeNum !== PropertyType.ImageUrl,
          }"
        ></i>
        <span class="title">图片链接</span>
        <input type="text" value disabled />
      </div>
      <div class="optional" @click="select(PropertyType.TextArray)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.TextArray,
            iconxingzhuang2: TypeNum === PropertyType.TextArray,
            iconweixuanze: TypeNum !== PropertyType.TextArray,
          }"
        ></i>
        <span class="title">文本数组</span>
        <input type="text" value disabled />
      </div>
      <div class="optional" @click="select(PropertyType.Editor)">
        <div class="left">
          <i
            :class="{
              iconfont: true,
              'i--check': TypeNum === PropertyType.Editor,
              iconxingzhuang2: TypeNum === PropertyType.Editor,
              iconweixuanze: TypeNum !== PropertyType.Editor,
            }"
          ></i
          ><span class="title">编辑器</span>
        </div>
        <div class="editor"></div>
      </div>
    </div>
    <!-- <div class="footer">
      <div class="btn btn--cancel" @click="cancel">取消</div>
      <div class="btn" @click="selectType">确定</div>
    </div> -->
  </div>
</template>

<script lang="ts">
import { PropertyType } from "./types";
import { defineComponent } from "vue";
import { ElMessage } from "element-plus";
export default defineComponent({
  props: ["selectedEditItem"],
  data() {
    return {
      PropertyType: PropertyType,
      TypeNum: -1,
    };
  },
  watch: {
    selectedEditItem: {
      handler(newName, oldName) {
        this.TypeNum = newName.type;
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    cancel() {
      this.$emit("cancel");
    },
    selectType() {
      if (this.TypeNum === -1) {
        ElMessage.warning("未选择变更项目");
        return false;
      }
      this.$emit("select-type", this.TypeNum);
      this.$emit("cancel");
    },
    // 选择
    select(val: number) {
      // 一级标题不可变更。
      if (
        this.selectedEditItem &&
        Object.prototype.hasOwnProperty.call(this.selectedEditItem, "title")
      ) {
        return false;
      }
      this.TypeNum = val;
    },
  },
});
</script>
<style scoped lang="scss">
* {
  box-sizing: content-box;
}
input {
  width: 140px;
  height: 30px;
  background: rgba(255, 255, 255, 1);
  border-radius: 4px;
  border: 1px solid rgba(231, 231, 231, 1);
  font-size: 12px;
  font-weight: 400;
  text-indent: 12px;
  color: #d8d8d8;
  margin-left: 8px;

  &.half {
    width: 66px;
  }
}
.box {
  margin-top: 38px;
  background: rgba(255, 255, 255, 1);
  h1 {
    margin: 0;
    padding: 0;
    font-size: 16px;
    font-weight: 500;
    color: rgba(0, 0, 0, 1);
    line-height: 1;
    padding-top: 38px;
    padding-bottom: 16px;
  }
  .center {
    width: 494px;
    height: 312px;
    background: rgba(251, 251, 251, 1);
    border: 1px solid rgba(240, 240, 240, 1);
    margin: 0 auto;
    padding: 18px 28px;
    .optional {
      cursor: pointer;
      float: left;
      font-size: 12px;
      margin-bottom: 16px;
      width: 247px;
      font-weight: 400;
      position: relative;
      color: #353535;
      .title {
        width: 48px;
        display: inline-block;
        white-space: nowrap;
      }
      .iconweixuanze {
        color: #d1d1d1;
      }
      i {
        margin-right: 12px;
      }
      .i--check {
        color: #15cbba;
      }
      .data-box {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 18px;
        color: #d8d8d8;
      }
      .big-box {
        width: 140px;
        height: 32px;
        display: inline-block;
        margin-left: 8px;
      }
      .pic-box {
        width: 35px;
        height: 32px;
        background: rgba(255, 255, 255, 1);
        border-radius: 4px;
        border: 1px solid rgba(231, 231, 231, 1);
        display: inline-block;
        line-height: 32px;
        text-align: center;
        color: #d8d8d8;
        font-size: 20px;
        i {
          margin: 0;
        }
      }
      .editor {
        width: 140px;
        height: 75px;
        margin-left: 8px;
        background: rgba(255, 255, 255, 1);
        border-radius: 4px;
        float: left;
        border: 1px solid rgba(231, 231, 231, 1);
      }
      .left {
        float: left;
      }
    }
  }
  .footer {
    overflow: hidden;
    float: right;
    margin-top: 28px;
    .btn {
      width: 120px;
      height: 40px;
      background: rgba(63, 121, 254, 1);
      border-radius: 4px;
      float: left;
      color: white;
      cursor: pointer;
      font-size: 14px;
      text-align: center;
      line-height: 40px;
    }
    .btn--cancel {
      background: white;
      color: #5c6476;
    }
  }
}
</style>
