driverList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="customer-list">
  3. <view class="list-wrap">
  4. <u-sticky bgColor="#fff" class="main-sticky">
  5. <view class="search-wrap">
  6. <view class="input-wrap">
  7. <view class="input">
  8. <u-search bgColor='#fff' :showAction='false'
  9. :placeholder="$t('base.common.inputPlaceholder')" @search="onGetVheicleList"
  10. @clear='onGetVheicleList' v-model="keyword">
  11. </u-search>
  12. <view class="search-btn" @click="onGetVheicleList">{{$t("customer_meter.search")}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. </u-sticky>
  17. <template v-if="vehicleList.length">
  18. <u-swipe-action>
  19. <view class="business-card" v-for="(item, index) in vehicleList" :key="index">
  20. <u-swipe-action-item :options="options" @click="onVehicleChange($event,item)">
  21. <view class="business-card-info">
  22. <view class="info-line">
  23. <text class="lebel">{{item.driver}}{{' '+ (item.fleet?$t("driver.fleet")+"【"+item.fleet+"】":'')}}</text>
  24. <!-- <text class="info"> {{item.vehicle || ''}}【{{item.agriculturalVehicle=='1'?'农车用':'正常车'}}】</text> -->
  25. <text class="info"> {{item.vehicle || ''}}【{{$t("order.phone")+': '+item.phone}}】</text>
  26. </view>
  27. <view class="businessStatus-info">
  28. <u--image width="100rpx" height="88rpx"
  29. :src="item.fleet&&item.fleet!=''?'/subpages/static/czzn-img/state/fleet_vehicle.png':'/subpages/static/czzn-img/state/private-vehicle.png'">
  30. </u--image>
  31. </view>
  32. </view>
  33. </u-swipe-action-item>
  34. </view>
  35. </u-swipe-action>
  36. </template>
  37. <template v-else>
  38. <u-empty mode="list" icon="https://cdn.uviewui.com/uview/empty/list.png">
  39. </u-empty>
  40. </template>
  41. <uni-fab ref="fab" horizontal="left" vertical="bottom" buttonColor="#3c9cff" @trigger="trigger"
  42. @fabClick="onClickRight" />
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import card from '../material/card.vue'
  48. import {
  49. getVehicleListByCondition,
  50. bindVehicle,
  51. deleteVehicle
  52. } from '../../api/driver'
  53. export default {
  54. data() {
  55. return {
  56. options: [{
  57. text: this.$t("base.button.delete"),
  58. name: "delete",
  59. style: {
  60. backgroundColor: '#f56c6c'
  61. }
  62. },
  63. // {
  64. // text: this.$t("base.button.update"),
  65. // name: "update",
  66. // style: {
  67. // backgroundColor: 'rgb(0, 122, 255)'
  68. // }
  69. // }
  70. ],
  71. keyword: '',
  72. active: 0,
  73. value: '',
  74. vehicleList: [],
  75. topheight: 0,
  76. }
  77. },
  78. components: {
  79. card
  80. },
  81. onLoad() {
  82. this.getTopHeight()
  83. },
  84. onShow() {
  85. this.onGetVheicleList()
  86. },
  87. methods: {
  88. onVehicleChange(e, item) {
  89. console.log("事件、", e);
  90. var that = this;
  91. if (e.index == 0) {
  92. uni.showModal({
  93. // title: '提示',
  94. content: that.$t("driver.deleteVehcile"),
  95. showCancel: true,
  96. cancelText: that.$t("base.search.cancelText"),
  97. confirmText: that.$t("base.search.submitText"),
  98. success: function(r) {
  99. if (r.confirm) {
  100. deleteVehicle(item).then(res => {
  101. if (res.statusCode == 200) {
  102. if (uni.getStorageSync("currentVehicleInfo") && item.vehicle ==
  103. uni.getStorageSync("currentVehicleInfo").vehicle) {
  104. uni.removeStorageSync("currentVehicleInfo")
  105. }
  106. that.onGetVheicleList()
  107. }
  108. })
  109. }
  110. }
  111. })
  112. } else {
  113. if (uni.getStorageSync("currentVehicleInfo") && item.id ==
  114. uni.getStorageSync("currentVehicleInfo").id) {
  115. uni.removeStorageSync("currentVehicleInfo")
  116. }
  117. uni.navigateTo({
  118. url: `/subpages/driver/add?id=${item.id}`
  119. })
  120. }
  121. },
  122. onBindVehicle(item) {
  123. bindVehicle(item).then(res => {
  124. if (res.statusCode == 200) {
  125. this.onGetVheicleList();
  126. }
  127. })
  128. },
  129. //适配状态栏高度
  130. getTopHeight() {
  131. console.log('123');
  132. let that = this;
  133. uni.getSystemInfo({
  134. success: function(e) {
  135. //48为自定义导航栏高度,一般为44
  136. let topPx = e.statusBarHeight + 44 // 顶部状态栏+沉浸式自定义顶部导航
  137. that.topheight = topPx // px转rpx,这里必须转化为rpx,不然适配失败
  138. },
  139. });
  140. },
  141. onGetVheicleList() {
  142. let data = {
  143. keyword: this.keyword || '',
  144. }
  145. getVehicleListByCondition(data).then(res => {
  146. if (res.statusCode == 200) {
  147. this.vehicleList = res.data.data
  148. if (this.vehicleList) {
  149. if (this.vehicleList.length == 1) {
  150. uni.setStorageSync("currentVehicleInfo", this.vehicleList[0]);
  151. } else {
  152. var vehicleInfo = this.vehicleList.filter(p => {
  153. return p.runFlag == 1
  154. });
  155. if (vehicleInfo) {
  156. uni.setStorageSync("currentVehicleInfo", vehicleInfo[0]);
  157. }
  158. }
  159. }
  160. }
  161. })
  162. },
  163. onClickRight() {
  164. uni.navigateTo({
  165. url: `/subpages/driver/add`
  166. })
  167. },
  168. changeTab(item) {
  169. this.active = item.index
  170. },
  171. }
  172. }
  173. </script>
  174. <style>
  175. /* #ifndef H5 */
  176. page {
  177. /* height: 100%; */
  178. background-color: #f2f2f2;
  179. }
  180. /* #endif */
  181. </style>
  182. <style lang="scss" scoped>
  183. @import '../../common/css/public.scss';
  184. </style>