血透系统PC前端

role.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <el-button
  6. type="primary"
  7. size="small"
  8. icon="el-icon-circle-plus"
  9. style="float:right;"
  10. @click="addRoleAction"
  11. >新增</el-button>
  12. </div>
  13. <div class="app-container">
  14. <!-- <el-table
  15. :data="roles"
  16. v-loading="loading_roles"
  17. border
  18. :row-style="{ color: '#303133' }"
  19. :header-cell-style="{
  20. backgroundColor: 'rgb(245, 247, 250)',
  21. color: '#606266'
  22. }"
  23. >
  24. <el-table-column label="角色名称" prop="name" min-width="20%" align="center"></el-table-column>
  25. <el-table-column label="角色描述" prop="intro" min-width="25%" align="center"></el-table-column>
  26. <el-table-column label="状态" min-width="15%" align="center">
  27. <template slot-scope="scope">
  28. <div v-if="scope.row.status == 1" style="color: #67C23A; font-size:20px;">
  29. <li class="el-icon-success"></li>
  30. </div>
  31. <div v-else style="color: #F56C6C; font-size:20px;">
  32. <li class="el-icon-error"></li>
  33. </div>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="操作" width="180" align="center">
  37. <template slot-scope="scope">
  38. <router-link :to="{ path: '/role/perview', query: { id: scope.row.id } }">
  39. <el-tooltip class="item" effect="dark" content="权限设置" placement="top">
  40. <el-button type="warning" icon="el-icon-setting" size="small"></el-button>
  41. </el-tooltip>
  42. </router-link>
  43. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  44. <el-button
  45. type="primary"
  46. size="small"
  47. icon="el-icon-edit-outline"
  48. @click="modifyRoleAction(scope.row)"
  49. ></el-button>
  50. </el-tooltip>
  51. <el-tooltip class="item" effect="dark" content="移除" placement="top">
  52. <el-button
  53. type="danger"
  54. size="small"
  55. icon="el-icon-delete"
  56. v-if="scope.row.status === 1"
  57. @click="disableRoleAction(scope.row)"
  58. ></el-button>
  59. </el-tooltip>
  60. <el-tooltip class="item" effect="dark" content="恢复" placement="top">
  61. <el-button
  62. type="info"
  63. size="small"
  64. icon="el-icon-refresh"
  65. v-if="scope.row.status !== 1"
  66. @click="recoverRoleAction(scope.row)"
  67. ></el-button>
  68. </el-tooltip>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <el-row style="margin-top: 15px;" v-if="role_total_count > 10">
  73. <el-col :span="24">
  74. <el-pagination
  75. :total="role_total_count"
  76. :current-page.sync="current_page"
  77. @current-change="pageChange"
  78. :page-size="10"
  79. layout="total, prev, pager, next, jumper"
  80. ></el-pagination>
  81. </el-col>
  82. </el-row>-->
  83. <edit-role ref="edit_role" @did-add-role="didAddRole" @did-edit-role="didModifyRole"></edit-role>
  84. <permission-settings ref="permission_settings"></permission-settings>
  85. <div class="roleBox">
  86. <div class="roleOne">
  87. <div class="setting">
  88. <i class="el-icon-setting"></i>
  89. <span style="margin-right:20px" @click="onClick">权限配置</span>
  90. </div>
  91. <div class="avatar">
  92. <img src="../../assets/img/pc1.png" alt />
  93. <p class="avatarname">子管理员</p>
  94. </div>
  95. <div class="roleTip">子管理员角色具备平台全部功能的使用权限,请谨慎配置...</div>
  96. <div class="roleTxt">
  97. 该角色目前已配置
  98. <span style="color:#4A8AF3">0</span> 个员工
  99. </div>
  100. <div class="btnBox">
  101. <el-button>新增用户</el-button>
  102. <el-button>用户管理</el-button>
  103. </div>
  104. </div>
  105. <div class="roleOne">
  106. <div class="setting">
  107. <i class="el-icon-setting"></i>
  108. <span style="margin-right:20px">权限配置</span>
  109. </div>
  110. <div class="avatar">
  111. <img src="../../assets/img/pc2.png" alt />
  112. <p class="avatarname">医生</p>
  113. </div>
  114. <div class="roleTip">医生角色能够进行建立患者档案,制定和调整患者透析治疗方案,定期评价病人的透析质量等...</div>
  115. <div class="roleTxt">
  116. 该角色目前已配置
  117. <span style="color:#4A8AF3">0</span> 个员工
  118. </div>
  119. <div class="btnBox">
  120. <el-button>新增用户</el-button>
  121. <el-button>用户管理</el-button>
  122. </div>
  123. </div>
  124. <div class="roleOne">
  125. <div class="setting">
  126. <i class="el-icon-setting"></i>
  127. <span style="margin-right:20px">权限配置</span>
  128. </div>
  129. <div class="avatar">
  130. <img src="../../assets/img/pc3.png" alt />
  131. <p class="avatarname">护士</p>
  132. </div>
  133. <div class="roleTip">护士角色能够进行病人透析管理,以及医院的感染控制与消毒记录等...</div>
  134. <div class="roleTxt">
  135. 该角色目前已配置
  136. <span style="color:#4A8AF3">0</span> 个员工
  137. </div>
  138. <div class="btnBox">
  139. <el-button>新增用户</el-button>
  140. <el-button>用户管理</el-button>
  141. </div>
  142. </div>
  143. <div class="roleOne">
  144. <div class="setting">
  145. <i class="el-icon-setting"></i>
  146. <span style="margin-right:20px">权限配置</span>
  147. </div>
  148. <div class="avatar">
  149. <img src="../../assets/img/pc2.png" alt />
  150. <p class="avatarname">技师</p>
  151. </div>
  152. <div class="roleTip">技师角色能够进行设备的管理,日常维护维修记录等...</div>
  153. <div class="roleTxt">
  154. 该角色目前已配置
  155. <span style="color:#4A8AF3">0</span> 个员工
  156. </div>
  157. <div class="btnBox">
  158. <el-button>新增用户</el-button>
  159. <el-button>用户管理</el-button>
  160. </div>
  161. </div>
  162. <div class="roleOne">
  163. <div class="setting">
  164. <i class="el-icon-setting"></i>
  165. <span style="margin-right:20px">权限配置</span>
  166. </div>
  167. <div class="avatar">
  168. <img src="../../assets/img/pc2.png" alt />
  169. <p class="avatarname">运营</p>
  170. </div>
  171. <div class="roleTip">运营角色能够在SCRM中管理微网站、使用营销工具、做会员管理和分销商品经营的操作...</div>
  172. <div class="roleTxt">
  173. 该角色目前已配置
  174. <span style="color:#4A8AF3">0</span> 个员工
  175. </div>
  176. <div class="btnBox">
  177. <el-button>新增用户</el-button>
  178. <el-button>用户管理</el-button>
  179. </div>
  180. </div>
  181. <div class="roleOne">
  182. <div class="setting">
  183. <i class="el-icon-setting"></i>
  184. <span style="margin-right:20px">权限配置</span>
  185. </div>
  186. <div class="avatar">
  187. <img src="../../assets/img/pc4.png" alt />
  188. <p class="avatarname">库存</p>
  189. </div>
  190. <div class="roleTip">库存角色负责透析耗材的日常管理,对耗材的入库、出库、退库的登记操作...</div>
  191. <div class="roleTxt">
  192. 该角色目前已配置
  193. <span style="color:#4A8AF3">0</span> 个员工
  194. </div>
  195. <div class="btnBox">
  196. <el-button>新增用户</el-button>
  197. <el-button>用户管理</el-button>
  198. </div>
  199. </div>
  200. <div class="roleOne">
  201. <div class="setting">
  202. <i class="el-icon-setting"></i>
  203. <span style="margin-right:20px">权限配置</span>
  204. </div>
  205. <div class="avatar">
  206. <img src="../../assets/img/pc5.png" alt />
  207. <p class="avatarname">院长</p>
  208. </div>
  209. <div class="roleTip">院长角色了解血透患者血液透析质量和相关的大数据,以及掌握透析中心整体运营情况</div>
  210. <div class="roleTxt">
  211. 该角色目前已配置
  212. <span style="color:#4A8AF3">0</span> 个员工
  213. </div>
  214. <div class="btnBox">
  215. <el-button>新增用户</el-button>
  216. <el-button>用户管理</el-button>
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. </div>
  222. </template>
  223. <script>
  224. import EditRole from "./components/EditRole.vue";
  225. import PermissionSettings from "./components/PermissionSettings.vue";
  226. import { getRoles, setRoleStatus } from "@/api/role/role";
  227. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  228. export default {
  229. components: {
  230. EditRole,
  231. BreadCrumb,
  232. PermissionSettings
  233. },
  234. data: function() {
  235. return {
  236. crumbs: [
  237. { path: false, name: "权限管理" },
  238. { path: false, name: "角色管理" }
  239. ],
  240. loading_roles: true,
  241. roles: [],
  242. role_total_count: 0,
  243. current_page: 1
  244. };
  245. },
  246. created: function() {
  247. this.requestRoleWithPage(1);
  248. },
  249. methods: {
  250. requestRoleWithPage: function(page) {
  251. this.roles.splice(0, this.roles.length);
  252. this.loading_roles = true;
  253. getRoles(page)
  254. .then(rs => {
  255. this.loading_roles = false;
  256. const resp = rs.data;
  257. if (resp.state === 1) {
  258. this.roles.push(...resp.data.roles);
  259. this.role_total_count = resp.data.total_count;
  260. } else {
  261. this.$message.error(resp.msg);
  262. }
  263. })
  264. .catch(err => {
  265. this.loading_roles = false;
  266. this.$message.error(err);
  267. });
  268. },
  269. addRoleAction: function() {
  270. // 父组件调用子组件方法 https://segmentfault.com/a/1190000009525355
  271. this.$refs.edit_role.show();
  272. },
  273. modifyRoleAction: function(row) {
  274. this.$refs.edit_role.modify(row.id, row.name, row.intro);
  275. },
  276. disableRoleAction: function(row) {
  277. this.$msgbox({
  278. title: "提示",
  279. message: "是否确定要移除该角色",
  280. showCancelButton: true,
  281. confirmButtonText: "确定",
  282. cancelButtonText: "取消",
  283. type: "warning",
  284. beforeClose: (action, instance, done) => {
  285. if (action === "confirm") {
  286. instance.confirmButtonLoading = true;
  287. instance.confirmButtonText = "移除中...";
  288. setRoleStatus(row.id, false)
  289. .then(rs => {
  290. done();
  291. instance.confirmButtonLoading = false;
  292. const resp = rs.data;
  293. if (resp.state === 1) {
  294. row.status = 0;
  295. } else {
  296. this.$message.error(resp.msg);
  297. }
  298. })
  299. .catch(err => {
  300. done();
  301. this.$message.error(err);
  302. instance.confirmButtonLoading = false;
  303. });
  304. } else {
  305. done();
  306. }
  307. }
  308. });
  309. },
  310. recoverRoleAction: function(row) {
  311. const loading = this.$loading({
  312. lock: true,
  313. text: "正在恢复角色...",
  314. spinner: "el-icon-loading",
  315. background: "rgba(0, 0, 0, 0.7)"
  316. });
  317. setRoleStatus(row.id, true)
  318. .then(rs => {
  319. loading.close();
  320. const resp = rs.data;
  321. if (resp.state === 1) {
  322. row.status = 1;
  323. } else {
  324. this.$message.error(resp.msg);
  325. }
  326. })
  327. .catch(err => {
  328. loading.close();
  329. this.$message.error(err);
  330. });
  331. },
  332. didAddRole: function(id, name, intro, status) {
  333. this.roles.push({ id: id, name: name, intro: intro, status: status });
  334. },
  335. didModifyRole: function(id, name, intro) {
  336. this.roles.forEach(role => {
  337. if (role.id === id) {
  338. role.name = name;
  339. role.intro = intro;
  340. return false;
  341. }
  342. });
  343. },
  344. pageChange: function(nextPage) {
  345. this.requestRoleWithPage(nextPage);
  346. },
  347. ///
  348. onClick() {
  349. this.$refs.permission_settings.show();
  350. }
  351. }
  352. };
  353. </script>
  354. <style rel="stylesheet/scss" lang="scss" scoped>
  355. .el-button + .el-button {
  356. margin-left: 0 !important;
  357. }
  358. .roleBox {
  359. display: flex;
  360. flex-wrap: wrap;
  361. .roleOne {
  362. width: 280px;
  363. height: 350px;
  364. margin: 0 15px 20px;
  365. border: 1px solid rgba(235, 238, 240, 1);
  366. border-radius: 4px;
  367. overflow: hidden;
  368. }
  369. .setting {
  370. // float: right;
  371. text-align: right;
  372. margin-right: 20px;
  373. margin-top: 20px;
  374. width: 100%;
  375. color: #313234;
  376. }
  377. .avatar {
  378. width: 100%;
  379. display: flex;
  380. justify-content: space-around;
  381. flex-direction: column;
  382. align-items: center;
  383. img {
  384. width: 60px;
  385. height: 60px;
  386. margin: 10px 0;
  387. }
  388. .avatarname {
  389. font-size: 18px;
  390. }
  391. }
  392. .roleTip {
  393. width: 82%;
  394. margin: 20px auto 10px;
  395. font-size: 14px;
  396. color: #989898;
  397. }
  398. .roleTxt {
  399. width: 82%;
  400. margin: 0 auto;
  401. font-size: 14px;
  402. color: #666666;
  403. }
  404. .btnBox {
  405. width: 82%;
  406. margin: 0 auto;
  407. display: flex;
  408. justify-content: space-between;
  409. margin-top: 50px;
  410. }
  411. }
  412. </style>
  413. <style>
  414. .el-table td,
  415. .el-table th.is-leaf,
  416. .el-table--border,
  417. .el-table--group {
  418. border-color: #d0d3da;
  419. }
  420. .el-table--border::after,
  421. .el-table--group::after,
  422. .el-table::before {
  423. background-color: #d0d3da;
  424. }
  425. </style>