authorityRoleHome.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-11-29 14:37:54
  4. * @LastEditTime: 2022-03-03 10:29:05
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 角色管理
  7. * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\authorityRole.vue
  8. -->
  9. <template>
  10. <div class="authorityRoleHome">
  11. <!--状态和搜索-->
  12. <div class="authority-head flex">
  13. <div class="status flex-wrap">
  14. <div class="manageTitle">角色管理</div>
  15. <!-- <div class="status1"><span class="icon"></span>存在互斥</div>
  16. <div class="status2"><span class="icon"></span>不存在互斥</div> -->
  17. </div>
  18. <Search @getSearchData="getSearchData" @clearSearchData="clearSearchData" :isTitle="false" :isSlot="true">
  19. <button @click="addRole" class="btnAdd">新增</button>
  20. </Search>
  21. </div>
  22. <!--列表-->
  23. <div class="role-content scrollbar infinite-list-wrapper">
  24. <template v-if="arrs.length">
  25. <el-row v-infinite-scroll="load" :infinite-scroll-distance="20" infinite-scroll-disabled="disabled" :gutter="24">
  26. <el-col v-for="(item, index) in arrs" class="account-left-content-teams" :lg="4" :key="index">
  27. <div class="team">
  28. <!-- <div :class="'status'+ item.IsDef" class="bg"></div> -->
  29. <div class="list">
  30. <div class="flex info">
  31. <div class="info-avoutr">
  32. <div class="msg flex-wrap">
  33. <p :title="item.role_name" class="name">{{ item.role_name }}</p>
  34. <div @click="editRole(item)" class="cap cap-edit"></div>
  35. <div @click="authRole(item)" class="cap cap-auth"></div>
  36. </div>
  37. </div>
  38. <div class="info-close">
  39. <i @click="checkRemove(item, index)" class="icon el-icon-close"></i>
  40. </div>
  41. </div>
  42. <div class="flex-wrap time">
  43. <div class="time-msg">账号数:</div>
  44. <div class="time-info glr">{{ item.UserCount }}</div>
  45. </div>
  46. <div class="flex-wrap ip">
  47. <div class="ip-msg">权限项数:</div>
  48. <div class="ip-info glr">{{ item.AuthCount }}</div>
  49. </div>
  50. <!-- <div class="flex details">
  51. <div class="details-msg">
  52. 状态:<span :class="item.Status == 1 ? 'success' : 'error'">{{item.Status == 1 ? '启用' : '停用'}}</span>
  53. </div>
  54. <div v-is="['role_state switch']" class="details-info">
  55. <el-switch v-model="item.isauto" @change="handleChange(item)" active-color="#2D67E3">
  56. </el-switch>
  57. </div>
  58. </div> -->
  59. </div>
  60. </div>
  61. </el-col>
  62. </el-row>
  63. <template v-if="total > 1">
  64. <p class="center" v-if="loading">加载中...</p>
  65. <p class="center" v-if="noMore">没有更多数据了~</p>
  66. </template>
  67. </template>
  68. <template v-else>
  69. <NoData />
  70. </template>
  71. </div>
  72. <!--删除弹框-->
  73. <Dialog :flag="flag">
  74. <div class="airportInfoDialog">
  75. <div class="title del-title">删除角色</div>
  76. <div class="content del-content">
  77. <span class="el-icon-error error r10"></span>您是否确认删除<span class="error l10">{{ title }}</span>
  78. </div>
  79. <div class="foot right Delfoot t30">
  80. <el-button size="medium" class="r24" @click="remove" type="danger">删除</el-button>
  81. <el-button size="medium" @click="flag = false">取消</el-button>
  82. </div>
  83. </div>
  84. </Dialog>
  85. <!--新增/编辑-->
  86. <Dialog :flag="editDialogVisible" width="508px" :show-flag="true">
  87. <div class="airportInfoDialog dialog-public-background">
  88. <div class="title">{{ editDialogTitle }}</div>
  89. <div class="content">
  90. <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="130px" class="demo-ruleForm">
  91. <el-form-item label="角色名称" prop="role_name">
  92. <el-input v-model="ruleForm.role_name" size="medium" placeholder="请输入节点名称(必填)" />
  93. </el-form-item>
  94. <el-form-item label="角色描述" prop="role_comment">
  95. <el-input v-model="ruleForm.role_comment" size="medium" type="textarea" :rows="3" placeholder="请输入跟踪节点描述" />
  96. </el-form-item>
  97. </el-form>
  98. </div>
  99. <div class="foot center t30">
  100. <el-button size="medium" type="primary" class="r25 r26" @click="submitClickHandler()">提交</el-button>
  101. <el-button size="medium" class="r26" @click="resetForm('ruleForm')">取消</el-button>
  102. </div>
  103. </div>
  104. </Dialog>
  105. </div>
  106. </template>
  107. <script>
  108. import Search from "@/layout/components/Search";
  109. import Dialog from "@/layout/components/Dialog";
  110. import roleData from "../minixs/roleData";
  111. import NoData from '@/components/nodata';
  112. import { Query, GeneralDataReception } from "@/api/dataIntegration";
  113. export default {
  114. name: "AuthorityRole",
  115. components: { Search, Dialog, NoData },
  116. mixins: [roleData],
  117. data () {
  118. return {
  119. arrs: [], //卡片数据
  120. arr: [],
  121. arrsCopy: [],
  122. flag: false,
  123. title: "",
  124. index: null,
  125. num: null,
  126. pageNum: 1,
  127. PageSize: 20,
  128. loading: false,
  129. keyWords: "",
  130. total: null,
  131. search: null,
  132. editDialogVisible: false,
  133. editDialogTitle: "新增角色",
  134. editType: "add",
  135. ruleForm: {
  136. // 协议信息表单
  137. role_name: "",
  138. role_comment: "",
  139. },
  140. rules: {
  141. // 协议信息表单验证
  142. role_name: [{ required: true, message: "请输入角色名称", trigger: "blur" }],
  143. },
  144. ruleFormObj: {},
  145. roleId: "",
  146. needPage: 1,
  147. };
  148. },
  149. created () {
  150. if (this.$route.query.keyWords) {
  151. keyWords = this.$route.query.keyWords;
  152. this.keyWords = keyWords;
  153. }
  154. this.queryData();
  155. },
  156. computed: {
  157. noMore () {
  158. return this.pageNum >= this.total;
  159. },
  160. disabled () {
  161. return this.loading || this.noMore;
  162. },
  163. },
  164. methods: {
  165. queryData () {
  166. let data = {
  167. id: DATACONTENT_ID.roleTableId,
  168. dataContent: [this.keyWords],
  169. needPage: this.needPage,
  170. };
  171. this.gueryRole(data);
  172. },
  173. //删除
  174. checkRemove (item, index) {
  175. this.flag = true;
  176. this.index = item;
  177. this.title = item.role_name;
  178. this.num = index;
  179. },
  180. //确认删除
  181. remove () {
  182. this.index.event = 3;
  183. this.editRoles(this.index);
  184. },
  185. //角色新增
  186. addRole () {
  187. this.editDialogTitle = "新增角色";
  188. this.editDialogVisible = true;
  189. this.editType = "add";
  190. // this.$router.push('/role/addRole')
  191. },
  192. //角色编辑
  193. editRole (item) {
  194. this.editDialogVisible = true;
  195. this.editType = "edit";
  196. this.editDialogTitle = "编辑角色";
  197. this.roleId = item.role_id;
  198. this.ruleForm = JSON.parse(JSON.stringify(item));
  199. },
  200. pageInit () {
  201. this.needPage = 1
  202. this.arrs = []
  203. this.queryData()
  204. },
  205. //新增角色
  206. async editRoles (params) {
  207. try {
  208. const res = await GeneralDataReception({
  209. serviceId: SERVICE_ID.roleMsgId,
  210. dataContent: JSON.stringify(params),
  211. });
  212. if (res.code === "0") {
  213. this.flag = false;
  214. this.$message.success(res.message);
  215. this.pageInit();
  216. } else {
  217. this.flag = false;
  218. this.$message.error(res.message);
  219. }
  220. } catch (error) {
  221. this.flag = false;
  222. console.log("出错了", error);
  223. }
  224. },
  225. // 角色授权
  226. authRole (item) {
  227. this.$router.push({
  228. path: "/role/editRole",
  229. query: { RoleId: item.role_id },
  230. });
  231. },
  232. //查询
  233. getSearchData (val) {
  234. this.arrs = [];
  235. this.needPage = 1;
  236. this.keyWords = val;
  237. this.queryData()
  238. },
  239. //清除查询
  240. clearSearchData () {
  241. this.arrs = [];
  242. this.needPage = 1;
  243. this.keyWords = "";
  244. this.queryData()
  245. },
  246. // 新增/编辑-确认
  247. submitClickHandler () {
  248. this.$refs["ruleForm"].validate((valid) => {
  249. if (valid) {
  250. if (this.editType == "add") {
  251. this.ruleForm.event = 1;
  252. this.editRoles(this.ruleForm);
  253. } else {
  254. this.ruleForm.event = 2;
  255. this.editRoles(this.ruleForm);
  256. }
  257. this.resetForm("ruleForm");
  258. } else {
  259. return false;
  260. }
  261. });
  262. },
  263. // 重置
  264. resetForm (formName) {
  265. this.ruleForm = [];
  266. this.$refs[formName].resetFields();
  267. this.editDialogVisible = false;
  268. },
  269. //滚动加载数据
  270. load () {
  271. this.needPage += 1
  272. this.queryData()
  273. },
  274. },
  275. };
  276. </script>
  277. <style lang="scss" scoped>
  278. .authorityRoleHome {
  279. // padding: 0 64px;
  280. padding: 16px 32px 32px 32px;
  281. }
  282. .authority-head {
  283. line-height: 32px;
  284. .status {
  285. & > div {
  286. .icon {
  287. width: 14px;
  288. height: 14px;
  289. background: #2d67e3;
  290. border-radius: 2px;
  291. display: inline-block;
  292. vertical-align: middle;
  293. margin-right: 10px;
  294. position: relative;
  295. top: -2px;
  296. }
  297. &:last-child {
  298. margin-right: 0;
  299. }
  300. }
  301. .status1 {
  302. font-size: 14px;
  303. margin-right: 28px;
  304. }
  305. .status2 {
  306. font-size: 14px;
  307. .icon {
  308. background: #afb4bf;
  309. }
  310. }
  311. }
  312. }
  313. .role-content {
  314. margin-top: 24px;
  315. height: 72vh;
  316. overflow-y: auto;
  317. overflow-x: hidden;
  318. .el-col-lg-5-5 {
  319. width: 20%;
  320. }
  321. .account-left-content-teams {
  322. position: relative;
  323. margin-bottom: 24px;
  324. .info-close {
  325. cursor: pointer;
  326. .icon {
  327. color: #303133;
  328. font-weight: 600;
  329. }
  330. }
  331. .list {
  332. .info {
  333. line-height: normal;
  334. margin-bottom: 19px;
  335. .name {
  336. font-size: 16px;
  337. font-weight: bold;
  338. }
  339. .cap {
  340. width: 14px;
  341. height: 14px;
  342. display: inline-block;
  343. background-repeat: no-repeat;
  344. background-size: cover;
  345. transition: all 0.3s;
  346. margin-left: 24px;
  347. cursor: pointer;
  348. &:first-child {
  349. margin-right: 0;
  350. }
  351. }
  352. .cap-plus {
  353. background-image: url("../../../assets/status/ic_plus.png");
  354. &:hover {
  355. background-image: url("../../../assets/status/ic_plus_hovar.png");
  356. }
  357. }
  358. .cap-edit {
  359. background-image: url("../../../assets/status/ic_edit_default.png");
  360. &:hover {
  361. background-image: url("../../../assets/status/ic_edit_hovar.png");
  362. }
  363. }
  364. .cap-sub {
  365. background-image: url("../../../assets/status/ic_subordinate.png");
  366. &:hover {
  367. background-image: url("../../../assets/status/ic_subordinate_hovar.png");
  368. }
  369. }
  370. .cap-auth {
  371. margin-left: 12px;
  372. background-image: url("../../../assets/status/ic_edit_authorization.png");
  373. &:hover {
  374. background-image: url("../../../assets/status/ic_edit_authorization_hover.png");
  375. }
  376. }
  377. }
  378. }
  379. .team {
  380. background: #fff;
  381. border-radius: 4px;
  382. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  383. overflow: hidden;
  384. .bg {
  385. height: 4px;
  386. background: #2d67e3;
  387. }
  388. .status1 {
  389. background: #2d67e3;
  390. }
  391. .status2 {
  392. background: #afb4bf;
  393. }
  394. }
  395. .list {
  396. padding: 24px;
  397. position: relative;
  398. min-width: 264px;
  399. .info {
  400. margin-bottom: 19px;
  401. .info-avoutr {
  402. display: flex;
  403. .avoutr {
  404. width: 40px;
  405. height: 40px;
  406. border-radius: 50%;
  407. background: #303133;
  408. img {
  409. max-width: 100%;
  410. }
  411. }
  412. .msg {
  413. p {
  414. margin: 0;
  415. padding: 0;
  416. height: 20px;
  417. line-height: 20px;
  418. }
  419. .name {
  420. font-weight: bold;
  421. color: #303133;
  422. font-size: 16px;
  423. max-width: 180px;
  424. white-space: nowrap;
  425. text-overflow: ellipsis;
  426. overflow: hidden;
  427. }
  428. .cap {
  429. position: relative;
  430. top: 2px;
  431. }
  432. .group {
  433. font-size: 14px;
  434. font-family: Microsoft YaHei;
  435. font-weight: 400;
  436. color: #303133;
  437. }
  438. }
  439. }
  440. .icon {
  441. font-size: 14px;
  442. cursor: pointer;
  443. }
  444. }
  445. .time,
  446. .details,
  447. .ip {
  448. height: 14px;
  449. line-height: 14px;
  450. font-size: 14px;
  451. .glr {
  452. color: #909399;
  453. }
  454. }
  455. .ip {
  456. margin-top: 14px;
  457. margin-bottom: 14px;
  458. }
  459. .details {
  460. height: 24px;
  461. line-height: 24px;
  462. .success {
  463. color: #2d67e3;
  464. }
  465. .error {
  466. color: #afb4bf;
  467. }
  468. }
  469. }
  470. }
  471. }
  472. </style>