Notice 第二阶段
This commit is contained in:
@@ -57,6 +57,19 @@ export default class index extends Component {
|
||||
title: '标题',
|
||||
dataIndex: 'title',
|
||||
},
|
||||
{
|
||||
title: '发布人',
|
||||
dataIndex: 'publicUserName',
|
||||
},
|
||||
{
|
||||
title: '发布时间',
|
||||
dataIndex: 'createdTime',
|
||||
},
|
||||
{
|
||||
title: '发布单位',
|
||||
dataIndex: 'publicOrgName',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
@@ -76,7 +89,7 @@ export default class index extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
const flag = auth({ [authName]: [['edit'], ['delete']] })
|
||||
const flag = auth({ [authName]: [['edit'], ['goBack'], ['publish'], ['delete']] })
|
||||
|
||||
if (flag) {
|
||||
this.columns.push({
|
||||
@@ -85,18 +98,55 @@ export default class index extends Component {
|
||||
dataIndex: 'actions',
|
||||
render: (text, record) => (
|
||||
<QueryTableActions>
|
||||
<Auth auth={{ [authName]: 'edit' }}>
|
||||
<a onClick={() => this.onOpen(this.editForm, record.id)}>编辑</a>
|
||||
</Auth>
|
||||
<Auth auth={{ [authName]: 'delete' }}>
|
||||
<Popconfirm
|
||||
placement="topRight"
|
||||
title="是否确认删除"
|
||||
onConfirm={() => this.onDelete(record.id)}
|
||||
{record.status === 1 ? (
|
||||
<Auth
|
||||
key={this.subUniqueKey(record.id, 1)}
|
||||
auth={{ [authName]: 'goBack' }}
|
||||
>
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</Auth>
|
||||
<Popconfirm
|
||||
placement="topRight"
|
||||
title="是否确认撤回"
|
||||
onConfirm={() => this.onGoBack(record.id)}
|
||||
>
|
||||
<a>撤回</a>
|
||||
</Popconfirm>
|
||||
</Auth>
|
||||
) : (
|
||||
[
|
||||
<Auth
|
||||
key={this.subUniqueKey(record.id, 2)}
|
||||
auth={{ [authName]: 'edit' }}
|
||||
>
|
||||
<a onClick={() => this.onOpen(this.editForm, record.id)}>
|
||||
编辑
|
||||
</a>
|
||||
</Auth>,
|
||||
<Auth
|
||||
key={this.subUniqueKey(record.id, 3)}
|
||||
auth={{ [authName]: 'publish' }}
|
||||
>
|
||||
<Popconfirm
|
||||
placement="topRight"
|
||||
title="是否确认发布"
|
||||
onConfirm={() => this.onPublish(record.id)}
|
||||
>
|
||||
<a>发布</a>
|
||||
</Popconfirm>
|
||||
</Auth>,
|
||||
<Auth
|
||||
key={this.subUniqueKey(record.id, 4)}
|
||||
auth={{ [authName]: 'delete' }}
|
||||
>
|
||||
<Popconfirm
|
||||
placement="topRight"
|
||||
title="是否确认删除"
|
||||
onConfirm={() => this.onDelete(record.id)}
|
||||
>
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</Auth>,
|
||||
]
|
||||
)}
|
||||
</QueryTableActions>
|
||||
),
|
||||
})
|
||||
@@ -128,7 +178,9 @@ export default class index extends Component {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
subUniqueKey(text, index) {
|
||||
return text.substr(index, 5)
|
||||
}
|
||||
/**
|
||||
* 调用加载数据接口,可在调用前对query进行处理
|
||||
* [异步,必要]
|
||||
@@ -200,8 +252,22 @@ export default class index extends Component {
|
||||
* @param {*} id
|
||||
*/
|
||||
onDelete(id) {
|
||||
this.onAction(apiAction.delete({ id }), '删除成功')
|
||||
this.onAction(apiAction.Status({ id, Status: 3 }), '删除成功')
|
||||
}
|
||||
/**
|
||||
* 发布
|
||||
* @param {*} id
|
||||
*/
|
||||
onPublish(id) {
|
||||
this.onAction(apiAction.Status({ id, Status: 1 }), '发布成功')
|
||||
}
|
||||
/**
|
||||
* 撤回
|
||||
* @param {*} id
|
||||
*/
|
||||
onGoBack(id) {
|
||||
this.onAction(apiAction.Status({ id, Status: 2 }), '撤回成功')
|
||||
} //
|
||||
|
||||
//#region 自定义方法
|
||||
//#endregion
|
||||
@@ -214,6 +280,7 @@ export default class index extends Component {
|
||||
<Card bordered={false}>
|
||||
<QueryTable
|
||||
ref={this.table}
|
||||
rowkey={record => record.id}
|
||||
autoLoad={false}
|
||||
loadData={this.loadData}
|
||||
columns={this.columns}
|
||||
@@ -223,11 +290,11 @@ export default class index extends Component {
|
||||
<Input
|
||||
autoComplete="off"
|
||||
placeholder="请输入标题、内容"
|
||||
className="w-400"
|
||||
className="w-200"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="类型" name="type">
|
||||
<Select placeholder="请选择类型" className="w-400" allowClear>
|
||||
<Select placeholder="请选择类型" className="w-200" allowClear>
|
||||
{codes.noticeType.map(item => (
|
||||
<Select.Option key={item.code} value={item.code}>
|
||||
{item.value}
|
||||
@@ -238,7 +305,7 @@ export default class index extends Component {
|
||||
</Auth>
|
||||
}
|
||||
operator={
|
||||
<Auth auth={{ [authName]: 'add' }}>
|
||||
<Auth key={record => record.id} auth={{ [authName]: 'add' }}>
|
||||
<Button
|
||||
icon={<AntIcon type="plus" />}
|
||||
onClick={() => this.onOpen(this.addForm)}
|
||||
@@ -255,6 +322,25 @@ export default class index extends Component {
|
||||
title={`新增${name}`}
|
||||
width={800}
|
||||
action={apiAction.add}
|
||||
buttons={[
|
||||
{
|
||||
index: 1,
|
||||
button: (getData, close) => (
|
||||
<Button
|
||||
type="primary"
|
||||
key="111"
|
||||
onClick={async () => {
|
||||
const data = await getData()
|
||||
data.status = 0 //草稿状态
|
||||
this.onAction(api.sysNoticeAdd(data))
|
||||
close()
|
||||
}}
|
||||
>
|
||||
保存草稿
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]}
|
||||
ref={this.addForm}
|
||||
onSuccess={() => this.table.current.onReloadData()}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user