陈婷婷
2026-04-03 32d02ad7839e63d0c721de8a2b243f531e5272d0
src/views/logistics/transportGPS/WL_YayBill.vue
@@ -17,8 +17,25 @@
                </el-select>
            </el-form-item>
            <el-form-item label="单据号" prop="HBillNo">
                <el-input v-model="queryParams.HBillNo" placeholder="请输入单据号" @keyup.enter.native="handleQuery" />
                <el-input v-model="queryParams.HBillNo" placeholder="请输入单据号" @keyup.enter.native="handleQuery"
                    style="width: 150px;" />
            </el-form-item>
            <el-form-item label="车牌号" prop="HPlateNumber">
                <el-input v-model="queryParams.HPlateNumber" placeholder="请输入车牌号" @keyup.enter.native="handleQuery"
                    style="width: 120px;" />
            </el-form-item>
            <el-form-item label="发货通知单" prop="HSourceBillNo">
                <el-input v-model="queryParams.HSourceBillNo" placeholder="请输入发货通知单" @keyup.enter.native="handleQuery"
                    style="width: 120px;" />
            </el-form-item>
            <el-form-item label="物流状态" prop="HBillStatus">
                <el-select v-model="queryParams.HBillStatus" placeholder="请选择物流状态">
                    <el-option v-for="(item, index) in HBillStatusList" :key="index" :label="item.Name"
                        :value="item.Name">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="组织" prop="HOrgID">
                <el-select v-model="queryParams.HOrgID" placeholder="请选择组织">
                    <el-option v-for="(item, index) in organizationList" :key="index" :label="item.Name"
@@ -143,8 +160,32 @@
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="set_CheckBill(0, form = rowForm)">审核</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="set_CheckBill(1, form = rowForm)">反审核</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="single"
                    @click="handleVolume(rowForm)">维护零单占用体积</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="single"
                    @click="set_ConfirmBill">供应商确认</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="hanleCarOrDriver(form = rowForm)">分配车辆和司机</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="openDataDialog(14, form = rowForm)">分配车辆</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="openDataDialog(15, form = rowForm)">分配司机</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="single"
@@ -162,29 +203,9 @@
                <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="single"
                    @click="set_ConfirmOtherBill(4)">到货签收确认</el-button>
            </el-col>
            <!-- <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="single"
                    @click="set_CheckBill(0, form = rowForm)">分配司机</el-button>
            </el-col> -->
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="single"
                    @click="handleVolume(rowForm)">维护零单占用体积</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini"
                    @click="handlePush(row = rowForm, OperationType = 4)">下推(费用结算单)</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="openDataDialog(14, form = rowForm)">分配司机</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="set_CheckBill(0, form = rowForm)">审核</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
                    @click="set_CheckBill(1, form = rowForm)">反审核</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-edit-outline" size="mini" :disabled="single"
@@ -203,22 +224,22 @@
                    @click="set_DropBill(2, form = rowForm)">反作废</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-printer" size="mini" @click="get_PrintReport">打印</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-date" size="mini" @click="handleRowHide">隐藏列设置</el-button>
            </el-col>
            <!-- <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-printer" size="mini" @click="get_PrintReport">打印</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-printer" size="mini" :disabled="single"
                    @click="get_BarCodeDetail">条码明细</el-button>
                <el-button type="primary" icon="el-icon-upload" size="mini" :disabled="single"
                    @click="handleFileUpload">附件上传</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-printer" size="mini" :disabled="single"
                    @click="get_PackStockDetail">包装容器出入库明细</el-button>
            </el-col>-->
                <el-button type="primary" icon="el-icon-download" size="mini" :disabled="multiple"
                    @click="handleBatchFileDownload">附件下载</el-button>
            </el-col> -->
        </el-row>
        <div class="tableBox" v-loading="loading">
            <el-table :data="tableData" ref="tableData" max-height="710" :summary-method="getSummaries"
