sceneManage.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <!--
  2. * @Author: liyi
  3. * @Date: 2020-11-13 16:35:06
  4. * @LastEditTime: 2021-06-01 17:19:54
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: \WEB\dispatchingManagement\src\views\sysManage\deviceManage\sceneManage.vue
  8. -->
  9. <template>
  10. <div style="padding-right: 20px">
  11. <div class="box-scene" v-show="isEntryPage">
  12. <div class="handle-box">
  13. <el-input class="servertype-serch" v-model.trim="mixins_query.sceneName" placeholder="请输入场景名称"></el-input>
  14. <select-tree
  15. class="new-select-tree"
  16. placeholder="请选择所属公司"
  17. selectTreeTitle="所属公司"
  18. width="240"
  19. :options="organListCompany"
  20. :props="defaultProps"
  21. @selected="selectedcompanyOrgId"
  22. v-model="mixins_query.companyOrgId"
  23. >
  24. </select-tree>
  25. <select-tree
  26. class="new-select-tree"
  27. placeholder="请选择所属部门"
  28. selectTreeTitle="所属部门"
  29. width="240"
  30. :options="organListdepartment"
  31. :props="defaultProps"
  32. v-model="mixins_query.deptOrgId"
  33. >
  34. </select-tree>
  35. <el-button class="servertype-serch-btn" type="primary" @click="getlistpage"><i class="iconfont">&#xe6fc;</i>查询</el-button>
  36. <i class="fr fr-fs-fc fr-add iconfont" @click="addOrEdit" v-txt-tip data-txt="新增">&#xe641;</i>
  37. <!-- <i class="fr fr-fs-fc fr-del iconfont" @click="delusergroup">&#xe63b;</i> -->
  38. </div>
  39. <!-- 表格 -->
  40. <div class="scene-manage-table">
  41. <zz-table
  42. :cols="cols"
  43. :settings="{ showCheckbox: false, showIndex: false }"
  44. :loading="mixins_onQuery"
  45. :data="mixins_list"
  46. row-key="id"
  47. :treeProps="treeProps"
  48. :pageset="mixins_pageset"
  49. @page-change="pageChange"
  50. >
  51. <template slot-scope="scope" slot="serviceTypeZN">
  52. <span v-for="item in allserviceType" :key="item.dictCode" v-show="scope.row.serviceType == item.dictCode">{{
  53. item.dictValue
  54. }}</span>
  55. </template>
  56. <!-- <template slot="enableState" slot-scope="scope">
  57. <p><span :style="{color:deviceLoader.getColor(scope.row.enableState)}">{{deviceLoader.getLabel(scope.row.enableState)}}</span></p>
  58. </template> -->
  59. <template slot-scope="scope" slot="opt">
  60. <i
  61. @click="bindDevice(scope.row.companyOrgId, scope.row.deptOrgId, scope.row.id)"
  62. class="iconfont"
  63. style="margin-right: 30px"
  64. v-txt-tip
  65. data-txt="绑定设备"
  66. >&#xe685;</i
  67. >
  68. <i @click="openDecicePage(scope.row)" class="iconfont" style="margin-right: 30px" v-txt-tip data-txt="设备列表"
  69. >&#xe671;</i
  70. >
  71. <i @click="addOrEdit('edit', scope.row)" class="iconfont" style="margin-right: 30px" v-txt-tip data-txt="编辑"
  72. >&#xe645;</i
  73. >
  74. <i @click="delusergroup(scope.row)" class="iconfont" style="color: #ff7272" v-txt-tip data-txt="删除">&#xe63a;</i>
  75. </template>
  76. </zz-table>
  77. </div>
  78. </div>
  79. <scenemanage-devicelist v-show="!isEntryPage" :clickid="clickid" @changeisEntryPage="changeisEntryPage"></scenemanage-devicelist>
  80. </div>
  81. </template>
  82. <script>
  83. import list from '@utils/list.js';
  84. // import {deviceLoader} from "@utils/commonLoader.js";
  85. import sceneManageDevicelist from './popups/sceneManageDevicelist.vue';
  86. export default {
  87. mixins: [list],
  88. components: {
  89. 'scenemanage-devicelist': sceneManageDevicelist
  90. },
  91. data() {
  92. return {
  93. clickid: '',
  94. selectRow: '',
  95. isEntryPage: true,
  96. mixins_query: {
  97. companyOrgId: '',
  98. deptOrgId: '',
  99. sceneName: ''
  100. },
  101. mixins_list: [],
  102. scenetypeList: [],
  103. allsceneType: [],
  104. organListCompany: '',
  105. organListdepartment: '',
  106. allServiceScene: '',
  107. allServiceStatu: [
  108. {
  109. id: 1,
  110. label: '启用'
  111. },
  112. {
  113. id: 0,
  114. label: '停用'
  115. }
  116. ],
  117. defaultProps: {
  118. value: 'id', // 唯一标识
  119. label: 'orgName', // 标签显示
  120. children: 'orgs' // 子级
  121. },
  122. allSelectRow: [],
  123. cols: [
  124. {
  125. label: '场景名称',
  126. prop: 'sceneName'
  127. },
  128. {
  129. label: '场景类型',
  130. prop: 'sceneTypeName'
  131. },
  132. {
  133. label: '所属公司',
  134. prop: 'companyOrgName'
  135. },
  136. {
  137. label: '所属部门',
  138. prop: 'deptOrgName'
  139. },
  140. {
  141. label: '状态',
  142. prop: 'enableState',
  143. format(val) {
  144. if (val == 1) {
  145. return '启用';
  146. } else if (val == 0) {
  147. return '停用';
  148. }
  149. }
  150. },
  151. {
  152. label: '操作',
  153. prop: 'opt',
  154. slot: 'opt',
  155. width: 260
  156. }
  157. ],
  158. treeProps: { children: 'children', hasChildren: 'hasChildren' }
  159. };
  160. },
  161. created() {
  162. this.getorgTree();
  163. this.getscenetypeTreeList();
  164. this.getlistpage();
  165. this.getAllScene();
  166. },
  167. methods: {
  168. /**
  169. * 获取设备列表页
  170. */
  171. getlistpage() {
  172. this.mixins_dataUrl = '/zoniot-water/scene/selectPage';
  173. this.mixins_pageset = {
  174. pageNum: this.mixins_pageset.pageNum,
  175. pageSize: this.mixins_pageset.pageSize
  176. };
  177. this.mixins_post = 'post';
  178. this.mixins_search();
  179. },
  180. addOrEdit(tip, item) {
  181. let row = {},
  182. title = '新增场景';
  183. new Promise((resolve) => {
  184. if (tip === 'edit') {
  185. // row = item;
  186. title = '修改场景';
  187. this.$http.get('/zoniot-water/scene/selectById', { id: item.id }).then(({ status, data, msg }) => {
  188. if (status === 0) {
  189. let isExist = this.__calleArr(this.allServiceScene, data.parentSceneId, 'id');
  190. data.parentSceneId = isExist ? data.parentSceneId : '';
  191. row = data;
  192. this.$http
  193. .postForm('/sc-user-center/org/getOrgUserTree', { orgType: 'department', id: data.companyOrgId })
  194. .then(({ status, data, msg }) => {
  195. if (status === 0) {
  196. this.organListdepartment = data ? data : [];
  197. this.$http
  198. .get('/zoniot-water/scene/selectListForParm', {
  199. comId: row.companyOrgId,
  200. deptId: row.deptOrgId
  201. })
  202. .then(({ status, data, msg }) => {
  203. if (status === 0) {
  204. this.allsceneType = data ? data : [];
  205. let current;
  206. this.allsceneType.map((item, index) => {
  207. if (item.id == row.parentSceneId) {
  208. current = item.sceneTypeId;
  209. }
  210. });
  211. current = current ? current : 0;
  212. this.$http
  213. .get('/zoniot-water/scenetype/selectListByParentId', { id: current })
  214. .then(({ status, data, msg }) => {
  215. if (status === 0) {
  216. this.scenetypeList = data ? data : [];
  217. resolve();
  218. } else {
  219. // this.$message.error(msg);
  220. }
  221. });
  222. } else {
  223. this.$message.error(msg);
  224. }
  225. });
  226. } else {
  227. this.$message.error(msg);
  228. }
  229. });
  230. } else {
  231. this.$message.error(msg);
  232. }
  233. });
  234. } else {
  235. this.organListdepartment = [];
  236. this.allsceneType = [];
  237. row.enableState = 1;
  238. resolve();
  239. }
  240. }).then(() => {
  241. new Promise((resolve) => {
  242. this.$store.dispatch('openModal', {
  243. url: '/sysManage/deviceManage/popups/addOrEditScene.vue',
  244. width: '580px',
  245. height: '700px',
  246. props: {
  247. data: row,
  248. todo: tip,
  249. organList: this.organList,
  250. allServiceScene: this.allServiceScene,
  251. allsceneType: this.allsceneType,
  252. organListCompany: this.organListCompany,
  253. scenetypeList: this.scenetypeList,
  254. organListdepartment: this.organListdepartment,
  255. // allRoleId: this.allRoleId,
  256. // allUserType: this.allUserType,
  257. callback: resolve
  258. },
  259. title: title
  260. });
  261. }).then(() => {
  262. this.mixins_search();
  263. this.getAllScene();
  264. });
  265. });
  266. },
  267. delusergroup(item) {
  268. let ids = [];
  269. if (item.id) {
  270. ids.push(item.id);
  271. } else {
  272. if (!this.selectRow.length) {
  273. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  274. return;
  275. }
  276. this.selectRow.forEach((v) => {
  277. ids.push(v.id);
  278. });
  279. }
  280. this.$msgBox(`确定要删除?`, '删除后将无法恢复,是否继续?').then(() => {
  281. this.$http.post('/zoniot-water/scene/deleteByIds', ids).then(({ status, data, msg }) => {
  282. if (status === 0) {
  283. this.$message.success('删除成功');
  284. this.getlistpage();
  285. this.getAllScene();
  286. } else {
  287. this.$message.error(msg);
  288. }
  289. });
  290. });
  291. },
  292. selectionChange(val) {
  293. this.selectRow = val;
  294. },
  295. getorgTree() {
  296. // 获取 公司树
  297. this.$http.postForm('/sc-user-center/org/getOrgUserTree', { orgType: 'company', id: '000' }).then(({ status, data, msg }) => {
  298. if (status === 0 && data) {
  299. this.organListCompany = data;
  300. // console.log(this.organListCompany );
  301. } else {
  302. // this.$message.error(msg);
  303. }
  304. });
  305. },
  306. selectedcompanyOrgId(e) {
  307. if (!e) return;
  308. // 获取 部门树e
  309. this.$http.postForm('/sc-user-center/org/getOrgUserTree', { orgType: 'department', id: e }).then(({ status, data, msg }) => {
  310. if (status === 0) {
  311. this.organListdepartment = data ? data : [];
  312. } else {
  313. this.$message.error(msg);
  314. }
  315. });
  316. },
  317. // 获取场景树
  318. getscenetypeTreeList() {
  319. this.$http.get('/zoniot-water/scenetype/selectList', { sceneTypeName: this.sceneName }).then(({ status, data, msg }) => {
  320. if (status === 0 && data) {
  321. this.scenetypeList = data;
  322. } else {
  323. // this.$message.error(msg);
  324. }
  325. });
  326. },
  327. // 上级 场景
  328. getAllScene() {
  329. this.$http.get('/zoniot-water/scene/selectList').then(({ status, data, msg }) => {
  330. if (status === 0) {
  331. this.allServiceScene = data;
  332. } else {
  333. this.$message.error(msg);
  334. }
  335. });
  336. },
  337. openDecicePage(row) {
  338. this.clickid = row.id + '-' + new Date();
  339. this.isEntryPage = !this.isEntryPage;
  340. },
  341. changeisEntryPage(val) {
  342. this.isEntryPage = val;
  343. },
  344. bindDevice(companyOrgId, deptOrgId, sceneId) {
  345. new Promise((resolve) => {
  346. let row,
  347. title = '绑定设备';
  348. row = {
  349. companyOrgId,
  350. deptOrgId,
  351. sceneId
  352. };
  353. this.$store.dispatch('openModal', {
  354. url: '/sysManage/deviceManage/popups/bindDevice.vue',
  355. title: title,
  356. width: '1000px',
  357. height: '610px',
  358. notip: true,
  359. showCancelButton: true,
  360. showConfirmButton: true,
  361. props: {
  362. data: row,
  363. callback: resolve
  364. }
  365. });
  366. }).then(() => {
  367. this.mixins_search();
  368. });
  369. }
  370. }
  371. };
  372. </script>
  373. <style lang="scss" scoped>
  374. .handle-box {
  375. // width: 1660px;
  376. height: 60px;
  377. background: #ffffff;
  378. opacity: 1;
  379. border-radius: 6px;
  380. box-sizing: border-box;
  381. padding: 15px 20px;
  382. margin-bottom: 20px;
  383. }
  384. .fr {
  385. float: right;
  386. margin-right: 20px;
  387. }
  388. .servertype-serch {
  389. width: 240px;
  390. height: 30px;
  391. margin-right: 20px;
  392. vertical-align: top;
  393. }
  394. .new-select-tree {
  395. vertical-align: top;
  396. display: inline-block;
  397. margin-right: 20px;
  398. }
  399. table p {
  400. display: inline-block;
  401. }
  402. .servertype-serch-btn {
  403. width: 60px;
  404. height: 30px;
  405. opacity: 1;
  406. border-radius: 4px;
  407. padding: 0;
  408. i {
  409. margin-right: 4px;
  410. vertical-align: text-top;
  411. }
  412. }
  413. </style>
  414. <style lang="scss" >
  415. .scene-manage-table {
  416. table p {
  417. display: inline-block;
  418. }
  419. }
  420. .el-table__expand-icon {
  421. vertical-align: super;
  422. }
  423. </style>