118 lines
4.0 KiB
Vue
118 lines
4.0 KiB
Vue
<!-- 用车管理 -->
|
|
<template>
|
|
<view class="container">
|
|
<scroll-view scroll-y style="padding-bottom: 180rpx;background-color: #fff;">
|
|
<uni-forms v-model="form" label-width="200rpx">
|
|
<ticketd :ticket_="form.ticket_"></ticketd>
|
|
<uni-forms-item label="用车事由" required>
|
|
<uni-easyinput v-model="form.reason" placeholder="请输入用车事由" :disabled="mode=='show'"/>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="用车范围" required>
|
|
<uni-data-select
|
|
v-model="form.is_city"
|
|
:localdata="vehicle_list"
|
|
:disabled="mode=='show'"
|
|
@change="mdateChange"
|
|
></uni-data-select>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="出发地点" required>
|
|
<uni-easyinput v-model="form.location" placeholder="请输入出发地点" :disabled="mode=='show'"/>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="途经地点" required>
|
|
<uni-easyinput v-model="form.via" placeholder="请输入途经地点" :disabled="mode=='show'"/>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="到达地点" required>
|
|
<uni-easyinput v-model="form.destination" placeholder="请输入到达地点" :disabled="mode=='show'"/>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="出发公里数" required>
|
|
<uni-number-box v-model="form.start_km" :disabled="mode=='show'"></uni-number-box>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="出车时间" required>
|
|
<uni-datetime-picker type="datetime" :clear-icon="false" v-model="form.start_time" @change="mdateChange"
|
|
v-if="mode!='show'"/>
|
|
<span v-else>{{form.start_time}}</span>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="归还公里数" required v-if="form.ticket_&&form.ticket_.state_">
|
|
<uni-number-box v-if="form.ticket_?.state_?.name=='用车中'" v-model="ticket_data.end_km" :disabled="mode=='show'"></uni-number-box>
|
|
<span v-else>{{form.ticket_.ticket_data.end_km}}</span>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="还车时间" required v-if="form.ticket_&&form.ticket_.state_">
|
|
<uni-datetime-picker type="datetime" v-if="form.ticket_?.state_?.name=='用车中'" :clear-icon="false" v-model="ticket_data.end_time" @change="mdateChange"/>
|
|
<span v-else>{{form.ticket_.ticket_data.end_time}}</span>
|
|
</uni-forms-item>
|
|
</uni-forms>
|
|
</scroll-view>
|
|
<view class="footer_fixed">
|
|
<ticketd_b :workflow_key="'wf_vehicle'" title="用车申请" :t_id="form.id" :ticket_="form.ticket_" :ticket_data="ticket_data"
|
|
@success="submitSuccess" :submit_b_func="submit_b_func" ref="ticketd_b_start"></ticketd_b>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import ticketd_b from "../wf/ticketd_b.vue"
|
|
import ticketd from "../wf/ticketd.vue"
|
|
import {actStateEnum} from "@/utils/enum.js"
|
|
export default {
|
|
components: { ticketd_b, ticketd },
|
|
data(){
|
|
return{
|
|
form:{
|
|
id:null,
|
|
via:"",
|
|
reason:"",
|
|
is_city:"",
|
|
location:"",
|
|
destination:"",
|
|
start_km:"",
|
|
start_time:"",
|
|
},
|
|
ticket_data:{
|
|
end_km:"",
|
|
end_time:"",
|
|
},
|
|
vehicle_list:[{text: '市内', value: true},{text: '市外', value: false}],
|
|
}
|
|
},
|
|
async onLoad(options) {
|
|
let that = this;
|
|
that.form.id='';
|
|
that.mode = options.mode?options.mode:'show';
|
|
that.t_id = options.t_id?options.t_id:null;
|
|
if(that.mode != "add"){
|
|
if(that.t_id) {
|
|
that.form = await that.$api.vehicleItem(that.t_id);
|
|
if(that.form.ticket_.state_.type == 1 && that.form.create_by == uni.getStorageSync("userInfo").id ) {
|
|
that.mode = "edit";
|
|
}else{
|
|
that.mode = "show";
|
|
}
|
|
}else{
|
|
}
|
|
}
|
|
},
|
|
methods:{
|
|
//选择会议室和日期后查询有无预定
|
|
async submit_b_func(id){
|
|
let that = this;
|
|
if (that.mode != 'show') {
|
|
if(that.form.id) {
|
|
await that.$api.vehicleUpdate(that.form.id, that.form);
|
|
}else{
|
|
let res = await that.$api.vehicleCreate(that.form);
|
|
that.form.id = res.id;
|
|
}
|
|
}
|
|
},
|
|
submitSuccess(){
|
|
uni.navigateTo({
|
|
url: "/pages/index/index"
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style> |