11<script setup lang="ts">
2- import { ref } from ' vue' ;
3- const message = useMessage ();
4- const emit = defineEmits <Emits >();
5- const { getServiceAccount, updateServiceAccount } = useAccessKeys ();
2+ import { ref } from " vue"
3+ const message = useMessage ()
4+ const emit = defineEmits <Emits >()
5+ const { getServiceAccount, updateServiceAccount } = useAccessKeys ()
66
7- const visible = ref (false );
7+ const visible = ref (false )
88
99const defaultFormModal = {
10- accesskey: ' ' ,
11- secretkey: ' ' ,
12- name: ' ' ,
13- description: ' ' ,
10+ accesskey: " " ,
11+ secretkey: " " ,
12+ name: " " ,
13+ description: " " ,
1414 expiry: null ,
15- policy: ' ' ,
16- status: ' on ' ,
17- };
18- const formModel = ref ({ ... defaultFormModal });
15+ policy: " " ,
16+ status: " on " ,
17+ }
18+ const formModel = ref ({ ... defaultFormModal })
1919
20- const accessKey = ref <string >(' ' );
20+ const accessKey = ref <string >(" " )
2121async function openDialog(row : any ) {
22- accessKey .value = row .accessKey ;
22+ accessKey .value = row .accessKey
2323
2424 try {
25- const res = await getServiceAccount (row .accessKey );
26- formModel .value = res ;
27- formModel .value .accesskey = row .accessKey ;
28- formModel .value .expiry = res .expiration ;
29- formModel .value .status = res .accountStatus ;
30- visible .value = true ;
25+ const res = await getServiceAccount (row .accessKey )
26+ formModel .value = res
27+ formModel .value .accesskey = row .accessKey
28+ formModel .value .expiry = res .expiration
29+ formModel .value .status = res .accountStatus
30+ visible .value = true
3131 } catch (error ) {
32- message .error (' 获取数据失败' );
32+ message .error (" 获取数据失败" )
3333 }
3434}
3535
36- defineExpose ({ openDialog });
36+ defineExpose ({ openDialog })
3737
3838interface Emits {
39- (e : ' search' ): void ;
39+ (e : " search" ): void
4040}
4141
4242function closeModal() {
43- visible .value = false ;
43+ visible .value = false
4444}
4545
4646function dateDisabled(ts : number ) {
47- const date = new Date (ts );
48- return date < new Date ();
47+ const date = new Date (ts )
48+ return date < new Date ()
4949}
5050
5151async function submitForm() {
5252 try {
5353 const res = await updateServiceAccount (accessKey .value , {
54- ... formModel .value ,
55- policy: formModel .value .policy || ' {}' ,
56- expiry: new Date (formModel .value .expiry || ' ' ).toISOString (),
57- });
58- message .success (' 修改成功' );
59- closeModal ();
60- emit (' search' );
54+ newPolicy: formModel .value .policy || " {}" , // 可选,新策略
55+ newStatus: formModel .value .status , // 可选,新状态
56+ newName: formModel .value .name , // 可选,新名称
57+ newDescription: formModel .value .description , // 可选,新描述
58+ newExpiration: new Date (formModel .value .expiry || " " ).toISOString (), // 可选,新过期时间
59+ })
60+ message .success (" 修改成功" )
61+ closeModal ()
62+ emit (" search" )
6163 } catch (error ) {
62- message .error (' 修改失败' );
64+ message .error (" 修改失败" )
6365 }
6466}
6567 </script >
@@ -78,7 +80,10 @@ async function submitForm() {
7880 <n-card >
7981 <n-form label-placement =" left" :model =" formModel" label-align =" right" :label-width =" 90" >
8082 <n-grid :cols =" 24" :x-gap =" 18" >
81- <n-form-item-grid-item :span =" 24" label =" Access Key" path =" policy" >
83+ <n-form-item-grid-item :span =" 24" label =" Access Key" path =" accesskey" >
84+ <n-input v-model:value =" formModel.accesskey" disabled />
85+ </n-form-item-grid-item >
86+ <n-form-item-grid-item :span =" 24" label =" 策略" path =" policy" >
8287 <json-editor v-model =" formModel.policy" />
8388 </n-form-item-grid-item >
8489 <!-- TODO: 时间格式有问题 -->
0 commit comments