123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <template>
- <view id="main" class="content main">
- <app-header @back="back">远程调度</app-header>
- <view>
- <view>
- <view id="top">
- <u-cell title="选择粮库" :value="form.orgName" :is-link="true"
- @click="storehouseSelectShow = true"></u-cell>
- <view class="queueCar">
- <view class="text">
- <view>排队车辆</view>
- <view>
- <view class="num">{{carCount}}</view> 辆</view>
- </view>
- </view>
- <view class="title">车辆调度</view>
- </view>
- <view class="list">
- <HM-dragSorts v-if="showList" :key="updateKey" :list="dataList" :autoScroll="true" :feedbackGenerator="true"
- :listHeight="listH" :rowHeight="55" @confirm="confirm"></HM-dragSorts>
- </view>
- <u-action-sheet2 :actions="orgList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="选择粮库"
- :show="storehouseSelectShow" @select="onOrgSelect" @close="storehouseSelectShow = false">
- </u-action-sheet2>
- </view>
- <tabbar></tabbar>
- </view>
- </view>
- </template>
- <script>
- import {
- HOME_INDEX,
- CAR_INDEX,
- MONITOR_INDEX,
- LIVE_INDEX
- } from '@/config/constants'
- import dragSorts from '@/uni_modules/HM-dragSorts/components/HM-dragSorts/HM-dragSorts.vue'
- import {
- getCarDynamicCheck,
- updateSort
- } from '@/api/schedule';
- import {
- getOrgTypes,
- getVehicleTypes
- } from '@/api/basic'
- import appHeader from '@/pages/components/header/header.vue'
- import tabbar from '@/pages/components/tabbar.vue'
- import uActionSheet2 from '@/components/u-action-sheet/my-action-sheet.vue'
- export default {
- components: {
- 'HM-dragSorts': dragSorts,
- appHeader,
- tabbar,
- uActionSheet2,
- },
- data() {
- return {
- updateKey: 0,
- storehouseSelectShow: false,
- orgList: [],
- dataList: [],
- vehicleTypeMap: {},
- carCount: 0,
- showList: false,
- listH: 0,
- form: {
- orgName: null,
- orgId: null,
- },
- }
- },
- mounted() {
- getOrgTypes().then(resp => {
- const list = resp.data || list
- list.forEach(d => {
- d.name = d.orgName
- })
- this.orgList = resp.data || []
- })
- getVehicleTypes().then(resp => {
- const list = resp.data || []
- list.forEach(d => {
- this.vehicleTypeMap[d.id] = d
- })
- })
- this.$nextTick(() => {
- let total
- this.getTotalHeight().then(all => {
- this.getTopHeight().then(t => {
- const listH = all - t - 60 - 80 - 20
- console.log("listH", listH);
- this.listH = listH
- this.showList = true
- })
- })
- })
- },
- methods: {
- back() {
- getApp().globalData.tabIndex = HOME_INDEX
- uni.redirectTo({
- url: '/pages/home/home'
- })
- },
- getTopHeight() {
- return new Promise((resolve) => {
- const query = uni.createSelectorQuery().in(this);
- query
- .select("#top")
- .boundingClientRect((data) => {
- const topH = data.height
- console.log('top 高度', topH);
- resolve(topH)
- })
- .exec();
- })
- },
- getTotalHeight() {
- return new Promise((resolve) => {
- const query = uni.createSelectorQuery().in(this);
- query
- .select("#main")
- .boundingClientRect((data) => {
- const topH = data.height
- console.log('main 高度', topH);
- resolve(topH)
- })
- .exec();
- })
- },
- onOrgSelect(data) {
- console.log('choose', data);
- this.form.orgName = data.orgName
- this.form.orgId = data.orgId
- this.queryData()
- },
- queryData() {
- console.log('orgId = ', this.form.orgId);
- return getCarDynamicCheck({
- orgId: this.form.orgId
- }).then(resp => {
- if (resp.code === 200) {
- this.updateKey += 1
- this.carCount = resp.data.carCount
- const list = resp.data.listParam || []
- this.updateList(list)
- }
- })
- },
- updateList(list) {
- let i = 1
- list.forEach(d => {
- d.name = `车牌号: ${d.licensePlateNumber} 排队号: ${i ++} 类型: ${this.carTypeName(d.vehicleType)} `
- })
- this.dataList = list
- },
- carTypeName(typeId) {
- if (typeId in this.vehicleTypeMap) {
- return this.vehicleTypeMap[typeId]?.dictLabel
- }
- return ""
- },
- onclick() {
- console.log('click', arguments);
- },
- change() {
- console.log('change', arguments);
- },
- confirm(data) {
- console.log('confirm', arguments);
- const {
- list
- } = data
- let i = 1
- const ret = list.map(d => {
- return {
- reservationRegisterId: d.id,
- sortNo: i++
- }
- })
- console.log(list, this.dataList);
- // {
- // id: xxx,
- // sortNo: 1,
- // }
- uni.showLoading({
- title: '更新中'
- })
- updateSort(ret).then(resp => {
- if (resp.code === 200) {
- this.queryData().then(_ => {
- uni.showToast({
- title: '更新成功',
- icon: 'success'
- })
- })
- }
- }).finally(_ => {
- uni.hideLoading()
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- background-color: #f0f1f2;
- height: 100vh;
- .title {
- margin-left: 15px;
- font-size: 20px;
- font-weight: 0.9;
- }
- }
- .queueCar {
- background: url('~@/static/queue-car.png') no-repeat;
- background-size: 100% 100%;
- height: 100px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- .text {
- margin-left: 30px;
- .num {
- display: inline-block;
- font-size: 30px;
- color: #334ec2;
- }
- }
-
-
- }
- .list {
- margin: 10px;
- }
- </style>
|