vue 判斷兩個列表是否重複

  async handleCrudSelect(e) {
      const that = this;
      let count = 0;
      // displayValueList 顯示值
      // rawValueList 原值
      // 彈窗選擇完數據後向後臺發起 每條數據新增一條歷史數據的請求
      // eslint-disable-next-line array-callback-return
      e.displayValueList.map((item) => {
        if (that.displayValueList.findIndex((preItem) =>
        // 根據preItem中的int_id屬性來判斷這個item是否存在,如果是,返回true,否返回false,繼續下面一條數據的遍歷,以此類推
        // eslint-disable-next-line implicit-arrow-linebreak,brace-style
        // eslint-disable-next-line no-unused-expressions,implicit-arrow-linebreak
          preItem.int_id === item.int_id,
        // eslint-disable-next-line function-paren-newline
        ) === -1) {
          // eslint-disable-next-line no-plusplus
          count++;
          that.displayValueList.push(item);
        }
      });

      e.rawValueList.map((item) => that.rawValueList.findIndex((preItem) =>
      // 根據preItem中的int_id屬性來判斷這個item是否存在,如果是,返回true,否返回false,繼續下面一條數據的遍歷,以此類推
      // eslint-disable-next-line implicit-arrow-linebreak
        preItem.int_id === item.int_id,
        // eslint-disable-next-line function-paren-newline
      ) === -1 && that.rawValueList.push(item));
      if (count !== 0) {
        // 需要新增HIS數據
        await request.postUrl('/insertHis', {
          data: { rawValueList: this.rawValueList },
          flowId: this.flowId,
        }).then((res) => {
          if (res.resultFlag.code !== 0) {
            this.$message.error(res.resultFlag.errorMessage);
          } else {
            this.$message.success('添加數據成功');
          }
        });
      }
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章