混凝土运输管理微信小程序、替班
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
4.7 KiB

2 weeks ago
  1. <template>
  2. <view class="select-car-container">
  3. <!-- 遮罩层 -->
  4. <view v-if="visible" :class="['mask', visible && 'active']" @click="close"></view>
  5. <!-- 选择器弹窗 -->
  6. <view :class="['select-popup', 'b-relative', visible && 'active']">
  7. <view class="popup-title">选择设备</view>
  8. <view class="close-btn" @click="close">关闭</view>
  9. <view class="car-list">
  10. <view v-if="carList.length === 0" class="empty-state">
  11. <view>暂无数据</view>
  12. </view>
  13. <view v-for="(car, index) in carList" :key="index" class="car-item">
  14. <view class="car-info">
  15. <image class="car-icon" src="/static/icons/icon11.png"></image>
  16. <text>{{ car.plateNumber }}</text>
  17. </view>
  18. <view class="car-actions">
  19. <view v-if="car.status === 'available'" class="action-btn confirm" @click="selectCar(car)">
  20. <text style="color:#F40000">确认选择</text>
  21. </view>
  22. <view v-else-if="car.status === 'pending'" class="action-btn pending">
  23. <text style="color:#F40000">审核中</text>
  24. </view>
  25. <view v-else-if="car.status === 'rejected'" class="action-btn rejected">
  26. <text style="color:#F40000">未通过审核</text>
  27. </view>
  28. <view v-else-if="car.status === 'busy'" class="action-btn busy">
  29. <text style="color:#F40000">设备使用中</text>
  30. </view>
  31. </view>
  32. <view class="car-details">
  33. <view class="detail-item">
  34. <text>车辆类型{{ car.type }}</text>
  35. </view>
  36. <view class="detail-item">
  37. <text>轴数{{ car.axleCount }}</text>
  38. </view>
  39. <view class="detail-item">
  40. <text>载重{{ car.capacity }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. name: 'SelectCar',
  51. props: {
  52. visible: {
  53. type: Boolean,
  54. default: false
  55. },
  56. carList: {
  57. type: Array,
  58. default: () => []
  59. }
  60. },
  61. data() {
  62. return {
  63. // 模拟车辆数据
  64. defaultCarList: [
  65. {
  66. id: 1,
  67. plateNumber: '湘A12345',
  68. type: '泵车',
  69. axleCount: 4,
  70. capacity: 25,
  71. status: 'available' // available, pending, rejected, busy
  72. },
  73. {
  74. id: 2,
  75. plateNumber: '湘A67890',
  76. type: '搅拌车',
  77. axleCount: 3,
  78. capacity: 12,
  79. status: 'busy'
  80. },
  81. {
  82. id: 3,
  83. plateNumber: '湘A11111',
  84. type: '泵车',
  85. axleCount: 5,
  86. capacity: 35,
  87. status: 'pending'
  88. }
  89. ]
  90. }
  91. },
  92. computed: {
  93. effectiveCarList() {
  94. return this.carList.length > 0 ? this.carList : this.defaultCarList;
  95. }
  96. },
  97. methods: {
  98. close() {
  99. this.$emit('close');
  100. },
  101. selectCar(car) {
  102. if (car.status === 'available') {
  103. this.$emit('select', car);
  104. this.close();
  105. } else {
  106. uni.showToast({
  107. title: '该设备不可选择',
  108. icon: 'none'
  109. });
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. .select-car-container {
  117. position: relative;
  118. }
  119. .mask {
  120. position: fixed;
  121. top: 0;
  122. left: 0;
  123. width: 100vw;
  124. height: 100vh;
  125. background-color: rgba(0, 0, 0, 0.5);
  126. z-index: 999;
  127. opacity: 0;
  128. transition: opacity 0.3s;
  129. &.active {
  130. opacity: 1;
  131. }
  132. }
  133. .select-popup {
  134. position: fixed;
  135. bottom: 0;
  136. left: 0;
  137. width: 100vw;
  138. max-height: 80vh;
  139. background-color: #fff;
  140. border-radius: 20rpx 20rpx 0 0;
  141. z-index: 1000;
  142. transform: translateY(100%);
  143. transition: transform 0.3s;
  144. &.active {
  145. transform: translateY(0);
  146. }
  147. }
  148. .popup-title {
  149. text-align: center;
  150. font-size: 32rpx;
  151. font-weight: bold;
  152. padding: 30rpx 0;
  153. border-bottom: 1rpx solid #eee;
  154. }
  155. .close-btn {
  156. position: absolute;
  157. top: 30rpx;
  158. right: 30rpx;
  159. font-size: 28rpx;
  160. color: #666;
  161. }
  162. .car-list {
  163. max-height: 60vh;
  164. overflow-y: auto;
  165. padding: 20rpx;
  166. }
  167. .empty-state {
  168. text-align: center;
  169. padding: 100rpx 0;
  170. color: #999;
  171. font-size: 28rpx;
  172. }
  173. .car-item {
  174. background-color: #fff;
  175. border: 1rpx solid #eee;
  176. border-radius: 10rpx;
  177. padding: 30rpx;
  178. margin-bottom: 20rpx;
  179. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  180. }
  181. .car-info {
  182. display: flex;
  183. align-items: center;
  184. margin-bottom: 20rpx;
  185. .car-icon {
  186. width: 72rpx;
  187. height: 60rpx;
  188. margin-right: 16rpx;
  189. }
  190. text {
  191. font-size: 32rpx;
  192. font-weight: bold;
  193. color: #333;
  194. }
  195. }
  196. .car-actions {
  197. display: flex;
  198. justify-content: flex-end;
  199. margin-bottom: 20rpx;
  200. }
  201. .action-btn {
  202. padding: 10rpx 20rpx;
  203. border-radius: 8rpx;
  204. border: 1rpx solid #F40000;
  205. background-color: #fff;
  206. &.confirm {
  207. cursor: pointer;
  208. }
  209. &.pending, &.rejected, &.busy {
  210. opacity: 0.6;
  211. }
  212. }
  213. .car-details {
  214. .detail-item {
  215. margin-bottom: 10rpx;
  216. font-size: 28rpx;
  217. color: #666;
  218. }
  219. }
  220. .b-relative {
  221. position: relative;
  222. }
  223. </style>