Przeglądaj źródła

feat: api key修改

max 5 miesięcy temu
rodzic
commit
25c7b9c312
1 zmienionych plików z 36 dodań i 5 usunięć
  1. 36 5
      src/modules/payment/views/merchant.vue

+ 36 - 5
src/modules/payment/views/merchant.vue

@@ -23,12 +23,29 @@
 			<cl-pagination />
 		</cl-row>
 		<cl-upsert ref="Upsert">
+			<template #slot-key="{ scope }">
+				<div v-if="scope.apikey">
+					{{ scope.apikey
+					}} <el-icon style="cursor: pointer" @click="copyToClipboard(scope.apiKey)"
+						><document-copy
+					/></el-icon>
+					<el-icon style="cursor: pointer" @click="createSecret(scope)"
+						><refresh-right/></el-icon>
+				</div>
+				<div v-else>
+					<el-button size="small" :icon="RefreshRight" @click="createSecret(scope)"
+						>重新生成</el-button
+					>
+				</div>
+			</template>
 			<template #slot-secret="{ scope }">
 				<div v-if="scope.apiSecret">
 					{{ scope.apiSecret
-					}}<el-icon style="cursor: pointer" @click="copyToClipboard(scope.apiSecret)"
-						><DocumentCopy
+					}} <el-icon style="cursor: pointer" @click="copyToClipboard(scope.apiSecret)"
+						><document-copy
 					/></el-icon>
+					<el-icon style="cursor: pointer" @click="createSecret(scope)"
+						><refresh-right/></el-icon>
 				</div>
 				<div v-else>
 					<el-button size="small" :icon="RefreshRight" @click="createSecret(scope)"
@@ -119,10 +136,25 @@ const Upsert = useUpsert({
 				]
 			}
 		},
+		() => {
+			return {
+				prop: 'apikey',
+				label: 'api key',
+				required: true,
+				component: {
+					name: 'slot-key',
+					props: { disabled: Upsert.value?.mode !== 'add' }
+				},
+				span: 24,
+				hidden(options) {
+					return Upsert.value?.mode === 'add';
+				}
+			};
+		},
 		() => {
 			return {
 				prop: 'apiSecret',
-				label: 'secret',
+				label: 'api secret',
 				required: true,
 				component: {
 					name: 'slot-secret',
@@ -130,7 +162,6 @@ const Upsert = useUpsert({
 				},
 				span: 24,
 				hidden(options) {
-					console.log(80, options);
 					return Upsert.value?.mode === 'add';
 				}
 			};
@@ -188,7 +219,7 @@ const copyToClipboard = async (secret: string) => {
 
 const createSecret = async (row: any) => {
 	const params = await service.payment.merchant.secret(row);
-	console.log(191, params);
+	row.apikey = params.apikey;
 	row.apiSecret = params.apiSecret;
 };
 </script>