addGroup.vue 3.6 KB

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