123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <template>
- <view class="page-container">
- <view class="page-head">
- <text>{{titleObj[model.form.scanType]}}</text>
- </view>
- <view class="page-body">
- <u--form label-width="auto" labelAlign="left"
- ref="uForm"
- :model="model"
- :rules="rules"
- :labelStyle="{
- fontSize: '28rpx',
- fontWeight: '500',
- }"
- >
- <u-cell-group :border="false">
-
- <template>
-
- <view class="box" style="margin: 24rpx 24rpx 0rpx 24rpx;">
- <u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
- <view slot="value" class="value">
- <u-form-item label="" labelPosition="" prop="form.remark" :required="false">
- <view slot="label" class="item-label">
- <view class="item-label-left">
- 驾驶员
- </view>
-
- </view>
- <view class="item-label-right">{{model.form.driverName}}</view>
- </u-form-item>
- </view>
- </u-cell>
-
- <u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
- <view slot="value" class="value">
- <u-form-item label="" labelPosition="" prop="form.remark" :required="false">
- <view slot="label" class="item-label">
- <view class="item-label-left">
- 车辆
- </view>
-
- </view>
- <view class="item-label-right">{{model.form.plate}}</view>
- </u-form-item>
- </view>
- </u-cell>
- </view>
-
- </template>
- </u-cell-group>
- </u--form>
- </view>
-
- <view class="page-footer">
- <u-row style="">
-
- <u-col :span="12">
- <u-button type="primary" shape="" :hairline="false" :custom-style="{
- width: '100%',
- borderRadius: '0',
- height: '100rpx',
- fontSize: '32rpx',
- fontWeight: '500',
- background:'linear-gradient(to right, #41B5FF, #4573FC)'
- }" @click="handleSubmit">确认
- </u-button>
- </u-col>
- </u-row>
-
- </view>
-
- </view>
- </template>
- <script>
- import {userProfile} from '@/api/common/user.js'
- import {checkHasOutRec,scanVehCode} from '@/api/vehDispatch/taskQrCode.js'
- import {clearProps,copyProps} from '@/utils/gdtq.js'
- import {isEmpty} from 'lodash'
- export default {
- components: {
- },
- data() {
- return {
- titleObj: {
- 1: '是否确认出车?',
- 2: '是否确认还车?',
- },
- model: {
- form: {
- recId: "", //出车记录ID (还车时,传该参数)
- scanType: "", //扫码类型 1出车 2还车
- vehicleId: "", //车辆ID (出车时,传该参数)
-
- driverName: '',
- plate: '',
- }
- },
- rules: {
-
- 'form.outflowType': [
- {
- type: 'string',
- required: true,
- message: '请选择',
- trigger: ['blur', 'change']
- },
- ],
- 'form.backDate': {
- type: 'string',
- required: true,
- message: '请选择',
- trigger: ['blur', 'change']
- },
- 'form.outList': {
- type: 'array',
- required: true,
- message: '请选择',
- trigger: ['blur', 'change']
- },
- },
-
- userInfo: null,
- params: null,
- copyItem: null,
- }
- },
- onLoad(params) {
- // console.log(id,'id')
- this.params = params
- setTimeout(() => {
- this.initData()
- },500)
-
- },
-
- async created() {
- // this.getUserInfo()
- },
-
- onShow() {
-
- },
- onHide() {
-
- },
- onReady() {
- // this.resetRules()
- },
- methods: {
- async initData() {
- let {vehicleId} = this.params
- let {code,data} = await checkHasOutRec({vehicleId})
- if(code == 0) {
- this.copyItem = data
- if(data.hasRec) {
- this.model.form.scanType = 2
- } else {
- this.model.form.scanType = 1
- }
- this.model.form.driverName = data.driverName
- this.model.form.vehicleId = data.vehicleId
- this.model.form.plate = data.plate
- this.model.form.recId = data.id
-
- }
- },
-
- resetRules() {
- this.$refs.uForm.setRules(this.rules)
- },
- async getInfo(id) {
- let {code,data} = await queryOneById({id})
- if(code == 0) {
- copyProps(this.model.form,data)
- }
- },
- getUserInfo() {
- userProfile().then((res) => {
- this.userInfo = res.data
- this.model.form.outflowUserId = res.data.userId
- this.model.form.outflowUser = res.data.nickName
-
- this.model.form.deptId = res.data.deptId
- this.model.form.deptName = res.data.deptName
- })
- },
- // 提交
- async handleSubmit() {
-
- let titleObj = {
- 1: '已出车',
- 2: '已还车',
- }
- this.$refs.uForm.validate().then(async res => {
-
-
- let ajaxData = {
- ...this.model.form,
- }
- let { data, code,msg } = await scanVehCode(ajaxData)
-
-
- if (code == 0) {
-
- uni.showModal({
- title: '提示',
- content: `${titleObj[ajaxData.scanType]}`,
- showCancel:false,
- confirmText: '好的',
- success: function(res) {
- if (res.confirm) {
- uni.switchTab({url: '/pages/index/index'})
- }
- }
- })
-
- }
-
- }).catch(errors => {
- console.log('校验失败',errors)
- })
- },
- handleClear() {
-
- clearProps(this.model.form,[])
- },
-
- }
- }
- </script>
- <style lang="scss" scoped>
- .disflex-center {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .disflex-right {
- display: flex;
- justify-content: right;
- align-items: center;
- }
- .page-container {
-
- font-size: 28rpx;
- min-height: 100%;
- position: relative;
- background: #fff;
- // padding-bottom: 60rpx;
-
- .page-head {
- text-align: center;
- font-size: 40rpx;
- font-weight: 700;
- padding: 40rpx 0;
- }
-
- .page-body {
- padding-bottom: 120rpx;
-
- .box {
- margin: 24rpx 24rpx 0;
- padding: 20rpx;
- border-radius: 20rpx;
- background: #fff;
- border: 1rpx solid #EBEDF0;
-
- .item-label {
- display: flex;
- justify-content: space-between;
- align-items: center;
- &-left {
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 32rpx;
- color: #999999;
-
- position: relative;
- text {
- color: #f56c6c;
- font-size: 40rpx;
- position: absolute;
- left: -18rpx;
- }
- }
- &-right {
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 32rpx;
- color: #333333;
- text-align: right;
- width: 100%;
- }
- }
- }
-
- }
- .page-footer {
- padding: 0rpx 0;
- position: fixed;
- width: 100%;
- left: 0;
- bottom: 0;
- }
- }
- ::v-deep {
-
- .u-form-item__body {
- padding: 0;
- }
- .hidde-cell-title {
-
- .u-cell__body__content {
- width: auto;
- flex: none;
-
- }
- .u-cell__body {
- .value {
- flex: 1;
- }
- }
-
- }
-
- }
- </style>
|