detail.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='员工管理'></cus-header>
  4. <div class="info">
  5. <div class="item">
  6. <div class="left">姓名</div>
  7. <div class="right">
  8. <input type="text" v-model="userInfo.name" placeholder="请输入姓名">
  9. </div>
  10. </div>
  11. <div class="item">
  12. <div class="left">工号</div>
  13. <div class="right">
  14. <input type="text" v-model="userInfo.jobNumber" placeholder="请输入工号">
  15. </div>
  16. </div>
  17. <div class="item">
  18. <div class="left">身份证</div>
  19. <div class="right">
  20. <input type="text" v-model="userInfo.idCard" placeholder="请输入身份证">
  21. </div>
  22. </div>
  23. <div class="item">
  24. <div class="left">性别</div>
  25. <div class="right" @tap="sexShow = true">
  26. {{userInfo.gender==1?'男':(userInfo.gender==2?'女':'保密')}}
  27. <u-icon name="arrow-right" color="#198CFF" size="32" style="margin-left: 10rpx;"></u-icon>
  28. </div>
  29. </div>
  30. <div class="item">
  31. <div class="left">手机号</div>
  32. <div class="right">
  33. <input type="text" v-model="userInfo.mobile" placeholder="请输入手机号">
  34. </div>
  35. </div>
  36. <div class="item">
  37. <div class="left">职位</div>
  38. <div class="right">
  39. <input type="text" v-model="userInfo.postName" placeholder="请输入职位">
  40. </div>
  41. </div>
  42. <div class="item">
  43. <div class="left">邮箱</div>
  44. <div class="right">
  45. <input type="text" v-model="userInfo.email" placeholder="请输入邮箱">
  46. </div>
  47. </div>
  48. <div class="item">
  49. <div class="left">家庭住址</div>
  50. <div class="right">
  51. <input type="text" v-model="userInfo.address" placeholder="请输入家庭住址">
  52. </div>
  53. </div>
  54. <div class="item">
  55. <div class="left">入职时间</div>
  56. <div class="right" @tap="dateShow = true">
  57. {{userInfo.entryDate}}
  58. <u-icon name="arrow-right" color="#198CFF" size="32" style="margin-left: 10rpx;"></u-icon>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="btn" @tap="confirm">确定</div>
  63. <u-picker :show="sexShow" :columns="sexColumns" title="性别" keyName="name" @cancel="sexShow = false;" @confirm="sexConfirm"></u-picker>
  64. <u-datetime-picker :show="dateShow" v-model="userInfo.workdate" mode="date" @cancel="dateShow = false;" @confirm="dateConfirm"></u-datetime-picker>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data(){
  70. return {
  71. userInfo:{},
  72. sexShow:false,
  73. sexColumns:[[{id:1,name:'男'},{id:2,name:'女'},{id:3,name:'保密'}]],
  74. dateShow:false
  75. }
  76. },
  77. onLoad(options) {
  78. this.getDetail(options.id||'')
  79. },
  80. methods:{
  81. getDetail(id){
  82. this.$api.get('/staff/info/'+id).then(res=>{
  83. if(res.data.code===0){
  84. this.userInfo = res.data.data;
  85. this.userInfo.workdate = new Date(this.userInfo.entryDate);
  86. }else this.$showToast(res.data.msg)
  87. })
  88. },
  89. sexConfirm(e){
  90. this.userInfo.gender = e.value[0].id;
  91. this.sexShow = false;
  92. },
  93. dateConfirm(e){
  94. this.userInfo.workdate = new Date(e.value);
  95. this.userInfo.entryDate = new Date(this.userInfo.workdate).Format('yyyy-MM-dd');
  96. this.dateShow = false;
  97. },
  98. confirm(){
  99. if(!this.$reg.idCard(this.userInfo.idCard)) return this.$showToast('请输入正确的身份证号')
  100. if(!this.$reg.mobile(this.userInfo.mobile)) return this.$showToast('请输入正确的手机号')
  101. if(!this.$reg.email(this.userInfo.email)) return this.$showToast('请输入正确的邮箱')
  102. this.$api.put('/staff/info',this.userInfo).then(res=>{
  103. if(res.data.code===0){
  104. this.$showToast('操作成功');
  105. setTimeout(()=>{
  106. uni.navigateBack();
  107. },1500)
  108. }else this.$showToast(res.data.msg)
  109. })
  110. }
  111. }
  112. }
  113. </script>
  114. <style scoped lang="less">
  115. .page{
  116. background: #F4F8FB;
  117. box-sizing: border-box;
  118. .info{
  119. width: 100%;
  120. margin-top: 20rpx;
  121. .item{
  122. padding: 24rpx 25rpx;
  123. background: #FFFFFF;
  124. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  125. display: flex;
  126. align-items: center;
  127. justify-content: space-between;
  128. .left{
  129. font-family: PingFangSC, PingFang SC;
  130. font-weight: 400;
  131. font-size: 30rpx;
  132. color: #1D2129;
  133. line-height: 42rpx;
  134. text-align: left;
  135. }
  136. .right{
  137. display: flex;
  138. align-items: center;
  139. input{
  140. font-family: PingFangSC, PingFang SC;
  141. font-weight: 400;
  142. font-size: 30rpx;
  143. color: #4E5969;
  144. line-height: 42rpx;
  145. text-align: right;
  146. outline: none;
  147. border: none;
  148. }
  149. }
  150. }
  151. }
  152. .btn{
  153. width: calc(100% - 108rpx);
  154. height: 88rpx;
  155. background: #198CFF;
  156. border-radius: 16rpx;
  157. margin: 240rpx 54rpx 0;
  158. font-family: PingFang-SC, PingFang-SC;
  159. font-weight: bold;
  160. font-size: 32rpx;
  161. color: #FFFFFF;
  162. line-height: 88rpx;
  163. text-align: center;
  164. letter-spacing: 2rpx;
  165. }
  166. }
  167. </style>