Browse Source

Merge branch 'master' of http://192.168.20.122:3000/root/qiyewechatApp.git

Lgx 4 years ago
parent
commit
ebeaf3cc75

+ 227 - 592
UI/src/pages/organization/Organization.js

@@ -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;

+ 0 - 366
UI/src/pages/organization/OrganizationCopy.js

@@ -1,366 +0,0 @@
-import React, { Component } from 'react';
-import { BirdGrid } from 'components/Grid';
-import { request } from 'utils';
-import { Modal, Button, message, Descriptions, Input } from 'antd';
-import config from 'utils/config'
-
-
-import 'antd/dist/antd.css';
-const { APIV3Auth } = config
-
-
-class OrganizationCopy extends Component {
-
-    constructor(props) {
-        super(props);
-        this.state = {
-            secretVisiable: false,
-            secretConfirmLoading: false,
-            organizationSecret: {},
-
-            resourceVisiable: false,
-            resourceConfirmLoading: false,
-
-
-            selectedOrgId: '',
-
-            selectedRowKeysInit: [],
-
-        };
-    }
-
-    // 接口密钥查看
-    handOrganizationCheck = (data) => {
-        console.log(data)
-        this.setState({
-            organizationSecret: data,
-            secretVisiable: true,
-            secretConfirmLoading: true,
-        })
-
-    }
-
-
-    /* 密钥查看取消事件 */
-    secretCancelClick = () => {
-        this.setState({
-            secretVisiable: false,
-            secretConfirmLoading: false
-        });
-    }
-
-    // 接口密钥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白名单不能为空")
-            return;
-        }
-        this.setState({
-            secretVisiable: false,
-            secretConfirmLoading: false,
-        }, () => {
-            request({
-                url: APIV3Auth + "/orgdoc/update",
-                method: "put",
-                data: this.state.organizationSecret
-            }).then(result => {
-                message.success("更新ip白名单成功")
-                this.refs.grid.reload();
-            });
-        })
-    }
-
-
-    // 接口授权窗口弹出
-    handResource = (data) => {
-        console.log(data.orgId)
-
-        this.setState({
-            resourceVisiable: true,
-            resourceConfirmLoading: true,
-            selectedOrgId: data.orgId,
-        })
-
-    }
-
-    /* 接口授权框取消事件 */
-    resourceCancelClick = () => {
-        this.setState({
-            resourceVisiable: false,
-            resourceConfirmLoading: false,
-        });
-    }
-
-    // 选中所有接口资源
-    saveAllResource = (data) => {
-        this.refs.gridResource.setState({
-            checkedValues: data
-        })
-    }
-
-    // 接口授权保存
-    handResourceOk = (e) => {
-        console.log("接口授权保存")
-
-        const { selectedRowKeysInit } = this.state;
-        let selectedRowKeys = this.refs.gridResource.state.checkedValues
-
-        let selectedRowKeysInitSet = new Set(selectedRowKeysInit)
-        let selectedRowKeysSet = new Set(selectedRowKeys)
-
-        // 要删除的授权
-        let resourceDelete = selectedRowKeysInit.filter(x => !selectedRowKeysSet.has(x)).map(key => {
-            return ({
-                "orgId": this.state.selectedOrgId.orgId,
-                "resourceId": key
-            })
-        })
-
-
-        if (resourceDelete.length > 0) {
-            // 将删除授权信息写入数据库
-            request({
-                url: APIV3Auth + "/orgdocResource/deleteBatch",
-                method: "delete",
-                data: resourceDelete
-            }).then(result => {
-                message.success("删除授权成功")
-                this.refs.grid.reload();
-            });
-        }
-
-        // 要保存的授权
-        let resourceAdd = selectedRowKeys.filter(x => !selectedRowKeysInitSet.has(x)).map(key => {
-            return ({
-                "orgId": this.state.selectedOrgId.orgId,
-                "resourceId": key
-            })
-        })
-
-        if (resourceAdd.length > 0) {
-            // 将授权信息写入数据库
-            request({
-                url: APIV3Auth + "/orgdocResource/addBatch",
-                method: "post",
-                data: resourceAdd
-            }).then(result => {
-                message.success("新增授权成功")
-                this.refs.grid.reload();
-            });
-        }
-
-        this.setState({
-            resourceVisiable: false,
-            resourceConfirmLoading: false,
-            resourceListCondition: this.state.resourceListAll,
-            selectedRowKeysInit: []
-        })
-
-        this.refs.gridResource.setState({
-            checkedValues: []
-        }
-        )
-
-
-    }
-
-    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
-            }
-        ];
-
-        let gridOption = {
-            title: "机构列表",
-            pageSize: 10,
-            url: {
-                read: APIV3Auth + "/orgdoc/query",
-                add: APIV3Auth + "/orgdoc/add",
-                edit: APIV3Auth + "/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", editor: {}, 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)
-                        }
-                    }]
-                }
-            ]
-        };
-
-        let gridOptionResource = {
-            title: "接口列表",
-            pageSize: 10,
-            checkable: true,
-            url: {
-                read: APIV3Auth + "/resource/query",
-            },
-
-            columns: [
-                { title: "接口id", data: "id", type: "text", query: false, hide: true },
-                { title: "接口编码", data: "code", type: "text", query: false },
-                { title: "接口类型", data: "parentId", type: "dropdown", source: { url: APIV3Auth + '/resourceType/selectAllAsJson' }, query: true },
-                { title: "接口名称", data: "name", 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.id))
-                    }
-                }
-            ],
-            afterQuery: function (result, filters) {
-                // 查询机构授权的接口
-                request({
-                    url: APIV3Auth + "/orgdocResource/selectByOrgId?orgId=" + self.state.selectedOrgId,
-                    method: "get",
-                }).then(result => {
-                    return result.result.map(x => x.resourceId)
-                }).then(result => {
-                    self.refs.gridResource.setState({
-                        checkedValues: result
-                    });
-                    self.setState({
-                        selectedRowKeysInit: result
-                    })
-                });
-
-
-
-            },
-        };
-
-
-        return (
-            <div>
-                <BirdGrid gridOption={gridOption} ref="grid"></BirdGrid>
-
-
-                {/* 接口密钥 */}
-                <div>
-                    <Modal title="接口密钥"
-                        width="70%"
-                        visible={this.state.secretVisiable}
-                        okButtonProps={{ disabled: true }}
-                        onCancel={() => this.secretCancelClick()}
-                        confirmLoading={this.state.secretConfirmLoading}
-                        footer={[
-                            <Button key="submit" type="primary" onClick={this.handSecretOk} >
-                                保存
-                            </Button>,
-                        ]}>
-
-                        <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
-                            <Descriptions.Item label="机构">{this.state.organizationSecret.orgId}</Descriptions.Item>
-                            <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="IP白名单"><Input value={this.state.organizationSecret.ips} onChange={this.organizationSecretIps}></Input></Descriptions.Item>
-                        </Descriptions>
-
-
-                    </Modal>
-
-                </div>
-
-                {/* 接口授权 */}
-                <div>
-                    <Modal title="接口授权"
-                        width="70%"
-                        visible={this.state.resourceVisiable}
-                        okButtonProps={{ disabled: true }}
-                        onCancel={() => this.resourceCancelClick()}
-                        confirmLoading={this.state.resourceConfirmLoading}
-                        footer={[
-                            <Button key="submit" type="primary" onClick={this.handResourceOk} >
-                                保存
-                            </Button>,
-                        ]}>
-
-                        <BirdGrid gridOption={gridOptionResource} ref="gridResource"></BirdGrid>
-
-
-                    </Modal>
-
-
-                </div>
-
-            </div>
-        );
-    }
-}
-
-export default OrganizationCopy;

