| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <view class="form_item">
- <view class="form_item_key font-bold" :class="{ 'require': required }">{{ label }}</view>
- <view class="form_item_val" @click="onClick">
- <input
- class="input"
- type="text"
- :disabled="true"
- :placeholder="placeholder"
- :value="value"
- />
- <view class="arrow"></view>
- </view>
- </view>
- </template>
- <script setup lang="ts">
- import { defineProps, defineEmits, watch } from 'vue';
- const props = defineProps({
- label: {
- type: String,
- default: ''
- },
- readOnly: {
- type: Boolean,
- default: false,
- },
- placeholder: {
- type: String,
- default: ''
- },
- required: {
- type: Boolean,
- default: false
- },
- errorMsg: {
- type: String,
- default: '输入不合法'
- },
- value: {
- type: String,
- default: ''
- }
- });
- const emit = defineEmits(['actionClick', 'validateRequest']);
- const onClick = () => {
- if (props.readOnly) {
- return;
- }
- emit('actionClick', { value: props.value });
- };
- const validateInput = (value: string) => {
- emit('validateRequest', { value });
- };
- watch(() => props.value, (newVal) => {
- validateInput(newVal);
- });
- </script>
- <style>
- /* 表单 start */
- .form_item {
- position: relative;
- width: inherit;
- padding: 0 10upx;
- font-size: 30upx;
- height: 120upx;
- display: flex;
- align-items: center;
- }
- .form_item .form_item_key {
- padding-left: 20upx;
- position: relative;
- width: 220upx;
- }
- .form_item .form_item_val {
- flex: 1 0 0;
- text-align: right;
- height: inherit;
- padding: 0 20upx;
- }
- .form_item .form_item_val .input {
- height: inherit;
- }
- .img_captcha {
- width: 160upx;
- height: inherit;
- background-color: var(--dominantColor);
- color: #fff;
- font-weight: bold;
- font-size: 38upx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .require::after {
- content: '*';
- position: absolute;
- color: #FF1D1F;
- top: 10%;
- left: 0;
- }
- /* 表单 end */
- .font-bold {
- font-weight: bold;
- }
- .arrow {
- content: "";
- position: absolute;
- top: 50%;
- right: 12upx;
- display: block;
- width: 18upx;
- height: 18upx;
- border-top: 4upx solid #e0e0e0;
- border-right: 4upx solid #e0e0e0;
- transform: rotate(45deg) translateY(-50%);
- }
- </style>
|