<template>
    <div>
        <div class="customer-head">
            <div class="customer-back">
                <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
                    @click="goBack(0)">返回列表
                </el-button>
            </div>
            <div class="add-customer-btn">
                <el-button class="el-button--small-yh" style="margin-left: 6px;" type="primary" size="small"
                    v-if="editButton" @click="inEdit">编 辑
                </el-button>
                <el-button class="el-button--small-yh" v-else style="margin-left: 6px;" type="primary" size="small"
                    :disabled="isSaveBtn || form.status != 0" @click="submit">保 存
                </el-button>
                <el-button v-if="form.id" class="el-button--small-yh" style="margin-left: 6px;" type="success" size="small"
                    :disabled="(form.status != 0 && form.status != 4)" @click="application">单据请核
                </el-button>
                <el-button v-if="form.status == 1" class="el-button--small-yh" style="margin-left: 6px;" type="danger"
                    size="small" @click="revokeApplication">撤销单据请核
                </el-button>
                <el-dropdown style="line-height: 0">
                    <el-button class="el-button--small-yh" style="margin-left: 6px;" type="warning" :disabled="!form.id"
                        size="small">
                        审 批<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item @click.native="checkScheduleDialog = true, checkId = form.id">审核进度
                        </el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </div>
        <div style="margin-top: 50px">
            <trade-card title="基础信息">
                <avue-form :option="optionForm" v-model="form" ref="form">
                    <tempalte slot="corpCnName">
                        <dic-select v-model="form.corpCnName" placeholder="客户" key="id" label="cnName" res="records"
                            url="/blade-los/bcorps/listByType" :filterable="true" :remote="true" dataName="cnName"
                            @selectChange="dicChange('corpCnName', $event)" :disabled="editDisabled"></dic-select>
                    </tempalte>
                    <tempalte slot="polCnName">
                        <dic-select v-model="form.polCnName" placeholder="起运港" key="id" label="cnName" res="records"
                            url="/blade-los/bports/list" :filterable="true" :remote="true" dataName="cnName"
                            @selectChange="dicChange('polCnName', $event)" :disabled="editDisabled"></dic-select>
                    </tempalte>
                    <tempalte slot="podCnName">
                        <dic-select v-model="form.podCnName" placeholder="目的港" key="id" label="cnName" res="records"
                            url="/blade-los/bports/list" :filterable="true" :remote="true" dataName="cnName"
                            @selectChange="dicChange('podCnName', $event)" :disabled="editDisabled"></dic-select>
                    </tempalte>
                    <tempalte slot="srcCnName">
                        <dic-select v-model="form.srcCnName" placeholder="业务员" key="id" label="realName" res="records"
                            url="/blade-user/page" :filterable="true" :remote="true" dataName="realName"
                            @selectChange="dicChange('srcCnName', $event)" :disabled="editDisabled"></dic-select>
                    </tempalte>
                    <tempalte slot="hshipperCnName">
                        <dic-select v-model="form.hshipperCnName" placeholder="发货人" key="id" label="cnName" res="records"
                            url="/blade-los/bcorps/listByType" :filterable="true" :remote="true" dataName="cnName"
                            @selectChange="dicChange('hshipperCnName', $event)" :disabled="editDisabled"></dic-select>
                    </tempalte>
                    <tempalte slot="hconsigneeCnName">
                        <dic-select v-model="form.hconsigneeCnName" placeholder="收货人" key="id" label="cnName" res="records"
                            url="/blade-los/bcorps/listByType" :filterable="true" :remote="true" dataName="cnName"
                            @selectChange="dicChange('hconsigneeCnName', $event)" :disabled="editDisabled"></dic-select>
                    </tempalte>
                    <tempalte slot="carrierCnName">
                        <dic-select v-model="form.carrierCnName" placeholder="船公司" key="id" label="cnName" res="records"
                            url="/blade-los/bcorps/listByType?corpTypeName=船公司" :filterable="true" :remote="true"
                            dataName="cnName" @selectChange="dicChange('carrierCnName', $event)"
                            :disabled="editDisabled"></dic-select>
                    </tempalte>
                    <template slot="hscode">
                        <div style="display:flex;">
                            <dic-select v-model="form.hscode" placeholder="品名" key="id" res="records" label="hsCode"
                                url="/blade-los/bcommodity/list" :filterable="true" :remote="true" dataName="hsCode"
                                @selectChange="dicChange('hscode', $event)" :disabled="editDisabled"></dic-select>
                            <el-input style="margin-left: 10px;" v-model="form.goodsName" placeholder="请输入品名"
                                :disabled="editDisabled"></el-input>
                        </div>
                    </template>
                </avue-form>
            </trade-card>
            <trade-card title="箱信息">
                <avue-crud :option="option" :data="form.preContainersList" id="out-table" ref="crud"
                    @selection-change="selectionChange" @resetColumn="resetColumn('crud', 'option', 'optionBack', 388)"
                    @saveColumn="saveColumn('crud', 'option', 'optionBack', 388)">
                    <template slot="menu" slot-scope="{ row, index }">
                        <el-button size="small" type="text" :disabled="editDisabled || row.whetherDispatchVehicles == 1"
                            @click="rowCell('编辑', row, index)">编
                            辑</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled || row.whetherDispatchVehicles == 1"
                            @click="rowCell('派车', row, index)">派
                            车</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled || row.whetherDispatchVehicles == 1"
                            @click="rowCell('自提', row, index)">自
                            提</el-button>
                    </template>
                </avue-crud>
            </trade-card>
            <trade-card title="派车">
                <avue-crud :option="option2" :data="form.dispatchVehiclesList" id="out-table" ref="crud2"
                    @selection-change="selectionChange" @resetColumn="resetColumn('crud2', 'option2', 'optionBack2', 389)"
                    @saveColumn="saveColumn('crud2', 'option2', 'optionBack2', 389)">
                    <tempalte slot="fleetName" slot-scope="{ row, index }">
                        <dic-select v-if="row.$cellEdit" v-model="row.fleetName" placeholder="承运车队" key="id" label="cnName"
                            res="records" url="/blade-los/bcorps/listByType?corpTypeName=车队" :filterable="true"
                            :remote="true" dataName="cnName" @selectChange="rowDicChange('fleetName', $event, row)"
                            :disabled="editDisabled"></dic-select>
                        <span v-else>{{ row.fleetName }}</span>
                    </tempalte>
                    <tempalte slot="pickupAddressName" slot-scope="{ row, index }">
                        <dic-select v-if="row.$cellEdit" v-model="row.pickupAddressName" placeholder="提箱地点" key="id"
                            label="cnName" res="records" url="/blade-los/blocations/list" :filterable="true" :remote="true"
                            dataName="cnName" @selectChange="rowDicChange('pickupAddressName', $event, row)"
                            :disabled="editDisabled"></dic-select>
                        <span v-else>{{ row.pickupAddressName }}</span>
                    </tempalte>
                    <tempalte slot="deliveryAddressName" slot-scope="{ row, index }">
                        <dic-select v-if="row.$cellEdit" v-model="row.deliveryAddressName" placeholder="提箱地点" key="id"
                            label="cnName" res="records" url="/blade-los/blocations/list" :filterable="true" :remote="true"
                            dataName="cnName" @selectChange="rowDicChange('deliveryAddressName', $event, row)"
                            :disabled="editDisabled"></dic-select>
                        <span v-else>{{ row.deliveryAddressName }}</span>
                    </tempalte>
                    <template slot="returnCyName" slot-scope="{ row }">
                        <dic-select v-if="row.$cellEdit" v-model="row.returnCyName" placeholder="返空场站" key="id"
                            label="cnName" res="records" url="/blade-los/bcorps/listByType?corpTypeName=场站"
                            :filterable="true" :remote="true" dataName="cnName"
                            @selectChange="rowDicChange('returnCyName', $event, row)"></dic-select>
                        <span v-else>{{ row.returnCyName }}</span>
                    </template>
                    <template slot="menu" slot-scope="{ row, index }">
                        <el-button size="small" type="text"
                            :disabled="editDisabled || row.whetherDispatchVehicles == 1 || row.whetherWarehouseEntry == 1"
                            @click="rowCell('编辑', row, index)">编
                            辑</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled || row.whetherDispatchVehicles == 1"
                            @click="rowCell('确认派车', row, index)">确
                            认</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled || row.whetherWarehouseEntry == 1"
                            @click="rowCell('生成入库', row, index)">入
                            库</el-button>
                        <!-- <el-button size="small" type="text"
                            :disabled="editDisabled || row.whetherDispatchVehicles == 1 || row.whetherWarehouseEntry == 1"
                            @click="rowCell('派车删除', row, index)">删 除</el-button> -->
                    </template>
                </avue-crud>
            </trade-card>
            <trade-card title="入库">
                <avue-crud :option="option3" :data="form.inStorageList" id="out-table" ref="crud3"
                    @selection-change="selectionChange" @resetColumn="resetColumn('crud3', 'option3', 'optionBack3', 390)"
                    @saveColumn="saveColumn('crud3', 'option3', 'optionBack3', 390)">
                    <template slot="warehouseName" slot-scope="{ row }">
                        <dic-select v-if="row.$cellEdit" v-model="row.warehouseName" placeholder="入库" key="id" label="cname"
                            url="/blade-los/storage/list" res="records" :filterable="true" :remote="true" dataName="cname"
                            @selectChange="rowDicChange('warehouseName', $event, row)"></dic-select>
                        <span v-else>{{ row.warehouseName }}</span>
                    </template>
                    <template slot="menu" slot-scope="{ row, index }">
                        <el-button size="small" type="text" :disabled="editDisabled || row.confirmDispatchVehicles == 1"
                            @click="rowCell('编辑', row, index)">编
                            辑</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled || row.confirmDispatchVehicles == 1"
                            @click="rowCell('入库确认', row, index)">入库确认</el-button>
                        <el-button size="small" type="text"
                            :disabled="editDisabled || (row.whetherInOutStorage == 1 && row.surplusQuantity == 0)"
                            @click="rowCell('生成出库', row, index)">出
                            库</el-button>
                        <!-- <el-button size="small" type="text"
                            :disabled="editDisabled || row.confirmDispatchVehicles == 1 || row.whetherInOutStorage == 1"
                            @click="rowCell('入库删除', row, index)">删 除</el-button> -->
                    </template>
                </avue-crud>
            </trade-card>
            <trade-card title="出库">
                <avue-crud :option="option4" :data="form.outStorageList" id="out-table" ref="crud4"
                    @selection-change="selectionChange" @resetColumn="resetColumn('crud4', 'option4', 'optionBack4', 391)"
                    @saveColumn="saveColumn('crud4', 'option4', 'optionBack4', 391)">
                    <template slot="menu" slot-scope="{ row, index }">
                        <el-button size="small" type="text" :disabled="editDisabled || row.confirmDispatchVehicles == 1"
                            @click="rowCell('编辑', row, index)">编
                            辑</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled || row.confirmDispatchVehicles == 1"
                            @click="rowCell('出库确认', row, index)">出库确认</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled" @click="rowCell('开票', row, index)">开
                            票</el-button>
                        <el-button size="small" type="text" :disabled="editDisabled || row.confirmDispatchVehicles == 1"
                            @click="rowCell('出库删除', row, index)">删 除</el-button>
                    </template>
                </avue-crud>
            </trade-card>
            <trade-card title="费用明细">
                <fee-info :form="form" :disabled="editDisabled" @getDetails="getDetails"></fee-info>
            </trade-card>
            <containerTitle title="上传附件"></containerTitle>
            <c-upload :data="form.filesCenterList" :enumerationValue="76"
                deleteUrl="/blade-purchase-sales/orderfiles/update" display :disabled="editDisabled"></c-upload>
        </div>
        <!--审核弹窗-->
        <el-dialog append-to-body title="审批进度" class="el-dialogDeep" :visible.sync="checkScheduleDialog" width="40%"
            :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" v-dialog-drag>
            <check-schedule :checkId="checkId" :batchNo="batchNo" @choceScheduleFun="choceScheduleFun"></check-schedule>
        </el-dialog>
    </div>
