123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <!--
- * @Author: liyi
- * @Date: 2020-11-13 16:35:06
- * @LastEditTime: 2021-06-01 17:19:54
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \WEB\dispatchingManagement\src\views\sysManage\deviceManage\sceneManage.vue
- -->
- <template>
- <div style="padding-right: 20px">
- <div class="box-scene" v-show="isEntryPage">
- <div class="handle-box">
- <el-input class="servertype-serch" v-model.trim="mixins_query.sceneName" placeholder="请输入场景名称"></el-input>
- <select-tree
- class="new-select-tree"
- placeholder="请选择所属公司"
- selectTreeTitle="所属公司"
- width="240"
- :options="organListCompany"
- :props="defaultProps"
- @selected="selectedcompanyOrgId"
- v-model="mixins_query.companyOrgId"
- >
- </select-tree>
- <select-tree
- class="new-select-tree"
- placeholder="请选择所属部门"
- selectTreeTitle="所属部门"
- width="240"
- :options="organListdepartment"
- :props="defaultProps"
- v-model="mixins_query.deptOrgId"
- >
- </select-tree>
- <el-button class="servertype-serch-btn" type="primary" @click="getlistpage"><i class="iconfont"></i>查询</el-button>
- <i class="fr fr-fs-fc fr-add iconfont" @click="addOrEdit" v-txt-tip data-txt="新增"></i>
- <!-- <i class="fr fr-fs-fc fr-del iconfont" @click="delusergroup"></i> -->
- </div>
- <!-- 表格 -->
- <div class="scene-manage-table">
- <zz-table
- :cols="cols"
- :settings="{ showCheckbox: false, showIndex: false }"
- :loading="mixins_onQuery"
- :data="mixins_list"
- row-key="id"
- :treeProps="treeProps"
- :pageset="mixins_pageset"
- @page-change="pageChange"
- >
- <template slot-scope="scope" slot="serviceTypeZN">
- <span v-for="item in allserviceType" :key="item.dictCode" v-show="scope.row.serviceType == item.dictCode">{{
- item.dictValue
- }}</span>
- </template>
- <!-- <template slot="enableState" slot-scope="scope">
- <p><span :style="{color:deviceLoader.getColor(scope.row.enableState)}">{{deviceLoader.getLabel(scope.row.enableState)}}</span></p>
- </template> -->
- <template slot-scope="scope" slot="opt">
- <i
- @click="bindDevice(scope.row.companyOrgId, scope.row.deptOrgId, scope.row.id)"
- class="iconfont"
- style="margin-right: 30px"
- v-txt-tip
- data-txt="绑定设备"
- ></i
- >
- <i @click="openDecicePage(scope.row)" class="iconfont" style="margin-right: 30px" v-txt-tip data-txt="设备列表"
- ></i
- >
- <i @click="addOrEdit('edit', scope.row)" class="iconfont" style="margin-right: 30px" v-txt-tip data-txt="编辑"
- ></i
- >
- <i @click="delusergroup(scope.row)" class="iconfont" style="color: #ff7272" v-txt-tip data-txt="删除"></i>
- </template>
- </zz-table>
- </div>
- </div>
- <scenemanage-devicelist v-show="!isEntryPage" :clickid="clickid" @changeisEntryPage="changeisEntryPage"></scenemanage-devicelist>
- </div>
- </template>
- <script>
- import list from '@utils/list.js';
- // import {deviceLoader} from "@utils/commonLoader.js";
- import sceneManageDevicelist from './popups/sceneManageDevicelist.vue';
- export default {
- mixins: [list],
- components: {
- 'scenemanage-devicelist': sceneManageDevicelist
- },
- data() {
- return {
- clickid: '',
- selectRow: '',
- isEntryPage: true,
- mixins_query: {
- companyOrgId: '',
- deptOrgId: '',
- sceneName: ''
- },
- mixins_list: [],
- scenetypeList: [],
- allsceneType: [],
- organListCompany: '',
- organListdepartment: '',
- allServiceScene: '',
- allServiceStatu: [
- {
- id: 1,
- label: '启用'
- },
- {
- id: 0,
- label: '停用'
- }
- ],
- defaultProps: {
- value: 'id', // 唯一标识
- label: 'orgName', // 标签显示
- children: 'orgs' // 子级
- },
- allSelectRow: [],
- cols: [
- {
- label: '场景名称',
- prop: 'sceneName'
- },
- {
- label: '场景类型',
- prop: 'sceneTypeName'
- },
- {
- label: '所属公司',
- prop: 'companyOrgName'
- },
- {
- label: '所属部门',
- prop: 'deptOrgName'
- },
- {
- label: '状态',
- prop: 'enableState',
- format(val) {
- if (val == 1) {
- return '启用';
- } else if (val == 0) {
- return '停用';
- }
- }
- },
- {
- label: '操作',
- prop: 'opt',
- slot: 'opt',
- width: 260
- }
- ],
- treeProps: { children: 'children', hasChildren: 'hasChildren' }
- };
- },
- created() {
- this.getorgTree();
- this.getscenetypeTreeList();
- this.getlistpage();
- this.getAllScene();
- },
- methods: {
- /**
- * 获取设备列表页
- */
- getlistpage() {
- this.mixins_dataUrl = '/zoniot-water/scene/selectPage';
- this.mixins_pageset = {
- pageNum: this.mixins_pageset.pageNum,
- pageSize: this.mixins_pageset.pageSize
- };
- this.mixins_post = 'post';
- this.mixins_search();
- },
- addOrEdit(tip, item) {
- let row = {},
- title = '新增场景';
- new Promise((resolve) => {
- if (tip === 'edit') {
- // row = item;
- title = '修改场景';
- this.$http.get('/zoniot-water/scene/selectById', { id: item.id }).then(({ status, data, msg }) => {
- if (status === 0) {
- let isExist = this.__calleArr(this.allServiceScene, data.parentSceneId, 'id');
- data.parentSceneId = isExist ? data.parentSceneId : '';
- row = data;
- this.$http
- .postForm('/sc-user-center/org/getOrgUserTree', { orgType: 'department', id: data.companyOrgId })
- .then(({ status, data, msg }) => {
- if (status === 0) {
- this.organListdepartment = data ? data : [];
- this.$http
- .get('/zoniot-water/scene/selectListForParm', {
- comId: row.companyOrgId,
- deptId: row.deptOrgId
- })
- .then(({ status, data, msg }) => {
- if (status === 0) {
- this.allsceneType = data ? data : [];
- let current;
- this.allsceneType.map((item, index) => {
- if (item.id == row.parentSceneId) {
- current = item.sceneTypeId;
- }
- });
- current = current ? current : 0;
- this.$http
- .get('/zoniot-water/scenetype/selectListByParentId', { id: current })
- .then(({ status, data, msg }) => {
- if (status === 0) {
- this.scenetypeList = data ? data : [];
- resolve();
- } else {
- // this.$message.error(msg);
- }
- });
- } else {
- this.$message.error(msg);
- }
- });
- } else {
- this.$message.error(msg);
- }
- });
- } else {
- this.$message.error(msg);
- }
- });
- } else {
- this.organListdepartment = [];
- this.allsceneType = [];
- row.enableState = 1;
- resolve();
- }
- }).then(() => {
- new Promise((resolve) => {
- this.$store.dispatch('openModal', {
- url: '/sysManage/deviceManage/popups/addOrEditScene.vue',
- width: '580px',
- height: '700px',
- props: {
- data: row,
- todo: tip,
- organList: this.organList,
- allServiceScene: this.allServiceScene,
- allsceneType: this.allsceneType,
- organListCompany: this.organListCompany,
- scenetypeList: this.scenetypeList,
- organListdepartment: this.organListdepartment,
- // allRoleId: this.allRoleId,
- // allUserType: this.allUserType,
- callback: resolve
- },
- title: title
- });
- }).then(() => {
- this.mixins_search();
- this.getAllScene();
- });
- });
- },
- delusergroup(item) {
- let ids = [];
- if (item.id) {
- ids.push(item.id);
- } else {
- if (!this.selectRow.length) {
- this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
- return;
- }
- this.selectRow.forEach((v) => {
- ids.push(v.id);
- });
- }
- this.$msgBox(`确定要删除?`, '删除后将无法恢复,是否继续?').then(() => {
- this.$http.post('/zoniot-water/scene/deleteByIds', ids).then(({ status, data, msg }) => {
- if (status === 0) {
- this.$message.success('删除成功');
- this.getlistpage();
- this.getAllScene();
- } else {
- this.$message.error(msg);
- }
- });
- });
- },
- selectionChange(val) {
- this.selectRow = val;
- },
- getorgTree() {
- // 获取 公司树
- this.$http.postForm('/sc-user-center/org/getOrgUserTree', { orgType: 'company', id: '000' }).then(({ status, data, msg }) => {
- if (status === 0 && data) {
- this.organListCompany = data;
- // console.log(this.organListCompany );
- } else {
- // this.$message.error(msg);
- }
- });
- },
- selectedcompanyOrgId(e) {
- if (!e) return;
- // 获取 部门树e
- this.$http.postForm('/sc-user-center/org/getOrgUserTree', { orgType: 'department', id: e }).then(({ status, data, msg }) => {
- if (status === 0) {
- this.organListdepartment = data ? data : [];
- } else {
- this.$message.error(msg);
- }
- });
- },
- // 获取场景树
- getscenetypeTreeList() {
- this.$http.get('/zoniot-water/scenetype/selectList', { sceneTypeName: this.sceneName }).then(({ status, data, msg }) => {
- if (status === 0 && data) {
- this.scenetypeList = data;
- } else {
- // this.$message.error(msg);
- }
- });
- },
- // 上级 场景
- getAllScene() {
- this.$http.get('/zoniot-water/scene/selectList').then(({ status, data, msg }) => {
- if (status === 0) {
- this.allServiceScene = data;
- } else {
- this.$message.error(msg);
- }
- });
- },
- openDecicePage(row) {
- this.clickid = row.id + '-' + new Date();
- this.isEntryPage = !this.isEntryPage;
- },
- changeisEntryPage(val) {
- this.isEntryPage = val;
- },
- bindDevice(companyOrgId, deptOrgId, sceneId) {
- new Promise((resolve) => {
- let row,
- title = '绑定设备';
- row = {
- companyOrgId,
- deptOrgId,
- sceneId
- };
- this.$store.dispatch('openModal', {
- url: '/sysManage/deviceManage/popups/bindDevice.vue',
- title: title,
- width: '1000px',
- height: '610px',
- notip: true,
- showCancelButton: true,
- showConfirmButton: true,
- props: {
- data: row,
- callback: resolve
- }
- });
- }).then(() => {
- this.mixins_search();
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .handle-box {
- // width: 1660px;
- height: 60px;
- background: #ffffff;
- opacity: 1;
- border-radius: 6px;
- box-sizing: border-box;
- padding: 15px 20px;
- margin-bottom: 20px;
- }
- .fr {
- float: right;
- margin-right: 20px;
- }
- .servertype-serch {
- width: 240px;
- height: 30px;
- margin-right: 20px;
- vertical-align: top;
- }
- .new-select-tree {
- vertical-align: top;
- display: inline-block;
- margin-right: 20px;
- }
- table p {
- display: inline-block;
- }
- .servertype-serch-btn {
- width: 60px;
- height: 30px;
- opacity: 1;
- border-radius: 4px;
- padding: 0;
- i {
- margin-right: 4px;
- vertical-align: text-top;
- }
- }
- </style>
- <style lang="scss" >
- .scene-manage-table {
- table p {
- display: inline-block;
- }
- }
- .el-table__expand-icon {
- vertical-align: super;
- }
- </style>
|