<template xmlns:el-col="http://www.w3.org/1999/html">
  <div class="app-container">
    <div v-show="viewState == 1">
      <div class="tab-header webtop">
        <div>{{ viewTitle }}</div>
        <div>
          <el-button type="primary" size="small" :disabled="submitdisabled" @click="dialogStatus === 'add' ? saveAdd() : saveEdit()">保存
          </el-button>
          <el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
        </div>
      </div>
      <div class="listconadd">
        <el-form ref="form_obj" :model="formobj" :rules="rules" class="formadd">
          <div class="title" style="padding: 7px;display: flex;flex-direction: row;justify-content: space-between;align-items: center">
            <div>挂车车型信息</div>
            <el-button type="primary" size="mini" class="btntopblueline" @click="handleChoose">选择</el-button>
          </div>
          <el-row style="border-top: 1px solid #E0E3EB">
            <el-col :span="4" class="tleftb">
              <span>车辆品牌</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ formobj.brandName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>车辆型号</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ formobj.carModelName }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>生产厂商名称</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>{{ formobj.manufacturerName }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>挂车类型</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>{{ formobj.trailerTypeValue }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>外观尺寸</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>长</span><span class="spanPadding">{{ formobj.appearanceSizeLong }}</span>mm,
                <span>宽</span><span class="spanPadding">{{ formobj.appearanceSizeWide }}</span>mm,
                <span>高</span><span class="spanPadding">{{ formobj.appearanceSizeHigh }}</span>mm,
                <span>总高</span><span class="spanPadding">{{ formobj.appearanceSizeTotalHigh }}</span>mm
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>内部尺寸</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>长</span><span class="spanPadding">{{ formobj.insideSizeLong }}</span>mm,
                <span>宽</span><span class="spanPadding">{{ formobj.insideSizeWide }}</span>mm,
                <span>高</span><span class="spanPadding">{{ formobj.insideSizeHigh }}</span>mm
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>鞍座离地高度</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span class="spanPadding">{{ formobj.saddleLeaveLandHigh }}</span>mm
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>大梁尺寸</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>高度</span><span class="spanPadding">{{ formobj.girderSizeHigh }}</span>mm,
                <span>宽度</span><span class="spanPadding">{{ formobj.girderSizeWide }}</span>mm,
                <span>立板</span><span class="spanPadding">{{ formobj.girderSizeStandPlate }}</span>mm
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb" style="display: flex;justify-content: flex-end;align-items: center">
              <span>底盘部分</span>
            </el-col>
            <el-col :span="20" style="padding: 0">
              <el-col :span="4" style="display: flex;justify-content: center;align-items: center">
                <span>牵引销</span>
              </el-col>
              <el-col :span="20" style="border-right: 0">
                <el-form-item>
                  <span>{{ formobj.towPin }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="4" style="display: flex;justify-content: center;align-items: center">
                <span>板簧</span>
              </el-col>
              <el-col :span="20" style="border-right: 0">
                <el-form-item>
                  <span>{{ formobj.plateSpring }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="4" style="display: flex;justify-content: center;align-items: center">
                <span>车桥</span>
              </el-col>
              <el-col :span="20" style="border-right: 0">
                <el-form-item>
                  <span>{{ formobj.axle }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="4" style="display: flex;justify-content: center;align-items: center">
                <span>轮胎及钢圈</span>
              </el-col>
              <el-col :span="20" style="border-right: 0">
                <el-form-item>
                  <span>{{ formobj.tyreAndSteelCircle }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="4" style="display: flex;justify-content: center;align-items: center;border-bottom: 0">
                <span>底板</span>
              </el-col>
              <el-col :span="20" style="border-right: 0;border-bottom: 0">
                <el-form-item>
                  <span class="spanPadding">{{ formobj.floorSize }}</span>mm
                </el-form-item>
              </el-col>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>门扇要求</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ formobj.doorFanRequirement }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>箱体颜色</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ formobj.boxColor }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>更多配置</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>{{ formobj.moreConfig }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>销售指导价(元)</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>{{ formobj.saleGuidancePrice }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="title">
            <div>主车信息</div>
          </div>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>主车车架号</span>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="zcvinNo">
                <el-select v-model="formobj.zcvinNo" @change="changeVinNo" filterable placeholder="请选择" class="addinputw">
                  <el-option v-for="item in vinNo_list" :key="item.vinNo" :label="item.vinNo" :value="item.vinNo">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>品牌</span>
            </el-col>
            <el-col :span="8">
              <el-form-item><span>{{ formobj.brand }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>车型</span>
            </el-col>
            <el-col :span="8">
              <el-form-item><span>{{ formobj.vehicleModel }}</span></el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>公告型号</span>
            </el-col>
            <el-col :span="8">
              <el-form-item><span>{{ formobj.noticeModel }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>销售订单编号</span>
            </el-col>
            <el-col :span="8">
              <el-form-item><span>{{ formobj.salesOrderNumber }}</span></el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>销售订单日期</span>
            </el-col>
            <el-col :span="8">
              <el-form-item><span>{{ formobj.dateOfSalesOrder }}</span></el-form-item>
            </el-col>
          </el-row>
          <div class="title">
            <div>挂车信息</div>
          </div>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>挂车车架号</span>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="vinNo"><el-input v-model="formobj.vinNo" @change="vinNoChange" clearable placeholder="" class="addinputw"></el-input></el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>入库日期</span>
            </el-col>
            <el-col :span="8">
              <el-form-item><el-date-picker v-model="formobj.warehousingDate" :picker-options="pickerOptions" type="date" clearable value-format="yyyy-MM-dd" placeholder="选择日期"/></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>厂家结算价(元)</span>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="settlementPrice"><el-input v-model="formobj.settlementPrice" clearable placeholder="" @keyup.native="UpNumber" class="addinputw"></el-input></el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>成交价(元)</span>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="dealPrice"><el-input v-model="formobj.dealPrice" clearable placeholder="" @keyup.native="UpNumber" class="addinputw"></el-input></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb" style="display: flex;justify-content: flex-end;align-items: center">
              <span>发票照片</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <upload_picture ref="imgUpload" v-model="imgList" bucket="map" :upload-data="{type:'0001'}" class="addinputw addinputwOne"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb" style="display: flex;justify-content: flex-end;align-items: center">
              <span>合格证照片</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <upload_picture ref="imgUpload" v-model="imgList2" bucket="map" :upload-data="{type:'0001'}" class="addinputw addinputwOne"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <!--End 添加修改部分-->
    <guachechexingselect v-show="viewState == 2" ref="divChoose" @backData="backData" @doback="resetState"/>
  </div>
</template>

<script>
import req from '@/api/guache/guachetaizhang'
import guachechexingselect from './relation/guachechexingselect'
import upload_picture from '@/components/uploadFile/upload_picture'
import { fetchBySid, fetchByVehSid } from '@/api/cheliang/dictcommons'

export default {
  name: 'GuaCheTaiZhangInfo',
  components: {
    guachechexingselect,
    upload_picture
  },
  data() {
    return {
      // 限制日期不可选择当天之前的
      pickerOptions: {
        disabledDate(time) {
          let oneDay = 3600 * 1000 * 24 * 5
          return Date.now() < time.getTime() || time.getTime() < Date.now() - oneDay
        }
      },
      viewTitle: '',
      dialogStatus: '',
      viewState: 1,
      brand_list: [],
      vinNo_list: [],
      imgList: [],
      imgList2: [],
      formobj: {
        sid: '',
        departmentSid: '',
        appearanceSizeHigh: '',
        appearanceSizeLong: '',
        appearanceSizeWide: '',
        appearanceSizeTotalHigh: '',
        axle: '',
        boxColor: '',
        brandName: '',
        carModelName: '',
        doorFanRequirement: '',
        floorSize: '',
        girderSizeHigh: '',
        girderSizeStandPlate: '',
        girderSizeWide: '',
        insideSizeHigh: '',
        insideSizeLong: '',
        insideSizeWide: '',
        manufacturerName: '',
        manufacturerSid: '',
        moreConfig: '',
        plateSpring: '',
        plateSpringKey: '',
        saddleLeaveLandHigh: '',
        saleGuidancePrice: '',
        towPin: '',
        towPinKey: '',
        trailerTypeKey: '',
        trailerTypeValue: '',
        tyreAndSteelCircle: '',
        tyreAndSteelCircleKey: '',
        useOrgName: '',
        useOrgSid: '',
        certificatePic: [],
        invoicePic: [],
        customerName: '',
        customerSid: '',
        dealPrice: '',
        issueDate: '',
        settlementPrice: '',
        staffName: '',
        staffSid: '',
        stockStateKey: '',
        stockStateValue: '',
        trailerModelSid: '',
        vehSid: '',
        vinNo: '',
        warehousingDate: '',
        zcvinNo: '',
        brand: '',
        vehicleModel: '',
        noticeModel: '',
        salesOrderNumber: '',
        dateOfSalesOrder: '',
        userSid: '',
      },
      rules: {
        zcvinNo: [{ required: true, message: '主车车架号不能为空', trigger: 'change' }],
        vinNo: [{ required: true, message: '挂车车架号不能为空', trigger: 'blur' }],
        settlementPrice: [{ required: true, message: '厂家结算价不能为空', trigger: 'blur' }],
        dealPrice: [{ required: true, message: '成交价不能为空', trigger: 'blur' }],
      },
      submitdisabled: false
    }
  },
  methods: {
    init() {
      req.selExistingCar({ createOrgSid: this.formobj.useOrgSid }).then((resp) => {
        if (resp.success) {
          this.vinNo_list = resp.data
        }
      })
      fetchBySid(this.formobj.useOrgSid).then((res) => {
        if (res.success) {
          this.formobj.useOrgName = res.data.name
        }
      })
    },
    UpNumber(e) {
      e.target.value = e.target.value.replace(/[^\d]/g, '') // 清除“数字”和“.”"-"以外的字符
      e.target.value = e.target.value.replace(/^00/, '0') // 开头不能有两个0
      if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
        // 以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
        console.log(e.target.value)
        e.target.value = parseFloat(e.target.value)
      }
    },
    showAdd(useOrgSid) {
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
        this.init()
      })
      this.viewTitle = '【入库】挂车'
      this.dialogStatus = 'add'
      this.formobj.departmentSid = window.sessionStorage.getItem('departmentSid')
      this.formobj.userSid = window.sessionStorage.getItem('userSid')
      this.formobj.useOrgSid = useOrgSid
      this.formobj.stockStateValue = '库存'
      this.formobj.stockStateKey = '0001'
    },
    showEdit(row, useOrgSid) {
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
        this.init()
      })
      this.viewTitle = '【入库】挂车'
      this.dialogStatus = 'edit'
      this.formobj.useOrgSid = useOrgSid
      req.fetchBySid(row.sid).then((res) => {
        if (res.success) {
          this.formobj.sid = row.sid
          this.formobj.trailerModelSid = res.data.baseTrailerModelDetailsVo.trailerModelSid
          this.formobj.brandName = res.data.baseTrailerModelDetailsVo.brandName
          this.formobj.carModelName = res.data.baseTrailerModelDetailsVo.carModelName
          this.formobj.manufacturerName = res.data.baseTrailerModelDetailsVo.manufacturerName
          this.formobj.manufacturerSid = res.data.baseTrailerModelDetailsVo.manufacturerSid
          this.formobj.trailerTypeValue = res.data.baseTrailerModelDetailsVo.trailerTypeValue
          this.formobj.trailerTypeKey = res.data.baseTrailerModelDetailsVo.trailerTypeKey
          this.formobj.appearanceSizeLong = res.data.baseTrailerModelDetailsVo.appearanceSizeLong
          this.formobj.appearanceSizeHigh = res.data.baseTrailerModelDetailsVo.appearanceSizeHigh
          this.formobj.appearanceSizeWide = res.data.baseTrailerModelDetailsVo.appearanceSizeWide
          this.formobj.appearanceSizeTotalHigh = res.data.baseTrailerModelDetailsVo.appearanceSizeTotalHigh
          this.formobj.insideSizeLong = res.data.baseTrailerModelDetailsVo.insideSizeLong
          this.formobj.insideSizeHigh = res.data.baseTrailerModelDetailsVo.insideSizeHigh
          this.formobj.insideSizeWide = res.data.baseTrailerModelDetailsVo.insideSizeWide
          this.formobj.saddleLeaveLandHigh = res.data.baseTrailerModelDetailsVo.saddleLeaveLandHigh
          this.formobj.girderSizeHigh = res.data.baseTrailerModelDetailsVo.girderSizeHigh
          this.formobj.girderSizeWide = res.data.baseTrailerModelDetailsVo.girderSizeWide
          this.formobj.girderSizeStandPlate = res.data.baseTrailerModelDetailsVo.girderSizeStandPlate
          this.formobj.towPin = res.data.baseTrailerModelDetailsVo.towPin
          this.formobj.towPinKey = res.data.baseTrailerModelDetailsVo.towPinKey
          this.formobj.plateSpring = res.data.baseTrailerModelDetailsVo.plateSpring
          this.formobj.plateSpringKey = res.data.baseTrailerModelDetailsVo.plateSpringKey
          this.formobj.axle = res.data.baseTrailerModelDetailsVo.axle
          this.formobj.tyreAndSteelCircle = res.data.baseTrailerModelDetailsVo.tyreAndSteelCircle
          this.formobj.tyreAndSteelCircleKey = res.data.baseTrailerModelDetailsVo.tyreAndSteelCircleKey
          this.formobj.floorSize = res.data.baseTrailerModelDetailsVo.floorSize
          this.formobj.doorFanRequirement = res.data.baseTrailerModelDetailsVo.doorFanRequirement
          this.formobj.boxColor = res.data.baseTrailerModelDetailsVo.boxColor
          this.formobj.moreConfig = res.data.baseTrailerModelDetailsVo.moreConfig
          this.formobj.saleGuidancePrice = res.data.baseTrailerModelDetailsVo.saleGuidancePrice

          this.formobj.useOrgName = res.data.useOrgName
          this.formobj.useOrgSid = res.data.useOrgSid
          this.formobj.certificatePic = res.data.certificatePic
          this.formobj.invoicePic = res.data.invoicePic
          this.formobj.customerName = res.data.customerName
          this.formobj.customerSid = res.data.customerSid
          this.formobj.dealPrice = res.data.dealPrice
          this.formobj.issueDate = res.data.issueDate
          this.formobj.settlementPrice = res.data.settlementPrice
          this.formobj.staffName = res.data.staffName
          this.formobj.staffSid = res.data.staffSid
          this.formobj.stockStateKey = res.data.stockStateKey
          this.formobj.stockStateValue = res.data.stockStateValue
          this.formobj.trailerModelSid = res.data.trailerModelSid
          this.formobj.vehSid = res.data.vehSid
          this.formobj.vinNo = res.data.vinNo
          this.formobj.warehousingDate = res.data.warehousingDate
          this.formobj.zcvinNo = res.data.zcvinNo
          this.formobj.brand = res.data.zcBrandName
          this.formobj.vehicleModel = res.data.zcModelName
          this.formobj.noticeModel = res.data.zcAnnouncementmodelName
          this.formobj.salesOrderNumber = res.data.saleOrderNo
          this.formobj.dateOfSalesOrder = res.data.saleOrderDate
          if (this.formobj.certificatePic !== null && this.formobj.certificatePic.length > 0) {
            this.formobj.certificatePic.forEach((e) => {
              this.imgList.push({
                name: e.fileName,
                filePath: e.filePath,
                size: e.fileSize,
                url: e.filePath
              })
            })
          }
          if (this.formobj.invoicePic !== null && this.formobj.invoicePic.length > 0) {
            this.formobj.invoicePic.forEach((e) => {
              this.imgList2.push({
                name: e.fileName,
                filePath: e.filePath,
                size: e.fileSize,
                url: e.filePath
              })
            })
          }
        }
      })
    },
    vinNoChange(val) {
      if (val.length < 17 && val.length !== 8) {
        this.$message({ showClose: true, type: 'error', message: '车架号的长度应为8位或17位' })
      }
    },
    changeVinNo(value) {
      const choose = this.vinNo_list.filter((item) => item.vinNo === value)
      if (choose !== null && choose !== undefined) {
        this.formobj.zcvinNo = choose[0].vinNo
        this.formobj.vehSid = choose[0].vehSid
        this.formobj.brand = choose[0].brandName
        this.formobj.vehicleModel = choose[0].vehicleAlias
        this.formobj.noticeModel = choose[0].noticeModel
        fetchByVehSid({ vehSid: choose[0].vehSid }).then((res) => {
          if (res.success) {
            this.formobj.salesOrderNumber = res.data.saleOrderNo
            this.formobj.dateOfSalesOrder = res.data.saleOrderDate
            this.formobj.staffName = res.data.staffName
            this.formobj.staffSid = res.data.staffSid
            this.formobj.customerName = res.data.customerName
            this.formobj.customerSid = res.data.customerSid
          }
        })
      }
    },
    handleChoose() {
      this.viewState = 2
      this.$refs['divChoose'].showData()
    },
    backData(value) {
      this.viewState = 1
      this.formobj.trailerModelSid = value.sid
      this.formobj.brandName = value.brandName
      this.formobj.carModelName = value.carModelName
      this.formobj.manufacturerName = value.manufacturerName
      this.formobj.manufacturerSid = value.manufacturerSid
      this.formobj.trailerTypeValue = value.trailerTypeValue
      this.formobj.trailerTypeKey = value.trailerTypeKey
      this.formobj.appearanceSizeLong = value.appearanceSizeLong
      this.formobj.appearanceSizeHigh = value.appearanceSizeHigh
      this.formobj.appearanceSizeWide = value.appearanceSizeWide
      this.formobj.appearanceSizeTotalHigh = value.appearanceSizeTotalHigh
      this.formobj.insideSizeLong = value.insideSizeLong
      this.formobj.insideSizeHigh = value.insideSizeHigh
      this.formobj.insideSizeWide = value.insideSizeWide
      this.formobj.saddleLeaveLandHigh = value.saddleLeaveLandHigh
      this.formobj.girderSizeHigh = value.girderSizeHigh
      this.formobj.girderSizeWide = value.girderSizeWide
      this.formobj.girderSizeStandPlate = value.girderSizeStandPlate
      this.formobj.towPin = value.towPin
      this.formobj.towPinKey = value.towPinKey
      this.formobj.plateSpring = value.plateSpring
      this.formobj.plateSpringKey = value.plateSpringKey
      this.formobj.axle = value.axle
      this.formobj.tyreAndSteelCircle = value.tyreAndSteelCircle
      this.formobj.tyreAndSteelCircleKey = value.tyreAndSteelCircleKey
      this.formobj.floorSize = value.floorSize
      this.formobj.doorFanRequirement = value.doorFanRequirement
      this.formobj.boxColor = value.boxColor
      this.formobj.moreConfig = value.moreConfig
      this.formobj.saleGuidancePrice = value.saleGuidancePrice
    },
    resetState() {
      this.viewState = 1
    },
    getUrl() {
      if (this.imgList.length > 0) {
        const aa = []
        for (var i = 0; i < this.imgList.length; i++) {
          aa.push({
            attachType: '',
            createBySid: '',
            fileName: this.imgList[i].name,
            filePath: this.imgList[i].filePath,
            fileSize: this.imgList[i].size,
            fileType: this.imgList[i].name.substr(this.imgList[i].name.lastIndexOf('.')),
            linkSid: '',
            name: window.sessionStorage.getItem('name'),
            sid: ''
          })
        }
        this.formobj.invoicePic = aa
      }
      if (this.imgList2.length > 0) {
        const bb = []
        for (var k = 0; k < this.imgList2.length; k++) {
          bb.push({
            attachType: '',
            createBySid: '',
            fileName: this.imgList2[k].name,
            filePath: this.imgList2[k].filePath,
            fileSize: this.imgList2[k].size,
            fileType: this.imgList2[k].name.substr(this.imgList2[k].name.lastIndexOf('.')),
            linkSid: '',
            name: window.sessionStorage.getItem('name'),
            sid: ''
          })
        }
        this.formobj.certificatePic = bb
      }
    },
    saveAdd() {
      if (this.formobj.brandName === '') {
        this.$message({ showClose: true, type: 'error', message: '请选择挂车车型信息' })
        return
      }
      this.$refs['form_obj'].validate((valid) => {
        if (valid) {
          const tip = '请确认是否保存此次所填信息'
          this.$confirm(tip, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.submitdisabled = true
            this.getUrl()
            req.save(this.formobj).then((resp) => {
              if (resp.success) {
                this.$message({ showClose: true, type: 'success', message: '保存成功' })
                this.submitdisabled = false
                this.handleReturn('true')
              } else {
                this.submitdisabled = false
              }
            }).catch(() => {
              this.submitdisabled = false
            })
          })
        } else {
          return false
        }
      })
    },
    saveEdit() {
      if (this.formobj.brandName === '') {
        this.$message({ showClose: true, type: 'error', message: '请选择挂车车型信息' })
        return
      }
      this.$refs['form_obj'].validate((valid) => {
        if (valid) {
          this.submitdisabled = true
          this.getUrl()
          req.update(this.formobj, this.formobj.sid).then((resp) => {
            if (resp.success) {
              this.$message({
                showClose: true,
                type: 'success',
                message: resp.msg
              })
              this.submitdisabled = false
              this.handleReturn('true')
            } else {
              this.submitdisabled = false
            }
          }).catch(() => {
            this.submitdisabled = false
          })
        } else {
          return false
        }
      })
    },
    handleReturn(isreload) {
      if (isreload === 'true') this.$emit('reloadlist')
      this.formobj = {
        sid: '',
        departmentSid: '',
        appearanceSizeHigh: '',
        appearanceSizeLong: '',
        appearanceSizeWide: '',
        appearanceSizeTotalHigh: '',
        axle: '',
        boxColor: '',
        brandName: '',
        carModelName: '',
        doorFanRequirement: '',
        floorSize: '',
        girderSizeHigh: '',
        girderSizeStandPlate: '',
        girderSizeWide: '',
        insideSizeHigh: '',
        insideSizeLong: '',
        insideSizeWide: '',
        manufacturerName: '',
        manufacturerSid: '',
        moreConfig: '',
        plateSpring: '',
        plateSpringKey: '',
        saddleLeaveLandHigh: '',
        saleGuidancePrice: '',
        towPin: '',
        towPinKey: '',
        trailerTypeKey: '',
        trailerTypeValue: '',
        tyreAndSteelCircle: '',
        tyreAndSteelCircleKey: '',
        useOrgName: '',
        useOrgSid: '',
        certificatePic: [],
        invoicePic: [],
        customerName: '',
        customerSid: '',
        dealPrice: '',
        issueDate: '',
        settlementPrice: '',
        staffName: '',
        staffSid: '',
        stockStateKey: '',
        stockStateValue: '',
        trailerModelSid: '',
        vehSid: '',
        vinNo: '',
        warehousingDate: '',
        zcvinNo: '',
        brand: '',
        vehicleModel: '',
        noticeModel: '',
        salesOrderNumber: '',
        dateOfSalesOrder: '',
        userSid: ''
      }
      this.imgList = []
      this.imgList2 = []
      this.submitdisabled = false
      this.$refs['form_obj'].resetFields()
      this.$emit('doback')
    }
  }
}
</script>

<style scoped>
.spanPadding {
  padding: 0 5px;
}
</style>
