The front-end JS traverses and judges the collection objects returned by the backend and stores them in a new collection

 need

        We need to judge the List<Object> collection object returned by the backend, judge the isCorrect field in the object, and if it is true, then judge that the object is correct and add it to the correct collection, otherwise add it to the failed collection .

The data returned by the backend

 

data

The data returned by the backend will be assigned to this collection object

 dataListSucErrDataDictionary: [],
 dataListSucErrError: [],

JavaScript

handleFileSuccessDataDictionary(response, file, fileList) {
      this.successTotal = response.Result.successCount;
      this.errorTotal = response.Result.failCount;
      this.dataListSucErrDataDictionary = response.Result.results;
}
dataSuccessDataDictionary() {
      this.openSuccessError = true;
      this.isFlag = true;
      //错误提示那一栏不显示
      this.errorNoticeColumn = false;
      //将原本的集合进行清空
      this.dataListSucErrSuccess = [];


      //对后端返回的集合进行判断某个字段如果为false存放在另一个集合里面
      this.dataListSucErrDataDictionary.map(item => {
        //是否可导入true false
        if (item.isCorrect) {
          this.dataListSucErrSuccess.push(item);
        }
      })


      this.dataListSucErr = [];
      this.dataListSucErr = this.dataListSucErrSuccess;
    },

achieve effect

 The article only writes part of the code, the main part of traversing the collection object and adding to the new collection code has been presented.

 

Guess you like

Origin blog.csdn.net/m0_64210833/article/details/130102371