|
@@ -22,15 +22,29 @@
|
|
|
<!-- 分页控件 -->
|
|
|
<cl-pagination />
|
|
|
</cl-row>
|
|
|
- <cl-upsert ref="Upsert"> </cl-upsert>
|
|
|
+ <cl-upsert ref="Upsert">
|
|
|
+ <template #slot-secret="{ scope }">
|
|
|
+ <div v-if="scope.apiSecret">
|
|
|
+ {{ scope.apiSecret
|
|
|
+ }}<el-icon style="cursor: pointer" @click="copyToClipboard(scope.apiSecret)"
|
|
|
+ ><DocumentCopy
|
|
|
+ /></el-icon>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-button size="small" :icon="RefreshRight" @click="createSecret(scope)"
|
|
|
+ >重新生成</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </cl-upsert>
|
|
|
</cl-crud>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" name="pay-merchant" setup>
|
|
|
import { useCrud, useTable, useUpsert, useForm } from '@cool-vue/crud';
|
|
|
import { useCool } from '/@/cool';
|
|
|
-import md5 from 'md5';
|
|
|
-import { ref } from 'vue';
|
|
|
+import { DocumentCopy, RefreshRight } from '@element-plus/icons-vue';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
const { service } = useCool();
|
|
|
|
|
|
// cl-upsert
|
|
@@ -105,7 +119,22 @@ const Upsert = useUpsert({
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+ () => {
|
|
|
+ return {
|
|
|
+ prop: 'apiSecret',
|
|
|
+ label: 'secret',
|
|
|
+ required: true,
|
|
|
+ component: {
|
|
|
+ name: 'slot-secret',
|
|
|
+ props: { disabled: Upsert.value?.mode !== 'add' }
|
|
|
+ },
|
|
|
+ span: 24,
|
|
|
+ hidden(options) {
|
|
|
+ console.log(80, options);
|
|
|
+ return Upsert.value?.mode === 'add';
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'remark',
|
|
|
label: '备注',
|
|
@@ -145,4 +174,21 @@ const Crud = useCrud(
|
|
|
app.refresh();
|
|
|
}
|
|
|
);
|
|
|
+
|
|
|
+const copyToClipboard = async (secret: string) => {
|
|
|
+ try {
|
|
|
+ // 使用 Clipboard API 复制内容
|
|
|
+ await navigator.clipboard.writeText(secret);
|
|
|
+ ElMessage.success('复制成功');
|
|
|
+ } catch (error) {
|
|
|
+ console.error('复制失败', error);
|
|
|
+ ElMessage.error('复制失败');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const createSecret = async (row: any) => {
|
|
|
+ const params = await service.payment.merchant.secret(row);
|
|
|
+ console.log(191, params);
|
|
|
+ row.apiSecret = params.apiSecret;
|
|
|
+};
|
|
|
</script>
|