import Mock from 'mockjs';

const getListTemplate = (fields) => {
  let item = {};
  Object.keys(fields).forEach((k, index) => {
    const n = (index % 10) + '';
    item[`${k}|1-3`] = n.repeat(2);
  });

  return {
    'records|10': [
      {
        'id|+1': 1,
        ...item,
      },
    ],
    'total': 80,
  };
};

// system customer manage
export const customerListApi = Mock.mock('/api/sys/custom/query', 'post', {
  'records|10': [
    {
      'id|+1': 1,
      'name': '1122',
      'type': '333',
      'province': '4',
      'city': '5',
      'area': '6',
      'address': '7',
      'managerName': '8',
      'level': '9',
      'roleList|2': [
        {
          'id|+1': 1,
          'customId': 0,
          'quota': 2,
          'roleId': 0,
          'roleName|3-5': '00',
        },
      ],
      'peoperDay': 12,
      'createName': '12',
      'createTime': '13',
    },
  ],
  'total': 80,
});
// supplier customer manage
export const supplierListApi = Mock.mock('/api/sys/supplier/query', 'post', {
  'records|10': [
    {
      'id|+1': 1,
      'code': '22',
      'name': '33',
      'type': '44',
      'remark': '55',
      'enable': true,
    },
  ],
  'total': 80,
});
// device customer manage
export const deviceListApi = Mock.mock(
  '/api/sys/device/query',
  'post',
  getListTemplate({
    code: '22',
    serialNo: '33',
    brand: '44',
    buyTime: '55',
    supllier: '66',
    status: '77',
    location: '88',
    scanCount: '99',
  })
);
// service-level manage
export const serviceLevelListApi = Mock.mock(
  '/api/sys/service-level/query',
  'post',
  getListTemplate({
    name: '11',
    businessType: '22',
    roles: [],
    creator: '44',
    createdTime: '',
  })
);
// checkin customer manage
export const checkinListApi = Mock.mock(
  '/api/sys/checkin/query',
  'post',
  getListTemplate({
    unit: '11',
    status: '22',
    name: '33',
    to: [],
    supplier: '44',
    checkinTime: [55],
    checkoutTime: [66],
    auditRoles: [77],
    openFace: false,
    backupCount: 2,
  })
);