@@ -246,8 +267,9 @@
                </template>
            </el-table>
            <!-- 记录数、页数、当前页 -->
            <pagination v-show="total > 0" :total="total" :page.sync="page" :limit.sync="pageSize"
                @pagination="handleQuery" />
            <!-- <pagination v-show="total > 0" :total="total" :page.sync="page" :limit.sync="pageSize"
                @pagination="handleQuery" /> -->
            <pagination v-show="total > 0" :total="total" :page.sync="page" :limit.sync="pageSize" :pageSizes="pageSizes" @pagination="getList" />
            <!-- 列设置 -->
            <el-dialog title="隐藏列设置" :visible.sync="openRowHide" width="816px" append-to-body>
                <RowSettings :colName="btResList" :HModName="HModName" @rowEditClose="rowSetClose" v-if="rowHideShow" />
@@ -261,8 +283,8 @@
            </el-dialog>
            <!-- 打印 -->
            <el-dialog title="打印模板选择" :visible.sync="openPrintList" width="800px" append-to-body>
                <PrintList :linterid=this.rowForm.HInterID :MyMsg=this.rowForm.HInterID :Type='HBillType'
                    :HModName="HModName" @rowEditClose="rowSetClose" v-if="printListShow" />
                <PrintList :linterid='printIds' :MyMsg='printIds' :Type='HBillType' :HModName="HBillType"
                    @rowEditClose="rowSetClose" v-if="printListShow" />
                <!-- <div>111</div> -->
            </el-dialog>
