Просмотр исходного кода

终端授权类型改为复选框

RuoYi лет назад: 5
Родитель
Сommit
e2c4ca4922
2 измененных файлов с 27 добавлено и 3 удалено
  1. 21 3
      ruoyi-ui/src/views/system/client/index.vue
  2. 6 0
      sql/ry_20200822.sql

+ 21 - 3
ruoyi-ui/src/views/system/client/index.vue

@@ -54,7 +54,7 @@
54
       <el-table-column label="编号" align="center" prop="clientId" />
54
       <el-table-column label="编号" align="center" prop="clientId" />
55
       <el-table-column label="安全码" align="center" prop="originSecret" :show-overflow-tooltip="true" />
55
       <el-table-column label="安全码" align="center" prop="originSecret" :show-overflow-tooltip="true" />
56
       <el-table-column label="授权范围" align="center" prop="scope" />
56
       <el-table-column label="授权范围" align="center" prop="scope" />
57
-      <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes" :show-overflow-tooltip="true" />
57
+      <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes" :formatter="authorizedGrantTypesFormat" :show-overflow-tooltip="true"/>
58
       <el-table-column label="令牌时效" align="center" prop="accessTokenValidity" />
58
       <el-table-column label="令牌时效" align="center" prop="accessTokenValidity" />
59
       <el-table-column label="刷新时效" align="center" prop="refreshTokenValidity" />
59
       <el-table-column label="刷新时效" align="center" prop="refreshTokenValidity" />
60
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
60
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -98,7 +98,14 @@
98
           <el-input v-model="form.scope" placeholder="请输入授权范围" />
98
           <el-input v-model="form.scope" placeholder="请输入授权范围" />
99
         </el-form-item>
99
         </el-form-item>
100
         <el-form-item label="授权类型" prop="authorizedGrantTypes">
100
         <el-form-item label="授权类型" prop="authorizedGrantTypes">
101
-          <el-input v-model="form.authorizedGrantTypes" placeholder="请输入授权类型" />
101
+          <el-checkbox-group v-model="form.authorizedGrantTypes">
102
+            <el-checkbox
103
+              v-for="dict in authorizedGrantTypesOptions"
104
+              :key="dict.dictValue"
105
+              :label="dict.dictValue">
106
+              {{dict.dictLabel}}
107
+            </el-checkbox>
108
+          </el-checkbox-group>
102
         </el-form-item>
109
         </el-form-item>
103
         <el-form-item label="令牌时效" prop="accessTokenValidity">
110
         <el-form-item label="令牌时效" prop="accessTokenValidity">
104
           <el-input-number v-model="form.accessTokenValidity" controls-position="right" :min="0" />
111
           <el-input-number v-model="form.accessTokenValidity" controls-position="right" :min="0" />
@@ -140,6 +147,8 @@ export default {
140
       title: "",
147
       title: "",
141
       // 是否显示弹出层
148
       // 是否显示弹出层
142
       open: false,
149
       open: false,
150
+      // 终端授权类型字典
151
+      authorizedGrantTypesOptions: [],
143
       // 查询参数
152
       // 查询参数
144
       queryParams: {
153
       queryParams: {
145
         pageNum: 1,
154
         pageNum: 1,
@@ -169,6 +178,9 @@ export default {
169
   },
178
   },
170
   created() {
179
   created() {
171
     this.getList();
180
     this.getList();
181
+    this.getDicts("sys_grant_type").then(response => {
182
+      this.authorizedGrantTypesOptions = response.data;
183
+    });
172
   },
184
   },
173
   methods: {
185
   methods: {
174
     /** 查询终端列表 */
186
     /** 查询终端列表 */
@@ -180,6 +192,10 @@ export default {
180
         this.loading = false;
192
         this.loading = false;
181
       });
193
       });
182
     },
194
     },
195
+    // 终端授权类型字典翻译
196
+    authorizedGrantTypesFormat(row, column) {
197
+      return this.selectDictLabels(this.authorizedGrantTypesOptions, row.authorizedGrantTypes);
198
+    },
183
     // 取消按钮
199
     // 取消按钮
