Compare commits
3 Commits
6140ca8f14
...
e98b4ed287
| Author | SHA1 | Date | |
|---|---|---|---|
| e98b4ed287 | |||
| 4ebd5f0988 | |||
| a0095b4054 |
@ -262,28 +262,6 @@ export default {
|
|||||||
saveDialog() {
|
saveDialog() {
|
||||||
this.$refs.addTempForm.validate(valid => {
|
this.$refs.addTempForm.validate(valid => {
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
//校验时间选择范围是否冲突
|
|
||||||
let status = true
|
|
||||||
this.tableData.forEach((outer, outerIndex) => {
|
|
||||||
const {startTime, endTime} = outer
|
|
||||||
const outerStart = parseInt(startTime), outerEnd = parseInt(endTime)
|
|
||||||
if (outerStart > outerEnd) {
|
|
||||||
status = false
|
|
||||||
} else {
|
|
||||||
this.tableData.forEach((inner, innerIndex) => {
|
|
||||||
if (innerIndex !== outerIndex) {
|
|
||||||
const {startTime: innerStartTime, endTime: innerEndTime} = inner
|
|
||||||
const innerStart = parseInt(innerStartTime), innerEnd = parseInt(innerEndTime)
|
|
||||||
if ((innerStart < outerStart && innerEnd > outerEnd) || !((innerStart < outerStart && innerEnd <= outerStart) || (innerStart >= outerEnd && innerEnd > outerEnd))) {
|
|
||||||
status = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!status) {
|
|
||||||
return this.$message.error('时间选择范围冲突');
|
|
||||||
}
|
|
||||||
const {templateName, sdcLimit, sdcDown, sdcUp} = this.formData
|
const {templateName, sdcLimit, sdcDown, sdcUp} = this.formData
|
||||||
const {siteId, updateStrategyId} = this.$home
|
const {siteId, updateStrategyId} = this.$home
|
||||||
const {tableData} = this
|
const {tableData} = this
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :visible.sync="dialogTableVisible" :close-on-press-escape="false" :close-on-click-modal="false"
|
<el-dialog :visible.sync="dialogTableVisible" :close-on-press-escape="false" :close-on-click-modal="false"
|
||||||
:show-close="false" destroy-on-close lock-scroll append-to-body width="600px" class="ems-dialog"
|
:show-close="false" destroy-on-close lock-scroll append-to-body width="800px" class="ems-dialog"
|
||||||
:title="mode === 'add'?'新增设备':`编辑设备` ">
|
:title="mode === 'add'?'新增设备':`编辑设备` ">
|
||||||
<el-form v-loading="loading>0" ref="addTempForm" :model="formData" :rules="rules" size="medium" label-width="140px">
|
<div v-loading="loading>0">
|
||||||
|
<el-form v-loading="loading>0" ref="addTempForm" inline :model="formData" :rules="rules" size="medium"
|
||||||
|
label-width="120px" class="device-form">
|
||||||
<el-form-item label="站点" prop="siteId">
|
<el-form-item label="站点" prop="siteId">
|
||||||
<el-select v-model="formData.siteId" placeholder="请选择" :style="{width: '100%'}" @change="changeType">
|
<el-select v-model="formData.siteId" placeholder="请选择" :style="{width: '100%'}" @change="changeType">
|
||||||
<el-option :label="item.siteName" :value="item.siteId" v-for="(item,index) in siteList"
|
<el-option :label="item.siteName" :value="item.siteId" v-for="(item,index) in siteList"
|
||||||
@ -35,7 +37,8 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备类别" prop="deviceCategory">
|
<el-form-item label="设备类别" prop="deviceCategory">
|
||||||
<el-select v-model="formData.deviceCategory" placeholder="请选择" :style="{width: '100%'}" @change="changeType">
|
<el-select v-model="formData.deviceCategory" placeholder="请选择" :style="{width: '100%'}"
|
||||||
|
@change="changeType">
|
||||||
<el-option :label="item.name" :value="item.code" v-for="(item,index) in deviceCategoryList"
|
<el-option :label="item.name" :value="item.code" v-for="(item,index) in deviceCategoryList"
|
||||||
:key="index+'deviceCategoryList'"></el-option>
|
:key="index+'deviceCategoryList'"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
@ -85,6 +88,49 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
<!-- pcs配置-->
|
||||||
|
<el-form v-if="isPcs" ref="pcsSettingForm" inline :model="pcsSetting" size="medium"
|
||||||
|
label-width="120px" class="device-form" :rules="pcsSettingRules">
|
||||||
|
<div style="font-size: 14px;padding: 10px 0 20px;font-weight: 600;">PCS配置</div>
|
||||||
|
<el-form-item label="开关机地址" prop="pointAddress">
|
||||||
|
<el-input v-model="pcsSetting.pointAddress" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="功率地址" prop="powerAddress">
|
||||||
|
<el-input v-model="pcsSetting.powerAddress" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开机指令" prop="startCommand">
|
||||||
|
<el-input v-model="pcsSetting.startCommand" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开机目标功率" prop="startPower">
|
||||||
|
<el-input v-model="pcsSetting.startPower" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="关机指令" prop="stopCommand">
|
||||||
|
<el-input v-model="pcsSetting.stopCommand" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="关机目标功率" prop="stopPower">
|
||||||
|
<el-input v-model="pcsSetting.stopPower" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电池簇数" prop="clusterNum">
|
||||||
|
<el-input v-model="pcsSetting.clusterNum" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<br>
|
||||||
|
<template v-for="index in parseInt(pcsSetting.clusterNum) || 0">
|
||||||
|
<el-form-item :label="'电池簇'+(index)+'地址'"
|
||||||
|
prop="clusterPointAddress">
|
||||||
|
<el-input v-model="pcsSetting.clusterPointAddress[index-1]" placeholder="请输入" clearable
|
||||||
|
:style="{width: '100%'}">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<el-button @click="closeDialog">取消</el-button>
|
<el-button @click="closeDialog">取消</el-button>
|
||||||
<el-button type="primary" @click="saveDialog">确定</el-button>
|
<el-button type="primary" @click="saveDialog">确定</el-button>
|
||||||
@ -124,6 +170,13 @@ export default {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const validateNumber = (rule, value, callback) => {
|
||||||
|
if (value !== '' && !/^[0-9]+$/.test(value)) {
|
||||||
|
callback(new Error('只能输入数字!'));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
loading: 0,
|
loading: 0,
|
||||||
dccDeviceCategoryList: ['CLUSTER', 'BATTERY'],//需要展示上级设备的设备类型
|
dccDeviceCategoryList: ['CLUSTER', 'BATTERY'],//需要展示上级设备的设备类型
|
||||||
@ -151,6 +204,17 @@ export default {
|
|||||||
pictureUrl: '',//设备图片
|
pictureUrl: '',//设备图片
|
||||||
slaveId: '',//从站地址
|
slaveId: '',//从站地址
|
||||||
},
|
},
|
||||||
|
pcsSetting: {
|
||||||
|
deviceSettingId: '',
|
||||||
|
powerAddress: '',//功率地址
|
||||||
|
pointAddress: "",//开关机地址
|
||||||
|
startCommand: "",//开机指令
|
||||||
|
stopCommand: "",//关机指令
|
||||||
|
startPower: '',//开机目标功率
|
||||||
|
stopPower: '',//关机目标功率
|
||||||
|
clusterNum: '',//电池簇数
|
||||||
|
clusterPointAddress: []//电池簇地址
|
||||||
|
},
|
||||||
rules: {
|
rules: {
|
||||||
siteId: [
|
siteId: [
|
||||||
{required: true, message: '请选择站点', trigger: ['blur', 'change']}
|
{required: true, message: '请选择站点', trigger: ['blur', 'change']}
|
||||||
@ -183,7 +247,7 @@ export default {
|
|||||||
{validator: validateText, trigger: 'blur'}
|
{validator: validateText, trigger: 'blur'}
|
||||||
],
|
],
|
||||||
slaveId: [
|
slaveId: [
|
||||||
{validator: validateText, trigger: 'blur'}
|
{validator: validateNumber, trigger: 'blur'}
|
||||||
],
|
],
|
||||||
serialPort: [
|
serialPort: [
|
||||||
{validator: validateText, trigger: 'blur'}
|
{validator: validateText, trigger: 'blur'}
|
||||||
@ -204,13 +268,47 @@ export default {
|
|||||||
// { required: true, message: '请上传图片', trigger: ['blur', 'change']}
|
// { required: true, message: '请上传图片', trigger: ['blur', 'change']}
|
||||||
// ],
|
// ],
|
||||||
},
|
},
|
||||||
|
pcsSettingRules: {
|
||||||
|
pointAddress: [
|
||||||
|
{required: true, message: '请输入开关机地址', trigger: 'blur'},
|
||||||
|
{validator: validateText, trigger: 'blur'}
|
||||||
|
],
|
||||||
|
powerAddress: [
|
||||||
|
{validator: validateText, trigger: 'blur'}
|
||||||
|
],
|
||||||
|
startCommand: [
|
||||||
|
{required: true, message: '请输入开机指令', trigger: 'blur'},
|
||||||
|
{validator: validateText, trigger: 'blur'}
|
||||||
|
],
|
||||||
|
startPower: [
|
||||||
|
{validator: validateText, trigger: 'blur'}
|
||||||
|
],
|
||||||
|
stopCommand: [
|
||||||
|
{required: true, message: '请输入关机指令', trigger: 'blur'},
|
||||||
|
{validator: validateText, trigger: 'blur'}
|
||||||
|
],
|
||||||
|
stopPower: [
|
||||||
|
{validator: validateText, trigger: 'blur'}
|
||||||
|
],
|
||||||
|
clusterNum: [
|
||||||
|
{required: true, message: '请输入电池簇数', trigger: 'blur'},
|
||||||
|
{validator: validateNumber, trigger: 'blur'}
|
||||||
|
],
|
||||||
|
clusterPointAddress: [
|
||||||
|
{required: true, message: '请输入电池簇地址', trigger: 'blur'},
|
||||||
|
{validator: validateText, trigger: 'blur'}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
communicationStatusOptions: state => state?.ems?.communicationStatusOptions || {},
|
communicationStatusOptions: state => state?.ems?.communicationStatusOptions || {},
|
||||||
deviceTypeOptions: state => state?.ems?.deviceTypeOptions || {}
|
deviceTypeOptions: state => state?.ems?.deviceTypeOptions || {}
|
||||||
})
|
}),
|
||||||
|
isPcs() {
|
||||||
|
return this.formData.deviceCategory === 'PCS'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
dialogTableVisible: {
|
dialogTableVisible: {
|
||||||
@ -228,7 +326,14 @@ export default {
|
|||||||
if ((newVal || newVal === 0) && this.mode !== 'add') {
|
if ((newVal || newVal === 0) && this.mode !== 'add') {
|
||||||
this.loading += 1
|
this.loading += 1
|
||||||
getDeviceDetailInfo(newVal).then(response => {
|
getDeviceDetailInfo(newVal).then(response => {
|
||||||
this.formData = JSON.parse(JSON.stringify(response?.data || {}));
|
const {pcsSetting, ...data} = JSON.parse(JSON.stringify(response?.data || {}))
|
||||||
|
this.formData = data;
|
||||||
|
if (pcsSetting && JSON.stringify(pcsSetting) !== '{}') {
|
||||||
|
this.pcsSetting = JSON.parse(JSON.stringify({
|
||||||
|
...pcsSetting,
|
||||||
|
clusterPointAddress: JSON.parse(pcsSetting.clusterPointAddress || [])
|
||||||
|
}));
|
||||||
|
}
|
||||||
if (this.dccDeviceCategoryList.includes(this.formData.deviceCategory)) {
|
if (this.dccDeviceCategoryList.includes(this.formData.deviceCategory)) {
|
||||||
this.getParentDeviceList(true)
|
this.getParentDeviceList(true)
|
||||||
}
|
}
|
||||||
@ -280,9 +385,7 @@ export default {
|
|||||||
this.loading = this.loading - 1
|
this.loading = this.loading - 1
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
saveDialog() {
|
saveData() {
|
||||||
this.$refs.addTempForm.validate(valid => {
|
|
||||||
if (!valid) return
|
|
||||||
this.loading += 1
|
this.loading += 1
|
||||||
const {
|
const {
|
||||||
id = '',
|
id = '',
|
||||||
@ -304,8 +407,18 @@ export default {
|
|||||||
pictureUrl = '',//设备图片
|
pictureUrl = '',//设备图片
|
||||||
slaveId = '',//从站地址
|
slaveId = '',//从站地址
|
||||||
} = this.formData;
|
} = this.formData;
|
||||||
if (this.mode === 'add') {
|
const {
|
||||||
addDevice({
|
deviceSettingId,
|
||||||
|
powerAddress,
|
||||||
|
pointAddress,
|
||||||
|
startCommand,
|
||||||
|
stopCommand,
|
||||||
|
startPower,
|
||||||
|
stopPower,
|
||||||
|
clusterNum,
|
||||||
|
clusterPointAddress
|
||||||
|
} = this.pcsSetting
|
||||||
|
let params = {
|
||||||
siteId,
|
siteId,
|
||||||
deviceId,
|
deviceId,
|
||||||
deviceName,
|
deviceName,
|
||||||
@ -322,8 +435,22 @@ export default {
|
|||||||
stopBits,
|
stopBits,
|
||||||
parity,
|
parity,
|
||||||
pictureUrl,
|
pictureUrl,
|
||||||
slaveId
|
slaveId,
|
||||||
}).then(response => {
|
}
|
||||||
|
if (this.isPcs) {
|
||||||
|
params.pcsSetting = {
|
||||||
|
powerAddress,
|
||||||
|
pointAddress,
|
||||||
|
startCommand,
|
||||||
|
stopCommand,
|
||||||
|
startPower,
|
||||||
|
stopPower,
|
||||||
|
clusterNum,
|
||||||
|
clusterPointAddress: JSON.stringify(!clusterNum ? [] : (clusterPointAddress || []).slice(0, clusterNum))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.mode === 'add') {
|
||||||
|
addDevice(params).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
//新增成功
|
//新增成功
|
||||||
// 关闭弹窗 更新表格
|
// 关闭弹窗 更新表格
|
||||||
@ -334,26 +461,9 @@ export default {
|
|||||||
this.loading -= 1
|
this.loading -= 1
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
updateDevice({
|
params.id = id
|
||||||
id,
|
params.pcsSetting && (params.pcsSetting.deviceSettingId = deviceSettingId)
|
||||||
siteId,
|
updateDevice(params).then(response => {
|
||||||
deviceId,
|
|
||||||
deviceName,
|
|
||||||
description,
|
|
||||||
communicationStatus,
|
|
||||||
deviceType,
|
|
||||||
deviceCategory,
|
|
||||||
parentId,
|
|
||||||
ipAddress,
|
|
||||||
ipPort,
|
|
||||||
serialPort,
|
|
||||||
baudRate,
|
|
||||||
dataBits,
|
|
||||||
stopBits,
|
|
||||||
parity,
|
|
||||||
pictureUrl,
|
|
||||||
slaveId
|
|
||||||
}).then(response => {
|
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
//新增成功
|
//新增成功
|
||||||
// 关闭弹窗 更新表格
|
// 关闭弹窗 更新表格
|
||||||
@ -364,7 +474,18 @@ export default {
|
|||||||
this.loading -= 1
|
this.loading -= 1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
saveDialog() {
|
||||||
|
this.$refs.addTempForm.validate(valid => {
|
||||||
|
if (!valid) return
|
||||||
|
if (this.isPcs) {
|
||||||
|
this.$refs.pcsSettingForm.validate(pcsValidate => {
|
||||||
|
if (!pcsValidate) return
|
||||||
|
this.saveData()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.saveData()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
closeDialog() {
|
closeDialog() {
|
||||||
@ -390,12 +511,34 @@ export default {
|
|||||||
pictureUrl: '',//设备图片
|
pictureUrl: '',//设备图片
|
||||||
slaveId: '',//从站地址
|
slaveId: '',//从站地址
|
||||||
}
|
}
|
||||||
|
this.pcsSetting = {
|
||||||
|
deviceSettingId: '',
|
||||||
|
powerAddress: '',//功率地址
|
||||||
|
pointAddress: "",//开关机地址
|
||||||
|
startCommand: "",//开机指令
|
||||||
|
stopCommand: "",//关机指令
|
||||||
|
startPower: '',//开机目标功率
|
||||||
|
stopPower: '',//关机目标功率
|
||||||
|
clusterNum: '',//电池簇数
|
||||||
|
clusterPointAddress: []//电池簇地址
|
||||||
|
}
|
||||||
this.$refs.addTempForm.resetFields()
|
this.$refs.addTempForm.resetFields()
|
||||||
|
this.$refs?.pcsSettingForm?.resetFields()
|
||||||
this.dialogTableVisible = false
|
this.dialogTableVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
|
.device-form {
|
||||||
|
::v-deep .el-form-item--medium .el-form-item__content {
|
||||||
|
width: 260px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-form-item {
|
||||||
|
width: 50%;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user