| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用电消耗区域:" prop="electricityConsumptionAreaId"> |
| | | <el-cascader |
| | | v-model="form.electricityConsumptionAreaId" |
| | | :options="areaList" |
| | | :props="{ |
| | | value: 'id', |
| | | label: 'label', |
| | | children: 'children', |
| | | checkStrictly: true, |
| | | }" |
| | | placeholder="请选择区域" |
| | | clearable |
| | | style="width: 100%" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="每日限制电量:" prop="everyNum"> |
| | | <el-input |
| | | v-model="form.everyNum" |
| | |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="额定功率:" prop="powerRating"> |
| | | <el-input |
| | |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="实际功率:" prop="powerActual"> |
| | | <el-input |
| | |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="运行时间:" prop="runDate"> |
| | | <el-date-picker |
| | |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="当日用电量:" prop="dayNum"> |
| | | <el-input |
| | |
| | | <script setup> |
| | | import {ref} from "vue"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | import {deviceList, equipmentEnergyAdd, equipmentEnergyUpdate} from "@/api/energyManagement/index.js"; |
| | | import {deviceList, equipmentEnergyAdd, equipmentEnergyUpdate, areaListTree} from "@/api/energyManagement/index.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | const emit = defineEmits(['close']) |
| | | const dialogFormVisible = ref(false); |
| | |
| | | powerActual: "", |
| | | runDate: "", |
| | | dayNum: "", |
| | | electricityConsumptionAreaId: "", |
| | | }, |
| | | rules: { |
| | | code: [{ required: true, message: "请选择", trigger: "change" }], |
| | |
| | | powerRating: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | powerActual: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | dayNum: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | electricityConsumptionAreaId: [{ required: true, message: "请选择区域", trigger: "change" }], |
| | | }, |
| | | }) |
| | | const { form, rules } = toRefs(data); |
| | | const codeList = ref([]) |
| | | const areaList = ref([]) |
| | | |
| | | // 打开弹框 |
| | | const openDialog = (type, row) => { |
| | |
| | | // form.value.maintenanceTime = getCurrentDate(); |
| | | form.value = {} |
| | | proxy.resetForm("formRef"); |
| | | |
| | | // 获取设备列表 |
| | | deviceList().then((res) => { |
| | | codeList.value = res.data; |
| | | }); |
| | | |
| | | // 获取区域列表 |
| | | areaListTree().then((res) => { |
| | | areaList.value = res; |
| | | console.log("areaList", res); |
| | | }); |
| | | |
| | | if (type === "edit") { |
| | | form.value = {...row} |
| | | // 编辑时,将单个ID转换为数组格式用于回显 |
| | | if (row.electricityConsumptionAreaId) { |
| | | form.value.electricityConsumptionAreaId = [row.electricityConsumptionAreaId]; |
| | | } |
| | | } |
| | | } |
| | | const setName = (code) => { |
| | |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | // 提交前处理 electricityConsumptionAreaId,取数组的最后一个值 |
| | | const submitData = { ...form.value }; |
| | | if (Array.isArray(submitData.electricityConsumptionAreaId) && submitData.electricityConsumptionAreaId.length > 0) { |
| | | submitData.electricityConsumptionAreaId = submitData.electricityConsumptionAreaId[submitData.electricityConsumptionAreaId.length - 1]; |
| | | } |
| | | |
| | | if (operationType.value === "add") { |
| | | equipmentEnergyAdd(form.value).then(response => { |
| | | equipmentEnergyAdd(submitData).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | closeDia() |
| | | }) |
| | | } else { |
| | | equipmentEnergyUpdate(form.value).then(response => { |
| | | equipmentEnergyUpdate(submitData).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | closeDia() |
| | | }) |