OrderListPanel.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <div class="panel-section order-mgmt">
  3. <div class="sec-header">
  4. <span class="tit">订单</span>
  5. <!-- Right Aligned Tabs -->
  6. <div class="header-right-tabs">
  7. <span class="h-tab-item" :class="{ active: currentTab === 'PendingDispatch' }" @click="currentTab = 'PendingDispatch'">
  8. <span class="txt">待派单</span>
  9. <span class="num danger">{{ stats.pendingDispatch }}</span>
  10. </span>
  11. <span class="h-tab-item" :class="{ active: currentTab === 'PendingAccept' }" @click="currentTab = 'PendingAccept'">
  12. <span class="txt">待接单</span>
  13. <span class="num warning">{{ stats.pendingAccept }}</span>
  14. </span>
  15. <span class="h-tab-item" :class="{ active: currentTab === 'Processing' }" @click="currentTab = 'Processing'">
  16. <span class="txt">进行中</span>
  17. <span class="num primary">{{ stats.processing }}</span>
  18. </span>
  19. </div>
  20. </div>
  21. <!-- Order List -->
  22. <div class="list-wrapper">
  23. <el-scrollbar>
  24. <div v-if="orders.length === 0" class="empty-state">暂无数据</div>
  25. <div v-else v-for="order in orders" :key="order.id" class="list-card order-card" @click="$emit('focus', order.lng, order.lat)">
  26. <div class="card-left">
  27. <div class="type-tag" :class="order.typeCode">
  28. {{ getShortType(order.typeCode) }}
  29. </div>
  30. </div>
  31. <div class="card-main">
  32. <template v-if="order.typeCode === 'transport'">
  33. <div class="row-addr" :title="order.fromAddress"><span class="tag pick">起</span> {{ order.fromAddress }}</div>
  34. <div class="row-addr" :title="order.toAddress"><span class="tag drop">终</span> {{ order.toAddress }}</div>
  35. <div class="row-time">
  36. <el-icon><Clock /></el-icon> {{ order.serviceTime }}
  37. <span class="days-tag" v-if="order.daysLater">{{ order.daysLater }}</span>
  38. </div>
  39. </template>
  40. <template v-else>
  41. <div class="row-addr" :title="order.toAddress"><span class="tag home">终</span> {{ order.toAddress }}</div>
  42. <div class="row-time" style="margin-top: 4px">
  43. <el-icon><Clock /></el-icon> {{ order.serviceTime }}
  44. <span class="days-tag" v-if="order.daysLater">{{ order.daysLater }}</span>
  45. </div>
  46. </template>
  47. </div>
  48. <!-- Right: Status & Actions -->
  49. <div class="card-right">
  50. <el-tag size="small" :type="getOrderStatusType(order.status)" effect="plain">{{ getOrderStatusText(order.status) }}</el-tag>
  51. <div class="actions">
  52. <el-button v-if="order.status === 0" type="primary" size="small" @click.stop="$emit('dispatch', order)"
  53. >派单</el-button
  54. >
  55. <el-button
  56. v-else-if="[1, 2, 3].includes(order.status)"
  57. type="primary"
  58. size="small"
  59. plain
  60. @click.stop="$emit('dispatch', order)"
  61. >重新派单</el-button
  62. >
  63. </div>
  64. </div>
  65. </div>
  66. </el-scrollbar>
  67. </div>
  68. </div>
  69. </template>
  70. <script setup>
  71. import { computed } from 'vue';
  72. import { Clock } from '@element-plus/icons-vue';
  73. const props = defineProps({
  74. modelValue: { type: String, default: 'PendingDispatch' },
  75. orders: { type: Array, default: () => [] },
  76. stats: { type: Object, default: () => ({}) }
  77. });
  78. const emit = defineEmits(['update:modelValue', 'focus', 'dispatch']);
  79. const currentTab = computed({
  80. get: () => props.modelValue,
  81. set: (val) => emit('update:modelValue', val)
  82. });
  83. const getShortType = (code) => {
  84. const map = { 'transport': '接送', 'feeding': '喂遛', 'washing': '洗护' };
  85. return map[code] || '订单';
  86. };
  87. const getOrderStatusText = (status) => {
  88. const map = { 0: '待派单', 1: '待接单', 2: '待服务', 3: '服务中', 4: '待商家确认', 5: '已完成', 6: '已取消' };
  89. return map[status] || '未知';
  90. };
  91. const getOrderStatusType = (status) => {
  92. const map = { 0: 'danger', 1: 'warning', 2: 'primary', 3: 'primary', 4: 'warning', 5: 'success', 6: 'info' };
  93. return map[status] || 'info';
  94. };
  95. </script>
  96. <style scoped>
  97. .order-mgmt {
  98. border-bottom: 8px solid #f5f7fa;
  99. flex: 1;
  100. display: flex;
  101. flex-direction: column;
  102. overflow: hidden;
  103. height: 50%;
  104. }
  105. .sec-header {
  106. height: 48px;
  107. padding: 0 16px;
  108. display: flex;
  109. align-items: center;
  110. justify-content: space-between;
  111. border-bottom: 1px solid #f0f0f0;
  112. }
  113. .sec-header .tit {
  114. font-weight: bold;
  115. font-size: 15px;
  116. color: #1f2f3d;
  117. }
  118. .header-right-tabs {
  119. display: flex;
  120. gap: 4px;
  121. }
  122. .h-tab-item {
  123. display: flex;
  124. flex-direction: row;
  125. align-items: center;
  126. justify-content: center;
  127. cursor: pointer;
  128. position: relative;
  129. padding: 6px 12px;
  130. gap: 6px;
  131. border-radius: 4px;
  132. transition: all 0.2s;
  133. color: #606266;
  134. }
  135. .h-tab-item:hover {
  136. background: #f5f7fa;
  137. }
  138. .h-tab-item.active {
  139. background: #ecf5ff;
  140. }
  141. .h-tab-item.active .txt {
  142. color: #409eff;
  143. font-weight: bold;
  144. }
  145. .h-tab-item .txt {
  146. font-size: 14px;
  147. }
  148. .h-tab-item .num {
  149. font-size: 14px;
  150. font-weight: bold;
  151. margin-bottom: 0;
  152. }
  153. .h-tab-item .num.danger {
  154. color: #f56c6c;
  155. }
  156. .h-tab-item .num.warning {
  157. color: #e6a23c;
  158. }
  159. .h-tab-item .num.primary {
  160. color: #409eff;
  161. }
  162. .list-wrapper {
  163. flex: 1;
  164. overflow: hidden;
  165. padding: 8px 12px;
  166. }
  167. .empty-state {
  168. text-align: center;
  169. color: #909399;
  170. padding: 20px;
  171. font-size: 13px;
  172. }
  173. .list-card {
  174. background: #fff;
  175. border: 1px solid #ebeef5;
  176. border-radius: 8px;
  177. padding: 12px;
  178. margin-bottom: 10px;
  179. display: flex;
  180. align-items: stretch;
  181. gap: 12px;
  182. transition: all 0.2s;
  183. cursor: pointer;
  184. }
  185. .list-card:hover {
  186. border-color: #c6e2ff;
  187. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  188. }
  189. .card-left {
  190. flex-shrink: 0;
  191. display: flex;
  192. align-items: center;
  193. }
  194. .order-card .type-tag {
  195. width: 40px;
  196. height: 40px;
  197. border-radius: 8px;
  198. color: #fff;
  199. display: flex;
  200. align-items: center;
  201. justify-content: center;
  202. font-size: 12px;
  203. font-weight: bold;
  204. }
  205. .type-tag.transport {
  206. background: #e6a23c;
  207. }
  208. .type-tag.feeding {
  209. background: #67c23a;
  210. }
  211. .type-tag.washing {
  212. background: #409eff;
  213. }
  214. .card-main {
  215. flex: 1;
  216. overflow: hidden;
  217. display: flex;
  218. flex-direction: column;
  219. justify-content: center;
  220. gap: 4px;
  221. }
  222. .row-addr {
  223. font-size: 13px;
  224. color: #303133;
  225. display: flex;
  226. align-items: center;
  227. gap: 4px;
  228. white-space: nowrap;
  229. overflow: hidden;
  230. text-overflow: ellipsis;
  231. line-height: 1.5;
  232. }
  233. .row-addr .tag {
  234. font-size: 11px;
  235. color: #fff;
  236. padding: 1px 4px;
  237. border-radius: 4px;
  238. flex-shrink: 0;
  239. transform: scale(0.9);
  240. }
  241. .tag.pick {
  242. background: #409eff;
  243. }
  244. .tag.drop {
  245. background: #e6a23c;
  246. }
  247. .tag.home {
  248. background: #67c23a;
  249. }
  250. .row-time {
  251. font-size: 12px;
  252. color: #909399;
  253. display: flex;
  254. align-items: center;
  255. gap: 4px;
  256. }
  257. .days-tag {
  258. color: #f56c6c;
  259. background: #fef0f0;
  260. padding: 0 4px;
  261. border-radius: 4px;
  262. font-size: 11px;
  263. border: 1px solid #fde2e2;
  264. transform: scale(0.95);
  265. }
  266. .card-right {
  267. display: flex;
  268. flex-direction: column;
  269. align-items: flex-end;
  270. justify-content: center;
  271. gap: 8px;
  272. margin-left: 8px;
  273. flex-shrink: 0;
  274. }
  275. .card-right .actions {
  276. display: flex;
  277. align-items: center;
  278. gap: 4px;
  279. }
  280. </style>