chenhaozhe
2025-11-20 f8ddb1cdc0caafa8aa74a214fffa552aac1d04a7
src/views/warehouse/barcodeMaster/Gy_BarCodeBill.vue
@@ -1 +1,1050 @@
<template></template>
<template>
    <div v-loading="formLoading" v-if="formShow" style="margin: 10px;">
        <div style=" margin-bottom: 10px; border-bottom: 1px solid #f6f6f6;">
            <el-button type="primary">预览打印</el-button>
            <el-button type="primary">生成</el-button>
            <el-button type="primary">重置</el-button>
            <el-button type="primary">库存</el-button>
            <el-button type="primary">同步资料</el-button>
            <el-button type="primary">批次</el-button>
            <el-button type="primary" @click="close">退 出</el-button>
        </div>
        <div style="margin: 10px; font-size: 28px; font-weight: bold; text-align: center;">器具档案编辑</div>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
            <el-row>
                <el-col :span="6">
                    <el-form-item label="组织" prop="HOrgID">
                        <el-select v-model="form.HOrgID" placeholder="请选择组织" @change="organizationChange"
                            style="width: 100%">
                            <el-option v-for="(item, index) in organizationList" :key="index" :label="item.Name"
                                :value="item.ID">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="工厂代码" prop="HWorksNumber">
                        <el-select v-model="form.HWorksNumber" placeholder="请选择组织" style="width: 100%">
                            <el-option v-for="(item, index) in HWorksNumberList" :key="index" :label="item"
                                :value="item">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="日期" prop="HDate">
                        <el-date-picker v-model="form.HDate" type="date" placeholder="选择日期" value-format="yyyy-MM-ddT"
                            style="width: 100%"> </el-date-picker>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item label="源单类型" prop="HSourceBillType">
                        <el-select v-model="form.HSourceBillType" placeholder="请选择" style="width: 100%">
                            <el-option v-for="(item, index) in HSourceBillTypeList" :key="index" :label="item.label"
                                :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="选单号" prop="HSourceBillNo">
                        <el-input v-model="form.HSourceBillNo" placeholder="请输入选单号" disabled>
                            <el-button slot="append" icon="el-icon-search" @click="openDataDialog(4)"></el-button>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="条码类型" prop="HBarCodeType">
                        <el-select v-model="form.HBarCodeType" placeholder="请选择" style="width: 100%">
                            <el-option v-for="(item, index) in HBarCodeTypeList" :key="index" :label="item"
                                :value="item">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-tabs type="border-card">
                <el-tab-pane label="物料信息">
                    <div style="margin-bottom: 10px;">
                        <el-button type="success" plain icon="el-icon-plus" @click="handleAddSysZb()"
                            size="mini">增加一行</el-button>
                        <el-button type="success" plain icon="el-icon-plus" @click="handleCopyZbRow"
                            size="mini">复制一行</el-button>
                    </div>
                    <el-table :data="editWlxxData" style="width: 100%" height="480" width="100%" ref="wlxxzbTable"
                        @selection-change="handleTableWlxxZbEdit" :row-class-name="wlxxzbRowSysZbIndex" border>
                        <el-table-column type="selection" width="55" align="center" />
                        <el-table-column align="center" label="序号" type="index" width="80" fixed />
                        <template v-for="(item, index) in wlxxBtList">
                            <el-table-column align="center" :prop="item.field" :label="item.title" :width="item.width"
                                :key="index" show-overflow-tooltip v-if="!item.hide">
                                <template slot-scope="{row,  column }">
                                    <div :style="item.style">
                                        <el-input v-if="item.edit == 'text'" v-model="row[column.label]" />
                                        <el-input-number v-else-if="item.edit == 'number'" v-model="row[column.label]"
                                            :min="0" controls-position="right" style="width: 100%;" />
                                        <el-date-picker v-else-if="item.edit == 'date'" v-model="row[column.label]"
                                            type="date" placeholder="选择日期" value-format="yyyy-MM-ddT"
                                            style="width: 100%"> </el-date-picker>
                                        <el-checkbox v-else-if="item.edit == 'checkbox'"
                                            v-model="row[column.label]"></el-checkbox>
                                        <span v-else>{{ row[column.label] }}</span>
                                    </div>
                                </template>
                            </el-table-column>
                        </template>
                        <el-table-column align="center" label="操作" width="55" fixed="right">
                            <template slot-scope="scope">
                                <el-button type="danger" icon="el-icon-delete" size="mini" circle
                                    @click="handleDeleteSysZb(scope.row)"></el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="条码信息">
                    <el-table :data="editTmData" style="width: 100%" height="480" width="100%" ref="tbzbTable"
                        @selection-change="handleTableWlxxZbEdit" :row-class-name="wlxxzbRowSysZbIndex" border>
                        <el-table-column type="selection" width="55" align="center" />
                        <el-table-column align="center" label="序号" type="index" width="80" fixed />
                        <template v-for="(item, index) in tmBtList">
                            <el-table-column align="center" :prop="item.field" :label="item.title" :width="item.width"
                                :key="index" show-overflow-tooltip v-if="!item.hide">
                                <template slot-scope="{row,  column }">
                                    <div :style="item.style">
                                        <el-input v-if="item.edit == 'text'" v-model="row[column.label]" />
                                        <el-input-number v-else-if="item.edit == 'number'" v-model="row[column.label]"
                                            :min="0" controls-position="right" style="width: 100%;" />
                                        <el-date-picker v-else-if="item.edit == 'date'" v-model="row[column.label]"
                                            type="date" placeholder="选择日期" value-format="yyyy-MM-ddT"
                                            style="width: 100%"> </el-date-picker>
                                        <el-checkbox v-else-if="item.edit == 'checkbox'"
                                            v-model="row[column.label]"></el-checkbox>
                                        <span v-else>{{ row[column.label] }}</span>
                                    </div>
                                </template>
                            </el-table-column>
                        </template>
                        <el-table-column align="center" label="操作" width="55" fixed="right">
                            <template slot-scope="scope">
                                <el-button type="danger" icon="el-icon-delete" size="mini" circle
                                    @click="handleDeleteSysZb(scope.row)"></el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="档案列表"><el-table :data="editDaData" style="width: 100%" height="480" width="100%"
                        ref="dazbTable" @selection-change="handleTableWlxxZbEdit" :row-class-name="wlxxzbRowSysZbIndex"
                        border>
                        <el-table-column type="selection" width="55" align="center" />
                        <el-table-column align="center" label="序号" type="index" width="80" fixed />
                        <template v-for="(item, index) in daBtList">
                            <el-table-column align="center" :prop="item.field" :label="item.title" :width="item.width"
                                :key="index" show-overflow-tooltip v-if="!item.hide">
                                <template slot-scope="{row,  column }">
                                    <div :style="item.style">
                                        <el-input v-if="item.edit == 'text'" v-model="row[column.label]" />
                                        <el-input-number v-else-if="item.edit == 'number'" v-model="row[column.label]"
                                            :min="0" controls-position="right" style="width: 100%;" />
                                        <el-date-picker v-else-if="item.edit == 'date'" v-model="row[column.label]"
                                            type="date" placeholder="选择日期" value-format="yyyy-MM-ddT"
                                            style="width: 100%"> </el-date-picker>
                                        <el-checkbox v-else-if="item.edit == 'checkbox'"
                                            v-model="row[column.label]"></el-checkbox>
                                        <span v-else>{{ row[column.label] }}</span>
                                    </div>
                                </template>
                            </el-table-column>
                        </template>
                        <el-table-column align="center" label="操作" width="55" fixed="right">
                            <template slot-scope="scope">
                                <el-button type="danger" icon="el-icon-delete" size="mini" circle
                                    @click="handleDeleteSysZb(scope.row)"></el-button>
                            </template>
                        </el-table-column>
                    </el-table></el-tab-pane>
            </el-tabs>
        </el-form>
        <!-- 部门弹窗 -->
        <el-dialog :title="dialogTitle" :visible.sync="openData" width="1280px" append-to-body>
            <Dept @deptEmitDb="dbEmitData" @deptEmit="emitData" v-if="deptShow" />
            <Warehouse @deptEmitDb="dbEmitData" @deptEmit="emitData" v-if="warehouseShow" />
            <Material @deptEmitDb="dbEmitData" @deptEmit="emitData" v-if="materialShow" />
            <GyEmployee @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyEmployeeShow" />
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="deptClickSub">确 定</el-button>
                <el-button @click="deptClose">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import axios from 'axios'