184
     cancel() {
200
     cancel() {
185
       this.open = false;
201
       this.open = false;
@@ -191,7 +207,7 @@ export default {
191
         clientId: undefined,
207
         clientId: undefined,
192
         clientSecret: undefined,
208
         clientSecret: undefined,
193
         scope: "server",
209
         scope: "server",
194
-        authorizedGrantTypes: "password,refresh_token",
210
+        authorizedGrantTypes: [],
195
         accessTokenValidity: 3600,
211
         accessTokenValidity: 3600,
196
         refreshTokenValidity: 7200
212
         refreshTokenValidity: 7200
197
       };
213
       };
@@ -227,6 +243,7 @@ export default {
227
       const clientId = row.clientId || this.ids;
243
       const clientId = row.clientId || this.ids;
228
       getClient(clientId).then(response => {
244
       getClient(clientId).then(response => {
229
         this.form = response.data;
245
         this.form = response.data;
246
+        this.form.authorizedGrantTypes = this.form.authorizedGrantTypes.split(",");
230
         this.open = true;
247
         this.open = true;
231
         this.title = "修改终端";
248
         this.title = "修改终端";
232
       });
249
       });
@@ -235,6 +252,7 @@ export default {
235
     submitForm: function() {
252
     submitForm: function() {
236
       this.$refs["form"].validate(valid => {
253
       this.$refs["form"].validate(valid => {
237
         if (valid) {
254
         if (valid) {
255
+          this.form.authorizedGrantTypes = this.form.authorizedGrantTypes.join(",");
238
           if (!this.isAdd && this.form.clientId != undefined) {
256
           if (!this.isAdd && this.form.clientId != undefined) {
239
             updateClient(this.form).then(response => {
257
             updateClient(this.form).then(response => {
240
               if (response.code === 200) {
258
               if (response.code === 200) {

+ 6 - 0
sql/ry_20200822.sql

@@ -461,6 +461,7 @@ insert into sys_dict_type values(7,  '通知类型', 'sys_notice_type',     '0',
461
 insert into sys_dict_type values(8,  '通知状态', 'sys_notice_status',   '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知状态列表');
461
 insert into sys_dict_type values(8,  '通知状态', 'sys_notice_status',   '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知状态列表');
462
 insert into sys_dict_type values(9,  '操作类型', 'sys_oper_type',       '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作类型列表');
462
 insert into sys_dict_type values(9,  '操作类型', 'sys_oper_type',       '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作类型列表');
463
 insert into sys_dict_type values(10, '系统状态', 'sys_common_status',   '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录状态列表');
463
 insert into sys_dict_type values(10, '系统状态', 'sys_common_status',   '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录状态列表');
464
+insert into sys_dict_type values(11, '授权类型', 'sys_grant_type',      '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '授权类型列表');
464
 
465
 
465
 
466
 
466
 -- ----------------------------
467
 -- ----------------------------
@@ -514,6 +515,11 @@ insert into sys_dict_data values(25, 8,  '生成代码', '8',       'sys_oper_ty
514
 insert into sys_dict_data values(26, 9,  '清空数据', '9',       'sys_oper_type',       '',   'danger',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '清空操作');
515
 insert into sys_dict_data values(26, 9,  '清空数据', '9',       'sys_oper_type',       '',   'danger',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '清空操作');
515
 insert into sys_dict_data values(27, 1,  '成功',     '0',       'sys_common_status',   '',   'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态');
516
 insert into sys_dict_data values(27, 1,  '成功',     '0',       'sys_common_status',   '',   'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态');
516
 insert into sys_dict_data values(28, 2,  '失败',     '1',       'sys_common_status',   '',   'danger',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态');
517
 insert into sys_dict_data values(28, 2,  '失败',     '1',       'sys_common_status',   '',   'danger',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态');
518
+insert into sys_dict_data values(29, 1,  '授权码模式',  'authorization_code',  'sys_grant_type',   '',   '',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '授权码模式');
519
+insert into sys_dict_data values(30, 2,  '密码模式',    'password',            'sys_grant_type',   '',   '',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '密码模式');
520
+insert into sys_dict_data values(31, 3,  '客户端模式',  'client_credentials',  'sys_grant_type',   '',   '',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '客户端模式');
521
+insert into sys_dict_data values(32, 4,  '简化模式',    'implicit',            'sys_grant_type',   '',   '',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '简化模式');
522
+insert into sys_dict_data values(33, 5,  '刷新模式',    'refresh_token',       'sys_grant_type',   '',   '',  'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '刷新模式');
517
 
523
 
518
 
524
 
519
 -- ----------------------------
525
 -- ----------------------------