|
@@ -1,682 +1,343 @@
|
|
|
import React, { Component } from 'react';
|
|
|
+import { BirdGrid } from 'components/Grid';
|
|
|
import { request } from 'utils';
|
|
|
-import { Modal, Row, Col, Table, Button, Popconfirm, message, Descriptions, Select, Input } from 'antd';
|
|
|
+import { Modal, Button, message, Descriptions, Input } from 'antd';
|
|
|
import config from 'utils/config'
|
|
|
|
|
|
-import 'antd/dist/antd.css';
|
|
|
|
|
|
+import 'antd/dist/antd.css';
|
|
|
const { APIV3Auth } = config
|
|
|
-const { Option } = Select;
|
|
|
|
|
|
-class Orginazation extends Component {
|
|
|
+
|
|
|
+class Organization extends Component {
|
|
|
+
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- editVisiable: false,
|
|
|
- editConfirmLoading: false,
|
|
|
secretVisiable: false,
|
|
|
secretConfirmLoading: false,
|
|
|
+ organizationSecret: {},
|
|
|
+
|
|
|
resourceVisiable: false,
|
|
|
resourceConfirmLoading: false,
|
|
|
- addVisiable: false,
|
|
|
- addConfirmLoading: false,
|
|
|
- organizationList: [
|
|
|
- ],
|
|
|
- resourceList: [
|
|
|
- ],
|
|
|
- organizationEdit: {},
|
|
|
- organizationSecret: {},
|
|
|
- organizationAdd: {},
|
|
|
- current: 1,
|
|
|
- total: 0,
|
|
|
- pageSize: 10,
|
|
|
|
|
|
|
|
|
- resourceListAll: [],
|
|
|
- resourceListCondition: [],
|
|
|
- resourceTypeListAll: [],
|
|
|
- selectedRowKeysInit: [],
|
|
|
- selectedRowKeys: [],
|
|
|
+ selectedOrg: {},
|
|
|
|
|
|
- // 即将授权的机构
|
|
|
- organizationResource: {},
|
|
|
- // 选择的接口类型
|
|
|
- selectedResourceType: '',
|
|
|
- // 选择的接口名称
|
|
|
- selectedResourceName: '',
|
|
|
+ selectedRowKeysInit: [],
|
|
|
|
|
|
};
|
|
|
-
|
|
|
- //初始化所有接口类型列表
|
|
|
- request({
|
|
|
- url: APIV3Auth + "/resourceType/all",
|
|
|
- method: "get"
|
|
|
- }).then(result => {
|
|
|
- let resourceTypeListTemp = result.result;
|
|
|
- this.setState({
|
|
|
- resourceTypeListAll: resourceTypeListTemp,
|
|
|
- });
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- //初始化接口列表
|
|
|
- request({
|
|
|
- url: APIV3Auth + "/resource/all",
|
|
|
- method: "get",
|
|
|
- }).then(result => {
|
|
|
- let resourceListAllTemp = result.result;
|
|
|
- this.setState({
|
|
|
- resourceListAll: resourceListAllTemp,
|
|
|
- resourceListCondition: resourceListAllTemp,
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- //初始化机构列表列表
|
|
|
- request({
|
|
|
- url: APIV3Auth + "/orgdoc/searchByCondition",
|
|
|
- method: "post",
|
|
|
- data: {
|
|
|
- current: this.state.current,
|
|
|
- searchCount: true,
|
|
|
- size: this.state.pageSize,
|
|
|
- }
|
|
|
- }).then(result => {
|
|
|
- let organizationListTemp = result.result.records;
|
|
|
- this.setState({
|
|
|
- organizationList: organizationListTemp,
|
|
|
- total: result.result.total
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 刷新机构数据
|
|
|
- refreshOrganizationData = () => {
|
|
|
- request({
|
|
|
- url: APIV3Auth + "/orgdoc/searchByCondition",
|
|
|
- method: "post",
|
|
|
- data: {
|
|
|
- current: this.state.current,
|
|
|
- searchCount: true,
|
|
|
- size: this.state.pageSize,
|
|
|
- }
|
|
|
- }).then(result => {
|
|
|
- let organizationListTemp = result.result.records;
|
|
|
- this.setState({
|
|
|
- organizationList: organizationListTemp,
|
|
|
- total: result.result.total
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 设置机构表格
|
|
|
- getTableColumnDef = () => {
|
|
|
- return [{
|
|
|
- title: "机构Id",
|
|
|
- dataIndex: "orgId",
|
|
|
- key: "orgId",
|
|
|
- render: (text, record, index) => {
|
|
|
- return <span>{text}</span>
|
|
|
- }
|
|
|
- }, {
|
|
|
- title: "机构名称",
|
|
|
- dataIndex: "orgName",
|
|
|
- key: "orgName",
|
|
|
- render: (text, record, index) => {
|
|
|
- return <span>{text}</span>
|
|
|
- }
|
|
|
- }, {
|
|
|
- title: "合作状态",
|
|
|
- dataIndex: "authStatus",
|
|
|
- key: "authStatus",
|
|
|
- render: (text, record, index) => {
|
|
|
- return <span>{text == 1 ? "合作中" : "已停止"}</span>
|
|
|
- }
|
|
|
- }, {
|
|
|
- title: "接口授权数量",
|
|
|
- dataIndex: "authNum",
|
|
|
- key: "authNum",
|
|
|
- render: (text, record, index) => {
|
|
|
- return <span><a style={{ marginRight: 16 }} onClick={() => this.handResource(text, record)}>{text}</a></span>
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- key: 'action',
|
|
|
- render: (text, record) => (
|
|
|
- <span>
|
|
|
- <a style={{ marginRight: 16 }} onClick={() => this.handOrganizationEdit(text, record)}>编辑</a>
|
|
|
- <a onClick={() => this.handOrganizationCheck(text, record)}>查看密钥</a>
|
|
|
- </span>
|
|
|
- ),
|
|
|
- },
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- // 设置授权表格
|
|
|
- getTableColumnDefResource = () => {
|
|
|
- return [{
|
|
|
- title: "接口编码",
|
|
|
- dataIndex: "code",
|
|
|
- key: "code",
|
|
|
- render: (text, record, index) => {
|
|
|
- return <span>{text}</span>
|
|
|
- }
|
|
|
- }, {
|
|
|
- title: "接口类型",
|
|
|
- dataIndex: "parentId",
|
|
|
- key: "parentId",
|
|
|
- render: (text, record, index) => {
|
|
|
- let resourceTypeTemp = this.state.resourceTypeListAll.find(resourceType => resourceType.id == text)
|
|
|
- if (resourceTypeTemp != null) {
|
|
|
- return <span>{resourceTypeTemp.name}</span>
|
|
|
- } else {
|
|
|
- return <span>无类型</span>
|
|
|
- }
|
|
|
- }
|
|
|
- }, {
|
|
|
- title: "接口名称",
|
|
|
- dataIndex: "name",
|
|
|
- key: "name",
|
|
|
- render: (text, record, index) => {
|
|
|
- return <span>{text}</span>
|
|
|
- }
|
|
|
- }, {
|
|
|
- title: "接口描述",
|
|
|
- dataIndex: "description",
|
|
|
- key: "description",
|
|
|
- render: (text, record, index) => {
|
|
|
- return <span>{text}</span>
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 显示页数发生变化
|
|
|
- onShowSizeChange = (current, pageSize) => {
|
|
|
- this.setState({
|
|
|
- pageSize: pageSize
|
|
|
- }, () => { this.refreshOrganizationData() });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // 表格点击换页
|
|
|
- changePage = (page) => {
|
|
|
-
|
|
|
- this.setState({
|
|
|
- current: page,
|
|
|
- }, () => { this.refreshOrganizationData() });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // 显示总条数
|
|
|
- showTotal = () => {
|
|
|
- return '总共' + this.state.total + '条'
|
|
|
}
|
|
|
|
|
|
- // 显示页数发生变化
|
|
|
- onShowSizeChange = (current, pageSize) => {
|
|
|
- this.setState({
|
|
|
- pageSize: pageSize
|
|
|
- }, () => { this.refreshOrganizationData() });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 新增组织机构
|
|
|
- onAddOrganization = () => {
|
|
|
- this.setState({
|
|
|
- addVisiable: true,
|
|
|
- addConfirmLoading: true
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /* 新增机构取消事件 */
|
|
|
- addCancelClick = () => {
|
|
|
- this.setState({
|
|
|
- addVisiable: false,
|
|
|
- addConfirmLoading: false
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 机构新增parentName
|
|
|
- organizationAddParentName = (value) => {
|
|
|
- let organizationAddTemp = { ...this.state.organizationAdd }
|
|
|
- organizationAddTemp.parentName = value
|
|
|
- this.setState({
|
|
|
- organizationAdd: organizationAddTemp
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // 机构新增orgName
|
|
|
- organizationAddOrgName = (event) => {
|
|
|
- let organizationAddTemp = { ...this.state.organizationAdd }
|
|
|
- organizationAddTemp.orgName = event.target.value
|
|
|
- this.setState({
|
|
|
- organizationAdd: organizationAddTemp
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 保存新增数据
|
|
|
- handAddOk = (e) => {
|
|
|
- if (this.state.organizationAdd.orgName == null || this.state.organizationAdd.orgName == '') {
|
|
|
- message.error("机构名称不能为空")
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (this.state.organizationAdd.parentName == null || this.state.organizationAdd.parentName == '') {
|
|
|
- message.error("所属平台不能为空")
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- request({
|
|
|
- url: APIV3Auth + "/orgdoc/add",
|
|
|
- method: "post",
|
|
|
- data: this.state.organizationAdd
|
|
|
- }).then(result => {
|
|
|
- if (result.messageCode == 200) {
|
|
|
- message.success("新增机构成功")
|
|
|
- this.refreshOrganizationData()
|
|
|
- this.setState({
|
|
|
- organizationAdd: {}
|
|
|
- })
|
|
|
- } else {
|
|
|
- message.error("新增机构失败")
|
|
|
- }
|
|
|
- }).then(
|
|
|
- this.setState({
|
|
|
- addVisiable: false,
|
|
|
- addConfirmLoading: false,
|
|
|
- })
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 机构信息数据编辑
|
|
|
- handOrganizationEdit = (text, record) => {
|
|
|
+ // 接口密钥查看
|
|
|
+ handOrganizationCheck = (data) => {
|
|
|
+ console.log(data)
|
|
|
this.setState({
|
|
|
- editVisiable: true,
|
|
|
- organizationEdit: record
|
|
|
+ organizationSecret: data,
|
|
|
+ secretVisiable: true,
|
|
|
+ secretConfirmLoading: true,
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- /* 机构信息编辑取消 */
|
|
|
- editCancelClick = () => {
|
|
|
+ /* 密钥查看取消事件 */
|
|
|
+ secretCancelClick = () => {
|
|
|
this.setState({
|
|
|
- editVisiable: false,
|
|
|
- editConfirmLoading: false
|
|
|
+ secretVisiable: false,
|
|
|
+ secretConfirmLoading: false
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // 机构编辑OrgName
|
|
|
- organizationEditOrgName = (event) => {
|
|
|
- let organizationEditTemp = { ...this.state.organizationEdit }
|
|
|
- organizationEditTemp.orgName = event.target.value
|
|
|
- this.setState({
|
|
|
- organizationEdit: organizationEditTemp
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 机构编辑ParentName
|
|
|
- organizationEditParentName = (value) => {
|
|
|
- let organizationEditTemp = { ...this.state.organizationEdit }
|
|
|
- organizationEditTemp.parentName = value
|
|
|
- this.setState({
|
|
|
- organizationEdit: organizationEditTemp
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // 机构编辑authStatus
|
|
|
- organizationEditauthStatus = (value) => {
|
|
|
- let organizationEditTemp = { ...this.state.organizationEdit }
|
|
|
- organizationEditTemp.authStatus = value == "合作中" ? 1 : 0;
|
|
|
+ // 接口密钥Ips
|
|
|
+ organizationSecretIps = (event) => {
|
|
|
+ let organizationSecretTemp = { ...this.state.organizationSecret }
|
|
|
+ organizationSecretTemp.ips = event.target.value
|
|
|
this.setState({
|
|
|
- organizationEdit: organizationEditTemp
|
|
|
+ organizationSecret: organizationSecretTemp
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- // 保存修改数据
|
|
|
- handEditOk = (e) => {
|
|
|
|
|
|
- if (this.state.organizationEdit.orgName == null || this.state.organizationEdit.orgName == '') {
|
|
|
- message.error("机构名称不能为空")
|
|
|
+ // 接口密钥保存
|
|
|
+ handSecretOk = (e) => {
|
|
|
+ if (this.state.organizationSecret.ips == null || this.state.organizationSecret.ips == '') {
|
|
|
+ message.error("IP白名单不能为空")
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
this.setState({
|
|
|
- editVisiable: false,
|
|
|
- editConfirmLoading: false,
|
|
|
+ secretVisiable: false,
|
|
|
+ secretConfirmLoading: false,
|
|
|
}, () => {
|
|
|
request({
|
|
|
- url: APIV3Auth + "/orgdoc/update",
|
|
|
+ url: APIV3Auth + "/ums/orgdoc/update",
|
|
|
method: "put",
|
|
|
- data: this.state.organizationEdit
|
|
|
+ data: this.state.organizationSecret
|
|
|
}).then(result => {
|
|
|
- message.success("更新机构信息成功")
|
|
|
- this.refreshOrganizationData()
|
|
|
+ message.success("更新ip白名单成功")
|
|
|
+ this.refs.grid.reload();
|
|
|
});
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
// 接口授权窗口弹出
|
|
|
- handResource = (text, record) => {
|
|
|
-
|
|
|
- // 查询机构授权的接口
|
|
|
- request({
|
|
|
- url: APIV3Auth + "/orgdocResource/selectByOrgId?orgId=" + record.orgId,
|
|
|
- method: "get",
|
|
|
- }).then(result => {
|
|
|
- let selectedRowKeysTemp = result.result.map(x => { return (x.resourceId) })
|
|
|
- // selectedRowKeys.push(result.data.resourceId)
|
|
|
- this.setState({
|
|
|
- selectedRowKeys: selectedRowKeysTemp,
|
|
|
- selectedRowKeysInit: selectedRowKeysTemp,
|
|
|
- organizationResource: record,
|
|
|
- resourceVisiable: true,
|
|
|
- resourceConfirmLoading: true,
|
|
|
- selectedResourceType: '',
|
|
|
- selectedResourceName: '',
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
+ handResource = (data) => {
|
|
|
+ let self = this
|
|
|
+
|
|
|
+ this.setState({
|
|
|
+ resourceVisiable: true,
|
|
|
+ resourceConfirmLoading: true,
|
|
|
+ selectedOrg: data,
|
|
|
+ }, () => {
|
|
|
+ console.log(data)
|
|
|
+ console.log(self.refs.gridResource)
|
|
|
+ if (data.authNum > 0 && self.refs.gridResource != null) {
|
|
|
+ // 查询机构授权的接口
|
|
|
+ console.log("查询机构授权的接口")
|
|
|
+ request({
|
|
|
+ url: APIV3Auth + "/ums/orgdocResource/selectByOrgId?orgId=" + data.orgId,
|
|
|
+ method: "get",
|
|
|
+ }).then(result => {
|
|
|
+ console.log(result)
|
|
|
+ self.refs.gridResource.setState({
|
|
|
+ checkedValues: result.result.map(x => x.resourceId)
|
|
|
+ });
|
|
|
+ self.setState({
|
|
|
+ selectedRowKeysInit: result.result.map(x => x.resourceId)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/* 接口授权框取消事件 */
|
|
|
resourceCancelClick = () => {
|
|
|
this.setState({
|
|
|
+ selectedRowKeysInit:[],
|
|
|
resourceVisiable: false,
|
|
|
resourceConfirmLoading: false,
|
|
|
- resourceListCondition: this.state.resourceListAll
|
|
|
});
|
|
|
+ this.refs.gridResource.setState({
|
|
|
+ checkedValues: []
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ // 选中所有接口资源
|
|
|
+ saveAllResource = (data) => {
|
|
|
+ let self = this
|
|
|
+ console.log(self.refs.gridResource)
|
|
|
+ console.log(data)
|
|
|
+ this.refs.gridResource.setState({
|
|
|
+ checkedValues: data
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 接口授权保存
|
|
|
handResourceOk = (e) => {
|
|
|
+ console.log("接口授权保存")
|
|
|
|
|
|
- const { selectedRowKeysInit, selectedRowKeys } = this.state;
|
|
|
-
|
|
|
- let selectedRowKeysInitSet = new Set(selectedRowKeysInit)
|
|
|
- let selectedRowKeysSet = new Set(selectedRowKeys)
|
|
|
+ const { selectedRowKeysInit } = this.state;
|
|
|
+ let selectedRowKeys = this.refs.gridResource.state.checkedValues
|
|
|
+ let currentPage = this.refs.gridResource.state.gridDatas.items.map(x => x.resId)
|
|
|
|
|
|
// 要删除的授权
|
|
|
- let resourceDelete = selectedRowKeysInit.filter(x => !selectedRowKeysSet.has(x)).map(key => {
|
|
|
+ let resourceDelete = selectedRowKeysInit.filter(function(val){return currentPage.indexOf(val) > -1})
|
|
|
+ .filter(function(val){return selectedRowKeys.indexOf(val) === -1}).map(key => {
|
|
|
return ({
|
|
|
- "orgId": this.state.organizationResource.orgId,
|
|
|
+ "orgId": this.state.selectedOrg.orgId,
|
|
|
"resourceId": key
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ console.log(resourceDelete)
|
|
|
|
|
|
if (resourceDelete.length > 0) {
|
|
|
// 将删除授权信息写入数据库
|
|
|
request({
|
|
|
- url: APIV3Auth + "/orgdocResource/deleteBatch",
|
|
|
+ url: APIV3Auth + "/ums/orgdocResource/deleteBatch",
|
|
|
method: "delete",
|
|
|
data: resourceDelete
|
|
|
}).then(result => {
|
|
|
message.success("删除授权成功")
|
|
|
- this.refreshOrganizationData()
|
|
|
+ this.refs.grid.reload();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 要保存的授权
|
|
|
- let resourceAdd = selectedRowKeys.filter(x => !selectedRowKeysInitSet.has(x)).map(key => {
|
|
|
+ let resourceAdd = selectedRowKeys.filter(function(val){return selectedRowKeysInit.indexOf(val) === -1}).map(key => {
|
|
|
return ({
|
|
|
- "orgId": this.state.organizationResource.orgId,
|
|
|
+ "orgId": this.state.selectedOrg.orgId,
|
|
|
"resourceId": key
|
|
|
})
|
|
|
})
|
|
|
+ console.log(resourceAdd)
|
|
|
|
|
|
if (resourceAdd.length > 0) {
|
|
|
// 将授权信息写入数据库
|
|
|
request({
|
|
|
- url: APIV3Auth + "/orgdocResource/addBatch",
|
|
|
+ url: APIV3Auth + "/ums/orgdocResource/addBatch",
|
|
|
method: "post",
|
|
|
data: resourceAdd
|
|
|
}).then(result => {
|
|
|
message.success("新增授权成功")
|
|
|
- this.refreshOrganizationData()
|
|
|
+ this.refs.grid.reload();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- this.setState({
|
|
|
- resourceVisiable: false,
|
|
|
- resourceConfirmLoading: false,
|
|
|
- resourceListCondition: this.state.resourceListAll
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /* 密钥查看取消事件 */
|
|
|
- secretCancelClick = () => {
|
|
|
- this.setState({
|
|
|
- secretVisiable: false,
|
|
|
- secretConfirmLoading: false
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 接口密钥查看
|
|
|
- handOrganizationCheck = (text, record) => {
|
|
|
- this.setState({
|
|
|
- organizationSecret: record,
|
|
|
- secretVisiable: true,
|
|
|
- secretConfirmLoading: true,
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // 接口密钥Ips
|
|
|
- organizationSecretIps = (event) => {
|
|
|
- let organizationSecretTemp = { ...this.state.organizationSecret }
|
|
|
- organizationSecretTemp.ips = event.target.value
|
|
|
- this.setState({
|
|
|
- organizationSecret: organizationSecretTemp
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 接口密钥保存
|
|
|
- handSecretOk = (e) => {
|
|
|
- if (this.state.organizationSecret.ips == null || this.state.organizationSecret.ips == '') {
|
|
|
- message.error("IP白名单不能为空")
|
|
|
+ if(resourceAdd.length == 0 && resourceDelete == 0){
|
|
|
+ message.info("请选择要授权或者取消授权的接口")
|
|
|
return;
|
|
|
}
|
|
|
- this.setState({
|
|
|
- secretVisiable: false,
|
|
|
- secretConfirmLoading: false,
|
|
|
- }, () => {
|
|
|
- request({
|
|
|
- url: APIV3Auth + "/orgdoc/update",
|
|
|
- method: "put",
|
|
|
- data: this.state.organizationSecret
|
|
|
- }).then(result => {
|
|
|
- message.success("更新ip白名单成功")
|
|
|
- this.refreshOrganizationData()
|
|
|
- });
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 选择授权
|
|
|
- onSelectChange = selectedRowKeys => {
|
|
|
- this.setState({
|
|
|
- selectedRowKeys
|
|
|
- })
|
|
|
- };
|
|
|
-
|
|
|
- // 全部授权按钮
|
|
|
- selectAllRowkeys = () => {
|
|
|
- this.setState({
|
|
|
- selectedRowKeys: this.state.resourceListCondition.map(x => { return (x.id) })
|
|
|
- })
|
|
|
- }
|
|
|
|
|
|
- // 选择接口类型
|
|
|
- selectedResourceTypeChange = (value) => {
|
|
|
this.setState({
|
|
|
- selectedResourceType: value
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // 选择接口名称
|
|
|
- selectedResourceNameChange = (event) => {
|
|
|
- this.setState({
|
|
|
- selectedResourceName: event.target.value
|
|
|
+ resourceVisiable: false,
|
|
|
+ resourceConfirmLoading: false,
|
|
|
+ selectedRowKeysInit: []
|
|
|
})
|
|
|
- }
|
|
|
|
|
|
- // 查询
|
|
|
- conditionQuery = () => {
|
|
|
- let resourceListConditionTemp = null
|
|
|
- if (this.state.selectedResourceType != '' && this.state.selectedResourceName != '') {
|
|
|
- resourceListConditionTemp = this.state.resourceListAll.filter(x => x.parentId == this.state.resourceTypeListAll.find(x => x.name == this.state.selectedResourceType).id && x.name == this.state.selectedResourceName)
|
|
|
+ this.refs.gridResource.setState({
|
|
|
+ checkedValues: []
|
|
|
}
|
|
|
- if (this.state.selectedResourceType != '' && this.state.selectedResourceName == '') {
|
|
|
- resourceListConditionTemp = this.state.resourceListAll.filter(x => x.parentId == this.state.resourceTypeListAll.find(x => x.name == this.state.selectedResourceType).id)
|
|
|
- }
|
|
|
- if (this.state.selectedResourceType == '' && this.state.selectedResourceName != '') {
|
|
|
- resourceListConditionTemp = this.state.resourceListAll.filter(x => x.name == this.state.selectedResourceName)
|
|
|
- }
|
|
|
- if (this.state.selectedResourceType == '' && this.state.selectedResourceName == '') {
|
|
|
- resourceListConditionTemp = this.state.resourceListAll
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- this.setState({
|
|
|
- resourceListCondition: resourceListConditionTemp
|
|
|
- })
|
|
|
+ )
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
render() {
|
|
|
|
|
|
+ let self = this;
|
|
|
+
|
|
|
+ let authStatus = [
|
|
|
+ {
|
|
|
+ "label": "合作中",
|
|
|
+ "value": "1",
|
|
|
+ "disabled": false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "label": "已停止",
|
|
|
+ "value": "0",
|
|
|
+ "disabled": false
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ let parentName = [
|
|
|
+ {
|
|
|
+ "label": "亮键官网",
|
|
|
+ "value": "亮键官网",
|
|
|
+ "disabled": false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "label": "互联网医院",
|
|
|
+ "value": "互联网医院",
|
|
|
+ "disabled": false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "label": "亮健优医",
|
|
|
+ "value": "亮健优医",
|
|
|
+ "disabled": false
|
|
|
+ }
|
|
|
+ ];
|
|
|
|
|
|
- const { selectedRowKeys } = this.state;
|
|
|
-
|
|
|
- const rowSelection = {
|
|
|
- selectedRowKeys,
|
|
|
- onChange: this.onSelectChange,
|
|
|
- // columnTitle: "授权",
|
|
|
- // fixed: true,
|
|
|
-
|
|
|
+ let gridOption = {
|
|
|
+ title: "机构列表",
|
|
|
+ pageSize: 10,
|
|
|
+ url: {
|
|
|
+ read: APIV3Auth + "/ums/orgdoc/query",
|
|
|
+ add: APIV3Auth + "/ums/orgdoc/add",
|
|
|
+ edit: APIV3Auth + "/ums/orgdoc/update",
|
|
|
+ },
|
|
|
+ afterQuery: function (result, filters) {
|
|
|
+ let columns = self.refs.grid.state.columns;
|
|
|
+ for (let col in columns) {
|
|
|
+ if (columns[col].data == 'authNum' && columns[col].actions != null && columns[col].actions.length >= 2) {
|
|
|
+ columns[col].actions.shift();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.refs.grid.setState({
|
|
|
+ columns: columns
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ { title: "机构Id", data: "orgId", type: "text", query: false },
|
|
|
+ { title: "机构名称", data: "orgName", type: "text", editor: {}, query: false },
|
|
|
+ { title: "所属平台", data: "parentName", type: "dropdown", editor: {}, hide: true, query: false, source: { data: parentName } },
|
|
|
+ { title: "合作状态", data: "authStatus", type: "dropdown", editor: {}, query: false, source: { data: authStatus } },
|
|
|
+ { title: "接口授权数量", data: "authNum", type: "text", editor: { ep: 'hide', ap: 'hide' }, query: false, hide: true },
|
|
|
+ {
|
|
|
+ title: "接口授权数量", data: "authNum", type: "command", query: false, actions: [
|
|
|
+ {
|
|
|
+ nameFormat: (data) => { return data.authNum },
|
|
|
+ color: '#67c23a',
|
|
|
+ onClick: (data) => {
|
|
|
+ this.handResource(data)
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ title: "操作选项", type: "command", actions: [{
|
|
|
+ name: '查看密钥',
|
|
|
+ color: '#1880FF',
|
|
|
+ onClick: (data) => {
|
|
|
+ this.handOrganizationCheck(data)
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ ]
|
|
|
};
|
|
|
|
|
|
- return (
|
|
|
- <div style={{ padding: '25px', background: 'white' }}>
|
|
|
- <div style={{ padding: '10px 0px' }}>
|
|
|
- <Button type="primary" onClick={this.onAddOrganization} >添加</Button>
|
|
|
- </div>
|
|
|
-
|
|
|
- {/* 机构表 */}
|
|
|
- <div>
|
|
|
- <Table
|
|
|
- size="small"
|
|
|
- dataSource={this.state.organizationList}
|
|
|
- bordered
|
|
|
- pagination={{ pageSize: 10 }}
|
|
|
- columns={this.getTableColumnDef()}
|
|
|
- rowKey={record => record.id}
|
|
|
- pagination={{ // 分页
|
|
|
- current: this.state.current,
|
|
|
- total: this.state.total,
|
|
|
- onChange: this.changePage,
|
|
|
- showTotal: this.showTotal,
|
|
|
- showSizeChanger: true,
|
|
|
- showQuickJumper: true,
|
|
|
- onShowSizeChange: (current, pageSize) => this.onShowSizeChange(current, pageSize)
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>
|
|
|
-
|
|
|
- {/* 添加机构 */}
|
|
|
- <div>
|
|
|
- <Modal title="添加机构"
|
|
|
- width="70%"
|
|
|
- visible={this.state.addVisiable}
|
|
|
- okButtonProps={{ disabled: true }}
|
|
|
- onCancel={() => this.addCancelClick()}
|
|
|
- confirmLoading={this.state.addConfirmLoading}
|
|
|
- footer={[
|
|
|
- <Button key="submit" type="primary" onClick={this.handAddOk} >
|
|
|
- 保存
|
|
|
- </Button>,
|
|
|
- ]}>
|
|
|
-
|
|
|
- <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
|
|
|
- <Descriptions.Item label="机构名称"><Input value={this.state.organizationAdd.orgName} onChange={this.organizationAddOrgName}></Input></Descriptions.Item>
|
|
|
- <Descriptions.Item label="所属平台">
|
|
|
- <Select value={this.state.organizationAdd.parentName} style={{ width: 180 }} onChange={this.organizationAddParentName}>
|
|
|
- <Option value="亮健官网">亮健官网</Option>
|
|
|
- <Option value="互联网医院">互联网医院</Option>
|
|
|
- <Option value="亮健优医">亮健优医</Option>
|
|
|
- </Select>
|
|
|
- </Descriptions.Item>
|
|
|
- </Descriptions>
|
|
|
-
|
|
|
-
|
|
|
- </Modal>
|
|
|
- </div>
|
|
|
-
|
|
|
- {/* 机构信息编辑 */}
|
|
|
- <div>
|
|
|
- <Modal title="机构信息编辑"
|
|
|
- width="70%"
|
|
|
- visible={this.state.editVisiable}
|
|
|
- okButtonProps={{ disabled: true }}
|
|
|
- onCancel={() => this.editCancelClick()}
|
|
|
- confirmLoading={this.state.editConfirmLoading}
|
|
|
- footer={[
|
|
|
- <Button key="submit" type="primary" onClick={this.handEditOk} >
|
|
|
- 保存
|
|
|
- </Button>,
|
|
|
- ]}>
|
|
|
+ let gridOptionResource = {
|
|
|
+ title: "接口列表",
|
|
|
+ pageSize: 10,
|
|
|
+ checkable: true,
|
|
|
+ url: {
|
|
|
+ read: APIV3Auth + "/ums/resource/query",
|
|
|
+ },
|
|
|
+
|
|
|
+ columns: [
|
|
|
+ { title: "接口id", data: "resId", type: "text", query: false, hide: true },
|
|
|
+ { title: "接口编码", data: "resId", type: "text", query: false },
|
|
|
+ { title: "接口类型", data: "resourceTypeId", type: "dropdown", source: { url: APIV3Auth + '/ums/resourceType/selectAllAsJson' }, query: true },
|
|
|
+ { title: "接口名称", data: "menuName", type: "text", hide: false, query: true, },
|
|
|
+ { title: "接口描述", data: "description", type: "text", query: false },
|
|
|
+ ],
|
|
|
+ actions: [
|
|
|
+ {
|
|
|
+ name: '全部授权',
|
|
|
+ color: '#67c23a',
|
|
|
+ onClick: (data) => {
|
|
|
+ self.saveAllResource(self.refs.gridResource.state.gridDatas.items.map(x => x.resId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ afterQuery: function (result, filters) {
|
|
|
+ if (self.state.selectedOrg.authNum > 0) {
|
|
|
+ // 查询机构授权的接口
|
|
|
+ console.log("查询机构授权的接口")
|
|
|
+ request({
|
|
|
+ url: APIV3Auth + "/ums/orgdocResource/selectByOrgId?orgId=" + self.state.selectedOrg.orgId,
|
|
|
+ method: "get",
|
|
|
+ }).then(result => {
|
|
|
+ console.log(result)
|
|
|
+ self.refs.gridResource.setState({
|
|
|
+ checkedValues: result.result.map(x => x.resourceId)
|
|
|
+ });
|
|
|
+ self.setState({
|
|
|
+ selectedRowKeysInit: result.result.map(x => x.resourceId)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ };
|
|
|
|
|
|
- <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
|
|
|
- <Descriptions.Item label="机构ID">{this.state.organizationEdit.orgId}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="机构名称">
|
|
|
- <Input value={this.state.organizationEdit.orgName} onChange={this.organizationEditOrgName}></Input>
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="所属平台">
|
|
|
- <Select value={this.state.organizationEdit.parentName} style={{ width: 180 }} onChange={this.organizationEditParentName}>
|
|
|
- <Option value="亮健官网">亮健官网</Option>
|
|
|
- <Option value="互联网医院">互联网医院</Option>
|
|
|
- <Option value="亮健优医">亮健优医</Option>
|
|
|
- </Select>
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="合作状态">
|
|
|
- <Select value={this.state.organizationEdit.authStatus == 1 ? "合作中" : "已停止"} style={{ width: 180 }} onChange={this.organizationEditauthStatus}>
|
|
|
- <Option value="合作中">合作中</Option>
|
|
|
- <Option value="已停止">已停止</Option>
|
|
|
- </Select>
|
|
|
- </Descriptions.Item>
|
|
|
- </Descriptions>
|
|
|
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <BirdGrid gridOption={gridOption} ref="grid"></BirdGrid>
|
|
|
|
|
|
- </Modal>
|
|
|
- </div>
|
|
|
|
|
|
{/* 接口密钥 */}
|
|
|
<div>
|
|
@@ -697,7 +358,7 @@ class Orginazation extends Component {
|
|
|
<Descriptions.Item label="机构名称">{this.state.organizationSecret.orgName}</Descriptions.Item>
|
|
|
<Descriptions.Item label="所属平台">{this.state.organizationSecret.parentName}</Descriptions.Item>
|
|
|
<Descriptions.Item label="APPID">{this.state.organizationSecret.orgId}</Descriptions.Item>
|
|
|
- {/* <Descriptions.Item label="KEY">{this.state.organizationSecret.orgKey}</Descriptions.Item> */}
|
|
|
+ <Descriptions.Item label="KEY">{this.state.organizationSecret.orgKey}</Descriptions.Item>
|
|
|
<Descriptions.Item label="IP白名单"><Input value={this.state.organizationSecret.ips} onChange={this.organizationSecretIps}></Input></Descriptions.Item>
|
|
|
</Descriptions>
|
|
|
|
|
@@ -720,33 +381,7 @@ class Orginazation extends Component {
|
|
|
</Button>,
|
|
|
]}>
|
|
|
|
|
|
- <Select value={this.state.selectedResourceType} defaultValue='13' style={{ padding: "10px 0px", width: "100px" }} onChange={this.selectedResourceTypeChange}>
|
|
|
- <Option value='' key='empty'></Option>
|
|
|
- {
|
|
|
- this.state.resourceTypeListAll.map((x) => {
|
|
|
- return (<Option value={x.name} key={x.id}>{x.name}</Option>)
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- </Select>
|
|
|
- <Input placeholder='接口名称' value={this.state.selectedResourceName} style={{ padding: "10px 10px", width: "100px" }} onChange={this.selectedResourceNameChange}></Input>
|
|
|
- <Button type="primary" style={{ padding: "0px 10px", width: "100px" }} onClick={this.conditionQuery}>查询</Button>
|
|
|
- <Button type="primary" style={{ width: "100px", float: "right" }} onClick={this.selectAllRowkeys}>全部授权</Button>
|
|
|
-
|
|
|
- <Table
|
|
|
- size="small"
|
|
|
- dataSource={this.state.resourceListCondition}
|
|
|
- bordered
|
|
|
- pagination={{ pageSize: 10 }}
|
|
|
- columns={this.getTableColumnDefResource()}
|
|
|
- rowKey={record => record.id}
|
|
|
- rowSelection={rowSelection}
|
|
|
- pagination={{ // 分页
|
|
|
- showTotal: (() => { return '总共' + this.state.resourceListAll.length + '条, 已选中' + this.state.selectedRowKeys.length + '条' }),
|
|
|
- showSizeChanger: true,
|
|
|
- showQuickJumper: true,
|
|
|
- }}
|
|
|
- />
|
|
|
+ <BirdGrid gridOption={gridOptionResource} ref="gridResource"></BirdGrid>
|
|
|
|
|
|
|
|
|
</Modal>
|
|
@@ -759,4 +394,4 @@ class Orginazation extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export default Orginazation;
|
|
|
+export default Organization;
|