setMember.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="center">
  3. <u-search placeholder="搜索" v-model="searchKeyWord" :clearabled="true" :show-action="false" @change="getList">
  4. </u-search>
  5. <view class="avatars">
  6. <view class="" v-for="(item,index) in formData" class="avatars_item flex" @click="radioClick(item)">
  7. <view class="flex avatars_left">
  8. <label class="radio" v-if="type == 1">
  9. <radio :value="item.id" :checked="item.checked" />
  10. </label>
  11. <!-- <label class="radio" @click="radioClick(item)">
  12. <radio :value="item.uid" :checked="item.checked" />
  13. </label> -->
  14. <!-- <u-checkbox-group v-model="checked" iconPlacement="right" placement="row">
  15. <u-checkbox activeColor="red" ></u-checkbox>
  16. </u-checkbox-group> -->
  17. <!-- <u-radio-group v-model="radiovalue1" >
  18. <u-radio :customStyle="{marginBottom: '8px'}" :key="index"
  19. :label="item.name" :name="item.name" @change="radioChange">
  20. </u-radio>
  21. </u-radio-group> -->
  22. <u-avatar :src="item.driverPortrait" size="38" class="img_css"></u-avatar>
  23. {{item.driverNickname}}
  24. </view>
  25. <view class="avatars_right" v-if="type == 2">
  26. <image src="../../static/images/riders/duihao.png" mode="" class="duihao_img" v-if="item.checkmark">
  27. </image>
  28. </view>
  29. </view>
  30. </view>
  31. <u-toast ref="uToast"></u-toast>
  32. <u-modal :show="setShow" :title="alertTitle" :closeOnClickOverlay='true' :showCancelButton='true'
  33. confirmColor='#F5BA3C' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  34. </view>
  35. </template>
  36. <script>
  37. import uniPopup from '../../components/uni-popup/uni-popup.vue';
  38. export default {
  39. data() {
  40. return {
  41. fleetId: "",
  42. formData: [],
  43. searchKeyWord: "",
  44. type: "",
  45. idList: [],
  46. setShow: false,
  47. alertTitle: ""
  48. }
  49. },
  50. onShow() {
  51. },
  52. onLoad(options) {
  53. this.type = options.type
  54. if (this.type == 1) {
  55. uni.setNavigationBarTitle({
  56. title: "删除成员"
  57. })
  58. } else {
  59. uni.setNavigationBarTitle({
  60. title: '车队管理权转让'
  61. });
  62. }
  63. this.fleetId = options.id
  64. this.getList()
  65. },
  66. onNavigationBarButtonTap(e) {
  67. if (this.type == 1) {
  68. if (this.idList.length == 0) {
  69. this.$refs.uToast.show({
  70. type: 'error',
  71. message: "请选择要删除的队员!",
  72. })
  73. return
  74. }
  75. this.alertTitle = "确定删除指定的队员?"
  76. this.setShow = true
  77. } else {
  78. if (!this.transferId) {
  79. this.$refs.uToast.show({
  80. type: 'error',
  81. message: "请选择一名新管理!",
  82. })
  83. return
  84. }
  85. this.alertTitle = "转移后您将不再是该车队的管理,确认转移?"
  86. this.setShow = true
  87. }
  88. },
  89. methods: {
  90. confirmClick() {
  91. if (this.type == 1) {
  92. this.delSunmit()
  93. this.cancelClick()
  94. } else {
  95. this.submit()
  96. this.cancelClick()
  97. }
  98. },
  99. cancelClick() {
  100. this.setShow = false
  101. },
  102. delSunmit() {
  103. this.alertTitle = "确定删除指定的队员?"
  104. this.setShow = true
  105. this.$request.baseRequest('post', '/fleetMemberInfo/api/delete', {
  106. // outFlag: 1,
  107. idList: this.idList
  108. }).then(res => {
  109. if (res.code == 200) {
  110. this.$refs.uToast.show({
  111. type: 'success',
  112. message: "队员删除成功!",
  113. // complete() {
  114. // uni.$u.route("pages/riders/myTeam")
  115. // }
  116. })
  117. this.getList()
  118. }
  119. })
  120. .catch(res => {
  121. uni.$u.toast(res.message);
  122. });
  123. },
  124. radioClick(item) {
  125. if (this.type == 1) {
  126. if (item.checked) {
  127. // this.idList.remove(item.id)
  128. for (let i = 0; i < this.idList.length; i++) {
  129. if (this.idList[i] == item.id) {
  130. this.idList.splice(i, 1)
  131. break
  132. }
  133. }
  134. item.checked = false;
  135. } else {
  136. this.idList.push(item.id)
  137. item.checked = true;
  138. }
  139. }
  140. if (this.type == 2) {
  141. for (let i = 0; i < this.formData.length; i++) {
  142. this.formData[i].checkmark = false
  143. }
  144. if (item.checkmark) {
  145. item.checkmark = false;
  146. } else {
  147. item.checkmark = true;
  148. this.transferId = item.id
  149. }
  150. }
  151. this.$forceUpdate()
  152. },
  153. getList() {
  154. this.$request.baseRequest('get', '/fleetMemberInfo/selectFleetMember', {
  155. searchKeyWord: this.searchKeyWord,
  156. fleetId: this.fleetId,
  157. pageSize: 10,
  158. currentPage: 1,
  159. }).then(res => {
  160. this.formData = res.data.records
  161. for (let i = 0; i < this.formData.length; i++) {
  162. this.formData[i].checkmark = false
  163. this.formData[i].checked = false
  164. }
  165. })
  166. .catch(res => {
  167. uni.$u.toast(res.message);
  168. });
  169. },
  170. submit() {
  171. this.$request.baseRequest('post', '/fleetMemberInfo/api/transferLeader', {
  172. fleetId: this.fleetId,
  173. transferId: this.transferId,
  174. }).then(res => {
  175. if (res.code == 200) {
  176. this.$refs.uToast.show({
  177. type: 'success',
  178. message: "管理转移成功!",
  179. complete() {
  180. uni.$u.route("pages/riders/myTeam")
  181. }
  182. })
  183. }
  184. })
  185. .catch(res => {
  186. uni.$u.toast(res.message);
  187. });
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .center {
  194. padding: 40rpx;
  195. }
  196. .avatars {
  197. .avatars_item {
  198. width: 100%;
  199. height: 120rpx;
  200. border-bottom: 1px solid #E6E6E6;
  201. line-height: 120rpx;
  202. .avatars_left {
  203. width: 80%;
  204. }
  205. .avatars_right {
  206. width: 20%;
  207. display: flex;
  208. justify-content: flex-end;
  209. .duihao_img {
  210. width: 28rpx;
  211. height: 28rpx;
  212. margin-top: 40rpx;
  213. margin: 50rpx 60rpx 0 0;
  214. }
  215. }
  216. }
  217. .img_css {
  218. margin-top: 30rpx;
  219. margin: 22rpx;
  220. }
  221. }
  222. </style>