From 5f5c4e8415105d29e97f2bb703f8eb13a7e7b72c Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Mon, 31 Aug 2020 17:55:18 +0800
Subject: [PATCH] remove pig

---
 ruoyi-ui/src/views/system/client/index.vue |   39 ++++++++++++++++++++++++++++++---------
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/ruoyi-ui/src/views/system/client/index.vue b/ruoyi-ui/src/views/system/client/index.vue
index e70c352..fea107f 100644
--- a/ruoyi-ui/src/views/system/client/index.vue
+++ b/ruoyi-ui/src/views/system/client/index.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" @submit.native.prevent>
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
       <el-form-item label="终端编号" prop="clientId">
         <el-input
           v-model="queryParams.clientId"
@@ -11,7 +11,7 @@
         />
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
       </el-form-item>
     </el-form>
@@ -46,14 +46,15 @@
           v-hasPermi="['system:client:remove']"
         >删除</el-button>
       </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
     <el-table v-loading="loading" :data="clientList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="编号" align="center" prop="clientId" />
-      <el-table-column label="安全码" align="center" prop="clientSecret" :show-overflow-tooltip="true" />
+      <el-table-column label="安全码" align="center" prop="originSecret" :show-overflow-tooltip="true" />
       <el-table-column label="授权范围" align="center" prop="scope" />
-      <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes" :show-overflow-tooltip="true" />
+      <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes" :formatter="authorizedGrantTypesFormat" :show-overflow-tooltip="true"/>
       <el-table-column label="令牌时效" align="center" prop="accessTokenValidity" />
       <el-table-column label="刷新时效" align="center" prop="refreshTokenValidity" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -90,14 +91,21 @@
         <el-form-item label="编号" prop="clientId">
           <el-input v-model="form.clientId" placeholder="请输入编号" :disabled="!isAdd" />
         </el-form-item>
-        <el-form-item label="安全码" prop="clientSecret">
-          <el-input v-model="form.clientSecret" placeholder="请输入安全码" />
+        <el-form-item label="安全码" prop="originSecret">
+          <el-input v-model="form.originSecret" placeholder="请输入安全码" />
         </el-form-item>
         <el-form-item label="授权范围" prop="scope">
           <el-input v-model="form.scope" placeholder="请输入授权范围" />
         </el-form-item>
         <el-form-item label="授权类型" prop="authorizedGrantTypes">
-          <el-input v-model="form.authorizedGrantTypes" placeholder="请输入授权类型" />
+          <el-checkbox-group v-model="form.authorizedGrantTypes">
+            <el-checkbox
+              v-for="dict in authorizedGrantTypesOptions"
+              :key="dict.dictValue"
+              :label="dict.dictValue">
+              {{dict.dictLabel}}
+            </el-checkbox>
+          </el-checkbox-group>
         </el-form-item>
         <el-form-item label="令牌时效" prop="accessTokenValidity">
           <el-input-number v-model="form.accessTokenValidity" controls-position="right" :min="0" />
@@ -129,6 +137,8 @@
       single: true,
       // 非多个禁用
       multiple: true,
+      // 显示搜索条件
+      showSearch: true,
       // 总条数
       total: 0,
       // 终端表格数据
@@ -137,6 +147,8 @@
       title: "",
       // 是否显示弹出层
       open: false,
+      // 终端授权类型字典
+      authorizedGrantTypesOptions: [],
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -152,7 +164,7 @@
         clientId: [
           { required: true, message: "编号不能为空", trigger: "blur" }
         ],
-        clientSecret: [
+        originSecret: [
           { required: true, message: "安全码不能为空", trigger: "blur" }
         ],
         scope: [
@@ -166,6 +178,9 @@
   },
   created() {
     this.getList();
+    this.getDicts("sys_grant_type").then(response => {
+      this.authorizedGrantTypesOptions = response.data;
+    });
   },
   methods: {
     /** 查询终端列表 */
@@ -176,6 +191,10 @@
         this.total = response.total;
         this.loading = false;
       });
+    },
+    // 终端授权类型字典翻译
+    authorizedGrantTypesFormat(row, column) {
+      return this.selectDictLabels(this.authorizedGrantTypesOptions, row.authorizedGrantTypes);
     },
     // 取消按钮
     cancel() {
@@ -188,7 +207,7 @@
         clientId: undefined,
         clientSecret: undefined,
         scope: "server",
-        authorizedGrantTypes: "password,refresh_token",
+        authorizedGrantTypes: [],
         accessTokenValidity: 3600,
         refreshTokenValidity: 7200
       };
@@ -224,6 +243,7 @@
       const clientId = row.clientId || this.ids;
       getClient(clientId).then(response => {
         this.form = response.data;
+        this.form.authorizedGrantTypes = this.form.authorizedGrantTypes.split(",");
         this.open = true;
         this.title = "修改终端";
       });
@@ -232,6 +252,7 @@
     submitForm: function() {
       this.$refs["form"].validate(valid => {
         if (valid) {
+          this.form.authorizedGrantTypes = this.form.authorizedGrantTypes.join(",");
           if (!this.isAdd && this.form.clientId != undefined) {
             updateClient(this.form).then(response => {
               if (response.code === 200) {

--
Gitblit v1.9.3