|
|
@@ -2,8 +2,9 @@
|
|
|
<el-dialog
|
|
|
:title="title"
|
|
|
:visible.sync="visible"
|
|
|
- width="1000px"
|
|
|
+ width="80%"
|
|
|
top="10vh"
|
|
|
+ :close-on-click-modal="false"
|
|
|
append-to-body
|
|
|
@opened="open"
|
|
|
@closed="closed"
|
|
|
@@ -19,18 +20,23 @@
|
|
|
>
|
|
|
<el-form-item label="组织机构:">
|
|
|
<tree-select
|
|
|
- v-model="left.condition.orgId"
|
|
|
- :options="deptOptions"
|
|
|
- :show-count="true"
|
|
|
- :normalizer="tenantIdnormalizer"
|
|
|
- :props="{ checkStrictly: true, label: 'name' }"
|
|
|
- placeholder="请选择归属机构"
|
|
|
- clearValueText="清除"
|
|
|
- :noChildrenText="''"
|
|
|
- @select="leftSearch"
|
|
|
- noOptionsText="没有数据"
|
|
|
- noResultsText="没有搜索结果"
|
|
|
- />
|
|
|
+ v-model="left.condition.orgId"
|
|
|
+ :searchable="searchable"
|
|
|
+ :default-expand-level="level"
|
|
|
+ :normalizer="tenantIdnormalizer"
|
|
|
+ :options="treeList"
|
|
|
+ :show-count="true"
|
|
|
+ :props="{ checkStrictly: true, label: 'name' }"
|
|
|
+ placeholder="请选择归属机构"
|
|
|
+ clearValueText="清除"
|
|
|
+ :noChildrenText="''"
|
|
|
+ @select="leftTreeSelect"
|
|
|
+ noOptionsText="没有数据"
|
|
|
+ noResultsText="没有搜索结果"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item >
|
|
|
+ <el-checkbox v-model="left.condition.searchChild" @change="leftSearch">是否包含下级</el-checkbox>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="名称:">
|
|
|
<el-input
|
|
|
@@ -84,19 +90,24 @@
|
|
|
>
|
|
|
<el-form-item label="组织机构:">
|
|
|
<tree-select
|
|
|
- v-model="right.condition.orgId"
|
|
|
- :options="deptOptions"
|
|
|
- :show-count="true"
|
|
|
- :normalizer="tenantIdnormalizer"
|
|
|
- :props="{ checkStrictly: true, label: 'name' }"
|
|
|
- placeholder="请选择归属机构"
|
|
|
- clearValueText="清除"
|
|
|
- :noChildrenText="''"
|
|
|
- @select="rightSearch"
|
|
|
- noOptionsText="没有数据"
|
|
|
- noResultsText="没有搜索结果"
|
|
|
- />
|
|
|
-
|
|
|
+ v-model="right.condition.orgId"
|
|
|
+ :searchable="searchable"
|
|
|
+ :options="treeList"
|
|
|
+ :default-expand-level="level"
|
|
|
+ :normalizer="tenantIdnormalizer"
|
|
|
+ :show-count="true"
|
|
|
+ :props="{ checkStrictly: true, label: 'name' }"
|
|
|
+ placeholder="请选择归属机构"
|
|
|
+ clearValueText="清除"
|
|
|
+ :noChildrenText="''"
|
|
|
+ @select="rightTreeSelect"
|
|
|
+ noOptionsText="没有数据"
|
|
|
+ noResultsText="没有搜索结果"
|
|
|
+ />
|
|
|
+
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item >
|
|
|
+ <el-checkbox v-model="right.condition.searchChild" @change="rightSearch">是否包含下级</el-checkbox>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="名称:">
|
|
|
<el-input
|
|
|
@@ -139,33 +150,83 @@
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script>
|
|
|
-
|
|
|
+import { mapGetters, mapMutations } from "vuex";
|
|
|
+import {device} from "@/api/iot/alarmRule";
|
|
|
+const defaultData = {
|
|
|
+ left: {
|
|
|
+ condition: {
|
|
|
+ orgId: null,
|
|
|
+ deviceName: "",
|
|
|
+ searchChild: false,
|
|
|
+ },
|
|
|
+ total: 0,
|
|
|
+ selectedCount: 0,
|
|
|
+ selectedRows: [],
|
|
|
+ data: [],
|
|
|
+ },
|
|
|
+ right: {
|
|
|
+ condition: {
|
|
|
+ orgId: null,
|
|
|
+ deviceName: "",
|
|
|
+ searchChild: false,
|
|
|
+ },
|
|
|
+ total: 0,
|
|
|
+ selectedCount: 0,
|
|
|
+ selectedRows: [],
|
|
|
+ data: [],
|
|
|
+ },
|
|
|
+}
|
|
|
export default {
|
|
|
name: "ruleBindDevice",
|
|
|
props: {
|
|
|
- // boundDevices: {
|
|
|
- // type: Array,
|
|
|
- // default: new Array(),
|
|
|
- // },
|
|
|
- deviceType: {
|
|
|
- type: [Number, String],
|
|
|
- required: false,
|
|
|
+ currentTempList: {
|
|
|
+ type: Array,
|
|
|
+ default: new Array(),
|
|
|
},
|
|
|
typeText: {
|
|
|
type: String,
|
|
|
required: false,
|
|
|
default: "报警防区",
|
|
|
},
|
|
|
+ customRequest: {
|
|
|
+ type: Function,
|
|
|
+ },
|
|
|
+ hangsheTree: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ businessTree: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ wholeTree: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // currentTempList: function (data) {
|
|
|
+ // this.right.data = data
|
|
|
+ // this.boundDevicesClone = data;
|
|
|
+ // }
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
title: "选择报警防区设备",
|
|
|
+ level: 1,
|
|
|
+ clearable: true,
|
|
|
+ searchable: true,
|
|
|
visible: false,
|
|
|
+ deviceType:null,
|
|
|
loading: false,
|
|
|
+ treeList: [],
|
|
|
+ deptOptions:[],
|
|
|
+ boundDevicesClone:[],
|
|
|
left: {
|
|
|
condition: {
|
|
|
- orgId: 0,
|
|
|
+ orgId: null,
|
|
|
deviceName: "",
|
|
|
+ searchChild: false,
|
|
|
},
|
|
|
total: 0,
|
|
|
selectedCount: 0,
|
|
|
@@ -174,53 +235,103 @@ export default {
|
|
|
},
|
|
|
right: {
|
|
|
condition: {
|
|
|
- orgId: 0,
|
|
|
+ orgId: null,
|
|
|
deviceName: "",
|
|
|
+ searchChild: false,
|
|
|
},
|
|
|
total: 0,
|
|
|
selectedCount: 0,
|
|
|
selectedRows: [],
|
|
|
data: [],
|
|
|
},
|
|
|
+ rightOrgIds:[],
|
|
|
+ boundDeviceIds:[],
|
|
|
+ searchDevices:[],
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
this.boundDevicesClone = [];
|
|
|
},
|
|
|
+ mounted() {
|
|
|
|
|
|
- mounted() {},
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ tenantIdnormalizer(node, instanceId) {
|
|
|
+ if (node.children && !node.children.length) {
|
|
|
+ delete node.children;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ id: node.id,
|
|
|
+ label: node.shortName,
|
|
|
+ children: node.children,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ orgTree(){
|
|
|
+ if (this.customRequest) {
|
|
|
+ this.customRequest().then((response) => {
|
|
|
+ this.treeList = response.data;
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (this.hangsheTree) {
|
|
|
+ this.treeList = this.$store.getters.depTree;
|
|
|
+ }
|
|
|
+ else if(this.businessTree)
|
|
|
+ {
|
|
|
+ this.treeList = this.$store.getters.businessTree;
|
|
|
+ }
|
|
|
+ else if(this.wholeTree)
|
|
|
+ {
|
|
|
+ this.treeList = this.$store.getters.wholeTree;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.treeList = this.$store.getters.orgTree;
|
|
|
+ }
|
|
|
+ console.log(this.treeList)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getChildIds(orgTree,parentId){
|
|
|
+ if(parentId){
|
|
|
+ orgTree.forEach((v,i) => {
|
|
|
+ if(v.path.indexOf(parentId) != -1){
|
|
|
+ this.rightOrgIds.push(v.id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if( v.children && v.children.length > 0){
|
|
|
+ this.getChildIds(v.children,parentId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
open() {
|
|
|
- // this.left.condition.orgId = this.loginUser.org.id;
|
|
|
- // this.boundDevicesClone = this.boundDevices
|
|
|
- // ? this.boundDevices.map((d) => d)
|
|
|
- // : new Array();
|
|
|
- // this.boundDeviceIds = this.boundDevicesClone.map((d) => d.deviceId);
|
|
|
- // this.title = `选择${this.typeText}设备`;
|
|
|
- // this.leftSearch();
|
|
|
- // this.rightSearch();
|
|
|
+ this.right.data = this.currentTempList;
|
|
|
+ this.boundDevicesClone = this.currentTempList;
|
|
|
},
|
|
|
showDialog() {
|
|
|
this.visible = true;
|
|
|
},
|
|
|
hideDialog() {
|
|
|
this.visible = false;
|
|
|
+ this.left = defaultData.left;
|
|
|
+ this.right = defaultData.right;
|
|
|
+ this.searchDevices = [];
|
|
|
+ this.boundDeviceIds = [];
|
|
|
+ this.boundDevicesClone = [];
|
|
|
},
|
|
|
closed() {
|
|
|
- this.left.data = [];
|
|
|
- this.left.condition.deviceName = "";
|
|
|
- this.left.condition.orgId = 0;
|
|
|
- this.right.data = [];
|
|
|
- this.right.condition.deviceName = "";
|
|
|
- this.right.condition.orgId = 0;
|
|
|
+ this.left = defaultData.left;
|
|
|
+ this.right = defaultData.right;
|
|
|
+ this.searchDevices = [];
|
|
|
+ this.boundDeviceIds = [];
|
|
|
+ this.boundDevicesClone = [];
|
|
|
},
|
|
|
- handleLeftOrgNodeClick(node) {
|
|
|
- this.left.condition.orgId = node.orgId;
|
|
|
+ leftTreeSelect(node){
|
|
|
+ this.left.condition.orgId = node.id;
|
|
|
this.leftSearch();
|
|
|
},
|
|
|
- handleRightOrgNodeClick(node) {
|
|
|
- this.right.condition.orgId = node.orgId;
|
|
|
- this.RightSearch();
|
|
|
+ rightTreeSelect(node){
|
|
|
+ this.right.condition.orgId = node.id;
|
|
|
+ this.rightSearch();
|
|
|
},
|
|
|
handleLeftSelectionChange(val) {
|
|
|
this.left.selectedCount = val.length;
|
|
|
@@ -234,17 +345,27 @@ export default {
|
|
|
this.right.condition.orgName = node.orgName;
|
|
|
},
|
|
|
handleAdd() {
|
|
|
+ this.right.condition.orgId = null;
|
|
|
+ this.right.condition.searchChild = false;
|
|
|
+ this.right.condition.deviceName = null;
|
|
|
let addData = this.left.selectedRows.filter(
|
|
|
(row) => this.boundDeviceIds.indexOf(row.deviceId) < 0
|
|
|
);
|
|
|
- addData.map((row) => {
|
|
|
- let clone = { ...row };
|
|
|
- this.right.data.push(clone);
|
|
|
- this.boundDevicesClone.push(clone);
|
|
|
- this.boundDeviceIds.push(clone.deviceId);
|
|
|
- });
|
|
|
+ if(addData.length > 0){
|
|
|
+ addData.forEach((i,v) => {
|
|
|
+ this.right.data.push(i);
|
|
|
+ this.boundDevicesClone.push(i);
|
|
|
+ });
|
|
|
+ this.boundDeviceIds = this.boundDevicesClone.map((d) => d.deviceId);
|
|
|
+
|
|
|
+ this.left.data = this.searchDevices.filter((row) => this.boundDeviceIds.indexOf(row.deviceId) < 0)
|
|
|
+ }
|
|
|
+ this.leftSearch();
|
|
|
},
|
|
|
handleRemove() {
|
|
|
+ this.right.condition.orgId = null;
|
|
|
+ this.right.condition.searchChild = false;
|
|
|
+ this.right.condition.deviceName = null;
|
|
|
let rightSelectedDeviceIds = this.right.selectedRows.map(
|
|
|
(r) => r.deviceId
|
|
|
);
|
|
|
@@ -255,9 +376,13 @@ export default {
|
|
|
(d) => rightSelectedDeviceIds.indexOf(d.deviceId) < 0
|
|
|
);
|
|
|
this.boundDeviceIds = this.boundDevicesClone.map((d) => d.deviceId);
|
|
|
+
|
|
|
+ this.left.data = this.searchDevices.filter((row) => this.boundDeviceIds.indexOf(row.deviceId) < 0)
|
|
|
+ if(this.left.condition.orgId){
|
|
|
+ this.leftSearch();
|
|
|
+ }
|
|
|
},
|
|
|
leftSearch() {
|
|
|
- return;
|
|
|
let { condition } = this.left;
|
|
|
if (
|
|
|
this.left.prevCondition &&
|
|
|
@@ -266,30 +391,49 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
this.left.prevCondition = { ...condition };
|
|
|
- this.$api.alarmRule
|
|
|
- .getDevice(
|
|
|
- condition.orgId,
|
|
|
- condition.deviceName,
|
|
|
- this.deviceType,
|
|
|
- 0,
|
|
|
- 9999
|
|
|
- )
|
|
|
- .then((result) => {
|
|
|
- this.left.data = result.content;
|
|
|
+ let params = {
|
|
|
+ orgId:condition.orgId,
|
|
|
+ deviceName:condition.deviceName,
|
|
|
+ type:this.deviceType,
|
|
|
+ includeSub:condition.searchChild,
|
|
|
+ page:0,
|
|
|
+ size:9999
|
|
|
+ }
|
|
|
+ device(params).then((result) => {
|
|
|
+ this.searchDevices = result.data.records;
|
|
|
+ this.boundDeviceIds = this.boundDevicesClone.map((d) => d.deviceId);
|
|
|
+ let data = result.data.records.filter((row) => this.boundDeviceIds.indexOf(row.deviceId) < 0);
|
|
|
+ this.left.data = data;
|
|
|
});
|
|
|
},
|
|
|
rightSearch() {
|
|
|
const { condition } = this.right;
|
|
|
- this.right.data = this.boundDevicesClone
|
|
|
- .filter(
|
|
|
- (d) =>
|
|
|
- !condition.deviceName || d.deviceName.includes(condition.deviceName)
|
|
|
- )
|
|
|
- .filter((d) => !condition.orgId || d.orgId == condition.orgId);
|
|
|
- },
|
|
|
+ if(this.boundDevicesClone.length > 0){
|
|
|
+ if(!this.right.condition.searchChild){
|
|
|
+ this.right.data = this.boundDevicesClone
|
|
|
+ .filter(
|
|
|
+ (d) =>
|
|
|
+ !condition.deviceName || d.deviceName.includes(condition.deviceName)
|
|
|
+ )
|
|
|
+ .filter((d) => !condition.orgId || d.orgId == condition.orgId);
|
|
|
+ }else{
|
|
|
+ this.getChildIds(this.treeList,condition.orgId);
|
|
|
+ let data = this.boundDevicesClone
|
|
|
+ .filter(
|
|
|
+ (d) =>
|
|
|
+ !condition.deviceName || d.deviceName.includes(condition.deviceName)
|
|
|
+ );
|
|
|
+ if(this.rightOrgIds.length > 0){
|
|
|
+ this.right.data = data.filter((d) => this.rightOrgIds.indexOf(d.orgId) > 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
onOK() {
|
|
|
- this.$emit("ok", this.boundDevicesClone);
|
|
|
+ this.$emit("addDevice", this.boundDevicesClone);
|
|
|
this.hideDialog();
|
|
|
},
|
|
|
},
|
|
|
@@ -297,15 +441,17 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-@ctlButtonWidth: 80px;
|
|
|
+.dialog-footer{
|
|
|
+ float: right;
|
|
|
+}
|
|
|
+::v-deep .el-dialog__footer{
|
|
|
+ height: 60px;
|
|
|
+}
|
|
|
.controller {
|
|
|
margin: auto;
|
|
|
width: 80px;
|
|
|
top: calc(50% - 30px);
|
|
|
position: relative;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
.remove{
|
|
|
margin-top: 20px;
|
|
|
margin-left: 0px;
|
|
|
@@ -342,4 +488,5 @@ export default {
|
|
|
display: block;
|
|
|
text-align: right;
|
|
|
}
|
|
|
+
|
|
|
</style>
|