</template>

<script>
import { submit, getDetail, detailTradeByMblno, remove, checkAgent, revokeCheckAgent, copyAgent, generateDispatchVehicles, confirmDispatchVehicles, generateWarehouseEntry, confirmWarehouseEntry, generateOutbound, dispatchvehiclesRemove, inoutstorageRemove, calculationWarehouseUnitPrice } from "@/api/tradeAgency/oceanFreightImport";
import feeInfo from "@/components/tradeAgency/fee-oceanFreight";
import dicSelect from "@/components/dicSelect/main";
import checkSchedule from "@/components/checkH/checkSchedule.vue";
import _ from "lodash";
export default {
    name: "detailsPage",
    data() {
        return {
            checkId: '', // 审核需要的id
            batchNo: '',
            checkScheduleDialog: false, // 审核弹窗
            editButton: false,
            editDisabled: false,
            form: {
                billNoFormat: 'HYJK',
                businessTypeCode: 'HYJK',
                businessType: 'SI',
                status: 0,
                seaType: 'I',
                feeCenterListC: [],
                feeCenterListD: [],
                filesCenterList: [],
                inStorageList: [],//入库
                outStorageList: [],//出库
                dispatchVehiclesList: [],//派车
                preContainersList: []//箱信息
            },
            optionForm: {
                menuBtn: false,
                span: 8,
                disabled: false,
                column: [
                    {
                        label: '客户',
                        prop: "corpCnName",
                        disabled: false,
                        rules: [{
                            required: true,
                            message: " ",
                            trigger: "blur"
                        }]
                    },
                    {
                        label: "委托编号",
                        prop: "billNo",
                        disabled: true,
                    },
                    {
                        label: "提单号",
                        prop: "mblno",
                        disabled: false,
                        rules: [{
                            required: true,
                            message: " ",
                            trigger: "blur"
                        }]
                    },
                    {
                        label: '合同号',
                        prop: "bookingNo",
                        disabled: false,
                        rules: [{
                            required: true,
                            message: " ",
                            trigger: "blur"
                        }]
                    },
                    {
                        label: '原产地',
                        prop: "mnotifyCntyCode",
                        type: 'select',
                        filterable: true,
                        remote: true,
                        dicUrl: "/api/blade-los/bcountrys/list",
                        props: {
                            label: 'cnName',
                            value: 'cnName',
                            res: 'data.records'
                        },
                        disabled: false,
                    },
                    {
                        label: '运输方式',
                        prop: "mnotifyCntyName",
                        type: 'select',
                        filterable: true,
                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=mode_transport",
                        props: {
                            label: 'dictValue',
                            value: 'dictValue',
                        },
                        disabled: false,
                        rules: [{
                            required: true,
                            message: " ",
                            trigger: "blur"
                        }]
                    },
                    {
                        label: "发货人",
                        prop: "hshipperCnName",
                        disabled: false,
                    },
                    {
                        label: "收货人",
                        prop: "hconsigneeCnName",
                        disabled: false,
                    },
                    {
                        label: "船名",
                        prop: "vesselCnName",
                        disabled: false,
                    },
                    {
                        label: "航次",
                        prop: "voyageNo",
                        overHidden: true,
                    },
                    {
                        label: '起运港',
                        prop: "polCnName",
                        disabled: false,
                    },
                    {
                        label: '目的港',
                        prop: "podCnName",
                        disabled: false,
                    },
                    {
                        label: "开船日期",
                        prop: "etd",
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd",
                    },
                    {
                        label: "预计到港",
                        prop: "bookingDate",
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd",
                    },
                    {
                        label: "实际到港",
                        prop: "eta",
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd",
                    },
                    {
                        label: "船公司",
                        prop: "carrierCnName",
                        disabled: false,
                    },
                    {
                        label: '装箱方式',
                        prop: "loadType",
                        type: 'select',
                        dicData: [{
                            label: '整箱',
                            value: 'FCL'
                        }, {
                            label: '拼箱',
                            value: 'LCL'
                        }],
                        disabled: false,
                    },
                    {
                        label: "HSCODE",
                        prop: "hscode",
                        disabled: false,
                    },
                    {
                        label: "件数",
                        prop: "quantity",
                        disabled: false,
                    },
                    {
                        label: "包装",
                        prop: "packing",
                        disabled: false,
                    },
                    {
                        label: "尺码",
                        prop: "measurement",
                        disabled: false,
                    },
                    {
                        label: "重量",
                        prop: "grossWeight",
                        disabled: false,
                    },
                    {
                        label: "净重",
                        prop: "netWeight",
                        disabled: false,
                    },
                    {
                        label: "是否退押",
                        prop: "billingStatus",
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        disabled: false,
                    },
                    {
                        label: "放单方式",
                        prop: "mconsigneeCntyCode",
                        type: 'select',
                        filterable: true,
                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=release_method",
                        props: {
                            label: 'dictValue',
                            value: 'dictValue',
                        },
                        disabled: false,
                    },
                    {
                        label: "免箱期",
                        prop: "iqNo",
                        disabled: false,
                    },
                    {
                        label: '报关单号',
                        prop: "mnotify2CntyName",
                        width: "100",
                        overHidden: true
                    },
                    {
                        label: "报关日期",
                        prop: "issueDate",
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd",
                    },
                    {
                        label: "放行日期",
                        prop: "cyReturnTime",
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd",
                    },
                    {
                        label: "提箱码头",
                        prop: "charData",
                        type: 'select',
                        filterable: true,
                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=container_terminal",
                        props: {
                            label: 'dictValue',
                            value: 'dictValue',
                        },
                        disabled: false,
                    },
                    {
                        label: '业务员',
                        prop: "srcCnName",
                        disabled: false,
                    },
                    {
                        label: '备注',
                        prop: "remarks",
                        type: 'textarea',
                        disabled: false,
                        span: 6,
                        minRows: 2,
                    },
                ]
            },
            option: {},
            optionBack: {
                height: 'auto',
                calcHeight: 30,
                menuWidth: 120,
                tip: false,
                border: true,
                index: true,
                addBtn: false,
                viewBtn: false,
                editBtn: false,
                delBtn: false,
                refreshBtn: false,
                selection: true,
                align: 'center',
                column: [
                    {
                        label: "箱型",
                        prop: "cntrTypeCode",
                        width: "120",
                        overHidden: true,
                    },
                    {
                        label: "箱号",
                        prop: "boxNo",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "品名",
                        prop: "goodsName",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "件数",
                        prop: "quantity",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "重量",
                        prop: "grossWeight",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "单价",
                        prop: "price",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "查验类型",
                        prop: "inspectionType",
                        cell: true,
                        type: 'select',
                        filterable: true,
                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=inspection_type",
                        props: {
                            label: 'dictValue',
                            value: 'dictValue',
                        },
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "查验时间",
                        prop: "inspectionDate",
                        width: "120",
                        cell: true,
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd 00:00:00",
                        overHidden: true
                    },
                    {
                        label: "是否机检",
                        prop: "whetherMachineInspection",
                        cell: true,
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "是否取样",
                        prop: "whetherSampling",
                        cell: true,
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "是否入库",
                        prop: "whetherWarehousing",
                        cell: true,
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "是否返场",
                        prop: "whetherReturnSite",
                        cell: true,
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "备注",
                        prop: "remarks",
                        width: "120",
                        cell: true,
                        overHidden: true
                    }
                ]
            },
            option2: {},
            optionBack2: {
                height: 'auto',
                calcHeight: 30,
                menuWidth: 120,
                tip: false,
                border: true,
                index: true,
                addBtn: false,
                viewBtn: false,
                editBtn: false,
                delBtn: false,
                refreshBtn: false,
                selection: true,
                align: 'center',
                column: [
                    {
                        label: "承运车队",
                        prop: "fleetName",
                        width: "120",
                        overHidden: true,
                    },
                    {
                        label: "车号",
                        prop: "licenseNumber",
                        cell: true,
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "姓名",
                        prop: "fullName",
                        cell: true,
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "联系方式",
                        prop: "contactInformation",
                        cell: true,
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "是否入库",
                        prop: "whetherWarehousing",
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "提箱时间",
                        prop: "pickupDate",
                        cell: true,
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd 00:00:00",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "提箱地点",
                        prop: "pickupAddressName",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "送货时间",
                        prop: "deliveryDate",
                        width: "120",
                        cell: true,
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd 00:00:00",
                        overHidden: true
                    },
                    {
                        label: "送货地点",
                        prop: "deliveryAddressName",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "是否打冷",
                        prop: "whetherChill",
                        cell: true,
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "运费价格",
                        prop: "freightPrice",
                        cell: true,
                        type: 'number',
                        controls: false,
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "返空时间",
                        prop: "returnDate",
                        cell: true,
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd 00:00:00",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "返空场站",
                        prop: "returnCyName",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "箱号",
                        prop: "boxNo",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "备注",
                        prop: "remarks",
                        width: "120",
                        cell: true,
                        overHidden: true
                    }
                ]
            },
            option3: {},
            optionBack3: {
                height: 'auto',
                calcHeight: 30,
                menuWidth: 140,
                tip: false,
                border: true,
                index: true,
                addBtn: false,
                viewBtn: false,
                editBtn: false,
                delBtn: false,
                refreshBtn: false,
                selection: true,
                align: 'center',
                column: [
                    {
                        label: "仓库",
                        prop: "warehouseName",
                        width: "120",
                        overHidden: true,
                    },
                    {
                        label: "品名",
                        prop: "goodsName",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "箱号",
                        prop: "boxNo",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "入库单位",
                        prop: "storageUnit",
                        width: "120",
                        cell: true,
                        type: 'select',
                        filterable: true,
                        remote: true,
                        dicUrl: "/api/blade-los/bunits/list",
                        props: {
                            label: 'cnName',
                            value: 'cnName',
                            res: 'data.records'
                        },
                        overHidden: true
                    },
                    {
                        label: "入库时间",
                        prop: "storageDate",
                        width: "120",
                        cell: true,
                        type: "date",
                        format: "yyyy-MM-dd",
                        valueFormat: "yyyy-MM-dd 00:00:00",
                        overHidden: true
                    },
                    {
                        label: "单价",
                        prop: "price",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "件数",
                        prop: "quantity",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "毛重",
                        prop: "grossWeight",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "是否保税",
                        prop: "whetherBonded",
                        cell: true,
                        width: "120",
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        overHidden: true
                    },
                    {
                        label: "是否分拣",
                        prop: "whetherSorting",
                        width: "120",
                        cell: true,
                        type: 'select',
                        dicData: [{
                            label: '是',
                            value: 1
                        }, {
                            label: '否',
                            value: 0
                        }],
                        overHidden: true
                    },
                    {
                        label: "仓储单价",
                        prop: "warehouseUnitPrice",
                        cell: true,
                        type: 'number',
                        controls: false,
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "车号",
                        prop: "licenseNumber",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "姓名",
                        prop: "fullName",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "联系方式",
                        prop: "tel",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "备注",
                        prop: "remarks",
                        width: "120",
                        cell: true,
                        overHidden: true
                    }
                ]
            },
            option4: {},
            optionBack4: {
                height: 'auto',
                calcHeight: 30,
                menuWidth: 180,
                tip: false,
                border: true,
                index: true,
                addBtn: false,
                viewBtn: false,
                editBtn: false,
                delBtn: false,
                refreshBtn: false,
                selection: true,
                align: 'center',
                column: [
                    {
                        label: "品名",
                        prop: "goodsName",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "箱号",
                        prop: "boxNo",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "出库件数",
                        prop: "outQuantity",
                        width: "120",
                        cell: true,
                        type: 'number',
                        controls: false,
                        overHidden: true
                    },
                    {
                        label: "出库重量",
                        prop: "outWeight",
                        width: "120",
                        cell: true,
                        type: 'number',
                        controls: false,
                        overHidden: true
                    },
                    {
                        label: "件数",
                        prop: "quantity",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "毛重",
                        prop: "grossWeight",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "存储天数",
                        prop: "storageDays",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "仓储费",
                        prop: "storageFeesAmount",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "剩余件数",
                        prop: "surplusQuantity",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "剩余重量",
                        prop: "surplusWeight",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "剩余货值",
                        prop: "surplusGoodsAmount",
                        width: "120",
                        overHidden: true
                    },
                    {
                        label: "备注",
                        prop: "remarks",
                        width: "120",
                        cell: true,
                        overHidden: true
                    }
                ]
            },
        }
    },
    components: {
        dicSelect,
        feeInfo,
        checkSchedule
    },
    props: {
        detailData: Object
    },
    async created() {
        this.option = await this.getColumnData(this.getColumnName(388), this.optionBack);
        this.option2 = await this.getColumnData(this.getColumnName(389), this.optionBack2);
        this.option3 = await this.getColumnData(this.getColumnName(390), this.optionBack3);
        this.option4 = await this.getColumnData(this.getColumnName(391), this.optionBack4);
        if (this.detailData.id) {
            this.editButton = true
            this.editDisabled = true
            this.optionForm.disabled = true
            this.getDetails(this.detailData.id)
        }
        if (this.$route.query.billNo) {
            this.getDetaiByMblno(this.$route.query.billNo)
        }
        if (this.detailData.copyId) {
            this.getCopydate(this.detailData.copyId)
        }
    },
    methods: {
        getDetaiByMblno(billNo) {
            this.editButton = true
            this.editDisabled = true
            this.optionForm.disabled = true
            const loading = this.$loading({
                lock: true,
                text: '加载中',
                spinner: 'el-icon-loading',
                background: 'rgba(255,255,255,0.7)'
            });
            detailTradeByMblno({ mblno: this.$route.query.billNo }).then(res => {
                this.form = res.data.data
                this.$refs.crud.dicInit();
                this.$refs.crud3.dicInit();
            }).finally(() => {
                loading.close()
            })
        },
        dicChange(name, row) {
            if (name == 'corpCnName') {
                if (row) {
                    this.form.corpId = row.id
                } else {
                    this.form.corpId = null
                }
            }
            if (name == 'polCnName') {
                console.log(row)
                if (row) {
                    this.form.polId = row.id
                    this.form.polCode = row.code
                    this.form.polEnName = row.enName

                } else {
                    this.form.polId = null
                    this.form.polCode = null
                    this.form.polEnName = null
                }
            }
            if (name == 'podCnName') {
                if (row) {
                    this.form.polId = row.id
                    this.form.polCode = row.code
                    this.form.polEnName = row.enName
                } else {
                    this.form.polId = null
                    this.form.polCode = null
                    this.form.polEnName = null
                }
            }
            if (name == 'srcCnName') {
                if (row) {
                    this.form.srcId = row.id
                } else {
                    this.form.salesmansrcId = null
                }
            }
            if (name == 'hshipperCname') {
                if (row) {
                    this.form.hshipperId = row.id
                } else {
                    this.form.hshipperId = null
                }
            }
            if (name == 'hconsigneeCnName') {
                if (row) {
                    this.form.hconsigneeId = row.id
                } else {
                    this.form.hconsigneeId = null
                }
            }
            if (name == 'carrierCnName') {
                if (row) {
                    this.form.carrierId = row.id
                } else {
                    this.form.carrierId = null
                }
            }
            if (name == 'hscode') {
                if (row) {
                    this.form.goodsName = row.cnName
                } else {
                    this.form.goodsName = null
                }
            }
        },
        rowDicChange(name, row, el) {
            if (name == 'fleetName') {
                if (row) {
                    el.fullName = row.mgrName
                    el.contactInformation = row.tel
                } else {
                    el.fullName = null
                    el.contactInformation = null
                }
            }
            if (name == 'pickupAddressName') {
                if (row) {
                    el.pickupAddressId = row.id
                } else {
                    el.pickupAddressId = null
                }
            }
            if (name == 'deliveryAddressName') {
                if (row) {
                    el.deliveryAddressId = row.id
                } else {
                    el.deliveryAddressId = null
                }
            }
            if (name == 'warehouseName') {
                if (row) {
                    el.warehouseId = row.id
                } else {
                    el.warehouseId = null
                }
            }
        },
        rowCell(name, row, index) {
            if (name == '编辑') {
                console.log(2232323)
                if (row.$cellEdit == true) {
                    this.$set(row, "$cellEdit", false);
                } else {
                    this.$set(row, "$cellEdit", true);
                }
            }
            if (name == '派车') {
                if (row.whetherMachineInspection == 1) {
                    if (!row.inspectionType) {
                        return this.$message.error("查验类型不能为空");
                    }
                    if (!row.inspectionDate) {
                        return this.$message.error("查验时间不能为空");
                    }
                }
                let obj = {
                    ...row,
                    type: 1,
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });

                generateDispatchVehicles(obj).then(res => {
                    this.$message.success("派车成功");
                    this.getDetails(this.form.id)
                }).finally(() => {
                    loading.close()
                })
            }
            if (name == '自提') {
                let obj = {
                    ...row,
                    type: 2,
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                generateDispatchVehicles(obj).then(res => {
                    this.$message.success("自提成功");
                    this.getDetails(this.form.id)
                }).finally(() => {
                    loading.close()
                })
            }
            // if (name == '派车删除') {
            //     const loading = this.$loading({
            //         lock: true,
            //         text: '加载中',
            //         spinner: 'el-icon-loading',
            //         background: 'rgba(255,255,255,0.7)'
            //     });
            //     dispatchvehiclesRemove({ ids: row.id }).then(res => {
            //         this.$message.success("删除成功");
            //         this.form.dispatchVehiclesList.splice(index, 1);
            //     }).finally(() => {
            //         loading.close()
            //     })
            // }
            if (name == '确认派车') {
                if (!row.fleetName) {
                    return this.$message.error("承运车队不能为空");
                }
                if (!row.licenseNumber) {
                    return this.$message.error("车号不能为空");
                }
                if (!row.fullName) {
                    return this.$message.error("姓名不能为空");
                }
                if (!row.contactInformation) {
                    return this.$message.error("联系方式不能为空");
                }
                if (!row.deliveryDate) {
                    return this.$message.error("送货时间不能为空");
                }
                if (!row.deliveryAddressName) {
                    return this.$message.error("送货地点不能为空");
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                confirmDispatchVehicles(row).then(res => {
                    this.$message.success("派车成功");
                    this.getDetails(this.form.id)
                }).finally(() => {
                    loading.close()
                })
            }
            if (name == '生成入库') {
                if (!row.fleetName) {
                    return this.$message.error("承运车队不能为空");
                }
                if (!row.licenseNumber) {
                    return this.$message.error("车号不能为空");
                }
                if (!row.fullName) {
                    return this.$message.error("姓名不能为空");
                }
                if (!row.contactInformation) {
                    return this.$message.error("联系方式不能为空");
                }
                if (!row.deliveryDate) {
                    return this.$message.error("送货时间不能为空");
                }
                if (!row.deliveryAddressName) {
                    return this.$message.error("送货地点不能为空");
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                generateWarehouseEntry(row).then(res => {
                    this.$message.success("生成入库成功");
                    this.getDetails(this.form.id)
                }).finally(() => {
                    loading.close()
                })
            }
            if (name == '入库确认') {
                if (!this.form.eta) {
                    return this.$message.error("实际到港不能为空");
                }
                if (!row.warehouseName) {
                    return this.$message.error("仓库不能为空");
                }
                calculationWarehouseUnitPrice(row).then(res => {
                    this.$confirm(res.data.data, '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        dangerouslyUseHTMLString: true,
                    }).then(() => {
                        const loading = this.$loading({
                            lock: true,
                            text: '加载中',
                            spinner: 'el-icon-loading',
                            background: 'rgba(255,255,255,0.7)'
                        });
                        confirmWarehouseEntry(row).then(res => {
                            this.$message.success("入库成功");
                            this.getDetails(this.form.id)
                        }).finally(() => {
                            loading.close()
                        })
                    })
                })


            }
            if (name == '生成出库') {
                if (!row.warehouseName) {
                    return this.$message.error("仓库不能为空");
                }
                if (!row.warehouseUnitPrice) {
                    return this.$message.error("仓储单价不能为空");
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                generateOutbound(row).then(res => {
                    this.$message.success("生成出库成功");
                    this.getDetails(this.form.id)
                }).finally(() => {
                    loading.close()
                })
            }
            if (name == '出库确认') {
                if (!row.outQuantity) {
                    return this.$message.error("出库件数不能为空");
                }
                if (!row.outWeight) {
                    return this.$message.error("出库重量不能为空");
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                confirmWarehouseEntry(row).then(res => {
                    this.$message.success("出库成功");
                    this.getDetails(this.form.id)
                }).finally(() => {
                    loading.close()
                })
            }
            if (name == '开票') {
                this.$message.error("待开发");
            }
            if (name == '出库删除') {
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                inoutstorageRemove({ ids: row.id }).then(res => {
                    this.$message.success("删除成功");
                    this.form.outStorageList.splice(index, 1);
                }).finally(() => {
                    loading.close()
                })
            }
        },
        getDetails(id) {
            const loading = this.$loading({
                lock: true,
                text: '加载中',
                spinner: 'el-icon-loading',
                background: 'rgba(255,255,255,0.7)'
            });
            getDetail({ id: id }).then(res => {
                this.form = res.data.data
                this.$refs.crud.dicInit();
                this.$refs.crud3.dicInit();
            }).finally(() => {
                loading.close()
            })
        },
        getCopydate(id) {
            const loading = this.$loading({
                lock: true,
                text: '加载中',
                spinner: 'el-icon-loading',
                background: 'rgba(255,255,255,0.7)'
            });
            copyAgent({ id: id }).then(res => {
                this.form = res.data.data
                if (res.data.data.abroadConsignorId) {
                    this.$refs.abankCode.IdGetDicData({ id: res.data.data.abroadConsignorId })
                }
                if (res.data.data.domesticConsigneeId) {
                    this.$refs.dbankCode.IdGetDicData({ id: res.data.data.domesticConsigneeId })
                }
            }).finally(() => {
                loading.close()
            })
        },
        inEdit() {
            this.editButton = false
            if (this.form.status == 0 || this.form.status == 4) {
                this.editDisabled = false
                this.optionForm.disabled = false
            }
        },
        allClick(name) {
        },
        submit() {
            this.$refs["form"].validate((valid, done) => {
                done();
                if (valid) {
                    const loading = this.$loading({
                        lock: true,
                        text: '加载中',
                        spinner: 'el-icon-loading',
                        background: 'rgba(255,255,255,0.7)'
                    });
                    submit(this.form).then(res => {
                        this.$message.success("保存成功");
                        this.getDetails(res.data.data.id)
                    }).finally(() => {
                        loading.close();
                    })
                } else {
                    return false;
                }
            });
        },
        application() {
            if (this.form.feeCenterListD.length == 0 && this.form.feeCenterListC.length == 0) return this.$message.error("费用不能为空");
            this.$confirm("确定请核数据?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                let obj = {}
                obj = {
                    id: this.form.id,
                    url: '/tradeAgency/oceanFreightImport/index',
                    pageStatus: '',
                    pageLabel: '海运进口(T)',
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                checkAgent(obj).then(res => {
                    this.$message.success("请核成功");
                    this.editDisabled = true
                    this.optionForm.disabled = true
                    this.getDetails(res.data.data.id)
                }).finally(() => {
                    loading.close();
                })
            });
        },
        revokeApplication() {
            this.$confirm("确定撤销请核?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                let obj = {}
                obj = {
                    id: this.form.id,
                }
                const loading = this.$loading({
                    lock: true,
                    text: '加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255,255,255,0.7)'
                });
                revokeCheckAgent(obj).then(res => {
                    this.$message.success("撤销请核成功");
                    this.getDetails(res.data.data.id)
                    this.editDisabled = false
                    this.optionForm.disabled = false
                }).finally(() => {
                    loading.close();
                })
            });

        },
        //请核关闭
        choceScheduleFun() {
            this.checkScheduleDialog = false
        },
        //自定义列保存
        async saveColumn(ref, option, optionBack, code) {
            const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
            if (inSave) {
                this.$message.success("保存成功");
                //关闭窗口
                this.$refs[ref].$refs.dialogColumn.columnBox = false;
            }
        },
        //自定义列重置
        async resetColumn(ref, option, optionBack, code) {
            this[option] = this[optionBack];
            const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
            if (inSave) {
                this.$message.success("重置成功");
                this.$refs[ref].$refs.dialogColumn.columnBox = false;
            }
        },
        goBack(type) {
            this.$emit("goBack", type);
            this.$emit('updateKey')
        },
    }
}
</script>

<style lang="scss" scoped>
::v-deep .el-form-item {
    margin-bottom: 8px !important;
}

::v-deep .el-table .cell {
    padding: 0 2px !important;

    .el-form-item {
        margin-bottom: 0px !important;
    }

}

::v-deep .avue-crud .el-table .el-form-item__label {
    left: -1px;
}

::v-deep#out-table .back-one {
    background: #ecf5ff !important;
}

::v-deep#out-table .back-two {
    background: #ecf5ff !important;
}
</style>
