敏感词顾虑

filterSensitive(data) {
      this.wordsData = [];
      this.returnModify = true;
      let content = window.tinyMCE.activeEditor.getBody().textContent;
      let newobj = {};
      let index = -1;
      data.forEach((item) => {
        do {
          index = content.indexOf(`${item.keyword}`, index + 1);
          if (index != -1) {
            if (item.level == 1) {
              this.wordsData.push({
                word: item.keyword,
                address: `第${index + 1}个字处`,
              });
            } else if (item.level == 2) {
              this.returnModify = false;
              this.wordsData.push({
                word: item.keyword,
                address: `第${
                  index + 1
                }个字处, ( 建议改为:上级 )`,
              });
            } else if (item.level == 3) {
              this.returnModify = false;
              this.wordsData.push({
                word: item.keyword,
                address: `第${index + 1}个字处, ( 建议改为:参加安保任务或参加有关工作任务 )`,
              });
            }
          }
        } while (index != -1);
      });
      this.wordsData = this.wordsData.reduce((preVal, curVal) => {
        newobj[curVal.address]
          ? ""
          : (newobj[curVal.address] = preVal.push(curVal));
        return preVal;
      }, []);
    },
this.sensitiveWords = true;
                this.wordsData = [];
                this.returnModify = true;
                this.formData.forEach((con, i) => {
                  let newobj = {};
                  let index = -1;
                  res.data.keywords.forEach((item) => {
                    do {
                      index = con.logDayContentT.indexOf(
                        `${item.keyword}`,
                        index + 1
                      );
                      if (index != -1) {
                        if (item.level == 1) {
                          this.wordsData.push({
                            word: item.keyword,
                            address: `第${i + 1}条, 第${index + 1}个字处`,
                          });
                        } else if (item.level == 2) {
                          this.returnModify = false;
                          this.wordsData.push({
                            word: item.keyword,
                            address: `第${i + 1}条, 第${
                              index + 1
                            }个字处, ( 建议改为:上级 )`,
                          });
                        } else if (item.level == 3) {
                          this.returnModify = false;
                          this.wordsData.push({
                            word: item.keyword,
                            address: `第${i + 1}条, 第${
                              index + 1
                            }个字处, ( 建议改为:参加安保任务或参加有关工作任务 )`,
                          });
                        }
                      }
                    } while (index != -1);
                  });
                  this.wordsData = this.wordsData.reduce((preVal, curVal) => {
                    newobj[curVal.address]
                      ? ""
                      : (newobj[curVal.address] = preVal.push(curVal));
                    return preVal;
                  }, []);
                });

 

posted @ 2021-01-25 10:03  三只小熊sky  阅读(16)  评论(0)    收藏  举报