|
@@ -0,0 +1,121 @@
|
|
|
+import React from 'react'
|
|
|
+import { FilterTable } from 'wptpc-design'
|
|
|
+import { Link } from 'dva/router'
|
|
|
+import { thanos } from '@/conf/config'
|
|
|
+import { Divider, Popconfirm } from 'antd'
|
|
|
+
|
|
|
+const apiUrl = `${thanos}/thanos-admin/api/v1/dsl/list`
|
|
|
+
|
|
|
+class GroupList extends React.PureComponent {
|
|
|
+ state = {
|
|
|
+ showModal: false,
|
|
|
+ params: {}
|
|
|
+ }
|
|
|
+
|
|
|
+ filterSetting = {
|
|
|
+ isClearSearch: true,
|
|
|
+ formFields: [
|
|
|
+ {
|
|
|
+ label: '描述:',
|
|
|
+ type: 'input',
|
|
|
+ key: 'queryName',
|
|
|
+ placeholder: '分组名称'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ // 在接口请求前,可以修改给接口的入参
|
|
|
+ // beforeSearchFunc: params => {
|
|
|
+ // params.pageNum = params.pageNum
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ // filtertable的列表配置
|
|
|
+ tableSetting = {
|
|
|
+ // rowKey: 'alias',
|
|
|
+ // isFrontPagination: true,
|
|
|
+ pagination: {
|
|
|
+ pageSize: 10
|
|
|
+ },
|
|
|
+ columnConfig: [
|
|
|
+ {
|
|
|
+ title: 'ID',
|
|
|
+ dataIndex: 'id'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '分组名称',
|
|
|
+ dataIndex: 'name'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '描述',
|
|
|
+ dataIndex: 'description'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '策略是否启用',
|
|
|
+ dataIndex: 'enabled',
|
|
|
+ render: (text) => text === true ? '是' : '否'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建人',
|
|
|
+ dataIndex: 'createUser'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '修改人',
|
|
|
+ dataIndex: 'updateUser'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'actions',
|
|
|
+ // 所有需要弹窗操作的都可以用编辑的逻辑;所有不需要弹窗的操作,比如上架、发布等,都可以用”删除“的逻辑
|
|
|
+ render: (text, record) => (
|
|
|
+ <span>
|
|
|
+ <Link
|
|
|
+ to={{
|
|
|
+ pathname: './edit',
|
|
|
+ state: record
|
|
|
+ }}
|
|
|
+ >编辑</Link>
|
|
|
+ <Divider type="vertical"/>
|
|
|
+ <Popconfirm
|
|
|
+ title="确定删除"
|
|
|
+ onConfirm={() => this.delItem(record)}>
|
|
|
+ <a>删除</a>
|
|
|
+ </Popconfirm>
|
|
|
+ </span>)
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ getRefresh: refresh => {
|
|
|
+ this.refresh = refresh
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击编辑按钮时的事件处理函数
|
|
|
+ editItem (record) {
|
|
|
+ console.log('11111111=')
|
|
|
+ // const fields = JSON.parse(record.fieldsJson)
|
|
|
+ // console.log('=====', fields)
|
|
|
+ const { fields } = record
|
|
|
+ const fieldsJson = Object.keys(fields).map(f => ({
|
|
|
+ key: f,
|
|
|
+ desc: fields[f].desc,
|
|
|
+ column: fields[f].column
|
|
|
+ }))
|
|
|
+ console.log(fieldsJson)
|
|
|
+ this.setState({
|
|
|
+ showModal: true,
|
|
|
+ params: {
|
|
|
+ ...record,
|
|
|
+ fieldsJson
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ render () {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <FilterTable filterSetting={this.filterSetting} tableSetting={this.tableSetting} apiUrl={apiUrl}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default GroupList
|