88 <el-form label-position =" top" ref =" displayFormRef" :model =" form" >
99 <el-form-item >
1010 <el-space direction =" vertical" alignment =" start" >
11- <el-checkbox v-model =" form.show_source" label =" 显示知识来源" />
1211 <el-checkbox
13- v-model =" form.show_history"
14- label =" 显示历史记录"
15- v-if =" user.isEnterprise()"
16- />
17- <el-checkbox
18- v-model =" form.draggable"
19- label =" 可拖拽位置(浮窗模式)"
20- v-if =" user.isEnterprise()"
21- />
22- <el-checkbox
23- v-model =" form.show_guide"
24- label =" 显示引导图(浮窗模式)"
25- v-if =" user.isEnterprise()"
12+ v-model =" form.show_source"
13+ :label =" isWorkFlow(detail.type) ? '显示执行详情' : '显示知识来源'"
2614 />
2715 </el-space >
2816 </el-form-item >
29- <el-form-item label =" 对话头像" v-if =" user.isEnterprise()" >
30- <div class =" flex mt-8" >
31- <div class =" border border-r-4 mr-16" style =" padding : 8px " >
32- <el-image
33- v-if =" imgUrl.avatar"
34- :src =" imgUrl.avatar"
35- alt =" "
36- fit =" cover"
37- style =" width : 50px ; height : 50px ; display : block "
38- />
39- <LogoIcon v-else height =" 50px" style =" width : 50px ; height : 50px ; display : block " />
40- </div >
41-
42- <el-upload
43- ref =" uploadRef"
44- action =" #"
45- :auto-upload =" false"
46- :show-file-list =" false"
47- accept =" image/jpeg, image/png, image/gif"
48- :on-change =" (file: any, fileList: any) => onChange(file, fileList, 'avatar')"
49- >
50- <el-button icon =" Upload" >{{
51- $t('views.applicationOverview.appInfo.EditAvatarDialog.upload')
52- }}</el-button >
53- <template #tip >
54- <div class =" el-upload__tip info" style =" margin-top : 0 " >
55- 建议尺寸 32*32,支持 JPG、PNG、GIF,大小不超过 10 MB
56- </div >
57- </template >
58- </el-upload >
59- </div >
60- </el-form-item >
61- <el-form-item label =" 浮窗入口图标" v-if =" user.isEnterprise()" >
62- <div class =" flex mt-8" >
63- <div class =" border border-r-4 mr-16" style =" padding : 8px " >
64- <el-image
65- v-if =" imgUrl.float_icon"
66- :src =" imgUrl.float_icon"
67- alt =" "
68- fit =" cover"
69- style =" width : 50px ; height : 50px ; display : block "
70- />
71- <img
72- v-else
73- src =" @/assets/logo/logo.svg"
74- height =" 50px"
75- style =" width : 50px ; height : 50px ; display : block "
76- />
77- </div >
78-
79- <el-upload
80- ref =" uploadRef"
81- action =" #"
82- :auto-upload =" false"
83- :show-file-list =" false"
84- accept =" image/jpeg, image/png, image/gif"
85- :on-change =" (file: any, fileList: any) => onChange(file, fileList, 'float_icon')"
86- >
87- <el-button icon =" Upload" >{{
88- $t('views.applicationOverview.appInfo.EditAvatarDialog.upload')
89- }}</el-button >
90- <template #tip >
91- <div class =" el-upload__tip info" style =" margin-top : 0 " >
92- 建议尺寸 32*32,支持 JPG、PNG、GIF,大小不超过 10 MB
93- </div >
94- </template >
95- </el-upload >
96- </div >
97- </el-form-item >
9817 </el-form >
9918 <template #footer >
10019 <span class =" dialog-footer" >
101- <el-button v-if =" user.isEnterprise()" type =" primary" @click.prevent =" resetForm" link
102- >恢复默认
103- </el-button >
10420 <el-button @click.prevent =" dialogVisible = false"
10521 >{{ $t('views.applicationOverview.appInfo.LimitDialog.cancelButtonText') }}
10622 </el-button >
@@ -116,11 +32,9 @@ import { ref, watch } from 'vue'
11632import { useRoute } from ' vue-router'
11733import type { FormInstance , FormRules , UploadFiles } from ' element-plus'
11834import applicationApi from ' @/api/application'
119- import applicationXpackApi from ' @/api /application-xpack '
35+ import { isWorkFlow } from ' @/utils /application'
12036import { MsgSuccess , MsgError } from ' @/utils/message'
12137import { t } from ' @/locales'
122- import useStore from ' @/stores'
123- const { user } = useStore ()
12438
12539const route = useRoute ()
12640const {
@@ -129,33 +43,13 @@ const {
12943
13044const emit = defineEmits ([' refresh' ])
13145
132- const defaultSetting = {
133- show_source: false ,
134- show_history: true ,
135- draggable: true ,
136- show_guide: true ,
137- avatar: ' ' ,
138- float_icon: ' '
139- }
14046
14147const displayFormRef = ref ()
14248const form = ref <any >({
14349 show_source: false
14450})
14551
146- const xpackForm = ref <any >({
147- show_source: false ,
148- show_history: false ,
149- draggable: false ,
150- show_guide: false ,
151- avatar: ' ' ,
152- float_icon: ' '
153- })
154-
155- const imgUrl = ref <any >({
156- avatar: ' ' ,
157- float_icon: ' '
158- })
52+ const detail = ref <any >(null )
15953
16054const dialogVisible = ref <boolean >(false )
16155const loading = ref (false )
@@ -165,50 +59,12 @@ watch(dialogVisible, (bool) => {
16559 form .value = {
16660 show_source: false
16761 }
168- imgUrl .value = {
169- avatar: ' ' ,
170- float_icon: ' '
171- }
17262 }
17363})
17464
175- function resetForm() {
176- form .value = {
177- ... defaultSetting
178- }
179- imgUrl .value = {
180- avatar: ' ' ,
181- float_icon: ' '
182- }
183- }
184-
185- const onChange = (file : any , fileList : UploadFiles , attr : string ) => {
186- // 1、判断文件大小是否合法,文件限制不能大于 10 MB
187- const isLimit = file ?.size / 1024 / 1024 < 10
188- if (! isLimit ) {
189- // @ts-ignore
190- MsgError (t (' views.applicationOverview.appInfo.EditAvatarDialog.fileSizeExceeded' ))
191- return false
192- } else {
193- xpackForm .value [attr ] = file .raw
194- imgUrl .value [attr ] = URL .createObjectURL (file .raw )
195- }
196- }
197-
198- const open = (data : any ) => {
199- if (user .isEnterprise ()) {
200- xpackForm .value .show_source = data .show_source
201- xpackForm .value .show_history = data .show_history
202- xpackForm .value .draggable = data .draggable
203- xpackForm .value .show_guide = data .show_guide
204- xpackForm .value .avatar = data .avatar
205- xpackForm .value .float_icon = data .float_icon
206- imgUrl .value .avatar = data .avatar
207- imgUrl .value .float_icon = data .float_icon
208- form .value = xpackForm .value
209- } else {
210- form .value .show_source = data .show_source
211- }
65+ const open = (data : any , content : any ) => {
66+ detail .value = content
67+ form .value .show_source = data .show_source
21268
21369 dialogVisible .value = true
21470}
@@ -217,28 +73,15 @@ const submit = async (formEl: FormInstance | undefined) => {
21773 if (! formEl ) return
21874 await formEl .validate ((valid , fields ) => {
21975 if (valid ) {
220- if (user .isEnterprise ()) {
221- let fd = new FormData ()
222- Object .keys (form .value ).map ((item ) => {
223- fd .append (item , form .value [item ])
224- })
225- applicationXpackApi .putAccessToken (id as string , fd , loading ).then ((res ) => {
226- emit (' refresh' )
227- // @ts-ignore
228- MsgSuccess (t (' views.applicationOverview.appInfo.LimitDialog.settingSuccessMessage' ))
229- dialogVisible .value = false
230- })
231- } else {
232- const obj = {
233- show_source: form .value .show_source
234- }
235- applicationApi .putAccessToken (id as string , obj , loading ).then ((res ) => {
236- emit (' refresh' )
237- // @ts-ignore
238- MsgSuccess (t (' views.applicationOverview.appInfo.LimitDialog.settingSuccessMessage' ))
239- dialogVisible .value = false
240- })
76+ const obj = {
77+ show_source: form .value .show_source
24178 }
79+ applicationApi .putAccessToken (id as string , obj , loading ).then ((res ) => {
80+ emit (' refresh' )
81+ // @ts-ignore
82+ MsgSuccess (t (' views.applicationOverview.appInfo.LimitDialog.settingSuccessMessage' ))
83+ dialogVisible .value = false
84+ })
24285 }
24386 })
24487}
0 commit comments