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.

128 lines
2.9 KiB
Vue

2 years ago
<template>
2 years ago
<el-dialog
class="addLineDialog"
title="设置"
:visible.sync="isShow"
:close-on-click-modal="false"
width="40%"
>
<el-form
label-position="left"
ref="formInfo"
label-width="100px"
:rules="rules"
:model="formdata"
>
2 years ago
<el-form-item label="通道:" prop="name">
2 years ago
<el-tree
:data="listnr"
show-checkbox
:props="defaultProps"
ref="tree"
node-key="id"
:default-expand-all="true"
@check-change="handleCheckChange"
></el-tree>
2 years ago
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="getCheckedNodes"></el-button>
<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 {
isShow: false,
formdata: {},
rules: {
2 years ago
name: [{ required: true, message: "请选择通道", trigger: "blur" }],
2 years ago
},
listnr: [],
defaultProps: {
2 years ago
children: "list",
label: "name",
2 years ago
},
2 years ago
selid: 0,
2 years ago
};
},
mounted() {
2 years ago
this.getlistnr();
2 years ago
},
methods: {
//判断
2 years ago
getdataform(val) {
this.selid = val.id;
2 years ago
// if (val==null) {
// return this.formdata = {}
2 years ago
// }
2 years ago
// this.formdata = val
// this.$set(this.formdata,'time',[val.startTime, val.endTime])
},
//获取所有通道
2 years ago
getlistnr() {
getScheduleRulelAccessList({})
.then((res) => {
this.listnr = res.data.list;
})
.catch((err) => {});
2 years ago
},
2 years ago
handleCheckChange(data, checked, indeterminate) {
//获取所有选中的节点 start
if (checked == true) {
console.log(checked, indeterminate);
console.log(data);
//获取所有选中的节点 end
}
},
2 years ago
//获取所选值
getCheckedNodes() {
2 years ago
console.log(this.$refs.tree);
console.log("当前选中的id是" + this.$refs.tree.getCheckedKeys(true));
console.log("当前选中的id是" + this.$refs.tree.getCheckedKeys(false));
2 years ago
},
2 years ago
2 years ago
// 保存确定操作
submitForm() {
this.$refs.formInfo.validate((valid) => {
if (valid) {
2 years ago
setScheduleRulel({ list: formArr })
.then((res) => {
this.isShow = false;
this.$message.success("添加成功");
this.$parent.deviceList();
})
.catch((err) => {
this.$message.error("添加失败");
});
2 years ago
} else {
console.log("error submit!!");
return false;
}
});
},
display() {
2 years ago
this.isShow = true;
2 years ago
},
hide() {
2 years ago
this.isShow = false;
},
},
2 years ago
};
</script>