|
@@ -4,7 +4,7 @@ import { Modal, Row, Col, Table, Button, Popconfirm, message, Descriptions, Sele
|
|
import config from 'utils/config'
|
|
import config from 'utils/config'
|
|
import 'antd/dist/antd.css';
|
|
import 'antd/dist/antd.css';
|
|
|
|
|
|
-const {APIV3Auth} = config
|
|
|
|
|
|
+const { APIV3Auth } = config
|
|
const { Option } = Select
|
|
const { Option } = Select
|
|
|
|
|
|
|
|
|
|
@@ -36,6 +36,8 @@ class Resources extends Component {
|
|
resourcePageSize: 10,
|
|
resourcePageSize: 10,
|
|
resourceListAll: [
|
|
resourceListAll: [
|
|
],
|
|
],
|
|
|
|
+ resourceListAllTemp: [
|
|
|
|
+ ],
|
|
|
|
|
|
|
|
|
|
};
|
|
};
|
|
@@ -61,6 +63,7 @@ class Resources extends Component {
|
|
let resourceListAllTemp = result.result;
|
|
let resourceListAllTemp = result.result;
|
|
this.setState({
|
|
this.setState({
|
|
resourceListAll: resourceListAllTemp,
|
|
resourceListAll: resourceListAllTemp,
|
|
|
|
+ resourceListAllTemp: resourceListAllTemp,
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -79,7 +82,7 @@ class Resources extends Component {
|
|
dataIndex: "name",
|
|
dataIndex: "name",
|
|
key: "name",
|
|
key: "name",
|
|
render: (text, record, index) => {
|
|
render: (text, record, index) => {
|
|
- return <span>{text}</span>
|
|
|
|
|
|
+ return <span onClick={() => this.chageResourceListAll(text, record, index)}>{text}</span>
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -94,6 +97,16 @@ class Resources extends Component {
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // 点击接口类型,变更接口表格显示数据
|
|
|
|
+ chageResourceListAll = (text, record, index) =>{
|
|
|
|
+ this.setState({
|
|
|
|
+ resourceListAllTemp: this.state.resourceListAll.filter(resource => resource.parentId == record.id)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
// 刷新所有接口类型表格数据
|
|
// 刷新所有接口类型表格数据
|
|
refreshResourceTypeData = () => {
|
|
refreshResourceTypeData = () => {
|
|
//初始化所有接口类型列表
|
|
//初始化所有接口类型列表
|
|
@@ -150,19 +163,33 @@ class Resources extends Component {
|
|
|
|
|
|
// 接口类型编辑成功
|
|
// 接口类型编辑成功
|
|
resourceTypehandEditOk = () => {
|
|
resourceTypehandEditOk = () => {
|
|
- this.setState({
|
|
|
|
- resourceTypeEditVisiable: false,
|
|
|
|
- resourceTypeEditConfirmLoading: false,
|
|
|
|
- }, () => {
|
|
|
|
- request({
|
|
|
|
- url: APIV3Auth + "/resourceType/update",
|
|
|
|
- method: "put",
|
|
|
|
- data: this.state.resourceTypeEdit
|
|
|
|
- }).then(result => {
|
|
|
|
|
|
+
|
|
|
|
+ if (this.state.resourceTypeEdit.name == null || this.state.resourceTypeEdit.name == '') {
|
|
|
|
+ message.error("接口类型名称不能为空")
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ request({
|
|
|
|
+ url: APIV3Auth + "/resourceType/update",
|
|
|
|
+ method: "put",
|
|
|
|
+ data: this.state.resourceTypeEdit
|
|
|
|
+ }).then(result => {
|
|
|
|
+ console.log(result.messageCode)
|
|
|
|
+ if (result.messageCode == 200) {
|
|
message.success("更新成功")
|
|
message.success("更新成功")
|
|
this.refreshResourceTypeData()
|
|
this.refreshResourceTypeData()
|
|
- });
|
|
|
|
- })
|
|
|
|
|
|
+ } else {
|
|
|
|
+ message.error("接口类型编辑保存失败")
|
|
|
|
+ }
|
|
|
|
+ }).then(
|
|
|
|
+ this.setState({
|
|
|
|
+ resourceTypeEditVisiable: false,
|
|
|
|
+ resourceTypeEditConfirmLoading: false,
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -185,10 +212,8 @@ class Resources extends Component {
|
|
|
|
|
|
// 新增接口类型成功
|
|
// 新增接口类型成功
|
|
resourceTypehandAddOk = () => {
|
|
resourceTypehandAddOk = () => {
|
|
- this.setState({
|
|
|
|
- resourceTypeAddVisiable: false,
|
|
|
|
- resourceTypeAddConfirmLoading: false,
|
|
|
|
- }, () => {
|
|
|
|
|
|
+
|
|
|
|
+ if (this.state.resourceTypeAdd != '') {
|
|
request({
|
|
request({
|
|
url: APIV3Auth + "/resourceType/add",
|
|
url: APIV3Auth + "/resourceType/add",
|
|
method: "post",
|
|
method: "post",
|
|
@@ -196,10 +221,17 @@ class Resources extends Component {
|
|
name: this.state.resourceTypeAdd
|
|
name: this.state.resourceTypeAdd
|
|
}
|
|
}
|
|
}).then(result => {
|
|
}).then(result => {
|
|
- message.success("新增接口成功");
|
|
|
|
|
|
+ message.success("新增接口类型成功");
|
|
this.refreshResourceTypeData();
|
|
this.refreshResourceTypeData();
|
|
- });
|
|
|
|
- })
|
|
|
|
|
|
+ this.setState({
|
|
|
|
+ resourceTypeAddVisiable: false,
|
|
|
|
+ resourceTypeAddConfirmLoading: false,
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ message.error("接口类型名称不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// 新增接口类型输入框
|
|
// 新增接口类型输入框
|
|
@@ -223,12 +255,12 @@ class Resources extends Component {
|
|
request({
|
|
request({
|
|
url: APIV3Auth + "/resource/all",
|
|
url: APIV3Auth + "/resource/all",
|
|
method: "get",
|
|
method: "get",
|
|
-
|
|
|
|
|
|
+
|
|
}).then(result => {
|
|
}).then(result => {
|
|
let resourceListAllTemp = result.data;
|
|
let resourceListAllTemp = result.data;
|
|
- console.log(resourceListAllTemp)
|
|
|
|
this.setState({
|
|
this.setState({
|
|
resourceListAll: resourceListAllTemp,
|
|
resourceListAll: resourceListAllTemp,
|
|
|
|
+ resourceListAllTemp: resourceListAllTemp,
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -283,7 +315,7 @@ class Resources extends Component {
|
|
|
|
|
|
// 接口显示总条数
|
|
// 接口显示总条数
|
|
resourceShowTotal = () => {
|
|
resourceShowTotal = () => {
|
|
- return '总共' + this.state.resourceListAll.length + '条'
|
|
|
|
|
|
+ return '总共' + this.state.resourceListAllTemp.length + '条'
|
|
}
|
|
}
|
|
|
|
|
|
// 接口显示页数发生变化
|
|
// 接口显示页数发生变化
|
|
@@ -297,9 +329,7 @@ class Resources extends Component {
|
|
// 接口编辑数据
|
|
// 接口编辑数据
|
|
handresourceEdit = (text, record) => {
|
|
handresourceEdit = (text, record) => {
|
|
let resourceTypeTemp = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId)
|
|
let resourceTypeTemp = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId)
|
|
- console.log("--------------")
|
|
|
|
- console.log(resourceTypeTemp)
|
|
|
|
- if(resourceTypeTemp != null){
|
|
|
|
|
|
+ if (resourceTypeTemp != null) {
|
|
record.parentName = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId).name
|
|
record.parentName = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId).name
|
|
}
|
|
}
|
|
this.setState({
|
|
this.setState({
|
|
@@ -382,23 +412,43 @@ class Resources extends Component {
|
|
// 新增接口成功
|
|
// 新增接口成功
|
|
resourcehandAddOk = (value) => {
|
|
resourcehandAddOk = (value) => {
|
|
|
|
|
|
- this.setState({
|
|
|
|
- resourceAddVisiable: false,
|
|
|
|
- resourceAddConfirmLoading: false,
|
|
|
|
- }, () => {
|
|
|
|
- request({
|
|
|
|
- url: APIV3Auth + "/resource/add",
|
|
|
|
- method: "post",
|
|
|
|
- data: this.state.resourceAdd
|
|
|
|
- }).then(result => {
|
|
|
|
- if (result.messageCode == 200) {
|
|
|
|
- message.success("新增接口成功")
|
|
|
|
- this.refreshResourceData()
|
|
|
|
- } else {
|
|
|
|
- message.error("新增接口失败")
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
|
|
+ if (this.state.resourceAdd.parentName == null || this.state.resourceAdd.parentName == '') {
|
|
|
|
+ message.error('接口类型不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.state.resourceAdd.code == null || this.state.resourceAdd.code == '') {
|
|
|
|
+ message.error('接口编码不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.state.resourceAdd.name == null || this.state.resourceAdd.name == '') {
|
|
|
|
+ message.error('接口名称不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.state.resourceAdd.url == null || this.state.resourceAdd.url == '') {
|
|
|
|
+ message.error('接口地址不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ request({
|
|
|
|
+ url: APIV3Auth + "/resource/add",
|
|
|
|
+ method: "post",
|
|
|
|
+ data: this.state.resourceAdd
|
|
|
|
+ }).then(result => {
|
|
|
|
+ if (result.messageCode == 200) {
|
|
|
|
+ message.success("新增接口成功")
|
|
|
|
+ this.refreshResourceData()
|
|
|
|
+ } else {
|
|
|
|
+ message.error("新增接口失败")
|
|
|
|
+ }
|
|
|
|
+ }).then(
|
|
|
|
+ this.setState({
|
|
|
|
+ resourceAddVisiable: false,
|
|
|
|
+ resourceAddConfirmLoading: false,
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// 编辑接口name输入框
|
|
// 编辑接口name输入框
|
|
@@ -446,23 +496,42 @@ class Resources extends Component {
|
|
|
|
|
|
// 编辑接口成功
|
|
// 编辑接口成功
|
|
resourcehandEditOk = (value) => {
|
|
resourcehandEditOk = (value) => {
|
|
- this.setState({
|
|
|
|
- resourceEditVisiable: false,
|
|
|
|
- resourceEditConfirmLoading: false,
|
|
|
|
- }, () => {
|
|
|
|
- request({
|
|
|
|
- url: APIV3Auth + "/resource/update",
|
|
|
|
- method: "put",
|
|
|
|
- data: this.state.resourceEdit
|
|
|
|
- }).then(result => {
|
|
|
|
- if (result.messageCode == 200) {
|
|
|
|
- message.success("编辑接口成功")
|
|
|
|
- this.refreshResourceData()
|
|
|
|
- } else {
|
|
|
|
- message.success("编辑接口失败")
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
|
|
+ if (this.state.resourceEdit.parentName == null || this.state.resourceEdit.parentName == '') {
|
|
|
|
+ message.error('接口类型不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.state.resourceEdit.code == null || this.state.resourceEdit.code == '') {
|
|
|
|
+ message.error('接口编码不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.state.resourceEdit.name == null || this.state.resourceEdit.name == '') {
|
|
|
|
+ message.error('接口名称不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.state.resourceEdit.url == null || this.state.resourceEdit.url == '') {
|
|
|
|
+ message.error('接口地址不能为空')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ request({
|
|
|
|
+ url: APIV3Auth + "/resource/update",
|
|
|
|
+ method: "put",
|
|
|
|
+ data: this.state.resourceEdit
|
|
|
|
+ }).then(result => {
|
|
|
|
+ if (result.messageCode == 200) {
|
|
|
|
+ message.success("编辑接口成功")
|
|
|
|
+ this.refreshResourceData()
|
|
|
|
+ } else {
|
|
|
|
+ message.success("编辑接口失败")
|
|
|
|
+ }
|
|
|
|
+ }).then(
|
|
|
|
+ this.setState({
|
|
|
|
+ resourceEditVisiable: false,
|
|
|
|
+ resourceEditConfirmLoading: false,
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -498,7 +567,7 @@ class Resources extends Component {
|
|
{/* 接口表 */}
|
|
{/* 接口表 */}
|
|
<Table
|
|
<Table
|
|
size="small"
|
|
size="small"
|
|
- dataSource={this.state.resourceListAll}
|
|
|
|
|
|
+ dataSource={this.state.resourceListAllTemp}
|
|
bordered
|
|
bordered
|
|
pagination={{ pageSize: 10 }}
|
|
pagination={{ pageSize: 10 }}
|
|
columns={this.getResourceTableColumnDef()}
|
|
columns={this.getResourceTableColumnDef()}
|