addGroup.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. <liu-drag-button @clickBtn="back">返回</liu-drag-button>
  28. <uni-popup ref="selectPersonPopup" type="bottom">
  29. <view class="selectMemberPopup">
  30. <view class="flex-row justify-around popupTitle">
  31. <text @click="closePopup('selectPersonPopup')">取消</text>
  32. <text>选择分组负责人</text>
  33. <text @click="getSelectPerson">确定</text>
  34. </view>
  35. <view class="scroll-y-view ">
  36. <mescroll-item ref="MescrollItem" :i="0" :index="0" :height="height">
  37. </mescroll-item>
  38. </view>
  39. </view>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script>
  44. import MescrollItem from "./module/mescrollUni-item.vue";
  45. export default {
  46. components: {
  47. MescrollItem
  48. },
  49. data() {
  50. return {
  51. height: '650px',
  52. form:{
  53. name:'',
  54. userId:'',
  55. userName:''
  56. },
  57. rules: {
  58. 'name': {
  59. type: 'string',
  60. required: true,
  61. min:1,
  62. message: '请输入分组名称',
  63. trigger: ['blur', 'change']
  64. },
  65. 'userName': {
  66. type: 'string',
  67. required: true,
  68. min:2,
  69. message: '请选择分组负责人',
  70. trigger: ['blur', 'change']
  71. }
  72. },
  73. }
  74. },
  75. onLoad(e) {
  76. let sysInfo = uni.getSystemInfoSync()
  77. this.height = sysInfo.screenWidth/750 * 650 + 'px' //除标题栏栏外的屏幕可用高度
  78. },
  79. methods: {
  80. back() {
  81. uni.navigateBack({
  82. delta: 1
  83. })
  84. },
  85. openSelectPerson(){
  86. this.$refs.selectPersonPopup.open()
  87. },
  88. closePopup(){
  89. this.$refs.selectPersonPopup.close()
  90. },
  91. getSelectPerson(){
  92. let a = this.$refs.MescrollItem.getSelectPerson()
  93. console.log('选择的负责人',a)
  94. if (!a){
  95. uni.showToast({
  96. icon: 'error',
  97. duration: 2000,
  98. title: '请选择负责人'
  99. });
  100. return
  101. }
  102. this.form.userId = a.id
  103. this.form.username = a.name
  104. this.$set(this.form,'userName', a.name)
  105. this.closePopup()
  106. },
  107. addGroup(){
  108. this.$refs.uForm.validate().then(res => {
  109. this.$api.service.addUpdateGroup(this.form).then(res=>{
  110. console.log(res)
  111. uni.showToast({
  112. icon: 'success',
  113. duration: 2000,
  114. title: '新增成功'
  115. });
  116. setTimeout(()=>{
  117. this.back()
  118. },2000)
  119. })
  120. })
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. @import './index.rpx.css';
  127. </style>