<template>
  <div class="app-container">
    <el-form label-width="100px">
      <el-row>
        <el-col :span="4">
          <el-form-item label="车牌号">
            <el-input v-model="searchFrom.LICENCE_NO" placeholder="请输入车牌号..." />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="车辆类型" prop="VEHICLE_TYPE">
            <SelectTree
              ref="selectTree_Search1"
              :clearable="false"
              :options="vehicleTypeList"
              :props="vehicleDefaultProps"
              v-model="searchFrom.VEHICLE_TYPE"
              placeholder="请选择车辆类型"/>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="车辆所属部门" prop="VEHICLE_DEPARTMENT_ID">
            <SelectTree
              ref="selectTree_Search2"
              :clearable="false"
              :options="departmentTreeData"
              :props="defaultProps"
              v-model="searchFrom.VEHICLE_DEPARTMENT_ID"
              placeholder="请选择车辆所属部门"/>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="车辆责任人">
            <el-input v-model="searchFrom.USER_NAME" placeholder="请输入车辆责任人..." />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="审核状态" prop="IS_AUDIT">
            <SelectTree
              ref="selectTree_Search3"
              :clearable="false"
              :options="auditTypeList"
              :props="vehicleDefaultProps"
              v-model="searchFrom.IS_AUDIT"
              placeholder="请选择车辆所属部门"/>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label-width="10px">
            <el-button v-waves type="primary" icon="el-icon-search" @click="getQuery">
              搜索
            </el-button>
            <el-button v-waves type="success" icon="el-icon-refresh" @click="goKeyReset">
              重置
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      v-loading="listLoading"
      ref="vehicleMessageTable"
      :data="varList"
      :row-key="getRowKey"
      :header-cell-style="{
        'font-weight': 'bold',
        'color': '#000'
      }"
      tooltip-effect="dark"
      border
      fit
      highlight-current-row
    >
      <el-table-column
        :reserve-selection="true"
        type="selection"
        width="55"
        align="center"/>
      <el-table-column type="index" label="序号" width="50" align="center" />
      <el-table-column prop="LICENCE_NO" label="车牌号" align="center" />
      <el-table-column label="车牌类型" align="center">
        <template slot-scope="{row}">
          {{ translateLicenceType(row.LICENCE_TYPE) }}
        </template>
      </el-table-column>
      <el-table-column label="车辆类型" align="center">
        <template slot-scope="{row}">
          {{ translateVehicleType(row.VEHICLE_TYPE) }}
        </template>
      </el-table-column>
      <el-table-column prop="DEPT_NAME" label="车辆所属部门" align="center" />
      <el-table-column prop="U_NAME" label="车辆责任人" align="center"/>
      <el-table-column prop="VISIT_START_TIME" label="访问起始时间" align="center"/>
      <el-table-column prop="VISIT_END_TIME" label="访问结束时间" align="center"/>
      <el-table-column label="审核状态" align="center">
        <template slot-scope="{row}">
          {{ getAuditType(row.IS_AUDIT) }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="400">
        <template slot-scope="{row}">
          <el-button v-if="row.IS_AUDIT === '3'" type="success" icon="el-icon-edit" size="mini" @click="remark(row)">查看原因</el-button>
          <el-button v-if="row.IS_AUDIT === '3'" type="primary" icon="el-icon-edit" size="mini" @click="apply(row)">重新申请</el-button>
          <el-button v-if="row.IS_AUDIT !== '3'" type="warning" size="mini" @click="vehicleInOutRecordBtn(row.LICENCE_NO)">车辆进出记录</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="page-btn-group">
      <div>
        <el-button type="primary" icon="el-icon-plus" @click="openAddDialogAddBtn">新增</el-button>
      </div>
      <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getPageList" />
    </div>
    <el-dialog :visible.sync="addDialogVisible" title="添加车辆信息" width="600px">
      <el-form v-if="addDialogVisible" ref="addForm" :model="addForm" :rules="rules" label-width="170px" style="padding:0 20px; width: 500px;">
        <el-form-item label="车牌号" prop="LICENCE_NO">
          <el-input v-model="addForm.LICENCE_NO" type="text" maxlength="300" placeholder="这里输入车牌号..." @blur="goCheckLicenceNoAdd()"/>
        </el-form-item>
        <el-form-item label="车牌类型" prop="LICENCE_TYPE">
          <SelectTree
            ref="selectTree_add2"
            :clearable="false"
            :options="licenceTypeList"
            :props="vehicleDefaultProps"
            v-model="addForm.LICENCE_TYPE"
            placeholder="请选择车牌类型"
            style="width: 300px"/>
        </el-form-item>
        <el-form-item label="车辆类型" prop="VEHICLE_TYPE">
          <SelectTree
            ref="selectTree_add3"
            :clearable="false"
            :options="vehicleTypeList"
            :props="vehicleDefaultProps"
            v-model="addForm.VEHICLE_TYPE"
            placeholder="请选择车辆类型"
            style="width: 300px"/>
        </el-form-item>
        <el-form-item label="车辆所属部门" prop="DEPARTMENT_ID">
          <SelectTree
            ref="selectTree_add1"
            :clearable="false"
            :options="departmentTreeData"
            :props="defaultProps"
            v-model="addForm.DEPARTMENT_ID"
            placeholder="请选择车辆所属部门"
            style="width: 300px"
            @change="handleCorpChange"/>
        </el-form-item>
        <el-form-item label="负责人" prop="USER_ID">
          <el-select
            v-model="addForm.USER_ID"
            placeholder="请选择负责人">
            <el-option
              v-for="user in personList"
              :key="user.USER_ID"
              :label="user.NAME"
              :value="user.USER_ID">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="访问起始时间" prop="VISIT_START_TIME">
          <el-date-picker
            v-model="addForm.VISIT_START_TIME"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="访问结束时间" prop="VISIT_END_TIME">
          <el-date-picker
            v-model="addForm.VISIT_END_TIME"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="addDialogCancelBtn">取 消</el-button>
        <el-button type="primary" @click="addDialogConfirmBtn">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="驳回原因"
      :visible.sync="remarkDialogVisible"
      width="30%"
      :before-close="handleRemarkClose">
      <el-form>
        <el-form-item label="驳回原因">
          <el-input
            v-model="remarkText"
            type="textarea"
            :rows="4"
            readonly>
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="remarkDialogVisible = false">关闭</el-button>
  </span>
    </el-dialog>

    <el-dialog :visible.sync="reapplyDialogVisible" title="重新申请" width="600px">
      <el-form v-if="reapplyDialogVisible" ref="reapplyForm" :model="reapplyForm" :rules="rules" label-width="170px" style="padding:0 20px; width: 500px;">
        <el-form-item label="车牌号" prop="LICENCE_NO">
          <el-input v-model="reapplyForm.LICENCE_NO" type="text" maxlength="300" placeholder="这里输入车牌号..." readonly/>
        </el-form-item>
        <el-form-item label="车牌类型" prop="LICENCE_TYPE">
          <SelectTree
            ref="selectTree_reapply2"
            :clearable="false"
            :options="licenceTypeList"
            :props="vehicleDefaultProps"
            v-model="reapplyForm.LICENCE_TYPE"
            placeholder="请选择车牌类型"
            style="width: 300px"/>
        </el-form-item>
        <el-form-item label="车辆类型" prop="VEHICLE_TYPE">
          <SelectTree
            ref="selectTree_reapply3"
            :clearable="false"
            :options="vehicleTypeList"
            :props="vehicleDefaultProps"
            v-model="reapplyForm.VEHICLE_TYPE"
            placeholder="请选择车辆类型"
            style="width: 300px"/>
        </el-form-item>
        <el-form-item label="车辆所属部门" prop="DEPT_NAME">
          <SelectTree
            ref="selectTree_reapply1"
            :clearable="false"
            :options="departmentTreeData"
            :props="defaultProps"
            v-model="reapplyForm.DEPARTMENT_ID"
            placeholder="请选择车辆所属部门"
            style="width: 300px"
            @change="handleCorpChange"/>
        </el-form-item>
        <el-form-item label="负责人" prop="U_NAME">
          <el-select
            v-model="reapplyForm.USER_ID"
            placeholder="请选择负责人">
            <el-option
              v-for="user in personList"
              :key="user.USER_ID"
              :label="user.NAME"
              :value="user.USER_ID">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="访问起始时间" prop="VISIT_START_TIME">
          <el-date-picker
            v-model="reapplyForm.VISIT_START_TIME"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="访问结束时间" prop="VISIT_END_TIME">
          <el-date-picker
            v-model="reapplyForm.VISIT_END_TIME"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="reapplyDialogCancelBtn">取 消</el-button>
        <el-button type="primary" @click="reapplyDialogConfirmBtn">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves' // waves directive
import SelectTree from '@/components/SelectTree'
import {log} from "nightwatch/lib/util/logger";
export default {
  components: { Pagination, SelectTree },
  directives: { waves },
  data() {
    return {
      rules: {
        LICENCE_NO: [
          { required: true, message: '车牌号不能为空', trigger: 'blur' }
        ],
        LICENCE_TYPE: [
          { required: true, message: '车牌类型不能为空', trigger: 'change' }
        ],
        VEHICLE_TYPE: [
          { required: true, message: '车辆类型不能为空', trigger: 'change' }
        ],
        DEPARTMENT_ID: [
          { required: true, message: '车辆所属部门不能为空', trigger: 'change' }
        ],
        USER_ID: [
          { required: true, message: '负责人不能为空', trigger: 'change' }
        ],
        VISIT_START_TIME: [
          { required: true, message: '访问起始时间不能为空', trigger: 'change' }
        ],
        VISIT_END_TIME: [
          { required: true, message: '访问结束时间不能为空', trigger: 'change' }
        ]
      },
      remarkDialogVisible: false,
      remarkText: '',
      ISCHECK: false,
      userInfo: JSON.parse(sessionStorage.getItem('user')),
      listLoading: true,
      add: false,
      del: false,
      edit: false,
      loginUserInfo: {},
      roleName: '', // 角色名称
      loginUserId: '',
      loginUserName: '',
      loginDepartmentId: '',
      loginDepartmentName: '',
      corpInfoId: '', // 获取当前登陆用户的企业id
      listQuery: {
        page: 1,
        limit: 20
      },
      defaultProps: {
        value: 'id',
        children: 'nodes',
        label: 'name'
      },
      total: 0,
      KEYWORDS: '',
      // 车牌类型列表
      auditTypeList: [
        { ID: '1', NAME: '待审核' },
        { ID: '2', NAME: '已审核' },
        { ID: '3', NAME: '审核驳回' }
      ],
      licenceTypeList: [
        // { ID: '', NAME: '请选择' },
        { ID: '0', NAME: '白牌' },
        { ID: '1', NAME: '蓝牌' },
        { ID: '2', NAME: '黄牌' },
        { ID: '3', NAME: '绿牌' },
        { ID: '4', NAME: '黑牌' }
      ],
      // 车辆类型列表
      vehicleTypeList: [
        // { ID: '', NAME: '请选择' },
        { ID: '0', NAME: '货车' },
        { ID: '1', NAME: '轿车' },
        { ID: '2', NAME: '大巴客车' }
      ],
      // 车辆所属类型列表
      vehicleBelongTypeList: [
        // { ID: '', NAME: '请选择' },
        { ID: '0', NAME: '员工车辆' },
        { ID: '1', NAME: '单位车辆' }
        // { ID: '2', NAME: '外部车辆' }
      ],
      // 车辆下拉树默认属性
      vehicleDefaultProps: {
        value: 'ID',
        label: 'NAME',
        children: 'nodes'
      },
      departmentTreeData: [],
      personList: [],
      // inspectionTypeList: [], //字典列表
      // 列表展示的数据
      varList: [],
      // 查询表单的数据
      searchFrom: {
        USER_NAME: '',
        IS_AUDIT: '',
        VEHICLE_ID: '', // 车辆ID(基础属性)
        LICENCE_NO: '', // 车牌号
        VEHICLE_TYPE: '', // 车辆类型
        VEHICLE_DEPARTMENT_ID: '' // 车辆所属部门ID
      },
      // 添加表单的数据
      addForm: {
        LICENCE_NO: '', // 车牌号
        CORPINFO_ID: '',
        USER_ID: '', // 车辆责任人
        LICENCE_TYPE: '', // 车牌类型
        VEHICLE_TYPE: '', // 车辆类型
        VEHICLE_BELONG_TYPE: '', // 车辆所属类型
        EMPLOYEE_VEHICLE_USER_ID: '', // 车辆所属人id
        EMPLOYEE_VEHICLE_USER_NAME: '', // 车辆所属人姓名
        DEPARTMENT_NAME: '', // 部门名称
        DEPARTMENT_ID: '',
        USER_NAME: '', // 车辆责任人姓名
        VISIT_START_TIME: '',
        VISIT_END_TIME: ''
      },
      // 修改表单的数据
      editForm: {
        VEHICLE_ID: '', // 车辆id(基础属性)
        LICENCE_NO: '', // 车牌号
        OLD_LICENCE_NO: '', // 修改前的车牌号
        USER_ID: '', // 车辆责任人
        USER_NAME: '', // 车辆责任人姓名
        LICENCE_TYPE: '', // 车牌类型
        VEHICLE_TYPE: '', // 车辆类型
        VEHICLE_BELONG_TYPE: '', // 车辆所属类型
        DEPARTMENT_NAME: '', // 车辆所属部门名称
        EMPLOYEE_VEHICLE_USER_ID: '', // 车辆所属人
        EMPLOYEE_VEHICLE_USER_NAME: '', // 车辆所属人姓名
        VEHICLE_DEPARTMENT_ID: '', // 车辆所属部门
        VEHICLE_DEPARTMENT_NAME: '' // 车辆所属部门名称
      },
      // 详情表单的数据
      detailForm: {
        LICENCE_NO: '', // 车牌号
        VEHICLE_DEPARTMENT_ID: '', // 车辆所属部门
        VEHICLE_BELONG_TYPE: '', // 车辆所属类型
        USER_ID: '', // 车辆责任人
        EMPLOYEE_VEHICLE_USER_ID: '', // 车辆所属人
        LICENCE_TYPE: null, // 车牌类型
        VEHICLE_TYPE: null // 车辆类型
      },
      reapplyDialogVisible: false, // 控制重新申请对话框的显示
      reapplyForm: { // 重新申请表单数据
        LICENCE_NO: '',
        LICENCE_TYPE: '',
        VEHICLE_TYPE: '',
        DEPARTMENT_ID: '',
        USER_ID: '',
        VISIT_START_TIME: '',
        VISIT_END_TIME: '',
        DEPT_NAME: '',
        U_NAME: ''
      },
      addDialogVisible: false, // 添加弹窗的展示与不展示
      editDialogVisible: false, // 编辑弹窗的展示与不展示
      detailDialogVisible: false, // 详情弹窗的展示与不展示
      userList: [], // 部门用户列表
      selectTree_edit: []
    }
  },
  created() {
    this.loginUserInfo = JSON.parse(sessionStorage.getItem('user')) // 获取当前登陆用户的信息
    this.getDepartmentTreeData() // 获取部门树的数据
    this.getLoginUserInfo() // 获取当前登陆用户的信息
    this.getPageList() // 获取分页列表要展示的数据
  },
  methods: {
    getAuditType(IS_AUDIT){
      if (IS_AUDIT === '2'){
        return '已审核'
      }else if (IS_AUDIT === '1'){
        return '待审核'
      }else if (IS_AUDIT === '3'){
        return '审核驳回'
      }
    },
    remark(row) {
      this.remarkText = row.QY_REMARK || row.GA_REMARK; // 假设驳回原因存储在 row.REJECT_REASON 中
      this.remarkDialogVisible = true; // 显示弹窗
    },
    handleRemarkClose() {
      this.remarkDialogVisible = false; // 关闭弹窗
    },
    getRowKey(row) {
      return row.VEHICLE_ID
    },
    translateLicenceType(id) {
      for (var i = 0; i < this.licenceTypeList.length; i++) {
        if (this.licenceTypeList[i].ID == id) return this.licenceTypeList[i].NAME
      }
    },
    translateVehicleType(id) {
      for (var i = 0; i < this.vehicleTypeList.length; i++) {
        if (this.vehicleTypeList[i].ID == id) return this.vehicleTypeList[i].NAME
      }
    },
    getLoginUserInfo() { // 获取登录人信息
      requestFN(
        '/user/goEditMyInfo',
        {}
      ).then((data) => {
        console.info(data.pd)
        this.loginUserId = data.pd.USER_ID
        this.loginUserName = data.pd.NAME
        this.loginDepartmentId = data.pd.DEPARTMENT_ID
        this.loginDepartmentName = data.pd.deptName
        this.corpInfoId = data.pd.CORPINFO_ID
        // resolve('ok')
      }).catch((e) => {
      })
      // })
    },
    // 搜索
    getQuery() {
      this.$refs.vehicleMessageTable.clearSelection() // 先置空表格再查询
      this.getPageList()
    },
    goKeyReset() {
      this.resetSearch()
      this.getQuery()
    },
    // 获取列表
    getPageList() {
      this.roleName = ''
      this.listLoading = true
      requestFN(
        '/mkmj/management/getXgfCarList?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          ...this.searchFrom,
          CORPINFO_ID: JSON.parse(sessionStorage.getItem('user')).CORPINFO_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.carInfoList
        this.total = data.page.totalResult
        this.roleName = data.roleName
        // this.hasButton()
        this.pd = data.pd
      }).catch((e) => {
        this.listLoading = false
      })
    },
    // 打开新增弹窗的新增按钮
    openAddDialogAddBtn() {
      this.addDialogVisible = true
      this.reSetAddDialog()
      this.ISCHECK = false
    },
    // 置空添加弹窗
    reSetAddDialog() {
      this.addForm.LICENCE_NO = ''
      this.addForm.USER_ID = ''
      this.addForm.VEHICLE_DEPARTMENT_ID = ''
      this.addForm.LICENCE_TYPE = ''
      this.addForm.VEHICLE_TYPE = ''
      this.addForm.VEHICLE_BELONG_TYPE = ''
      this.addForm.EMPLOYEE_VEHICLE_USER_ID = ''
      this.userList = []
      this.addForm.DEPARTMENT_NAME = ''
      this.addForm.DEPARTMENT_ID = ''
    },
    // 获得部门树
    getDepartmentTreeData() {
      requestFN(
        '/department/listzTree',
        {
          CORPINFO_ID: JSON.parse(sessionStorage.getItem('user')).CORPINFO_ID
        }
      ).then((data) => {
        this.departmentTreeData = JSON.parse(data.zTreeNodes)
      }).catch((e) => {
      })
    },
    handleCorpChange(deptId) {
      // 根据选择的公司ID获取审核人列表
      this.getUserList(deptId);

    },
    getUserList(deptId){
      requestFN(
        '/mkmj/management/getUserListByDeptId',
        {
          CORPINFO_ID: JSON.parse(sessionStorage.getItem('user')).CORPINFO_ID,
          DEPARTMENT_ID: deptId
        }
      ).then((data) => {
        this.personList = data.userList
      }).catch((e) => {
      })
    },
    resetSearch() {
      this.searchFrom.LICENCE_NO = ''
      this.searchFrom.VEHICLE_TYPE = ''
      this.searchFrom.IS_AUDIT = ''
      this.searchFrom.USER_NAME = ''
      this.searchFrom.VEHICLE_DEPARTMENT_ID = ''
      this.$refs.selectTree_Search1.clearHandle() // 清空
      this.$refs.selectTree_Search2.clearHandle()
      this.$refs.selectTree_Search3.clearHandle()
    },
    resetForm(row) {
      this.searchFrom = {
        LICENCE_NO: '', // 车牌号
        VEHICLE_TYPE: '', // 车辆类型
        VEHICLE_DEPARTMENT_ID: '' // 车辆所属部门
      }
    },
    goCheckLicenceNoAdd() {
      if (this.addForm.LICENCE_NO) {
        const regex = /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})$/
        const result = regex.test(this.addForm.LICENCE_NO)
        if (result) {
          console.log('格式校验通过')
          requestFN(
            '/mkmj/management/goCheckLicenceNo',
            {
              'LICENCE_NO': this.addForm.LICENCE_NO
            }
          ).then((data) => {
            if (data.result === 'success') {
              this.$message.success('验证通过')
              this.ISCHECK = true
            } else {
              this.$message.error('车牌号已存在,请重新输入')
              this.ISCHECK = false
            }
          }).catch((e) => {
            console.info(e)
            this.listLoading = false
            this.ISCHECK = false
          })
        } else {
          this.$message.success('车牌号不规范')
          this.ISCHECK = false
        }
      }
    },
    // 车辆进出记录按钮的点击事件
    vehicleInOutRecordBtn(LICENCE_NO) {
      this.$parent.activeName = 'Record'
      this.$parent.LICENCE_NO = LICENCE_NO
    },
    addDialogCancelBtn(){
      this.addDialogVisible = false
      this.reSetAddDialog()
    },

    apply(row) {
      this.reapplyForm = { ...row }; // 将当前行的数据复制到 reapplyForm
      this.reapplyForm.DEPT_NAME = row.DEPT_NAME
      this.reapplyForm.U_NAME = row.U_NAME
      this.reapplyDialogVisible = true; // 打开对话框
      console.log(this.reapplyForm)
    },
    reapplyDialogCancelBtn() {
      this.reapplyDialogVisible = false; // 关闭对话框
    },
    reapplyDialogConfirmBtn() {
      // 在这里处理重新申请的逻辑
      this.$refs.reapplyForm.validate(valid => {
        if (valid) {
          requestFN(
            '/mkmj/management/saveLongTimeCarInfo',
            {
              CORPINFO_ID: JSON.parse(sessionStorage.getItem('user')).CORPINFO_ID,
              VEHICLE_DEPARTMENT_ID: this.reapplyForm.DEPARTMENT_ID,
              USER_ID: this.reapplyForm.USER_ID,
              LICENCE_NO: this.reapplyForm.LICENCE_NO,
              LICENCE_TYPE: this.reapplyForm.LICENCE_TYPE,
              VEHICLE_TYPE: this.reapplyForm.VEHICLE_TYPE,
              VISIT_START_TIME: this.reapplyForm.VISIT_START_TIME,
              VISIT_END_TIME: this.reapplyForm.VISIT_END_TIME,
              CAR_FROM: '2'
            }
          ).then((data) => {
            this.reapplyDialogVisible = false; // 关闭对话框
            this.getPageList()
          }).catch((e) => {
          })
        }
      });
    },
    addDialogConfirmBtn(){
      this.$refs.addForm.validate(valid => {
        if (valid){
          requestFN(
            '/mkmj/management/saveLongTimeCarInfo',
            {
              CORPINFO_ID: JSON.parse(sessionStorage.getItem('user')).CORPINFO_ID,
              DEPARTMENT_ID: this.addForm.DEPARTMENT_ID,
              USER_ID: this.addForm.USER_ID,
              LICENCE_NO: this.addForm.LICENCE_NO,
              LICENCE_TYPE: this.addForm.LICENCE_TYPE,
              VEHICLE_TYPE: this.addForm.VEHICLE_TYPE,
              VISIT_START_TIME: this.addForm.VISIT_START_TIME,
              VISIT_END_TIME: this.addForm.VISIT_END_TIME,
              CAR_FROM: '2'
            }
          ).then((data) => {
            this.addDialogVisible = false
            this.getPageList()
          }).catch((e) => {
          })
        }else {
          return false
        }
      })
    }
  }
}
</script>
