addGroup.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. uni.navigateBack({
  84. delta: 1
  85. })
  86. },
  87. openSelectPerson(){
  88. this.$refs.selectPersonPopup.open()
  89. },
  90. closePopup(){
  91. this.$refs.selectPersonPopup.close()
  92. },
  93. getSelectPerson(){
  94. let a = this.$refs.MescrollItem.getSelectPerson()
  95. console.log('选择的负责人',a)
  96. if (!a){
  97. uni.showToast({
  98. icon: 'error',
  99. duration: 2000,
  100. title: '请选择负责人'
  101. });
  102. return
  103. }
  104. this.form.userId = a.id
  105. this.form.username = a.name
  106. this.$set(this.form,'userName', a.name)
  107. this.closePopup()
  108. },
  109. addGroup(){
  110. this.$refs.uForm.validate().then(res => {
  111. this.$api.service.addUpdateGroup(this.form).then(res=>{
  112. console.log(res)
  113. uni.showToast({
  114. icon: 'success',
  115. duration: 2000,
  116. title: '新增成功'
  117. });
  118. setTimeout(()=>{
  119. this.back()
  120. },2000)
  121. })
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. @import './index.rpx.css';
  129. </style>