<!--  -->
<template>
  <div class="Big-Book-Sudoku" v-if="curQue">
    <div class="Big-Book-Sudoku-content">
      <div class="adult-book-input-item">
        <span class="adult-book-lable">标题：</span>           
        <el-input
          type="textarea"
          class="adult-book-input"
          :autosize="{ minRows: 2 }"
          placeholder="请输入标题"
          v-model="curQue.title"
          @blur="onBlur(curQue, 'title')"
        ></el-input>
      </div>
      <p>双击修改为提示</p>
      <div class="Big-Book-table">
        <div v-for="(item, index) in curQue.option" :key="index">
          <div v-for="(it, itindex) in item" :key="itindex + 'td'">
            <input
              :class="it.isHint ? 'dbclick' : ''"
              type="text"
              @input="changeNumber(it)"
              maxlength="1"
              v-model="it.value"
              @dblclick="dbClickHint(it)"
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Sudoku",
  props: ["curQue", "fn_data", "changeCurQue"],
  components: {},
  data() {
    return {
      data_structure: {
        type: "sudoku_chs",
        name: "数独",
        title: "",
        option: [
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
          [
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
            {
              value: "",
              isHint: false, //是不是提示
            },
          ],
        ],
      },
      hintNumber: 0,
    };
  },
  computed: {},
  watch: {},
  //方法集合
  methods: {
    dbClickHint(item) {
      if (item.isHint) {
        if (this.hintNumber > 0) {
          this.hintNumber--;
          item.isHint = false;
        }
      } else {
        if (this.hintNumber < 17) {
          this.hintNumber++;
          item.isHint = true;
        }else{
          this.$message.warning("最多为17个提示")
          return
        }
      }
    },
    changeNumber(item) {
      item.value = item.value.replace(/[^\d]/g, "");
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    if (!this.curQue) {
      let res_data = JSON.parse(JSON.stringify(this.data_structure));
      this.changeCurQue(res_data);
    }
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='scss' scope>
//@import url(); 引入公共css类
.Big-Book-Sudoku {
  &-content {
    &.m {
      display: flex;
      justify-content: flex-start;
      align-items: flex-start;
    }

    .Big-Book-title {
      font-size: 16px;
      line-height: 40px;
      color: #000;
      margin-right: 15px;
    }
    .Big-Book-main {
      > div {
        margin-bottom: 10px;
        &.Big-Book-pinyin {
          display: flex;
          justify-content: flex-start;
          align-items: center;
        }
      }
    }
  }
  .addoption {
    width: 565px;
    height: 40px;
    left: 40px;
    top: 304px;
    background: #f3f3f3;
    border: 1px dashed rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    border-radius: 4px;
    text-align: center;
    line-height: 40px;
    cursor: pointer;
  }
  .Big-Book-table {
    width: 546px;
    height: 546px;
    display: flex;
    flex-wrap: wrap;
    > div {
      display: flex;
      flex-wrap: wrap;
      width: 182px;
      height: 182px;
      border: 1px solid #484848;
      box-sizing: border-box;
      > div {
        width: 60px;
        height: 60px;
        border: 1px solid #d1d1d1;
        box-sizing: border-box;
        input {
          width: 100%;
          height: 100%;
          border: none;
          outline: none;
          font-size: 20px;
          line-height: 150%;
          color: #000000;
          text-align: center;
        }
        .dbclick {
          background: #bdbdbd;
        }
      }
    }
  }
}
</style>
<style lang="scss">
</style>