11<script lang="ts" setup>
2- import { ref , shallowRef } from ' vue'
2+ import { onMounted , provide , reactive , unref } from ' vue'
33import icon_info_outlined_1 from ' @/assets/svg/icon_info_outlined_1.svg'
44import { useI18n } from ' vue-i18n'
5-
5+ import PlatformParam from ' ./xpack/PlatformParam.vue'
6+ import { request } from ' @/utils/request'
7+ import { formatArg } from ' @/utils/utils'
68const { t } = useI18n ()
79
8- const chatSetting = ref ({
9- modelThinkingProcess: false ,
10- rows_of_data: false ,
10+ const state = reactive ({
11+ parameterForm: reactive <any >({
12+ ' chat.enable_model_thinking' : false ,
13+ ' chat.rows_of_data' : false ,
14+ }),
1115})
12-
13- const platform = ref ({
14- organization: false ,
15- modelThinkingProcess: false ,
16- roles: [],
16+ provide (' parameterForm' , state .parameterForm )
17+ const loadData = () => {
18+ request .get (' /system/parameter' ).then ((res : any ) => {
19+ if (res ) {
20+ res .forEach ((item : any ) => {
21+ if (
22+ item .pkey ?.startsWith (' chat' ) ||
23+ item .pkey ?.startsWith (' login' ) ||
24+ item .pkey ?.startsWith (' platform' )
25+ ) {
26+ state .parameterForm [item .pkey ] = formatArg (item .pval )
27+ }
28+ })
29+ console .log (state .parameterForm )
30+ }
31+ })
32+ }
33+ const buildParam = () => {
34+ const changedItemArray = Object .keys (state .parameterForm ).map ((key : string ) => {
35+ return {
36+ pkey: key ,
37+ pval: Object .prototype .hasOwnProperty .call (state .parameterForm , ' key' )
38+ ? state .parameterForm [key ].toString ()
39+ : state .parameterForm [key ],
40+ }
41+ })
42+ const formData = new FormData ()
43+ formData .append (' data' , JSON .stringify (unref (changedItemArray )))
44+ return formData
45+ }
46+ const saveHandler = () => {
47+ const param = buildParam ()
48+ request
49+ .post (' /system/parameter' , param , {
50+ headers: {
51+ ' Content-Type' : ' multipart/form-data' ,
52+ },
53+ })
54+ .then (() => {
55+ ElMessage .success (t (' common.save_success' ))
56+ })
57+ }
58+ onMounted (() => {
59+ loadData ()
1760})
18-
19- const organizations = shallowRef <any []>([])
20- const roles = shallowRef <any []>([])
2161 </script >
2262
2363<template >
@@ -41,7 +81,7 @@ const roles = shallowRef<any[]>([])
4181 </el-tooltip >
4282 </div >
4383 <div class =" value" >
44- <el-switch v-model =" chatSetting.modelThinkingProcess " />
84+ <el-switch v-model =" state.parameterForm['chat.enable_model_thinking'] " />
4585 </div >
4686 </div >
4787
@@ -59,77 +99,15 @@ const roles = shallowRef<any[]>([])
5999 </el-tooltip >
60100 </div >
61101 <div class =" value" >
62- <el-switch v-model =" chatSetting. rows_of_data" />
102+ <el-switch v-model =" state.parameterForm['chat. rows_of_data'] " />
63103 </div >
64104 </div >
65105 </div >
66106
67- <div class =" card" >
68- <div class =" card-title" >
69- {{ t('parameter.third_party_platform_settings') }}
70- </div >
71- <div class =" card-item" style =" width : 100% " >
72- <div class =" label" >
73- {{ t('parameter.by_third_party_platform') }}
74- </div >
75- <div class =" value" >
76- <el-switch v-model =" platform.modelThinkingProcess" />
77- </div >
78- </div >
79- <div class =" card-item" >
80- <div class =" label" >
81- {{ t('parameter.platform_user_organization') }}
82- <span class =" require" ></span >
83- <el-tooltip
84- effect =" dark"
85- :content =" t('parameter.and_platform_integration')"
86- placement =" top"
87- >
88- <el-icon size =" 16" >
89- <icon _info_outlined_1 ></icon _info_outlined_1 >
90- </el-icon >
91- </el-tooltip >
92- </div >
93- <div class =" value" >
94- <el-select filterable v-model =" platform.organization" >
95- <el-option
96- v-for =" item in organizations"
97- :key =" item.value"
98- :label =" item.label"
99- :value =" item.value"
100- />
101- </el-select >
102- </div >
103- </div >
104- <div class =" card-item" style =" margin-left : 16px " >
105- <div class =" label" >
106- {{ t('parameter.platform_user_roles') }}
107- <span class =" require" ></span >
108- <el-tooltip
109- effect =" dark"
110- :content =" t('parameter.and_platform_integration')"
111- placement =" top"
112- >
113- <el-icon size =" 16" >
114- <icon _info_outlined_1 ></icon _info_outlined_1 >
115- </el-icon >
116- </el-tooltip >
117- </div >
118- <div class =" value" >
119- <el-select multiple filterable v-model =" platform.roles" >
120- <el-option
121- v-for =" item in roles"
122- :key =" item.value"
123- :label =" item.label"
124- :value =" item.value"
125- />
126- </el-select >
127- </div >
128- </div >
129- </div >
107+ <platform-param />
130108 </div >
131109 <div class =" save" style =" margin-top : 16px " >
132- <el-button type =" primary" >{{ t('common.save') }}</el-button >
110+ <el-button type =" primary" @click = " saveHandler " >{{ t('common.save') }}</el-button >
133111 </div >
134112 </div >
135113</template >
0 commit comments