import Mock from 'mockjs'

function fakeSuccess() {
  return {code: 200, success: true, msg: '操作成功'};
}
let Random = Mock.Random;

export default ({mock}) => {
  if (!mock) return;
  //获取表格数据
  Mock.mock(/\/api\/jobslink-system\/main\/list[.]*?/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};
    const list = [];
    for (let i = 0; i < 5; i++) {
      list.push(Mock.mock({
        id: '@increment',
        stationId: '@increment',
        companyName: Mock.mock('@cname'),
        manager: Mock.mock('@cname'),
        'telphone|11': '1',
        'percent|0.1-99': 0.1,
        'status|1-4': 1,
      }))
    }
    json.data = {
      total: 10,
      size: 10,
      current: 1,
      searchCount: true,
      pages: 1,
      records: list,
    };
    return json;
  })

  Mock.mock(/\/api\/jobslink-system\/main\/detail/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};

    json.data = Mock.mock({
      id: '@increment',
      stationId: '@increment',
      companyName: Mock.mock('@cname'),
      manager: Mock.mock('@cname'),
      'telphone|11': '1',
      'percent|0.1-99': 0.1,
      'status|1-4': 1,
      'companyTid|18': '2',
      masterName: Mock.mock('@cname'),
      'masterIdentity|18': '1',
      'cityId': 12,
      companyAddress: Random.county(true),
      authUrlId:
          'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1906469856,4113625838&fm=26&gp=0.jpg',
      identityUrl4Id:
          'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2534506313,1688529724&fm=26&gp=0.jpg',
      identityUrl5Id:
          'https://dss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1035415831,1465727770&fm=26&gp=0.jpg'
    });
    return json;
  })

  Mock.mock(/\/api\/jobslink-system\/main\/submit/, 'post', fakeSuccess);

  Mock.mock(/\/api\/jobslink-system\/main\/remove/, 'post', fakeSuccess);
}
