addGroup.vue 3.2 KB

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