authorityRoleHome.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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.index.operator_id = sessionStorage.getItem("User_Id");
  184. this.editRoles(this.index);
  185. },
  186. //角色新增
  187. addRole() {
  188. this.editDialogTitle = "新增角色";
  189. this.editDialogVisible = true;
  190. this.editType = "add";
  191. // this.$router.push('/role/addRole')
  192. },
  193. //角色编辑
  194. editRole(item) {
  195. this.editDialogVisible = true;
  196. this.editType = "edit";
  197. this.editDialogTitle = "编辑角色";
  198. this.roleId = item.role_id;
  199. this.ruleForm = _.cloneDeep(item);
  200. },
  201. pageInit() {
  202. this.needPage = 1;
  203. this.arrs = [];
  204. this.queryData();
  205. },
  206. //新增角色
  207. async editRoles(params) {
  208. try {
  209. const res = await GeneralDataReception({
  210. serviceId: SERVICE_ID.roleMsgId,
  211. dataContent: JSON.stringify(params),
  212. });
  213. if (res.code === "0") {
  214. this.flag = false;
  215. this.$message.success(res.message);
  216. this.pageInit();
  217. } else {
  218. this.flag = false;
  219. this.$message.error(res.message);
  220. }
  221. } catch (error) {
  222. this.flag = false;
  223. console.log("出错了", error.message || error);
  224. }
  225. },
  226. // 角色授权
  227. authRole(item) {
  228. this.$router.push({
  229. path: "/role/editRole",
  230. query: { RoleId: item.role_id },
  231. });
  232. },
  233. //查询
  234. getSearchData(val) {
  235. this.arrs = [];
  236. this.needPage = 1;
  237. this.keyWords = val;
  238. this.queryData();
  239. },
  240. //清除查询
  241. clearSearchData() {
  242. this.arrs = [];
  243. this.needPage = 1;
  244. this.keyWords = "";
  245. this.queryData();
  246. },
  247. // 新增/编辑-确认
  248. submitClickHandler() {
  249. this.$refs["ruleForm"].validate((valid) => {
  250. if (valid) {
  251. if (this.editType == "add") {
  252. this.ruleForm.event = 1;
  253. this.ruleForm.operator_id = sessionStorage.getItem("User_Id");
  254. this.editRoles(this.ruleForm);
  255. } else {
  256. this.ruleForm.event = 2;
  257. this.ruleForm.operator_id = sessionStorage.getItem("User_Id");
  258. this.editRoles(this.ruleForm);
  259. }
  260. this.resetForm("ruleForm");
  261. } else {
  262. return false;
  263. }
  264. });
  265. },
  266. // 重置
  267. resetForm(formName) {
  268. this.ruleForm = {};
  269. this.$refs[formName].resetFields();
  270. this.editDialogVisible = false;
  271. },
  272. //滚动加载数据
  273. load() {
  274. this.needPage += 1;
  275. this.queryData();
  276. },
  277. },
  278. };
  279. </script>
  280. <style lang="scss" scoped>
  281. .authorityRoleHome {
  282. // padding: 0 64px;
  283. padding: 16px 32px 32px 32px;
  284. }
  285. .authority-head {
  286. line-height: 32px;
  287. .status {
  288. & > div {
  289. .icon {
  290. width: 14px;
  291. height: 14px;
  292. background: #2d67e3;
  293. border-radius: 2px;
  294. display: inline-block;
  295. vertical-align: middle;
  296. margin-right: 10px;
  297. position: relative;
  298. top: -2px;
  299. }
  300. &:last-child {
  301. margin-right: 0;
  302. }
  303. }
  304. .status1 {
  305. font-size: 14px;
  306. margin-right: 28px;
  307. }
  308. .status2 {
  309. font-size: 14px;
  310. .icon {
  311. background: #afb4bf;
  312. }
  313. }
  314. }
  315. }
  316. .role-content {
  317. margin-top: 24px;
  318. height: 72vh;
  319. overflow-y: auto;
  320. overflow-x: hidden;
  321. .el-col-lg-5-5 {
  322. width: 20%;
  323. }
  324. .account-left-content-teams {
  325. position: relative;
  326. margin-bottom: 24px;
  327. .info-close {
  328. cursor: pointer;
  329. .icon {
  330. color: #303133;
  331. font-weight: 600;
  332. }
  333. }
  334. .list {
  335. .info {
  336. line-height: normal;
  337. margin-bottom: 19px;
  338. .name {
  339. font-size: 16px;
  340. font-weight: bold;
  341. }
  342. .cap {
  343. width: 14px;
  344. height: 14px;
  345. display: inline-block;
  346. background-repeat: no-repeat;
  347. background-size: cover;
  348. transition: all 0.3s;
  349. margin-left: 24px;
  350. cursor: pointer;
  351. &:first-child {
  352. margin-right: 0;
  353. }
  354. }
  355. .cap-plus {
  356. background-image: url("../../../assets/status/ic_plus.png");
  357. &:hover {
  358. background-image: url("../../../assets/status/ic_plus_hovar.png");
  359. }
  360. }
  361. .cap-edit {
  362. background-image: url("../../../assets/status/ic_edit_default.png");
  363. &:hover {
  364. background-image: url("../../../assets/status/ic_edit_hovar.png");
  365. }
  366. }
  367. .cap-sub {
  368. background-image: url("../../../assets/status/ic_subordinate.png");
  369. &:hover {
  370. background-image: url("../../../assets/status/ic_subordinate_hovar.png");
  371. }
  372. }
  373. .cap-auth {
  374. margin-left: 12px;
  375. background-image: url("../../../assets/status/ic_edit_authorization.png");
  376. &:hover {
  377. background-image: url("../../../assets/status/ic_edit_authorization_hover.png");
  378. }
  379. }
  380. }
  381. }
  382. .team {
  383. background: #fff;
  384. border-radius: 4px;
  385. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  386. overflow: hidden;
  387. .bg {
  388. height: 4px;
  389. background: #2d67e3;
  390. }
  391. .status1 {
  392. background: #2d67e3;
  393. }
  394. .status2 {
  395. background: #afb4bf;
  396. }
  397. }
  398. .list {
  399. padding: 24px;
  400. position: relative;
  401. min-width: 264px;
  402. .info {
  403. margin-bottom: 19px;
  404. .info-avoutr {
  405. display: flex;
  406. .avoutr {
  407. width: 40px;
  408. height: 40px;
  409. border-radius: 50%;
  410. background: #303133;
  411. img {
  412. max-width: 100%;
  413. }
  414. }
  415. .msg {
  416. p {
  417. margin: 0;
  418. padding: 0;
  419. height: 20px;
  420. line-height: 20px;
  421. }
  422. .name {
  423. font-weight: bold;
  424. color: #303133;
  425. font-size: 16px;
  426. max-width: 115px;
  427. white-space: nowrap;
  428. text-overflow: ellipsis;
  429. overflow: hidden;
  430. }
  431. .cap {
  432. position: relative;
  433. top: 2px;
  434. }
  435. .group {
  436. font-size: 14px;
  437. font-family: Microsoft YaHei;
  438. font-weight: 400;
  439. color: #303133;
  440. }
  441. }
  442. }
  443. .icon {
  444. font-size: 14px;
  445. cursor: pointer;
  446. }
  447. }
  448. .time,
  449. .details,
  450. .ip {
  451. height: 14px;
  452. line-height: 14px;
  453. font-size: 14px;
  454. .glr {
  455. color: #909399;
  456. }
  457. }
  458. .ip {
  459. margin-top: 14px;
  460. margin-bottom: 14px;
  461. }
  462. .details {
  463. height: 24px;
  464. line-height: 24px;
  465. .success {
  466. color: #2d67e3;
  467. }
  468. .error {
  469. color: #afb4bf;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. </style>