import HeaderMain from "../../components/HeaderMain";
import ShareSetting from "../../components/ShareSetting";
export default {
  components: {
    HeaderMain, ShareSetting
  },
  data() {
    return {
      isCopy: false,
      isShareSetting: false,
      cities: [{
        value: 'Beijing',
        label: '北京'
      }, {
        value: 'Shanghai',
        label: '上海'
      }, {
        value: 'Nanjing',
        label: '南京'
      }, {
        value: 'Chengdu',
        label: '成都'
      }, {
        value: 'Shenzhen',
        label: '深圳'
      }, {
        value: 'Guangzhou',
        label: '广州'
      }],
      value: '',
      lists: [{ index: 0 }, { index: 1 }, { index: 2 }, { index: 3 }, { index: 4 }, { index: 5 }, { index: 6 }, { index: 7 }, { index: 8 }, { index: 9 }, { index: 10 }, { index: 11 }, { index: 12 }, { index: 13 }, { index: 14 }, { index: 15 }, { index: 16 }, { index: 17 }, { index: 18 }, { index: 19 }]
    }
  },
  watch: {
    isShareSetting: function (val) {
      var mo = function (e) { e.preventDefault(); };
      document.body.style.overflow = val ? 'hidden' : '';
      if (val) {
        document.addEventListener("touchmove", mo, false);
      } else {
        document.removeEventListener("touchmove", mo, false);
      }
    }
  },
  methods: {
    createTest() {
      this.$router.push({ path: '/cncTestLists' });
    },
    deleteTest(index) {
      const h = this.$createElement;
      this.$msgbox({
        title: '删除',
        message: '删除后不可撤回，确定删除此套测题？',
        showCancelButton: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = '执行中...';
            setTimeout(() => {
              done();
              setTimeout(() => {
                instance.confirmButtonLoading = false;
              }, 300);
            }, 3000);
          } else {
            done();
          }
        }
      }).then(() => {
        this.lists.splice(index, 1);
        this.$message({
          type: 'success',
          message: '删除成功'
        });
      }).catch(() => { });
    },
    copyTest() {
      this.$message({
        message: '复制成功',
        type: 'success'
      });
      this.lists.unshift({ index: 100 });
      this.isCopy = true;
      setTimeout(() => {
        this.isCopy = false;
      }, 2000);
    },
    editTest() {
      this.$router.replace({ path: '/h5editor', query: { itemId: 0 } })
    },
    shareTest() {
      this.isShareSetting = true;
    },
    closeShare() {
      this.isShareSetting = false;
    }
  },
}