|
@@ -1,6 +1,17 @@
|
|
|
<template>
|
|
|
<div class="alert-body__main_content">
|
|
|
<zz-form class="add-device-form-style" :cols="cols" :data="formdata" :rules="rules" labelWidth="100" :errors="errors" ref="form">
|
|
|
+ <template slot="currentReading">
|
|
|
+ <el-input
|
|
|
+ v-model="formdata.currentReading"
|
|
|
+ oninput="value=value.replace(/[^0-9.]/g,'')"
|
|
|
+ @blur="formdata.currentReading = $event.target.value"
|
|
|
+ maxlength="10"
|
|
|
+ placeholder="请输入本期读数"
|
|
|
+ clearable
|
|
|
+ @blur.native.capture="calculation(formdata.currentReading)"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
</zz-form>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -12,21 +23,28 @@ export default {
|
|
|
return {
|
|
|
formdata: {
|
|
|
id: '',
|
|
|
- waterConsumption: ''
|
|
|
+ waterConsumption: '',
|
|
|
+ currentReading: ''
|
|
|
},
|
|
|
cols: [
|
|
|
[
|
|
|
+ {
|
|
|
+ prop: 'currentReading',
|
|
|
+ label: '本期读数',
|
|
|
+ slot: 'currentReading'
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'waterConsumption',
|
|
|
label: '用水量(吨)',
|
|
|
- placeholder: '限20位之内的数字',
|
|
|
+ placeholder: '请先输入本期读数',
|
|
|
maxlength: 20,
|
|
|
+ disabled: true,
|
|
|
input: true
|
|
|
}
|
|
|
]
|
|
|
],
|
|
|
rules: {
|
|
|
- waterConsumption: this.$valid.customeFloat({
|
|
|
+ currentReading: this.$valid.customeFloat({
|
|
|
validator(rule, value, callback) {
|
|
|
const reg = /^\d+(\.\d{1,3})?$/;
|
|
|
if (value === '') {
|
|
@@ -37,6 +55,15 @@ export default {
|
|
|
callback();
|
|
|
}
|
|
|
}
|
|
|
+ }),
|
|
|
+ waterConsumption: this.$valid.customeFloat({
|
|
|
+ validator(rule, value, callback) {
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('读数不能为空'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
errors: {}
|
|
@@ -64,13 +91,19 @@ export default {
|
|
|
$loading.close();
|
|
|
});
|
|
|
});
|
|
|
+ },
|
|
|
+ calculation(va) {
|
|
|
+ const { lastReading } = this.params.data;
|
|
|
+ if (!!va) {
|
|
|
+ this.formdata.waterConsumption = va - lastReading;
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.formdata.waterConsumption = this.params.data.waterConsumption;
|
|
|
+ // this.formdata.currentReading = this.params.data.currentReading;
|
|
|
this.formdata.id = this.params.data.id;
|
|
|
if (this.params.type == 2) {
|
|
|
- this.cols[0][0].label = '用电量(度)';
|
|
|
+ this.cols[0][1].label = '用电量(度)';
|
|
|
}
|
|
|
}
|
|
|
};
|