iot-ui-app/components/iot-components/number-box/iots-number-box.vue

158 lines
2.9 KiB
Vue

<template>
<view class="iots-component-box">
<view class="attr-item-left">
<view class="iconfont" :class="icon"></view>
<view class="attr-name">{{name}}</view>
<view v-if="logShow" class="iconfont icon-unordered-list" @click="clickLog"></view>
</view>
<view class="attr-item-right">
<text v-if="disabled">{{value}}</text>
<view v-else class="attr-value item-number">
<number-box :integer="integer"
:min="min"
:max="max"
:step="step"
:value="parseFloat(value)"
@changeValue="changeNumber" style="width: 100%;height: 100%;"></number-box>
</view>
<text style="margin-left: 6rpx;font-size: 24rpx;">&nbsp;&nbsp;{{unit}}</text>
</view>
</view>
</template>
<script>
import NumberBox from '@/components/number-box/NumberBox.vue'
export default{
name: 'iots-number-box',
props:{
// 选择值
value: {
type: [ Number,String],
default: 0
},
// 最小值
min:{
type:Number,
default:-99999
},
// 最大值
max:{
type:Number,
default:99999
},
// 是否为整数值
integer: {
type:Boolean,
default:true
},
// 步长
step: {
type:Number,
default:1
},
// 图标处理后
icon: {
type: [String],
default: 'icon-gongnengdingyi'
},
name: {
type: [String],
default: ''
},
logShow:{
type: [Boolean],
default: true
},
disabled:{
type: [Boolean],
default: true
},
unit:{
type: [String],
default: ''
},
},
components:{
NumberBox
},
data(){
return {
}
},
created() {
console.log("this.vlaue",this.value)
},
methods:{
// 点击步进器
changeNumber(e) {
this.$u.debounce(()=>{
this.$emit('input', e);
this.$emit('change',e);
}, 500)
},
clickLog(){
this.$emit('clickLog');
}
}
}
</script>
<style lang="scss" scoped>
@import '../common.css';
.iots-component-box{
padding: 20rpx 20rpx;
background: #fff;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
border-radius: 10rpx;
// .attr-item-left{
// display: flex;
// align-items: center;
// font-size: 28rpx;
// color: #000;
// .iconfont{
// margin-right: 20rpx;
// font-size: 40rpx;
// }
// }
.attr-item-right{
flex: 1;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
.attr-value{
display: flex;
align-items: center;
justify-content: flex-end;
height: 70rpx;
flex: 1;
&.item-number{
flex: 0 1 auto;
width: 250rpx;
display: flex;
align-items: center;
justify-content: flex-end;
color: #ccc;
border: 1px solid #dcdfe6;
border-radius: 8rpx;
/deep/.number-box {
.minus {
border: none;
border-right: 1px solid #dcdfe6;
}
.plus {
border: none;
border-left: 1px solid #dcdfe6;
}
}
}
}
}
}
</style>