updateGroup.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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="updateGroup">
  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">取消</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: '',
  53. form:{
  54. id:'',
  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 item = JSON.parse(e.item)
  79. this.form.id = item.id
  80. this.form.name = item.name
  81. this.form.userId = item.userId
  82. this.form.userName = item.userName
  83. let sysInfo = uni.getSystemInfoSync()
  84. this.height = sysInfo.screenWidth/750 * 650 + 'px'
  85. },
  86. methods: {
  87. back() {
  88. uni.navigateBack({
  89. delta: 1
  90. })
  91. },
  92. updateGroup(){
  93. this.$refs.uForm.validate().then(res => {
  94. this.$api.service.addUpdateGroup(this.form).then(res=>{
  95. console.log(res)
  96. uni.showToast({
  97. icon: 'success',
  98. duration: 2000,
  99. title: '修改成功'
  100. });
  101. setTimeout(()=>{
  102. this.back()
  103. },2000)
  104. })
  105. })
  106. },
  107. getSelectPerson(){
  108. let a = this.$refs.MescrollItem.getSelectPerson()
  109. console.log('选择的负责人',a)
  110. if (!a){
  111. uni.showToast({
  112. icon: 'error',
  113. duration: 2000,
  114. title: '请选择负责人'
  115. });
  116. return
  117. }
  118. this.form.userId = a.id
  119. this.form.username = a.name
  120. this.$set(this.form,'userName', a.name)
  121. this.closePopup()
  122. },
  123. openSelectPerson(){
  124. this.$refs.selectPersonPopup.open()
  125. },
  126. closePopup(){
  127. this.$refs.selectPersonPopup.close()
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. @import './index.rpx.css';
  134. </style>