ソースを参照

调整开放平台

XW 4 年 前
コミット
f9c4289abf

+ 7 - 0
TEAMModelOS/ClientApp/src/api/openMgmt.js

@@ -43,5 +43,12 @@ export default{
      */
     delOpen: function (data) {
         return post('/open-api/delete-app', data)
+    },
+    /**
+     * 获取订阅通知
+     * @param {} data
+     */
+     getWebhook: function (data) {
+        return post('/open-api/get-webhook', data)
     }
 }

+ 2 - 1
TEAMModelOS/ClientApp/src/locale/lang/zh-CN/settings.js

@@ -56,7 +56,8 @@ export default {
 	openStatus: '状态',
 	enable: '启用',
 	disable: '禁用',
-	webhook: "webhook",
+	webhook: "webhook配置",
+	authorization: "Token(authorization)",
 	domainName: "域名",
 	subNews: "订阅通知",
 	apiType1: "数据写入接口",

+ 4 - 57
TEAMModelOS/ClientApp/src/view/settings/OpenMgmt2.css

@@ -59,19 +59,9 @@
 .open-mgmt .open-mgmt-right .open-right-info .open-info {
   width: 30%;
   font-size: 16px;
-  /* .ivu-input{
-                    font-size: 16px;
-                    color: #525B6F;
-                }
-                .ivu-radio-wrapper{
-                    color: #525B6F;
-                } */
 }
 .open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info {
   padding: 20px 20px 0 20px;
-  /* .ivu-radio-inner{
-                        background-color: #F3F3F3;
-                    } */
 }
 .open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info + p {
   color: #949494;
@@ -81,19 +71,6 @@
   border-top: 1px solid #424242;
   border-bottom: 1px solid #424242;
 }
-.open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info .ivu-checkbox {
-  margin-right: 0;
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info .ivu-checkbox-wrapper {
-  margin-left: 0;
-  margin-right: 30px;
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-info .ivu-form-item:not(:first-child) {
-  margin-top: 30px;
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-info .ivu-form-item:last-child {
-  margin-bottom: 70px;
-}
 .open-mgmt .open-mgmt-right .open-right-info .open-info .api-token {
   position: relative;
 }
@@ -102,48 +79,18 @@
   top: -33px;
   right: 0;
 }
-.open-mgmt .open-mgmt-right .open-right-info .open-info .open-info-disabled .ivu-input {
-  background: transparent;
-  border: none;
-  box-shadow: none;
-  font-size: 16px;
-  font-weight: 500;
-}
 .open-mgmt .open-mgmt-right .open-right-info .open-api {
   width: 70%;
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav {
-  color: #a5a5a5;
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav .ivu-tabs-ink-bar {
-  border-bottom: 2px solid #1cc0f3;
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav .ivu-tabs-tab-active {
-  font-size: 14px;
-  color: #fff;
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav .ivu-tabs-tab:hover {
-  color: #fff;
+  /* .ivu-checkbox-wrapper {
+                    margin-left: 0;
+                    margin-top: 0;
+                } */
 }
 .open-mgmt .open-mgmt-right .open-right-info .open-api .open-api-header {
   height: 40px;
 }
-.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-tab {
-  height: 40px;
-}
 .open-mgmt .open-mgmt-right .open-right-info .open-api .open-api-table {
   padding: 20px;
-  /* .ivu-table-wrapper{
-                        box-shadow: 0px 0px 10px 2px #ccc;
-                    }
-
-                    .ivu-checkbox-inner{
-                        background-color: white;
-                    } */
-}
-.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-checkbox-wrapper {
-  margin-left: 0;
-  margin-top: 0;
 }
 .open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-page {
   float: right;

+ 2 - 71
TEAMModelOS/ClientApp/src/view/settings/OpenMgmt2.less

@@ -87,26 +87,6 @@
                         border-top: 1px solid #424242;
                         border-bottom: 1px solid #424242;
                     }
-
-                    .ivu-checkbox{
-                        margin-right: 0;
-                    }
-
-                    .ivu-checkbox-wrapper{
-                        margin-left: 0;
-                        margin-right: 30px;
-                    }
-
-                    /* .ivu-radio-inner{
-                        background-color: #F3F3F3;
-                    } */
-                }
-      
-                .ivu-form-item:not(:first-child){
-                    margin-top: 30px;
-                }
-                .ivu-form-item:last-child{
-                    margin-bottom: 70px;
                 }
 
                 .api-token{
@@ -118,73 +98,24 @@
 
                     }
                 }
-
-                /* .ivu-input{
-                    font-size: 16px;
-                    color: #525B6F;
-                }
-                .ivu-radio-wrapper{
-                    color: #525B6F;
-                } */
-
-                .open-info-disabled{
-                    .ivu-input{
-                        background: transparent;
-                        border: none;
-                        box-shadow: none;
-                        font-size: 16px;
-                        // color: #1e1f21;
-                        font-weight: 500;
-                    }
-                }
-
                 
             }
             
             .open-api{
                 width: 70%;
 
-                .ivu-tabs-nav{
-                    color: #a5a5a5;
-
-                    .ivu-tabs-ink-bar{
-                        border-bottom: 2px solid #1cc0f3;
-                    }
-
-                    .ivu-tabs-tab-active{
-                        font-size: 14px;
-                        color: #fff;
-                    }
-
-                    .ivu-tabs-tab:hover{
-                        color: #fff;
-                    }
-                }
-
                 .open-api-header{
                     height: 40px;
                 }
 
-                .ivu-tabs-tab{
-                    height: 40px;
-                }
-
                 .open-api-table{
                     padding: 20px;
-
-                    /* .ivu-table-wrapper{
-                        box-shadow: 0px 0px 10px 2px #ccc;
-                    }
-
-                    .ivu-checkbox-inner{
-                        background-color: white;
-                    } */
                 }
 
-                .ivu-checkbox-wrapper {
+                /* .ivu-checkbox-wrapper {
                     margin-left: 0;
                     margin-top: 0;
-                }
+                } */
 
                 .ivu-page{
                     float: right;

+ 180 - 65
TEAMModelOS/ClientApp/src/view/settings/OpenMgmt2.vue

@@ -7,9 +7,9 @@
                 <span>{{ $t("settings.openList") }}</span>
                 <div class="open-action">
                     <!-- <Icon type="md-add" size="18" style="margin-right: 10px" color="rgb(115 115 115)" @click="editOpen(true, true)" /> -->
-                    <Icon type="md-add" size="18" style="margin-right: 10px" color="#0094FF" @click="editOpen(true, true)" />
+                    <Icon type="md-add" title="新增" size="18" style="margin-right: 10px" color="#FFF" @click="editOpen(true, true)" />
                     
-                    <Icon type="md-trash" size="18" color="#0094FF" @click="delOpen" />
+                    <Icon type="md-trash" title="删除" size="18" color="#FFF" @click="delOpen" />
                 </div>
             </div>
             <vuescroll>
@@ -30,17 +30,17 @@
                 <span>{{ $t("settings.openInfo") }}</span>
                 <div class="open-action" @click="editOpen(true, false)" v-show="!isEdit">
                     <div>
-                        <Icon type="ios-create" size="18" color="#0094FF" />
+                        <Icon type="ios-create" size="18" color="#FFF" />
                         <span>{{ $t("settings.edit") }}</span>
                     </div>
                 </div>
                 <div class="open-action" v-show="isEdit">
                     <div @click="keepMgmt(true)">
-                        <Icon type="md-checkmark-circle" size="18" color="#0094FF" />
+                        <Icon type="md-checkmark-circle" size="18" color="#FFF" />
                         <span>{{ $t("settings.openKeep") }}</span>
                     </div>
                     <div @click="keepMgmt(false)">
-                        <Icon type="md-close-circle" size="18" color="#DDDDDD" />
+                        <Icon type="md-close-circle" size="18" color="rgb(115, 115, 115)" />
                         <span>{{ $t("settings.unedit") }}</span>
                     </div>
                 </div>
@@ -48,7 +48,7 @@
             <div class="open-right-info">
                 <div class="open-info">
                     <vuescroll>
-                        <div class=" dark-iview-form disabled-iview-input">
+                        <div class=" dark-iview-form">
                             <!-- <div class="open-mgmt-info"> -->
                                 <Form :model="openMgInfo" label-position="top">
                                     <div class="open-mgmt-info">
@@ -60,11 +60,11 @@
                                         <FormItem :label="$t('settings.token')" class="api-token" v-show="!isEdit">
                                             <div class="api-icon">
                                                 <!-- 隐藏 -->
-                                                <Icon :type="isTokenShow ? 'md-eye' : 'md-eye-off'" size="18" style="margin-right: 10px" color="rgb(115 115 115)" @click="isTokenShow = !isTokenShow" />
+                                                <Icon :type="isTokenShow ? 'md-eye' : 'md-eye-off'" :title="isTokenShow ? '隐藏' : '显示'" size="18" style="margin-right: 10px" color="#FFF" @click="isTokenShow = !isTokenShow" />
                                                 <!-- 刷新 -->
-                                                <Icon type="md-refresh" size="18" style="margin-right: 10px" color="rgb(115 115 115)" @click="refresh" />
+                                                <Icon type="md-refresh" title="刷新" v-show="isTokenShow" size="18" style="margin-right: 10px" color="#FFF" @click="refresh" />
                                                 <!-- 复制 -->
-                                                <Icon type="ios-copy" size="18" color="rgb(115 115 115)" @click="copyToken" />
+                                                <Icon type="ios-copy" title="复制" v-show="isTokenShow" size="18" color="#FFF" @click="copyToken" />
                                             </div>
                                             <Input
                                                 v-model="openMgInfo.token"
@@ -96,19 +96,21 @@
                                                 :class="isEdit ? '' : 'open-info-disabled'"
                                                 :readonly="isEdit ? false : true"></Input>
                                         </FormItem>
+                                        <FormItem :label="$t('settings.authorization')">
+                                            <Input v-model="openMgInfo.webhookToken"
+                                                type="textarea"
+                                                :autosize="{ minRows: 2 }"
+                                                :class="isEdit ? '' : 'open-info-disabled'"
+                                                :readonly="isEdit ? false : true"></Input>
+                                        </FormItem>
                                         <FormItem :label="$t('settings.subNews')">
-                                            <CheckboxGroup v-model="openMgInfo.news">
-                                                <Checkbox label="hhhh" :disabled="isEdit ? false : true">
-                                                    <span>订阅通知1</span>
-                                                </Checkbox>
-                                                <Checkbox label="www" :disabled="isEdit ? false : true">
-                                                    <span>订阅通知2</span>
-                                                </Checkbox>
-                                                <Checkbox label="mmm" :disabled="isEdit ? false : true">
-                                                    <span>订阅通知3</span>
-                                                </Checkbox>
-                                                <Checkbox label="wwwww" :disabled="isEdit ? false : true">
-                                                    <span>订阅通知4</span>
+                                            <CheckboxGroup v-model="openMgInfo.webhooks">
+                                                <Checkbox v-for="(item, index) in webhook"
+                                                          :label="item.auth"
+                                                          :disabled="isEdit ? false : true"
+                                                          :key="index"
+                                                >
+                                                    <span>{{ item.name}}</span>
                                                 </Checkbox>
                                             </CheckboxGroup>
                                         </FormItem>
@@ -120,39 +122,14 @@
                 </div>
                 <div class="open-api dark-iview-table dark-iview-page dark-iview-tabs-card">
                 <!-- <div class="open-api"> -->
-                    <!-- <vuescroll> -->
-                        <!-- <div class="open-api-table">
-                            <p>数据写入接口</p>
-                            <Table ref="selection"
-                                   :loading="isLoadList"
-                                   :columns="apiListCol"
-                                   :data="isEdit ? apiListSelect : apiListNow"
-                                   @on-selection-change="selectionChange"
-                            ></Table>
-                            <Page :total="pageTotal" :page-size-opts="pageSizeOpts" size="small" show-sizer show-total />
-                        </div> -->
-                    <!-- </vuescroll> -->
-                    <!-- <vuescroll> -->
-                        <!-- <div class="open-api-table">
-                            <p>数据读取接口</p>
-                            <Table ref="selection"
-                                   :loading="isLoadList"
-                                   :columns="apiListCol"
-                                   :data="isEdit ? apiListSelect : apiListNow"
-                                   @on-selection-change="selectionChange"
-                            ></Table>
-                            <Page :total="pageTotal" :page-size-opts="pageSizeOpts" size="small" show-sizer show-total />
-                        </div> -->
-                    <!-- </vuescroll> -->
-
                     <Tabs value="1">
                         <TabPane :label="$t('settings.apiType1')" name="1">
                             <div class="open-api-table">
                                 <Table ref="selection"
                                        :loading="isLoadList"
                                        :columns="apiListCol"
-                                       :data="isEdit ? apiListSelect : apiListNow"
-                                       @on-selection-change="selectionChange"
+                                       :data="isEdit ? apiListW : apiListSelW"
+                                       @on-selection-change="selectionChange1"
                                 >
                                     <template slot-scope="{ row }" slot="name">
                                         <span>{{ row.name }}</span>
@@ -169,13 +146,12 @@
                                 <Table ref="selection"
                                        :loading="isLoadList"
                                        :columns="apiListCol"
-                                       :data="isEdit ? apiListSelect : apiListNow"
-                                       @on-selection-change="selectionChange"
+                                       :data="isEdit ? apiListR : apiListSelR"
+                                       @on-selection-change="selectionChange2"
                                 >
                                     <template slot-scope="{ row }" slot="name">
                                         <span>{{ row.name }}</span>
                                         <Poptip trigger="hover" :content="row.descr" placement="right">
-                                            <!-- <Icon type="ios-alert" /> -->
                                             <Icon type="ios-alert-outline" />
                                         </Poptip>
                                     </template>
@@ -220,16 +196,21 @@ export default {
                     title: this.$t("settings.apiMethod"),
                     key: "method",
                 },
-                {
+                /* {
                     title: this.$t("settings.des"),
                     key: "descr",
-                },
+                }, */
             ],
             apiList: [], //api原有列表
-            apiListSelect: [], //api选择列表
-            apiListNow: [], //当前应用已有的api 列表
+            apiListR: [], //读取接口
+            apiListW: [], //写入接口
+            // apiListSelect: [], //api选择列表
+            // apiListNow: [], //当前应用已有的api 列表
+            apiListSelR: [], //已有的读取接口
+            apiListSelW: [], //已有的写入接口
             pageTotal: 0,
             pageSizeOpts:[5, 10, 20, 30, 40],
+            webhook: [],
             nowIndex: 0, //当前下标
             isEdit: false, //编辑状态
             isAdd: false, // 编辑/新增
@@ -238,6 +219,7 @@ export default {
     mounted () {
         this.getOpenList()
         this.getApiList()
+        this.getWebhook()
     },
     methods: {
         // 获取应用列表
@@ -285,23 +267,56 @@ export default {
                     }, 1000)
             })
         },
+        // 获取订阅通知
+        getWebhook() {
+            let reqs = {}
+            this.$api.openMgmt.getWebhook(reqs).then(res => {
+                if(res) {
+                    res.webhooks.sort(function(a, b) {
+                        return a.auth - b.auth
+                    })
+                    this.webhook = res.webhooks
+                }
+            }).catch(err => {})
+        },
         // 筛选出该应用已有的api
         selectApi() {
-            this.apiListNow = []
             let listSel = this._.cloneDeep(this.apiList)
+            let apiNow = []
             if(listSel.length > 0) {
                 if(this.openMgInfo.auths.length > 0) {
                     listSel.map(item => {
                         this.openMgInfo.auths.map(items => {
                             if(item.auth == items) {
-                                this.apiListNow.push({...item})
+                                apiNow.push({...item})
                                 item._checked = true
                             }
                         })
                     })
                 }
             }
-            this.apiListSelect = listSel
+            let listArr = this.screenType(listSel)
+            this.apiListR = listArr.listR
+            this.apiListW = listArr.listW
+            let listSelArr = this.screenType(apiNow)
+            this.apiListSelR = listSelArr.listR
+            this.apiListSelW = listSelArr.listW
+        },
+        // 分出写入和读取接口
+        screenType(arr) {
+            let list = arr
+            let listArr = {
+                listR: [],
+                listW: []
+            }
+            for (let i = 0; i < list.length; i++) {
+                if(list[i].type == "r") {
+                    listArr.listR.push(list[i])
+                } else if(list[i].type == "w") {
+                    listArr.listW.push(list[i])
+                }
+            }
+            return listArr
         },
         // 编辑、新增
         editOpen (isEdit, isAdd) {
@@ -311,7 +326,7 @@ export default {
             } else {
                 this.apiListCol.unshift({
                     type: 'selection',
-                    width: 80,
+                    width: 40,
                     align: 'center',
                 })
                 this.isEdit = isEdit
@@ -329,7 +344,9 @@ export default {
                     this.openList.unshift(defaultInfo)
                     this.openMgInfo = defaultInfo
                     this.nowIndex = 0
-                    this.apiListSelect = this._.cloneDeep(this.apiList)
+                    let listArr = this.screenType(this.apiList)
+                    this.apiListR = listArr.listR
+                    this.apiListW = listArr.listW
                 }
             }
         },
@@ -392,8 +409,9 @@ export default {
             // this.isEdit = type
             if(type) {
                 let auths = []
-                if(this.apiListNow.length > 0) {
-                    this.apiListNow.map(item => {
+                let arr = this.apiListSelR.concat(this.apiListSelW)
+                if(arr.length > 0) {
+                    arr.map(item => {
                         auths.push(item.auth)
                     })
                 }
@@ -410,8 +428,12 @@ export default {
                         name: this.openMgInfo.name,
                         school: this.schoolCode,
                         status: this.openMgInfo.status,
+                        domain: this.openMgInfo.domain,
+                        webhookToken: this.openMgInfo.webhookToken,
+                        webhooks: this.openMgInfo.webhooks
                     }
                 }
+                console.log(req);
                 this.$api.openMgmt.editOpenInfo(req).then(res => {
                         if (res) {
                             console.log(res.app);
@@ -483,9 +505,13 @@ export default {
                 );
             }
         },
-        selectionChange(selection) {
-            this.apiListNow = selection
-            console.log(selection);
+        // 写入接口
+        selectionChange1(selection) {
+            this.apiListSelW = selection
+        },
+        // 读取接口
+        selectionChange2(selection) {
+            this.apiListSelR = selection
         },
         selectMenu(name) {
             console.log(name);
@@ -497,4 +523,93 @@ export default {
 
 <style lang="less">
     @import "./OpenMgmt2.less";
+</style>
+
+<style lang="less">
+.open-mgmt{
+
+    .ivu-form-item:not(:first-child){
+        margin-top: 30px;
+    }
+    .ivu-form-item:last-child{
+        margin-bottom: 70px;
+    }
+    .ivu-radio-inner, .ivu-checkbox-inner {
+        width: 18px;
+        height: 18px;
+        border-radius: 4px;
+        background-color: #0f0f0f;
+        border-color: #4d4d4d;
+        border-width: 1px;
+        margin-right: 5px;
+    }
+    .ivu-radio-inner::after,
+    .ivu-checkbox-checked .ivu-checkbox-inner::after {
+        content: "";
+        display: block;
+        width: 10px;
+        height: 16px;
+        border-right: #ffffff solid 3px;
+        border-bottom: #ffffff solid 3px;
+        transform: rotate(35deg);
+        position: absolute;
+        top: -4px;
+        left: 4px;
+        border-radius: 0;
+        background-color: transparent;
+        border-color: #0094ff;
+    }
+
+    .ivu-checkbox-disabled .ivu-checkbox-inner{
+        background-color: #0f0f0f;
+        border-color: #4d4d4d;
+    }
+
+    .ivu-radio-wrapper,
+    .ivu-checkbox-wrapper{
+        color: #a5a5a5;
+    }
+
+    .ivu-checkbox{
+        margin-right: 0;
+    }
+
+    .ivu-checkbox-wrapper{
+        margin-left: 0;
+        margin-right: 30px;
+    }
+
+    .open-info-disabled{
+        .ivu-input{
+            background: transparent;
+            border: none;
+            box-shadow: none;
+            font-size: 16px;
+            // color: #1e1f21;
+            font-weight: 500;
+        }
+    }
+
+    .ivu-tabs-nav{
+        color: #a5a5a5;
+
+        .ivu-tabs-tab{
+            height: 40px;
+        }
+
+        .ivu-tabs-ink-bar{
+            border-bottom: 2px solid #1cc0f3;
+        }
+
+        .ivu-tabs-tab-active{
+            font-size: 14px;
+            color: #fff;
+        }
+
+        .ivu-tabs-tab:hover{
+            color: #fff;
+        }
+    }
+    
+}
 </style>