updateGroup.vue 3.7 KB

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