index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view class="container uni-container">
  3. <view class="uni-padding-wrap uni-common-mt">
  4. <uni-segmented-control :current="current" :values="items" style-type="text" active-color="rgb(25, 146, 148)"
  5. @clickItem="onClickItem" />
  6. </view>
  7. <view class="content">
  8. <view v-if="current === 0">
  9. <u-list @scrolltolower="scrolltolower">
  10. <u-list-item v-for="(item, index) in tableData" :key="index" link>
  11. <uni-row>
  12. <uni-col :span="8">
  13. <u-avatar shape="square" size="80" src="https://cdn.uviewui.com/uview/album/1.jpg"
  14. customStyle="margin: -3px 5px -3px 0"></u-avatar>
  15. </uni-col>
  16. <uni-col :span="17">
  17. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  18. <uni-col :span="24" class="text-xl font-weight-700">{{ item.username }}</uni-col>
  19. </uni-row>
  20. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  21. <uni-col :span="24" class="text-cut text-grey1">用户昵称:{{ item.nickname }}</uni-col>
  22. </uni-row>
  23. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  24. <uni-col :span="24" class="text-cut text-grey1">部门:{{deptListTran(item.deptId) }}
  25. </uni-col>
  26. </uni-row>
  27. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  28. <uni-col :span="24" class="text-cut text-grey1">手机号码:{{ item.mobile }}</uni-col>
  29. </uni-row>
  30. </uni-col>
  31. </uni-row>
  32. <uni-row class="demo-uni-row " :gutter="20" width="100%">
  33. <uni-col :span="24">
  34. <view class="card-actions">
  35. <!-- <view class="card-actions-item" @click="editClick(item)">
  36. <u-icon name="edit-pen" color="#999" size="18"></u-icon>
  37. <text class="card-actions-item-text">编辑</text>
  38. </view> -->
  39. <view class="card-actions-item" @click="roleClick(item)">
  40. <u-icon name="setting" color="#999" size="18"></u-icon>
  41. <text class="card-actions-item-text">分配角色</text>
  42. </view>
  43. <view class="card-actions-item" @click="passwordClick(item)">
  44. <u-icon name="lock" color="#999" size="18"></u-icon>
  45. <text class="card-actions-item-text">重置密码</text>
  46. </view>
  47. </view>
  48. </uni-col>
  49. </uni-row>
  50. </u-list-item>
  51. </u-list>
  52. </view>
  53. <view v-if="current === 1">
  54. <u-list @scrolltolower="scrolltolower">
  55. <u-list-item v-for="(item, index) in roleAppList" :key="index" link>
  56. <uni-row>
  57. <uni-col :span="8">
  58. <u-avatar shape="square" size="80" src="https://cdn.uviewui.com/uview/album/1.jpg"
  59. customStyle="margin: -3px 5px -3px 0"></u-avatar>
  60. </uni-col>
  61. <uni-col :span="17">
  62. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  63. <uni-col :span="24" class="text-xl font-weight-700">{{ item.roleName }}</uni-col>
  64. </uni-row>
  65. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  66. <uni-col :span="24" class="text-cut text-grey1">角色标识:{{ item.roleLable }}</uni-col>
  67. </uni-row>
  68. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  69. <uni-col :span="24" class="text-cut text-grey1">角色排序:{{item.roleSort }}
  70. </uni-col>
  71. </uni-row>
  72. </uni-col>
  73. </uni-row>
  74. <uni-row class="demo-uni-row " :gutter="20" width="100%">
  75. <!-- <uni-col :span="24">
  76. <view class="card-actions">
  77. <view class="card-actions-item" @click="editRoleClick(item)">
  78. <u-icon name="edit-pen" color="#999" size="18"></u-icon>
  79. <text class="card-actions-item-text">编辑</text>
  80. </view>
  81. <view class="card-actions-item" @click="menuClick(item)">
  82. <u-icon name="setting" color="#999" size="18"></u-icon>
  83. <text class="card-actions-item-text">分配菜单</text>
  84. </view>
  85. </view>
  86. </uni-col> -->
  87. </uni-row>
  88. </u-list-item>
  89. </u-list>
  90. </view>
  91. </view>
  92. <u-modal :title="content" :show="showpassword" showCancelButton closeOnClickOverlay @confirm="confirm"
  93. @cancel="cancel" @close="close">
  94. <u--input v-model="password"></u--input>
  95. </u-modal>
  96. <!-- 加载中 -->
  97. <isLodingModel></isLodingModel>
  98. </view>
  99. </template>
  100. <script>
  101. let that = null;
  102. import {
  103. getUserPage, // 获取人员信息分页
  104. getDeptAllSimpleList, // 获取部门信息
  105. resetUserPwd ,// 用户密码重置
  106. getAppRolesPage, // 获得移动端角色分页
  107. } from '@/api/personnel_permissions';
  108. export default {
  109. data() {
  110. return {
  111. current: 0,
  112. items: ['用户管理', '角色管理', ],
  113. // 数据
  114. tableData: [],
  115. // 每页数据量
  116. pageSize: 10,
  117. // 当前页
  118. pageNo: 1,
  119. // 数据总量
  120. total: 0,
  121. // tableData数据加载中
  122. loading: false,
  123. deptList: {},
  124. showpassword: false,
  125. content: '',
  126. password: '',
  127. roleId: '',
  128. // 角色
  129. roleAppList:[],
  130. roleAppList2:[], //只要专兼职
  131. };
  132. },
  133. watch: {
  134. loading: {
  135. handler(newLength, oldLength) {
  136. this.$modal.isLoadingModel(this.loading)
  137. },
  138. immediate: true
  139. }
  140. },
  141. // onLoad: function(option) {
  142. // this.getData(1);
  143. // },
  144. onShow() {
  145. this.tableData=[]
  146. this.getData(1);
  147. this.getRoleData(1)
  148. },
  149. methods: {
  150. // =================数据转换==================
  151. deptListTran(val) {
  152. //status状态转换
  153. return this.deptList[val];
  154. },
  155. // ================================
  156. // tab头部点击
  157. onClickItem(e) {
  158. if (this.current !== e.currentIndex) {
  159. this.current = e.currentIndex;
  160. }
  161. },
  162. // 获取数据
  163. async getData(pageNo, value = '') {
  164. await getDeptAllSimpleList().then(response => {
  165. let list = response.data ? response.data : []
  166. list.map(i => {
  167. this.deptList[i.id] = i.name
  168. })
  169. })
  170. this.loading = true;
  171. this.pageNo = pageNo;
  172. getUserPage({
  173. pageNo: this.pageNo,
  174. pageSize: this.pageSize,
  175. // status: '1'
  176. }).then(response => {
  177. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  178. this.tableData = [...this.tableData, ...response.data.list];
  179. // this.tableData = response.data.list;
  180. this.total = response.data.total;
  181. this.loading = false;
  182. });
  183. },
  184. getRoleData(pageNo, value = ''){
  185. // 获得角色列表
  186. this.pageNo = pageNo;
  187. getAppRolesPage({
  188. pageNo: this.pageNo,
  189. pageSize: this.pageSize,
  190. // status: '1'
  191. }).then(response => {
  192. // 处理 roleAppList 参数
  193. this.roleAppList = response.data.list;
  194. });
  195. },
  196. onClick(val) {
  197. },
  198. // ==========用户信息相关========================================================================
  199. editClick(val) {
  200. uni.navigateTo({
  201. url: '/pagesA/fire/personnel_permissions/editUser/editUser?val=' + encodeURIComponent(JSON
  202. .stringify(val))
  203. });
  204. },
  205. roleClick(val) {
  206. uni.navigateTo({
  207. url: '/pagesA/fire/personnel_permissions/roleUser/roleUser?val=' + encodeURIComponent(JSON
  208. .stringify(val))
  209. });
  210. },
  211. passwordClick(val) {
  212. this.roleId = val.id
  213. this.showpassword = true
  214. this.content = "请输入" + `${val.username}` + "的新密码"
  215. },
  216. confirm(e) {
  217. this.showpassword = false
  218. resetUserPwd(this.roleId, this.password).then(response => {
  219. this.$modal.msg("修改成功")
  220. });
  221. },
  222. cancel() {
  223. this.showpassword = false
  224. },
  225. close() {
  226. this.showpassword = false
  227. },
  228. // ===================================================================================
  229. // ===================角色相关=========================================================
  230. editRoleClick(val){
  231. uni.navigateTo({
  232. url: '/pagesA/fire/personnel_permissions/editRole/editRole?val=' + encodeURIComponent(JSON
  233. .stringify(val))
  234. });
  235. },
  236. menuClick(val){
  237. uni.navigateTo({
  238. url: '/pagesA/fire/personnel_permissions/menuRole/menuRole?val=' + encodeURIComponent(JSON
  239. .stringify(val))
  240. });
  241. },
  242. //
  243. // 触底的事件
  244. scrolltolower() {
  245. // 判断是否还有下一页数据
  246. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  247. title: `数据加载完毕`
  248. });
  249. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  250. if (this.loading) return;
  251. this.pageNo += 1;
  252. this.getData(this.pageNo);
  253. }
  254. }
  255. };
  256. </script>
  257. <style>
  258. </style>