办学质量监测教学评价系统
shenrongliang
2025-06-13 11d86cc6c26bb4f709e407acadf4805c2024e79f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script setup lang="ts">
import { IconifyIcon } from '@vben/icons';
import { buildUUID } from '@vben/utils';
 
import { Input } from 'ant-design-vue';
 
defineOptions({ name: 'SecretInput' });
 
withDefaults(defineProps<{ disabled?: boolean; placeholder?: string }>(), {
  disabled: false,
  placeholder: '请输入密钥或随机生成',
});
 
const value = defineModel<string>('value', {
  required: false,
});
 
function refreshSecret() {
  value.value = buildUUID();
}
 
/**
 * 万一要在每次新增时打开Drawer刷新
 * 需要调用实例方法
 */
defineExpose({ refreshSecret });
</script>
 
<template>
  <Input v-model:value="value" :disabled="disabled" :placeholder="placeholder">
    <template v-if="!disabled" #addonAfter>
      <a-button type="primary" @click="refreshSecret">
        <div class="flex items-center gap-[4px]">
          <IconifyIcon icon="charm:refresh" />
          <span>随机生成</span>
        </div>
      </a-button>
    </template>
  </Input>
</template>
 
<style lang="scss" scoped>
:deep(.ant-input-group-addon) {
  padding: 0;
  border: none;
}
 
:deep(.ant-btn-primary) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
</style>