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.

355 lines
8.9 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
<div class="flexTimeGz">
<p class="timeGz" v-for="(val, index) in ruleSchedule" :key="index">
<span>{{ val.startTime }}</span> ~
<span>{{ val.endTime }}</span>
间隔<b>{{ val.span }}分钟</b>
</p>
</div>
<h3>设置通道</h3>
2 years ago
<div class="chooseTDBox">
2 years ago
<label>选择通道:</label>
2 years ago
<div class="checkBox">
2 years ago
<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>
<div class="flexnr" v-loading="loading" v-if="newzzList.length !== 0">
2 years ago
<el-tree
:data="newzzList"
show-checkbox
:props="defaultProps"
ref="tree"
node-key="id"
:default-expand-all="true"
2 years ago
@check="getCheckedNodes"
2 years ago
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ data.name }}</span>
<span v-if="data.list == ''" class="zzdown"> </span>
</span>
</el-tree>
</div>
<div class="flexnr" v-else>
<p class="nochannel">暂无通道</p>
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,
2 years ago
getTermListByChannelJoggle,
2 years ago
} 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
},
2 years ago
termidArr: [],
ruleid: "",
2 years ago
parmsList: [], //选中的通道
multipleSelection: [],
2 years ago
//新是数据结构参数
newzzList: [],
2 years ago
zzListCheck: [],
loading: false,
2 years ago
2 years ago
//全选
checkAll: true,
isIndeterminate: true, //全选设置默认选中
2 years ago
timer: null,
termidArrNum: -1,
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
//选择通道
2 years ago
handleChange() {
console.log(this.checkedAisle);
this.loading = true;
2 years ago
getTermListByChannelJoggle({
id: this.checkedAisle,
})
.then((res) => {
console.log(res);
this.newzzList = res.data.list;
2 years ago
console.log(this.listnr);
console.log(this.newzzList);
console.log(this.zzListCheck);
this.loading = false;
2 years ago
})
.catch((err) => {});
2 years ago
},
handleCheckBox() {
console.log(this.zzListCheck);
},
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) => {
2 years ago
if (item.list == undefined) {
console.log("1111111111111");
console.log(item);
this.termidArr.push(item.id);
}
2 years ago
// 父节点结构的情况 判断是否有list子节点如果有定义数组结构
// if (item.list !== undefined) {
// index++;
// this.parmsList[index] = {
// //name: item.name,
// termid: item.id,
// channelidlist: [],
// };
// console.log(item);
// } else {
// console.log("aaaaaaaaaaaaaa");
// //如果没有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 {
2 years ago
termid: this.termidArr[0],
channelidlist: [this.checkedAisle],
};
});
2 years ago
this.termidArr = Array.from(new Set(this.termidArr));
console.log(this.termidArr);
console.log(this.parmsList);
return this.parmsList;
2 years ago
},
2 years ago
2 years ago
// 保存确定操作
submitForm() {
2 years ago
console.log(this.termidArr);
this.timer = window.setInterval(() => {
this.termidArrNum++;
console.log(this.termidArrNum);
if (this.termidArrNum < this.termidArr.length) {
this.sureSum();
} else {
2 years ago
this.$message({
showClose: true,
message: "添加成功",
type: "success",
});
2 years ago
this.isShow = false;
this.$parent.deviceList();
clearTimeout(this.timer);
}
}, 1000);
},
//时间表
sureSum() {
setScheduleRulel({
list: [
{
termid: this.termidArr[this.termidArrNum],
channelidlist: [this.checkedAisle],
},
],
scheduleid: this.selid,
})
.then((res) => {
2 years ago
// this.$message({
// showClose: true,
// message: '添加成功',type: 'success'
// });;
})
2 years ago
.catch((err) => {
2 years ago
this.$message({
showClose: true,
message: "添加失败",
type: "error",
});
2 years ago
});
2 years ago
},
display() {
2 years ago
this.isShow = true;
2 years ago
},
hide() {
2 years ago
this.isShow = false;
2 years ago
clearTimeout(this.timer);
2 years ago
},
},
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
border: 1px solid #eee;
padding: 16px;
border-radius: 4px;
.dybox {
h4 {
font-size: 14px;
color: #333;
line-height: 24px;
font-weight: normal;
}
.xlbox {
h4 {
font-size: 14px;
color: #333;
line-height: 24px;
font-weight: normal;
}
margin-left: 16px;
.zzbox {
2 years ago
h4 {
}
.el-checkbox-group {
2 years ago
// display: flex;
// flex-direction: column;
2 years ago
margin-left: 22px;
.el-checkbox {
2 years ago
line-height: 28px;
//width: 196px;
.el-checkbox__label {
b {
margin-left: 18px;
font-weight: normal;
font-size: 12px;
}
}
}
}
}
}
}
.nochannel {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
2 years ago
}
2 years ago
}
.w50 {
width: 50px;
}
.setTimeTd {
h3 {
margin: 8px 0px;
font-size: 16px;
line-height: 24px;
}
2 years ago
.flexTimeGz {
display: flex;
flex-wrap: wrap;
.timeGz {
line-height: 32px;
margin-right: 16px;
b {
font-weight: normal;
color: #409eff;
}
span {
margin: 0px 8px;
}
2 years ago
}
}
2 years ago
.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;
2 years ago
margin-bottom: 8px;
2 years ago
label {
margin-right: 8px;
}
}
.treeTable {
margin-top: 16px;
}
2 years ago
}
</style>