<template>
    <el-skeleton :rows="10" animated v-if="showSkeleton" />
    <div v-if="!showSkeleton">
        <el-card :body-style="cardBodyStyle" class="diaClass90">
            <el-card :body-style="cardBodyStyle" class="diaClass90">
                <el-form :inline="true" :model="queryForm" status-icon>
                    <el-form-item>
                        <el-input v-model="queryForm.tem" placeholder="支持模糊查询/物资名称/发货单位/收货单位/车号"
                            style="margin-left: 20px;width: 318px;" clearable>
                        </el-input>
                        <div style="margin-left: 20px;"></div>
                        <el-switch v-model="switchOpen" size="large" @change="openchange" active-text="自动推送数据" />

                    </el-form-item>
                </el-form>
            </el-card>
            <el-card><el-button type="primary" plain @click="handleExport" style="">导出全部列表数据</el-button><el-button
                    type="primary" @click="dwQuery">查询</el-button></el-card>

            

            <el-card>
                <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">

                    <el-tab-pane label="已发货" name="ysh">
                        <el-card :body-style="cardBodyStyle">
                            <el-table :data="yshTableData" border highlight-current-row
                                @selection-change="handleSelectionChange">
                                <el-table-column type="index" label="序号" width="80" header-align="center" align="center"
                                    show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="true" prop="jlh" label="计量号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="ybid" label="运单号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="true" prop="wuzimc" label="物资名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="carno" label="车号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="storageOperatorname" label="收货人" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="storagetime" label="收货时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="fhdwmc" label="发货单位名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="shdwmc" label="收货单位名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="storaged" label="收货确认" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="false" prop="kzh" sortable label="扣吨(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="jszl" sortable label="结算重量(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="fdrivername" label="司机姓名" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>


                                <el-table-column v-if="true" prop="wtdwmc" label="承运商" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="ckmc" label="仓库名称" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lsmz" sortable label="来时毛重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lspz" sortable label="来时皮重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lsjz" sortable label="来时净重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="mzh" sortable label="毛重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="pzh" sortable label="实际皮重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="jzh" sortable label="实际净重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="rossTime" sortable label="计毛时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="tareTime" sortable label="皮重时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="suttleTime" sortable label="净重时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="ddsj" sortable label="等待时间(分)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="xcys" sortable label="卸车用时(分)???" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="true" fixed="right" label="重载" width="150" header-align="center"
                                    align="center" show-overflow-tooltip>
                                    <template #default="scope">
                                        <p></p>

                                        <el-button size="small" type="primary" plain
                                            @click="resetLoad(scope.row)"><el-icon>
                                                <EditPen />
                                            </el-icon>重载</el-button>
                                    </template>
                                </el-table-column>
                                <el-table-column fixed="right" v-if="false" label="查看" width="80" header-align="center"
                                    align="center" show-overflow-tooltip>
                                    <template #default="{ row }">
                                        <p>
                                        <p @click="confirmPre(row)" style="cursor: pointer;">
                                            <el-icon>
                                                <InfoFilled />
                                            </el-icon>
                                        </p>
                                        </p>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-card>
                        <el-card :body-style="cardBodyStyle">
                            <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize"
                                :page-sizes="[5, 10, 15, 20]" :background="background"
                                layout="total, sizes, prev, pager, next, jumper" :total="yshTotal"
                                @size-change="handleSizeChange" @current-change="handleCurrentChange" />
                        </el-card>
                    </el-tab-pane>
                    <el-tab-pane label="待发货" name="dsh">
                        <el-card :body-style="cardBodyStyle">
                            <el-table :data="dshTableData" border highlight-current-row
                                @selection-change="handleSelectionChange">
                                <el-table-column type="index" label="序号" width="80" header-align="center" align="center"
                                    show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="true" prop="jlh" label="计量号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="ybid" label="运单号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="true" prop="wuzimc" label="物资名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="carno" label="车号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="storageOperatorname" label="收货人" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="fhdwmc" label="发货单位名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="storaged" label="发货确认" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>

                                </el-table-column>
                                <el-table-column v-if="false" prop="kzh" label="扣吨(t)" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="jszl" label="结算重量(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="fdrivername" label="司机姓名" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="shdwmc" label="收货单位名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="carno" label="车号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="wtdwmc" label="承运商" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="ckmc" label="仓库名称" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lsmz" label="来时毛重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="lspz" label="皮重(t)" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lsjz" label="来时净重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="mzh" label="实际毛重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="mzc" label="毛重差(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="pzh" label="实际皮重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="jzh" label="实际净重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="rossTime" label="计毛时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="tareTime" label="皮重时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="suttleTime" label="净重时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="ddsj" label="等待时间(分)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="xcys" label="卸车用时(分)???" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column fixed="right" label="收货" width="150" header-align="center"
                                    align="center" show-overflow-tooltip>
                                    <template #default="scope">
                                        <el-button size="small" type="primary" plain
                                            @click="confirmPre(scope.row)"><el-icon>
                                                <EditPen />
                                            </el-icon>确认发货</el-button>
                                    </template>
                                </el-table-column>
                                <el-table-column fixed="right" v-if="false" label="查看" width="80" header-align="center"
                                    align="center" show-overflow-tooltip>
                                    <template #default="{ row }">
                                        <p>
                                        <p @click="confirmPre(row)" style="cursor: pointer;">
                                            <el-icon>
                                                <InfoFilled />
                                            </el-icon>
                                        </p>
                                        </p>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-card>
                        <el-card :body-style="cardBodyStyle">

                            <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize"
                                :page-sizes="[5, 10, 15, 20]" :background="background"
                                layout="total, sizes, prev, pager, next, jumper" :total="dshTotal"
                                @size-change="handleSizeChange" @current-change="handleCurrentChange" />
                        </el-card>
                    </el-tab-pane>

                    <el-tab-pane label="全部" name="qb">
                        <el-card :body-style="cardBodyStyle">
                            <el-table style="width: 100%" :data="tableData" border :row-style="rowStyle"
                                @selection-change="handleSelectionChange">
                                <el-table-column type="index" label="序号" width="80" header-align="center" align="center"
                                    show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="jlh" label="计量号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="ybid" label="运单号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="wuzimc" label="物资名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="carno" label="车号" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="false" prop="storageOperatorname" label="操作人" width="100"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="fhdwmc" label="发货单位名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="shdwmc" label="收货单位名称" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="storaged" label="收货确认" width="81"
                                    header-align="center" align="center" show-overflow-tooltip>
                                    <template #default="scope">
                                        {{ scope.row.storaged == 1 ? '是' : '否' }}
                                    </template>
                                </el-table-column>
                                <el-table-column v-if="false" prop="kzh" sortable label="扣吨(t)" width="100"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="jszl" sortable label="结算重量(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="fdrivername" label="司机姓名" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>


                                <el-table-column v-if="true" prop="wtdwmc" label="承运商" width="200" header-align="center"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="ckmc" label="仓库名称" header-align="center" width="150"
                                    align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lsmz" sortable label="来时毛重(t)" width="130"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lspz" sortable label="来时皮重(t)" header-align="center"
                                    width="130" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="lsjz" sortable label="来时净重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="mzh" sortable label="毛重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="pzh" sortable label="实际皮重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="jzh" sortable label="实际净重(t)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="rossTime" sortable label="计毛时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="true" prop="tareTime" sortable label="皮重时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="suttleTime" sortable label="净重时间" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="ddsj" sortable label="等待时间(分)" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column v-if="false" prop="xcys" sortable label="卸车用时(分)???" width="200"
                                    header-align="center" align="center" show-overflow-tooltip>
                                </el-table-column>

                                <el-table-column v-if="false" fixed="right" label="收货" width="150" header-align="center"
                                    align="center" show-overflow-tooltip>
                                    <template #default="scope">
                                        <p></p>

                                        <el-button type="primary" plain @click="confirmPre(scope.row)"><el-icon>
                                                <EditPen />
                                            </el-icon>确认发货</el-button>
                                    </template>
                                </el-table-column>
                                <el-table-column fixed="right" v-if="false" label="查看" width="80" header-align="center"
                                    align="center" show-overflow-tooltip>
                                    <template #default="{ row }">
                                        <p>
                                        <p @click="confirmPre(row)" style="cursor: pointer;">
                                            <el-icon>
                                                <InfoFilled />
                                            </el-icon>
                                        </p>
                                        </p>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-card>
                        <el-card :body-style="cardBodyStyle">
                            <div style="display: flex;width: 100%;align-items: center;">
                                <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize"
                                    :page-sizes="[5, 10, 15, 20]" :background="background"
                                    layout="total, sizes, prev, pager, next, jumper" :total="total"
                                    @size-change="handleSizeChange" @current-change="handleCurrentChange" />
                                &nbsp &nbsp &nbsp &nbsp &nbsp <p
                                    style="height: 25px;width: 25px;background-color: rgb(188, 216, 190);"></p>
                                &nbsp已发货&nbsp &nbsp

                            </div>
                        </el-card>
                    </el-tab-pane>
                </el-tabs>

            </el-card>

        </el-card>


        <!-- 收货凭证弹出框 -->
        <el-dialog :close-on-click-modal="false" draggable title="发货凭证" v-model="dialogVisibleM" width="1200px">
            <div>
                <el-card :body-style="cardBodyStyle">
                    <Attachment ref="AttachmentRefManual" :fId="fId"></Attachment>
                </el-card>
            </div>
        </el-dialog>

        <el-dialog :close-on-click-modal="false" draggable title="发货确认" v-model="dialogVisible" width="1000px"
            top="18vh">
            <div>
                <el-button plain @click="uploadSHPhoto">发货凭证
                </el-button>
                <el-button type="primary" @click="ConfrimSure">发货确认后关闭</el-button>
            </div><br>

            <!-- 此处是列表描述 -->
            <el-card :body-style="cardBodyStyle" class="diaClass90">
                <el-descriptions title="详细信息" :column="4">
                    <el-descriptions-item label="计量号：">{{ jlzbData.jlh }}</el-descriptions-item>
                    <el-descriptions-item label="运单号：">{{ jlzbData.ybid }}</el-descriptions-item>
                    <el-descriptions-item label="物资名称：">{{ jlzbData.wuzimc }}</el-descriptions-item>
                    <el-descriptions-item label="车号：">{{ jlzbData.carno }}</el-descriptions-item>

                    <el-descriptions-item label="发货单位：">{{ jlzbData.frcvstationcode }}</el-descriptions-item>
                    <el-descriptions-item label="承运商：">{{ jlzbData.wtdwmc }}</el-descriptions-item>
                    <el-descriptions-item label="收货单位：">{{ jlzbData.frcvstation }}</el-descriptions-item>
                    <el-descriptions-item label="皮重：">{{ jlzbData.pzh }}</el-descriptions-item>

                    <el-descriptions-item label="皮重时间：">{{ jlzbData.tareTime }}</el-descriptions-item>
                    <el-descriptions-item label="入场时间：">{{ ydData.ftin }}</el-descriptions-item>

                </el-descriptions>
            </el-card>

        </el-dialog>


    </div>
</template>

<script setup>
/**
 * 必写
 */
import {
    onUnmounted,
    ref,
    reactive,
    onMounted,
    getCurrentInstance,
    nextTick
} from 'vue'

const {
    proxy
} = getCurrentInstance()

import tools from '@/tools'
import Popup_sto_config_one from "@/views/sto/components/Popup_sto_config_one.vue";
/**
 * 必写
 */

/**
 * 重载
 */
const resetLoad = (row) => {
    if (ydData.value.fstatus == 'F' || ydData.value.fstatus == 'f') {
        ElMessage.warning("车辆已出厂，无法重载")
        return
    }
    ElMessageBox.confirm(
        '您确认要重载吗?',
        '警告',
        {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning',
        }
    )
        .then(() => {
            var url = 'wgt/Qchjlxx/fhResetLoad'
            czConfirm.value.id = row.id
            czConfirm.value.storaged = 0


            var json = {
                json: JSON.stringify(czConfirm.value)
            }
            proxy.$axios.get(url, json).then(response => {
                if (response.data.code == '0') {
                    ydData.value = { ...response.data.data }
                    resetczConfirm()
                    query()
                    ElMessage.success('操作成功')
                } else {
                    ElMessage.error('操作失败！' + response.data.msg)
                    resetczConfirm()
                    query()
                }
            })
            dialogVisible.value = false
        })
        .catch(() => {
            ElMessage({
                type: 'info',
                message: '取消操作',
            })
        })
}
/**
 * 重载
 */

/**
 * 刷新页面用
 */
// 控制骨架屏显示的变量
const showSkeleton = ref(false)
function reloadPage() {
    showSkeleton.value = true;

    setTimeout(() => {
        location.reload();
    }, 1000);
}
/**
 * 刷新页面用
 */

/**
 * 仓库选择
 */
const retu = (val) => {
    czConfirm.value.ckmc = val.value
    czConfirm.value.ckbm = val.storeCd
}
/**
 * 仓库选择
 */

const cardBodyStyle = ref(tools.style.card)
const inputStyle = ref(tools.style.input)
// import Attachment from '../../components/Attachment.vue';
import Attachment from '../../../components/Attachment.vue'

import { ElMessage, ElSkeleton } from 'element-plus';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter()
const route = useRoute()

const localStorageDeptTree = ref()
onMounted(() => {
    localStorage.setItem('activeName', 'dsh')
    query()
    localStorageDeptTree.value = JSON.parse(localStorage.getItem("deptTree"))
    localStorageDeptTree.value = localStorageDeptTree.value[0]
})

/**
 * 所属类目配置
 */
//已收货
const yshTableData = ref([])
const yshTotal = ref(0)
//待收货
const dshTableData = ref([])
const dshTotal = ref(0)
//复磅
const fbTableData = ref([])
const fbTotal = ref(0)
//整车退货
const thTableData = ref([])
const thTotal = ref(0)

const activeName = ref(localStorage.getItem('activeName'))

const handleClick = (tab, event) => {
    //每次点击标签都会回到第一页
    currentPage.value = 1
    query()
}
/**
 * 所属类目配置
 */

/**
 * 自动推送数据
 */
// localStorage.setItem("switchOpen","false")
const switchOpen = ref(false)
const intervalId = ref(null);

const openchange = (val) => {
    aa()
};

const aa = () => {
    if (switchOpen.value) {
        startTimer()
    } else {
        stopTimer()
    }
}

const bb = () => {
    query()
}

const startTimer = () => {
    if (intervalId.value) {
        return;
    }
    intervalId.value = setInterval(bb, 10000);
};

const stopTimer = () => {
    if (intervalId.value) {
        clearInterval(intervalId.value);
        intervalId.value = null;
    }
};

onUnmounted(() => {
    if (intervalId.value) {
        clearInterval(intervalId.value);
    }
});

/**
 * 自动推送数据
 */

/**
 * 行样式
 * @param param0 
 */
const rowStyle = ({ row, rowIndex }) => {
    if (row.storaged == 2) {
        return {
            background: 'rgb(192, 188, 216)'
        };
    } else if (row.storaged == 1) {
        return {
            background: 'rgb(188, 216, 190)'
        }
    } else if (row.storaged == 3) {
        return {
            background: '#969a98'
        }
    }

    return ''
};
/**
 * 行样式
 * @param param0 
 */

/**
 *   查询
 */




const queryForm = ref({
    tem: '',
    ywlxid: '',
})

const tableData = ref([])

const dwQuery = () => {
    currentPage.value = 1
    query()
}

const query = () => {
    var url = 'wgt/Qchjlxx/queryFh'
    queryForm.value.ywlxid = '02'
    var param = {
        page: currentPage.value,
        rows: pageSize.value,
        params: JSON.stringify(queryForm.value)
    }

    proxy.$axios.get(url, param).then(response => {
        if (response.data.code == '0') {
            //全部数据
            tableData.value = response.data.data.list
            total.value = response.data.data.total

            dshTableData.value = response.data.data.dshList
            yshTableData.value = response.data.data.yshList
            fbTableData.value = response.data.data.fbList
            thTableData.value = response.data.data.thList

            dshTotal.value = response.data.data.dshTotal
            yshTotal.value = response.data.data.yshTotal
            fbTotal.value = response.data.data.fbTotal
            thTotal.value = response.data.data.thTotal
        } else {
            ElMessage.error('操作失败！' + response.data.msg)
        }
    })
}
/**
 *   查询
 */

/**
 * 收货确认
 */
//是否扣吨
const sfkdDisable = ref(false)
//根据运单号查运单表数据
const ydData = ref([])
//计量主表单行数据
const jlzbData = ref([])

/**
 * 修改用
 */
const czConfirm = ref({
    id: '',
    fhdwmc: '',
    fhdwbm: '',
    storaged: ''
})
const resetczConfirm = () => {
    czConfirm.value = {
        id: '',
        fhdwmc: '',
        fhdwbm: '',
        storaged: ''
    }
}
/**
 * 修改用
 */

//收货凭证上传
const uploadSHPhoto = () => {
    nextTick(() => {
        dialogVisibleM.value = true
        fId.value = jlzbData.value.id
        query()
    })
}
//收货确认，访问后端接口
const ConfrimSure = (row) => {
    if (ydData.value.fstatus == 'F' || ydData.value.fstatus == 'f') {
        ElMessage.warning("车辆已出厂，无法重载")
        return
    }
    ElMessageBox.confirm(
        '您确认要发货吗?',
        '警告',
        {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning',
        }
    )
        .then(() => {
            var url = 'wgt/Qchjlxx/saveFh'
                czConfirm.value.id = jlzbData.value.id
                czConfirm.value.storaged = 1
                czConfirm.value.fhdwmc = localStorageDeptTree.value.deptName
                czConfirm.value.fhdwbm = localStorageDeptTree.value.deptCode


                var json = {
                    json: JSON.stringify(czConfirm.value)
                }
                proxy.$axios.get(url, json).then(response => {
                    if (response.data.code == '0') {
                        ydData.value = { ...response.data.data }
                        resetczConfirm()
                        query()
                    } else {
                        ElMessage.error('操作失败！' + response.data.msg)
                        resetczConfirm()
                        query()
                    }
                })
                dialogVisible.value = false
        })
        .catch(() => {
            ElMessage({
                type: 'info',
                message: '取消操作',
            })
        })
}

//确认弹窗
const dialogVisible = ref(false)


const confirmPre = (row) => {
    query()

    jlzbData.value = row

    dialogVisible.value = true

    var url = 'tms/TmsWaybill/queryByfbillno'
    var param = {
        fbillno: row.ybid,
    }
    proxy.$axios.get(url, param).then(response => {
        if (response.data.code == '0') {
            ydData.value = { ...response.data.data }
        } else {
            ElMessage.error('操作失败！' + response.data.msg)
        }
    })
}

//上传图片的
const dialogVisibleM = ref(false)


/**
 * 发货确认
 */

/**
 * 上传
 */

const fId = ref('x')
const AttachmentRefManual = ref(null)

/**
 * 上传
 */


/**
 * 分页
 */
const currentPage = ref(1)
const total = ref(0)
const pageSize = ref(5)
const handleSizeChange = (val) => {
    pageSize.value = val
    query()
}
const handleCurrentChange = (val) => {
    currentPage.value = val
    query()
}
/**
 * 分页
 */

/**
 * 导出表格
 */
const handleExport = () => {
    location.href = import.meta.env.VITE_BASE_API + '/wgt/excel/exportFhAll'
}
/**
 * 导出表格
 */

const multipleSelection = ref([])
const handleSelectionChange = (val) => {
    multipleSelection.value = val
}



</script>

<style scoped>
::v-deep .diaClass90 .el-form-item {
    width: 90%
}

.el-descriptions {
    margin-top: 20px;
}

.cell-item {
    display: flex;
    align-items: center;
}

.margin-top {
    margin-top: 20px;
    background-color: #969a98;
}
</style>