schedule.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view id="main" class="content main">
  3. <app-header @back="back">远程调度</app-header>
  4. <view>
  5. <view>
  6. <view id="top">
  7. <u-cell title="选择粮库" :value="form.orgName" :is-link="true"
  8. @click="storehouseSelectShow = true"></u-cell>
  9. <view class="queueCar">
  10. <view class="text">
  11. <view>排队车辆</view>
  12. <view>
  13. <view class="num">{{carCount}}</view> 辆</view>
  14. </view>
  15. </view>
  16. <view class="title">车辆调度</view>
  17. </view>
  18. <view class="list">
  19. <HM-dragSorts v-if="showList" :key="updateKey" :list="dataList" :autoScroll="true" :feedbackGenerator="true"
  20. :listHeight="listH" :rowHeight="55" @confirm="confirm"></HM-dragSorts>
  21. </view>
  22. <u-action-sheet2 :actions="orgList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="选择粮库"
  23. :show="storehouseSelectShow" @select="onOrgSelect" @close="storehouseSelectShow = false">
  24. </u-action-sheet2>
  25. </view>
  26. <tabbar></tabbar>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. HOME_INDEX,
  33. CAR_INDEX,
  34. MONITOR_INDEX,
  35. LIVE_INDEX
  36. } from '@/config/constants'
  37. import dragSorts from '@/uni_modules/HM-dragSorts/components/HM-dragSorts/HM-dragSorts.vue'
  38. import {
  39. getCarDynamicCheck,
  40. updateSort
  41. } from '@/api/schedule';
  42. import {
  43. getOrgTypes,
  44. getVehicleTypes
  45. } from '@/api/basic'
  46. import appHeader from '@/pages/components/header/header.vue'
  47. import tabbar from '@/pages/components/tabbar.vue'
  48. import uActionSheet2 from '@/components/u-action-sheet/my-action-sheet.vue'
  49. export default {
  50. components: {
  51. 'HM-dragSorts': dragSorts,
  52. appHeader,
  53. tabbar,
  54. uActionSheet2,
  55. },
  56. data() {
  57. return {
  58. updateKey: 0,
  59. storehouseSelectShow: false,
  60. orgList: [],
  61. dataList: [],
  62. vehicleTypeMap: {},
  63. carCount: 0,
  64. showList: false,
  65. listH: 0,
  66. form: {
  67. orgName: null,
  68. orgId: null,
  69. },
  70. }
  71. },
  72. mounted() {
  73. getOrgTypes().then(resp => {
  74. const list = resp.data || list
  75. list.forEach(d => {
  76. d.name = d.orgName
  77. })
  78. this.orgList = resp.data || []
  79. })
  80. getVehicleTypes().then(resp => {
  81. const list = resp.data || []
  82. list.forEach(d => {
  83. this.vehicleTypeMap[d.id] = d
  84. })
  85. })
  86. this.$nextTick(() => {
  87. let total
  88. this.getTotalHeight().then(all => {
  89. this.getTopHeight().then(t => {
  90. const listH = all - t - 60 - 80 - 20
  91. console.log("listH", listH);
  92. this.listH = listH
  93. this.showList = true
  94. })
  95. })
  96. })
  97. },
  98. methods: {
  99. back() {
  100. getApp().globalData.tabIndex = HOME_INDEX
  101. uni.redirectTo({
  102. url: '/pages/home/home'
  103. })
  104. },
  105. getTopHeight() {
  106. return new Promise((resolve) => {
  107. const query = uni.createSelectorQuery().in(this);
  108. query
  109. .select("#top")
  110. .boundingClientRect((data) => {
  111. const topH = data.height
  112. console.log('top 高度', topH);
  113. resolve(topH)
  114. })
  115. .exec();
  116. })
  117. },
  118. getTotalHeight() {
  119. return new Promise((resolve) => {
  120. const query = uni.createSelectorQuery().in(this);
  121. query
  122. .select("#main")
  123. .boundingClientRect((data) => {
  124. const topH = data.height
  125. console.log('main 高度', topH);
  126. resolve(topH)
  127. })
  128. .exec();
  129. })
  130. },
  131. onOrgSelect(data) {
  132. console.log('choose', data);
  133. this.form.orgName = data.orgName
  134. this.form.orgId = data.orgId
  135. this.queryData()
  136. },
  137. queryData() {
  138. console.log('orgId = ', this.form.orgId);
  139. return getCarDynamicCheck({
  140. orgId: this.form.orgId
  141. }).then(resp => {
  142. if (resp.code === 200) {
  143. this.updateKey += 1
  144. this.carCount = resp.data.carCount
  145. const list = resp.data.listParam || []
  146. this.updateList(list)
  147. }
  148. })
  149. },
  150. updateList(list) {
  151. let i = 1
  152. list.forEach(d => {
  153. d.name = `车牌号: ${d.licensePlateNumber} 排队号: ${i ++} 类型: ${this.carTypeName(d.vehicleType)} `
  154. })
  155. this.dataList = list
  156. },
  157. carTypeName(typeId) {
  158. if (typeId in this.vehicleTypeMap) {
  159. return this.vehicleTypeMap[typeId]?.dictLabel
  160. }
  161. return ""
  162. },
  163. onclick() {
  164. console.log('click', arguments);
  165. },
  166. change() {
  167. console.log('change', arguments);
  168. },
  169. confirm(data) {
  170. console.log('confirm', arguments);
  171. const {
  172. list
  173. } = data
  174. let i = 1
  175. const ret = list.map(d => {
  176. return {
  177. reservationRegisterId: d.id,
  178. sortNo: i++
  179. }
  180. })
  181. console.log(list, this.dataList);
  182. // {
  183. // id: xxx,
  184. // sortNo: 1,
  185. // }
  186. uni.showLoading({
  187. title: '更新中'
  188. })
  189. updateSort(ret).then(resp => {
  190. if (resp.code === 200) {
  191. this.queryData().then(_ => {
  192. uni.showToast({
  193. title: '更新成功',
  194. icon: 'success'
  195. })
  196. })
  197. }
  198. }).finally(_ => {
  199. uni.hideLoading()
  200. })
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss" scoped>
  206. .main {
  207. background-color: #f0f1f2;
  208. height: 100vh;
  209. .title {
  210. margin-left: 15px;
  211. font-size: 20px;
  212. font-weight: 0.9;
  213. }
  214. }
  215. .queueCar {
  216. background: url('~@/static/queue-car.png') no-repeat;
  217. background-size: 100% 100%;
  218. height: 100px;
  219. display: flex;
  220. flex-direction: column;
  221. justify-content: center;
  222. .text {
  223. margin-left: 30px;
  224. .num {
  225. display: inline-block;
  226. font-size: 30px;
  227. color: #334ec2;
  228. }
  229. }
  230. }
  231. .list {
  232. margin: 10px;
  233. }
  234. </style>