employee.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="人员管理"></u-navbar>
  5. <view class="content">
  6. <scroll-view class="scrollview" :scroll-with-animation="true" scroll-y lower-threshold="100"
  7. :style="{height:fullHeight}">
  8. <view class="list" v-if="list&&list.length>0">
  9. <block v-for="(item, index) in list" :key="index">
  10. <view class="comm-main flex justify-between">
  11. <view @click.stop="detail(item)">
  12. <view class="flex align-center">
  13. <view>
  14. {{item.name}}
  15. </view>
  16. <view>
  17. {{item.roleNames[0]||'无'}}
  18. </view>
  19. </view>
  20. <view class="phone-user flex align-center" @click.stop="phone(item.tel)">
  21. <image class="image" src="https://ossfile.mxrvending.com/assets/xy_merc_mini/images/system/tel.png" mode="widthFix"></image>
  22. <view class="tel">
  23. {{item.tel}}
  24. </view>
  25. </view>
  26. </view>
  27. <view class="stop">
  28. <u-switch activeColor="#2C6FF3" size="20" v-model="item.status"
  29. @change="stop(item)"></u-switch>
  30. </view>
  31. </view>
  32. </block>
  33. </view>
  34. <view class="empty" v-if="list.length==0">
  35. <u-empty mode="list" text="没有用户!"></u-empty>
  36. </view>
  37. </scroll-view>
  38. <view class="btn safe-bottom">
  39. <xbutton size="large" round="82rpx" @click="add">添加人员</xbutton>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. list,
  47. update
  48. } from "@/api/system/employee.js"
  49. export default {
  50. data() {
  51. return {
  52. list: [], //列表
  53. fullHeight: 0,
  54. }
  55. },
  56. onLoad() {
  57. let _this = this;
  58. const query = uni.createSelectorQuery().in(this);
  59. query.select(".scrollview").boundingClientRect((data) => {
  60. uni.getSystemInfo({
  61. success(res) {
  62. // 针对iPhone X等机型底部安全距离做适配
  63. const model = res.model;
  64. const modelInclude = [
  65. "iPhone X",
  66. 'iPhone XR',
  67. "iPhone XS",
  68. "iPhone XS MAX",
  69. "iPhone 12/13 mini",
  70. "iPhone 12/13 (Pro)",
  71. "iPhone 12/13 Pro Max",
  72. "iPhone 14 Pro Max"
  73. ];
  74. let safeDistance = modelInclude.includes(model)
  75. //动态设置商品区域高度
  76. if (safeDistance) {
  77. _this.fullHeight = res.windowHeight - data.top - 34 + 'px';
  78. } else {
  79. _this.fullHeight = res.windowHeight - data.top + 'px';
  80. }
  81. },
  82. });
  83. }).exec();
  84. },
  85. onShow() {
  86. this.getList()
  87. },
  88. methods: {
  89. //获取分页
  90. getList() {
  91. list({}).then(res => {
  92. this.list = res.data
  93. })
  94. },
  95. detail(item) {
  96. this.$tab.navigateTo(`/pages/system/empDetail?title=${item.name}&id=${item.userId}`)
  97. },
  98. stop(item) {
  99. let msg = item.status ? '启用' : '禁用'
  100. uni.showModal({
  101. title: '提示',
  102. content: `是否确认${msg}`,
  103. success: res=> {
  104. if (res.confirm) {
  105. update({
  106. userId: item.userInfoId,
  107. status: item.status
  108. }).then(res => {
  109. this.getList()
  110. setTimeout(()=>{
  111. this.$modal.showToast(`${msg}成功~`)
  112. },500)
  113. }).catch(err => {
  114. })
  115. } else if (res.cancel) {
  116. item.status=!item.status
  117. }
  118. }
  119. });
  120. },
  121. //添加人员
  122. add() {
  123. this.$tab.navigateTo('/pages/system/addEmployee')
  124. },
  125. //拨打电话
  126. phone(tel){
  127. uni.makePhoneCall({
  128. phoneNumber: tel
  129. })
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .container {
  136. overflow: hidden;
  137. .content {
  138. .list {
  139. width: 100%;
  140. padding: 0rpx 13rpx 12rpx;
  141. padding-bottom: calc(110rpx + env(safe-area-inset-bottom) / 2);
  142. overflow: hidden;
  143. .comm-img {
  144. width: 130rpx;
  145. height: 130rpx;
  146. display: flex;
  147. flex-direction: row;
  148. align-items: center;
  149. justify-content: space-around;
  150. image {
  151. width: 130rpx;
  152. height: 130rpx;
  153. }
  154. }
  155. .comm-main {
  156. padding: 20rpx 30rpx;
  157. background-color: #fff;
  158. border-radius: 12rpx;
  159. margin-top: 12rpx;
  160. box-sizing: border-box;
  161. color: #999;
  162. line-height: 60rpx;
  163. position: relative;
  164. .image{
  165. width:23rpx;
  166. height:23rpx;
  167. margin-right: 12rpx;
  168. }
  169. >view:nth-child(1){
  170. width:580rpx;
  171. >view {
  172. padding: 4rpx 0;
  173. }
  174. >view:nth-child(1) {
  175. >view:nth-child(1) {
  176. font-size: 30rpx;
  177. font-weight: bold;
  178. color: #333;
  179. }
  180. >view:nth-child(2) {
  181. font-size: 28rpx;
  182. margin-left: 24rpx;
  183. }
  184. }
  185. >view:nth-child(2) {
  186. font-size: 28rpx;
  187. }
  188. }
  189. .phone-user{
  190. width:250rpx;
  191. }
  192. .stop {
  193. // position: absolute;
  194. // right: 30rpx;
  195. // top: 26rpx;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. .empty {
  202. margin-top: 40%;
  203. }
  204. .btn {
  205. width: 100%;
  206. position: fixed;
  207. left: 0;
  208. padding: 0 24rpx;
  209. }
  210. .popup-content {
  211. padding: 36rpx 24rpx;
  212. display: flex;
  213. flex-flow: row nowrap;
  214. justify-content: flex-start;
  215. align-items: center;
  216. input {
  217. border: 1rpx solid #999;
  218. border-radius: 6rpx;
  219. width: 530rpx;
  220. padding: 0 24rpx;
  221. }
  222. &.edit-point {
  223. flex-direction: column;
  224. align-items: flex-start;
  225. .edit-point-item {
  226. width: 100%;
  227. padding-left: 170rpx;
  228. position: relative;
  229. &+.edit-point-item {
  230. margin-top: 12rpx;
  231. }
  232. >view:nth-child(1) {
  233. position: absolute;
  234. left: 0;
  235. top: 50%;
  236. transform: translateY(-50%);
  237. }
  238. }
  239. }
  240. }
  241. .del-popup-content {
  242. padding: 36rpx 24rpx;
  243. text-align: center;
  244. font-size: 32rpx;
  245. }
  246. </style>