import Mock from 'mockjs'
import { MockMethod } from 'vite-plugin-mock'
const list = Mock.mock({
  'list|4-10': [
    {
      id: '@id',
      num: function () {
        const date = new Date()
        const year = date.getFullYear().toString().slice(-2)
        const month = (date.getMonth() + 1).toString().padStart(2, '0')
        const day = date.getDate().toString().padStart(2, '0')
        const random = Math.random().toString().slice(-10)
        return `BA${year}${month}${day}${random}`
      },
      name: '@ctitle',
      num2: '@integer(1, 100)',
      num3: '@integer(1, 100)',
      num4: '@integer(1, 100)',
      productName: '@goods("name")',
      specifications: function () {
        return this.unit
      },
      price: '@integer(1, 100)',
      unit: '@unit',
      statistics: '@ctitle',
      money: '@ctitle',
      total: '@integer(1, 100)',
      country: '@country',
      mcountry: '@country',
      way: '@ctitle',
      sprice: '@ctitle',
      msprice: '@ctitle'
    }
  ]
}).list

const mockMethodTen: MockMethod[] = [
  {
    url: '/mock/api/three',
    method: 'get',
    timeout: 1000,
    response: () => ({
      code: '0',
      data: {
        info: {
          filed1: '010120201000005031',
          filed2: '010120201000005031',
          filed3: '无纸/通关一体化',
          filed4: '进口',
          filed5: '',
          filed6: '',
          filed7: '@date',
          filed8: '@date',
          filed9: '@date',
          filed10: '',
          filed11: '',
          filed12: '',
          filed13: '中国大恒(集团)有限公司/1108919038/86652412100006491000000916',
          filed14: '中国大恒(集团)有限公司/110891903866524121000064931108919038',
          filed15: '中国大恒(团)有限公司/1108919038/866524121000064931/110891903',
          filed16: 'no',
          filed17: '北京关区',
          filed18: '北仑海关',
          filed19: '',
          filed20: '阿富汗',
          filed21: '天津保税区',
          filed22: '天津保税区',
          filed23: '海关总署/000000',
          filed24: '阿富汗',
          filed25: '北京天竺综合保税区',
          filed26: '',
          filed27: '包/袋',
          filed28: '',
          filed29: '海关总署/000000',
          filed30: '水路运输',
          filed31: 'UN281924',
          filed32: 'T281924',
          filed33: 'W20200917048',
          filed34: '进口',
          filed35: '海关总署/000000',
          filed36: '一般贸易',
          filed37: '一般征税',
          filed38: '',
          filed39: '',
          filed40: '1.0%',
          filed41: '海关总署/000000',
          filed42: 'CIF',
          filed43: '1',
          filed44: '1',
          filed45: '1',
          filed46: '',
          filed47: 'A',
          filed48: '',
          filed49: '',
          filed50: '',
          filed51: 'NM',
          filed52: '',
          filed53: '使用人',
          filed54: '两段准入申请',
          filed55: ''
        },
        list
      }
    })
  },
  {
    url: '/mock/api/three/detail',
    method: 'get',
    timeout: 1000,
    response: ({ query }: { query: any }) => {
      const id = query.id || list[0].id
      const data = list.find((v: any) => v.id === id)
      return {
        code: '0',
        data
      }
    }
  }
]

export default mockMethodTen
