import Mock from 'mockjs'

let Random = Mock.Random;

export default ({mock}) => {
  if (!mock) return;

  Mock.mock(/\/api\/jobslink-system\/order\/detail/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};
    const list = [];
    for (let index = 0; index < 5; index++) {
      let name = Mock.mock('@cname');
      list.push(Mock.mock({
        id: '@increment',
        businessNo: index,
        titles: name,
        type: 1,
        'total|1-99999.00-99': 1,
      }))
      list.push(Mock.mock({
        id: '@increment',
        businessNo: index,
        titles: name,
        type: 2,
        'total|1-99999.00-99': 1,
      }))
    }
    list.push(Mock.mock({
      id: '@increment',
      businessNo: 4,
      titles: name,
      type: 3,
      'total|1-99999.00-99': 1,
    }))
    json.data = {
      total: 10,
      size: 10,
      current: 1,
      searchCount: true,
      pages: 1,
      records: list,
    };
    return json;
  })

  Mock.mock(/\/api\/jobslink-system\/order\/list/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};
    const list = [];
    for (let index = 0; index < 5; index++) {
      list.push(Mock.mock({
        invoiceNo: '@increment',
        businessNo: index,
        'type|0-1': 1,
        'natureType|0-1': 1,
        'total|1-99999.00-99': 1,
        fastmailName: '顺丰',
        fastmailOrder: '123456789987654321',
        invoiceUrl: Random.url('http')
      }))
    }
    json.data = {
      total: 10,
      size: 10,
      current: 1,
      searchCount: true,
      pages: 1,
      records: list,
    };
    return json;
  })
}
