execl格式根据属性转换二维数组

 let { data } = await importExcel({

        file: file,

        header: [

          { label: '分院名称', prop: 'branchName' },

          { label: '分院', prop: 'branchCode' },

          { label: '文章标题', prop: 'title' },

          { label: '主讲人姓名', prop: 'user_alias' },

          { label: '主讲人工号', prop: 'user_code' },

          { label: '文章地址', prop: 'article_url' },

          { label: '主讲人当前单位', prop: 'company_name' }

        ]

      })

      console.log(data)

      let first = []

      let a = {}

      data.map(item => {

        let name = {

          branchCode: item.branchCode,

          branchName: item.branchName,

          time: ' ',

          data: []

        }

        a[item.branchCode] ? '' : (a[item.branchCode] = true && first.push(name))

      })

      data.map(item => {

        first.map(a => {

          if (a.branchCode == item.branchCode) {

            a.data.push(item)

          }

        })

      })

      console.log(JSON.stringify(first))

猜你喜欢

转载自blog.csdn.net/aleluye/article/details/130724335