<template>
  <div class="app-container">
    <div class="tab-header webtop">
      <div>{{ viewTitle }}</div>
      <div>
        <el-button type="primary" size="small" @click="handleCreate()">保存</el-button>
        <el-button type="info" size="small" @click="handleReturn()">返回</el-button>
      </div>
    </div>
    <div class="listconadd">
      <el-form ref="dataForm" :model="temp" label-position="right" label-width="190px" class="formadd" :rules="rules">
        <div class="title">车辆台账信息</div>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="modelName">
              <span slot="label">车型名称：</span>
              <el-autocomplete
                popper-class="my-autocomplete"
                v-model="temp.modelName"
                :fetch-suggestions="querySearch"
                placeholder="请输入内容"
                @select="handleSelectModelName">
                <i
                  class="el-icon-edit el-input__icon"
                  slot="suffix"
                  @click="handleIconClick">
                </i>
                <template slot-scope="{ item }">
                  <span class="addr">{{ item.modelName }}</span>
                </template>
              </el-autocomplete>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="modelConfigSid">
              <span slot="label">常用配置：</span>
              <el-select ref="config" v-model="temp.modelConfigSid" class="addinputw" clearable placeholder=""
                         @change="modelConfigChange">
                <el-option v-for="(item,index) in modelConfig_list" :key="item.sid" :label="item.configName"
                           :value="item.sid"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="vehicleState">
              <span slot="label">库存状态：</span>
              <el-select v-model="temp.vehicleState" class="addinputw" clearable placeholder=""
                         @change="vehicleStateValueChange">
                <el-option v-for="(item,index) in vehicleState_list" :key="item.dictKey" :label="item.dictValue"
                           :value="item.dictKey"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item>
              <span slot="label">车架号：</span>
              <el-input v-model="temp.vinNo" maxlength="125" placeholder="" class="addinputw" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="engineNo">
              <span slot="label">发动机号/许可证号：</span>
              <el-input v-model="temp.engineNo" maxlength="125" placeholder="" class="addinputw" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="orderingNo">
              <span slot="label">厂家订单编码：</span>
              <el-input v-model="temp.orderingNo" maxlength="125" placeholder="" class="addinputw" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="manPurOrderTypeKey">
              <span slot="label">厂家采购订单类型：</span>
              <el-select v-model="temp.manPurOrderTypeKey	" class="addinputw" clearable placeholder=""
                         @change="manPurOrderTypeChange">
                <el-option v-for="(item,index) in manPurOrderType_list" :key="item.dictKey" :label="item.dictValue"
                           :value="item.dictKey"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="priceDate">
              <span slot="label">厂家入库日期：</span>
              <el-date-picker v-model="temp.priceDate" type="date" format="yyyy-MM-dd" class="addinputw"
                              value-format="yyyy-MM-dd" placeholder="选择日期时间"/>
              <!-- <el-input v-model="temp.manufactureDate" maxlength="125" placeholder="" class="addinputw" clearable /> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="departureDate">
              <span slot="label">发车日期：</span>
              <el-date-picker v-model="temp.departureDate" type="date" format="yyyy-MM-dd" class="addinputw"
                              value-format="yyyy-MM-dd" placeholder="选择日期时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="arrivalDate">
              <span slot="label">到货日期：</span>
              <el-date-picker v-model="temp.arrivalDate" type="date" format="yyyy-MM-dd" class="addinputw"
                              value-format="yyyy-MM-dd" placeholder="选择日期时间"/>
              <!-- <el-input v-model="temp.manufactureDate" maxlength="125" placeholder="" class="addinputw" clearable /> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="salesDate">
              <span slot="label">销售日期：</span>
              <el-date-picker v-model="temp.salesDate" type="date" format="yyyy-MM-dd" class="addinputw"
                              value-format="yyyy-MM-dd" placeholder="选择日期时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="solidDate">
              <span slot="label">买断日期：</span>
              <el-date-picker v-model="temp.solidDate" type="date" format="yyyy-MM-dd" class="addinputw"
                              value-format="yyyy-MM-dd" placeholder="选择日期时间"/>
              <!-- <el-input v-model="temp.manufactureDate" maxlength="125" placeholder="" class="addinputw" clearable /> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="settlementStatus">
              <span slot="label">结算状态：</span>
              <el-select v-model="temp.settlementStatus" class="addinputw" clearable placeholder=""
                         @change="settlementStatusChange">
                <el-option v-for="(item,index) in settlementStatus_list" :key="item.key" :label="item.value"
                           :value="item.key"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="returnDate">
              <span slot="label">采购退库日期：</span>
              <el-date-picker v-model="temp.returnDate" type="date" format="yyyy-MM-dd" class="addinputw"
                              value-format="yyyy-MM-dd" placeholder="选择日期时间"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="location">
              <span slot="label">存放地点：</span>
              <el-select v-model="temp.location" class="addinputw" clearable placeholder=""
                         @change="locationChange">
                <el-option v-for="(item,index) in location_list" :key="item.sid" :label="item.warehouseName"
                           :value="item.sid"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="priced">
              <span slot="label">厂家入库价：</span>
              <el-input v-model="temp.priced" maxlength="125" placeholder="" class="addinputw" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="guidedPrice">
              <span slot="label">成交价：</span>
              <el-input v-model="temp.guidedPrice" maxlength="125" placeholder="" class="addinputw" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="warrantyCardNo">
              <span slot="label">保终卡号：</span>
              <el-input v-model="temp.warrantyCardNo" maxlength="125" placeholder="" class="addinputw" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="lockedState">
              <span slot="label">锁定状态：</span>
              <el-select v-model="temp.lockedState" class="addinputw" clearable placeholder=""
                         @change="lockedStateChange">
                <el-option v-for="(item,index) in lockedState_list" :key="item.dictKey" :label="item.dictValue"
                           :value="item.dictKey"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="useOrgName">
              <span slot="label">使用组织：</span> <!--useOrg useOrgName-->
              <el-input placeholder="请输入内容" class="addinputw" v-model="temp.useOrgName" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="createOrgName">
              <span slot="label">创建组织：</span>
              <el-input placeholder="" class="addinputw" v-model="temp.createOrgName" :disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="specialInstructions">
              <span slot="label">特殊说明：</span>
              <el-input v-model="temp.specialInstructions" maxlength="125" placeholder="" class="addinputw" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import {
  details,
  fetchByUseOrgSid,
  getListByVeSid,
  getUseOrgByUserSid,
  SaveList,
  selectModelName,
  Update
} from '@/api/cheliang/basevehicle'
import { selectListOrg } from '@/api/cheliang/basemanufacturer'
import { typeValues } from '@/api/cheliang/dictcommons'
import { setChe } from '@/utils/baocun'
// import { getFileType, parseDate, parseTime, ConvertMenuState } from "@/utils";
// import { findButtonByUserId } from '@/api/sys/permission'
export default {
  name: 'CheliangtaizhangAdd',
  components: {},
  data() {
    var validCascader = (rule, value, callback) => {
      if (this.useOrgArry.length == 0) {
        callback(new Error('请填写创建'))
      } else {
        callback()
      }
    }
    return {
      viewTitle: '',
      // --按钮菜单-------
      sid: '',
      datas: null,
      stateId: 0,
      FormLoading: false,
      listLoading: false,
      // 下拉框
      vehicleState_list: [], // 库存
      modelName_list: [], // 车型名称
      manPurOrderType_list: [],// 采购订单
      location_list: [], // 存放地点
      org_list: {},// 分公司
      modelConfig_list: [], //常用配置
      settlementStatus_list: [{
        value: '没买断',
        key: '0'
      }, {
        value: '预买断',
        key: '1'
      }, {
        value: '买断',
        key: '2'
      }], // 结算状态
      lockedState_list: [], // 锁定状态
      temp: {
        arrivalDate: '',//	到货日期
        createOrg: '',//创建组织sid(陕汽必须的字段)
        createOrgName: '',//创建组织名称(陕汽必须的字段)
        departureDate: '',//	发车日期
        engineNo: '',//发动机号/许可证号（陕汽必须的字段）
        guidedPrice: '',//	成交价
        locationName: '',// 存放地点
        location: '',//存放地点（陕汽必须的字段）
        lockedState: '',//	锁定状态
        lockedStateValue: '',//	锁定状态Value
        manPurOrderTypeKey: '',//	厂家采购订单类型key
        manPurOrderTypeValue: '',//	厂家采购订单类型value
        materialSid: '',//物料sid（陕汽必须的字段）
        modelConfigSid: '',//	车型配置sid
        configName: '',
        modelName: '',//	车型名称
        modelSid: '',//车型sid（陕汽必须的字段）
        orderingNo: '',//	厂家订单编号
        priceDate: '',//	厂家入库日期
        priced: '',//	厂家入库价
        returnDate: '',//	采购退库日期
        salesDate: '',//	销售日期
        settlementStatus: '',//结算状态（0：没买断，1预买断，2买断）
        solidDate: '',//	买断日期
        specialInstructions: '',//	特殊或差异说明
        useOrg: '',//	使用组织sid
        useOrgName: '',//	使用组织名称
        vehicleState: '',//	车辆状态key值
        vehicleStateValue: '',//	车辆状态value值
        vinNo: '',//车架号(VIN)（陕汽必须的字段）
        warrantyCardNo: ''//保修卡号
      }, // 添加和修改
      useOrgArry: [],
      modelValue: [],
      templook: {}, // 查看实体
      textMap: {
        update: '修改',
        create: '创建'
      },
      vinNosse: [],
      vinNoop: {
        vinNo: '',
        sid: ''
      },
      dataArr: [],
      options: [],
      useOrg: [],
      props: {
        emitPath:false,
        value: 'sid',
        label: 'name',
        children: 'children',
        multiple: true
      },
      YongHu: [],
      ConfigSid: [],
      rycxloading: false,
      dialogFormVisible: false, // 添加修改对话框状态
      dialogFormShowVisible: false, // 查看对话框默认关闭状态
      dialogStatus: '', // 对话框状态
      fenzuOptions: [],
      select_temp: '',
      vehiclePhoto: [],
      rules: {
        modelName: [{
          required: true,
          message: '请选择车型名称',
          trigger: 'change'
        }],
        modelConfigSid: [{
          required: true,
          message: '请选择常用配置',
          trigger: 'change'
        }],

        priced: [{
          required: true,
          message: '请填写厂家入库价',
          trigger: 'blur'
        }],
        guidedPrice: [{
          required: true,
          message: '请填写指导价',
          trigger: 'blur'
        }],
        engineNo: [{
          required: true,
          message: '请填写发动机号/许可证号',
          trigger: 'blur'
        }],
        location: [{
          required: true,
          message: '请填写存放地点',
          trigger: 'blur'
        }],
        vehicleState: [{
          required: true,
          message: '请选择库存状态',
          trigger: 'change'
        }],
        firstStartDate: [{
          required: true,
          message: '请填写首次发车日期',
          trigger: 'blur'
        }],
        useOrgArry: [{
          required: true,
          validator: validCascader,
          trigger: 'change'
        }],
        priceDate: [{
          required: true,
          message: '请选择厂家入库时间',
          trigger: 'blur'
        }],
        departureDate: [{
          required: true,
          message: '请选择发车日期',
          trigger: 'blur'
        }],
        arrivalDate: [{
          required: true,
          message: '请选择到货日期',
          trigger: 'blur'
        }],
        salesDate: [{
          required: true,
          message: '请选择销售日期',
          trigger: 'blur'
        }],
        solidDate: [{
          required: true,
          message: '请选择买断日期',
          trigger: 'blur'
        }],
        returnDate: [{
          required: true,
          message: '请选择采购退库日期',
          trigger: 'blur'
        }]
      }
        // ------------------------------------
      }
    },
    computed: {
      ...mapGetters([
        'id',
        'roles',
        'rolesIds',
        'departmentId',
        'departmentCode'
      ])
    },
    created() {

    },
    methods: {
      init() {
        this.stateId = this.$route.params.id
        if (this.stateId !== '0') {
          details(this.stateId).then((response) => {
            if (response.code === '200') {
              if (response.data.useOrg) {
                this.useOrgArry = response.data.useOrg
              }
              this.temp = response.data
              this.setDatche(response.data.brandSid)
              this.getNeizhiBianma(response.data.modelSid)
              console.log(this.temp, 555555555555)
            }
          })
        }
      },
      showAdd() {
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
        this.dialogStatus = 'add'
        this.viewTitle = '【新增】车辆台账'
        this.getType()
        this.getZuZhi()
        this.getUseOrg()
      },
      showEdit(sid) {
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
        this.dialogStatus = 'update'
        this.viewTitle = '【修改】车辆台账'
        this.temp.sid = sid
        console.log('修改页面sid',this.temp.sid)
        details(sid).then((response) => {
          if (response.code === '200') {
            if (response.data.createOrg) {
              console.log('级联选择1：', response.data.useOrg)
              this.useOrgArry = response.data.createOrg
              console.log('级联选择2：', this.useOrgArry)
            }
            this.temp = response.data
            this.getLocation()
            this.getModelConfig(this.temp.modelSid)
          }
        })
        this.getType()
        this.getZuZhi()
        this.getUseOrg()
      },
      // 获得使用组织
      getUseOrg() {
        const userSid = window.sessionStorage.getItem('userSid')
        getUseOrgByUserSid({ userSid: userSid }).then((res) => {
          if (res.success) {
            this.temp.useOrgName = res.data.name
            this.temp.useOrg = res.data.sid
            this.temp.createOrg = res.data.sid
            this.temp.createOrgName = res.data.name
            this.org_list = res.data
            this.getLocation()
          }
        })
      },
      // 根据组织获得存放地点
      getLocation() {
        // 存放地点
        fetchByUseOrgSid({
          sid: this.temp.useOrg
        }).then((res) => {
          if (res.code === '200') {
            this.location_list = res.data
            console.log('存放地点', this.location_list)
          }
        })
      },
      // 下拉框
      getType() {
        // 库存
        typeValues({
          type: 'vehicleLedgerState'
        }).then((res) => {
          if (res.code === '200') {
            this.vehicleState_list = res.data
            console.log('库存状态', this.vehicleState_list)
          }
        })
        // 采购订单
        typeValues({
          type: 'orderType'
        }).then((res) => {
          if (res.code === '200') {
            this.manPurOrderType_list = res.data
          }
        })
        // 锁定状态
        typeValues({
          type: 'lockedState'
        }).then((res) => {
          if (res.code === '200') {
            this.lockedState_list = res.data
            console.log('锁定状态', this.lockedState_list)
          }
        })
      },
      vehicleStateValueChange(val) {
        const choosetItem = this.vehicleState_list.filter((item) => item.dictKey == val)
        this.temp.vehicleStateValue = choosetItem[0].dictValue
        console.log('name:', this.temp.vehicleStateValue, 'key:', this.temp.vehicleState)
      },
      manPurOrderTypeChange(val) {
        const choosetItem = this.manPurOrderType_list.filter((item) => item.dictKey == val)
        this.temp.manPurOrderTypeValue = choosetItem[0].dictValue
        console.log('name:', this.temp.manPurOrderTypeValue, 'key:', this.temp.manPurOrderTypeKey)
      },
      settlementStatusChange(val) {
        const choosetItem = this.settlementStatus_list.filter((item) => item.dictKey == val)
        // this.temp.vehicleStateValue = choosetItem[0].dictValue
        console.log('name:', this.temp.settlementStatus, 'key:', this.temp.settlementStatus)
      },
      // 存放地点
      locationChange(val) {
        const choosetItem = this.location_list.filter((item) => item.sid == val)
        this.temp.locationName = choosetItem[0].warehouseName
        console.log('name:', this.temp.locationName, 'key:', this.temp.location)
      },
      // 锁定状态
      lockedStateChange(val) {
        const choosetItem = this.lockedState_list.filter((item) => item.dictKey == val)
        this.temp.lockedStateValue = choosetItem[0].dictValue
        console.log('name:', this.temp.lockedStateValue, 'key:', this.temp.lockedState)
      },
      // 模糊查询 车型名称 selectModelName
      searchData(data) {
        selectModelName(data).then((response) => {
          console.log('车型名称', response)
          if (response.code === '200') {
            this.modelName_list = response.data
          }
        })
      },
      // 车型名称
      querySearch(queryString, cb) {
        console.log('查询条件：', queryString)
        if (
          queryString != null ||
          queryString != undefined ||
          queryString !== ''
        ) {
          this.searchData({ name: queryString })
          selectModelName({ name: queryString }).then((response) => {
            if (response.code === '200') {
              // const data = response.data
              cb(response.data)
            }
          })
        } else {
          cb(this.modelName_list)
        }
      },
      handleIconClick() {
        this.temp.modelName = ''
      },
      handleSelectModelName(e) {
        console.log('选择：' + e)
        this.temp.modelName = e.modelName
        this.temp.modelSid = e.sid
        // this.temp.modelConfigSid = e.configurationItemsSid
        this.getModelConfig(this.temp.modelSid)
      },
      // 根据车型获取常用配置
      getModelConfig(modelSid) {
        getListByVeSid({ modelSid: modelSid }).then((response) => {
          console.log('常用配置', response)
          if (response.code === '200') {
            this.modelConfig_list = response.data
            console.log(1111111)
            if (!this.modelConfig_list) {
              console.log(2222222)
              this.$refs.config.clearSelection()
            }
          }
        })
      },
      modelConfigChange(val) {
        const choosetItem = this.modelConfig_list.filter((item) => item.sid == val)
        this.temp.configName = choosetItem[0].configName
        console.log('name:', this.temp.configName, 'key:', this.temp.modelConfigSid)
      },
      // -------------- 组织------------------------------------------------------------------------------
      getZuZhi() {
        selectListOrg().then(res => {
          console.log('组织', res)
          if (res.code === '200') {
            this.options = res.data
            console.log('11445522', res.data)
            this.zuzhi0(this.options)
          }
        })
      },
      zuzhi0(data) {
        data.forEach((e) => {
          if (e.children) {
            if (e.children.length != 0) {
              this.zuzhi0(e.children)
            } else {
              delete e.children //删除多的空白
              return
            }
          }
        })
      },
      usrOrgArryChange(e) {
        console.log('选中结果：' + JSON.stringify(e))
        var result = ''
        var result_Sid = ''
        if (e.length > 0) {
          // 循环多选项
          e.forEach((item) => {
            var last_id = item
            console.log('1', last_id)
            // 循环查找名字
            this.select_temp = '' // 临时遍历，用来保存选中结果
            this.select_temp_Sid = '' // 临时遍历，用来保存选中结果(组织Sid)
            console.log('2', this.select_temp)
            console.log('3', this.select_temp_Sid)
            console.log('4', this.options)
            this.findOrgId(last_id, this.options)
            result = result + this.select_temp + ','
            result_Sid = result_Sid + this.select_temp_Sid + ','

          })
        }
        if (result !== '') {
          result = result.substring(0, result.length - 1)
        }
        if (result_Sid !== '') {
          result_Sid = result_Sid.substring(0, result_Sid.length - 1)
        }
        this.temp.createOrgName = result
        this.temp.createOrg = result_Sid
        console.log('选中名称：' + this.temp.createOrgName,this.temp.createOrg)
      },
      // --- 循环查询
      findOrgId(id, options) {
        if (options) {
          for (var i = 0; i < options.length; i++) {
            if (id == options[i].sid) {
              this.select_temp = options[i].name // 保存找到的内容
              this.select_temp_Sid = options[i].sid
              return true
            } else {
              // 判断是否最后一级
              if (options[i].children !== undefined) {
                // 不是的话查询下一级
                if (this.findOrgId(id, options[i].children)) {
                  return true
                }
              }
            }
          }
        }
      },

      // ----------------------------------方法--------------------
      // 返回
      handleReturn(isreload) {
        if (isreload === 'true') this.$emit('reloadlist')
        this.temp = {
          arrivalDate: '',//	到货日期
          createOrg: '',//创建组织sid(陕汽必须的字段)
          createOrgName: '',//创建组织名称(陕汽必须的字段)
          departureDate: '',//	发车日期
          engineNo: '',//发动机号/许可证号（陕汽必须的字段）
          guidedPrice: '',//	成交价
          locationName: '',// 存放地点
          location: '',//存放地点（陕汽必须的字段）
          lockedState: '',//	锁定状态
          lockedStateValue: '',//	锁定状态Value
          manPurOrderTypeKey: '',//	厂家采购订单类型key
          manPurOrderTypeValue: '',//	厂家采购订单类型value
          materialSid: '',//物料sid（陕汽必须的字段）
          modelConfigSid: '',//	车型配置sid
          configName: '',
          modelName: '',//	车型名称
          modelSid: '',//车型sid（陕汽必须的字段）
          orderingNo: '',//	厂家订单编号
          priceDate: '',//	厂家入库日期
          priced: '',//	厂家入库价
          returnDate: '',//	采购退库日期
          salesDate: '',//	销售日期
          settlementStatus: '',//结算状态（0：没买断，1预买断，2买断）
          solidDate: '',//	买断日期
          specialInstructions: '',//	特殊或差异说明
          useOrg: '',//	使用组织sid
          useOrgName: '',//	使用组织名称
          vehicleState: '',//	车辆状态key值
          vehicleStateValue: '',//	车辆状态value值
          vinNo: '',//车架号(VIN)（陕汽必须的字段）
          warrantyCardNo: ''//保修卡号
        }
        this.useOrgArry = []
        this.$emit('doback')
        // this.$router.go(-1)
      },
      // 添加前数据初始化
      resetTemp() {
        // this.useOrg = []
        this.temp = {
          useOrg: []
        }
      },
      // 提交添加数据
      handleCreate() {
        console.log('this.temp.useOrg', this.useOrgArry)
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.FormLoading = true
            // 只需添加和修改
            if (this.dialogStatus === 'add') {
              SaveList(this.temp).then((response) => {
                this.FormLoading = false
                if (response.code === '200') {
                  setChe(response.data)
                  this.dialogFormVisible = false
                  this.$notify({
                    title: '提示',
                    message: '添加成功',
                    type: 'success',
                    duration: 2000
                  })
                  this.handleReturn('true')
                } else {
                  this.$notify({
                    title: '提示',
                    message: '添加失败',
                    type: 'error',
                    duration: 2000
                  })
                }
              })
            } else {
              Update(this.temp).then((response) => {
                this.FormLoading = false
                if (response.code === '200') {
                  this.dialogFormVisible = false
                  this.$notify({
                    title: '提示',
                    message: '修改成功',
                    type: 'success',
                    duration: 2000
                  })
                  this.handleReturn('true')
                } else {
                  this.$notify({
                    title: '失败',
                    message: '修改失败',
                    type: 'error'
                  })
                }
              })
            }
          }
        })
      },

      // 处理图片
      // this.temp.vehiclePhoto = []
      // if (this.vehiclePhoto_Images.length > 0) {
      //   for (var i = 0; i < this.vehiclePhoto_Images.length; i++) {
      //     var image_start = this.vehiclePhoto_Images.indexOf('/upload') + 8
      //     var image_url = this.vehiclePhoto_Images.substring(image_start)
      //     this.temp.vehiclePhoto.push(image_url)
      //   }
      // }
    }
  }
</script>
<style scoped>
/deep/ .el-autocomplete {
  width: 80%;
}

.listconadd {
  width: 100%;
  padding: 0 48px !important;
}
</style>
