zhaoxiaoqiang
2022-08-30 496fd3866f44ad362539b316d16e34d03cf169e3
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!--
 * @Author: 小明丶
 * @Date: 2020-05-09 13:38:38
 * @LastEditors: zxq
 * @LastEditTime: 2022-08-30 16:45:16
 * @Description: cell框组件
 -->
<template>
  <div class="flex-between-g v-cell-box" @click.stop="_click">
    <div class="left flex-start-g">
      <svg v-if="icon" class="icon" aria-hidden="true" style="width:16px;height:16px;">
        <use :xlink:href="'#'+icon" />
      </svg>
      <span style="color:red" v-show="isMust">*</span>
      <span class="label" :class="[isTitle? 'title' : '']">{{label}}</span>
    </div>
    <div class="right flex-end-g">
      <!-- <template 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"
          @blur.stop="_blur"
          :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="#iconright" />
        </svg>
      <!-- </template> -->
      <slot name="button">
        
      </slot>
    </div>
  </div>
</template>
 
<script>
export default {
  name: "h-cell",
  props: {
    max: [String, Number],
    type: {
      type: String,
      default: "text"
    },
    // 左侧文字
    label: String,
    //左侧图标类名
    icon: String,
    isMust:{
      type: Boolean,
      default: false
    },
    //是否展示右侧图标
    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);
      }
    }
  },
  methods:{
    _click(){
      this.$emit('click')
    },
    _blur(){
      this.$emit('blur'); 
    }
  }
};
</script>
 
<style lang="less" scoped>
.v-cell-box {
  padding: 16px 0;
  background-color: @c-bg-fff;
  margin-bottom: 1px;
  border-bottom:1px solid #f1f1f1;
  &: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-14;
    font-weight:500;
    color:rgba(101,101,101,1);
    &.title {
      font-weight: 500;
    }
  }
 
  .left {
    .icon {
      margin-right: 8px;
    }
  }
 
  .right{
    width: 60%;
  }
 
  .input {
    border: none;
    outline: none;
    width: 100%;
    text-align: right;
    color: @c-text-333;
    background: @c-bg-fff;
    &.readonly {
      color:#999999;
    }
    &[disabled] {
      opacity: 1;
      -webkit-opacity: 1;
      color: #999999;
      -webkit-text-fill-color: #999999;
    }
  }
  input::-webkit-input-placeholder {
    color: #999999;
  }
 
  input::-moz-placeholder {
    /* Mozilla Firefox 19+ */
    color: #999999;
  }
 
  input:-moz-placeholder {
    /* Mozilla Firefox 4 to 18 */
    color: #999999;
  }
 
  input:-ms-input-placeholder {
    /* Internet Explorer 10-11 */
    color: #999999;
  }
  input:-internal-autofill-previewed,
  input:-internal-autofill-selected {
    -webkit-text-fill-color: #333;
    transition: background-color 5000s ease-out 0.5s;
  }
}
</style>