+ 70 - 723
UI/src/pages/resources/Resources.js

@@ -1,749 +1,96 @@
 import React, { Component } from 'react';
-import { request } from 'utils';
-import { Modal, Row, Col, Table, Button, Popconfirm, message, Descriptions, Select, Input ,Tooltip} from 'antd';
+import { BirdGrid } from 'components/Grid';
+import { Row, Col, message } from 'antd';
 import config from 'utils/config'
 import 'antd/dist/antd.css';
 
 const { APIV3Auth } = config
-const { Option } = Select
-
 
 class Resources extends Component {
     constructor(props) {
         super(props);
-        this.state = {
-            resourceTypeEditVisiable: false,
-            resourceTypeEditConfirmLoading: false,
-            resourceTypeEdit: {},
-            resourceTypeAddVisiable: false,
-            resourceTypeAddConfirmLoading: false,
-            resourceTypeAdd: '',
-            resourceTypeCurrent: 1,
-            resourceTypeTotal: 0,
-            resourceTypePageSize: 10,
-
-            resourceTypeListAll: [
-            ],
-
-            resourceEditVisiable: false,
-            resourceEditConfirmLoading: false,
-            resourceEdit: {},
-            resourceAddVisiable: false,
-            resourceAddConfirmLoading: false,
-            resourceAdd: {},
-            resourceCurrent: 1,
-            resourceTotal: 0,
-            resourcePageSize: 10,
-            resourceListAll: [
-            ],
-            resourceListAllTemp: [
-            ],
-            resourceListAllTempTypeId:'',
-
-
-        };
-
-        //初始化所有接口类型列表
-        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,
-                resourceListAllTemp: resourceListAllTemp,
-            });
-        });
-    }
-
-    // 设置接口类型表格标签
-    getResourceTypeTableColumnDef = () => {
-        return [{
-            title: "类型Id",
-            dataIndex: "id",
-            key: "id",
-            render: (text, record, index) => {
-                return <span>{text}</span>
-            }
-        }, {
-            title: "类型名称",
-            dataIndex: "name",
-            key: "name",
-            render: (text, record, index) => {
-                return <span onClick={() => this.chageResourceListAll(text, record, index)}>{text}</span>
-            }
-        },
-        {
-            title: '操作',
-            key: 'action',
-            render: (text, record) => (
-                <span>
-                    <a style={{ marginRight: 16 }} onClick={() => this.handResourceTypeEdit(text, record)}>编辑</a>
-                </span>
-            ),
-        },
-        ];
-    }
-
-
-    // 点击接口类型,变更接口表格显示数据
-    chageResourceListAll = (text, record, index) =>{
-        if(this.state.resourceListAllTempTypeId == ''){
-            this.setState({
-                resourceListAllTemp: this.state.resourceListAll.filter(resource => resource.parentId == record.id),
-                resourceListAllTempTypeId: record.id
-            })
-        }else{
-            this.setState({
-                resourceListAllTemp: this.state.resourceListAll,
-                resourceListAllTempTypeId:''
-            })
-        }
+        this.state = {};
     }
