addGroup.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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="addGroup">
  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('selectPersonPopup')">取消</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: '650px',
  54. form:{
  55. name:'',
  56. userId:'',
  57. userName:''
  58. },
  59. rules: {
  60. 'name': {
  61. type: 'string',
  62. required: true,
  63. min:1,
  64. message: '请输入分组名称',
  65. trigger: ['blur', 'change']
  66. },
  67. 'userName': {
  68. type: 'string',
  69. required: true,
  70. min:2,
  71. message: '请选择分组负责人',
  72. trigger: ['blur', 'change']
  73. }
  74. },
  75. }
  76. },
  77. onLoad(e) {
  78. let sysInfo = uni.getSystemInfoSync()
  79. this.height = sysInfo.screenWidth/750 * 650 + 'px' //除标题栏栏外的屏幕可用高度
  80. },
  81. methods: {
  82. back() {
  83. let pages = getCurrentPages()
  84. if (pages.length > 1){
  85. uni.navigateBack({
  86. delta: 1,
  87. fail:err=>{
  88. console.log(err)
  89. }
  90. })
  91. }else {
  92. uni.switchTab({
  93. url: '/pages/my/my'
  94. });
  95. }
  96. },
  97. openSelectPerson(){
  98. this.$refs.selectPersonPopup.open()
  99. },
  100. closePopup(){
  101. this.$refs.selectPersonPopup.close()
  102. },
  103. getSelectPerson(){
  104. let a = this.$refs.MescrollItem.getSelectPerson()
  105. console.log('选择的负责人',a)
  106. if (!a){
  107. uni.showToast({
  108. icon: 'error',
  109. duration: 2000,
  110. title: '请选择负责人'
  111. });
  112. return
  113. }
  114. this.form.userId = a.id
  115. this.form.username = a.name
  116. this.$set(this.form,'userName', a.name)
  117. this.closePopup()
  118. },
  119. addGroup(){
  120. this.$refs.uForm.validate().then(res => {
  121. this.$api.service.addUpdateGroup(this.form).then(res=>{
  122. console.log(res)
  123. uni.showToast({
  124. icon: 'success',
  125. duration: 2000,
  126. title: '新增成功'
  127. });
  128. setTimeout(()=>{
  129. this.back()
  130. },2000)
  131. })
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. @import './index.rpx.css';
  139. </style>