list.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view>
  3. <scroll-view :scroll-y="true">
  4. <view class="cu-bar bg-white solid-bottom">
  5. <view class="action">
  6. <text class="cuIcon-title text-orange "></text> 班组列表
  7. </view>
  8. <view class="action">
  9. <button class="cu-btn bg-blue shadow" @click="addClick">新增</button>
  10. </view>
  11. </view>
  12. <view class="cu-list menu card-menu margin-top">
  13. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" @touchstart="ListTouchStart"
  14. @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index"
  15. style="margin-top: 10rpx;" v-for="(item,index) in teamList" :key="index">
  16. <view class="content" @click="editTeam(item)">
  17. <view class="cu-form-group">
  18. <view class="title" style="min-width: calc(6em + 15px);">制衣班组</view>
  19. <text class="text-grey" style="flex: 1;">{{item.zyTeam}}</text>
  20. </view>
  21. <view class="cu-form-group">
  22. <view class="title" style="min-width: calc(6em + 15px);">制衣生产车间</view>
  23. <text class="text-grey" style="flex: 1;">{{item.workshop.zyProductWorkshop}}</text>
  24. </view>
  25. <view class="cu-form-group">
  26. <view class="title" style="min-width: calc(6em + 15px);" >状态</view>
  27. <text v-if="item.status" class="text-grey" style="flex: 1;">正常</text>
  28. <text v-else="item.status" class="text-grey" style="flex: 1;">禁用</text>
  29. </view>
  30. <!-- <view class="cu-form-group">
  31. <view class="title" style="min-width: calc(6em + 15px);">订单号</view>
  32. <text class="text-grey" style="flex: 1;">{{item.orderNo}}</text>
  33. </view>
  34. <view class="cu-form-group"> -->
  35. <!-- <view class="title" style="min-width: calc(6em + 15px);">交期</view>
  36. <text class="text-grey" style="flex: 1;">{{item.deliveryDate}}</text>
  37. </view> -->
  38. </view>
  39. <view class="move">
  40. <view class="bg-grey" @click="editTeam(item)">修改</view>
  41. <view class="bg-red" @click="deleteTeam(item)">删除</view>
  42. </view>
  43. </view>
  44. </view>
  45. <u-toast ref="uToast" />
  46. </scroll-view>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. list,
  52. deleteTeam
  53. } from '@/api/biz/team.js'
  54. export default {
  55. data() {
  56. return {
  57. teamList: [],
  58. modalName: null,
  59. }
  60. },
  61. methods: {
  62. addClick() {
  63. uni.navigateTo({
  64. url: '/pages/team/add'
  65. })
  66. },
  67. loadData() {
  68. list().then(res => {
  69. if (res.success) {
  70. this.teamList = res.data
  71. } else {}
  72. })
  73. },
  74. editTeam(item) {
  75. uni.navigateTo({
  76. url: '/pages/team/edit?teamInfo=' + encodeURIComponent(JSON.stringify(item))
  77. })
  78. },
  79. // ListTouch触摸开始
  80. ListTouchStart(e) {
  81. this.listTouchStart = e.touches[0].pageX
  82. },
  83. // ListTouch计算方向
  84. ListTouchMove(e) {
  85. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
  86. },
  87. // ListTouch计算滚动
  88. ListTouchEnd(e) {
  89. if (this.listTouchDirection == 'left') {
  90. this.modalName = e.currentTarget.dataset.target
  91. } else {
  92. this.modalName = null
  93. }
  94. this.listTouchDirection = null
  95. },
  96. deleteTeam(item) {
  97. const arr = []
  98. arr.push(item)
  99. deleteTeam(arr).then(res => {
  100. if (res.success) {
  101. this.$refs.uToast.show({
  102. type: 'success',
  103. message: "删除成功",
  104. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  105. })
  106. this.removeTeamInfo(item)
  107. }else{
  108. this.$refs.uToast.show({
  109. type: 'error',
  110. message: res.message,
  111. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  112. })
  113. }
  114. })
  115. },
  116. removeTeamInfo(item) {
  117. const index = this.teamList.findIndex(ele => {
  118. return ele.id == item.id
  119. })
  120. this.teamList.splice(index, 1)
  121. }
  122. },
  123. onLoad() {
  124. this.loadData()
  125. uni.$on('loadData', () => {
  126. this.loadData();
  127. })
  128. }
  129. }
  130. </script>
  131. <style>
  132. .cu-form-group {
  133. min-height: 0;
  134. border: none;
  135. }
  136. </style>