<template>
  <el-dialog
    title="发货信息"
    append-to-body
    :visible.sync="dialogVisible"
    :before-close="handleClose"
    width="1100px"
    destroy-on-close
    v-if="dialogShow"
    @close="close"
  >
    <el-form ref="form3" :model="formMst" :rules="rules" size="mini" label-width="130px">
      <el-row>
        <el-col :span="8">
          <el-form-item label="收货单位:">
            <el-input v-model="formMst.consignee" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货人:">
            <el-input v-model="formMst.receiver" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货地址:">
            <el-input v-model="formMst.receiptaddress" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="收货人联系电话:">
            <el-input v-model="formMst.receiptphone" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="物流公司:">
            <el-input v-model="formMst.logisticscompany" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="司机:">
            <el-input v-model="formMst.drivername" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="车牌号:">
            <el-input v-model="formMst.carno" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="司机联系电话:">
            <el-input v-model="formMst.driverphone" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="合同号:">
            <el-input v-model="formMst.contractno" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="送货单位:">
            <el-input v-model="formMst.deliveryunit" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="送货方地址:">
            <el-input v-model="formMst.deliveryaddress" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="送货方联系人:">
            <el-input v-model="formMst.deliveryname" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="送货联系电话:">
            <el-input v-model="formMst.deliveryphone" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="物流公司编码:">
            <el-select
              v-model="formMst.trans_code"
              clearable
              size="mini"
              placeholder="请选择"
              class="filter-item"
              style="width: 210px"
            >
              <el-option
                v-for="item in transportaList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="预估运费:">
            <el-input v-model="formMst.estimated_freight" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="运转费:">
            <el-input v-model="formMst.run_freight" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="卸车费:">
            <el-input v-model="formMst.unload_freight" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="其他费用:">
            <el-input v-model="formMst.other_freight" size="mini" style="width: 210px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="20" style="border: 1px solid white">
          <span />
        </el-col>
        <el-col :span="4">
          <span>
            <el-button icon="el-icon-check" size="mini" type="primary" @click="moneySubmit">保存</el-button>
            <el-button icon="el-icon-close" size="mini" type="info" @click="close">关闭</el-button>
          </span>
        </el-col>
      </el-row>
    </el-form>

  </el-dialog>
</template>

<script>

import CRUD, { crud } from '@crud/crud'
import checkoutbill from '@/views/wms/st/outbill/checkoutbill'
import crudTransportationbase from '@/views/wms/basedata/master/transport/transportationbase'

export default {
  name: 'SunShowDialog',
  mixins: [crud()],
  props: {
    dialogShow: {
      type: Boolean,
      default: false
    },
    openParamMoney: {
      type: Object
    }
  },
  watch: {
    dialogShow: {
      handler(newValue, oldValue) {
        this.dialogVisible = newValue
        this.formMst = this.openParamMoney
      }
    }
  },
  data() {
    return {
      transportaList: [],
      formMst: {},
      dialogVisible: false
    }
  },
  created() {
    crudTransportationbase.getTransporta().then(res => {
      this.transportaList = res
    })
  },
  methods: {
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => {
        })
    },
    close() {
      this.$refs['form3'].resetFields()
      this.$emit('update:dialogShow', false)
      // this.crud.resetQuery(true)
    },
    moneySubmit() {
      checkoutbill.moneySubmit(this.formMst).then(res => {
        this.crud.notify('保存成功！', CRUD.NOTIFICATION_TYPE.INFO)
        this.crud.toQuery()
        this.close()
      })
    }
  }
}
</script>

<style scoped>

</style>