+    render() {
 
-
-
-    // 刷新所有接口类型表格数据
-    refreshResourceTypeData = () => {
-        //初始化所有接口类型列表
-        request({
-            url: APIV3Auth + "/resourceType/all",
-            method: "get"
-        }).then(result => {
-            let resourceTypeListTemp = result.result;
-            this.setState({
-                resourceTypeListAll: resourceTypeListTemp,
-            });
-
-        });
-    }
-
-    // 接口类型表格显示总条数
-    resourceTypeShowTotal = () => {
-        return '总共' + this.state.resourceTypeListAll.length + '条'
-    }
-
-
-    // 接口类型编辑按钮
-    handResourceTypeEdit = (text, record) => {
-        this.setState({
-            resourceTypeEdit: record,
-        }, () => {
-            this.setState({
-                resourceTypeEditVisiable: true,
-                resourceTypeEditConfirmLoading: true,
-            })
-        })
-    }
-
-
-    // 接口类型取消编辑模态框
-    resourceTypeHandEditCancelClick = () => {
-        this.setState({
-            resourceTypeEditVisiable: false,
-            resourceTypeEditConfirmLoading: false,
-        })
-    }
-
-
-    // 编辑接口类型输入框
-    resourceTypeHandEditInput = (event) => {
-        // let resourceTypeEditTemp = {...this.state.resourceTypeEdit}
-        let resourceTypeEditTemp = JSON.parse(JSON.stringify(this.state.resourceTypeEdit))
-        resourceTypeEditTemp.name = event.target.value
-        resourceTypeEditTemp.updateTime = new Date().toLocaleDateString
-        this.setState({
-            resourceTypeEdit: resourceTypeEditTemp
-        })
-    }
-
-    // 接口类型编辑成功
-    resourceTypehandEditOk = () => {
-
-        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("更新成功")
-                this.refreshResourceTypeData()
-            } else {
-                message.error("接口类型编辑保存失败")
-            }
-        }).then(
-            this.setState({
-                resourceTypeEditVisiable: false,
-                resourceTypeEditConfirmLoading: false,
-            })
-        );
-
-
-
-    }
-
-
-    // 接口类型添加按钮
-    resourceTypeHandAdd = () => {
-        this.setState({
-            resourceTypeAddVisiable: true,
-            resourceTypeAddConfirmLoading: true,
-        })
-    }
-
-
-    // 取消接口类型添加
-    resourceTypeAddCancelClick = () => {
-        this.setState({
-            resourceTypeAddVisiable: false,
-            resourceTypeAddConfirmLoading: false,
-        })
-    }
-
-    // 新增接口类型成功
-    resourceTypehandAddOk = () => {
-
-        if (this.state.resourceTypeAdd != '') {
-            request({
-                url: APIV3Auth + "/resourceType/add",
-                method: "post",
-                data: {
-                    name: this.state.resourceTypeAdd
-                }
-            }).then(result => {
-                message.success("新增接口类型成功");
-                this.refreshResourceTypeData();
-                this.setState({
-                    resourceTypeAddVisiable: false,
-                    resourceTypeAddConfirmLoading: false,
-                })
-            })
-        } else {
-            message.error("接口类型名称不能为空");
-        }
-
-    }
-
-    // 新增接口类型输入框
-    resourceTypeHandAddInput = (event) => {
-        this.setState({
-            resourceTypeAdd: event.target.value
-        })
-    }
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-
-    // 刷新接口数据
-    refreshResourceData = () => {
-        request({
-            url: APIV3Auth + "/resource/all",
-            method: "get",
-
-        }).then(result => {
-            let resourceListAllTemp = result.result;
-            this.setState({
-                resourceListAll: resourceListAllTemp,
-            },() => {
-                if (this.state.resourceListAllTempTypeId != '') {
-                    this.setState({
-                        resourceListAllTemp: this.state.resourceListAll.filter(resource => resource.parentId == this.state.resourceListAllTempTypeId),
-                    })
-                } else {
-                    this.setState({
-                        resourceListAllTemp: this.state.resourceListAll,
-                    })
-                }
-            });
-        });
-    }
-
-
-    // 设置接口表格标签
-    getResourceTableColumnDef = () => {
-        return [{
-            title: "接口编码",
-            dataIndex: "code",
-            key: "code",
-            render: (text, record, index) => {
-                return <span>{text}</span>
-            }
-        }, {
-            title: "接口名称",
-            dataIndex: "name",
-            key: "name",
-            onCell: () => {
-                return {
-                  style: {
-                    maxWidth: 150,
-                    overflow: 'hidden',
-                    whiteSpace: 'nowrap',
-                    textOverflow:'ellipsis',
-                    cursor:'pointer'
-                  }
-                }
-              },
-            ellipsis: true,
-            render: (text) => <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
-        }, {
-            title: "接口描述",
-            dataIndex: "description",
-            key: "description",
-            onCell: () => {
-                return {
-                  style: {
-                    maxWidth: 150,
-                    overflow: 'hidden',
-                    whiteSpace: 'nowrap',
-                    textOverflow:'ellipsis',
-                    cursor:'pointer'
-                  }
+        let self = this;
+
+        let gridOptionResourceType = {
+            title: "接口类型列表",
+            pageSize: 10,
+            sortDirection: 'asc',
+            url: {
+                read: APIV3Auth + "/ums/resourceType/query",
+                add: APIV3Auth + "/ums/resourceType/add",
+                edit: APIV3Auth + "/ums/resourceType/update",
+            },
+
+            columns: [
+                { title: "类型Id", data: "id", type: "text", editor: {}, query: false },
+                { title: "类型名称", data: "name", type: "text", editor: {}, query: false },
+                {
+                    title: "操作选项", type: "command", actions: [{
+                        name: '明细 >',
+                        color: '#67c23a',
+                        onClick: (data) => {
+                            let customDataInit = this.refs.gridResource.state.customData
+                            console.log(customDataInit)
+                            if (customDataInit.length > 0 && customDataInit[0].value == data.id) {
+                                this.refs.gridResource.setCustomData([]);
+                            } else {
+                                this.refs.gridResource.setCustomData([{
+                                    field: "resourceTypeId",
+                                    value: data.id,
+                                }]);
+                            }
+                        }
+                    }]
                 }
-              },
-            ellipsis: true,
-            render: (text) => <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
-        }, {
-            title: "接口地址",
-            dataIndex: "url",
-            key: "url",
-            onCell: () => {
-                return {
-                  style: {
-                    maxWidth: 150,
-                    overflow: 'hidden',
-                    whiteSpace: 'nowrap',
-                    textOverflow:'ellipsis',
-                    cursor:'pointer'
-                  }
-                }
-              },
-            ellipsis: true,
-            render: (text) => <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
-            // render: (text, record, index) => {
-            //     return <span>{text}</span>
-            // }
-        },
-        {
-            title: '操作',
-            key: 'action',
-            render: (text, record) => (
-                <span>
-                    <a style={{ marginRight: 16 }} onClick={() => this.handresourceEdit(text, record)}>编辑</a>
-                </span>
-            ),
-        },
-        ];
-    }
-
-
-    // 接口显示总条数
-    resourceShowTotal = () => {
-        return '总共' + this.state.resourceListAllTemp.length + '条'
-    }
-
-    // 接口显示页数发生变化
-    resourceOnShowSizeChange = (current, pageSize) => {
-        this.setState({
-            resourcePageSize: pageSize
-        }, () => { this.refreshResourceData() });
-
-    }
-
-    // 接口编辑数据
-    handresourceEdit = (text, record) => {
-        let resourceTypeTemp = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId)
-        if (resourceTypeTemp != null) {
-            record.parentName = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId).name
-        }
-        this.setState({
-            resourceEditVisiable: true,
-            resourceEditConfirmLoading: true,
-            resourceEdit: record
-        })
-
-    }
-
-    // 接口取消编辑
-    editResourceCancelClick = () => {
-        this.setState({
-            resourceEditVisiable: false,
-            resourceEditConfirmLoading: false,
-        })
-    }
-
-    // 点击按钮添加接口
-    resourceHandAdd = () => {
-        this.setState({
-            resourceAddVisiable: true,
-            resourceAddConfirmLoading: true,
-        })
-    }
-
-    // 取消添加接口
-    resourceAddCancelClick = () => {
-        this.setState({
-            resourceAddVisiable: false,
-            resourceAddConfirmLoading: false,
-        })
-    }
-
-
-    // 新增接口name输入框
-    resourceHandAddInputName = (event) => {
-        let resourceAddTemp = { ...this.state.resourceAdd }
-        resourceAddTemp.name = event.target.value
-        this.setState({
-            resourceAdd: resourceAddTemp
-        })
-    }
-    // 新增接口code输入框
-    resourceHandAddInputCode = (event) => {
-        let resourceAddTemp = { ...this.state.resourceAdd }
-        resourceAddTemp.code = event.target.value
-        resourceAddTemp.types = 2
-        this.setState({
-            resourceAdd: resourceAddTemp
-        })
-    }
-    // 新增接口parentName输入框
-    resourceHandAddInputParentName = (value) => {
-        let resourceAddTemp = { ...this.state.resourceAdd }
-        resourceAddTemp.parentName = value
-        resourceAddTemp.parentId = this.state.resourceTypeListAll.find(resourceType => value == resourceType.name).id
-        this.setState({
-            resourceAdd: resourceAddTemp
-        })
-    }
-    // 新增接口url输入框
-    resourceHandAddInputUrl = (event) => {
-        let resourceAddTemp = { ...this.state.resourceAdd }
-        resourceAddTemp.url = event.target.value
-        this.setState({
-            resourceAdd: resourceAddTemp
-        })
-    }
-    // 新增接口description输入框
-    resourceHandAddInputDescription = (event) => {
-        let resourceAddTemp = { ...this.state.resourceAdd }
-        resourceAddTemp.description = event.target.value
-        this.setState({
-            resourceAdd: resourceAddTemp
-        })
-    }
-
-
-    // 新增接口成功
-    resourcehandAddOk = (value) => {
-
-        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输入框
-    resourceHandEditInputName = (event) => {
-        let resourceEditTemp = { ...this.state.resourceEdit }
-        resourceEditTemp.name = event.target.value
-        this.setState({
-            resourceEdit: resourceEditTemp
-        })
-    }
-    // 编辑接口code输入框
-    resourceHandEditInputCode = (event) => {
-        let resourceEditTemp = { ...this.state.resourceEdit }
-        resourceEditTemp.code = event.target.value
-        this.setState({
-            resourceEdit: resourceEditTemp
-        })
-    }
-    // 编辑接口parentName输入框
-    resourceHandEditInputParentName = (value) => {
-        let resourceEditTemp = { ...this.state.resourceEdit }
-        resourceEditTemp.parentId = this.state.resourceTypeListAll.find(resourceType => value == resourceType.name).id
-        resourceEditTemp.parentName = value
-        this.setState({
-            resourceEdit: resourceEditTemp
-        })
-    }
-    // 编辑接口url输入框
-    resourceHandEditInputUrl = (event) => {
-        let resourceEditTemp = { ...this.state.resourceEdit }
-        resourceEditTemp.url = event.target.value
-        this.setState({
-            resourceEdit: resourceEditTemp
-        })
-    }
-    // 编辑接口description输入框
-    resourceHandEditInputDescription = (event) => {
-        let resourceEditTemp = { ...this.state.resourceEdit }
-        resourceEditTemp.description = event.target.value
-        this.setState({
-            resourceEdit: resourceEditTemp
-        })
-    }
-
-
-    // 编辑接口成功
-    resourcehandEditOk = (value) => {
-        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()
-                this.setState({
-                    resourceEditVisiable: false,
-                    resourceEditConfirmLoading: false,
-                })
-            } else {
-                message.success("编辑接口失败")
-            }
-        });
-
-
-    }
-
+            ]
+        };
 
