wzj-vue/src/views/system/client/SecretInput.vue
2024-08-13 20:32:37 +08:00

42 lines
895 B
Vue

<template>
<el-input v-model="secret" :disabled="disabled" placeholder="请输入密钥或随机生成">
<template v-if="!disabled" #append>
<el-button id="refresh-secret" type="primary" @click="refreshSecret">随机生成</el-button>
</template>
</el-input>
</template>
<script setup lang="ts">
import { buildUUID } from '@/utils/uuid';
const secret = defineModel('secret', {
type: String,
required: true
});
defineProps({
disabled: {
type: Boolean,
default: false
}
});
function refreshSecret() {
secret.value = buildUUID();
}
/**
* 万一要在每次新增时打开Drawer刷新
* 需要调用实例方法
*/
defineExpose({ refreshSecret });
</script>
<style lang="scss" scoped>
:deep(.el-input-group__append button.el-button) {
background-color: var(--el-button-bg-color);
border-color: var(--el-button-bg-color);
color: initial;
}
</style>