You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

303 lines
7.8 KiB
Vue

2 years ago
<template>
2 years ago
<el-dialog
2 years ago
class="photoSetDialog"
2 years ago
title="设置"
:visible.sync="isShow"
:close-on-click-modal="false"
2 years ago
width="1020px"
2 years ago
>
<div class="setTimeTd">
2 years ago
<h3>时间表规则</h3>
2 years ago
<el-descriptions
title=""
:column="3"
border
v-for="(val, index) in ruleSchedule"
:key="index"
>
<el-descriptions-item label="开始时间">{{
val.startTime
}}</el-descriptions-item>
<el-descriptions-item label="结束时间">{{
val.endTime
}}</el-descriptions-item>
<el-descriptions-item
label="时间间隔(分)"
:contentStyle="contentStyle"
>
2 years ago
<el-tag size="small">{{ val.span }}</el-tag>
</el-descriptions-item>
</el-descriptions>
<h3>设置通道</h3>
2 years ago
<div class="chooseTDBox">
2 years ago
<label>选择通道:</label>
2 years ago
<div class="checkBox">
2 years ago
<!-- <el-checkbox-group v-model="checkedAisle" @change="handleChange">
<el-checkbox
:label="val.id"
border
v-for="val in aisleList"
:key="val.id"
>{{ val.name }}</el-checkbox
>
</el-checkbox-group> -->
<el-radio-group v-model="checkedAisle" @change="handleChange">
<el-radio
:label="val.id"
border
v-for="val in aisleList"
:key="val.id"
>{{ val.name }}</el-radio
>
</el-radio-group>
2 years ago
</div>
</div>
2 years ago
<div class="flexnr">
2 years ago
<!-- <div class="w50">通道:</div>
2 years ago
<el-tree
:data="listnr"
show-checkbox
:props="defaultProps"
ref="tree"
node-key="id"
:default-expand-all="true"
2 years ago
></el-tree> -->
2 years ago
</div>
2 years ago
</div>
2 years ago
<div slot="footer" class="dialog-footer">
2 years ago
<!-- <el-button @click="getCheckedNodes"></el-button> -->
2 years ago
<el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</template>
<script>
2 years ago
import {
setScheduleRulel,
getScheduleRulelAccessList,
} from "@/utils/api/index";
2 years ago
export default {
props: {
2 years ago
title: String,
2 years ago
},
data() {
return {
2 years ago
contentStyle: { width: "90px" },
2 years ago
isShow: false,
2 years ago
selid: 0, //选中时间表id
ruleSchedule: [], //时间表规则
checkedAisle: "", //选中通道数据
aisleList: [], //通道数据内容
listnr: [], //通道树状结构
2 years ago
defaultProps: {
2 years ago
children: "list",
label: "name",
2 years ago
},
ruleid: "",
2 years ago
parmsList: [], //选中的通道
tableData: [
{
2 years ago
id: 2,
date: "220kv",
name: "线路11",
address: "asdadadadad",
children: [
{
id: 31,
date: "220kv",
name: "线路11",
address: "asdadadadad",
},
{
id: 32,
date: "220kv",
name: "线路11",
address: "asdadadadad",
},
],
},
{
2 years ago
id: 3,
date: "220kv",
name: "线路11",
address: "asdadadadad",
children: [
{
id: 31,
date: "220kv",
name: "线路11",
address: "asdadadadad",
},
{
id: 32,
date: "220kv",
name: "线路11",
address: "asdadadadad",
},
],
},
],
multipleSelection: [],
2 years ago
//新是数据结构参数
newzzList: [],
2 years ago
};
},
2 years ago
mounted() {},
2 years ago
methods: {
//判断
2 years ago
getdataform(val) {
this.selid = val.id;
2 years ago
this.ruleSchedule = val.list;
console.log(this.ruleSchedule, "时间规则");
2 years ago
this.getlistnr();
2 years ago
},
//获取所有通道
2 years ago
getlistnr() {
getScheduleRulelAccessList({})
.then((res) => {
this.listnr = res.data.list;
2 years ago
this.aisleList = res.data.channellist;
2 years ago
})
.catch((err) => {});
2 years ago
},
2 years ago
//选择通道
2 years ago
handleChange() {
console.log(this.listnr);
console.log(this.checkedAisle);
this.newzzList = this.listnr.filter((item) => {
console.log(item);
});
console.log(this.newzzList);
2 years ago
this.$refs.tree.setCheckedKeys(this.checkedAisle);
},
//遍历数据
2 years ago
eachTreeData(data, callback, childKey) {
if (!childKey) childKey = "children";
data.forEach((d) => {
if (callback(d) !== false && d[childKey])
this.eachTreeData(d[childKey], callback, childKey);
});
2 years ago
},
//给树的每一个节点 添加一个唯一值key并算出默认选中的节点key数组
2 years ago
addKeyToList(data) {
2 years ago
let key = 0;
this.eachTreeData(data, (d) => {
2 years ago
d.key = key++;
});
2 years ago
},
2 years ago
//获取所选值
getCheckedNodes() {
2 years ago
this.parmsList = [];
const checkedNodes = this.$refs.tree.getCheckedNodes(false, true); //若节点可被选择,则返回目前被选中的节点所组成的数组
//const checkedParam = []; //定义选中的数组
let index = -1;
2 years ago
// console.log(checkedNodes);
if (checkedNodes.length !== 0) {
checkedNodes.forEach((item) => {
// 父节点结构的情况 判断是否有list子节点如果有定义数组结构
if (item.list !== undefined) {
index++;
this.parmsList[index] = {
//name: item.name,
termid: item.id,
channelidlist: [],
};
} else {
//如果没有list 把子节点id push到 定义的数组channelidlist中
this.parmsList[index].channelidlist.push(item.id);
}
//通过bsManufacturer 判断是否是 线路 获取线路id
2 years ago
// if (item.bsManufacturer !== undefined) {
// this.ruleid = item.id;
// console.log(this.ruleid);
// }
});
}
2 years ago
// console.log(this.parmsList);
//遍历删除没有channelichilddlist的数据只留下通道
this.parmsList = this.parmsList
.filter((item) => item.channelidlist.length !== 0)
.map((item) => {
return {
termid: item.termid,
channelidlist: item.channelidlist,
};
});
console.log(this.parmsList);
return this.parmsList;
2 years ago
},
2 years ago
2 years ago
// 保存确定操作
submitForm() {
2 years ago
this.getCheckedNodes();
if (this.parmsList.length == 0)
return this.$message.error("通道不能为空");
2 years ago
setScheduleRulel({ list: this.parmsList, ruleid: this.selid })
.then((res) => {
this.isShow = false;
this.$message.success("添加成功");
this.$parent.deviceList();
})
.catch((err) => {
this.$message.error("添加失败");
});
2 years ago
},
display() {
2 years ago
this.isShow = true;
2 years ago
},
hide() {
2 years ago
this.isShow = false;
},
},
2 years ago
};
</script>
2 years ago
<style lang="less">
.photoSetDialog {
2 years ago
.el-dialog__body {
// height: 360px;
// overflow: auto;
}
2 years ago
.flexnr {
2 years ago
height: 360px;
overflow: auto;
2 years ago
display: flex;
align-items: flex-start;
2 years ago
.el-tree {
flex: 1;
}
2 years ago
}
.w50 {
width: 50px;
}
.setTimeTd {
h3 {
margin: 8px 0px;
font-size: 16px;
line-height: 24px;
}
.setCheckbox {
.el-table__header .el-table-column--selection .cell .el-checkbox:after {
color: #333;
content: "全选";
font-size: 16px;
margin-left: 12px;
font-weight: bold;
}
}
}
2 years ago
.chooseTDBox {
display: flex;
align-items: center;
label {
margin-right: 8px;
}
}
.treeTable {
margin-top: 16px;
}
2 years ago
}
</style>