import Mock from 'mockjs'

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

export default ({mock}) => {
  if (!mock) return;
  let Random = Mock.Random;
  //获取表格数据
  Mock.mock(/\/api\/jobslink-system\/station\/list[.]*?/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};
    const list = [];
    for (let i = 0; i < 5; i++) {
      list.push(Mock.mock({
        id: '@increment',
        stationName: Mock.mock('@cname'),
        linkman: Mock.mock('@last'),
        websiteUrl: Random.url('http'),
        'state|1-5': 1,
        introduce: Mock.mock('@cparagraph(1, 3)')
      }))
    }
    json.data = {
      total: 10,
      size: 10,
      current: 1,
      searchCount: true,
      pages: 1,
      records: list,
    };
    return json;
  })

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

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