-    render() {
 
+        let gridOptionResource = {
+            title: "接口列表",
+            pageSize: 10,
+            checkable: false,
+            url: {
+                read: APIV3Auth + "/ums/resource/query",
+                add: APIV3Auth + "/ums/resource/addResource",
+                edit: APIV3Auth + "/ums/resource/update",
+            },
+            afterSave: function(){
+                console.log(self.refs.gridResource)
+            },
+            columns: [
+                { title: "接口编码", data: "resId", type: "text", query: false },
+                { title: "接口名称", data: "menuName", type: "text", hide: false, editor: {},query: true },
+                {
+                    title: "接口类型", data: "resourceTypeId", type: "dropdown",
+                    editor: {},
+                    source: { url: APIV3Auth + '/ums/resourceType/selectAllAsJson' },
+                    query: true
+                },
+                { title: "接口描述", data: "description", type: "text", editor: {}, query: false },
+                { title: "接口地址", data: "linkUrl", type: "text", editor: {}, query: false },
+                { title: "操作选项", type: "command" }
+            ]
+        };
 
         return (
             <div>
                 <Row style={{ background: "white", padding: "10px 10px" }}>
-                    <Col span={8} style={{ padding: "10px 10px" }}>
+                    <Col span={7} style={{ padding: "10px 10px" }}>
                         <div>
-                            <Button style={{ margin: "10px 0px" }} type="primary" onClick={this.resourceTypeHandAdd}>添加接口类型</Button>
-                            {/* 添加接口类型 */}
-                            <Table
-                                size="small"
-                                dataSource={this.state.resourceTypeListAll}
-                                bordered
-                                pagination={{ pageSize: 10 }}
-                                columns={this.getResourceTypeTableColumnDef()}
-                                rowKey={record => record.id}
-                                pagination={{  // 分页
-                                    // total: this.state.resourceTypeListAll.size,
-                                    showTotal: this.resourceTypeShowTotal,
-                                    showSizeChanger: true,
-                                    showQuickJumper: true,
-                                }}
-                            />
+
+                            <BirdGrid gridOption={gridOptionResourceType} ref="gridResourceType"></BirdGrid>
                         </div>
                     </Col>
-                    <Col span={16} style={{ padding: "10px 10px" }}>
-                        <div>
-                            <Button style={{ margin: "10px 0px" }} type="primary" onClick={this.resourceHandAdd}>添加接口</Button>
-                            {/* 接口表 */}
-                            <Table
-                                size="small"
-                                dataSource={this.state.resourceListAllTemp}
-                                bordered
-                                pagination={{ pageSize: 10 }}
-                                columns={this.getResourceTableColumnDef()}
-                                rowKey={record => record.id}
-                                pagination={{  // 分页
-                                    showTotal: this.resourceShowTotal,
-                                    showSizeChanger: true,
-                                    showQuickJumper: true,
-                                }}
-                            />
-                        </div>
+                    <Col span={17} style={{ padding: "10px 10px" }}>
+                        <BirdGrid gridOption={gridOptionResource} ref="gridResource"></BirdGrid>
+
                     </Col>
                 </Row>
-
-                <div>
-                    {/* 添加接口类型 */}
-                    <div>
-                        <Modal title="添加接口类型"
-                            width="70%"
-                            visible={this.state.resourceTypeAddVisiable}
-                            okButtonProps={{ disabled: true }}
-                            onCancel={() => this.resourceTypeAddCancelClick()}
-                            confirmLoading={this.state.resourceTypeAddConfirmLoading}
-                            footer={[
-                                <Button key="submit" type="primary" onClick={this.resourceTypehandAddOk} >
-                                    保存
-                            </Button>,
-                            ]}>
-
-                            <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
-                                <Descriptions.Item label="类型名称"><Input placeholder={this.state.resourceTypeAdd} onChange={this.resourceTypeHandAddInput}></Input></Descriptions.Item>
-                            </Descriptions>
-
-
-                        </Modal>
-                    </div>
-
-                    {/* 编辑接口类型 */}
-                    <div>
-                        <Modal title="类型信息编辑"
-                            width="70%"
-                            visible={this.state.resourceTypeEditVisiable}
-                            okButtonProps={{ disabled: true }}
-                            onCancel={() => this.resourceTypeHandEditCancelClick()}
-                            confirmLoading={this.state.add}
-                            footer={[
-                                <Button key="submit" type="primary" onClick={this.resourceTypehandEditOk}>
-                                    保存
-                            </Button>,
-                            ]}>
-
-                            <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
-                                <Descriptions.Item label="类型名称"><Input value={this.state.resourceTypeEdit.name} onChange={this.resourceTypeHandEditInput}></Input></Descriptions.Item>
-                            </Descriptions>
-
-
-                        </Modal>
-                    </div>
-
-                    {/* 添加接口 */}
-                    <div>
-                        <Modal title="添加接口"
-                            width="70%"
-                            visible={this.state.resourceAddVisiable}
-                            okButtonProps={{ disabled: true }}
-                            onCancel={() => this.resourceAddCancelClick()}
-                            confirmLoading={this.state.resourceAddConfirmLoading}
-                            footer={[
-                                <Button key="submit" type="primary" onClick={this.resourcehandAddOk}>
-                                    保存
-                            </Button>,
-                            ]}>
-
-
-                            <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
-                                <Descriptions.Item label="接口类型">
-                                    <Select value={this.state.resourceAdd.parentName} style={{ width: 180 }} onChange={this.resourceHandAddInputParentName}>
-                                        {
-                                            this.state.resourceTypeListAll.map((x) => {
-                                                return (<Option value={x.name} key={x.id}>{x.name}</Option>)
-                                            })
-                                        }
-                                    </Select>
-                                </Descriptions.Item>
-                                {/* <Descriptions.Item label="接口类型"><Input value={this.state.resourceAdd.parentName} onChange={this.resourceHandAddInputParentName}></Input></Descriptions.Item> */}
-                                <Descriptions.Item label="接口编码"><Input value={this.state.resourceAdd.code} onChange={this.resourceHandAddInputCode}></Input></Descriptions.Item>
-                                <Descriptions.Item label="接口名称"><Input value={this.state.resourceAdd.name} onChange={this.resourceHandAddInputName}></Input></Descriptions.Item>
-                                <Descriptions.Item label="接口地址"><Input value={this.state.resourceAdd.url} onChange={this.resourceHandAddInputUrl}></Input></Descriptions.Item>
-                                <Descriptions.Item label="接口描述"><Input value={this.state.resourceAdd.description} onChange={this.resourceHandAddInputDescription}></Input></Descriptions.Item>
-                            </Descriptions>
-
-
-                        </Modal>
-                    </div>
-
-                    {/* 编辑接口 */}
-                    <div>
-                        <Modal title="类型信息编辑"
-                            width="70%"
-                            visible={this.state.resourceEditVisiable}
-                            okButtonProps={{ disabled: true }}
-                            onCancel={() => this.editResourceCancelClick()}
-                            confirmLoading={this.state.resourceTypeEditConfirmLoading}
-                            footer={[
-                                <Button key="submit" type="primary" onClick={this.resourcehandEditOk}>
-                                    保存
-                            </Button>,
-                            ]}>
-
-                            <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
-                                <Descriptions.Item label="接口名称"><Input value={this.state.resourceEdit.name} onChange={this.resourceHandEditInputName}></Input></Descriptions.Item>
-                                <Descriptions.Item label="接口编码"><Input value={this.state.resourceEdit.code} onChange={this.resourceHandEditInputCode}></Input></Descriptions.Item>
-                                <Descriptions.Item label="接口地址"><Input value={this.state.resourceEdit.url} onChange={this.resourceHandEditInputUrl}></Input></Descriptions.Item>
-                                <Descriptions.Item label="接口描述"><Input value={this.state.resourceEdit.description} onChange={this.resourceHandEditInputDescription}></Input></Descriptions.Item>
-                                <Descriptions.Item label="接口类型">
-                                    <Select value={this.state.resourceEdit.parentName} style={{ width: 180 }} onChange={this.resourceHandEditInputParentName}>
-                                        {
-                                            this.state.resourceTypeListAll.map((x) => {
-                                                return (<Option value={x.name} key={x.id}>{x.name}</Option>)
-                                            })
-                                        }
-                                    </Select>
-                                </Descriptions.Item>
-                            </Descriptions>
-
-
-                        </Modal>
-                    </div>
-                </div>
             </div>
         );
     }

