updateGroup.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="page">
  3. <view>
  4. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm">
  5. <u-form-item prop="name" borderBottom>
  6. <view class="item">
  7. <text class="key">分组名称</text>
  8. <view class="flex-row input">
  9. <u--input v-model="form.name" placeholder="请输入分组名称" border="none"></u--input>
  10. </view>
  11. </view>
  12. </u-form-item>
  13. <u-form-item prop="userName" borderBottom>
  14. <view class="item">
  15. <text class="key">负责人</text>
  16. <view class="flex-row input" @click="openSelectPerson">
  17. <u--input v-model="form.userName" disabled placeholder="请选择负责人" border="none"></u--input>
  18. <u-icon name="arrow-right"></u-icon>
  19. </view>
  20. </view>
  21. </u-form-item>
  22. </u--form>
  23. </view>
  24. <view class="addGroup" @click="updateGroup">
  25. <text>修改</text>
  26. </view>
  27. <!--#ifdef H5-->
  28. <liu-drag-button @clickBtn="back">返回</liu-drag-button>
  29. <!--#endif-->
  30. <uni-popup ref="selectPersonPopup" type="bottom">
  31. <view class="selectMemberPopup">
  32. <view class="flex-row justify-around popupTitle">
  33. <text @click="closePopup">取消</text>
  34. <text>选择分组负责人</text>
  35. <text @click="getSelectPerson">确定</text>
  36. </view>
  37. <view class="scroll-y-view ">
  38. <mescroll-item ref="MescrollItem" :i="0" :index="0" :height="height">
  39. </mescroll-item>
  40. </view>
  41. </view>
  42. </uni-popup>
  43. </view>
  44. </template>
  45. <script>
  46. import MescrollItem from "./module/mescrollUni-item.vue";
  47. export default {
  48. components: {
  49. MescrollItem
  50. },
  51. data() {
  52. return {
  53. height: '',
  54. form:{
  55. id:'',
  56. name:'',
  57. userId:'',
  58. userName:''
  59. },
  60. rules: {
  61. 'name': {
  62. type: 'string',
  63. required: true,
  64. min:1,
  65. message: '请输入分组名称',
  66. trigger: ['blur', 'change']
  67. },
  68. 'userName': {
  69. type: 'string',
  70. required: true,
  71. min:2,
  72. message: '请选择分组负责人',
  73. trigger: ['blur', 'change']
  74. }
  75. },
  76. }
  77. },
  78. onLoad(e) {
  79. let item = JSON.parse(e.item)
  80. this.form.id = item.id
  81. this.form.name = item.name
  82. this.form.userId = item.userId
  83. this.form.userName = item.userName
  84. let sysInfo = uni.getSystemInfoSync()
  85. this.height = sysInfo.screenWidth/750 * 650 + 'px'
  86. },
  87. methods: {
  88. back() {
  89. let pages = getCurrentPages()
  90. if (pages.length > 1){
  91. uni.navigateBack({
  92. delta: 1,
  93. fail:err=>{
  94. console.log(err)
  95. }
  96. })
  97. }else {
  98. uni.switchTab({
  99. url: '/pages/my/my'
  100. });
  101. }
  102. },
  103. updateGroup(){
  104. this.$refs.uForm.validate().then(res => {
  105. this.$api.service.addUpdateGroup(this.form).then(res=>{
  106. console.log(res)
  107. uni.showToast({
  108. icon: 'success',
  109. duration: 2000,
  110. title: '修改成功'
  111. });
  112. setTimeout(()=>{
  113. this.back()
  114. },2000)
  115. })
  116. })
  117. },
  118. getSelectPerson(){
  119. let a = this.$refs.MescrollItem.getSelectPerson()
  120. console.log('选择的负责人',a)
  121. if (!a){
  122. uni.showToast({
  123. icon: 'error',
  124. duration: 2000,
  125. title: '请选择负责人'
  126. });
  127. return
  128. }
  129. this.form.userId = a.id
  130. this.form.username = a.name
  131. this.$set(this.form,'userName', a.name)
  132. this.closePopup()
  133. },
  134. openSelectPerson(){
  135. this.$refs.selectPersonPopup.open()
  136. },
  137. closePopup(){
  138. this.$refs.selectPersonPopup.close()
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. @import './index.rpx.css';
  145. </style>