@@ -272,7 +294,8 @@
                        <el-input v-model="formVolume.单据号" placeholder="请输入单据号" disabled />
                    </el-form-item>
                    <el-form-item label="零单占用体积">
                        <el-input-number v-model="formVolume.currentVolume" placeholder="请输入零单占用体积" />
                        <el-input-number v-model="formVolume.currentVolume"
                            :placeholder="`零担体积: ${formVolume.零担体积 || 0}`" />
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
@@ -298,6 +321,88 @@
                    <el-button @click="deptClose">取 消</el-button>
                </div>
            </el-dialog>
            <!-- 分配车辆和司机 -->
            <el-dialog title="分配车辆和司机" :visible.sync="openCarDriver" width="500px" append-to-body>
                <el-form ref="carDriverForm" :model="carDriverForm" :rules="carDriverRules" label-width="100px">
                    <el-form-item label="车牌号" prop="CarHNumber">
                        <el-input v-model="carDriverForm.CarHNumber" placeholder="请输入车牌号" />
                    </el-form-item>
                    <el-form-item label="车辆名称" prop="CarHName">
                        <el-input v-model="carDriverForm.CarHName" placeholder="请输入车辆名称" />
                    </el-form-item>
                    <el-form-item label="驾驶员" prop="DriverHName">
                        <el-input v-model="carDriverForm.DriverHName" placeholder="请输入驾驶员" />
                    </el-form-item>
                    <el-form-item label="身份证号" prop="DriverHIDCard">
                        <el-input v-model="carDriverForm.DriverHIDCard" placeholder="请输入身份证号" />
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="submitCarDriver">确 定</el-button>
                    <el-button @click="openCarDriver = false">取 消</el-button>
                </div>
            </el-dialog>
            <!-- 附件上传 -->
            <el-dialog title="附件上传" :visible.sync="openFileUpload" width="600px" append-to-body>
                <el-form ref="fileUploadForm" label-width="100px">
                    <el-form-item label="单据号">
                        <el-input v-model="fileUploadForm.billNo" disabled />
                    </el-form-item>
                    <el-form-item label="附件">
                        <el-upload class="upload-demo" ref="fileUpload" :headers="upload.headers" action="http://220.189.218.155:9010/File" :on-preview="handleFilePreview"
                            :on-remove="handleFileRemove" :on-change="handleFileChange" :file-list="fileList"  :on-success="handleFileSuccess" :on-error="handleFileError"
                             :limit="10" :on-exceed="handleFileExceed"
                            accept=".jpg,.png,.jpeg,.pdf,.doc,.docx,.xls,.xlsx,.zip,.rar">
                            <el-button size="small" type="primary">点击上传</el-button>
                            <div slot="tip" class="el-upload__tip">
                                支持上传jpg/png/jpeg/pdf/doc/docx/xls/xlsx/zip/rar格式文件,最多10个</div>
                        </el-upload>
                    </el-form-item>
                    <el-form-item label="已上传附件" v-if="uploadedFileList.length > 0">
                        <el-table :data="uploadedFileList" border size="small" max-height="200">
                            <el-table-column label="文件名" prop="name" align="center" show-overflow-tooltip />
                            <el-table-column label="上传时间" prop="uploadTime" align="center" width="150" />
                            <el-table-column label="操作" align="center" width="100">
                                <template slot-scope="scope">
                                    <el-button type="text" size="small" @click="downloadFile(scope.row)">下载</el-button>
                                    <el-button type="text" size="small" style="color: red;"
                                        @click="deleteUploadedFile(scope.row, scope.$index)">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <!-- <el-button type="primary" @click="submitFileUpload" :loading="fileUploadLoading">上传</el-button> -->
                    <el-button @click="openFileUpload = false">关 闭</el-button>
                </div>
            </el-dialog>
            <!-- 附件批量下载 -->
            <el-dialog title="附件批量下载" :visible.sync="openBatchDownload" width="900px" append-to-body>
                <div style="margin-bottom: 10px;">
                    <el-alert :title="`已选择 ${selectedBillCount} 条单据,共 ${batchFileList.length} 个附件`" type="info"
                        show-icon :closable="false" />
                </div>
                <el-table :data="batchFileList" border v-loading="batchDownloadLoading" max-height="400"
                    @selection-change="handleBatchFileSelectionChange">
                    <el-table-column type="selection" width="55" align="center" />
                    <el-table-column label="单据号" prop="billNo" align="center" width="150" show-overflow-tooltip />
                    <el-table-column label="文件名" prop="name" align="center" show-overflow-tooltip />
                    <el-table-column label="文件类型" prop="fileType" align="center" width="100" />
                    <el-table-column label="上传时间" prop="uploadTime" align="center" width="150" />
                    <el-table-column label="操作" align="center" width="80">
                        <template slot-scope="scope">
                            <el-button type="text" size="small" @click="downloadSingleFile(scope.row)">下载</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="batchDownloadFiles" :loading="batchDownloadLoading"
                        :disabled="selectedBatchFiles.length === 0">批量下载选中</el-button>
                    <el-button type="primary" @click="downloadAllFiles" :loading="batchDownloadLoading">下载全部</el-button>
                    <el-button @click="openBatchDownload = false">关 闭</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</template>