import Dept from '@/views/component/dept'
import Warehouse from '@/views/component/warehouse'
import Material from '@/views/component/material'
import RowSettings from '@/views/component/rowSettings'
import GyEmployee from '@/views/basic/gyEmployee/gyEmployee.vue'
import moment from 'moment';
export default {
    name: 'Gy_BarCodeBill',
    components: { Dept, Warehouse, Material, RowSettings, GyEmployee },
    props: {
        OperationType: { type: Number, },
        linterid: { type: Number, },
        HSouceBillType: { type: String, },
        propsData: { type: String, },
        copyType: { type: Number, },
    },
    data() {
        return {
            HModName: "Gy_BarCodeBill",
            HSourceBillTypeList: [
                { value: 1, label: '生产订单', },
                { value: 2, label: '生产汇报单', },
                { value: 3, label: '采购订单', },
                { value: 4, label: '收料通知单', },
                { value: 5, label: '委外订单', },
                { value: 6, label: '生产入库单', },
                { value: 7, label: '采购入库单', },
                { value: 8, label: '销售退货单', },
                { value: 9, label: '生产退料单', },
                { value: 10, label: '工序流转卡', },
                { value: 11, label: '销售出库单', },
                { value: 12, label: '领料出库单', }
            ],
            wlxxBtList: [{ field: 'HMainID', title: '源单主内码', width: 100, hide: true }
                , { field: 'HSubID', title: '源单子内码', width: 100, hide: true }
                , { field: 'HSourceBillSEQ', title: '源单行号', width: 100, hide: true }
                , { field: 'HBillNo', title: '源单单号', width: 200 }
                , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                , { field: 'HMaterNumber', title: '物料代码', edit: 'text', event: 'HMaterNumber', width: 200 }
                , { field: 'HMaterName', title: '物料名称', width: 200 }
                , { field: 'HMaterModel', title: '规格型号', width: 200 }
                , { field: 'HCusModel', title: '客户规格型号', edit: 'text', width: 200 }
                , { field: 'HCusMaterName', title: '客户物料名称', edit: 'text', width: 200 }
                , { field: 'HEmpID', title: '操作员ID', width: 100, hide: true }
                , { field: 'HEmpNumber', title: '操作员代码', edit: 'text', width: 200, event: 'HEmpNumber' }
                , { field: 'HEmpName', title: '操作员', width: 200 }
                , { field: 'HGroupID', title: '班组ID', width: 100, hide: true }
                , { field: 'HGroupNumber', title: '班组代码', edit: 'text', width: 200, event: 'HGroupNumber' }
                , { field: 'HGroupName', title: '班组名称', width: 200 }
                , { field: 'HCheckEmpName', title: '检验员', width: 200, edit: 'text' }
                , { field: 'HBatchNo', title: '批号', edit: 'text', width: 100 }
                , { field: 'HMTONo', title: '计划跟踪号', width: 100, edit: 'text' }
                , { field: 'HQty', title: '数量', edit: 'number', width: 100, totalRow: true }
                , { field: 'HMinQty', title: '最小包装数', edit: 'number', totalRow: true, width: 100 }
                , { field: 'HBQty', title: '箱数', width: 100, totalRow: true }
                , { field: 'HPackQty', title: '外箱数', edit: 'text', width: 100, totalRow: true }
                , { field: 'HCoilNO', title: '钢卷捆包号', edit: 'text', width: 100 }
                , { field: 'HFurnaceNO', title: '炉号', edit: 'text', width: 100 }
                , { field: 'HFactory', title: '厂商', edit: 'text', width: 100 }
                , { field: 'HCusID', title: '客户ID', width: 100, hide: true }
                , { field: 'HCusNumber', title: '客户代码', edit: 'text', event: 'HCusNumber', width: 120 }
                , { field: 'HCusName', title: '客户名称', width: 120 }
                , { field: 'HSeOrderBillNo', title: '销售订单号', width: 200 }
                , { field: 'HRemark', title: '备注', edit: 'text', width: 100 }
                , { field: 'HProduceDate', title: '生产日期', edit: 'date', event: 'HProduceDate', width: 160 }
                , { field: 'HExpiryDate', title: '保质期至', edit: 'date', event: 'HExpiryDate', width: 160 }
                , { field: 'HheatNO', title: '热处理', edit: 'text', width: 100 }
                , { field: 'HAuxPropID', title: '辅助属性ID', width: 100, hide: true }
                , { field: 'HAuxPropNumber', title: '辅助属性代码', edit: 'text', event: 'HAuxPropNumber', width: 100 }
                , { field: 'HAuxPropName', title: '辅助属性名称', width: 100 }
                , { field: 'HUnitID', title: '计量单位ID', width: 100, hide: true }
                , { field: 'HUnitNumber', title: '计量单位代码', edit: 'text', event: 'HUnitNumber', width: 100 }
                , { field: 'HUnitName', title: '计量单位', width: 100 }
                , { field: 'HAuxQty', title: '辅单位数量', edit: 'text', width: 100, totalRow: true }
                , { field: 'HExpirationDateFlag', title: '是否启用保质期', width: 120, edit: 'checkbox', templet: '#switchTp3', unresize: false }
                , { field: 'HGiveAwayFlag', title: '是否赠品', width: 100, edit: 'checkbox', templet: '#switchTpl', unresize: false }
                , { field: 'HDate', title: '条码日期', width: 100, hide: true }
            ],
            tmBtList: [
                { field: 'HBarCode2', title: '条码编号', width: 100 }
                , { field: 'HMaterNumber2', title: '物料代码', width: 100 }
                , { field: 'HMaterName2', title: '物料名称', width: 100 }
                , { field: 'HMaterModel2', title: '规格型号', width: 100 }
                , { field: 'HAuxPropNumber2', title: '辅助属性代码', width: 100 }
                , { field: 'HAuxPropName2', title: '辅助属性', event: 'HWHCode', width: 120 }
                , { field: 'HGiveAwayFlag2', title: '是否赠品', width: 120, templet: '#switchTpl', unresize: false }
                , { field: 'HUnitCode2', title: '计量单位代码', width: 120 }
                , { field: 'HUnitName2', title: '计量单位', width: 120 }
                , { field: 'HQty2', title: '数量', width: 120 }
                , { field: 'HDate2', title: '进料日期', width: 120 }
                , { field: 'HCusNumber2', title: '客户代码', width: 120 }
                , { field: 'HCusName2', title: '客户', width: 120 }
                , { field: 'HSourceBillNo2', title: '源单单号', width: 120 }
                , { field: 'HSeOrderBillNo2', title: '销售订单号', width: 120 }
                , { field: 'HRemark2', title: '备注', width: 120 }
                , { field: 'HMTONo2', title: '计划跟踪号', width: 120 }
                , { field: 'HShowDate2', title: '日期', width: 100 }
                , { field: 'HInnerBillNo2', title: '内部采购订单号', width: 100 }
                , { field: 'HMaker2', title: '制单人', width: 100 }
            ],
            daBtList: [
                { field: 'HItemID', title: 'HItemID', width: 100, hide: true }
                , { field: 'hmainid', title: 'hmainid', width: 100, hide: true }
                , { field: 'hsubid', title: 'hsubid', width: 100, hide: true }
                , { field: 'HinterID', title: 'HinterID', width: 100, hide: true }
                , { field: '条码类型', title: '条码类型', width: 100 }
                , { field: '条码编号', title: '条码编号', width: 120 }
                , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                , { field: '物料代码', title: '物料代码', width: 120 }
                , { field: '物料名称', title: '物料名称', width: 120 }
                , { field: '规格型号', title: '规格型号', width: 120 }
                , { field: 'HUnitID', title: '计量单位ID', width: 100, hide: true }
                , { field: '计量单位代码', title: '计量单位代码', width: 120 }
                , { field: '计量单位', title: '计量单位', width: 120 }
                , { field: 'HAuxPropID', title: '辅助属性ID', width: 100, hide: true }
                , { field: '辅助属性代码', title: '辅助属性代码', width: 120 }
                , { field: '辅助属性', title: '辅助属性', width: 120 }
                , { field: '批号', title: '批号', width: 120 }
                , { field: '数量', title: '数量', width: 100 }
                , { field: '源单单号', title: '源单单号', width: 120 }
                , { field: '计划跟踪号', title: '计划跟踪号', width: 120 }
                , { field: '是否赠品', title: '是否赠品', width: 100 }
                , { field: 'DeptID', title: '车间ID', width: 100, hide: true }
                , { field: '车间', title: '车间', width: 120 }
                , { field: 'HSupID', title: '供应商ID', width: 100, hide: true }
                , { field: '供应商代码', title: '供应商代码', width: 120 }
                , { field: '供应商', title: '供应商', width: 120 }
                , { field: '客户条码编号', title: '客户条码编号', width: 120 }
                , { field: '客户型号', title: '客户型号', width: 120 }
                , { field: '往来单位', title: '往来单位', width: 120 }
                , { field: '销售订单号', title: '销售订单号', width: 120 }
                , { field: '销售订单行号', title: '销售订单行号', width: 120 }
                , { field: '托号', title: '托号', width: 120 }
                , { field: '总托数', title: '总托数', width: 100 }
                , { field: '条码日期', title: '条码日期', width: 120 }
                , { field: '生产入库日期', title: '生产入库日期', width: 120 }
                , { field: '生产入库单号', title: '生产入库单号', width: 120 }
                , { field: '生产入库次数', title: '生产入库次数', width: 100 }
                , { field: '销售出库日期', title: '销售出库日期', width: 120 }
                , { field: '销售出库单号', title: '销售出库单号', width: 120 }
                , { field: '销售出库次数', title: '销售出库次数', width: 100 }
                , { field: '作废标记', title: '作废标记', width: 100 }
                , { field: '作废人', title: '作废人', width: 100 }
                , { field: '备注', title: '备注', width: 120 }
                , { field: '制作人', title: '制作人', width: 100 }
                , { field: '日期', title: '日期', width: 120 }
                , { field: '计划完工日期', title: '计划完工日期', width: 120 }
                , { field: '打印次数', title: '打印次数', width: 100 }
                , { field: 'HSTOCKORGID', title: 'HSTOCKORGID', width: 100, hide: true }
                , { field: '生成组织', title: '生成组织', width: 120 }
            ],
            HBarCodeTypeList: [],
            HWorksNumberList: [],
            formShow: false,
            temp: undefined,
            formLoading: true,
            zzSelDis: false,
            rowHideShow: false,
            openRowHide: false,
            hPriceTypeList: ['成本价', '结算价'],
            addBtnShow: false,
            zbIndex: null,
            zbSelForm: {},//子表选中数据
            dialogTypeNum: null,//部门弹窗1,仓库弹窗2
            deptShow: false,//部门数据组件
            warehouseShow: false,//仓库数据组件
            materialShow: false,//物料数据组件
            gyEmployeeShow: false,//销售员数据组件
            deptform: {},//弹窗选中数据
            openData: false,//数据弹窗
            dialogTitle: '',
            organizationList: JSON.parse(sessionStorage.getItem('organizationList')),//组织列表
            subDisabled: false,//编辑页面保存按钮是否禁用(true禁用,false可用)
            // OperationType: this.$route.query.OperationType,//保存类型(新增1修改3)
            HInterID: null,
            baseURL: process.env.VUE_APP_BASE_API,
            checkedSysZb: [],
            editWlxxData: [],//子表
            editTmData: [],
            editDaData: [],
            editBtData: [],//子表表头
            activeName: 'first',
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 日期范围
            dateRange: [],
            // 查询参数
            queryParams: {
                HBillNo: '',
                HInitTimeCycle: 29,
                HProjectNumber: '',
                HCusID: null,
                HMaterNumber: '',
                HMaterName: '',
                ColName1: '',
                ColName2: '',
                ColName: '',
                Comparator1: '',
                Comparator2: '',
                Comparator: '',
                ColContent1: '',
                ColContent2: '',
                ColContent: '',
            },
            // 显示搜索条件
            showSearch: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 遮罩层
            loading: true,
            btResList: [],
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                HSupName: [
                    { required: true, message: "客户不能为空", trigger: "blur" }
                ],
                HDate: [
                    { required: true, message: "日期不能为空", trigger: "blur" }
                ],
                HExRate: [
                    { required: true, message: "汇率不能为空", trigger: "blur" }
                ]
            }
        };
    },
    created() {
        this.set_HBarCodeType()
        this.getdata()
    },
    methods: {
        set_HBarCodeType() {
            //获取条码类型代码
            axios.get(this.baseURL + '/Sc_BarCode/GetHBarCodeTypeBill').then(response => {
                console.log(response)
                let result = response.data
                if (result.count == 1) {
                    this.HBarCodeTypeList = result.list
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
            axios.get(this.baseURL + '/Sc_BarCode/GetHWorksNumberBill').then(response => {
                console.log(response)
                let result = response.data
                if (result.count == 1) {
                    this.HWorksNumberList = result.list
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        getdata() {
            console.log(this.copyType, this.OperationType)
            this.formShow = false
            this.formLoading = true
            if (this.OperationType == 4) {
                this.zzSelDis = true
                this.handleAdd()
                var data = this.getUrlVars_JSON();
                var dataArray = [];
                for (var i = 0; i < data.length; i++) {
                    // this.getPushSourceBillInit(data[i].hmainid, data[i].hsubid);
                    axios.get(this.baseURL + '/Xs_SeOrderBill/loadXs_SeOrderBill_Push', {
                        params: {
                            "HInterID": data[i].hmainid
                            , "HSubID": data[i].hsubid
                        },
                    }).then(response => {
                        let result = response.data
                        if (result.code == 1) { // 说明验证成功了,
                            this.temp = result.data[0];
                        } else {
                            this.temp = result.data;
                        }
                        if (this.temp) {
                            dataArray.push(this.temp);
                            this.form.HDeptID = dataArray[0].HDeptID
                            this.form.HDeptName = dataArray[0].部门
                            this.form.HEmpID = dataArray[0].HEmpID
                            this.form.HEmpName = dataArray[0].业务员
                            this.form.HManagerID = dataArray[0].HManagerID
                            this.form.HManagerName = dataArray[0].主管
                            this.form.HMainSourceInterID = "0"
                            this.form.HMainSourceEntryID = "0"
                            this.form.HMainSourceBillNo = ""
                            this.form.HMainSourceBillType = dataArray[0].HBillType
                            this.form.HSupID = dataArray[0].HCusID
                            this.form.HSupName = dataArray[0].客户
                            this.form.HLinkMan = dataArray[0].联系人
                            this.form.HLinkPhone = dataArray[0].联系电话
                            this.form.HSellSID = dataArray[0].HSellSID
                            this.form.HSellSName = dataArray[0].销售方式
                            this.form.HCurID = dataArray[0].HCurID
                            this.form.HCurName = dataArray[0].币别
                            this.form.HExRate = dataArray[0].汇率
                            for (var i = 0; i < dataArray.length; i++) {
                                this.editWlxxData.push(
                                    {
                                        "HMaterID": dataArray[i].HMaterID
                                        , "物料代码": dataArray[i].物料代码
                                        , "物料名称": dataArray[i].物料名称
                                        , "规格型号": dataArray[i].规格型号
                                        , "HUnitID": dataArray[i].HUnitID
                                        , "计量单位": dataArray[i].计量单位
                                        , "HQtyMust": dataArray[i].数量.toFixed(6)
                                        , "HQty": dataArray[i].数量.toFixed(6)
                                        , "HPieceQty": "0"
                                        , "HPrice": dataArray[i].单价.toFixed(4)
                                        , "HTaxPrice": dataArray[i].实际含税单价.toFixed(4)
                                        , "HTaxRate": dataArray[i].税率
                                        , "HMoney": dataArray[i].金额.toFixed(2)
                                        , "HTaxMoney": dataArray[i].价税合计.toFixed(2)
                                        , "HWHID": dataArray[i].HWHID
                                        , "发货仓库": dataArray[i].HWHName
                                        , "HRemark": ""
                                        , "HQty_Full": "0"
                                        , "HQty_Empty": "0"
                                        , "HQty_Back": "0"
                                        , "HCostPrice": "0"
                                        , "HCostMoney": "0"
                                        , "HSalePrice": "0"
                                        , "HSeOrderInterID": dataArray[i].hmainid
                                        , "HSeOrderEntryID": dataArray[i].hsubid
                                        , "HSeOrderBillNo": dataArray[i].单据号
                                        , "HSourceInterID": dataArray[i].hmainid
                                        , "HSourceEntryID": dataArray[i].hsubid
                                        , "HSourceBillNo": dataArray[i].单据号
                                        , "HSourceBillType": dataArray[i].HBillType
                                        , "HRelationQty": "0"
                                        , "HRelationMoney": "0"
                                        , 'HSPID': "0"
                                        , 'HSPName': ""
                                        , 'HSPGroupID': "0"
                                        , "HSPGroupName": ""
                                        , 'HSCWHID': "0"
                                        , 'HSCWHName': ""
                                        , 'HSCSPID': "0"
                                        , 'HSCSPName': ""
                                        , 'HBatchNo': ""
                                        , 'HPOOrderInterID': "0"
                                        , 'HPOOrderEntryID': "0"
                                        , 'HPOOrderBillNo': ""
                                        , 'HPropertyID': "0"
                                        , 'HPropertyName': ""
                                        , 'HSecUnitID': "0"
                                        , 'HSecUnitName': ""
                                        , 'HSecUnitRate': "0"
                                        , 'HEngineNum': ""
                                        , 'HUnderPanNum': ""
                                        , 'HLeaveFactCard': ""
                                        , 'HReqBuyQty': "0"
                                        , 'HReqOutQty': "0"
                                        , 'HCurrentInventory': "0"
                                    }
                                );
                            }
                        }
                        this.$nextTick(() => {
                            this.formShow = true
                            this.formLoading = false
                        })
                    }).catch(error => {
                        this.$modal.msgError("接口请求失败!");
                    });
                }
            } else if ((this.OperationType == 1 && this.copyType != 1) || (!this.OperationType && !this.copyType)) {
                this.handleAdd()
            } else if (this.OperationType == 3 || this.copyType == 1) {
                this.handleUpdate()
            }
        },
        // 获取参数_传递的JSON格式参数
        getUrlVars_JSON() {
            var datajson;
            var str = this.propsData; //获取链接中传递的参数
            var arr = str.substring(str.lastIndexOf("=") + 1);
            datajson = JSON.parse(decodeURI(arr));
            return datajson;
        },
        //根据主内码与子内码获取源单销售订单数据
        getPushSourceBillInit(HSourceInterID, HSourceEntryID) {
            axios.get(this.baseURL + '/Xs_SeOrderBill/loadXs_SeOrderBill_Push', {
                params: {
                    "HInterID": HSourceInterID
                    , "HSubID": HSourceEntryID
                },
            }).then(response => {
                let result = response.data
                if (result.code == 1) { // 说明验证成功了,
                    this.temp = result.data[0];
                } else {
                    this.temp = result.data;
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        handleRowHide() {
            this.rowHideShow = true
            this.openRowHide = true
        },
        rowSetClose(val) {
            this.rowHideShow = false
            this.openRowHide = val
        },
        organizationChange(val) {
            // let options=undefined
            //  this.form=this.organizationList.find(option => option.ID === val)?.Name || '';
        },
        //部门弹窗赋值
        dbEmitData(deptRow, num) {
            // num=1部门 num=2出库仓库
            console.log(deptRow)
            if (deptRow.HItemID) {
                if (num == 1) {
                    this.form.HDeptName = deptRow.部门名称
                    this.form.HDeptID = deptRow.HItemID
                    this.form.HManagerName = deptRow.负责人
                    this.deptShow = false
                    this.openData = false
                } else if (num == 2) {
                    this.editData[this.zbIndex].HWHID = deptRow.HItemID;
                    this.editData[this.zbIndex].发货仓库 = deptRow.仓库名称;
                    this.warehouseShow = false
                    this.openData = false
                } else if (num == 3) {
                    this.editData[this.zbIndex].HMaterID = deptRow.HItemID;
                    this.editData[this.zbIndex].物料代码 = deptRow.物料代码;
                    this.editData[this.zbIndex].物料名称 = deptRow.物料名称;
                    this.editData[this.zbIndex].HUnitID = deptRow.HUnitID;
                    this.editData[this.zbIndex].规格型号 = deptRow.规格型号
                    this.editData[this.zbIndex].计量单位 = deptRow.计量单位名称
                    this.editData[this.zbIndex].HTaxPrice = deptRow.含税成本价
                    this.editData[this.zbIndex].HTaxRate = deptRow.默认税率
                    this.materialShow = false
                    this.openData = false
                } else if (num == 4) {
                    this.form.HEmpName = deptRow.职员名称
                    this.form.HEmpID = deptRow.HItemID
                    this.gyEmployeeShow = false
                    this.openData = false
                }
            } else {
                this.$modal.msgError("请选择单条数据!");
            }
        },
        emitData(deptRow, num) {
            this.dialogTypeNum = num
            this.deptform = deptRow
        },
        deptClickSub() {
            this.dbEmitData(this.deptform, this.dialogTypeNum)
            this.deptform = {}
        },
        deptClose() {
            this.deptform = {}
            this.openData = false
        },
        //新增编辑表单初始化
        reset() {
            this.form = {
                HOrgID: sessionStorage["OrganizationID"] - 0,
                HWorksNumber: '',
                HDate: moment(new Date()).format('YYYY-MM-DD'),
                HSourceBillType: 1,
                HSourceBillNo: '',
                HBarCodeType: '',
            }
            this.editWlxxData = []
            this.editBtData = []
            this.ids = []
            this.subDisabled = false
            this.addBtnShow = false
            // this.$refs.tableData.clearSelection()
            this.activeName = 'first'
            this.resetForm("form");
        },
        //退出
        close() {
            this.reset()
            console.log(1111)
            console.log(this.$route.path)
            if (!this.OperationType && !this.copyType) {
                console.log(this.$route.path)
                const obj = { fullPath: this.$route.path, path: this.$route.path, name: this.$route.name, };
                this.$tab.closePage(obj).then(res => {
                    const latestView = res.visitedViews.slice(-1)[0]
                    if (latestView) {
                        this.$router.push(latestView.fullPath)
                    } else {
                        if (obj.name === 'Dashboard') {
                            this.$router.replace({ path: '/redirect' + obj.fullPath })
                        } else {
                            this.$router.push('/')
                        }
                    }
                });
            } else {
                this.formShow = false
                this.$emit('editClose', false)
            }
        },
        //根据用户获取对应职员、部门、销售主管
        getCzyglByUser() {
            axios.get(this.baseURL + '/Xs_SeOrderBill/getCzyglByUser', {
                params: { "CurUserName": sessionStorage["HUserName"] }
            }).then(response => {
                let dataForm = response.data.data[0]
                this.form.HDeptID = dataForm.HDeptID
                this.form.HDeptName = dataForm.HDeptName
                this.form.HEmpID = dataForm.HEmpID
                this.form.HEmpName = dataForm.HEmpName
                this.form.HManagerID = dataForm.HManagerID
                this.form.HManagerName = dataForm.HManagerName
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset()
            this.handleAddSysZb()
            this.$nextTick(() => {
                this.formShow = true
                this.formLoading = false
            })
        },
        //获取对应的条码明细
        getBarCodeNoteBySellOutBill(rowHmainid) {
            axios.get(this.baseURL + '/Kf_SellOutBill/BarCodeNote', {
                params: { "HInterID": rowHmainid }
            }).then(response => {
                if (response.data.count == 1) {
                    if (response.data.data[2].length > 0) {
                        this.$modal.msgError("当前单据由扫码生成,不可以编辑!");
                        this.subDisabled = true
                    }
                } else { }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#region 根据客户获取客户余额
        getCustomerBalance(HCusID) {
            axios.get(this.baseURL + '/Xs_CusRatingChangeBill/getCustomerBalance', {
                params: { "HCusID": HCusID, 'CurUserName': sessionStorage["HUserName"] }
            }).then(response => {
                var data = response.data.data[0];
                this.form.HCusBalance = data.HCusBalance
                this.form.HCreditRating_Now = data.HCreditRating_Now
                this.form.HAvailableBalance = data.HAvailableBalance
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        /** 修改按钮操作 */
        handleUpdate() {
            this.reset()
            let rowHmainid = this.linterid
            console.log(this.linterid)
            axios.get(this.baseURL + "/Kf_SellOutBill/cx", {
                params: { 'HInterID': rowHmainid }
            }).then(response => {
                if (response.data.count == 1) {
                    var result = response.data
                    var data = response.data.data[0]
                    this.form.BillType = data.HSourceBillType
                    if (this.copyType == 1) {
                        let date = new Date()
                        this.form.HDate = moment(date).format('YYYY-MM-DDTHH:mm:ss')
                    } else {
                        this.form.HBillNo = data.单据号
                        this.form.HInterID = data.hmainid
                        this.form.HDate = data.日期
                        this.form.HMaker = data.制单人
                        this.form.HUpDater = data.修改人
                        this.form.HChecker = data.审核人
                        this.form.HMakeDate = data.制单日期
                        this.form.HUpDateDate = data.修改日期
                        this.form.HCheckDate = data.审核日期
                        this.form.HCloseMan = data.关闭人
                        this.form.HDeleteMan = data.作废人
                        this.form.HCloseDate = data.关闭日期
                        this.form.HDeleteDate = data.作废日期
                    }
                    this.form.HBillSubType = data.HBillSubType
                    this.form.HMainSourceInterID = data.HMainSourceInterID
                    this.form.HMainSourceEntryID = data.HMainSourceEntryID
                    this.form.HMainSourceBillType = data.HMainSourceBillType
                    this.form.HMainSourceBillNo = data.HMainSourceBillNo
                    this.form.HEmpName = data.业务员
                    this.form.HEmpID = data.HEmpID
                    this.form.HDeptName = data.部门
                    this.form.HDeptID = data.HDeptID
                    this.form.HManagerName = data.主管
                    this.form.HManagerID = data.HManagerID
                    this.form.HSupName = data.客户
                    this.form.HSupID = data.HSupID
                    this.form.HLinkMan = data.联系人
                    this.form.HLinkPhone = data.联系电话
                    this.form.HSecManagerName = data.发货人
                    this.form.HSecManagerID = data.HSecManagerID
                    this.form.HKeeperName = data.保管员
                    this.form.HKeeperID = data.HKeeperID
                    this.form.HRemark = data.表头备注
                    this.form.HProjectNumber = data.项目编码
                    this.form.HProjectID = data.HProjectID
                    this.form.HProjectName = data.项目名称
                    this.form.HGroupName = data.班组
                    this.form.HGroupID = data.HGroupID
                    this.form.HWHName = data.主表仓库
                    this.form.HWHID = data.HWHID_Main
                    this.form.HConveyCompName = data.运输公司
                    this.form.HConveyCompID = data.HConveyCompID
                    this.form.HConveyTypeName = data.运输方式
                    this.form.HConveyTypeID = data.HConveyTypeID
                    this.form.HConveyMoney = data.HConveyMoney
                    this.form.HCarriage = data.运费
                    this.form.HSTOCKORGID = data.HSTOCKORGID
                    this.form.HOWNERID = data.HOWNERID
                    this.form.HSCWHName = data.主表调出仓库
                    this.form.HSCWHID = data.HSCWHID
                    this.form.HCheckStatusMan = data.核销人
                    this.form.HExplanation = data.摘要
                    this.form.HInnerBillNo = data.内部单据号
                    this.form.HCurName = data.币别
                    this.form.HCurID = data.HCurID
                    this.form.HExRate = data.汇率
                    this.form.HSellSName = data.销售方式
                    this.form.HSellSID = data.HSellSID
                    //  this.form.HCusBalance=data
                    //  this.form.HCreditRating_Now=HConveyMoney
                    //  this.form.HAvailableBalance=data
                    this.form.HPriceType = data.单价类型
                    this.form.HOrgID = data.HOrgID
                    this.getCustomerByCusID(response.data.data[0].HSupID)//根据客户获取联系人,联系人电话
                    this.getBarCodeNoteBySellOutBill(rowHmainid)//获取对应的条码明细是否可编辑
                    for (var i = 0; i < result.data.length; i++) {
                        this.editWlxxData.push(
                            {
                                "HMaterID": result.data[i].HMaterID
                                , "物料代码": result.data[i].物料代码
                                , "物料名称": result.data[i].物料名称
                                , "规格型号": result.data[i].规格型号
                                , "HUnitID": result.data[i].HUnitID
                                , "计量单位": result.data[i].计量单位
                                , "HQtyMust": result.data[i].应发数量.toFixed(6)
                                , "HQty": result.data[i].数量.toFixed(6)
                                , "HPieceQty": result.data[i].件数.toFixed(0)
                                , "HPrice": result.data[i].单价.toFixed(4)
                                , "HTaxPrice": result.data[i].含税单价.toFixed(4)
                                , "HTaxRate": result.data[i].税率
                                , "HMoney": (result.data[i].数量 * result.data[i].单价).toFixed(2)
                                , "HTaxMoney": (result.data[i].数量 * result.data[i].含税单价, 2).toFixed(2)
                                , "HWHID": result.data[i].hwhid
                                , "发货仓库": result.data[i].发货仓库
                                , "HRemark": result.data[i].表体备注
                                , "HQty_Full": result.data[i].满车重量
                                , "HQty_Empty": result.data[i].空车重量
                                , "HQty_Back": result.data[i].回车重量
                                , "HCostPrice": result.data[i].成本单价
                                , "HCostMoney": result.data[i].成本金额
                                , "HSalePrice": result.data[i].销售单价
                                , "HSeOrderInterID": result.data[i].HSeOrderInterID
                                , "HSeOrderEntryID": result.data[i].HSeOrderEntryID
                                , "HSeOrderBillNo": result.data[i].销售订单号
                                , "HSourceInterID": result.data[i].HSourceInterID
                                , "HSourceEntryID": result.data[i].HSourceEntryID
                                , "HSourceBillNo": result.data[i].源单单号
                                , "HSourceBillType": result.data[i].HSourceBillType
                                , "HRelationQty": result.data[i].关联数量
                                , "HRelationMoney": result.data[i].关联金额
                                , 'HSPID': result.data[i].HSPID
                                , 'HSPName': result.data[i].仓位
                                , 'HSPGroupID': result.data[i].HSPGroupID
                                , "HSPGroupName": result.data[i].仓位组
                                , 'HSCWHID': result.data[i].HSCWHID
                                , 'HSCWHName': result.data[i].调出仓库
                                , 'HSCSPID': result.data[i].HSCSPID
                                , 'HSCSPName': result.data[i].调出仓位
                                , 'HBatchNo': result.data[i].批次
                                , 'HPOOrderInterID': result.data[i].采购订单内码
                                , 'HPOOrderEntryID': result.data[i].采购订单子内码
                                , 'HPOOrderBillNo': result.data[i].采购订单号
                                , 'HPropertyID': result.data[i].HPropertyID
                                , 'HPropertyName': result.data[i].辅助属性
                                , 'HSecUnitID': result.data[i].HSecUnitID
                                , 'HSecUnitName': result.data[i].辅助计量单位
                                , 'HSecUnitRate': result.data[i].换算率
                                , 'HEngineNum': result.data[i].发动机号
                                , 'HUnderPanNum': result.data[i].地盘号
                                , 'HLeaveFactCard': result.data[i].出厂证
                                , 'HReqBuyQty': result.data[i].申请采购数量
                                , 'HReqOutQty': result.data[i].申请出库数量
                                , 'HCurrentInventory': result.data[i].当前库存
                            }
                        );
                    }
                    if (data.状态 != '创建' && this.copyType != 1) {
                        this.$modal.msgError("此条数据不是创建状态,不能修改");
                        this.subDisabled = true
                    }
                    this.formShow = true
                    this.formLoading = false
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //根据客户带出联系人、联系电话
        getCustomerByCusID(HCusID) {
            axios.get(this.baseURL + "/Xs_SeOrderBill/getCustomerByCusID", {
                params: {
                    HCusID: HCusID
                }
            }).then(response => {
                this.form.联系人 = response.data.data[0].HLinkMan
                this.form.联系电话 = response.data.data[0].HLinkPhone
                // this.form = response.data.data[0]
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        /** 销售出库子表明细序号 */
        wlxxzbRowSysZbIndex({ row, rowIndex }) {
            row.index = rowIndex + 1;
        },
        /** 编辑页子表添加按钮操作 */
        handleAddSysZb(index, num) {
            if (num == 1 && !index) {
                this.$modal.msgError("请选择一行数据编辑!");
            } else {
                let obj = {
                    HMainID: 0,
                    HSubID: 0,
                    HSourceBillSEQ: '',
                    HBillNo: '',
                    HMaterID: '',
                    HMaterNumber: '',
                    HMaterName: '',
                    HMaterModel: '',
                    HCusModel: '',
                    HCusMaterName: '',
                    HEmpID: 0,
                    HEmpNumber: '',
                    HEmpName: '',
                    HGroupID: 0,
                    HGroupNumber: '',
                    HGroupName: '',
                    HCheckEmpName: '',
                    HBatchNo: '',
                    HMTONo: '',
                    HQty: 0,
                    HMinQty: 0,
                    HBQty: 0,
                    HPackQty: '',
                    HCoilNO: '',
                    HFurnaceNO: '',
                    HFactory: '',
                    HCusID: 0,
                    HCusNumber: '',
                    HCusName: '',
                    HSeOrderBillNo: '',
                    HRemark: '',
                    HProduceDate: this.form.HDate,
                    HExpiryDate: this.form.HDate,
                    HheatNO: '',
                    HAuxPropID: 0,
                    HAuxPropNumber: '',
                    HAuxPropName: '',
                    HUnitID: 0,
                    HUnitNumber: '',
                    HUnitName: '',
                    HAuxQty: '',
                    HExpirationDateFlag: '',
                    HGiveAwayFlag: '',
                    HDate: this.form.HDate,
                }
                if (index) {
                    this.editWlxxData.splice(index, 0, obj);
                    this.$set(this.editWlxxData, index, obj)
                } else {
                    this.editWlxxData.push(obj);
                }
            }
        },
        handleCopyZbRow() {
            if (!this.zbIndex) {
                this.$modal.msgError("请选择一行数据")
            } else {
                let copyRow = JSON.parse(JSON.stringify(this.zbSelForm))
                this.editWlxxData.push(copyRow);
            }
        },
        /** 编辑页子表删除按钮操作 */
        handleDeleteSysZb(row) {
            this.checkedSysZb = []
            this.checkedSysZb.push(row.index)
            if (this.checkedSysZb.length == 0) {
                this.$modal.msgError("请先选择要删除的商品订单明细数据");
            } else {
                const editWlxxData = this.editWlxxData;
                const checkedSysZb = this.checkedSysZb;
                this.editWlxxData = editWlxxData.filter(function (item) {
                    return checkedSysZb.indexOf(item.index) == -1
                });
            }
        },
        /** 编辑页子表复选框选中数据 */
        handleTableWlxxZbEdit(selection) {
            this.checkedSysZb = selection.map(item => item.index)
            this.zbSelForm = selection[0]
            this.zbIndex = this.checkedSysZb[0]
            if (selection.length > 1) {
                const del_row = selection.shift()
                this.$refs.wlxxzbTable.toggleRowSelection(del_row, false) //设置这一行取消选中
            }
        },
        showReset() {
            this.deptShow = false
            this.warehouseShow = false
            this.materialShow = false
            this.gyEmployeeShow = false
        },
        //  打开数据列表弹窗
        openDataDialog(num, row) {
            //num1部门,2出库仓库,3物料,4销售员
            if (row) {
                this.zbIndex = row.index - 1
            }
            this.showReset()
            if (num == 1) {
                this.dialogTitle = '部门列表'
                this.deptShow = true
                this.openData = true
            } else if (num == 2) {
                this.dialogTitle = '出库仓库列表'
                this.warehouseShow = true
                this.openData = true
            } else if (num == 3) {
                this.dialogTitle = '物料列表'
                this.materialShow = true
                this.openData = true
            } else if (num == 4) {
                this.dialogTitle = '销售员列表'
                this.gyEmployeeShow = true
                this.openData = true
            }
        },
    }
};
</script>