import React from 'react';
import './index.less';
import Page from '@src/containers/Page';
import Block from '@src/components/Block';
import FilterLayout from '@src/layouts/FilterLayout';
// import ActionLayout from '@src/layouts/ActionLayout';
import TableLayout from '@src/layouts/TableLayout';
import { bindSearch, formatDate } from '@src/services/Tools';
import { asyncSMessage, asyncDelConfirm } from '@src/services/AsyncTools';
// import { QuestionType, AnswerStatus, MoneyRange, SwitchSelect, AskTarget } from '../../../../Constant';
import { User } from '../../../stores/user';
export default class extends Page {
init() {
this.filterForm = [{
key: 'userId',
type: 'select',
allowClear: true,
name: '用户',
select: [],
number: true,
placeholder: '请输入',
}, {
key: 'totalAlert',
type: 'number',
allowClear: true,
name: '警告次数',
number: true,
}, {
key: 'time',
type: 'daterange',
name: '注册时间',
}];
this.columns = [{
title: '登录时间',
dataIndex: 'createTime',
render: (text) => {
return formatDate(text, 'YYYY-MM-DD HH:mm:ss');
},
}, {
title: '用户id',
dataIndex: 'user.id',
}, {
title: '手机号',
dataIndex: 'user.mobile',
}, {
title: '昵称',
dataIndex: 'user.nickname',
}, {
title: '注册时间',
dataIndex: 'user.createTime',
render: (text) => {
return formatDate(text, 'YYYY-MM-DD HH:mm:ss');
},
}, {
title: '注册ip',
dataIndex: 'user.registerIp',
}, {
title: '注册地',
dataIndex: 'user.registerCity',
}, {
title: '本次登录ip',
dataIndex: 'loginIp',
}, {
title: '本次登录地',
dataIndex: 'loginCity',
}, {
title: '累计警告次数',
dataIndex: 'user.totalAlert',
}, {
title: '操作',
dataIndex: 'handler',
render: (text, record) => {
return
;
},
}];
bindSearch(this.filterForm, 'userId', this, (search) => {
return User.list(search);
}, (row) => {
return {
title: `${row.nickname}(${row.mobile})`,
value: row.id,
};
}, this.state.search.userId ? Number(this.state.search.userId) : null, null);
}
initData() {
const { search } = this.state;
const data = Object.assign({}, search);
if (data.time) {
data.startTime = data.time[0] || '';
data.endTime = data.time[1] || '';
}
User.listAbnormal(data).then(result => {
this.setTableData(result.list, result.total);
});
}
alertAction(row) {
asyncDelConfirm('警告确认', '是否警告选中记录?', () => {
return User.handleAbnormal({ id: row.id, isAlert: 1 }).then(() => {
asyncSMessage('操作成功!');
this.refresh();
});
});
}
ignoreAction(row) {
asyncDelConfirm('忽略确认', '是否忽略选中记录?', () => {
return User.handleAbnormal({ id: row.id, isIgnore: 1 }).then(() => {
asyncSMessage('操作成功!');
this.refresh();
});
});
}
frozenAction(row) {
asyncDelConfirm('封禁确认', '是否封禁选中用户?', () => {
return User.frozen({ id: row.userId }).then(() => {
asyncSMessage('操作成功!');
this.refresh();
});
});
}
noFrozenAction(row) {
asyncDelConfirm('取消封禁确认', '是否取消封禁选中用户?', () => {
return User.noFrozen({ id: row.userId }).then(() => {
asyncSMessage('操作成功!');
this.refresh();
});
});
}
renderView() {
return
{
if (data.time.length > 0) {
data.time = [data.time[0].format('YYYY-MM-DD 00:00:00'), data.time[1].format('YYYY-MM-DD 23:59:59')];
}
data.page = 1;
this.search(data);
}} />
{/* this.onAction(key)}
/> */}
this.tableChange(pagination, filters, sorter)}
onSelect={(keys, rows) => this.tableSelect(keys, rows)}
selectedKeys={this.state.selectedKeys}
/>
;
}
}