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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
<div class="app-preset-input">
<i-input size="default" v-model="curValue" :type="curType" :disabled="disabled" :placeholder="curPlaceHolder"
:password="curType == 'password' && enableShowPwd" @on-blur="valueChange">
</i-input>
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
@Component({})
export default class AppPreSetInput extends Vue {
/**
* 输入值
*
* @type {*}
* @memberof AppPreSetInput
*/
@Prop() public value!: any;
/**
* 名称
*
* @type {string}
* @memberof AppPreSetInput
*/
@Prop() public name!: string;
/**
* 类型
*
* @type {string}
* @memberof AppPreSetInput
*/
@Prop() public type?: string;
/**
* 禁用
*
* @type {boolean}
* @memberof AppPreSetInput
*/
@Prop() public disabled?: boolean;
/**
* 密码框是否启用显示值切换图标
*
* @type {boolean}
* @memberof AppPreSetInput
*/
@Prop({ default: false }) public enableShowPwd!: boolean;
/**
* 占位文本
*
* @type {string}
* @memberof AppPreSetInput
*/
@Prop() public placeholder?: any;
/**
* 当前占位文本
*
* @type {string}
* @memberof AppPreSetInput
*/
get curPlaceHolder() {
if (this.placeholder) {
return this.placeholder;
} else {
if (Object.is(this.type, 'AUTH_USERID')) {
return '请输入登录账号';
} else if (Object.is(this.type, 'AUTH_PASSWORD')) {
return '请输入密码';
} else {
return '';
}
}
}
/**
* 当前类型
*
* @type {string}
* @memberof AppPreSetInput
*/
get curType() {
if (Object.is(this.type, 'AUTH_PASSWORD')) {
return 'password';
} else {
return 'text';
}
}
/**
* 当前值
*
* @memberof AppPreSetInput
*/
public curValue: any;
/**
* 值变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AppPreSetInput
*/
@Watch('value', { immediate: true })
public onValueChange(newVal: any, oldVal: any) {
this.curValue = newVal;
}
/**
* 值变化
*
* @memberof AppPreSetInput
*/
public valueChange() {
this.$emit('valueChange', { name: this.name, value: this.curValue });
}
}
</script>
<style lang='less'>
@import './app-preset-input.less';
</style>