managementList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view>
  3. <u-navbar title="授权管理" title-color="#101010" :is-back="isback" >
  4. <view slot="right" v-if="list.length"
  5. @click="deleteShow=!deleteShow">
  6. <img v-if="deleteShow==true" src="@/assets/img/arcoDesign-select-all.svg" alt="" />
  7. <span v-else style="color: red;" >删除</span>
  8. <!-- <img src="@/assets/img/riLine-list-settings-line.svg" alt="" /> -->
  9. </view>
  10. </u-navbar>
  11. <view class="search-box">
  12. <u-search @custom="getAuthorizedUserList(true)"
  13. placeholder="搜索授权用户" bg-color="#f2f4f6" height="80" :show-action="true" v-model="keyword">
  14. </u-search>
  15. </view>
  16. <view class="member-list-main">
  17. <!-- 列表 -->
  18. <view class="member-list">
  19. <checkbox-group @change="checkboxChange">
  20. <view class="item-info" v-for="(item,i) in list" :key="i" >
  21. <!-- <view class="photo">
  22. <img src="@/assets/img/PEokWS2@3x.png" alt="" />
  23. </view> -->
  24. <view class="item" >
  25. <view class="infos">
  26. <view class="name">
  27. {{item.name}}
  28. </view>
  29. <view class="tel">
  30. {{item.phone}}
  31. </view>
  32. </view>
  33. <view class="button" @click="getAuthorizedUserDetails(item.id),userName=item.name" v-if="!deleteShow">
  34. 权限管理
  35. </view>
  36. <!-- 单选框 -->
  37. <view class="radio-box" v-if="deleteShow">
  38. <checkbox :value="item.id"></checkbox>
  39. </view>
  40. </view>
  41. </view>
  42. </checkbox-group>
  43. </view>
  44. <u-divider :isnone="list.length==0"
  45. nonetext="暂无记录" border-color="#CFD2D5">
  46. 已经到底了</u-divider>
  47. </view>
  48. <view class="bottom">
  49. <view class="button qr-code"
  50. @click="gotoUrl('/pages/managementList/authorizedQRCode')"
  51. >
  52. <img src="@/assets/img/riLine-qr-code-line 1.svg" alt="" /> 授权二维码
  53. </view>
  54. <view class="button list-button" @click="gotoUrl('/pages/managementList/applicantsList')" >
  55. <img src="@/assets/img/riLine-contacts-line.svg" alt="" /> 申请人列表
  56. <view class="bot" v-if="approvalListNum">
  57. {{approvalListNum}}
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 删除 -->
  62. <view class="delete" v-if="deleteShow" @click="deletePopupQuery">
  63. <view class="icon">
  64. <img src="@/assets/img/riLine-delete-bin-7-line 1.svg" alt="" />
  65. </view>
  66. <view class="text">
  67. 删除
  68. </view>
  69. </view>
  70. <!-- 删除确认弹框 -->
  71. <u-popup v-model="deletePopup" mode="bottom" border-radius="12">
  72. <view class="popup">
  73. <view class="headline">
  74. 删除人员
  75. </view>
  76. <view class="hint">
  77. 要删除选中的人员吗?
  78. </view>
  79. <view class="btn-box">
  80. <view class="cancel" @click="deletePopup=false">
  81. 取消
  82. </view>
  83. <view class="confirm" @click="deletePopupApi" >
  84. 确认删除
  85. </view>
  86. </view>
  87. </view>
  88. </u-popup>
  89. <!-- 人员权限管理 -->
  90. <view>
  91. <u-popup v-model="show" mode="bottom">
  92. <view class="popup2" >
  93. <view class="title">
  94. {{userName}}-权限管理
  95. </view>
  96. <scroll-view scroll-y="true" style="height: 600rpx;" >
  97. <u-checkbox-group style=" width: 100%;" @change="checkboxGroupChange">
  98. <view class="content">
  99. <view class="item" v-for="(item,i) in meterList" >
  100. <view class="item-title">
  101. {{replaceLastTwoWords(item.name)}}
  102. </view>
  103. <view class="item-radio">
  104. <!-- <label class="radio">
  105. <radio value="" /><text></text>
  106. </label> -->
  107. <u-checkbox
  108. v-model="item.checked"
  109. :name="item.id"
  110. ></u-checkbox>
  111. </view>
  112. </view>
  113. </view>
  114. </u-checkbox-group>
  115. <u-divider border-color="#CFD2D5">
  116. 已经到底了</u-divider>
  117. </scroll-view>
  118. <view class="popup-bottom">
  119. <view class="button cancel" @click="show=false">
  120. 取消
  121. </view>
  122. <view class="button save" @click="submitBtn()" >
  123. 保存
  124. </view>
  125. </view>
  126. </view>
  127. </u-popup>
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. import * as API from '@/apis/pagejs/managementList.js'
  133. import * as API_user from '@/apis/pagejs/user.js'
  134. export default {
  135. data() {
  136. return {
  137. keyword:"",
  138. deleteShow:false,
  139. deletePopup:false,
  140. deleteIds: "",
  141. pageIndex: 1,
  142. recordsTotal: 0,
  143. show:false,
  144. list:[],
  145. approvalListNum:0,
  146. meterList:[],
  147. meterListIn:[],
  148. userId:"",
  149. userName:"",
  150. isback:false,
  151. }
  152. },
  153. onLoad(op){
  154. if(op.isback){
  155. this.isback=op.isback
  156. }
  157. },
  158. onReady() {
  159. //this.getAuthorizedUserList()
  160. },
  161. onShow() {
  162. this.getAuthorizedUserList(true)
  163. this.getApprovalList()
  164. },
  165. onReachBottom() {
  166. if (this.list.length < this.recordsTotal) {
  167. this.myLoadmore();
  168. }
  169. },
  170. methods: {
  171. loginset(response){
  172. var token = response ? response.data.token : '';
  173. this.carhelp.setToken(token);
  174. this.carhelp.setPersonInfo(response.data.regUser);
  175. this.carhelp.setPersonInfoPlus(response.data)
  176. //this.gotoUrl("pages/user/index")
  177. this.getApprovalList()
  178. },
  179. query(){
  180. uni.showLoading({
  181. title: "加载中",
  182. mask: true,
  183. })
  184. API_user.findByOpenId({
  185. noerror:true,
  186. openId: this.carhelp.getOpenId(),
  187. }).then((response) => {
  188. uni.hideLoading();
  189. if(response.message){
  190. }else{
  191. this.loginset(response)
  192. }
  193. }).catch(error => {
  194. uni.hideLoading();
  195. })
  196. },
  197. deletePopupQuery() {
  198. if (this.deleteIds != '') {
  199. this.deletePopup = true
  200. } else {
  201. uni.showToast({
  202. title: "请至少勾选一项",
  203. icon: "none"
  204. })
  205. }
  206. },
  207. deletePopupApi() {
  208. uni.showLoading({
  209. title: "加载中",
  210. mask: true,
  211. })
  212. API.authorizedUserDelete({
  213. userIds: this.deleteIds
  214. }).then((response) => {
  215. uni.hideLoading();
  216. this.deletePopup = false
  217. this.deleteShow = false
  218. this.deleteIds = ""
  219. this.getAuthorizedUserList(true)
  220. }).catch(error => {
  221. uni.showToast({
  222. title: error,
  223. icon: "none"
  224. })
  225. })
  226. },
  227. checkboxChange(e) {
  228. var sz = e.detail.value;
  229. console.log(sz)
  230. this.deleteIds = sz.join()
  231. },
  232. submitBtn(){
  233. uni.showLoading({
  234. title: "加载中",
  235. mask: true,
  236. })
  237. var meterIds="";
  238. if(this.meterListIn.length){
  239. meterIds=this.meterListIn.join()
  240. }
  241. API.authorizedUserSave({
  242. userId:this.userId,
  243. meterIds:meterIds,
  244. }).then((res) => {
  245. //this.userId=id;
  246. uni.hideLoading();
  247. //this.meterList=res.data.meterList;
  248. this.show=false
  249. uni.showModal({
  250. title:"提示",
  251. content:"设置成功",
  252. showCancel:false,
  253. })
  254. }).catch(error => {
  255. uni.showToast({
  256. title: error,
  257. icon: "none"
  258. })
  259. })
  260. },
  261. checkboxGroupChange(e){
  262. console.log(e)
  263. this.meterListIn=e
  264. },
  265. getAuthorizedUserDetails(id) {
  266. uni.showLoading({
  267. title: "加载中",
  268. mask: true,
  269. })
  270. API.authorizedUserDetails({
  271. userId:id,
  272. }).then((res) => {
  273. this.userId=id;
  274. uni.hideLoading();
  275. this.meterList=res.data.meterList;
  276. this.show=true
  277. this.meterListIn=[]
  278. for(var i in this.meterList){
  279. var obj=this.meterList[i]
  280. if(obj.checked){
  281. this.meterListIn.push(obj.id)
  282. }
  283. }
  284. }).catch(error => {
  285. uni.showToast({
  286. title: error,
  287. icon: "none"
  288. })
  289. })
  290. },
  291. myLoadmore() {
  292. this.pageIndex += 1;
  293. this.getAuthorizedUserList();
  294. },
  295. getAuthorizedUserList(bl) {
  296. uni.showLoading({
  297. title: "加载中",
  298. mask: true,
  299. })
  300. if (bl) {
  301. this.list = [];
  302. this.pageIndex = 1;
  303. }
  304. API.authorizedUserList({
  305. pageIndex:this.pageIndex,
  306. pageSize:20,
  307. nameOrPhone:this.keyword
  308. }).then((res) => {
  309. uni.hideLoading();
  310. this.list = [
  311. ...this.list,
  312. ...res.data.authorizedUserList.data
  313. ];
  314. this.recordsTotal = res.data.authorizedUserList.recordsTotal;
  315. if(res.data.switchUser){
  316. this.query()
  317. }
  318. }).catch(error => {
  319. uni.showToast({
  320. title: error,
  321. icon: "none"
  322. })
  323. })
  324. },
  325. getApprovalList() {
  326. API.approvalList({
  327. status:0
  328. }).then((res) => {
  329. this.approvalListNum= res.data.recordsTotal;
  330. }).catch(error => {
  331. uni.showToast({
  332. title: error,
  333. icon: "none"
  334. })
  335. })
  336. },
  337. }
  338. }
  339. </script>
  340. <style>
  341. </style>
  342. <style lang="scss" scoped>
  343. /deep/.u-slot-right {
  344. padding-right: 32rpx;
  345. padding-left: 16rpx;
  346. line-height: 30px;
  347. background-color: #fff;
  348. img {
  349. width: 48rpx;
  350. height: 48rpx;
  351. vertical-align: middle;
  352. }
  353. }
  354. .search-box {
  355. padding: 16rpx 32rpx;
  356. position: sticky;
  357. top: 88rpx;
  358. z-index: 999;
  359. background-color: rgba(255,255,255,1);
  360. /deep/.u-content {
  361. border-radius: 8px !important;
  362. }
  363. ;
  364. /deep/.u-search {
  365. position: relative
  366. }
  367. ;
  368. /deep/.u-action {
  369. width: 96rpx;
  370. line-height: 56rpx;
  371. border-radius: 4px;
  372. background-color: rgba(22, 119, 255, 1);
  373. color: rgba(255, 255, 255, 1);
  374. text-align: center;
  375. z-index: 9999;
  376. position: absolute;
  377. right: 12rpx;
  378. }
  379. }
  380. .member-list-main{
  381. padding-bottom: 120rpx ;
  382. }
  383. // 列表
  384. .member-list{
  385. background: #fff;
  386. .item-info{
  387. padding: 32rpx 0;
  388. margin: 0 32rpx;
  389. border-bottom: 1px solid rgba(244,244,244,1);;
  390. border-bottom: 1px solid #f4f4f4;
  391. }
  392. .item{
  393. display: flex;
  394. align-items: center;
  395. }
  396. .photo{
  397. img{
  398. width: 80rpx;
  399. height: 80rpx;
  400. border-radius: 50px;
  401. }
  402. }
  403. .infos{
  404. margin-left: 16rpx;
  405. .name{
  406. color: rgba(51,51,51,1);
  407. font-size: 32rpx;
  408. }
  409. .tel{
  410. color: rgba(119,119,119,1);
  411. font-size: 24rpx;
  412. margin-top: 4rpx;
  413. }
  414. }
  415. .button{
  416. width: 144rpx;
  417. height: 56rpx;
  418. line-height: 56rpx;
  419. border-radius: 50px;
  420. background-color: rgba(22,119,255,1);
  421. color: rgba(255,255,255,1);
  422. text-align: center;
  423. margin-left: auto;
  424. }
  425. .radio-box{
  426. margin-left: auto;
  427. }
  428. }
  429. .bottom{
  430. position: fixed;
  431. left: 0;
  432. right: 0;
  433. bottom: 0;
  434. background-color: #fff;
  435. padding: 20rpx 32rpx;
  436. display: flex;
  437. justify-content: space-between;
  438. img{
  439. width: 40rpx;
  440. height: 40rpx;
  441. margin-right: 8rpx;
  442. }
  443. .button{
  444. width: 328rpx;
  445. height: 80rpx;
  446. line-height: 80rpx;
  447. border-radius: 4px;
  448. font-size: 32rpx;
  449. text-align: center;
  450. display: flex;
  451. align-items: center;
  452. justify-content: center;
  453. }
  454. .qr-code{
  455. background-color: rgba(22,119,255,1);
  456. color: rgba(255,255,255,1);
  457. }
  458. .list-button{
  459. background-color: rgba(222,225,228,1);
  460. color: rgba(51,51,51,1);
  461. position: relative;
  462. }
  463. .bot{
  464. width: 40rpx;
  465. height: 40rpx;
  466. line-height: 40rpx;
  467. border-radius: 10px;
  468. background-color: rgba(244,60,50,1);
  469. color: rgba(255,255,255,1);
  470. font-size: 24rpx;
  471. text-align: center;
  472. position: absolute;
  473. top: -10rpx;
  474. right:-10rpx;
  475. }
  476. }
  477. // 删除
  478. .delete {
  479. position: fixed;
  480. left: 0;
  481. right: 0;
  482. bottom: 0;
  483. background-color: #fff;
  484. display: flex;
  485. flex-direction: column;
  486. align-items: center;
  487. justify-content: center;
  488. height: 120rpx;
  489. img {
  490. width: 48rpx;
  491. height: 48rpx;
  492. }
  493. .text {
  494. color: rgba(51, 51, 51, 1);
  495. font-size: 20rpx;
  496. }
  497. }
  498. .popup {
  499. padding: 32rpx;
  500. text-align: center;
  501. .headline {
  502. color: rgba(16, 16, 16, 1);
  503. font-size: 36rpx;
  504. font-weight: bold;
  505. }
  506. .hint {
  507. color: rgba(16, 16, 16, 1);
  508. font-size: 32rpx;
  509. margin-top: 40rpx;
  510. }
  511. .btn-box {
  512. margin-top: 82rpx;
  513. display: flex;
  514. justify-content: space-between;
  515. .cancel {
  516. width: 328rpx;
  517. line-height: 80rpx;
  518. border-radius: 4px;
  519. background-color: rgba(222, 225, 228, 1);
  520. color: rgba(51, 51, 51, 1);
  521. font-size: 32rpx;
  522. }
  523. .confirm {
  524. width: 328rpx;
  525. line-height: 80rpx;
  526. border-radius: 4px;
  527. background-color: rgba(255, 68, 68, 1);
  528. color: rgba(255, 255, 255, 1);
  529. font-size: 32rpx;
  530. }
  531. }
  532. }
  533. // 人员权限管理
  534. .popup2{
  535. padding: 32rpx 0;
  536. .title{
  537. color: rgba(16,16,16,1);
  538. font-size: 36rpx;
  539. font-weight: bold;
  540. text-align: center;
  541. }
  542. .content{
  543. width: 100%;
  544. margin-bottom: 24rpx;
  545. .item{
  546. display: flex;
  547. align-items: center;
  548. justify-content: space-between;
  549. padding: 28rpx 30rpx;
  550. border-bottom: 1px solid rgba(245,245,245,1);
  551. }
  552. }
  553. .popup-bottom{
  554. display: flex;
  555. justify-content: space-between;
  556. padding: 0 32rpx;
  557. .button{
  558. width: 328rpx;
  559. height: 80rpx;
  560. line-height: 80rpx;
  561. border-radius: 4px;
  562. font-size: 32rpx;
  563. text-align: center;
  564. }
  565. .cancel{
  566. background-color: rgba(222,225,228,1);
  567. color: rgba(51,51,51,1);
  568. }
  569. .save{
  570. background-color: rgba(22,119,255,1);
  571. color: rgba(255,255,255,1);
  572. }
  573. }
  574. }
  575. </style>