zhaoxiaoqiang
2021-09-16 dcc61fc4b536f672d36508b6a2717a12ca6cc8cb
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
130
131
132
133
134
135
136
137
138
<!--
 * @Author: 小明丶
 * @Date: 2019-08-19 10:05:10
 * @LastEditors: 小明丶
 * @LastEditTime: 2020-11-09 11:12:38
 * @Description:
 -->
<template>
    <div class="flex-between-g v-cell-box">
        <div class="left flex-start-g">
            <svg v-if="icon" class="icon" aria-hidden="true" style="width:16px;height:16px;">
                <use :xlink:href="'#'+icon"></use>
            </svg>
            <span class="label" :class="[isTitle? 'title' : '']">{{label}}</span>
        </div>
        <div class="right flex-end-g">
            <slot name="v-cell-right">
            <div class="c-text-999-g" v-if="!Show_input">{{calcValue}}</div>
            <input class="input" :class="[readonly ? 'readonly' : '']" :type="type" :maxlength="max" v-if="Show_input"  :disabled="readonly" v-model="calcValue" :placeholder="placeholder">
 
            <svg v-if="isLink" class="icon" aria-hidden="true" style="width:18px;height:18px;fill:#999;">
                <use xlink:href="#iconyou"></use>
            </svg>
            </slot>
        </div>
    </div>
</template>
 
<script>
    export default {
        name: 'v-cell',
        props: {
            max:[String,Number],
            type:{
                type:String,
                default:'text'
            },
            // 左侧文字
            label:String,
            //左侧图标类名
            icon: String,
            //是否展示右侧图标
            isLink: {
                type: Boolean,
                default: false
            },
            // title文字加粗
            isTitle:{
                type: Boolean,
                default: false
            },
            // 是否只读
            readonly: {
                type: Boolean,
                default: false
            },
            // 是否禁用
            disabled:{
                type: Boolean,
                default: false
            },
            Show_input:{
                type:Boolean,
                default: true
            },
            // input 的vmodel
            value:[String, Number],
            placeholder:String,
        },
        computed: {
            calcValue: {
                get() {
                    return this.value;
                },
                set(v) {
                    this.$emit('input', v)
                }
            }
        },
        mounted(){
            
        },
        methods:{
           
        }
    }
</script>
 
<style lang="less" scoped>
    .v-cell-box {
        padding: 16px 12px;
        background-color: @c-bg-fff;
        margin-bottom: 1px;
 
 
 
        &:first-child {
            border-top-left-radius: 3px;
            border-top-right-radius: 3px;
        }
 
        &:last-child {
            border-bottom-left-radius: 3px;
            border-bottom-right-radius: 3px;
            margin-bottom: 0;
        }
 
        .label {
            font-size: @font-16;
            &.title{
                font-weight: bold;
            }
        }
 
        .left {
            .icon {
                margin-right: 8px;
            }
        }
 
        .input {
            border: none;
            outline: none;
            text-align: right;
            color: @c-text-333;
            background: @c-bg-fff;
            &.readonly{
                color: @c-text-999;
            }
            &[disabled]{
                opacity: 1;
                -webkit-opacity:1;
                color: @c-text-999;
                -webkit-text-fill-color:@c-text-999;
            }
        }
    }
</style>