|
<script setup >
|
import meterReadingRecordApi from "@/api/meterReadingApi/meterReadingRecord";
|
// import user from "@/api/system/user";
|
import useWaterMeterApi from "@/api/waterMeterApi/useWaterMeter";
|
const { proxy } = getCurrentInstance();
|
|
/**
|
* 新增/修改弹窗Form表单相关
|
*/
|
const data = reactive({
|
form:{},
|
rules: {
|
useWaterMeterId: [{required: true, message: '请选择水表', trigger: 'blur'}],
|
currentAmount: [{required: true, message: '请输入抄表读数', trigger: 'blur'}],
|
},
|
});
|
const { form, rules } = toRefs(data);
|
|
//获取账号列表
|
const meterList = ref()
|
const getMeterList = async() =>{
|
await useWaterMeterApi().search({limit:10000,page:1}).then((res) =>{
|
meterList.value = res.data.list
|
})
|
}
|
getMeterList()
|
/** 提交按钮 */
|
function submitForm() {
|
proxy.$refs["formRef"].validate(valid => {
|
if (valid) {
|
meterReadingRecordApi().manualMeterReading(form.value).then(res => {
|
proxy.$modal.msgSuccess("新增成功");
|
reset()
|
}).catch(() =>{
|
proxy.$modal.msgError("新增失败");
|
reset()
|
});
|
}
|
});
|
}
|
/** 取消按钮 */
|
function cancel() {
|
reset();
|
}
|
/** 表单重置 */
|
function reset() {
|
form.value = {
|
useWaterMeterId:"",
|
currentAmount:"",
|
description: "",
|
};
|
proxy.resetForm("formRef");
|
}
|
</script>
|
<template>
|
<div class="app-container">
|
<!-- 添加或修改对话框 -->
|
<div class="form-container">
|
<div class="title">手动抄表:</div>
|
<el-form class="form-box" ref="formRef" :model="form" :rules="rules" label-width='auto'>
|
<el-form-item label="所属水表" prop="useWaterMeterId">
|
<el-select v-model="form.useWaterMeterId" filterable placeholder="请输入或选择用户">
|
<el-option
|
v-for="item in meterList"
|
:key="item.id"
|
:label="item.sn"
|
:title="item.sn"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="本月抄表止数" prop="currentAmount">
|
<el-input v-model="form.currentAmount"></el-input>
|
</el-form-item>
|
<el-form-item label="描述" prop="description">
|
<el-input v-model="form.description"></el-input>
|
</el-form-item>
|
<el-form-item></el-form-item>
|
</el-form>
|
<div class="footer">
|
<el-button type="primary" size="large" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel" size="large">取 消</el-button>
|
</div>
|
</div>
|
</div>
|
</template>
|
<style lang="scss" scoped>
|
.app-container{
|
width: 100%;
|
height: 100%;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
.form-container{
|
width: 70%;
|
height: 800px;
|
background: rgba(28, 132, 198, 0.07);
|
padding: 0 5%;
|
border-radius: 10px;
|
border-top: 2px solid rgb(11, 136, 216);
|
.title{
|
width: 100%;
|
display: flex;
|
justify-content:flex-start;
|
align-items: center;
|
height: 100px;
|
font-weight: bold;
|
font-size: 20px;
|
color: #3f4040;
|
}
|
.el-form{
|
width: 100%;
|
margin-top: 40px;
|
.el-form-item{
|
height: 40px;
|
}
|
}
|
.footer{
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
margin: 200px 0;
|
}
|
}
|
}
|
</style>
|
|