初始化
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<!-- label 为字段名 -->
|
||||
<!-- isSelectAuto 默认为true false只选择年月日 -->
|
||||
<!-- isBorder 是否有边框 默认 true有-->
|
||||
<template>
|
||||
<view class="input-box" :class="isBorder ? '' : 'border-none'">
|
||||
<view class="label"><text>*</text> {{label}}</view>
|
||||
<view @click="onClickDate" class="date-box">
|
||||
<view v-if="value" class="time">{{value}}</view>
|
||||
<view v-else class="time placeholder">请选择{{label}}</view>
|
||||
<image src="../../static/jiantou.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { watch } from "vue";
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
default: ''
|
||||
},
|
||||
isSelectAuto: {
|
||||
default: true
|
||||
},
|
||||
isBorder: {
|
||||
default: true
|
||||
},
|
||||
label:{
|
||||
default: '时间'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
sea: ''
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 点击选择日期
|
||||
onClickDate () {
|
||||
let formtStr = 'yyyy-MM-dd HH:mm'
|
||||
this.isSelectAuto ? formtStr = 'yyyy-MM-dd HH:mm' : formtStr = 'HH:mm:ss'
|
||||
let date = new Date()
|
||||
uni.datePicker({
|
||||
format: formtStr,
|
||||
currentDate: this.value ? this.value : (date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()),
|
||||
success: (res) => {
|
||||
this.$emit('input', res.date)
|
||||
},
|
||||
});
|
||||
},
|
||||
onClickInput(e) {
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.input-box{
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
background: #fff;
|
||||
padding: 0 16rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
border-bottom: 2rpx dashed #D9D9D9;
|
||||
.label{
|
||||
width: 200rpx;
|
||||
line-height: 40rpx;
|
||||
display: flex;
|
||||
text{
|
||||
display: block;
|
||||
width: 14rpx;
|
||||
color: #E14343;
|
||||
margin-right: 8rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
}
|
||||
.date-box{
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
image{
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-left: 4rpx;
|
||||
}
|
||||
.placeholder{
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
.border-none{
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,99 @@
|
||||
<!-- label 为字段名 -->
|
||||
<!-- type 为输入框类型 默认text
|
||||
maxlength 为长度默认不限
|
||||
<!-- isBorder 是否有边框 默认 true有-->
|
||||
-->
|
||||
<template>
|
||||
<view class="input-box" :class="isBorder ? '' : 'border-none'">
|
||||
<view class="label"> <text>*</text> {{ label }}</view>
|
||||
<input :type="text" :value="sea" @input="onClickInput" :placeholder="'请输入' + label" :maxlength="maxlength" placeholder-style="font-size: 28rpx; color:#999999" >
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { watch } from "vue";
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
default: ''
|
||||
},
|
||||
label: {
|
||||
default: ''
|
||||
},
|
||||
type: {
|
||||
default: 'text'
|
||||
},
|
||||
maxlength: {
|
||||
default: -1
|
||||
},
|
||||
isBorder: {
|
||||
default: true
|
||||
}
|
||||
|
||||
},
|
||||
name:"input-li",
|
||||
data() {
|
||||
return {
|
||||
sea: ''
|
||||
};
|
||||
},
|
||||
created() {
|
||||
// console.log(this.value)
|
||||
this.sea = this.value
|
||||
},
|
||||
watch: {
|
||||
value: (val) => {
|
||||
// console.log(val)
|
||||
// this.sea = val
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClickInput(e) {
|
||||
this.$emit('input', e.target.value)
|
||||
},
|
||||
onClickName() {
|
||||
this.$emit('click', 'name')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* emits */
|
||||
// const emits = emits(['update:modelValue', 'click'])
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.input-box{
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
background: #fff;
|
||||
padding: 0 16rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
border-bottom: 2rpx dashed #D9D9D9;
|
||||
.label{
|
||||
width: 200rpx;
|
||||
line-height: 40rpx;
|
||||
display: flex;
|
||||
text{
|
||||
display: block;
|
||||
color: #E14343;
|
||||
margin-right: 8rpx;
|
||||
line-height: 40rpx;
|
||||
width: 14rpx;
|
||||
}
|
||||
}
|
||||
input{
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
}
|
||||
.border-none{
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,122 @@
|
||||
<!-- label 为字段名 -->
|
||||
<!-- type 为输入框类型 默认text -->
|
||||
<!-- laebel 为字段名 -->
|
||||
<!-- isBorder 是否有边框 默认 true有-->
|
||||
<template>
|
||||
<view class="select-box" :class="isBorder ? '' : 'border-none'">
|
||||
<view class="label"> <text>*</text> {{ label }}</view>
|
||||
<view class="uni-list-cell-db">
|
||||
<picker @change="bindPickerChange" :value="index" range-key="name" :range="array">
|
||||
<view class="uni-input">
|
||||
<view v-if="index || index == 0" >{{ array[index].name }}</view>
|
||||
<view class="placeholder" v-else >请选择{{label}}</view>
|
||||
<image src="../../static/jiantou.png" ></image>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { watch } from "vue";
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
default: ''
|
||||
},
|
||||
label: {
|
||||
default: ''
|
||||
},
|
||||
array: {
|
||||
default: []
|
||||
},
|
||||
isBorder: {
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
index: null,
|
||||
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
array: function (newArr){
|
||||
newArr.forEach( (item, index) =>{
|
||||
if(item.id == this.value){
|
||||
this.index = index
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.array.forEach( (item, index) =>{
|
||||
if(item.id == this.value){
|
||||
this.index = index
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
bindPickerChange: function(e) {
|
||||
this.index = e.detail.value
|
||||
this.array.forEach( (item, index) =>{
|
||||
if(index == e.detail.value) {
|
||||
this.$emit('input', item.id)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.select-box{
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
background: #fff;
|
||||
padding: 0 16rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
border-bottom: 2rpx dashed #D9D9D9;
|
||||
.label{
|
||||
width: 200rpx;
|
||||
line-height: 40rpx;
|
||||
display: flex;
|
||||
text{
|
||||
display: block;
|
||||
color: #E14343;
|
||||
margin-right: 8rpx;
|
||||
line-height: 40rpx;
|
||||
width: 14rpx;
|
||||
}
|
||||
}
|
||||
.uni-list-cell-db{
|
||||
flex: 1;
|
||||
height: 100rpx;
|
||||
.uni-input{
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
image{
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-left: 4rpx;
|
||||
}
|
||||
.placeholder{
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
.border-none{
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user