+ 0 - 94
UI/src/pages/resources/ResourcesCopy.js

@@ -1,94 +0,0 @@
-import React, { Component } from 'react';
-import { BirdGrid } from 'components/Grid';
-import { Row, Col } from 'antd';
-import config from 'utils/config'
-import 'antd/dist/antd.css';
-
-const { APIV3Auth } = config
-
-class ResourcesCopy extends Component {
-    constructor(props) {
-        super(props);
-        this.state = {};
-    }
-    render() {
-
-        let gridOptionResourceType = {
-            title: "接口类型列表",
-            pageSize: 10,
-            sortDirection: 'asc',
-            url: {
-                read: APIV3Auth + "/resourceType/query",
-                add: APIV3Auth + "/resourceType/add",
-                edit: APIV3Auth + "/resourceType/update",
-            },
-
-            columns: [
-                { title: "类型Id", data: "id", type: "text", editor: {}, query: false },
-                { title: "类型名称", data: "name", type: "text", editor: {}, query: false },
-                {
-                    title: "操作选项", type: "command", actions: [{
-                        name: '明细',
-                        color: '#67c23a',
-                        onClick: (data) => {
-                            let customRules = this.state.customRule || [];
-                            customRules = [{
-                                field: "parentId",
-                                value: data.id,
-                            }];
-                            if (this.refs.gridResource) {
-                                this.refs.gridResource.setCustomData(customRules);
-
-                            }
-                        }
-                    }]
-                }
-            ]
-        };
-
-
-        let gridOptionResource = {
-            title: "接口列表",
-            pageSize: 10,
-            checkable: false,
-            url: {
-                read: APIV3Auth + "/resource/query",
-                add: APIV3Auth + "/resource/add",
-                edit: APIV3Auth + "/resource/update",
-            },
-
-            columns: [
-                { title: "接口编码", data: "code", type: "text", editor: {}, query: false },
-                { title: "接口名称", data: "name", type: "text", hide: false, editor: {}, query: true },
-                {
-                    title: "接口类型", data: "parentId", type: "dropdown",
-                    editor: {},
-                    source: { url: APIV3Auth + '/resourceType/selectAllAsJson' },
-                    query: true
-                },
-                { title: "接口描述", data: "description", type: "text", editor: {}, query: false },
-                { title: "接口地址", data: "url", type: "text", editor: {}, query: false },
-                { title: "操作选项", type: "command" }
-            ]
-        };
-
-        return (
-            <div>
-                <Row style={{ background: "white", padding: "10px 10px" }}>
-                    <Col span={7} style={{ padding: "10px 10px" }}>
-                        <div>
-
-                            <BirdGrid gridOption={gridOptionResourceType} ref="gridResourceType"></BirdGrid>
-                        </div>
-                    </Col>
-                    <Col span={17} style={{ padding: "10px 10px" }}>
-                        <BirdGrid gridOption={gridOptionResource} ref="gridResource"></BirdGrid>
-
-                    </Col>
-                </Row>
-            </div>
-        );
-    }
-}
-
-export default ResourcesCopy;

+ 2 - 2
UI/src/utils/config.js

@@ -13,9 +13,9 @@ module.exports =  {
   iconFontCSS: '/iconfont.css',
   iconFontJS: '/iconfont.js',
   CORS: ['http://localhost:8000', 
+  'http://192.168.10.87:8030',
   'http://localhost:8030',
   'http://localhost:8004',
-  'http://localhost:7000',
   'https://coop.360lj.com',
   'http://localhost:7777','http://119.130.113.245:7777'],
   //YQL: ['http://localhost:57251'],
@@ -56,4 +56,4 @@ module.exports =  {
     permissions:`${APIV3Auth}/ums/oauth2/list/permission?types=2`,
   },
   JAPIV, 
-}
+}