<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>
        输入框
        <input type="text" value disabled="disabled" />
      </div>
      <div class="optional optional--right" @click="select(PropertyType.Date)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Date,
            iconxingzhuang2: TypeNum === PropertyType.Date,
            iconweixuanze: TypeNum !== PropertyType.Date,
          }"
        ></i
        >日期
        <input type="text" class="mr" value disabled="disabled" />
        <div class="data-box">
          <i class="iconfont iconxingzhuang"></i>
        </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
        >上传图片
        <div class="big-box">
          <div class="pic-box">+</div>
        </div>
      </div>
      <!-- 下拉框 -->
      <div
        class="optional optional--right"
        @click="select(PropertyType.Select)"
      >
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Select,
            iconxingzhuang2: TypeNum === PropertyType.Select,
            iconweixuanze: TypeNum !== PropertyType.Select,
          }"
        ></i
        >下拉框
        <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
        >上传音频
        <div class="big-box">
          <div class="pic-box">
            <i class="iconfont iconshangchuanwenjianbeifen"></i>
          </div>
        </div>
      </div>

      <div
        class="optional optional--right"
        @click="select(PropertyType.TextArea)"
      >
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.TextArea,
            iconxingzhuang2: TypeNum === PropertyType.TextArea,
            iconweixuanze: TypeNum !== PropertyType.TextArea,
          }"
        ></i
        >文本域
        <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
        >上传PDF
        <div class="big-box">
          <div class="pic-box">
            <i class="iconfont iconshangchuanwenjianbeifen"></i>
          </div>
        </div>
      </div>

      <div class="optional optional--right" @click="select(PropertyType.Video)">
        <i
          :class="{
            iconfont: true,
            'i--check': TypeNum === PropertyType.Video,
            iconxingzhuang2: TypeNum === PropertyType.Video,
            iconweixuanze: TypeNum !== PropertyType.Video,
          }"
        ></i
        >上传视频
        <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.Editor)">
        <div class="left">
          <i
            :class="{
              iconfont: true,
              'i--check': TypeNum === PropertyType.Editor,
              iconxingzhuang2: TypeNum === PropertyType.Editor,
              iconweixuanze: TypeNum !== PropertyType.Editor,
            }"
          ></i
          >编辑器
        </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: 16px;
}
.box {
  width: 549px;
  height: 478px;
  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: 276px;
    background: rgba(251, 251, 251, 1);
    border: 1px solid rgba(240, 240, 240, 1);
    margin: 0 auto;
    padding: 18px 28px;
    .optional--right {
      float: right !important;
      margin-right: 13px;
      // border: 1px solid #000;
    }
    .optional {
      cursor: pointer;
      float: left;
      font-size: 12px;
      margin-bottom: 16px;
      font-weight: 400;
      position: relative;
      color: rgba(53, 53, 53, 1);
      .iconweixuanze {
        color: #d1d1d1;
      }
      i {
        margin-right: 12px;
      }
      .i--check {
        color: #15cbba;
      }
      .mr {
        margin-left: 28px;
      }
      .data-box {
        position: absolute;
        top: 8px;
        right: 10px;

        i {
          color: #d8d8d8;
        }
        .iconxiangxia {
          font-size: 12px;
          // transform: scale(0.46);
        }
      }
      .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: 391px;
        height: 75px;
        margin-left: 24px;
        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>

