personInfo.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view class="container">
  3. <view class="md-scroll">
  4. <scroll-view
  5. scroll-y
  6. style="height: calc(100vh - var(--status-bar-height) - 50px);width: 100%;overflow: auto;"
  7. @scrolltolower="onreachBottom">
  8. <view class="personInfo" v-for="(item,index) in listData" :key="item.id">
  9. <view class="personItem">
  10. <view class="personItemLeft">
  11. <view class="personName">
  12. <text style="font-weight: bold;">{{item.name}}</text>
  13. <text class="manger" v-show="item.isManager == 1">
  14. {{item.isManager | isManagerFilter}}
  15. </text>
  16. </view>
  17. </view>
  18. <view class="personItemLeft">
  19. <text class="personName">{{ item.sex | sexFilter }}</text>
  20. <!-- <text :class="'sex_'+item.sex">{{item.sex?'♂':'♀'}}</text> -->
  21. </view>
  22. <view class="personItemLeft">
  23. <text class="personName">{{item.mobile}}</text>
  24. </view>
  25. <view class="personItemRight">
  26. <text class="personName">{{item.workFlag == 1 ? '在职' : '离职'}}</text>
  27. </view>
  28. </view>
  29. <view class="personItem">
  30. <view class="personItemLeft">
  31. <text class="personVal">级别:{{filterpayType(item.employeeLevel) || '-'}}</text>
  32. </view>
  33. <view class="personItemRight">
  34. <text class="personVal">系统使用:{{item.userType == 1 ? '启用' : '禁用'}}</text>
  35. </view>
  36. </view>
  37. <view class="personItem">
  38. <view class="personItemLeft">
  39. <text class="personVal">角色:{{item.roleNames}}</text>
  40. </view>
  41. </view>
  42. <view class="icon-group">
  43. <view v-if="item.userType == 1 && $hasPermissions('M_employee_mobile')" style="color:#55aaff;" @click="resetPwd(item,index)">
  44. <uni-font-icons size="16" type="icon-mima" color="#55aaff"></uni-font-icons> 重置密码
  45. </view>
  46. <view v-if="item.isManager != 1 && $hasPermissions('M_empOroleDel_mobile')" style="color:#ff0000;" @click="delItem(item,index)">
  47. <uni-font-icons size="16" type="icon-shanchu" color="#ff0000"></uni-font-icons> 删除
  48. </view>
  49. <view style="color:#00aa00;" v-if="$hasPermissions('M_employee_mobile')" @click="editItem(item)">
  50. <uni-font-icons size="16" type="icon-editor" color="#00aa00"></uni-font-icons> 编辑
  51. </view>
  52. </view>
  53. </view>
  54. <u-empty :text="noDataText" img-width="120" v-if="listData.length==0 && status!='loading'" mode="list"></u-empty>
  55. <view style="padding: 20upx;">
  56. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  57. </view>
  58. </scroll-view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import {searchEmployee, delEmployee, resetPSD} from '@/api/employee'
  64. import { getLookUpDatas } from '@/api/data'
  65. import { clzConfirm } from '@/libs/tools.js'
  66. export default{
  67. data(){
  68. return{
  69. status: 'loadmore',
  70. noDataText: '暂无数据',
  71. listData:[],
  72. employeeLevel: "", //员工级别
  73. queryWord: "",
  74. userType: "", //权限类别
  75. workFlag: "", //在职状态
  76. pageNo:1,
  77. pageSize:20,
  78. content: '',
  79. title:'',
  80. nowId: '', // 当前员工 id
  81. total:'' //获取数据总条数
  82. }
  83. },
  84. onShow(){
  85. this.$store.state.vuex_nowStaffData = ''
  86. this.pageNo = 1
  87. this.employeeJBList()
  88. },
  89. // 判断员工身份权限
  90. filters:{
  91. sexFilter(sexFilterVal){
  92. if(sexFilterVal == 1){
  93. return '男'
  94. }
  95. if(sexFilterVal == 0){
  96. return '女'
  97. }
  98. },
  99. isManagerFilter(isManagerFilterVal){
  100. if(isManagerFilterVal == 1){
  101. return '负责人'
  102. }
  103. }
  104. },
  105. methods:{
  106. // 员工信息列表
  107. getPersonInfoList(){
  108. let _this=this
  109. const data={
  110. employeeLevel:this.employeeLevel,
  111. queryWord:this.queryWord,
  112. userType: this.userType, //权限类别
  113. workFlag:this.workFlag,
  114. pageNo:this.pageNo,
  115. pageSize:this.pageSize
  116. }
  117. this.status = "loading"
  118. searchEmployee(data).then(res=>{
  119. if(res.status == 200){
  120. // 将返回的每页数据拼接
  121. if(_this.pageNo>1){
  122. _this.listData = _this.listData.concat(res.data.list || [])
  123. }else{
  124. _this.listData = res.data.list || []
  125. }
  126. _this.total = res.data.count || 0
  127. }else {
  128. _this.listData = []
  129. _this.total = 0
  130. _this.noDataText = res.message
  131. }
  132. _this.status = "loadmore"
  133. })
  134. },
  135. // 下一页
  136. onreachBottom() {
  137. console.log('next page')
  138. if(this.listData.length < this.total){
  139. this.pageNo += 1
  140. this.getPersonInfoList()
  141. }else{
  142. this.status = "nomore"
  143. }
  144. },
  145. // 获取员工级别
  146. employeeJBList () {
  147. let _this = this
  148. getLookUpDatas({
  149. type: 'EMPLOYEE_LEVEL'
  150. }).then(result => {
  151. if (result && result.status + '' === '200') {
  152. _this.employeeList= result.data
  153. _this.getPersonInfoList()
  154. }
  155. })
  156. },
  157. filterpayType (val) {
  158. var _value = ''
  159. for (let i = 0; i < this.employeeList.length; i++) {
  160. if (val == this.employeeList[i].code) {
  161. _value = this.employeeList[i].dispName
  162. break
  163. }
  164. }
  165. return _value
  166. },
  167. // 页面返回
  168. goBack(){
  169. console.log(11)
  170. uni.navigateBack()
  171. },
  172. // 添加员工
  173. add(){
  174. uni.navigateTo({
  175. url:'/pages/personInfo/addPersonInfo'
  176. })
  177. },
  178. // 编辑修改
  179. editItem(item){
  180. // 将当前员工的信息赋值给store中声明保存员工信息的vuex_nowStaffData
  181. this.$store.state.vuex_nowStaffData = item
  182. uni.navigateTo({
  183. url:'/pages/personInfo/addPersonInfo'
  184. })
  185. },
  186. // 删除角色
  187. delItem(item,index){
  188. let _this = this
  189. clzConfirm({
  190. title: "提示",
  191. content: "数据删除后无法恢复, 确认删除吗?",
  192. showCancel: true,
  193. success: function(e){
  194. if(e.confirm||e.index == 0){
  195. // 删除数据
  196. delEmployee({id: item.id}).then(res=>{
  197. if(res.status == 200){
  198. uni.showToast({
  199. icon:'none',
  200. title:res.message
  201. })
  202. // 刷新列表
  203. _this.listData.splice(index,1)
  204. _this.total = _this.total -1
  205. }else{
  206. uni.showToast({icon: 'none', title: res.message})
  207. }
  208. })
  209. }
  210. },
  211. })
  212. },
  213. // 重置密码
  214. resetPwd(item,index){
  215. resetPSD({
  216. id: item.id
  217. }).then(res => {
  218. if (res.status == 200) {
  219. uni.showToast({icon: 'none', title: '密码重置成功'})
  220. }else{
  221. uni.showToast({icon: 'none', title: res.message})
  222. }
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="less">
  229. page{
  230. height: 100%;
  231. }
  232. .container{
  233. padding-top: var(--status-bar-height);
  234. height: calc(100vh - var(--status-bar-height));
  235. display: flex;
  236. flex-direction: column;
  237. .md-scroll{
  238. flex-grow: 1;
  239. overflow: auto;
  240. }
  241. .personInfo{
  242. margin:30rpx;
  243. border-radius: 6upx;
  244. box-shadow: 1px 1px 3px #EEEEEE;
  245. background-color: #FFFFFF;
  246. .personItem{
  247. display: flex;
  248. align-items: center;
  249. padding: 20rpx 30rpx;
  250. border-bottom: 1px dashed #f3f3f3;
  251. .sex_1,.sex_0{
  252. margin-right: 6upx;
  253. font-size: 20upx;
  254. width: 30upx;
  255. height: 30upx;
  256. line-height: 30upx;
  257. display: block;
  258. text-align: center;
  259. border-radius: 30upx;
  260. color: #FFFFFF;
  261. }
  262. .sex_1{
  263. background: #00aaff;
  264. }
  265. .sex_0{
  266. background: #FA3534;
  267. }
  268. .personItemLeft{
  269. text-align: left;
  270. display: flex;
  271. align-items: center;
  272. flex-grow: 1;
  273. }
  274. .personItemRight{
  275. text-align: right;
  276. }
  277. .personName{
  278. display: flex;
  279. align-items: center;
  280. .manger{
  281. background-color: #57A3F3;
  282. border-radius: 10px;
  283. color: #fff;
  284. text-align: center;
  285. margin-left: 15rpx;
  286. padding:5rpx 15rpx;
  287. font-size: 20upx;
  288. }
  289. }
  290. .personVal{
  291. color: #999;
  292. }
  293. }
  294. .icon-group{
  295. padding: 20rpx 30rpx;
  296. display: flex;
  297. flex-direction: row-reverse;
  298. > view{
  299. margin-left: 40upx;
  300. }
  301. }
  302. .uni-icons{
  303. margin-right: 6upx;
  304. }
  305. }
  306. }
  307. </style>