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. <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">取消</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: '',
  52. form:{
  53. id:'',
  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 item = JSON.parse(e.item)
  78. this.form.id = item.id
  79. this.form.name = item.name
  80. this.form.userId = item.userId
  81. this.form.userName = item.userName
  82. let sysInfo = uni.getSystemInfoSync()
  83. this.height = sysInfo.screenWidth/750 * 650 + 'px'
  84. },
  85. methods: {
  86. back() {
  87. uni.navigateBack({
  88. delta: 1
  89. })
  90. },
  91. updateGroup(){
  92. this.$refs.uForm.validate().then(res => {
  93. this.$api.service.addUpdateGroup(this.form).then(res=>{
  94. console.log(res)
  95. uni.showToast({
  96. icon: 'success',
  97. duration: 2000,
  98. title: '修改成功'
  99. });
  100. setTimeout(()=>{
  101. this.back()
  102. },2000)
  103. })
  104. })
  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. openSelectPerson(){
  123. this.$refs.selectPersonPopup.open()
  124. },
  125. closePopup(){
  126. this.$refs.selectPersonPopup.close()
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. @import './index.rpx.css';
  133. </style>