elkers
2025-01-16 0b62eca817d6c40c188dc72c3034835a61a30a35
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
 
 <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>