<template>
	<div class="app-container calendar-list-container" v-loading.body="showLoadingBody">
		<div class="filter-container" ref="filter-container">
			<el-form
				:model="listQuery"
				label-width="100px"
			>
        <el-row>
          <el-col :span="6">
            <el-form-item label="车牌号">
              <el-input v-model="listQuery.numberPlate" placeholder="请输入车牌号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属公司">
              <el-select class="filter-item" v-model="listQuery.companyId" placeholder="请选择所属公司" filterable>
                <el-option :key="undefined" label="全部" :value="undefined"></el-option>
                <el-option
                  v-for="(val,index) in allVehicleCompany "
                  :key="index"
                  :label="val.name"
                  :value="val.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属门店">
              <el-select class="filter-item" v-model="listQuery.subordinateBranch" placeholder="请选择所属门店" filterable>
                <el-option :key="undefined" label="全部" :value="undefined"></el-option>
                <el-option
                  v-for="(val,index) in allVehicleBranchCompany"
                  :key="index"
                  :label="val.name"
                  :value="val.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="停靠门店">
              <el-select class="filter-item" v-model="listQuery.parkBranchCompanyId" placeholder="请选择停靠门店" filterable>
                <el-option :key="undefined" label="全部" :value="undefined"></el-option>
                <el-option
                  v-for="(val,index) in allVehicleBranchCompany"
                  :key="index"
                  :label="val.name"
                  :value="val.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="车型">
              <el-select class="filter-item" v-model="listQuery.modelId" placeholder="请选择车型" filterable>
                <el-option :key="undefined" label="全部" :value="undefined"></el-option>
                <el-option
                  v-for="(val,index) in allVehicleList"
                  :key="index"
                  :label="val.name"
                  :value="val.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出行状态">
              <el-select class="filter-item" v-model="listQuery.status" placeholder="请选择出行状态" filterable>
                <el-option :key="undefined" label="全部" :value="undefined"></el-option>
                <el-option
                  v-for="(val,index) in getAllVehicleStatus()"
                  :key="index"
                  :label="val.val"
                  :value="val.code"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
