沈斌
2017-12-18 5933685ea11e748cca2f5c13b79abc2b1ffa32a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const list = [];
 
for (let i = 0; i < 50; i += 1) {
  list.push({
    key: i,
    name: '用户' + (i + 1),
    sex: ['男', '女'][i % 2],
    mobile: 13713713777 + i,
    email: `test_${i + 1}@test.com`,
    weixin: 'test' + (i + 1),
    password: 'ISGMyneATSuhkiwz4BURBQ==',
    organization: '组织' + (i + 1),
    nickname:  '昵称' + (i + 1),
    updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`)
  });
}
 
export function getInstaller(params: any) {
  let ret = [...list];
  if (params.sorter) {
    const s = params.sorter.split('_');
    ret = ret.sort((prev, next) => {
      if (s[1] === 'descend') {
        return next[s[0]] - prev[s[0]];
      }
      return prev[s[0]] - next[s[0]];
    });
  }
  if (params.u_name) {
    ret = ret.filter(data => data.name.indexOf(params.u_name) > -1);
  }
  if (params.u_mobile) {
    ret = ret.filter(data => data.mobile.toString().indexOf(params.u_mobile) > -1);
  }
  return ret;
}
 
export function deleteInstaller(name: string): boolean {
  const idx = list.findIndex(w => w.name === name);
  if (idx !== -1) {
    list.splice(idx, 1);
    return true;
  }
  return false;
}