staffHome.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-11-29 14:37:54
  4. * @LastEditTime: 2022-03-18 10:27:34
  5. * @LastEditors: your name
  6. * @Description: 角色管理
  7. * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\authorityRole.vue
  8. -->
  9. <template>
  10. <div class="authorityRoleHome">
  11. <!--状态和搜索-->
  12. <div style="justify-content: flex-end;" class="authority-head flex">
  13. <Search @getSearchData="getSearchData" @clearSearchData="clearSearchData" :isSlot="true">
  14. <button v-is="['officerlist_btn_add_officer']" @click="addRole" class="btnAdd">新增</button>
  15. </Search>
  16. </div>
  17. <!--列表-->
  18. <template v-if="arrs.length">
  19. <div class="role-content">
  20. <div class="scrollbar" v-infinite-scroll="load" :infinite-scroll-distance="20" infinite-scroll-disabled="disabled">
  21. <el-row :gutter="24">
  22. <el-col :span="6" v-for="(item,index) in arrs" class="account-left-content-teams" :key="index">
  23. <div class="team">
  24. <div class="list">
  25. <div class="flex info">
  26. <div class="info-avoutr">
  27. <div class="msg flex-wrap">
  28. <p :title="item.OfficerName" class="name">{{item.OfficerName}}</p>
  29. <div v-is="['officerlist_btn_edit']" @click="editRole(item)" class="cap cap-edit"></div>
  30. </div>
  31. </div>
  32. <div v-is="['officerlist_btn_del_officer']" class="info-close">
  33. <i @click="checkRemove(item,index)" class="icon el-icon-close"></i>
  34. </div>
  35. </div>
  36. <template v-if="doesJobShow">
  37. <div class="flex ip">
  38. <div class="time-info flex1">职务名称:<span :title="item.JobName" class="glr">{{item.JobName ? item.JobName : '暂无'}}</span></div>
  39. <!-- <div class="ip-info flex1">是否有副岗:<span class="glr">{{item.HasDepJob == 1 ? '是':'否'}}</span></div> -->
  40. </div>
  41. </template>
  42. <div class="flex time">
  43. <div class="time-msg flex1">所属组织:<span :title="item.OrganName" class="glr">{{item.OrganName}}</span></div>
  44. </div>
  45. <div class="flex ip">
  46. <div class="ip-msg flex1">登录名:<span :title="item.LoginName" class="glr">{{item.LoginName}}</span></div>
  47. <div style="margin-right:20px;" class="power">权限:<span class="glr">{{item.AuthCount}}</span></div>
  48. </div>
  49. <div class="flex details">
  50. <div class="details-msg">
  51. 状态:<span :class="item.Status == 1 ? 'success' : 'error'">{{item.Status == 1 ? '启用' : '停用'}}</span>
  52. </div>
  53. <div v-is="['officerlist_btn_state_switch']" class="details-info">
  54. <el-switch v-model="item.isauto" @change="handleChange(item)" active-color="#6F81BC">
  55. </el-switch>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </el-col>
  61. </el-row>
  62. <template v-if="total > 1">
  63. <p class="center" v-if="loading">加载中...</p>
  64. <p class="center" v-if="noMore">没有更多数据了~</p>
  65. </template>
  66. </div>
  67. </div>
  68. </template>
  69. <template v-else>
  70. <el-empty description="暂无数据"></el-empty>
  71. </template>
  72. <!--删除弹框-->
  73. <Dialog :flag="flag">
  74. <div class="airportInfoDialog">
  75. <div class="title">删除职员</div>
  76. <div class="content">是否确认删除{{ title }}?</div>
  77. <div class="foot right t30">
  78. <el-button size="medium" class="r24" @click="remove" type="danger">删除</el-button>
  79. <el-button size="medium" @click="flag = false">取消</el-button>
  80. </div>
  81. </div>
  82. </Dialog>
  83. </div>
  84. </template>
  85. <script>
  86. import Search from '@/layout/components/Search'
  87. import Dialog from '@/layout/components/Dialog'
  88. import roleData from '../minixs/roleData'
  89. import { staffStart } from '@/api/postInterface'
  90. import { GetOfficerListByOrganId } from '@/api/jobApi'
  91. export default {
  92. name: 'AuthorityRole',
  93. components: { Search, Dialog },
  94. mixins: [roleData],
  95. data () {
  96. return {
  97. arrs: [], //卡片数据
  98. arrsCopy: [],
  99. flag: false,
  100. title: '',
  101. index: null,
  102. keyWords: '',
  103. pageNum: 1,
  104. PageSize: 20,
  105. loading: false,
  106. keyWords: '',
  107. total: null,
  108. search: null,
  109. num: null
  110. }
  111. },
  112. created () {
  113. const { OrganId, orgType, keyWords } = this.$route.query;
  114. if (OrganId && orgType == 'org') {
  115. this.OrganId = OrganId;
  116. this.orgType = orgType;
  117. this.getJobListByOrgan(OrganId);
  118. } else {
  119. if (keyWords) {
  120. this.keyWords = keyWords;
  121. }
  122. this.gueryRole({
  123. QueryName: this.keyWords,
  124. PageSize: this.PageSize,
  125. PageIndex: this.pageNum
  126. });
  127. }
  128. },
  129. computed: {
  130. noMore () {
  131. return this.pageNum >= this.total
  132. },
  133. disabled () {
  134. return this.loading || this.noMore
  135. }
  136. },
  137. methods: {
  138. //根据组织查询职员
  139. async getJobListByOrgan (OrganId) {
  140. try {
  141. const res = await GetOfficerListByOrganId({
  142. OrganId: OrganId
  143. });
  144. if (res.code === 0) {
  145. const datas = res.returnData.map(item => {
  146. item.isauto = item.Status == 1
  147. return item
  148. })
  149. this.arrs = datas
  150. this.pageNum = this.total = Math.ceil(datas.length / this.PageSize)
  151. } else {
  152. this.$message.error(res.message)
  153. }
  154. } catch (error) {
  155. console.log('出错了', error)
  156. }
  157. },
  158. //删除
  159. checkRemove (item, num) {
  160. this.flag = true
  161. this.index = item
  162. this.title = item.OfficerName
  163. this.num = num
  164. },
  165. //确认删除
  166. remove () {
  167. this.deleteRole(this.index.OfficerId, this.num)
  168. },
  169. //职员新增
  170. addRole () {
  171. this.$router.push('/staff/staffAdd')
  172. },
  173. //职员编辑
  174. editRole (item) {
  175. this.$router.push({ path: '/staff/staffEdit', query: { OfficerId: item.OfficerId, Status: item.Status } })
  176. },
  177. //查询
  178. getSearchData (val) {
  179. if (val) {
  180. this.$router.replace({ path: '/staff', query: { keyWords: val } })
  181. } else if (this.$route.query) {
  182. this.$router.replace('/staff')
  183. }
  184. this.arrs = []
  185. this.dataList = []
  186. this.pageNum = 1
  187. this.keyWords = val
  188. this.gueryRole({
  189. QueryName: val,
  190. PageSize: this.PageSize,
  191. PageIndex: this.pageNum
  192. })
  193. },
  194. //清除查询
  195. clearSearchData () {
  196. this.$router.replace('/staff')
  197. this.arrs = []
  198. this.dataList = []
  199. this.pageNum = 1
  200. this.keyWords = ''
  201. this.gueryRole({
  202. QueryName: this.keyWords,
  203. PageSize: this.PageSize,
  204. PageIndex: this.pageNum
  205. })
  206. },
  207. //状态变更
  208. async handleChange (item) {
  209. try {
  210. const { OfficerId, isauto } = item
  211. const Status = isauto ? 1 : 0
  212. const res = await staffStart({
  213. OfficerId: OfficerId,
  214. Status: Status
  215. })
  216. if (res.code === 0) {
  217. this.$message.success(res.message)
  218. this.arrs.forEach(item => {
  219. if (item.OfficerId == OfficerId) {
  220. item.isauto = isauto
  221. item.Status = Status
  222. }
  223. })
  224. } else {
  225. this.$message.error(res.message)
  226. }
  227. } catch (error) {
  228. console.log('出错了', error)
  229. }
  230. },
  231. //滚动加载数据
  232. load () {
  233. this.pageNum += 1
  234. this.gueryRole({
  235. QueryName: this.keyWords,
  236. PageSize: this.PageSize,
  237. PageIndex: this.pageNum
  238. })
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. .authorityRoleHome {
  245. padding: 0 64px;
  246. }
  247. .authority-head {
  248. position: fixed;
  249. width: 100%;
  250. padding: 32px 64px;
  251. padding-left: 156px;
  252. left: 0;
  253. display: flex;
  254. flex-direction: row;
  255. justify-content: space-between;
  256. background: #f5f7fa;
  257. z-index: 100;
  258. line-height: 48px;
  259. .status {
  260. & > div {
  261. margin-right: 28px;
  262. .icon {
  263. width: 16px;
  264. height: 16px;
  265. background: #6f81bc;
  266. border-radius: 2px;
  267. display: inline-block;
  268. vertical-align: middle;
  269. margin-right: 10px;
  270. position: relative;
  271. top: -2px;
  272. }
  273. &:last-child {
  274. margin-right: 0;
  275. }
  276. }
  277. .status2 {
  278. .icon {
  279. background: #cfd6e2;
  280. }
  281. }
  282. }
  283. }
  284. .role-content {
  285. padding-top: 112px;
  286. height: calc(100vh - 144px);
  287. .scrollbar {
  288. height: 100%;
  289. overflow-y: auto;
  290. overflow-x: hidden;
  291. > p {
  292. margin: 0;
  293. }
  294. }
  295. .el-col-lg-5-5 {
  296. width: 20%;
  297. }
  298. .account-left-content-teams {
  299. position: relative;
  300. margin-bottom: 24px;
  301. .info-close {
  302. cursor: pointer;
  303. .icon {
  304. color: #303133;
  305. font-weight: 600;
  306. }
  307. }
  308. .list {
  309. .info {
  310. line-height: normal;
  311. margin-bottom: 19px;
  312. .name {
  313. font-size: 16px;
  314. font-weight: bold;
  315. }
  316. .cap {
  317. width: 24px;
  318. height: 24px;
  319. display: inline-block;
  320. background-repeat: no-repeat;
  321. background-size: cover;
  322. transition: all 0.3s;
  323. margin-left: 16px;
  324. cursor: pointer;
  325. &:first-child {
  326. margin-right: 0;
  327. }
  328. }
  329. .cap-plus {
  330. background-image: url("../../../assets/status/ic_plus.png");
  331. &:hover {
  332. background-image: url("../../../assets/status/ic_plus_hovar.png");
  333. }
  334. }
  335. .cap-edit {
  336. background-image: url("../../../assets/status/ic_edit.png");
  337. &:hover {
  338. background-image: url("../../../assets/status/ic_edit_hovar.png");
  339. }
  340. }
  341. .cap-sub {
  342. background-image: url("../../../assets/status/ic_subordinate.png");
  343. &:hover {
  344. background-image: url("../../../assets/status/ic_subordinate_hovar.png");
  345. }
  346. }
  347. }
  348. }
  349. .team {
  350. background: #fff;
  351. border-radius: 5%;
  352. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  353. overflow: hidden;
  354. .bg {
  355. height: 4px;
  356. background: #6f81bc;
  357. }
  358. .status1 {
  359. background: #6f81bc;
  360. }
  361. .status2 {
  362. background: #cfd6e2;
  363. }
  364. }
  365. .list {
  366. padding: 31px 24px 22px 32px;
  367. position: relative;
  368. min-width: 264px;
  369. .info {
  370. margin-bottom: 19px;
  371. .info-avoutr {
  372. display: flex;
  373. .avoutr {
  374. width: 40px;
  375. height: 40px;
  376. border-radius: 50%;
  377. background: #303133;
  378. img {
  379. max-width: 100%;
  380. }
  381. }
  382. .msg {
  383. p {
  384. margin: 0;
  385. padding: 0;
  386. height: 20px;
  387. line-height: 20px;
  388. }
  389. .name {
  390. font-weight: bold;
  391. color: #303133;
  392. font-size: 18px;
  393. max-width: 180px;
  394. white-space: nowrap;
  395. text-overflow: ellipsis;
  396. overflow: hidden;
  397. }
  398. .cap {
  399. position: relative;
  400. top: -3px;
  401. }
  402. .group {
  403. font-size: 14px;
  404. font-family: Microsoft YaHei;
  405. font-weight: 400;
  406. color: #303133;
  407. }
  408. }
  409. }
  410. .icon {
  411. font-size: 16px;
  412. cursor: pointer;
  413. }
  414. }
  415. .time,
  416. .ip {
  417. height: 16px;
  418. line-height: 16px;
  419. font-size: 16px;
  420. .glr {
  421. color: #909399;
  422. display: inline-block;
  423. // max-width: 60px;
  424. overflow: hidden;
  425. position: relative;
  426. white-space: nowrap;
  427. top: 4px;
  428. text-overflow: ellipsis;
  429. }
  430. }
  431. .ip {
  432. margin-top: 14px;
  433. margin-bottom: 14px;
  434. }
  435. .details {
  436. height: 24px;
  437. line-height: 24px;
  438. .success {
  439. color: #6f80bc;
  440. }
  441. .error {
  442. color: #f25555;
  443. }
  444. }
  445. }
  446. }
  447. }
  448. </style>