<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 (
|
[
|
'firstsetfirstpay',
|
'twosetfirstpay',
|
'aveprice',
|
'pricebetweenup',
|
'pricebetweendown',
|
'projectoneprice'
|
].some(item => item === name) &&
|
value.includes('.')
|
) {
|
const tempVal = (value * 1).toFixed(2).split('.')
|
this.svalue = tempVal[1] === '00' ? tempVal[0] : tempVal.join('.')
|
}
|
if (
|
['singlesumpricetop', 'singlesumpricelower'].some(
|
item => item === name
|
)
|
) {
|
this.svalue = this.formatMoney(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>
|