he wei
2025-06-06 895129470d7ee48183fc15b9ee18ef0880503e5d
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
<template>
  <div class="change-text">
    <span>{{ showValue }}</span>
    <span v-if="showUnit">{{ unit }}</span>
    <div class="change-text-icon" v-if="!noChange">
      <i class="el-icon-edit" @click="showDialog"></i>
    </div>
    <!-- 电池信息 -->
    <el-dialog
      :title="label+'参数设置'"
      width="auto"
      :visible.sync="paramsSetDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false">
        <div class="params-container">
          <el-form
            ref="ruleForm"
            size="mini"
            label-position="top"
            :model="params"
            :rules="rules"
            class="params-dialog bg-white">
            <el-row :gutter="layout.gutter">
              <el-col :span="layout.span">
                <el-form-item :label="labelStr">
                  <el-input v-model="params.value"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <div class="form-footer">
              <el-button type="primary" size="mini" @click="submitForm">确定</el-button>
              <el-button type="warning" size="mini" @click="close">取消</el-button>
            </div>
          </el-form>
        </div>
    </el-dialog>
  </div>
</template>
 
<script>
export default {
  name: "ChangeText",
  model: {
    name: "value",
    event: "change"
  },
  props: {
    label: {
      type: String,
      default: ""
    },
    showUnit: {
      type: Boolean,
      default: false
    },
    unit: {
      type: String,
      default: ""
    },
    value: {
      type: [String, Number],
      default: ""
    },
    noChange: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      paramsSetDialog: false,
      layout: {
        gutter: 16,
        span: 24,
      },
      params: {
        value: 0,
      },
      rules: {}
    }
  },
  methods: {
    submitForm() {
      this.$emit("change", this.params.value);
      this.paramsSetDialog = false;
    },
    close() {
      this.paramsSetDialog = false;
    },
    showDialog() {
      this.params.value = this.value;
      this.paramsSetDialog = true;
    }
  },
  computed: {
    showValue() {
      return this.value !== ""?this.value:"???";
    },
    labelStr() {
      let unit = this.unit?"("+this.unit+")":"";
      return this.label+unit;
    }
  },
  mounted() {
 
  }
}
</script>
 
<style scoped>
.change-text {
  position: relative;
  display: inline-block;
  width: 100%;
}
.change-text-icon {
  position: absolute;
  top: 0;
  right: 0;
  cursor: pointer;
}
.params-container {
  width: 300px;
  background-color: #ececec;
  text-align: left;
}
.form-footer {
  margin-top: 16px;
  margin-bottom: 16px;
  text-align: right;
}
 
.form-footer .three-btn {
  margin-left: 12px;
}
</style>