index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div class="siteManage-main roleInfoPage">
  3. <div style="text-align: right; margin-bottom: 20px">
  4. <!-- <el-button type="success" >新增</el-button> -->
  5. <el-button type="primary" @click="saveMenu()">保存</el-button>
  6. </div>
  7. <!-- <el-table :data="menuData" border stripe>
  8. <el-table-column prop="label" label="菜单" width="180"></el-table-column>
  9. <el-table-column prop="authority2" label="权限" class="roleLeft">
  10. <template #default="scope">
  11. <el-radio-group
  12. v-model="scope.row.authority2"
  13. @change="listTabsChange(scope.row)"
  14. >
  15. <el-radio label="1" :disabled="radio1 == 1 ? true : false">
  16. </el-radio>
  17. <el-radio label="0" :disabled="radio1 == 1 ? true : false">
  18. </el-radio>
  19. </el-radio-group>
  20. </template>
  21. </el-table-column>
  22. </el-table> -->
  23. <!-- <br />
  24. <br /> -->
  25. <!-- 树结构的表格 start -->
  26. <!-- <el-table
  27. :data="tableData"
  28. style="width: 100%; margin-bottom: 20px"
  29. row-key="id"
  30. border
  31. >
  32. <el-table-column prop="date" label="菜单" width="180" />
  33. <el-table-column prop="name" label="权限">
  34. <template #default="scope">
  35. <el-radio-group v-model="scope.row.authority2">
  36. <el-radio label="1">是</el-radio>
  37. <el-radio label="0">否</el-radio>
  38. </el-radio-group>
  39. </template>
  40. </el-table-column>
  41. </el-table> -->
  42. <!-- 树结构的表格 end -->
  43. <!-- 带复选框的树结构 start -->
  44. <el-tree
  45. :data="data"
  46. show-checkbox
  47. node-key="id"
  48. :default-checked-keys="[11,2,31,32,4,51,52,53,81]"
  49. :props="defaultProps"
  50. @check="currentChecked"
  51. />
  52. <!-- 带复选框的树结构 end -->
  53. </div>
  54. </template>
  55. <script>
  56. import { defineComponent, ref, onMounted, watch } from 'vue'
  57. import * as api from '@/api/systemManage/rolePermission.js'
  58. import { ElMessage } from 'element-plus'
  59. export default defineComponent({
  60. name: 'RoleInfoCom',
  61. props: ['menuData', 'objItem', 'radio1'],
  62. // props: {
  63. // menuData: Object,
  64. // objItem: Object,
  65. // radio1: String,
  66. // },
  67. setup(props) {
  68. const aa = ref([])
  69. const saveArr = ref([])
  70. const tableData = ref([
  71. {
  72. id: 1,
  73. date: '告警管理',
  74. name: 'wangxiaohu',
  75. authority2: '1',
  76. children: [
  77. {
  78. id: 11,
  79. date: '新增',
  80. name: 'wangxiaohu',
  81. authority2: '1',
  82. },
  83. {
  84. id: 12,
  85. date: '修改',
  86. name: 'wangxiaohu',
  87. authority2: '1',
  88. },
  89. {
  90. id: 13,
  91. date: '删除',
  92. name: 'wangxiaohu',
  93. authority2: '0',
  94. },
  95. ],
  96. },
  97. {
  98. id: 2,
  99. date: '站点管理',
  100. name: 'wangxiaohu',
  101. authority2: '1',
  102. children: [
  103. {
  104. id: 21,
  105. date: '新增',
  106. name: 'wangxiaohu',
  107. authority2: '1',
  108. },
  109. {
  110. id: 22,
  111. date: '修改',
  112. name: 'wangxiaohu',
  113. authority2: '1',
  114. },
  115. {
  116. id: 23,
  117. date: '删除',
  118. name: 'wangxiaohu',
  119. authority2: '0',
  120. },
  121. ],
  122. },
  123. {
  124. id: 3,
  125. date: '数据管理',
  126. name: 'wangxiaohu',
  127. authority2: '0',
  128. children: [
  129. {
  130. id: 31,
  131. date: '同比分析报表',
  132. name: 'wangxiaohu',
  133. authority2: '0',
  134. children: [
  135. {
  136. id: 41,
  137. date: '新增',
  138. name: 'wangxiaohu',
  139. authority2: '0',
  140. },
  141. {
  142. id: 42,
  143. date: '修改',
  144. name: 'wangxiaohu',
  145. authority2: '0',
  146. },
  147. {
  148. id: 43,
  149. date: '删除',
  150. name: 'wangxiaohu',
  151. authority2: '0',
  152. },
  153. ],
  154. },
  155. {
  156. id: 32,
  157. date: '台区管理',
  158. name: 'wangxiaohu',
  159. authority2: '0',
  160. children: [
  161. {
  162. id: 51,
  163. date: '新增',
  164. name: 'wangxiaohu',
  165. authority2: '0',
  166. },
  167. {
  168. id: 52,
  169. date: '修改',
  170. name: 'wangxiaohu',
  171. authority2: '0',
  172. },
  173. {
  174. id: 53,
  175. date: '删除',
  176. name: 'wangxiaohu',
  177. authority2: '0',
  178. },
  179. ],
  180. },
  181. ],
  182. },
  183. ])
  184. const data = ref([
  185. {
  186. id: 1,
  187. label: '告警管理',
  188. children: [
  189. {
  190. id: 11,
  191. label: '查询',
  192. },
  193. {
  194. id: 12,
  195. label: '新增',
  196. },
  197. {
  198. id: 13,
  199. label: '修改',
  200. },
  201. {
  202. id: 14,
  203. label: '删除',
  204. },
  205. ],
  206. },
  207. {
  208. id: 2,
  209. label: '站点管理',
  210. },
  211. {
  212. id: 3,
  213. label: '台区管理',
  214. children: [
  215. {
  216. id: 31,
  217. label: '查询',
  218. },
  219. {
  220. id: 32,
  221. label: '新增',
  222. },
  223. {
  224. id: 33,
  225. label: '编辑',
  226. },
  227. {
  228. id: 34,
  229. label: '删除',
  230. },
  231. ],
  232. },
  233. {
  234. id: 4,
  235. label: '设备管理',
  236. },
  237. {
  238. id: 5,
  239. label: '数据管理',
  240. children: [
  241. {
  242. id: 51,
  243. label: '同比分析报表',
  244. },
  245. {
  246. id: 52,
  247. label: '环比分析报表',
  248. },
  249. {
  250. id: 53,
  251. label: '用能月报',
  252. },
  253. {
  254. id: 54,
  255. label: '需量分析',
  256. },
  257. ],
  258. },
  259. {
  260. id: 6,
  261. label: '电能质量',
  262. children: [
  263. {
  264. id: 61,
  265. label: '谐波报表',
  266. },
  267. {
  268. id: 62,
  269. label: '实时监测',
  270. },
  271. {
  272. id: 63,
  273. label: '实时评估',
  274. },
  275. {
  276. id: 64,
  277. label: '三项不平衡分析',
  278. },
  279. ],
  280. },
  281. {
  282. id: 7,
  283. label: '计划停电',
  284. children: [
  285. {
  286. id: 71,
  287. label: '查询',
  288. },
  289. {
  290. id: 72,
  291. label: '新增',
  292. },
  293. {
  294. id: 73,
  295. label: '编辑',
  296. },
  297. {
  298. id: 74,
  299. label: '删除',
  300. },
  301. ],
  302. },
  303. {
  304. id: 8,
  305. label: '系统管理',
  306. children: [
  307. {
  308. id: 81,
  309. label: '用户管理',
  310. },
  311. {
  312. id: 82,
  313. label: '权限管理',
  314. },
  315. ],
  316. },
  317. ])
  318. function currentChecked (nodeObj, SelectedObj) {
  319. console.log(SelectedObj)
  320. console.log(SelectedObj.checkedKeys) // 这是选中的节点的key数组
  321. // console.log(SelectedObj.checkedNodes) // 这是选中的节点数组
  322. }
  323. function saveMenu() {
  324. api
  325. .saveMenu({
  326. menuIds: saveArr.value,
  327. roleId: props.radio1,
  328. roleKey: props.objItem.roleKey,
  329. roleName: props.objItem.roleName,
  330. roleSort: props.objItem.roleSort,
  331. })
  332. .then((requset) => {
  333. if (requset.status === 'SUCCESS') {
  334. ElMessage.success({
  335. message: '权限修改成功',
  336. type: 'success',
  337. })
  338. } else {
  339. ElMessage.error(requset.msg)
  340. }
  341. })
  342. }
  343. const listTabsChange = (value) => {
  344. saveArr.value = []
  345. value
  346. props.menuData.forEach(function (item) {
  347. if (item.authority2 == '1') {
  348. saveArr.value.push(item.id)
  349. var aa = item.children
  350. aa.forEach(function (item) {
  351. saveArr.value.push(item.id)
  352. })
  353. }
  354. })
  355. }
  356. onMounted(() => {})
  357. //监听变化
  358. watch(
  359. () => props.radio1,
  360. (newVal) => {
  361. newVal
  362. // if (newVal == '1') {
  363. // alert(1)
  364. // props.menuData.forEach(function (item) {
  365. // item.authority2 = '1'
  366. // saveArr.value.push(item.id)
  367. // })
  368. // console.log(' 22props.menuData')
  369. // console.log(props.menuData)
  370. // }
  371. }
  372. )
  373. return {
  374. saveMenu,
  375. aa,
  376. listTabsChange,
  377. saveArr,
  378. tableData,
  379. data,
  380. currentChecked
  381. }
  382. },
  383. })
  384. </script>
  385. <style lang="scss">
  386. </style>