mode
This commit is contained in:
parent
acccf234d3
commit
41f77f5d04
|
@ -213,7 +213,6 @@ class Dashboard extends Component {
|
|||
}
|
||||
|
||||
pageChange = e =>{
|
||||
|
||||
api.get("/admin/board/get_new_companies", { page_no: e, page_size: 10 }).then(res => {
|
||||
this.setState({
|
||||
company: res.result.records,
|
||||
|
|
|
@ -4,8 +4,6 @@ import { rsaKey } from "@/utils/rsaKey.js";
|
|||
import api from "@/api/request"
|
||||
import FeTable from "@/components/table"
|
||||
|
||||
const { Search } = Input
|
||||
|
||||
const { Option } = Select
|
||||
|
||||
class UserSet extends Component {
|
||||
|
@ -15,16 +13,17 @@ class UserSet extends Component {
|
|||
visible: false,
|
||||
data: [],
|
||||
columns: [],
|
||||
loading:false
|
||||
loading: false,
|
||||
total: 0
|
||||
}
|
||||
}
|
||||
|
||||
AddForm = React.createRef()
|
||||
|
||||
componentDidMount() {
|
||||
this.onSearch("")
|
||||
}
|
||||
|
||||
this.submit("")
|
||||
}
|
||||
|
||||
|
||||
setVisible = () => {
|
||||
this.setState({
|
||||
|
@ -38,34 +37,47 @@ class UserSet extends Component {
|
|||
})
|
||||
}
|
||||
|
||||
onSearch = (value) => {
|
||||
api.get("/admin/user/list_user", {
|
||||
criteria: value,
|
||||
skip: 1,
|
||||
limit: 10
|
||||
})
|
||||
submit = (value) => {
|
||||
const obj = {
|
||||
search: value || {},
|
||||
sort: {
|
||||
创建时间: value.sort || 'desc'
|
||||
},
|
||||
page_size: 10,
|
||||
page_no: 1
|
||||
}
|
||||
api.post("/admin/user/list_user", obj)
|
||||
.then(res => {
|
||||
const col = Object.keys(res.result.data[0]).map((item, key) => {
|
||||
return {
|
||||
title: item,
|
||||
dataIndex: item,
|
||||
key,
|
||||
align: 'center',
|
||||
}
|
||||
})
|
||||
col.push(
|
||||
{
|
||||
title: "operation",
|
||||
dataIndex: "operation",
|
||||
key: res.result.data[0].length - 1,
|
||||
align: 'center',
|
||||
render: (record) => <Space><Button type="info" danger>停 用</Button><Button type="primary" danger>删 除</Button></Space>,
|
||||
}
|
||||
)
|
||||
this.setState({
|
||||
data: res.result.data,
|
||||
columns: col
|
||||
})
|
||||
if (res.result.records.length !== 0) {
|
||||
const col = Object.keys(res.result.records[0]).map((item, key) => {
|
||||
return {
|
||||
title: item,
|
||||
dataIndex: item,
|
||||
key,
|
||||
align: 'center',
|
||||
}
|
||||
})
|
||||
col.push(
|
||||
{
|
||||
title: "operation",
|
||||
dataIndex: "operation",
|
||||
key: res.result.records[0].length - 1,
|
||||
align: 'center',
|
||||
render: (record) => <Space><Button type="info" danger>停 用</Button><Button type="primary" danger>删 除</Button></Space>,
|
||||
}
|
||||
)
|
||||
this.setState({
|
||||
data: res.result.records,
|
||||
total: res.result.total,
|
||||
columns: col
|
||||
})
|
||||
} else {
|
||||
this.setState({
|
||||
data: [],
|
||||
total: 0,
|
||||
columns: []
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
|
@ -84,15 +96,23 @@ class UserSet extends Component {
|
|||
message.success(res.info)
|
||||
this.onSearch()
|
||||
})
|
||||
}else {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
pageChange = e => {
|
||||
api.get("/admin/board/get_new_companies", { page_no: e, page_size: 10 }).then(res => {
|
||||
this.setState({
|
||||
data: res.result.records,
|
||||
total: res.result.total
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
onAdd = () => {
|
||||
this.setState({
|
||||
loading:true
|
||||
loading: true
|
||||
})
|
||||
const form = this.AddForm.current
|
||||
const data = {
|
||||
|
@ -103,13 +123,13 @@ class UserSet extends Component {
|
|||
}
|
||||
api.post("/admin/user/create_user", data).then(res => {
|
||||
this.setState({
|
||||
loading:false
|
||||
},()=>{
|
||||
loading: false
|
||||
}, () => {
|
||||
message.success(res.info)
|
||||
this.onCancel()
|
||||
this.onSearch()
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -117,15 +137,43 @@ class UserSet extends Component {
|
|||
return (
|
||||
<React.Fragment>
|
||||
<Row justify='space-between'>
|
||||
<Search placeholder="检索企业" onSearch={this.onSearch} enterButton style={{ width: 300, marginBottom: 20 }} />
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={this.setVisible}
|
||||
>
|
||||
新增用户
|
||||
</Button>
|
||||
<Form layout="inline" onFinish={this.submit} style={{ marginBottom: 20 }}>
|
||||
<Form.Item name="uid" label="uid">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="姓名" label="姓名">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="邮箱" label="邮箱">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="sort" label="排序">
|
||||
<Select style={{ width: 150 }} defaultValue="降序">
|
||||
<Option value="asc">升序</Option>
|
||||
<Option value="desc">降序</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="状态" label="状态">
|
||||
<Select style={{ width: 150 }}>
|
||||
<Option value="正常">正常</Option>
|
||||
<Option value="停用">停用</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="角色" label="角色" >
|
||||
<Select style={{ minWidth: 150 }} mode="multiple">
|
||||
<Option value="管理员">管理员</Option>
|
||||
<Option value="分析师">分析师</Option>
|
||||
<Option value="开发者">开发者</Option>
|
||||
<Option value="运营人员">运营人员</Option>
|
||||
<Option value="访客">访客</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit">
|
||||
检索
|
||||
</Button>
|
||||
</Form>
|
||||
</Row>
|
||||
<FeTable data={this.state.data} columns={this.state.columns} callback={this.callback.bind(this)} />
|
||||
<FeTable data={this.state.data} columns={this.state.columns} callback={this.callback.bind(this)} total={this.state.total} pageChange={this.pageChange.bind(this)} />
|
||||
<Modal
|
||||
visible={this.state.visible}
|
||||
title="新增"
|
||||
|
|
Loading…
Reference in New Issue