const Mock = require('mockjs')
const {parse} = require('json2csv')
const fs = require('fs')
//模拟生成表头
const csvHeaders = ['序号','身份证号','客户名','归属客户经理号','归属机构']

const csvData = Mock.mock({
    'data|372': [{
        '序号|+1': 1,
        '身份证号': '@id',
        '客户名':'@cname',
        '归属客户经理号：':'admin',
        '归属机构': '@ctitle'+`支行`
    }]
}).data

const csv = parse(csvData)
fs.writeFileSync('test.csv',csv,'utf-8')

const csvContent = [csvHeaders.join(',')].concat(csvData.map(item => {
    Object.values(item).join(',')
})).join('\n')

// module.exports =[
//   {
//     url: '/system/download/csv',
//     type: 'get',
//     response: () => {
//         const blob = new Blob([csvContent],{type:'text/csv'})
//         return blob
//     }
//   }
// ]



