<template>
    <div>
        <div class="divborder newSearchDiv">
            <div class="filter">
                <label>仓库名称：</label>
                <Select v-model="name" clearable class="searchSelect">
                    <Option
                        v-for="item in storeList"
                        :value="item.id"
                        :key="item.id"
                        >{{ item.name }}</Option
                    >
                </Select>
            </div>
            <div class="filter">
                <label>单号：</label>
                <Select v-model="orderNum" clearable class="searchSelect">
                    <Option
                        v-for="item in billCodes"
                        :value="item.name"
                        :key="item.id"
                        >{{ item.name }}</Option
                    >
                </Select>
            </div>
            <div class="filter">
                <label>料号：</label>
                <Select
                    v-model="materialCode"
                    clearable
                    class="searchSelect"
                    filterable
                    remote
                    :remote-method="getMaterialPn"
                    label-in-value
                >
                    <!-- <Option value="" style="color:red">数据过多请继续输入搜索内容</Option> -->
                    <Option
                        v-for="(item, index) in pnList"
                        :value="item.id"
                        :key="item.id"
                        :label="item.name"
                    >
                        <span>{{ item.name }}</span>
                    </Option>
                </Select>
            </div>
            <div class="filter">
                <label>原始单号：</label>
                <Select v-model="originalOrder" clearable class="searchSelect">
                    <Option
                        v-for="item in originalOrderList"
                        :value="item.origin_order_number"
                        :key="item.id"
                        >{{ item.origin_order_number }}</Option
                    >
                </Select>
            </div>
            <!-- 次级搜索条件--隐藏 -->
            <div v-show="!morecondition">
                <div class="filter">
                    <label>{{ $t("900908") }}：</label>
                    <DatePicker
                        type="datetimerange"
                        format="yyyy-MM-dd HH:mm:ss"
                        :clearable="false"
                        v-model="index_time"
                        class="searchInput MaxWidth"
                    ></DatePicker>
                </div>
            </div>
            <div class="searchBtn">
                <Button
                    type="primary"
                    class="twoWord"
                    icon="ios-search"
                    @click="search(1, 10)"
                    >{{ $t("1001") }}</Button
                >
            </div>
            <!-- 更多条件 按钮组件 -->
            <MoreConbtn
                @getCon="morecondition = !morecondition"
                :morecondition="morecondition"
            ></MoreConbtn>
        </div>
        <div class="divborder newTableDiv">
            <Table
                class="tableClass"
                @on-current-change="handleRowChange"
                highlight-row
                :data="tableData1"
                :columns="tableColumns1"
            ></Table>
            <div class="pageDiv">
                <div class="pageDirection">
                    <Page
                        :total="total"
                        :current="page"
                        @on-change="changePage"
                        show-elevator
                        show-sizer
                        show-total
                        @on-page-size-change="handlePageSize"
                        :page-size-opts="[10, 20, 30, 40, 100]"
                    ></Page>
                </div>
            </div>
        </div>
        <div class="divborder newTableDiv" v-show="show">
            <Table
                class="tableClass"
                highlight-row
                :data="tableData3"
                :columns="tableColumns3"
            ></Table>
            <div class="pageDiv">
                <div class="pageDirection">
                    <Page
                        :total="total3"
                        :current="page3"
                        @on-change="changePage1"
                        show-elevator
                        show-sizer
                        show-total
                        @on-page-size-change="handlePageSize1"
                        :page-size-opts="[10, 20, 30, 40, 100]"
                    ></Page>
                </div>
            </div>
        </div>
        <!-- 模态框 -->
        <Modal
            class="newModalClass"
            v-model="modal1"
            title="批量入库"
            :styles="{ width: '640px' }"
        >
            <div class="modal_body">
                <div class="filter">
                    <label> 单号： </label>
                    <Input
                        type="text"
                        class="searchInput"
                        disabled
                        v-model="code"
                    />
                </div>
                <div class="filter">
                    <label> 料号： </label>
                    <Input
                        type="text"
                        disabled
                        class="searchInput"
                        v-model="mtcode"
                    />
                </div>
                <div class="filter">
                    <label>储位：</label>
                    <Select
                        v-model="storageLocation"
                        clearable
                        class="searchSelect"
                        transfer-class-name="location"
                    >
                        <Option
                            v-for="item in storageList"
                            :value="item.id"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                </div>
                <div class="filter">
                    <label>入库数量：</label>
                    <InputNumber
                        :min="0"
                        class="searchInput"
                        v-model="number"
                        @on-change="getCount"
                    />
                </div>
            </div>
            <div slot="footer">
                <Button type="text" size="large" @click="modal1 = false">{{
                    $t("1033")
                }}</Button>
                <Button
                    type="primary"
                    size="large"
                    :loading="loading"
                    @click="warehousingPost(3)"
                    >入库</Button
                >
            </div>
        </Modal>
        <Modal
            class="newModalClass"
            v-model="modal2"
            title="序号入库"
            :styles="{ width: '1000px' }"
        >
            <div class="modal_body" style="margin-right: 40px">
                <div class="divborder row1">
                    <div class="inblock">
                        <label>单号：</label>
                        <Input
                            type="text"
                            class="searchInput"
                            disabled
                            v-model="code"
                        />
                    </div>
                    <div class="inblock">
                        <label>料号：</label>
                        <Input
                            type="text"
                            disabled
                            class="searchInput"
                            v-model="mtcode"
                        />
                    </div>
                    <div class="inblock">
                        <label>总数：</label>
                        <Input
                            type="text"
                            disabled
                            class="searchInput"
                            v-model="totalNum"
                        />
                    </div>
                    <div class="inblock">
                        <label>已入库：</label>
                        <Input
                            type="text"
                            disabled
                            class="searchInput"
                            v-model="storedNum"
                        />
                    </div>
                    <div class="inblock">
                        <label>储位：</label>
                        <Select v-model="storageLocation" class="searchSelect">
                            <Option
                                v-for="item in storageList"
                                :value="item.id"
                                :key="item.id"
                                >{{ item.name }}</Option
                            >
                        </Select>
                    </div>
                    <div class="inblock">
                        <label style="width: 200px">使用来料序号入库</label>
                        <Checkbox
                            v-model="useorder"
                            style="width: 30px; text-align: center"
                        ></Checkbox>
                    </div>
                    <div class="inblock">
                        <label>序号：</label>
                        <Input
                            type="text"
                            :disabled="useorder == false"
                            class="searchInput"
                            v-model="order"
                        />
                    </div>
                    <div class="inblock" v-show="useorder == false">
                        <label>入库数量：</label>
                        <InputNumber
                            :min="0"
                            class="searchInput"
                            v-model="number"
                            @on-change="getCount"
                        />
                    </div>
                    <div class="inblock">
                        <Button
                            type="primary"
                            icon="ios-search"
                            @click="warehousingPost(2)"
                            :loading="loading"
                            >入库</Button
                        >
                    </div>
                </div>
                <div class="divborder">
                    <Table
                        style="margin-top: 10px"
                        :data="tableData2"
                        :columns="tableColumns2"
                    ></Table>
                    <div style="margin: 10px; overflow: hidden">
                        <div style="float: right">
                            <Page
                                :total="total2"
                                :current="page2"
                                @on-change="changePage2"
                                show-elevator
                                show-sizer
                                show-total
                                @on-page-size-change="handlePageSize2"
                                :page-size-opts="[10, 20, 30, 40, 100]"
                            ></Page>
                        </div>
                    </div>
                </div>
            </div>
            <div slot="footer">
                <Button type="text" size="large" @click="modal2 = false">{{
                    $t("1033")
                }}</Button>
                <Button type="primary" size="large" @click="modal2 = false"
                    >确定</Button
                >
            </div>
        </Modal>
        <!--  -->
        <Modal
            class="newModalClass"
            v-model="modal3"
            title="批次入库"
            :styles="{ width: '900px' }"
        >
            <div class="modal_body" style="margin-right: 40px">
                <div class="divborder row1">
                    <div class="inblock">
                        <label>单号：</label>
                        <Input
                            type="text"
                            class="searchInput"
                            disabled
                            v-model="code"
                        />
                    </div>
                    <div class="inblock">
                        <label>料号：</label>
                        <Input
                            type="text"
                            disabled
                            class="searchInput"
                            v-model="mtcode"
                        />
                    </div>
                    <div class="inblock">
                        <label style="width: 200px !important"
                            >使用来料批次号入库</label
                        >
                        <Checkbox
                            v-model="useorder"
                            style="width: 50px !important; text-align: center"
                        ></Checkbox>
                    </div>
                    <div class="inblock">
                        <label>序号：</label>
                        <Input
                            type="text"
                            :disabled="useorder == false"
                            class="searchInput"
                            v-model="order"
                        />
                    </div>
                    <div class="inblock">
                        <label>生产日期：</label>
                        <DatePicker
                            type="datetime"
                            format="yyyy-MM-dd HH:mm:ss"
                            :clearable="false"
                            v-model="productDate"
                            class="searchInput"
                        ></DatePicker>
                    </div>
                    <div class="inblock">
                        <label>储位：</label>
                        <Select v-model="storageLocation" class="searchSelect">
                            <Option
                                v-for="item in storageList"
                                :value="item.id"
                                :key="item.id"
                                >{{ item.name }}</Option
                            >
                        </Select>
                    </div>
                    <div class="inblock">
                        <label>入库数量：</label>
                        <InputNumber
                            :min="0"
                            class="searchInput"
                            v-model="number"
                            @on-change="getCount"
                        />
                    </div>
                </div>
            </div>
            <div slot="footer">
                <Button type="text" size="large" @click="modal3 = false">{{
                    $t("1033")
                }}</Button>
                <Button
                    type="primary"
                    size="large"
                    :loading="loading"
                    @click="warehousingPost(1)"
                    >入库</Button
                >
            </div>
        </Modal>
        <Modal v-model="preview" :styles="{ width: '400px' }">
            <div slot="header">是否调用打印机</div>
            <div>
                <div
                    id="printContent"
                    ref="print"
                    style="width: 150px; font-size: 14px; line-height: 20px"
                >
                    <div
                        class="printItem"
                        v-for="(item, index) in printDetail"
                        :key="index"
                    >
                        <p style="padding-left: 10px">
                            品名 {{ item.material_name }}
                        </p>
                        <p style="padding-left: 10px">
                            规格 {{ item.material_spec }}
                        </p>
                        <p style="padding-left: 10px">日期 {{ item.time }}</p>
                        <svg :id="'barcode' + index" />
                    </div>
                </div>

                <!-- <barcode
                :value="printDetail.code"
                :options="{ width:4,height:50,
             background:'rgba(255,255,255,.0)'}"
                ></barcode>-->
            </div>
            <div slot="footer">
                <Button type="text" size="large" @click="preview = false">{{
                    $t("1033")
                }}</Button>
                <!-- <Button type="primary" @click="printPreview(1)">打印预览</Button> -->
                <Button type="primary" @click="printPreview(0)"
                    >直接打印</Button
                >

                <!-- <Button
                    type="primary"
                    size="large"
                    v-print="'#printContent'"
                    @click="preview=false"
                >确定</Button>-->
            </div>
        </Modal>
        <!-- <div slot="overlay">
            <Button type="primary" @click="printPreview(0)">直接打印</Button>
            <Button type="primary" @click="printPreview(1)">打印预览</Button>
            <Button type="primary" @click="printPreview(2)">打印维护</Button>
            <Button type="primary" @click="printPreview(3)">打印设计</Button>
        </div>-->
    </div>
