feat(web): 新增设备管理功能

- 新增设备管理页面和相关功能
This commit is contained in:
zhoumengru
2025-09-09 09:39:15 +08:00
36 changed files with 4123 additions and 815 deletions

View File

@@ -360,8 +360,6 @@ defineExpose({ ...toRefs(data), loading, mountedScroll, scroll: data.scroll })
}
//表格样式
:deep(.ant-table-tbody) {
color: var(--theme-text-default) !important;
> tr {
&:hover {
> .ant-table-cell {

View File

@@ -0,0 +1,711 @@
<!-- item.type:xxxx-unshow:表示不显示 items.displayFlag为false表示不展示卡片 -->
<template>
<div class="card-content">
<a-card style="margin: 0 0 15px 0; text-align: left">
<div :class="['info-title', items.title ? '' : 'title-none']">
<div class="box">
<div>
{{ items.title ? items.title : '基础信息' }}
</div>
<a-tooltip
placement="bottomLeft"
trigger="['hover','click']"
:overlay-style="{ color: '#ccc' }"
v-if="items.tooltip && items.tooltip !== ''"
>
<template #title>
<!-- -->
<span v-html="items.tooltip"></span>
</template>
<ExclamationCircleOutlined
:style="{
fontSize: '18px',
color: 'var(--theme-text3)',
cursor: 'pointer',
position: 'relative',
top: '0',
left: '15px'
}"
/>
</a-tooltip>
</div>
</div>
<div class="info-content">
<a-form
layout="horizontal"
:wrap="true"
ref="formRef"
:rules="props.formRules"
name="info-form"
class="info-form"
label-align="left"
:model="propsInfo.ruleForm.value"
@submit="handleSubmit"
@onFieldsChange="onFieldsChange"
>
<template v-for="item in items.list">
<div
v-if="item.type !== 'unshow'"
:key="item.key"
:class="item.className ? [item.className, 'item-div'] : 'item-div'"
>
<a-form-item
:label="item.label"
:name="item.key"
:class="[item.colStatus || item.type === 'table' ? 'item-width' : 'form-item']"
:tooltip="item.tooltip ? item.tooltip : ''"
>
<a-input-password
v-if="item.type === 'input-password'"
v-model:value="propsInfo.ruleForm.value[item.key]"
:placeholder="'请输入' + item.label"
:disabled="!props.disabled && type ? !!item.disabled : props.disabled"
/>
<a-input
v-if="item.type === 'input'"
v-model:value="propsInfo.ruleForm.value[item.key]"
:type="item.inputType"
:placeholder="'请输入' + item.label"
:disabled="!props.disabled && type ? !!item.disabled : props.disabled"
/>
<a-input-number
v-if="item.type == 'input-number'"
id="inputNumber"
v-model:value="propsInfo.ruleForm.value[item.key]"
:min="item.min || 0"
:max="item.max || 10000000"
:formatter="item.formatter || null"
:addon-before="item.addonBefore"
:disabled="props.disabled"
/>
<a-date-picker
v-if="item.type === 'date-picker'"
v-model:value="propsInfo.ruleForm.value[item.key]"
:placeholder="'请输入' + item.label"
:disabled="props.disabled"
value-format="YYYY-MM-DD HH:mm:ss"
/>
<a-date-picker
show-time
v-if="item.type === 'time'"
value-format="YYYY-MM-DD HH:mm:ss"
:disabled="props.disabled"
v-model:value="propsInfo.ruleForm.value[item.key]"
:placeholder="'请输入' + item.label"
/>
<a-range-picker
v-if="item.type === 'date-time'"
v-model:value="propsInfo.ruleForm.value[item.key]"
value-format="YYYY-MM-DD HH:mm:ss"
:disabled="props.disabled"
show-time
/>
<a-time-range-picker
v-if="item.type === 'timeRangePicker'"
v-model:value="propsInfo.ruleForm.value[item.key]"
value-format="HH:mm"
format="HH:mm"
:disabled="props.disabled"
/>
<a-time-picker
v-if="item.type === 'timePicker'"
v-model:value="propsInfo.ruleForm.value[item.key]"
value-format="HH:mm"
format="HH:mm"
:disabled="props.disabled"
/>
<a-textarea
v-if="item.type === 'textarea'"
v-model:value="propsInfo.ruleForm.value[item.key]"
:placeholder="'请输入' + item.label"
allow-clear
:disabled="!props.disabled && type ? !!item.disabled : props.disabled"
:auto-size="item.autoSize ? item.autoSize : { minRows: 3, maxRows: 10 }"
/>
<a-select
:dropdown-match-select-width="false"
v-if="item.type === 'select'"
v-model:value="propsInfo.ruleForm.value[item.key]"
:placeholder="'请选择' + item.label"
:disabled="!props.disabled && type ? !!item.disabled : props.disabled"
allow-clear
>
<template v-if="item.options">
<a-select-option
:value="selectItem[item.options.value]"
v-for="selectItem in item.list"
:key="selectItem[item.options.value]"
>
{{ selectItem[item.options.label] }}
</a-select-option>
</template>
<template v-else>
<a-select-option
:value="selectItem.value"
v-for="selectItem in item.list"
:key="selectItem.value"
>
{{ selectItem.label }}
</a-select-option>
</template>
</a-select>
<!-- 下拉多选 -->
<a-select
:dropdown-match-select-width="false"
v-if="item.type === 'selectMultiple'"
mode="multiple"
v-model:value="propsInfo.ruleForm.value[item.key]"
:placeholder="'请选择' + item.label"
:disabled="!props.disabled && type ? !!item.disabled : props.disabled"
allow-clear
>
<a-select-option
:value="selectItem.value"
v-for="selectItem in item.list"
:key="selectItem.value"
>
{{ selectItem.label }}
</a-select-option>
</a-select>
<!-- 新增时disabled -->
<a-select
:dropdown-match-select-width="false"
v-if="item.type === 'select-disabled'"
v-model:value="propsInfo.ruleForm.value[item.key]"
:placeholder="'请选择' + item.label"
:disabled="!props.disabled ? item.disabled : props.disabled"
allow-clear
>
<a-select-option
:value="selectItem.value"
v-for="selectItem in item.list"
:key="selectItem.value"
>
{{ selectItem.label }}
</a-select-option>
</a-select>
<!-- 下拉展示icon -->
<a-select
v-if="item.type === 'icon-select'"
:get-popup-container="(triggerNode) => triggerNode.parentNode"
v-model:value="propsInfo.ruleForm.value[item.key]"
allow-clear
option-label-prop="children"
>
<a-select-option
v-for="icon in iconList"
:key="icon.icon_id"
:value="`icon-${icon.font_class}`"
>
<i
class="iconfont"
:class="`icon-${icon.font_class}`"
style="margin-right: 8px"
></i>
<span> {{ icon.name }} </span>
</a-select-option>
</a-select>
<a-switch
v-if="item.type === 'switch'"
v-model:checked="propsInfo.ruleForm.value[item.key]"
style="margin-bottom: 5px"
:disabled="!props.disabled && type ? !!item.disabled : props.disabled"
/>
<a-radio-group
name="radioGroup"
v-model:value="propsInfo.ruleForm.value[item.key]"
v-if="item.type === 'radio'"
:disabled="props.disabled"
>
<a-radio
:value="radioItem.value"
v-for="radioItem in item.list"
:key="radioItem.value"
>
{{ radioItem.label }}
</a-radio>
</a-radio-group>
<a-tree-select
:disabled="props.disabled"
v-model:value="propsInfo.ruleForm.value[item.key]"
v-if="item.type === 'tree-radio'"
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
:tree-data="item.list"
:placeholder="'请选择' + item.label"
:field-names="
item.replaceFields
? item.replaceFields
: {
children: 'children',
title: 'title',
key: 'key',
value: 'value'
}
"
/>
<a-tree-select
:allow-clear="true"
:disabled="props.disabled"
v-if="item.type === 'tree-check'"
v-model:value="propsInfo.ruleForm.value[item.key]"
style="width: 100%"
:tree-data="item.list"
:tree-checkable="true"
:show-checked-strategy="SHOW_PARENT"
:placeholder="'请选择' + item.label"
:field-names="
item.replaceFields
? item.replaceFields
: {
children: 'children',
title: 'title',
key: 'key',
value: 'value'
}
"
:check="checkTree"
/>
<a-tree-select
:allow-clear="true"
:disabled="props.disabled"
v-if="item.type === 'tree-check-org'"
v-model:value="propsInfo.ruleForm.value[item.key]"
style="width: 100%"
:tree-data="item.list"
allow-clear
multiple
tree-default-expand-all
:placeholder="'请选择' + item.label"
:field-names="
item.replaceFields
? item.replaceFields
: {
children: 'children',
title: 'title',
key: 'key',
value: 'value'
}
"
:check="checkTree"
/>
<a-cascader
:disabled="props.disabled"
v-if="item.type === 'cascader'"
:options="item.list"
:field-names="
item.fieldNames
? item.fieldNames
: { label: 'label', value: 'value', children: 'children' }
"
:show-search="{ filter }"
:placeholder="'请选择' + item.label"
v-model:value="propsInfo.ruleForm.value[item.key]"
change-on-select
>
</a-cascader>
<a-checkbox
v-if="item.type === 'checkbox'"
v-model:checked="propsInfo.ruleForm.value[item.key]"
>
</a-checkbox>
<div v-if="item.type === 'tag'" class="table-css">
<a-tag :color="propsInfo.ruleForm.value[item.key] ? 'green' : 'red'">
{{ item.list[propsInfo.ruleForm.value[item.key]] }}
</a-tag>
</div>
<!-- </a-col>-->
<!-- <a-button v-if="item.type === 'btn'" @click="btnClick(item)">{{ item.title }}</a-button> -->
<div v-if="item.type === 'table'" class="table-css">
<slot :name="item.type" v-bind="item"></slot>
</div>
<div v-if="item.type === 'treetable'" class="table-css">
<slot :name="item.type" v-bind="item"></slot>
</div>
<div v-if="item.type === 'slot'">
<slot
:name="item.slotName"
v-bind="{ ...item, ...propsInfo.ruleForm.value }"
></slot>
</div>
</a-form-item>
</div>
</template>
<!-- <a-form-item
v-for="item in items.list"
:key="item.key"
:label="item.label"
:name="item.key"
:class="[item.colStatus ? 'item-width' : 'form-item']"
> -->
</a-form>
</div>
</a-card>
</div>
</template>
<script setup>
import { UserOutlined, InfoCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue'
import {
ref,
reactive,
defineProps,
defineEmits,
watch,
toRefs,
onMounted,
defineExpose
} from 'vue'
import { TreeSelect } from 'ant-design-vue'
import iconfonts from '../assets/iconfont/iconfont.json'
import validateRulesObj from '../utils/decorator'
const iconList = iconfonts.glyphs
const formRef = ref()
const props = defineProps({
items: {
type: Object,
required: () => []
},
formRules: {
type: Object
},
ruleForm: {
type: Object
},
disabled: {
type: Boolean
},
type: {
type: Boolean,
default: false
}
})
const propsInfo = toRefs(props)
const exposeRuleForm = propsInfo.ruleForm.value
onMounted(() => {})
const emit = defineEmits(['handlerClick'])
const data = reactive({
validateRulesObj,
newRuleForm: {},
// : {},
key: 0,
tableIndex: null,
tableInfo: [],
// tableIndex: 0,
mockData: [{}],
targetKeys: [],
// 单选-树节点
treeRadioValue: null,
treeData: [
{ id: 1, pId: 0, value: '1', title: 'Expand to load' },
{ id: 2, pId: 0, value: '2', title: 'Expand to load' },
{ id: 3, pId: 0, value: '3', title: 'Tree Node', isLeaf: true }
],
treeCheckValue: null,
SHOW_PARENT: TreeSelect.SHOW_PARENT,
loading: false,
imageUrl: ''
})
const extraInformation = ref(
'Cron表达式由6个(或7个)字段组成,分别表示秒、分、小时、月中的日期、月份、星期中的日期(以及可选的年份)。每个字段可以包含以下字符:·星号(*):表示该字段可以接受任何值、·问号(?):通常用于""星期”字段,表示不指定值,即表示“无特定值”。·连字符(-):用于指定范围,如"10-12表示101112·逗号():用于指定多个值MON,WED,FRI表示星期一星期三和星期五·斜杠(/):0/15015·L:""()W:()15W15#:6#3Cron:"0012**?12'
)
watch(
() => props.formRules,
(nVal, o) => {
for (const key in nVal) {
nVal[key].forEach((item) => {
if (item.validatorType) {
item.validator = data.validateRulesObj[item.validatorType]?.rules[0].validator
}
})
}
},
{ deep: true, immediate: true }
)
function checkTree(checkedKeys, e) {}
// 按钮的点击事件
function btnClick(item) {
emit('handlerClick', item)
}
function confirm() {
return new Promise((resolve, reject) => {
if (formRef.value) {
formRef.value
.validate()
.then(() => {
resolve(true)
})
.catch((error) => {
console.log('error', error)
resolve(false)
})
}
})
}
function handleReset() {
if (formRef.value) {
formRef.value.resetFields()
}
}
function switchChange(checked, switchItem) {
propsInfo.ruleForm.value[switchItem.key] = checked
}
function RadioChange(e, radioItem) {
const { value } = e.target
propsInfo.ruleForm.value[radioItem.key] = value
}
function transferChange(targetKeys, transferItem) {
data.targetKeys = targetKeys
propsInfo.ruleForm.value[transferItem.key] = data.targetKeys
}
function transferSearch(dir, value) {}
// 单选-树节点
function genTreeNode(parentId, isLeaf = false) {
const random = Math.random().toString(36).substring(2, 6)
return {
id: random,
pId: parentId,
value: random,
title: isLeaf ? 'Tree Node' : 'Expand to load',
isLeaf
}
}
function onLoadTree(treeNode) {
return new Promise((resolve) => {
const { id } = treeNode.dataRef
setTimeout(() => {
data.treeData = data.treeData.concat([
data.genTreeNode(id, false),
data.genTreeNode(id, true)
])
resolve()
}, 300)
})
}
function treeChange(key, value, node, extra) {
propsInfo.ruleForm.value[key] = value
}
// 级联选择器
function cascaderChange(value, cascaderItem) {
propsInfo.ruleForm.value[cascaderItem.key] = value
}
function filter(inputValue, path) {
return path.some((option) => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1)
}
function avatarUploadChange(info) {
if (info.file.status === 'uploading') {
data.loading = true
return
}
if (info.file.status === 'done') {
getBase64(info.file.originFileObj, (imageUrl) => {
data.imageUrl = imageUrl
data.loading = false
})
}
}
function onFieldsChange() {}
function handleSubmit() {}
function getBase64(img, callback) {
const reader = new FileReader()
reader.addEventListener('load', () => callback(reader.result))
reader.readAsDataURL(img)
}
// 主动暴露方法
defineExpose({
confirm,
handleReset,
ruleForm: exposeRuleForm
})
</script>
<style lang="scss" scoped>
.allHeight {
height: 100%;
}
.card-content:first-child {
margin-top: 0px;
}
.card-content {
margin-top: 15px;
}
:deep(.ant-timeline) {
color: var(--theme-text-default) !important;
.ant-timeline-item-tail {
border-inline-start: 2px solid var(--theme-text-default) !important;
}
}
:deep(.ant-form-item .ant-form-item-label > label) {
color: var(--theme-text-default) !important;
}
.info-title {
font-size: 18px;
font-weight: 530;
color: var(--theme-text-default);
text-align: left;
border-bottom: 1.5px solid var(--theme-bg);
margin-bottom: 20px;
.box {
color: #fff;
width: 230px;
display: flex;
align-items: center;
margin-bottom: 10px;
border-bottom: 5px solid transparent;
border-image: url('../assets/boxBottom.png') 0 0 100% 0 stretch;
div:last-child {
height: 25px;
line-height: 25px;
}
}
:deep(.a-tooltip) {
color: var(--theme-text3);
}
:deep(.ant-divider) {
color: var(--theme-bg);
}
}
// :deep(.ant-table-wrapper) {
// :deep(.ant-input) {
// background: red !important;
// }
// }
.title-none {
display: none;
}
:deep(.ant-card) {
background-color: transparent;
}
:deep(.ant-card-body) {
padding: 15px;
height: 100%;
border-radius: 8px;
.ant-form {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
height: 100%;
.item-l,
.item-div {
height: 100%;
}
}
}
.ant-card-bordered {
border: none;
}
.info-content {
height: calc(100% - 30px);
.info-form {
.item-div {
width: 45%;
display: inline-block;
}
.item-l {
width: 100%;
}
.form-item {
width: 320px !important;
}
}
}
:deep(.ant-form-item-label) {
color: #fff;
font-size: 16px !important;
width: 100px;
}
:deep(.ant-form-item-control-wrapper) {
flex: 1;
}
.editable-row-operations a {
margin-right: 8px;
}
// 表格中的按钮
:deep(.ant-table-cell) {
.ant-btn {
height: 24px !important;
color: #fff;
}
.ant-btn-dangerous {
background: var(--theme-btn2) !important;
}
.btn-del {
background: var(--theme-btn2);
}
.btn-add {
background: var(--theme-btn3);
}
.btn-upload,
.btn-downTemplate {
background: var(--theme-btn1);
}
}
:deep(.ant-calendar-picker) {
width: 100% !important;
}
:deep(.ant-picker) {
width: 100% !important;
}
:deep(.ant-input-number) {
width: 100% !important;
}
:deep(.ant-form-item.form-item) {
padding: 0px !important;
padding-right: 20px !important;
}
:deep(.ant-checkbox-disabled + span) {
color: var(--theme-text-default) !important;
}
:deep(textarea.ant-input) {
background-color: var(--theme-bg) !important;
border: none !important;
color: var(--theme-text-default) !important;
}
:deep(.ant-checkbox-wrapper) {
color: var(--theme-text-default);
}
</style>

View File

@@ -0,0 +1,420 @@
<template>
<div class="editCom">
<template v-for="(detailInfo, index) in detailInfos" :key="index">
<DetailInfo
:items="detailInfo"
:rule-form="detailInfo.ruleForm"
:form-rules="formRules"
:ref="'detailInfo' + index"
:disabled="disabled"
>
<template #role_id="item">
<a-select
:dropdown-match-select-width="false"
v-model:value="detailInfo.ruleForm[item.key]"
:placeholder="'请选择' + item.label"
:disabled="disabled"
allow-clear
>
<a-select-option
:value="selectItem.role_id"
v-for="selectItem in roleIdList"
:key="selectItem.role_id"
>
{{ selectItem.name }}
</a-select-option>
</a-select>
</template>
<template #treetable="item">
<TreeTable
:columns="item.columns"
:table-data="item.tableData"
ref="treeTable"
:transfer-dialog="transferDialog"
@handleDetailPagesizeChange="handleDetailPagesizeChange"
:table-option="{
checkStrictly: false,
selectTableData: item.selectTableData,
scroll: { y: 500 }
}"
>
<template #isQuery="record">
<a-tag :color="record.isQuery ? 'green' : 'red'">{{
record.isQuery ? '启用' : '禁用'
}}</a-tag>
</template>
<template #isEdit="record">
<a-tag :color="record.isEdit ? 'green' : 'red'">{{
record.isEdit ? '启用' : '禁用'
}}</a-tag>
</template>
<template #isControl="record">
<a-tag :color="record.isControl ? 'green' : 'red'">{{
record.isControl ? '启用' : '禁用'
}}</a-tag>
</template>
</TreeTable>
</template>
</DetailInfo>
</template>
<div style="display: flex; justify-content: center; gap: 20px">
<a-button @click="handleback">取消</a-button>
<a-button @click="handleConfirm" type="primary" :disabled="disabled">确认</a-button>
</div>
</div>
</template>
<script>
import {
userOptions,
userFormRules,
roleOptions,
roleFormRules,
stationOptions,
stationFormRules,
deviceOptions,
deviceFormRules,
alarmlogOptions
} from '../../public/config/columnList'
import DetailInfo from './DetailInfo.vue'
import { postReq, getReq } from '@/request/api'
const dictionary = {
menu: '菜单',
file: '文件',
role: '角色',
permission: '权限',
account: '账户',
log: '日志',
server: '服务',
computer: '主机'
}
export default {
name: '',
components: { DetailInfo },
props: {
action: {
type: String,
default: ''
},
type: {
type: String,
default: ''
},
record: {
type: Object,
default: () => {}
}
},
data() {
return {
tip: '正在加载...',
roleIdList: [],
transferDialog: false,
detailInfos: [],
disabled: true,
formRules: {},
apiMethods: {
// menu: 'menuConfirm',
// permission: 'permissionConfirm',
user: 'userConfirm',
role: 'roleConfirm',
device: 'deviceConfirm'
},
form: {},
ObjInfo: {},
loading: false
}
},
computed: {},
watch: {
action: {
handler(n) {
if (n === 'read') {
this.disabled = true
} else {
this.disabled = false
}
},
immediate: true
},
type: {
async handler(n) {
switch (n) {
case 'user':
this.detailInfos = userOptions
this.formRules = userFormRules
break
case 'menu':
// this.detailInfos = menuOptions
// this.formRules = menuFormRules
break
case 'permission':
// this.detailInfos = permissionOptions
// this.formRules = permissionFormRules
break
case 'role':
this.detailInfos = roleOptions
this.formRules = roleFormRules
break
case 'station':
this.detailInfos = stationOptions
this.formRules = stationFormRules
break
case 'device':
this.detailInfos = deviceOptions
this.formRules = deviceFormRules
break
case 'alarmLog':
this.detailInfos = alarmlogOptions
this.formRules = {}
break
default:
break
}
},
immediate: true
}
},
mounted() {
this.getRoleIdList()
},
methods: {
async getRoleIdList() {
const params = {
page_size: 1000,
page: 1
}
try {
const res = await getReq('/queryRoleList', params)
if (res.errcode === 0) {
this.roleIdList = res.data
} else {
const err = { tip: res.errmsg }
throw err
}
} catch (error) {
this.roleIdList = []
//统一处理报错提示
}
},
handleChange(value) {
this.ip = ''
this.selectComputer = value.option
this.selectComputer.id = value.option.value
this.ipList = this.getIpOptions(this.selectComputer.id)
},
handleDetailPagesizeChange(val) {
this.detailInfos[val[1]].list[0].detailPaginationOption = {
...this.detailInfos[val[1]].list[0].detailPaginationOption,
...val[0]
}
if (this.detailInfos[val[1]].list[0].key === 'servebiaoge') {
// 应用信息中消息模板需要通过接口调用数据
let arr = {
ids: this.clickId,
pageIndex: val[0].current,
pageSize: val[0].pageSize
}
}
},
handleRemove(file) {
const index = this.fileList.indexOf(file)
this.fileList.splice(index, 1)
},
beforeUpload(file, fileList) {
this.fileList = [...this.fileList, file]
return false
},
// 调用子组件的表单的方法
async handleConfirm() {
const result = []
const { length } = this.detailInfos
for (let index = 0; index < length; index++) {
// 校验规则
const res = await this.$refs[`detailInfo${index}`][0].confirm()
result.push(res)
if (!res) {
break
}
}
if (result.every((item) => item == true)) {
this.handleSubmit()
}
},
handleSubmit() {
const { length } = this.detailInfos
let form = {}
for (let index = 0; index < length; index++) {
if (this.$refs[`detailInfo${index}`][0].ruleForm) {
form = Object.assign(this.$refs[`detailInfo${index}`][0].ruleForm, form)
} else {
console.log('对象为空')
}
}
this.form = form
eval('this.' + this.apiMethods[this.type] + '()')
},
async userConfirm() {
try {
const menuApi = {
add: '/insertUser',
edit: '/updateUser'
}
const paramsDate = {
...this.form
}
if (this.action == 'edit') {
paramsDate.user_id = this.record.user_id
}
const res = await postReq(menuApi[this.action], paramsDate)
if (res.errcode === 0) {
setTimeout(() => {
this.handleback()
}, 1000)
} else {
throw res
}
} catch (error) {
console.log(error, 'userConfirm')
}
},
async roleConfirm() {
try {
const menuApi = {
add: '/insertRole',
edit: '/deleteRole'
}
const paramsDate = {
...this.form
}
if (this.action == 'edit') {
paramsDate.role_id = this.record.role_id
}
const res = await postReq(menuApi[this.action], paramsDate)
if (res.errcode === 0) {
setTimeout(() => {
this.handleback()
}, 1000)
} else {
throw res
}
} catch (error) {
console.log(error, 'roleConfirm')
}
},
async stationConfirm() {
try {
const menuApi = {
add: '/insertStation',
edit: '/updateStation'
}
const paramsDate = {
...this.form
}
if (this.action == 'edit') {
paramsDate.station_id = this.record.station_id
}
const res = await postReq(menuApi[this.action], paramsDate)
if (res.errcode === 0) {
setTimeout(() => {
this.handleback()
}, 1000)
} else {
throw res
}
} catch (error) {
console.log(error, 'stationConfirm')
}
},
async deviceConfirm() {
try {
const menuApi = {
add: '/insertDevice',
edit: '/updateDevice'
}
const { is_open, rated_capacity, rated_current, rated_voltage, reted_power } = this.form
const paramsDate = {
...this.form,
is_open: Number(is_open),
attrs: JSON.stringify({rated_capacity, rated_current, rated_voltage, reted_power})
}
if (this.action == 'edit') {
paramsDate.device_id = this.record.device_id
}
const res = await postReq(menuApi[this.action], paramsDate)
if (res.errcode === 0) {
this.$message.success('添加成功')
setTimeout(() => {
this.handleback()
}, 1000)
} else {
throw res
}
} catch (error) {
this.$message.error('添加失败')
}
},
handleback() {
this.$emit('operateForm', 'back')
},
getObjIds(selectKeys) {
const ids = []
for (let i = 0; i < selectKeys.length; i++) {
ids.push({ id: selectKeys[i] })
}
return ids
}
}
}
</script>
<style lang="scss" scoped>
.editCom {
// height:400px;
}
.ant-upload-select-picture-card i {
font-size: 32px;
color: #999;
}
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
}
.detail-header {
display: flex;
span,
div {
margin: 10px;
}
}
:deep(.ant-picker) {
color: var(--theme-text-default) !important;
}
</style>

View File

@@ -132,7 +132,7 @@ export default {
station_id: this.stationId,
category: 0
}
const res = await getReq('/api/queryStatTotal', query)
const res = await getReq('/queryStatTotal', query)
if (res.errcode === 0) {
this.modalInfo.allTotal = res.data
this.modalInfo.allTotal.runDays = getRunDays(res.data.launch_date)
@@ -153,7 +153,7 @@ export default {
const query = {
station_id: this.stationId,
}
const res = await getReq('/api//queryStationInfo', query)
const res = await getReq('//queryStationInfo', query)
if (res.errcode === 0) {
this.modalInfo.prefabTotal = res.data
} else {
@@ -177,7 +177,7 @@ export default {
end_date: getDateDaysAgo(0)
}
const categoryObj = { 1: 'energy' }
const res = await getReq('/api/queryStatDayList', query)
const res = await getReq('/queryStatDayList', query)
if (res.errcode === 0) {
this.modalInfo[categoryObj[category]] = res.data.map((item) => {
const { income_charge: incomeCharge, income_elect: incomeElect } = item

View File

@@ -6,8 +6,9 @@
v-for="item in operateList"
:key="item.type"
type="primary"
style="margin-right: 5px"
:class="['operateCol', item.type]"
size="small"
style="margin-right: 10px"
:class="`btn-${item.type}`"
:disabled="item.disabled"
@click="munuClick(item.type)"
>{{ item.label }}
@@ -59,49 +60,7 @@ export default {
</script>
<style lang="scss" scoped>
.moreIcon{
color:#fff !important
}
:deep(.ant-btn) {
padding: 0px 7px !important;
height: 24px !important;
font-size: 13px !important;
letter-spacing: -1px;
border-radius: 4px;
& > span + .anticon {
margin-inline-start: 4px;
}
}
:deep(.ant-btn-primary) {
box-shadow: none !important;
background: var(--theme-btn3);
}
:deep(.ant-btn,.ant-btn-primary){
&:hover{
opacity: 0.9;
}
&:disabled{
color: rgba(255,255,255,0.5);
}
}
.operate{
display: flex;
justify-content: center;
}
.operateCol {
background: var(--theme-btn3);
&.more {
background: var(--theme-btn1);
}
&.del {
background: var(--theme-btn2);
}
}
.ant-dropdown .ant-dropdown-menu{
background-color:var(--theme-opert-bg)!important;
}
</style>

View File

@@ -192,6 +192,7 @@ input:-internal-autofill-selected {
color: var(--theme-text-default) !important;
}
.search {
height:70px;
color: #fff;
display: flex;
flex-direction: column;

View File

@@ -1,58 +1,89 @@
<template>
<div class="device">
<div class="device" ref="device">
<div class="device-item" v-for="item in deviceList" :key="item">
<div class="item-header">
<div style="display: flex; width: 50%">
<div class="icon-bg"></div>
<div class="icon-bg">
<span class="iconfont" :class="getIcongont(item)"></span>
</div>
<div class="title">
<span class="number">521245786665412</span>
<span class="name">逆变器1</span>
<span class="number type">逆变器</span>
<span class="number">{{ item.device_id }}</span>
<span class="name">{{ item.name }}</span>
<span class="number type">{{ item.typename }}</span>
</div>
</div>
<div class="status">
<div class="status-item">
<span>在线</span>
<span>{{ ['离线', '在线'][item.is_online] }}</span>
<span class="text">在线状态</span>
</div>
<div class="status-item">
<span>在线</span>
<span>{{ ['正常', '错误'][item.is_error] }}</span>
<span class="text">故障状态</span>
</div>
<div class="status-item">
<span>在线</span>
<span>{{ ['空闲', '工作'][item.is_running] }}</span>
<span class="text">工作状态</span>
</div>
</div>
</div>
<div class="item-content">
<div v-for="info in chunengInfo" :key="info.key">
<span class="text">{{ info.label }}</span>
<a-button
v-if="info.key === 'realTimeData'"
type="primary"
size="small"
@click="openModal"
>查看</a-button
>
<span v-else class="value">{{ info.value }}</span>
<div v-for="info in item.params" :key="info.k" class="item-info">
<span class="text">{{ info.k }}</span>
<span class="value">{{ info.v }}</span>
</div>
</div>
<div v-if="item.view == 1" class="item-button">
<span class="text">实时数据</span>
<a-button type="primary" size="small" @click="openModal(item)">查看</a-button>
</div>
</div>
<a-modal v-model:open="modalOpen" @ok="handleOk" width="800px">
<!-- <p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p> -->
<a-modal
v-model:open="modalOpen"
@ok="handleOk"
width="90%"
class="modal-device"
:get-container="() => $refs.device"
>
<div>
<div class="title">
<div>电流电压</div>
<img src="@/assets/images/titleLine.png" alt="" />
</div>
<div class="echarts">
<predictEcharts
:chart-options="chartOptions[0]"
:chart-data="chartData"
ref="chartRef1"
/>
</div>
</div>
<div>
<div class="title">
<div>功率</div>
<img src="@/assets/images/titleLine.png" alt="" />
</div>
<div class="echarts">
<predictEcharts
:chart-options="chartOptions[1]"
:chart-data="chartData"
ref="chartRef2"
/>
</div>
</div>
</a-modal>
</div>
</template>
<script>
import predictEcharts from '@/components/predict/predictEcharts.vue'
import { postReq, getReq } from '@/request/api'
import { deviceTypeList } from '@/utils/config'
export default {
name: '',
components: {},
components: { predictEcharts },
props: {
stationId: {
type: String,
@@ -79,7 +110,70 @@ export default {
{ label: '实时数据', key: 'realTimeData', value: '0.01kWh' },
{ label: '额定功率', key: 'ratedPower', value: '0.01kW' },
{ label: '冷却方式', key: 'coolingMethod', value: '风冷' }
]
],
chartOptions: [
{
type: 'line',
smooth: true,
dataKey: 'chargeDischarge',
infoKeys: [
{
key: 'V',
label: '电压',
seriesOptions: {
symbol: 'circle',
symbolSize: 8,
itemStyle: {
color: '#00FDF9' // 充电电量线条颜色
},
lineStyle: {
color: '#00FDF9' // 充电电量线条颜色
}
}
},
{
key: 'I',
label: '电流',
seriesOptions: {
symbol: 'circle',
symbolSize: 8,
itemStyle: {
color: '#3E7EEF' // 充电电量线条颜色
},
lineStyle: {
color: '#3E7EEF' // 充电电量线条颜色
}
}
}
]
},
{
type: 'line',
smooth: true,
dataKey: 'chargeDischarge',
infoKeys: [
{
key: 'P',
label: '功率',
seriesOptions: {
symbol: 'circle',
symbolSize: 8,
itemStyle: {
color: '#00FDF9' // 充电电量线条颜色
},
lineStyle: {
color: '#00FDF9' // 充电电量线条颜色
}
}
}
]
}
],
chartData: {
xdata: [],
ydata: {}
}
}
},
watch: {
@@ -99,24 +193,65 @@ export default {
this.getDeviceList()
},
methods: {
async getDeviceList() {
const data = {
category: this.systemType,
'station_id': this.stationId,
page: 0,
'page_size': 1000
}
try {
const res = await getReq('/queryDeviceList', data)
getIcongont(ele) {
return deviceTypeList.find((item) => item.value == ele.type).iconfont || ''
},
generateTimePoints() {
const timePoints = []
for (let hour = 0; hour <= 24; hour++) {
for (let minute = 0; minute < 60; minute += 10) {
// 处理24:00的特殊情况
if (hour === 24 && minute === 0) {
timePoints.push('24:00')
break
}
// 格式化小时和分钟,确保两位数
const formattedHour = hour.toString().padStart(2, '0')
const formattedMinute = minute.toString().padStart(2, '0')
timePoints.push(`${formattedHour}:${formattedMinute}`)
}
}
return timePoints
},
//查看实时数据
async getDevicCharts(item) {
try {
const res = await getReq('/queryDevicCharts', {
station_id: this.stationId,
device_id: item.device_id
})
this.chartData.ydata = res.data
this.chartData.xdata = this.generateTimePoints()
this.$refs.chartRef1.initCharts()
this.$refs.chartRef2.initCharts()
console.log(res)
this.deviceList = res.data
// this.selectStation=this.stations[0]['station_id']
} catch (error) {
console.log(error)
}
},
openModal() {
//请求运行监控系统设备信息
async getDeviceList() {
try {
const res = await getReq('/queryDevicByCategory', {
station_id: this.stationId,
category: this.systemType
})
this.deviceList = res.data
} catch (error) {
this.deviceList = []
console.log(error)
}
},
async openModal(item) {
await this.getDevicCharts(item)
this.modalOpen = true
},
handleOk() {
@@ -136,8 +271,6 @@ export default {
grid-template-columns: 1fr 1fr 1fr;
overflow-y: auto;
.device-item {
// width: 410px;
// height: 340px;
border-radius: 15px;
background: $bg2-color;
@@ -149,11 +282,16 @@ export default {
color: #fff;
justify-content: space-between;
.icon-bg {
width: 76px;
height: 72px;
width: 66px;
height: 66px;
text-align: center;
line-height: 66px;
border-radius: 6px;
background: linear-gradient(90deg, #3dfefa 0%, #2a82e4 2.96%, #27a188 100%),
linear-gradient(90deg, #3dfefa 0%, #01dfef 2.96%, #08a5ff 100%);
.iconfont {
font-size: 50px;
}
}
.title {
display: flex;
@@ -194,12 +332,20 @@ export default {
grid-template-columns: 1fr 1fr;
color: #fff;
display: grid;
line-height: 45px;
// line-height: 45px;
margin-top: 15px;
padding: 0 10px;
height: 120px;
overflow-y: auto;
.value {
font-weight: 700;
}
.item-info {
height: 30px;
}
}
.item-button {
padding-left: 10px;
}
.text {
color: $text-color;
@@ -212,4 +358,22 @@ export default {
.environment {
width: 200px;
}
:deep(.modal-device) {
color: #fff;
.title {
display: flex;
font-weight: 700;
flex-direction: column;
img {
width: 232px;
height: 6px;
margin-top: 10px;
}
}
.echarts {
width: 100%;
height: 280px;
}
}
</style>

View File

@@ -32,13 +32,12 @@
</div>
<div class="table-content">
<ComTable
:columns="columns"
:table-data="tableData"
:columns="columns[activeTab]"
:table-data="tableDatas[activeTab]"
@handlePagesizeChange="handlePagesizeChange"
ref="comTable"
:table-option="tableOption"
:page-option="pageOption"
:table-h="tableH"
>
</ComTable>
</div>
@@ -46,65 +45,143 @@
</template>
<script>
import { postReq, getReq } from '@/request/api'
export default {
name: '',
components: {},
props: {},
props: {
stationId: {
type: String,
default: ''
},
systemType: {
type: Number,
default: 1
}
},
data() {
return {
activeTab: '0',
activeTab: 'temp_hum',
columns: {
airc: [
{
title: '名称',
dataIndex: 'pos',
key: 'pos',
ellipsis: true,
align: 'center'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
ellipsis: true,
align: 'center'
}
],
cooling: [
{
title: '名称',
dataIndex: 'pos',
key: 'pos',
ellipsis: true,
align: 'center'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
ellipsis: true,
align: 'center'
}
],
fire40: [
{
title: '点位',
dataIndex: 'pos',
key: 'pos',
ellipsis: true,
align: 'center'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
ellipsis: true,
align: 'center'
}
],
'temp_hum': [
{
title: '点位',
dataIndex: 'pos',
key: 'pos',
ellipsis: true,
align: 'center'
},
{
title: '温度',
dataIndex: 'temp',
key: 'temp',
ellipsis: true,
align: 'center'
},
{
title: '湿度',
dataIndex: 'hum',
key: 'hum',
ellipsis: true,
align: 'center'
}
]
},
tabList: [
{
key: '0',
key: 'temp_hum',
name: '环境温湿度信息'
},
{
key: '1',
key: 'fire40',
name: '安防信息'
},
{
key: '2',
key: 'airc',
name: '空调信息'
},
{
key: '3',
key: 'cooling',
name: '冷机信息'
}
],
columns: [
{
title: '点位',
dataIndex: 'policyId',
key: 'policyId',
ellipsis: true
},
{
title: '温度',
dataIndex: 'name',
key: 'name',
ellipsis: true
},
{
title: '湿度',
dataIndex: 'type',
key: 'type',
ellipsis: true
}
],
tableDatas: {},
tableOption: {
select: false,
page: false
}
}
},
mounted() {},
methods: {}
mounted() {
this.getEnvironment()
},
methods: {
async getEnvironment() {
try {
const res = await getReq('/queryEnvironment', { station_id: this.stationId })
console.log(res, '==============')
this.tableDatas = res.data
// this.deviceList=res.data
} catch (error) {
console.log(error)
}
}
}
}
</script>
<style lang="scss" scoped>
.videos {
width: 60%;
width: calc(100% - 470px);
margin-left: 20px;
display: grid;
grid-gap: 20px;
@@ -130,7 +207,7 @@ export default {
}
}
.environment {
width: calc(40% - 20px);
width: 430px;
margin-left: 20px;
color: #fff;
@@ -187,6 +264,7 @@ export default {
}
.table-content {
margin-top: 20px;
height: calc(100% - 60px);
:deep(.ant-table) {
border-radius: 10px 10px 0 0 !important;
overflow: hidden; /* 确保圆角生效 */

View File

@@ -1,16 +1,17 @@
<template>
<div class="echarts">
<div class="chart-container">
<div class="content-header">
<div class="chart-container" >
<div class="content-header" v-if="chartOptions.title">
<div class="verline"></div>
<span>{{ chartOptions.title }}</span>
</div>
<!-- {{ chartData.ydata }} -->
<div ref="chartContainer" class="echarts-content"></div>
</div>
</div>
</template>
<script>
import { postReq } from '@/request/api'
export default {
name: 'PredictEcharts',
props: {
@@ -20,8 +21,8 @@ export default {
required: false // 非必须
},
chartData: {
type: Array,
default: () => ([]), // 默认空对象
type: Object,
default: () => ({}), // 默认空对象
required: false // 非必须
}
},
@@ -32,12 +33,11 @@ export default {
},
mounted() {
this.$nextTick(() => {
// 确保 DOM 完全渲染
this.initCharts()
window.addEventListener('resize', this.handleResize)
})
// this.$nextTick(() => {
// // 确保 DOM 完全渲染
// this.initCharts()
// window.addEventListener('resize', this.handleResize)
// })
},
beforeUnmount() {
window.removeEventListener('resize', this.handleResize)
@@ -45,8 +45,7 @@ export default {
},
methods: {
initCharts() {
// this.chartOptions.forEach((option, index) => {
const {title,infoKeys,dataKey,type,smooth}=this.chartOptions
const {infoKeys,dataKey,type,smooth}=this.chartOptions
const dom = this.$refs.chartContainer
if (!dom) return
@@ -73,12 +72,29 @@ export default {
grid: {
left: '3%',
right: '3%',
bottom: '1%',
bottom: '15%',
containLabel: true
},
dataZoom: [
{
type: 'slider', // 滑动条型
show: true,
xAxisIndex: 0, // 控制第一个X轴
start: 0, // 初始显示范围起点(百分比)
end: 20, // 初始显示范围终点(百分比)
height: 20, // 滑动条高度
bottom: 10 // 距离底部距离
},
{
type: 'inside', // 内置型(鼠标滚轮/拖拽交互)
xAxisIndex: 0,
start: 0,
end: 20
}
],
xAxis: {
type: 'category',
data: this.chartData.map((item) => item.date),
data: this.chartData.xdata,
axisLine: {
show: true,
lineStyle: {
@@ -122,7 +138,7 @@ export default {
name: info.label,
smooth: smooth || false,
type: type,
data: this.chartData.map((item) => item[info.key]),
data: this.chartData.ydata[info.key],
...info.seriesOptions,
}
})

View File

@@ -347,7 +347,11 @@ export default {
changePolicy(e) {
const val = e.target.value
if (val == 1) {
this.formData.period5.splice(1,1)
// const {length} = this.formData.period5
// this.formData.period5.splice(1,1)
this.formData.period1=[]
} else {
this.formData.period5[1] =
{
@@ -477,11 +481,13 @@ export default {
this.$refs.periodRef
.validateFields()
.then((res) => {
console.log(this.formData.period1)
console.log(this.formData.period1,'=============')
const target = this.formData.period1.find((item) => item.month == this.periodForm.month)
if (target) {
target.children.push(this.periodForm) // 如果找到,放入 children
}else{
this.formData.period1.push(this.periodForm)
}
// this.formData.period1.push(this.periodForm)
@@ -636,6 +642,9 @@ export default {
:deep(.no-hover-row:hover > td) {
background-color: transparent !important;
}
:deep(.ant-table-wrapper .ant-table-cell){
background:none!important;
}
// /* 禁用行的 hover 过渡动画 */
// .ant-table-tbody > tr.ant-table-row {
// transition: none !important;