export default {
  data() {
    var that = this;
    return {
      froalaConfig: {
        //More -> https://www.froala.com/wysiwyg-editor/docs/options
        // toolbarButtons: ['undo', 'redo', 'clearFormatting', '|', 'bold', 'italic', 'underline','strikeThrough','|', 'fontFamily', 'fontSize', 'color', '|','paragraphFormat', 'align', 'formatOL', 'formatUL', 'outdent', 'indent', 'quote', '-', 'insertLink', 'insertImage', 'insertVideo', 'embedly', 'insertFile', 'insertTable', '|', 'emoticons', 'specialCharacters', 'insertHR', 'selectAll', '|', 'print', 'spellChecker', 'help', '|', 'fullscreen'],//['fullscreen', 'bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', '|', 'fontFamily', 'fontSize', 'color', 'inlineStyle', 'paragraphStyle', '|', 'paragraphFormat', 'align', 'formatOL', 'formatUL', 'outdent', 'indent', 'quote', '-', 'insertLink', 'insertImage', 'insertVideo', 'embedly', 'insertFile', 'insertTable', '|', 'emoticons', 'specialCharacters', 'insertHR', 'selectAll', 'clearFormatting', '|', 'print', 'spellChecker', 'help', 'html', '|', 'undo', 'redo'],//显示可操作项
        toolbarButtons: [
          "insertImage",
          "textColor",
          "bold",
          "italic",
          "underline",
          "strikeThrough",
          "fontFamily",
          "fontSize",
          "color",
          "paragraphStyle",
          "lineHeight",
          "paragraphFormat",
          "align",
          "insertHR",
          "undo",
          "redo",
        ],
        height: 200,
        fontSize: ["12", "14", "16", "18", "20", "24", "28", "32", "36", "40"],
        fontSizeDefaultSelection: "16",
        theme: "dark", //主题
        placeholderText: "请输入文字描述",
        language: "zh_cn", //国际化
        imageUploadURL: process.env.API_ROOT + "/report/uploadImg", //上传url
        videoUploadURL: process.env.API_ROOT + "/report/uploadImg", //上传url
        fileUploadURL: process.env.API_ROOT + "/report/uploadImg", //上传url 更多上传介绍 请访问https://www.froala.com/wysiwyg-editor/docs/options
        imageDefaultWidth: false,
        // imageEditButtons:['imageAlign', 'imageCaption', 'imageRemove', '|', 'imageLink', 'linkOpen', 'linkEdit', 'linkRemove', '-', 'imageDisplay', 'imageStyle', 'imageAlt', 'imageSize'],
        quickInsertButtons: ["image", "table", "ul", "ol", "hr"], //快速插入项
        toolbarVisibleWithoutSelection: true, //是否开启 不选中模式
        // disableRightClick:true,//是否屏蔽右击
        // colorsHEXInput:false,//关闭16进制色值
        toolbarSticky: false, //操作栏是否自动吸顶
        // zIndex:99999,
        saveInterval: 0,
        events: {
          initialized: function () {
            // this.editor = editor;
            that.editor = this;
            // that.editor.html.set(that.value);
            // that.setHtml()
          },
          keyup: function (e, editor) {
            //添加事件，在每次按键按下时，都记录一下最后停留位置
            that.$nextTick(function () {
              that.lastEditRange = getSelection().getRangeAt(0);
            });
          },
          click: function (e, editor) {
            //添加事件，在每次鼠标点击时，都记录一下最后停留位置
            that.$nextTick(function () {
              that.lastEditRange = getSelection().getRangeAt(0);
            });
          },
        },
        charCounterCount: false,
        reportloadding: false,
        lastsavetime: "",
        isAddEnter: false, //是否已经添加过
        timer: null,
        ischange: false,
        isPublishloading: false,
      },
      ruleForm: {
        title: "", //标题
        author: "", //作者
        time: "", //时间
        explain: "", //说明
        alteration: "", //变更
      },
      rules: {
        title: [{ required: true, message: "请输入标题", trigger: "blur" }],
        author: [{ required: true, message: "请输入作者", trigger: "blur" }],
        time: [{ required: true, message: "请输入时间", trigger: "change" }],
        explain: [{ required: true, message: "请输入摘要", trigger: "blur" }],
      },
      //产业调研纪要篇
      ListCydyjy: [],
      SortCydyjy: "",
      //上市公司调研纪要篇
      ListSsgs: [],
      SortSsgs: "",
      //产业调研纪要篇 上市公司调研纪要篇 输入框是否高亮
      isSortCydyjyShow: true,
      isSortSsgsShow: true,
    };
  },
  methods: {
    //深度报告篇 产业调研纪要篇 本周晨会精华
    addListSdbg(item, index, type) {
      switch (type) {
        case "深度报告篇":
          this.ListSdbg[index].List.push({ Body: "", ReportLink: "" });
          break;
        case "产业调研纪要篇":
          this.ListCydyjy[index].List.push({ Body: "", ReportLink: "" });
          break;
        case "上市公司调研纪要篇":
          this.ListSsgs[index].List.push({ Body: "", ReportLink: "" });
          break;
        case "本周晨会精华":
          this.ListBzchjh[index].List.push({ Body: "", ReportLink: "" });
        // case "研选":
        // this.ListYanx[index].List.push({ Body: "", ReportLink: "" });
          break;
      }
    },
    //深度报告篇 产业调研纪要篇 本周晨会精华
    deleteListSdbg(item, num, index, type) {
      switch (type) {
        case "深度报告篇":
          this.ListSdbg[index].List.splice(num, 1);
          break;
        case "产业调研纪要篇":
          this.ListCydyjy[index].List.splice(num, 1);
          break;
        case "上市公司调研纪要篇":
          this.ListSsgs[index].List.splice(num, 1);
          break;
        case "本周晨会精华":
          this.ListBzchjh[index].List.splice(num, 1);
          // case "研选":
          // this.ListYanx[index].List.splice(num, 1);
          break;
      }
    },
    chidrenList(list) {
      const flag = list.some((item) => {
        if (item.List.length > 0 && !item.ChartPermissionSort) {
          this.$set(item, "isShow", true);
          return true;
        }
      });
      return flag;
    },
    initGetList(list) {
      list.forEach((item) => {
        if (!item.List) {
          item.List = [];
        }
      });
    },
  },
};
