|
|
|
@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
|
|
<view>
|
|
|
|
|
|
|
|
<u-sticky
|
|
|
|
|
|
|
|
class="sticky"
|
|
|
|
|
|
|
|
:custom-nav-height="0"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<u-navbar
|
|
|
|
|
|
|
|
:title="id ? '编辑能源设备':'新增能源设备'"
|
|
|
|
|
|
|
|
bg-color="transparent"
|
|
|
|
|
|
|
|
:auto-back="true"
|
|
|
|
|
|
|
|
:title-style="{ fontWeight: 'bold' }"
|
|
|
|
|
|
|
|
safe-area-inset-top
|
|
|
|
|
|
|
|
placeholder
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</u-sticky>
|
|
|
|
|
|
|
|
<view class="container">
|
|
|
|
|
|
|
|
<!-- 自定义表单校验 -->
|
|
|
|
|
|
|
|
<uni-forms ref="customForm" :rules="customRules" labelWidth="105px" :modelValue="formData">
|
|
|
|
|
|
|
|
<uni-forms-item label="名称" required name="name">
|
|
|
|
|
|
|
|
<u-input v-model="formData.name" placholder="请输入名称"/>
|
|
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
|
|
<uni-forms-item label="编码">
|
|
|
|
|
|
|
|
<u-input v-model="formData.code" placholder="请输入编码"/>
|
|
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
|
|
<uni-forms-item label="设备类型" required name="deviceType">
|
|
|
|
|
|
|
|
<uni-data-checkbox v-model="formData.deviceType" :localdata="deviceTypes"/>
|
|
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
|
|
<uni-forms-item label="抄表周期cron">
|
|
|
|
|
|
|
|
<u-input v-model="formData.checkCron" placholder="请输入抄表周期cron"/>
|
|
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
|
|
<uni-forms-item label="单位">
|
|
|
|
|
|
|
|
<u-input v-model="formData.unitName" placholder="单位"/>
|
|
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
|
|
<uni-forms-item label="是否启用" required name="isEnable">
|
|
|
|
|
|
|
|
<uni-data-checkbox v-model="formData.isEnable" :localdata="isEnable"/>
|
|
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
|
|
<uni-forms-item label="信息资料">
|
|
|
|
|
|
|
|
<u-input v-model="formData.info" />
|
|
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
|
|
</uni-forms>
|
|
|
|
|
|
|
|
<view class="u-flex justify-end">
|
|
|
|
|
|
|
|
<view @click="submit()">
|
|
|
|
|
|
|
|
<u-button type="primary">
|
|
|
|
|
|
|
|
<uni-icons type="checkbox" class="u-m-r-10"/>
|
|
|
|
|
|
|
|
确定
|
|
|
|
|
|
|
|
</u-button></view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
|
|
import { onLoad, onReady } from "@dcloudio/uni-app";
|
|
|
|
|
|
|
|
import tab from "@/plugins/tab";
|
|
|
|
|
|
|
|
import {createEnergyDevice, getEnergyDeviceById, updateEnergyDevice} from "@/api/mes/application";
|
|
|
|
|
|
|
|
import modal from "@/plugins/modal";
|
|
|
|
|
|
|
|
import { deviceTypes, isEnable } from "@/api/system/dict/data";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formData = ref({
|
|
|
|
|
|
|
|
id: undefined,
|
|
|
|
|
|
|
|
name: undefined,
|
|
|
|
|
|
|
|
code: undefined,
|
|
|
|
|
|
|
|
deviceType: undefined,
|
|
|
|
|
|
|
|
info: undefined,
|
|
|
|
|
|
|
|
checkCron: undefined,
|
|
|
|
|
|
|
|
lastCheckTime: undefined,
|
|
|
|
|
|
|
|
lastCheckValue: undefined,
|
|
|
|
|
|
|
|
unitName: undefined,
|
|
|
|
|
|
|
|
isEnable: undefined
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const id = ref()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const customForm = ref()
|
|
|
|
|
|
|
|
// 自定义表单校验规则
|
|
|
|
|
|
|
|
const customRules = ref({
|
|
|
|
|
|
|
|
name: { rules: { required: true, errorMessage: '设备名称不能为空' }},
|
|
|
|
|
|
|
|
deviceType: { rules: { required: true, errorMessage: '设备类型不能为空'}},
|
|
|
|
|
|
|
|
isEnable: { rules: { required: true, errorMessage: '是否启用不能为空' }}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const submit = ()=>{
|
|
|
|
|
|
|
|
customForm.value.validate(async(valid)=>{
|
|
|
|
|
|
|
|
if(!valid && !id.value) {
|
|
|
|
|
|
|
|
await createEnergyDevice(formData.value)
|
|
|
|
|
|
|
|
modal.msgSuccess("保存成功")
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
await updateEnergyDevice(formData.value)
|
|
|
|
|
|
|
|
modal.msgSuccess("修改成功")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await tab.navigateBack()
|
|
|
|
|
|
|
|
uni.$emit('success', true)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onReady(()=>{
|
|
|
|
|
|
|
|
// 设置自定义表单校验规则,必须在节点渲染完毕后执行
|
|
|
|
|
|
|
|
customForm.value.setRules(customRules.value)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
onLoad(() => {
|
|
|
|
|
|
|
|
id.value = tab.getParams().id
|
|
|
|
|
|
|
|
if(id.value) {
|
|
|
|
|
|
|
|
getEnergyDeviceById(id.value).then(response => {
|
|
|
|
|
|
|
|
formData.value = response.data
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="sass" scoped>
|
|
|
|
|
|
|
|
.sticky
|
|
|
|
|
|
|
|
background: linear-gradient(180deg, #d4e9ff 0%, #f3f9ff 100%)
|
|
|
|
|
|
|
|
backdrop-filter: blur(27.18px)
|
|
|
|
|
|
|
|
box-shadow: 0 1px 1px 0 rgba(0, 72, 145, 0.1), 0 0.5px 0 0 rgba(0, 0, 0, 0.1)
|
|
|
|
|
|
|
|
.container
|
|
|
|
|
|
|
|
padding: 20rpx
|
|
|
|
|
|
|
|
margin: 20rpx
|
|
|
|
|
|
|
|
background-color: #ffffff
|
|
|
|
|
|
|
|
.uniui-checkbox:before
|
|
|
|
|
|
|
|
color: #ffffff
|
|
|
|
|
|
|
|
.u-button
|
|
|
|
|
|
|
|
height: 35px
|
|
|
|
|
|
|
|
:deep(.uni-forms-item__content)
|
|
|
|
|
|
|
|
display: flex
|
|
|
|
|
|
|
|
align-items: center
|
|
|
|
|
|
|
|
</style>
|