@@ -318,15 +423,38 @@
    components: { BarCodeDetail, PackStockDetail, Edit, RowSettings, PrintList, PayMentOtherBillTranEdit, GyCar, GyDriver },
    data() {
        return {
            upload: {
                // 是否显示弹出层
                open: false,
                // 弹出层标题
                title: "",
                // 是否禁用上传
                isUploading: false,
                // 是否更新已经存在的数据
                updateSupport: 0,
                // 设置上传的请求头部
                 headers: {  'Content-Type': 'multipart/form-data'},
                // 上传的地址
                url: 'http://220.189.218.155:9010/File'
            },
            baseURL: process.env.VUE_APP_BASE_API,                //后端接口前缀(后端服务器ip地址)
            HModName: "Cg_ContractTransportBillMainList",
            HBillType: "Cg_ContractTransportBillMainList",
            HBillType: "WL_YayBill",
            OperationType: null,                                  //保存类型(新增1修改3)
            copyType: 0,                                          //复制标记。打开编辑组件时,用于区分编辑还是复制
            HInterID: null,
            hPriceTypeList: ['成本价', '结算价'],
            HBillStatusList:[
                {ID: 1, Name: "申请中" },
                {ID: 2, Name: "待供应商确认" },
                {ID: 3, Name: "指定驾驶员、车辆中" },
                {ID: 4, Name: "正在前往始发地" },
                {ID: 5, Name: "提货中" },
                {ID: 6, Name: "准备离厂" },
                {ID: 7, Name: "送货中" },
                {ID: 8, Name: "已签收" },
                {ID: 9, Name: "已核算" },
            ],
            rqsgList: [                                           //日期间隔下拉列表数据
                { label: '今天', value: 0 },
                { label: '近两天', value: 1 },
@@ -376,6 +504,33 @@
            packStockDetailShow: false,                            //包装容器出入库明细容器显示标记
            openVolume: false,                                    //维护零单占用体积弹窗标记
            openData: false,                                                           //数据弹窗
            openCarDriver: false,                                                      //分配车辆和司机弹窗标记
            carDriverForm: {                                                           //分配车辆和司机表单
                CarHNumber: '',
                CarHName: '',
                DriverHName: '',
                DriverHIDCard: ''
            },
            carDriverRules: {                                                          //分配车辆和司机表单验证
                CarHNumber: [{ required: true, message: '请输入车牌号', trigger: 'blur' }],
                CarHName: [{ required: true, message: '请输入车辆名称', trigger: 'blur' }],
                DriverHName: [{ required: true, message: '请输入驾驶员', trigger: 'blur' }],
                DriverHIDCard: [{ required: true, message: '请输入身份证号', trigger: 'blur' }],
            },
            openFileUpload: false,                                                     //附件上传弹窗标记
            fileUploadForm: {                                                          //附件上传表单
                billNo: '',
                hInterID: 0
            },
            fileList: [],                                                              //待上传文件列表
            uploadFiles: [],                                                           //待上传文件数据
            fileUploadLoading: false,                                                  //上传加载状态
            uploadedFileList: [],                                                      //已上传文件列表
            openBatchDownload: false,                                                  //批量下载弹窗标记
            batchFileList: [],                                                         //批量下载文件列表
            selectedBatchFiles: [],                                                    //选中的批量下载文件
            batchDownloadLoading: false,                                               //批量下载加载状态
            selectedBillCount: 0,                                                      //选中的单据数量
            dialogTypeNum: null,                                                       //部门弹窗1,仓库弹窗2
            gyCarShow: false,                                                          //车辆数据组件显示标记
            gyDriverShow: false,                                                       //司机数据组件显示标记
@@ -384,7 +539,10 @@
            sWhere: '',                                                   // 拼接过滤条件
            queryParams: {                                                // form数据
                HBillNo: '',
                HPlateNumber: '',
                HInitTimeCycle: 29,
                HSourceBillNo:'',
                HBillStatus:'',
                sTime: '',
                eTime: '',
                HOrgID: sessionStorage["OrganizationID"] - 0,
@@ -401,7 +559,14 @@
                ColContent2: '',
                ColContent: '',
            },
            loading: true,
            tyResList: [],//列表(接口数据)
            btList: [],//表头列表显示
            btResList: [],
            tableData: [],//列表(分页显示)
            dataList: [],
            titleData: [],//不需要显示的字段 可扩展
            pageSizes: [ 50,100, 500, 5000, 50000],
            page: 1,                                                      //page页索引
            pageSize: 0,                                                  //page页面记录数
            total: 0,                                                     //记录合计数
@@ -409,6 +574,7 @@
            totalNameList: [],                                            // 需要设置合计行的列数组
            tableData: [],                                                // 列表数据。用于table监听事件
            ids: [],                                                      // 选中行的hmainid数组
            printIds: '',                                                   //打印选择Id字段
            single: true,                                                 // 当选中的行数不为1时为true。用于禁用相关操作
            multiple: true,                                               // 当选中的行数为0时为true。用于禁用相关操作
            lastSelectedRowIndex: null,                                   // 用于记录上次点击的行索引
@@ -429,6 +595,7 @@
    },
    methods: {
        //#region 设置表头
        renderHeader(h, { column, $index }) {// 新建一个 span
            let span = document.createElement(span)// 设置表头名称
@@ -517,10 +684,29 @@
            this.handleQuery()
        },
        //#endregion
        //#region 权限判断
        async set_ModCheck(ModRightNameCheck) {
            var Permission = false;
            const res = await axios.get(this.$baseUrl + '/LMES/getReportByModRightNameCheck', {
                params: {
                    "ModRightNameCheck": ModRightNameCheck,
                    "user": sessionStorage["HUserName"],
                },
            }).then(result => {
                if (result.data.count != 1) {
                    Permission = true;
                    this.sWhere = this.sWhere + " and 承运商ID =" + sessionStorage["HSupID"]
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
        //#region 快速过滤
        handleQuery() {
        async handleQuery() {
            this.sWhere = ''
            await this.set_ModCheck("WLYayBill_SUPQuery")
            if (this.queryParams.ColName && this.queryParams.Comparator) {
                var com = "";
                switch (this.queryParams.Comparator) {
@@ -592,9 +778,20 @@
            if (this.queryParams.HBillNo) {
                this.sWhere += " and 单据号 like '%" + this.queryParams.HBillNo + "%'";
            }
            if (this.queryParams.HPlateNumber) {
                this.sWhere += " and 车牌号 like '%" + this.queryParams.HPlateNumber + "%'";
            }
            if (this.queryParams.HSourceBillNo) {
                this.sWhere += " and 发货通知单号 like '%" + this.queryParams.HSourceBillNo + "%'";
            }
            if (this.queryParams.HBillStatus) {
                this.sWhere += " and 物流状态 like '%" + this.queryParams.HBillStatus + "%'";
            }
            // if (this.queryParams.HOrgID) {
            //     this.sWhere += " and HOrgID = '" + this.queryParams.HOrgID + "'";
            // }
            console.log("swhere", this.sWhere)
            this.clearData()
            this.getList()
        },
@@ -602,26 +799,27 @@
        //#region 查询
        getList() {
            this.pageSize = 50
            if (this.pageSize == 0) {
                this.pageSize = 50
            }
            this.tableShow = false
            this.loading = true
            console.log("swhere", this.sWhere)
            // 列表查询
            axios.get(this.$baseUrl + '/WLYayBillController/GetListPage', {
            axios.get(this.$baseUrl + '/WLYayBillController/page', {
                params: {
                    "sWhere": this.sWhere,
                    "user": sessionStorage["HUserName"],
                    "page": this.page,
                    "size": this.pageSize
                    "size": this.pageSize,
                    "Type":3321
                },
            }).then(response => {
                this.tyResList = response.data.data//总数据
                let data1 = response.data
                let option = []
                if (data1.code == 1) {
                if (data1.list && data1.list.length > 0) {
                    this.btResList = data1.list             //列表表头数据
                    this.total = data1.count;
                    var data = [];//列字段数据
@@ -713,8 +911,8 @@
        //#region 删除
        handleDelete() {
            this.$modal.confirm('确认要删除吗,删除后不能恢复').then(() => {
                axios.get(this.$baseUrl + "/Cg_ContractTransportBillListController/DeleteBill", {
                    params: { 'HInterID': this.rowForm.HInterID.toString(), 'user': sessionStorage["HUserName"] }
                axios.get(this.$baseUrl + "/WLYayBillController/deleteBill", {
                    params: { 'HItemID': this.rowForm.HInterID.toString(), 'user': sessionStorage["HUserName"] }
                }).then(response => {
                    if (response.data.count == 1) {
                        this.handleQuery()
@@ -800,6 +998,7 @@
                HInterID: 0,
                HEntryID0: 0,
                currentVolume: 0,
                单据号: ''
            }
        },
@@ -835,6 +1034,7 @@
        cancelVolume() {
            this.openVolume = false
            this.resetVolume()
            this.handleQuery()
        },
        //#region 维护零单占用体积提交
        set_HScatteredVolumeList() {
@@ -1070,11 +1270,11 @@
                            this.totalNameList.push(item)
                        }
                    })
                    if (data1.data[0].HPageSize == 0) {
                        this.pageSize = 50
                    } else {
                        this.pageSize = data1.data[0].HPageSize
                    }
                    // if (data1.data[0].HPageSize == 0) {
                    //     this.pageSize = 50
                    // } else {
                    //     this.pageSize = data1.data[0].HPageSize
                    // }
                    this.tableData = option.data
                    this.tableShow = true
                    this.loading = false
@@ -1113,29 +1313,13 @@
        //#region 打印
        get_PrintReport() {
            if (this.ids.length != 1) {
                this.$modal.msgError("请选择一行数据")
            } else if (this.rowForm.单据状态 != "已审核" && !this.defaintOperationByCompanyName()) {
                this.$modal.msgError("打印失败!原因:单据状态不为'已审核'状态!!");
            if (this.ids.length == 0) {
                this.$modal.msgError("请至少选择一行数据")
            } else {
                axios.get(this.$baseUrl + "/Kf_SellOutBill/CheckSellOutBill_IsExist", {
                    params: { "HInterID": this.rowForm.HInterID }
                }).then(response => {
                    var result = response.data
                    if (result.count == 1) {
                        this.printListShow = true
                        this.openPrintList = true
                        // this.$router.push({ path:'/printList', query: { linterid: this.rowForm.hmainid,MyMsg:this.rowForm.hmainid,Type:'Kf_SellOutBillList' }})
                    } else {
                        this.$modal.msgError(result.code + result.Message)
                    }
                }).catch(error => {
                    this.$modal.msgError("接口请求失败!");
                });
                this.printIds = this.ids.join(',')
                this.printListShow = true
                this.openPrintList = true
            }
            //  var content= ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + data[0].hmainid.toString() + '&MyMsg=' + data[0].hmainid.toString() + '&Type=Kf_SellOutBillList', 'yes']
        },
        //#endregion
@@ -1224,6 +1408,7 @@
                IsAudit = 2
            }
            try {
                console.log(deptRow)
                const response = await axios.get(this.baseURL + '/WLYayBillController/selectDriver', {
                    params: {
                        "HInterID": this.rowForm.HInterID.toString(),
@@ -1277,6 +1462,295 @@
        },
        //#endregion
        //#endregion
        //#region 分配车辆和司机
        hanleCarOrDriver(form) {
            this.carDriverForm = {
                CarHNumber: '',
                CarHName: '',
                DriverHName: '',
                DriverHIDCard: ''
            }
            this.openCarDriver = true
        },
        submitCarDriver() {
            this.$refs.carDriverForm.validate((valid) => {
                if (valid) {
                    axios({
                        method: 'GET',
                        url: this.baseURL + "WLYayBillController/selectDriver1",
                        params: {
                            "CarHNumber": this.carDriverForm.CarHNumber,
                            "CarHName": this.carDriverForm.CarHName,
                            "DriverHName": this.carDriverForm.DriverHName,
                            "DriverHIDCard": this.carDriverForm.DriverHIDCard,
                            "CurUserName": sessionStorage["HUserName"],
                            "HInterID": this.rowForm.HInterID
                        },
                    }).then(response => {
                        let result = response.data
                        if (result.code == 1) {
                            this.$modal.msgSuccess(result.Message || "分配成功");
                            this.openCarDriver = false
                            this.handleQuery()
                        } else {
                            this.$modal.msgError(result.code + result.Message);
                        }
                    }).catch(error => {
                        console.log(error)
                        this.$modal.msgError("接口请求失败!");
                    });
                }
            })
        },
        //#endregion
        //#region 附件上传
        handleFileUpload() {
            this.fileUploadForm = {
                billNo: this.rowForm.单据号,
                hInterID: this.rowForm.HInterID
            }
            this.fileList = []
            this.uploadFiles = []
            this.uploadedFileList = []
            // this.getUploadedFileList()
            this.openFileUpload = true
        },
        handleFileChange(file, fileList) {
            console.log(file, fileList)
            // this.uploadFiles = fileList
        },
        handleFileRemove(file, fileList) {
            console.log(file, fileList)
            this.uploadFiles = fileList
        },
        handleFileSuccess(response, file, fileList){
                       console.log(response, file, fileList)
        },
          handleFileError(response, file, fileList){
            console.log(response, file, fileList)
        },
        handleFilePreview(file) {
            if (file.url) {
                window.open(file.url, '_blank')
            } else if (file.raw) {
                const url = URL.createObjectURL(file.raw)
                window.open(url, '_blank')
            } else {
                this.$modal.msgWarning('无法预览该文件')
            }
        },
        handleFileExceed(files, fileList) {
            this.$modal.msgWarning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
        },
        submitFileUpload() {
            if (this.uploadFiles.length === 0) {
                this.$modal.msgWarning('请先选择要上传的文件')
                return
            }
            console.log(this.uploadFiles)
            this.fileUploadLoading = true
            const formData = new FormData()
            this.uploadFiles.forEach(file => {
                formData.append('files', file.raw)
            })
            // formData.append('HBillNo', this.fileUploadForm.billNo)
            formData.append('HInterID', this.fileUploadForm.hInterID)
            formData.append('HUserName', sessionStorage["HUserName"] || '')
            // axios.get(this.$baseUrl + '/WLYayBillController/saveFileAddress', formData, {
            //     headers: {
            //         'Content-Type': 'multipart/form-data'
            //     },
            //     params:{
            //         HInterID:this.fileUploadForm.hInterID,
            //         HFileAddress:this.fileUploadPath + '/' + this.uploadFiles[0].name,
            //         CurUserName:sessionStorage["HUserName"]
            //     }
            // })
            axios('', {
                headers: {
                    'Content-Type': 'multipart/form-data'
                },
                methods: 'post',
                data: formData
            }).then(response => {
                console.log(response)
                this.fileUploadLoading = false
                if (response.data.code == 1) {
                    this.$modal.msgSuccess(response.data.Message || '文件上传成功')
                    this.fileList = []
                    this.uploadFiles = []
                    this.getUploadedFileList()
                } else {
                    this.$modal.msgError(response.data.code + response.data.Message || '上传失败')
                }
            }).catch(error => {
                this.fileUploadLoading = false
                this.$modal.msgError('上传请求失败')
                console.error('上传错误:', error)
            })
        },
        getUploadedFileList() {
            axios.get(this.$baseUrl + '/WLYayBillController/GetFileList', {
                params: {
                    HInterID: this.fileUploadForm.hInterID
                }
            }).then(response => {
                if (response.data.code == 1) {
                    this.uploadedFileList = response.data.data || []
                }
            }).catch(error => {
                console.error('获取文件列表失败:', error)
            })
        },
        downloadFile(row) {
            if (row.url) {
                window.open(row.url, '_blank')
            } else {
                axios.get(this.$baseUrl + '/WLYayBillController/DownloadFile', {
                    params: {
                        fileId: row.id || row.fileId
                    },
                    responseType: 'blob'
                }).then(response => {
                    const blob = new Blob([response.data])
                    const url = window.URL.createObjectURL(blob)
                    const link = document.createElement('a')
                    link.href = url
                    link.download = row.name || row.fileName
                    link.click()
                    window.URL.revokeObjectURL(url)
                }).catch(error => {
                    this.$modal.msgError('下载失败')
                    console.error('下载错误:', error)
                })
            }
        },
        deleteUploadedFile(row, index) {
            this.$modal.confirm('确认要删除该文件吗?').then(() => {
                axios.get(this.$baseUrl + '/WLYayBillController/DeleteFile', {
                    params: {
                        fileId: row.id || row.fileId,
                        HInterID: this.fileUploadForm.hInterID,
                        HUserName: sessionStorage["HUserName"]
                    }
                }).then(response => {
                    if (response.data.code == 1) {
                        this.$modal.msgSuccess('删除成功')
                        this.uploadedFileList.splice(index, 1)
                    } else {
                        this.$modal.msgError(response.data.Message || '删除失败')
                    }
                }).catch(error => {
                    this.$modal.msgError('删除请求失败')
                    console.error('删除错误:', error)
                })
            }).catch(() => { })
        },
        //#endregion
        //#region 附件批量下载
        handleBatchFileDownload() {
            if (this.rowList.length === 0) {
                this.$modal.msgWarning('请先选择要下载附件的单据')
                return
            }
            this.selectedBillCount = this.rowList.length
            this.batchFileList = []
            this.selectedBatchFiles = []
            this.getBatchFileList()
            this.openBatchDownload = true
        },
        getBatchFileList() {
            this.batchDownloadLoading = true
            const interIds = this.rowList.map(item => item.HInterID).join(',')
            axios.get(this.$baseUrl + '/WLYayBillController/GetBatchFileList', {
                params: {
                    HInterIDs: interIds
                }
            }).then(response => {
                this.batchDownloadLoading = false
                if (response.data.code == 1) {
                    this.batchFileList = response.data.data || []
                } else {
                    this.$modal.msgError(response.data.Message || '获取文件列表失败')
                }
            }).catch(error => {
                this.batchDownloadLoading = false
                this.$modal.msgError('获取文件列表失败')
                console.error('获取文件列表错误:', error)
            })
        },
        handleBatchFileSelectionChange(selection) {
            this.selectedBatchFiles = selection
        },
        downloadSingleFile(row) {
            if (row.url) {
                window.open(row.url, '_blank')
            } else {
                axios.get(this.$baseUrl + '/WLYayBillController/DownloadFile', {
                    params: {
                        fileId: row.id || row.fileId
                    },
                    responseType: 'blob'
                }).then(response => {
                    const blob = new Blob([response.data])
                    const url = window.URL.createObjectURL(blob)
                    const link = document.createElement('a')
                    link.href = url
                    link.download = row.name || row.fileName
                    link.click()
                    window.URL.revokeObjectURL(url)
                }).catch(error => {
                    this.$modal.msgError('下载失败')
                    console.error('下载错误:', error)
                })
            }
        },
        batchDownloadFiles() {
            if (this.selectedBatchFiles.length === 0) {
                this.$modal.msgWarning('请先选择要下载的文件')
                return
            }
            this.downloadFiles(this.selectedBatchFiles)
        },
        downloadAllFiles() {
            if (this.batchFileList.length === 0) {
                this.$modal.msgWarning('没有可下载的文件')
                return
            }
            this.downloadFiles(this.batchFileList)
        },
        downloadFiles(fileList) {
            this.batchDownloadLoading = true
            const fileIds = fileList.map(item => item.id || item.fileId).join(',')
            axios.get(this.$baseUrl + '/WLYayBillController/BatchDownloadFiles', {
                params: {
                    fileIds: fileIds
                },
                responseType: 'blob'
            }).then(response => {
                this.batchDownloadLoading = false
                const blob = new Blob([response.data], { type: 'application/zip' })
                const url = window.URL.createObjectURL(blob)
                const link = document.createElement('a')
                link.href = url
                const now = new Date()
                const timestamp = `${now.getFullYear()}${(now.getMonth() + 1).toString().padStart(2, '0')}${now.getDate().toString().padStart(2, '0')}_${now.getHours().toString().padStart(2, '0')}${now.getMinutes().toString().padStart(2, '0')}${now.getSeconds().toString().padStart(2, '0')}`
                link.download = `附件下载_${timestamp}.zip`
                link.click()
                window.URL.revokeObjectURL(url)
                this.$modal.msgSuccess('下载成功')
            }).catch(error => {
                this.batchDownloadLoading = false
                this.$modal.msgError('批量下载失败')
                console.error('批量下载错误:', error)
            })
        },
        //#endregion
        //清除选中数据的缓存
        clearData() {
            this.ids = []
@@ -1285,7 +1759,6 @@
            this.OperationType = 0
            this.copyType = 0
        },
    }
};
</script>