| <template> | 
|   <div :ref="'settings'" class="settings-sub-container"> | 
|     <el-form ref="form" :model="formData" label-width="150px" class="margin-top-20"> | 
|       <el-form-item label="重量公差"> | 
|         <el-input v-model="formData.product_weightTolerance" class="w-500 app-secret"></el-input> | 
|       </el-form-item> | 
|       <el-form-item label="空器具重量公差"> | 
|         <el-input v-model="formData.product_emptyWeightTolerance" class="w-500 app-secret"></el-input> | 
|       </el-form-item> | 
|       <el-form-item> | 
|         <el-button type="primary" @click="onSave()">保存</el-button> | 
|       </el-form-item> | 
|     </el-form> | 
|   </div> | 
| </template> | 
|   | 
| <script> | 
| export default { | 
|   name: "settings-pda", | 
|   | 
|   components: {}, | 
|   data() { | 
|     return { | 
|       type_Id: 585, // 通用参数类别ID,不可修改 | 
|       // 编辑数据对象 | 
|       formData: { | 
|         product_weightTolerance: null, | 
|         product_emptyWeightTolerance: null | 
|       }, | 
|       // 接口数据 | 
|       valueList: [] | 
|     }; | 
|   }, | 
|   mounted() { | 
|     this.loadParam(); | 
|   }, | 
|   methods: { | 
|     handleClose(tag) {}, | 
|   | 
|     // 加载数据 | 
|     loadParam() { | 
|       var keys = Object.keys(this.formData).join(","); | 
|       var url = "/api/sys/param/getConfig"; | 
|       var params = { | 
|         openNodeApi: true, | 
|         type_Id: this.type_Id, | 
|         keys: keys | 
|       }; | 
|       var callback = res => { | 
|         this.common.showMsg(res); | 
|         this.valueList = res.data; | 
|   | 
|         // 获得参数值列表,将数字转换为对象 | 
|         res.data.forEach(item => { | 
|           var value03 = item.value03; | 
|           if (this.common.isNumber(item.value03)) { | 
|             value03 = parseFloat(item.value03); | 
|           } | 
|           this.$set(this.formData, item.value02, value03); | 
|         }); | 
|       }; | 
|       var target = this.$refs["settings"]; | 
|       this.common.ajax(url, params, callback, target); | 
|     }, | 
|     // 保存数据 | 
|     onSave() { | 
|       Object.keys(this.formData).forEach(key => { | 
|         var item = this.valueList.find(item => { | 
|           return item.value02 === key; | 
|         }); | 
|         if (item) { | 
|           item.value03 = this.formData[key]; | 
|         } else { | 
|           this.valueList.push({ | 
|             type_Id: this.type_Id, | 
|             value02: key, | 
|             value03: this.formData[key] | 
|           }); | 
|         } | 
|       }); | 
|   | 
|       var url = "/api/sys/param/saveParams"; | 
|       var params = { | 
|         openNodeApi: true, | 
|         type_Id: this.type_Id, | 
|         valueList: this.valueList | 
|       }; | 
|       var target = this.$refs["settings"]; | 
|       this.common.ajax( | 
|         url, | 
|         params, | 
|         res => { | 
|           this.common.showMsg(res); | 
|         }, | 
|         target | 
|       ); | 
|     } | 
|   } | 
| }; | 
| </script> | 
|   | 
| <style lang="scss" scoped> | 
| .settings-sub-container { | 
|   /deep/ .sub-title { | 
|     font-size: 14px; | 
|     padding-bottom: 10px; | 
|     border-bottom: 1px solid #ebeef5; | 
|     padding-top: 20px; | 
|     margin-bottom: 10px; | 
|   } | 
|   /deep/ .el-form-item__label { | 
|     font-weight: normal; | 
|   } | 
|   .remark { | 
|     color: #888; | 
|   } | 
|   /deep/ .el-form-item { | 
|     margin-bottom: 20px; | 
|   } | 
|   .form-footer { | 
|     margin-top: 30px; | 
|   } | 
| } | 
| </style> |