<!--          <el-col :span="6">-->
<!--            <el-form-item label="上架状态">-->
<!--              <el-select class="filter-item" v-model="listQuery.status" placeholder="请选择上架状态">-->
<!--                <el-option :key="undefined" label="全部" :value="undefined"></el-option>-->
<!--                <el-option-->
<!--                  v-for="(val,index) in getAllVehicleStatus() "-->
<!--                  :key="index"-->
<!--                  :label="val.val"-->
<!--                  :value="val.code"-->
<!--                ></el-option>-->
<!--              </el-select>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
        </el-row>
			</el-form>
			<el-button
				class="filter-item"
				type="primary"
				v-waves
				icon="search"
				@click="handleFilter('search')"
			>搜索</el-button>
			<el-button class="filter-item" type="primary" v-waves @click="reloadPage">清除搜索</el-button>
      <el-button class="filter-item" v-if="elements['vehicleInfo:btn_add']" @click="handleCreate" plain><i class="el-icon-plus"></i>添加车辆</el-button>
		</div>
		<el-table :key="tableKey" :data="list" border fit highlight-current-row style="width: 100%" v-loading="listLoading">
			<el-table-column type="index" align="center" label="序号" width="65"></el-table-column>
      <el-table-column align="center" label="车牌号">
        <template slot-scope="scope">
          <span>{{scope.row.numberPlate}}</span>
        </template>
      </el-table-column>
			<el-table-column align="center" label="车辆编码">
				<template slot-scope="scope">
					<span>{{scope.row.code}}</span>
				</template>
			</el-table-column>
      <el-table-column align="center" label="车型">
        <template slot-scope="scope">
          <span>{{scope.row.vehicleType}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="所属门店">
        <template slot-scope="scope">
          <span>{{scope.row.subBranchName}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="停靠门店">
        <template slot-scope="scope">
          <span>{{scope.row.parkBranchCompanyName}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="所属公司">
        <template slot-scope="scope">
          <span>{{scope.row.companyName}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="出行状态">
        <template slot-scope="scope">
          <span>{{getVehicleStatus(scope.row.status)}}</span>
        </template>
      </el-table-column>
<!--			<el-table-column align="center" label="车辆状态">-->
<!--				<template slot-scope="scope">-->
<!--					<span>上下架</span>-->
<!--				</template>-->
<!--			</el-table-column>-->
			<el-table-column align="center" label="操作">
				<template slot-scope="scope">
					<el-button
						size="small"
						class="el-button el-button--text el-button--small"
						@click="handleUpdate(scope.row)"
					>{{elements['vehicleInfo:btn_edit'] ? "编辑" : "查看"}}</el-button>
<!--          <el-button-->
<!--            size="small"-->
<!--            class="el-button el-button&#45;&#45;text el-button&#45;&#45;small"-->
<!--            @click="handleUpdate(scope.row)"-->
<!--          >上架/下架</el-button>-->
					<el-button
						size="small"
						@click="deleteHandler(scope.row)"
						class="el-button el-button--text el-button--small"
						style="color:red;"
						v-if="elements['vehicleInfo:btn_ret']"
					>删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
      class="pagination-container"
			@size-change="handleSizeChange"
			@current-change="handleCurrentChange"
			:current-page.sync="listQuery.page"
			:page-sizes="[10,20,30, 50]"
			:page-size="listQuery.limit"
			layout="total, sizes, prev, pager, next, jumper"
			:total="total"
		></el-pagination>

    <!--  添加、编辑车辆  -->
    <one-vehicle v-on:oneDialogEvent="oneDialogEvent" :title="title" :oneRow="oneRow" v-if="oneDialogVisible"></one-vehicle>
	</div>
</template>

<script type="javascript">
import upkeepDialog from '../../modal/upkeepDialogVisible' // 保养弹框
import departureDialog from '../../modal/departureDialog' // 出车弹框
import 'static/css/uploadImg.css' // 引入图片上传组件对话框
import {
	page,
	addObj,
	book,
	putObj,
	delObj,
	downloadExcel,
	exportExcel,
  vehicleBranchCompanyAll,
  vehicleCompanyAll
} from '../../../api/vehicle/vehicleInfo/'

import {
	getAllVehicleList
} from '../../../api/vehicleType'

import { getSonRegionByCodes } from 'api/base_info/region/'
import {
	newEast8Date,
	convertDate2Str
} from 'utils/dateUtils'

import rsCode from '../../../utils/rsCode'

import { mapGetters } from 'vuex'

import bookInfoViewer from '../bookInfoViewer'
import accItemSelector from '../accompanyingItem/accItemSelector.vue'
import Element1 from '../../admin/menu/components/element'
import ElRow from 'element-ui/packages/row/src/row'
import ElCol from 'element-ui/packages/col/src/col'
import ElFormItem from '../../../../node_modules/element-ui/packages/form/src/form-item.vue'

import oneVehicle from "./oneVehicle";

export default {
	name: 'vehicleInfo',
	components: {
		ElFormItem,
		ElCol,
		ElRow,
		Element1,
		bookInfoViewer,
		accItemSelector,
		upkeepDialog,
		departureDialog,
    oneVehicle
	},
	data() {
		return {
      oneDialogVisible: false, // 添加、编辑车辆弹框
      title: '添加车辆',
      oneRow: {}, // 当前操作项
      allVehicleBranchCompany: [],// 所属门店列表
      allVehicleCompany: [], // 所属公司列表

			state1: '',
			vehicleArr: '',
			BASE_API: process.env.BASE_API,
			dialogForm4LicenceVisible: false,
			licenceSrcUrl: undefined,
			showLoadingBody: false,
			allVehicleList: [], //全部车型

			form: {
				insuranceEndDate: null, //商业险日期
				vehicleModelName: '', //车型
				subordinateBranchName: '', // 所属门店
				subordinateBranch: undefined, // 所属门店id
				parkBranchCompanyName: '', // 停靠门店
				parkBranchCompanyId: undefined, // 停靠门店id
				modelId: undefined, //车型id
				status: undefined, //车辆状态
				code: undefined, //车辆编码
				numberPlate: undefined, //车牌
				mileageLastUpdate: undefined, //公里数
				remark: undefined, // 备注
        vehicleInnerStatus: 1, // 内饰：1、全新，2、9成新，3、8成新，4、7成新
        vehicleStatus: 1, // 车辆状况：1、全新，2、9成新，3、8成新，4、7成新
        vehicleBodyStatus: 1// 车身状况：1、无剐蹭，2、微瑕疵，3、无瑕疵
			},
			form4Apply: {
				bookStartDate: undefined,
				bookEndDate: undefined,
				vehicle: undefined,
				liftAddr: undefined,
				state3: '',
				retCompany: undefined,
				state4: '',
				liftCompany: undefined,
				destination: undefined,
				selectedAccItem: undefined,
				remark: undefined,
				vehicleId: undefined,
				bookType: undefined,
				vehicleUsername: undefined,
				vehicleUserPhone: undefined,
				upkeepIds: []
			},
			pickerOptions4Apply: {
				disabledDate: this.checkBookDate
			},
			selectArry: [],
			selectVehicleModelArray: [],
			list: [],
			total: null,
			listLoading: true,
			listQuery: {
				page: 1,
				limit: 10,
        subordinateBranch: undefined, // 所属门店
        companyName: undefined, // 所属公司
        parkBranchCompanyId: undefined, // 停靠门店
        modelId: undefined, // 车型
			},
			showMoreQueryFilter: false,
			showMoreMoreCol: false,
			inline: true,
			dialogFormVisible: false,
			dialogForm4ApplyVisible: false,
			curBookedInfo3Month: undefined,
			curBookedInfo: undefined,
			dialogStatus: '',
			allCompanies: {},
			allCompaniesArr: [],
			textMap: {
				update: '编辑',
				create: '创建',
				apply: '预定申请'
			},
			tableKey: 0,
			departureDialogVisible: false, //出车弹框
			departureForm: {
				vehicleId: null,
				numberPlate: null,
				departureDate: null,
				departureBranchCompanyId: null,
				departureBranchCompanyName: '',
				use: null,
				user: null,
				userTel: null,
				checkMan: null,
				checkManTel: null,
				expectArrivalBranchCompanyId: null,
				expectArrivalBranchCompanyName: '',
				mileage: null
			},
			arrivalDialogVisible: false,
			arrivalForm: {
				vehicleId: null,
				numberPlate: null,
				arrivalDate: null,
				recycleMan: null,
				recycleManTel: null,
				mileage: null,
				arrivalBranchCompanyId: null,
				arrivalBranchCompanyName: ''
			},
			upkeepDialogVisible: false,
			allZoneArr: [], //全部片区
			provinceRegions: [], //片区下省份数据
			cityList: [],

		}
	},
	created() {
    this.getVehicleBranchCompanyAll() // 获取  所属门店 所有门店筛选列表
    this.getVehicleCompanyAll() // 获取 所属公司 所有公司筛选条件
		let t = this
    t.getList() // 获取车辆列表
    t.getAllVehicleType() //获取全部车型
	},
	computed: {
		...mapGetters(['elements', 'belong2Type', 'vehicleStatus']),
	},
	methods: {
	  /**
     * 获取所有门店-筛选列表
     */
    getVehicleBranchCompanyAll(){
      vehicleBranchCompanyAll({state: 1}).then(response => {
        if(response.status == 200){
          this.allVehicleBranchCompany = response.data
        } else {
          this.$notify({
            title: '失败',
            message: response.message,
            type: 'error',
            duration: 2000
          })
        }
      })
    },
    /**
     * 获取所属公司  所有公司--筛选条件
     */
    getVehicleCompanyAll(){
      vehicleCompanyAll({state: 1}).then(response => {
        if(response.status == 200){
          this.allVehicleCompany = response.data
        } else {
          this.$notify({
            title: '失败',
            message: response.message,
            type: 'error',
            duration: 2000
          })
        }
      })
    },
    /**
     * 新建、编辑车辆信息  刷新页面
     * */
    oneDialogEvent(e) {
      this.oneDialogVisible = false;
      if (e) {
        this.getList();
      }
    },
		handlerChange(e) {
			console.log(e)
		},
		handleInput(e){
				this.form.strongInsuranceNo=e.target.value.replace(/[^\d]/g,'');
		},
		cityRegions4Query() {
			let that = this
			if (!this.$utils.isInteger(this.listQuery.addrProvince)) {
				return that.getAllCities()
			}
			that.cityList = getSonRegionByCodes(this.listQuery.addrProvince)
			return that.cityList
		},
		getAllCities() {
			var cityStr = []
			var provinceIds = this.provinceRegions
			for (var index in provinceIds) {
				var sysregion = getSonRegionByCodes(provinceIds[index].id)
				for (var i in sysregion) {
					cityStr.push(sysregion[i])
				}
			}
			this.cityList = cityStr
			return cityStr
		},

		getValue(e) {
			this.listQuery.addrCity = undefined
		},
		/**
		 * 获取全部车型
		 * */
		getAllVehicleType() {
			let t = this
			getAllVehicleList().then(response => {
				let listRs = undefined
				if (!this.$utils.isEmpty(response.data)) {
					listRs = response.data
				}
				this.allVehicleList = listRs
			})
		},
		/**
		 * 重置
		 * */
		reloadPage() {
			this.listQuery = {
        page: 1,
        limit: 20,
        subordinateBranch: undefined, // 所属门店
        companyName: undefined, // 所属公司
        parkBranchCompanyId: undefined, // 停靠门店
        modelId: undefined, // 车型
			}
			this.getList()
		},
		exportExcelInfo() {
			exportExcel().then(res => {
				const content = res
				const blob = new Blob([content])
				const fileName = 'vehicle.xlsx'
				if ('download' in document.createElement('a')) {
					// 非IE下载
					const elink = document.createElement('a')
					elink.download = fileName
					elink.style.display = 'none'
					elink.href = URL.createObjectURL(blob)
					document.body.appendChild(elink)
					elink.click()
					URL.revokeObjectURL(elink.href) // 释放URL 对象
					document.body.removeChild(elink)
				} else {
					// IE10+下载
					navigator.msSaveBlob(blob, fileName)
				}
			})
		},
		/**
		 *  下载车辆信息excel表
		 * */
		download() {
			this.listLoading = true
			let listQueryTemp = this.fillDateRange2Object(
				this.listQuery,
				'mRange',
				'mRangeDateStart',
				'mRangeDateEnd'
			)
			listQueryTemp = this.fillDateRange2Object(
				listQueryTemp,
				'aVRange',
				'aVRangeDateStart',
				'aVRangeDateEnd'
			)
			listQueryTemp = this.fillDateRange2Object(
				listQueryTemp,
				'insuranceDateRange',
				'insuranceDateRangeStart',
				'insuranceDateRangeEnd'
			)
			if (!this.state1) {
				listQueryTemp.subordinateBranch = undefined
			}
			if (!this.vehicleArr) {
				listQueryTemp.modelId = undefined
			}
			downloadExcel(listQueryTemp).then(res => {
				const content = res
				const blob = new Blob([content])
				const fileName = '车辆信息.xlsx'
				if ('download' in document.createElement('a')) {
					// 非IE下载
					const elink = document.createElement('a')
					elink.download = fileName
					elink.style.display = 'none'
					elink.href = URL.createObjectURL(blob)
					document.body.appendChild(elink)
					elink.click()
					URL.revokeObjectURL(elink.href) // 释放URL 对象
					document.body.removeChild(elink)
				} else {
					// IE10+下载
					navigator.msSaveBlob(blob, fileName)
				}
			})
		},
		/**
		 * 出车modal传递回来的数据
		 * */
		departureDialogEvent(e) {
			if (e) {
				this.getList()
			}
			this.departureDialogVisible = false
		},
		/**
		 * 保养modal传递回来的数据
		 * */
		upkeepDialogEvent(e) {
			if (e) {
				this.getList()
			}
			this.upkeepDialogVisible = false
		},
		/**
		 * 城市模糊查询
		 * */
		querySearchCityName(queryString, cb) {
			let selectArry = []
			let iitem = {
				value: '全部',
				name: '全部'
			}
			selectArry.push(iitem)
			this.cityArr.map(function(item) {
				item.value = item.name
				selectArry.push(item)
			})
			this.selectArry = selectArry
			var results = queryString
				? selectArry.filter(this.createFilter(queryString))
				: selectArry
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		/**
		 * 省份模糊查询
		 * */
		querySearchProvinceName(queryString, cb) {
			let selectArry = []
			let iitem = {
				value: '全部',
				name: '全部'
			}
			selectArry.push(iitem)
			this.provinceArr.map(function(item) {
				item.value = item.name
				selectArry.push(item)
			})
			this.selectArry = selectArry
			var results = queryString
				? selectArry.filter(this.createFilter(queryString))
				: selectArry
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		/**
		 * 分公司模糊查询
		 * */
		querySearch(queryString, cb) {
			let selectArry = []
			let iitem = {
				value: '全部',
				name: '全部'
			}
			selectArry.push(iitem)
			this.allCompaniesArr.map(function(item) {
				item.value = item.name
				selectArry.push(item)
			})
			this.selectArry = selectArry
			var results = queryString
				? selectArry.filter(this.createFilter(queryString))
				: selectArry
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		queryVehicleModelSearch(queryString, cb) {
			let selectArry = []
			//   let iitem = {
			//   value: "全部",
			//   name: "全部"
			// };
			//   selectArry.push(iitem);
			this.allVehicleList.map(function(item) {
				item.value = item.name
				selectArry.push(item)
			})
			this.selectVehicleModelArray = selectArry
			var results = queryString
				? selectArry.filter(this.createFilter(queryString))
				: selectArry
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		createFilter(queryString) {
			return restaurant => {
				return restaurant.name.indexOf(queryString.toLowerCase()) != -1
			}
		},
		/**
		 * 还车分公司
		 */
		handleSelectArrivalCompanyName(item) {
			if (item.value == '全部') {
				this.arrivalForm.arrivalBranchCompanyId = undefined
			} else {
				this.arrivalForm.arrivalBranchCompanyId = item.id
			}
			console.log(item)
		},
		handleSelectDepartureForm(item) {
			if (item.value == '全部') {
				this.departureForm.departureBranchCompanyId = undefined
			} else {
				this.departureForm.departureBranchCompanyId = item.id
			}
			console.log(item)
		},
		handleSelectEexpectArrivalCompanyName(item) {
			if (item.value == '全部') {
				this.departureForm.expectArrivalBranchCompanyId = undefined
			} else {
				this.departureForm.expectArrivalBranchCompanyId = item.id
			}
			console.log(item)
		},
    getVehicleStatus: function(code) {
      // console.log(this.getAllVehicleStatus()[1].val);
      // let demo = this.getAllVehicleStatus.filter(item => item)
      // console.log(this.vehicleStatus[code]);

      return this.getAllVehicleStatus()[code].val
    },
    /**
     * 出行状态
     */
		getAllVehicleStatus: function() {
			return {
				1: {
					code: 1,
					val: '正常运行'
				},
				3: {
					code: 3,
					val: '报废'
				},
				4: {
					code: 4,
					val: '出车'
				},
				6: {
					code: 6,
					val: '维修中'
				},
				7: {
					code: 7,
					val: '保养中'
				},
				8: {
					code: 8,
					val: '上牌中'
				}
			}
		},
		/**
     * 获取车辆列表
     */
		getList() {
			this.listLoading = true
			page(this.listQuery).then(response => {
        this.listLoading = false
				if (response.code == 1) {
					this.list = response.data.data
					this.total = response.data.totalCount
				} else {
					this.list = []
					this.listLoading = false
          this.$notify({
            title: '失败',
            message: response.message,
            type: 'error',
            duration: 2000
          })
				}
			})
		},
    /**
     * 搜索
     */
		handleFilter(p) {
			let t = this
			this.listQuery.page = 1
      this.getList()
		},
		handleSizeChange(val) {
			this.listQuery.limit = val
			this.getList()
		},
		handleCurrentChange(val) {
			this.listQuery.page = val
			this.getList()
		},
    /**
     * 添加车辆
     */
		handleCreate() {
      this.title = '添加车辆'
			this.oneDialogVisible = true
		},
    /**
     * 编辑车辆
     */
		handleUpdate(row) {
      this.title = '编辑车辆'
      this.oneRow = row
      this.oneDialogVisible = true
		},
		create(formName) {
			const set = this.$refs
			set[formName].validate(valid => {
				if (valid) {
					let formTemp = this.fillDateRange2Object(
						this.form,
						'insuranceDateRange4form',
						'insuranceStartDate',
						'insuranceEndDate'
					)
					convertDate2Str(formTemp)
					addObj(formTemp).then(response => {
						if (response.code === rsCode.RS_CODE_SUC) {
							this.dialogFormVisible = false
							this.getList()
							this.$notify({
								title: '成功',
								message: '创建成功',
								type: 'success',
								duration: 2000
							})
							this.getList()
						} else {
							this.$notify({
								title: '失败',
								message: rsCode.msg[response.code]
									? rsCode.msg[response.code]
									: '操作失败！',
								type: 'error',
								duration: 2000
							})
						}
					})
				} else {
					this.$message('必填项不能为空')
					return false
				}
			})
		},
		cancel(formName) {
			this.dialogFormVisible = false
			this.dialogForm4ApplyVisible = false
			this.$refs[formName].resetFields()
			// this.listQuery.code = ''
		},
		closePop(formName) {
			this.$refs.form.resetFields()
		},
		cancel4Apply(formName) {
			this.dialogForm4ApplyVisible = false
			this.$refs[formName].resetFields()
		},
		update(formName) {
			const set = this.$refs
			set[formName].validate(valid => {
				if (valid) {
					this.form.insurancePDF = JSON.stringify(this.pdfList)
					let formTemp = this.fillDateRange2Object(
						this.form,
						'insuranceDateRange4form',
						'insuranceStartDate',
						'insuranceEndDate'
					)
					convertDate2Str(formTemp)
					putObj(formTemp).then(response => {
						if (response.code === rsCode.RS_CODE_SUC) {
							this.dialogFormVisible = false
							this.getList()
							this.$notify({
								title: '成功',
								message: '更新成功',
								type: 'success',
								duration: 2000
							})
							this.getList()
						} else {
							this.$notify({
								title: '失败',
								message: rsCode.msg[response.code]
									? rsCode.msg[response.code]
									: '操作失败！',
								type: 'error',
								duration: 2000
							})
						}
					})
				} else {
					return false
				}
			})
		},
		/**
		 * 申请预定-确定
		 * @param formName
		 */
		apply(formName) {
			if (!this.form4Apply.state3 || this.form4Apply.state3 == '全部') {
				this.form4Apply.liftCompany = undefined
				this.$notify({
					title: '失败',
					message: '请选择提车分公司',
					type: 'warning',
					duration: 2000
				})
				return
			}
			if (!this.form4Apply.state4 || this.form4Apply.state4 == '全部') {
				this.form4Apply.retCompany = undefined
				this.$notify({
					title: '失败',
					message: '请选择还车分公司',
					type: 'warning',
					duration: 2000
				})
				return
			}
			const set = this.$refs
			set[formName].validate(valid => {
				if (valid) {
					if (this.form4Apply.bookType == 6) {
						if (this.form4Apply.upkeepIds.length == 0) {
							this.$notify({
								title: '警告',
								message: '请选择保养项目',
								type: 'warning',
								duration: 2000
							})
							return false
						}
					}
					this.form4Apply.upkeepIds =
						this.form4Apply.bookType == 6
							? this.form4Apply.upkeepIds.join(',')
							: ''
					this.dialogFormVisible = false
					book(this.form4Apply).then(res => {
						if (res.status == 200) {
							this.dialogForm4ApplyVisible = false
							this.getList()
							this.$notify({
								title: '成功',
								message: '预定成功',
								type: 'success',
								duration: 2000
							})
						} else {
							this.$notify({
								title: '失败',
								message: res.message,
								type: 'error',
								duration: 2000
							})
						}
					})
				} else {
					return false
				}
			})
		},
		/**
		 * 删除
		 * */
		deleteHandler(row) {
			this.$confirm('确定删除吗?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				delObj(row.id).then(response => {
					if (response.status === 200) {
						this.$notify({
							title: '成功',
							message: '删除成功',
							type: 'success',
							duration: 2000
						})
						this.bannerDialogVisible = false
						this.getList()
					} else {
						this.$notify({
							title: '删除失败',
							message: rsCode.msg[response.code]
								? rsCode.msg[response.code]
								: '操作失败！',
							type: 'error',
							duration: 2000
						})
					}
				})
			})
		},
		resetTemp() {
			this.form = {
				status: undefined,
				code: undefined,
				parkBranchCompanyName: '', //停靠分公司名称
				parkBranchCompanyId: undefined, //停靠分公司id
				modelId: undefined, //车型id
				numberPlate: undefined,
				brand: undefined,
				subordinateBranchName: '',
				vehicleModelName: '',
				subordinateBranch: undefined,
				useType: undefined,
				vin: undefined,
				insuranceNo: undefined,
				insuranceCompany: undefined,
				insuranceDateRange4form: undefined,
				annualVerificationDate: undefined,
				maintenanceDate: undefined,
				maintenanceMileage: undefined,
				belongTo: undefined,
				belongToName: undefined,
				engineNum: undefined,
				manufacturer: undefined,
				mileageLastUpdate: undefined,
				//          receiveTime: undefined,
				drivingLicensePath: undefined,
				drivingLicenseDuplicatePath: undefined,
				remark: undefined,
				memberUse: undefined,
				strongInsuranceEndDate: undefined,
				strongInsuranceNo: undefined,
				strongInsuranceCompany: undefined,
				insuranceEndDate: null,
        vehicleInnerStatus: 1, // 内饰：1、全新，2、9成新，3、8成新，4、7成新
        vehicleStatus: 1, // 车辆状况：1、全新，2、9成新，3、8成新，4、7成新
        vehicleBodyStatus: 1// 车身状况：1、无剐蹭，2、微瑕疵，3、无瑕疵
			}
		},
		resetTemp4Apply() {
			this.form4Apply = {
				bookStartDate: undefined,
				bookEndDate: undefined,
				state3: '',
				state4: '',
				retCompany: undefined,
				vehicle: undefined,
				selectedAccItem: undefined,
				liftCompany: undefined,
				liftAddr: undefined,
				destination: undefined,
				remark: undefined,
				vehicleId: undefined,
				bookType: undefined,
				vehicleUsername: undefined,
				vehicleUserPhone: undefined,
				upkeepIds: []
			}
		},
		resetTemp4BookInfo() {
			this.form4BookInfo = {
				selectedMonth: this.$utils.toDateString(
					newEast8Date(),
					'yyyy-MM'
				),
				vehicle: undefined
			}
		}
	}
}
</script>
<style>
.driving-title {
	position: absolute;
	top: 34px;
	left: 140px;
	font-size: 14px;
}
</style>