</template>

<script>
// import { getLodop } from "@/assets/js/LodopFuncs";
import { getLodop } from "../../../static/Clodop/LodopFuncs";


import moment from "moment";
import VueBarcode from "vue-barcode";
import Vue from "vue";
Vue.component("barcode", VueBarcode);

export default {
    components: {},
    data() {
        return {
            morecondition: false, // 条件
            name: "",
            storeList: [],
            orderNum: "",
            billCodes: "",
            materialCode: "",
            codeList: "",
            originalOrder: "",
            originalOrderList: "",
            pnList: [],
            index_time: [],
            tableData1: [],
            total: 0,
            page: 1,
            pagesize: 10,
            tableColumns1: [
                {
                    type: "index2",
                    title: this.$t("1008"),
                    key: "xuhao",
                    render: (h, params) => {
                        return h(
                            "span",
                            params.index + (this.page - 1) * this.pagesize + 1
                        );
                    },
                },
                {
                    title: "单号",
                    key: "billCode",
                },
                {
                    title: "供应商",
                    key: "businessName",
                },
                {
                    title: "料号",
                    key: "material_pn",
                },
                {
                    title: "管理模式",
                    key: "manage_modeName",
                },
                {
                    title: "名称",
                    key: "material_name",
                },
                {
                    title: "规格",
                    key: "material_spec",
                },
                {
                    title: "总数量",
                    key: "quantity",
                },
                {
                    title: "入库数量",
                    key: "access_quantity",
                },
                {
                    title: "操作",
                    key: "action",
                    align: "center",
                    render: (h, params) => {
                        return h("div", [
                            h(
                                "p",
                                {
                                    style: {
                                        color: "#2D8CF0",
                                        cursor: "pointer",
                                    },
                                    on: {
                                        click: (row) => {
                                            if (params.row.manage_mode == 1) {
                                                this.modal3 = true;
                                            }
                                            if (params.row.manage_mode == 2) {
                                                this.modal2 = true;
                                                this.getDetail(1, 10);
                                            }
                                            if (params.row.manage_mode == 3) {
                                                this.modal1 = true;
                                            }

                                            this.code = params.row.billCode;
                                            this.mtcode =
                                                params.row.material_pn;
                                            this.totalNum = params.row.quantity;
                                            this.storedNum =
                                                params.row.access_quantity;
                                            this.storageLocation = "";
                                            this.number = 0;
                                            this.useorder = false;
                                            this.order = "";

                                            this.getStorageLocation(
                                                params.row.storageid
                                            );
                                        },
                                    },
                                },
                                "入库"
                            ),
                        ]);
                    },
                },
            ],
            detailobj: {},
            modal1: false,
            modal2: false,
            modal3: false,
            code: "",
            mtcode: "",
            storageLocation: "",
            storageList: [],
            useorder: false,
            order: "",
            totalNum: "",
            storedNum: "",
            tableData2: [],
            total2: 0,
            page2: 1,
            pagesize2: 10,
            tableColumns2: [
                {
                    type: "index2",
                    title: this.$t("1008"),
                    key: "xuhao",
                    render: (h, params) => {
                        return h(
                            "span",
                            params.index + (this.page2 - 1) * this.pagesize2 + 1
                        );
                    },
                },
                {
                    title: "单号",
                    key: "billID",
                },
                {
                    title: "料号",
                    key: "inventorySN",
                },
                {
                    title: "序号",
                    key: "no",
                },
                {
                    title: "名称",
                    key: "inventoryName",
                },
                {
                    title: "规格",
                    key: "inventorySpec",
                },
                {
                    title: "储位",
                    key: "locationname",
                    render: (h, params) => {
                        return h("div", [
                            h(
                                "Tooltip",
                                {
                                    props: {
                                        placement: "top",
                                        transfer: true,
                                    },
                                },
                                [
                                    params.row.locationname,
                                    h(
                                        "span",
                                        {
                                            slot: "content",
                                            style: {
                                                whiteSpace: "normal",
                                            },
                                        },
                                        params.row.locationname1
                                    ),
                                ]
                            ),
                        ]);
                    },
                },
                {
                    title: "入库人",
                    key: "username",
                },
                {
                    title: "入库时间",
                    key: "updatetime",
                },
            ],
            useorder1: false,
            productDate: "",
            number: 0,
            show: false,
            total3: 0,
            page3: 1,
            pagesize3: 10,
            tableData3: [],
            tableColumns3: [
                {
                    type: "index2",
                    title: this.$t("1008"),
                    key: "xuhao",
                    render: (h, params) => {
                        return h(
                            "span",
                            params.index + (this.page3 - 1) * this.pagesize3 + 1
                        );
                    },
                    width: 70,
                },
                {
                    title: "单号",
                    key: "billID",
                },
                {
                    title: "供应商",
                    key: "businessName",
                },
                {
                    title: "料号",
                    key: "inventorySN",
                },
                {
                    title: "总数量",
                    key: "allqty",
                },
                {
                    title: "入库数量",
                    key: "qty",
                },
                {
                    title: "批次号",
                    key: "batch",
                },
                {
                    title: "序号",
                    key: "no",
                },
                {
                    title: "入库人",
                    key: "username",
                },
                {
                    title: "入库时间",
                    key: "updatetime",
                },
            ],
            printDetail: [],
            preview: false,
            loading: false,
        };
    },
    created() {
        this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1);
        this.tableColumns2 = this.$time.initTableTitle(this.tableColumns2);
        this.tableColumns3 = this.$time.initTableTitle(this.tableColumns3);
        this.index_time = [
            moment(new Date().getTime() - 3600 * 1000 * 24 * 7).format(
                "YYYY-MM-DD "
            ) + "00:00:00",
            moment(new Date().getTime()).format("YYYY-MM-DD ") + "23:59:59",
        ];
        this.search(1, 10);
        this.initData();
    },
    methods: {
        initData() {
            this.getStoreList();
            // this.getType();
            // this.getState();
            this.getOrderList();
            // this.getSupplier();
            this.getMaterialPn();
            this.getBill();
            this.getStorageLocation();
        },
        // 仓库名称
        getStoreList() {
            this.request("/wms/WaveHouse/GetWaveHouseNameList", "", "get").then(
                (res) => {
                    if (res.data.ret == 1) {
                        this.storeList = res.data.data;
                    }
                }
            );
        },
        // 原始单号
        getOrderList() {
            this.request(
                "/wms/WaveHousing/GetOriginOrderNumbers?type=1",
                "",
                "get"
            ).then((res) => {
                // console.log(res.data);
                if (res.data.ret == 1) {
                    this.originalOrderList = res.data.data;
                }
            });
        },
        getBill() {
            var data = {
                type: 1, // 1入库，2出库
                storageid: this.name,
            };
            this.request("/wms/WaveHousing/GetBillCodes", data, "get").then(
                (res) => {
                    // console.log(res.data);
                    if (res.data.ret == 1) {
                        this.billCodes = res.data.data;
                    }
                }
            );
        },
        getMaterialPn(query) {
            if (query !== "") {
                // this.loading1 = true;
                setTimeout(() => {
                    let data = {
                        type: 1,
                        billCode: this.orderNum,
                        pn: query,
                        count: 50,
                    };
                    this.request(
                        "/wms/WaveHousing/GetInventoryNameList",
                        data,
                        "get"
                    ).then((res) => {
                        // console.log(res.data.data);
                        if (res.data.ret == 1) {
                            this.pnList = res.data.data;
                        }
                    });
                }, 200);
            } else {
                this.pnList = [];
            }
        },
        getStorageLocation(id) {
            let data = {
                storageid: id,
            };
            this.request("/wms/Location/GetLastLocation", data, "get").then(
                (res) => {
                    // console.log(res.data);
                    if (res.data.ret == 1) {
                        this.storageList = res.data.data;
                    }
                }
            );
        },
        search(page, pagesize) {
            let starttime = this.index_time[0];
            let endtime = this.index_time[1];

            this.page = page;
            this.pagesize = pagesize;
            var data = {
                type: 1, // 1入库2出库
                dataFilter: 1, // 0获取所有数据，1获取审核数据
                wavehouseid: this.name,
                billCode: this.orderNum,
                inventoryid: this.materialCode,
                originOrderNumber: this.originalOrder,
                start: starttime,
                end: endtime,
                page: page,
                pageSize: pagesize,
            };
            this.request("/wms/Stock/GetBillList", data, "get").then((res) => {
                if (res.data.ret == 1) {
                    // this.typeList = res.data.data;
                    this.total = res.data.total;
                    let arr = res.data.data;
                    let list = [];
                    arr.forEach((item) => {
                        list.push({
                            id: item.id,
                            storageid: item.storageid,
                            billCode: item.billCode,
                            material_id: item.material_id,
                            material_name: item.material_name,
                            material_pn: item.material_pn,
                            material_spec: item.material_spec,
                            businessName: item.businessName,
                            businessid: item.businessid,
                            manage_modeName: item.manage_modeName,
                            manage_mode: item.manage_mode,
                            quantity: item.quantity,
                            access_quantity: item.access_quantity,
                            stateid: item.stateid,
                            auditdesc: item.auditdesc, // 审核备注
                        });
                    });
                    this.tableData1 = list;
                }
            });
        },
        getCount(data) {
            if (
                data >
                this.detailobj.quantity - this.detailobj.access_quantity
            ) {
                this.$Message.error("入库数量不能大于应入库数量");
                data = this.detailobj.quantity - this.detailobj.access_quantity;
                // return false;
            }
        },
        warehousingPost(type) {
            this.loading = true;
            if (!this.storageLocation) {
                this.$Message.error("请选择储位");
                this.loading = false;
                return false;
            }
            // console.log(this.storageLocation)
            let data = {};
            let code = this.useorder == true ? 1 : 0;
            if (type == 1) {
                if (
                    this.number == 0 ||
                    this.number == undefined ||
                    this.number == ""
                ) {
                    this.$Message.error("请输入入库数量");
                    this.loading = false;

                    return false;
                }
                if (code == 1) {
                    if (this.order == "") {
                        this.$Message.error("请输入批次号");
                        this.loading = false;

                        return false;
                    }
                }

                data = {
                    id: this.detailobj.id,
                    locationid: this.storageLocation,
                    count: this.number,
                    type: 1,
                    useSourceBatch: code,
                    batchCode: this.order,
                    productingTime: this.productDate,
                    businessID: this.detailobj.businessid,
                    isReceiving: 0,
                };
            }
            if (type == 2) {
                if (code == 1) {
                    if (this.order == "") {
                        this.$Message.error("请输入序号");
                        this.loading = false;

                        return false;
                    }
                    this.number = 1;
                } else {
                    if (
                        this.number == 0 ||
                        this.number == undefined ||
                        this.number == ""
                    ) {
                        this.$Message.error("请输入入库数量");
                        this.loading = false;

                        return false;
                    }
                }

                data = {
                    id: this.detailobj.id,
                    locationid: this.storageLocation,
                    count: this.number,
                    type: 2,
                    useSourceBatch: code,
                    No: this.order,
                    businessID: this.detailobj.businessid,
                    isReceiving: 0,
                };
            }

            if (type == 3) {
                if (
                    this.number == 0 ||
                    this.number == undefined ||
                    this.number == ""
                ) {
                    this.$Message.error("请输入入库数量");
                    this.loading = false;

                    return false;
                }

                data = {
                    id: this.detailobj.id,
                    locationid: this.storageLocation,
                    count: this.number,
                    businessID: this.detailobj.businessid,
                    type: 3,
                    isReceiving: 0,
                };
            }
            if (
                this.number >
                this.detailobj.quantity - this.detailobj.access_quantity
            ) {
                this.$Message.error("入库数量不能大于应入库数量");
                this.loading = false;

                return false;
            }
            // console.log(data);

            // debugger
            // return false;
            this.request("/wms/Stock/CheckIn", data, "post").then((res) => {
                // console.log(res.data.data);
                if (res.data.ret == 1) {
                    this.loading = false;
                    if (type != 3) {
                        this.printDetail = res.data.data;
                        var JsBarcode = require("jsbarcode");
                        setTimeout(() => {
                            this.preview = true;
                            for (
                                let index = 0;
                                index < this.printDetail.length;
                                index++
                            ) {
                                let element = "#barcode" + index;
                                JsBarcode(
                                    element,
                                    this.printDetail[index].code,
                                    {
                                        lineColor: "#000",
                                        width: 1,
                                        height: 50,
                                        displayValue: false,
                                    }
                                );
                            }
                        }, 1000);
                    }

                    // document.getElementById("print").click();

                    // this.$Message.success("入库成功");
                    this.modal1 = false;
                    if (type == 2) {
                        this.modal2 = false;
                        this.getDetail(this.page1, this.pagesize1);
                    }
                    this.modal3 = false;
                    this.search(this.page, this.pagesize);

                    // 需要打印
                    // 批量不需要打印，批次和序号需要调用打印接口
                } else {
                    this.$Message.error(this.$t("" + res.data.msg));
                }
            });
        },
        print() {
            this.$print(this.$refs.print, {});
        },
        printPreview(s) {
            // this.CreateOneFormPage();
            if (s == 0) {
                this.CreateOneFormPage();

                LODOP.PRINT(); // 直接打印
            }
            if (s == 1) {
                LODOP.PREVIEW(); // 打印预览
            }
            if (s == 2) {
                LODOP.PRINT_SETUP(); // 打印维护
            }
            if (s == 3) {
                LODOP.PRINT_DESIGN(); // 打印设计
            }
        },
        CreateOneFormPage() {
            LODOP = getLodop();
            // 样式
            var olstyle1 =
                "<style>" + document.getElementById("tese") + "</style>";
            var body =
                "<body>" +
                document.getElementById("printContent").innerHTML +
                "</body>";
            // LODOP.PRINT_INIT(""); // 打印初始化
            // LODOP.SET_PRINT_STYLE("FontSize", 18); // 设置对象风格
            // LODOP.SET_PRINT_STYLE("Bold", 1); /// /设置对象风格
            // LODOP.ADD_PRINT_TEXT(50, 521, 130, 39, this.description); // 增加纯文本项
            // LODOP.SET_PRINT_PAGESIZE(0, 400, 600, ""); // 设定纸张大小
            // LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT", "60%"); // 设置缩放
            // LODOP.SET_PREVIEW_WINDOW(2, 2, 0, 0, 0, ""); // 设置窗口
            // 打印二维码
            // LODOP.ADD_PRINT_BARCODE(23,23,233,233,"QRCode","https://blog.csdn.net/qq_43652509");
            for (let i = 0; i < this.printDetail.length; i++) {
                let list = document.querySelectorAll(".printItem");
                // console.log(list[i].innerHTML);
                var html = "";
                html = "<body>" + list[i].innerHTML;
                ("</body>");
                LODOP.PRINT_INIT(""); // 打印初始化
                LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT", "60%");
                LODOP.ADD_PRINT_HTM(10, 30, 400, 300, html);
                LODOP.PRINT();
            }

            // LODOP.ADD_PRINT_HTM(10, 20, 400, 300, body); // 增加超文本项
        },
        getDetail(page, pagesize) {
            let data = {
                type: 1, // 入库1 出库2
                billCode: this.detailobj.billCode, // 单号
                inventorySN: this.detailobj.material_pn,
                businessID: this.detailobj.businessid,
                page: page,
                pageSize: pagesize,
            };
            this.request("/wms/Stock/GetBillTrace", data, "get").then((res) => {
                // console.log(res.data.data);
                if (res.data.ret == 1) {
                    this.total2 = res.data.total;
                    this.total3 = res.data.total;
                    this.page2 = res.data.page;
                    this.pagesize2 = res.data.pagesize;
                    // this.total1 = res.data.total;
                    let arr = res.data.data;
                    let list = [];
                    arr.forEach((item) => {
                        let location = item.locationname;
                        let a = location.split("->");
                        // console.log(location);
                        if (a.length > 1) {
                            location =
                                a[0] +
                                "->...->" +
                                a[a.length - 2] +
                                "->" +
                                a[a.length - 1];
                        }
                        list.push({
                            id: item.id,
                            locationname: location,
                            locationname1: item.locationname,
                            locationid: item.locationid,
                            billID: item.billID,
                            material_id: item.material_id,
                            inventoryName: item.inventoryName,
                            inventorySN: item.inventorySN,
                            inventorySpec: item.inventorySpec,
                            businessName: item.businessName,
                            businessid: item.businessid,
                            manage_modeName: item.manage_modeName,
                            username: item.username,
                            allqty: item.allqty,
                            qty: item.qty,
                            batch: item.batch,
                            no: item.no,
                            updatetime: item.updatetime, // 审核备注
                        });
                    });
                    this.tableData3 = list;
                    this.tableData2 = list;
                }
            });
        },
        handleRowChange(currentRow, oldCurrentRow) {
            this.detailobj = currentRow;
            this.getDetail(1, 10);
            this.show = true;
            console.log(this.detailobj);
        },
        handlePageSize(value) {
            this.pagesize = value;
            this.tableData1 = this.search(this.page, this.pagesize);
            this.show = false;
        },
        changePage(value) {
            this.page = value;
            this.tableData1 = this.search(this.page, this.pagesize);
            this.show = false;
        },
        handlePageSize1(value) {
            this.pagesize3 = value;
            this.tableData3 = this.getDetail(this.page3, this.pagesize3);
        },
        changePage1(value) {
            this.page3 = value;
            this.tableData3 = this.getDetail(this.page3, this.pagesize3);
        },
        handlePageSize2(value) {
            this.pagesize1 = value;
            this.getDetail(this.page1, this.pagesize1);
        },
        changePage2(value) {
            this.page1 = value;
            this.getDetail(this.page1, this.pagesize1);
        },
        request(url, data, type) {
            if (type == "get") {
                return this.axios
                    .request({
                        url: url,
                        params: data,
                        method: type,
                    })
                    .then((res) => {
                        return res;
                    })
                    .catch((error) => error);
            } else {
                return this.axios
                    .request({
                        url: url,
                        data,
                        method: type,
                    })
                    .then((res) => {
                        return res;
                    })
                    .catch((error) => error);
            }
        },
    },
};
</script>

<style scoped>
.row1 {
    display: flex;
    flex-wrap: wrap;
}
.inblock {
    margin: 0 10px;
    height: 40px;
    line-height: 40px;
    /* display: inline-block; */
}
.location {
    width: 500px;
    white-space: normal;
}
</style>
