updateGroup.vue 3.2 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="updateGroup">
  25. <text>修改</text>
  26. </view>
  27. <uni-popup ref="selectPersonPopup" type="bottom">
  28. <view class="selectMemberPopup">
  29. <view class="flex-row justify-around popupTitle">
  30. <text @click="closePopup">取消</text>
  31. <text>选择分组负责人</text>
  32. <text @click="getSelectPerson">确定</text>
  33. </view>
  34. <view class="scroll-y-view ">
  35. <mescroll-item ref="MescrollItem" :i="0" :index="0" :height="height">
  36. </mescroll-item>
  37. </view>
  38. </view>
  39. </uni-popup>
  40. </view>
  41. </template>
  42. <script>
  43. import MescrollItem from "./module/mescrollUni-item.vue";
  44. export default {
  45. components: {
  46. MescrollItem
  47. },
  48. data() {
  49. return {
  50. height: '',
  51. form:{
  52. id:'',
  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 item = JSON.parse(e.item)
  77. this.form.id = item.id
  78. this.form.name = item.name
  79. this.form.userId = item.userId
  80. this.form.userName = item.userName
  81. let sysInfo = uni.getSystemInfoSync()
  82. this.height = sysInfo.screenWidth/750 * 650 + 'px'
  83. },
  84. methods: {
  85. back() {
  86. uni.navigateBack({
  87. delta: 1
  88. })
  89. },
  90. updateGroup(){
  91. this.$refs.uForm.validate().then(res => {
  92. this.$api.service.addUpdateGroup(this.form).then(res=>{
  93. console.log(res)
  94. uni.showToast({
  95. icon: 'success',
  96. duration: 2000,
  97. title: '修改成功'
  98. });
  99. setTimeout(()=>{
  100. this.back()
  101. },2000)
  102. })
  103. })
  104. },
  105. getSelectPerson(){
  106. let a = this.$refs.MescrollItem.getSelectPerson()
  107. console.log('选择的负责人',a)
  108. if (!a){
  109. uni.showToast({
  110. icon: 'error',
  111. duration: 2000,
  112. title: '请选择负责人'
  113. });
  114. return
  115. }
  116. this.form.userId = a.id
  117. this.form.username = a.name
  118. this.$set(this.form,'userName', a.name)
  119. this.closePopup()
  120. },
  121. openSelectPerson(){
  122. this.$refs.selectPersonPopup.open()
  123. },
  124. closePopup(){
  125. this.$refs.selectPersonPopup.close()
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. @import './index.rpx.css';
  132. </style>