const { mock } = require('mockjs') module.exports = [ // { // url: '/dailySummary/getdailySummary', // type: 'get', // response: (config) => { // const query = config.query // // 解析日期并计算后一天 // const currentDate = new Date(query.date) // const nextDate = new Date(currentDate) // nextDate.setDate(currentDate.getDate() + 1) // // 日期格式化函数 // const format = (date) => date.toISOString().split('T')[0].replace(/-/g, '-') // return { // code: 200, // msg: 'success', // data: { // record_date: `${format(currentDate)}`, // week_period: `${format(currentDate)} 06:00 至${format(nextDate)} 06:00`, // duty_leader: ' 张伟', // duty_department: '李晓明', // }, // } // }, // }, { url: '/dailySummary/getSupplyList', type: 'get', response(config) { const currentDate = new Date(config.query.date) //const mockSummaryList = SummaryList.filter((item) => !(currentDate && item.record_date.indexOf(currentDate) < 0)) const list = SummaryList return { code: 200, msg: 'success', data: { list }, } }, }, { url: '/dailySummary/editSupply', type: 'post', response: (config) => { return { code: 200, msg: 'success', data: {}, } }, }, ] const SummaryList = (() => { const models = { 广州: { 电力: ['HXD1D', 'SS8', 'SS9', 'FXN5C'], 内燃: ['DF4', 'DF4K', 'DF11', 'DF11G'], '专调(大功率)': ['HXN5B', 'FXN3B', 'DF12'], }, 长沙: { 电力: ['HXD3C', 'SS8'], 内燃: ['DF4', 'DF4D'], '专调(大功率)': ['HXN5B', 'DF12'], }, 怀化: { 电力: ['HXD1'], 内燃: ['DF4', 'DF4K'], '专调(大功率)': ['HXN5B', 'DF12'], }, 株洲: { 电力: ['HXD1C'], 内燃: ['DF4', 'DF4K'], '专调(大功率)': ['HXN5B', 'DF12'], }, 汕头: { 内燃: ['DF4', 'DF4K', 'DF4D'], }, 海口: { 内燃: ['DF4', 'DF4K'], }, } const results = [] let id = 1 // 遍历所有机务段 Object.entries(models).forEach(([depot, types]) => { // 遍历所有类型 Object.entries(types).forEach(([type, models]) => { // 为每个车型生成1条记录 models.forEach((model) => { results.push({ id: id++, locomotive_depot: depot, locomotive_type: type, locomotive_model: model, operating_planned: mock('@integer(80,120)'), operating_actual: mock('@integer(70,110)'), short_term_reserve: mock('@integer(50,90)'), repair_major: mock('@integer(5,20)'), repair_medium: mock('@integer(10,30)'), repair_minor: mock('@integer(15,40)'), repair_temporary: mock('@integer(3,15)'), repair_other: mock('@integer(2,10)'), }) }) }) }) return results })()