zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
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
<template>
  <el-form-item :label="config.filedDescription" :prop="config.name" :rules="rules">
    <el-input
      class="text-area-row"
      v-model="svalue"
      :rows="inputRows"
      :type="inputType"
      :placeholder="placeholder"
      @input="change($event)"
      @blur="changeMoney"
      :readonly="!config.writeAble"
      resize="none"
    ></el-input>
  </el-form-item>
</template>
 
<script>
import { money } from '@/views/area/mixins'
export default {
  props: ['config', 'value', 'inputType', 'inputRows', 'placeholder'],
  mixins: [money],
  data: function() {
    return {
      rules: {
        required: this.config.required,
        message: '请输入' + this.config.filedDescription,
        trigger: 'blur'
      },
      svalue: this.value,
      writeAble: false
    }
  },
  watch: {
    'config.required': function(newVal) {
      this.rules.required = newVal
    }
  },
  methods: {
    change(val) {
      this.$emit('input', val)
    },
    changeMoney(event) {
      const { config, placeholder } = this
      const { name, filedDescription } = config
      let value = event.target.value
      if (!/^\d+(?=\{0,1}\d+$|$)/.test(value)) {
        this.$message.warning(`${filedDescription}输入有误,请重新输入`)
        this.svalue = ''
      } else {
        if (['rebateterm','term'].some(item => item === name)) {
          this.svalue = value
        }
      }
      this.$emit('changeValue', this.svalue, name)
    }
  }
}
</script>
<!-- 文本框为readonly时,只读 -->
<style lang="postcss" scoped>
.text-area-row {
  & >>> .el-textarea__inner {
    color: #000;
  }
  
  .el-textarea__inner[readonly='readonly'] {
    color: #666;
    background-color: #fafafa;
  }
}
</style>