<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="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="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="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="disabled" />
        <div class="data-box">
          <i class="iconfont iconxiangxia"></i>
        </div>
      </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="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.JSON)">-->
<!--        <i-->
<!--            :class="{-->
<!--            iconfont: true,-->
<!--            'i&#45;&#45;check': TypeNum === PropertyType.JSON,-->
<!--            iconxingzhuang2: TypeNum === PropertyType.JSON,-->
<!--            iconweixuanze: TypeNum !== PropertyType.JSON,-->
<!--          }"-->
<!--        ></i>-->
<!--        <span class="title">JSON</span>-->
<!--        <input type="text" class="half" value disabled="disabled" />-->
<!--        <input type="text" class="half" value disabled="disabled" />-->
<!--      </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="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="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>
import { PropertyType } from "@/plugins/types";
export default {
  props: ["selectedEditItem"],
  data() {
    return {
      PropertyType: PropertyType,
      TypeNum: -1,
    };
  },
  watch: {
    selectedEditItem: {
      handler(newName, oldName) {
        this.TypeNum = newName.type;
      },
      deep: true,
      immediate: true,
    },
  },
  created() {},
  computed: {},
  methods: {
    cancel() {
      this.$emit("cancel");
    },
    selectType() {
      if (this.TypeNum === -1) {
        this.$message({
          message: "未选择变更项目",
          type: "warning",
        });
        return false;
      }
      this.$emit("select-type", this.TypeNum);
      this.$emit("cancel");
    },
    // 选择
    select(val) {
      // 一级标题不可变更。
      if (
        this.selectedEditItem &&
        this.selectedEditItem.hasOwnProperty("title")
      ) {
        return false;
      }
      this.TypeNum = val;
    },
  },
};
</script>
<style scoped lang="less">
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 {
  width: 549px;
  height: 562px;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 0px 20px 0px rgba(61, 118, 249, 0.18);
  padding: 0 50px;
  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;
      }
      .iconweixuanze {
        color: #d1d1d1;
      }
      i {
        margin-right: 12px;
      }
      .i--check {
        color: #15cbba;
      }
      .data-box {
        position: absolute;
        top: 8px;
        right: 18px;

        i {
          color: #d8d8d8;
        }
        .iconxiangxia {
          font-size: 12px;
        }
      }
      .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: 135px;
        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>

