<template>
    <div>
        <el-tabs type="border-card">
            <el-tab-pane label="库存">
                <el-card :body-style="cardBodyStyle">
                    <el-form :model="query" label-width="auto" label-position="right" ref="queryFormRef">
                        <el-row :gutter="10">
                            <el-col :span="5">
                                <el-form-item label="库房名称" style="margin-bottom: 5px;" prop="storeNm">
                                    <el-input v-model="query.storeNm" placeholder="请输入库房名称" clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="物料名称" style="margin-bottom: 5px;" prop="itemNm">
                                    <el-input v-model="query.itemNm" placeholder="请输入物料名称" clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="物料类型" style="margin-top: 5px;margin-bottom: 5px;" prop="itemType">
                                    <el-select v-model="query.itemType" style="width: 100%" placeholder="物料类型"
                                        clearable>
                                        <el-option v-for="item in dictList.item_sort3" :key="item.dicCode"
                                            :label="item.dicName" :value="item.dicCode" />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-card>

                <ButtonBox @search="handleSearch"></ButtonBox>

                <el-card :body-style="cardBodyStyle">
                    <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange"
                        >
                        <el-table-column type="selection" fixed></el-table-column>
                        <el-table-column type="index" label="序号" align="center" width="60">
                            <template #default="scope">
                                <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="true" prop="storeCd" label="库房代码" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="storeNm" label="库房名称" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="areaCd" label="区号" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="stackCd" label="垛位号" width="180" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="storeType" label="库房类型" :formatter="formatter" width="120"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemCd" label="物料编码" width="180" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemNm" label="物料名称" width="180" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="qty" label="库存现有量" width="140" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="qtyWet" label="湿基量" width="140" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="purOrdNo" label="采购订单号" width="300" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="purOrdLn" label="采购订单行号" width="300" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemType" label="物料类型" width="240" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="uom" label="计量单位" width="240" :formatter="formatter"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>

                        <el-table-column v-if="true" prop="lastName" label="最后操作人" width="300" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="lastTime" label="最后操作时间" width="360" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="remarks" label="备注" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="price" label="物料成本" width="240" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="batchNo" label="批次号" width="180" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="compCd" label="公司代码" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="deptCd" label="部门代码" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>

                        <el-table-column label="操作" header-align="center" align="center" width="180px" fixed="right">
                            <template #default="scope">
                                <el-button plain type="primary" @click="handleEdit(scope.row)">调拨</el-button>
                                <!--            <el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>-->
                                <!--            <el-button plain type="danger" @click="handleDelete(scope.row )">删除</el-button>-->
                            </template>
                        </el-table-column>
                    </el-table>
                </el-card>
                <el-card :body-style="cardBodyStyle">
                    <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes"
                        :total="totalRows" background="background" layout="total, sizes, prev, pager, next, jumper"
                        @size-change="handleSizeChange" @current-change="handleCurrentChange">
                    </el-pagination>
                </el-card>
            </el-tab-pane>

            <el-tab-pane label="调拨单" name="master1">

                <el-card :body-style="cardBodyStyle">
                    <el-form :model="query" label-position="right" :inline="true">
                        <el-row :gutter="10" style="margin-bottom: 5px;">
                            <el-col :span="5">
                                <el-form-item label="调拨单号" style="margin-bottom: 0px;">
                                    <el-input v-model="query.transferNo" placeholder="请输入" clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="物料名称" style="margin-bottom: 0px;">
                                    <el-input v-model="query.itemNm" placeholder="请输入" clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="调拨部门" style="margin-bottom: 0px;">
                                    <el-input v-model="query.addDeptName" placeholder="请输入" clearable></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-card>

                <ButtonBar @search="handleSearch"></ButtonBar>

                <el-card :body-style="cardBodyStyle">
                    <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange"
                        @row-click="DoubleClick">
                        <el-table-column type="selection" fixed></el-table-column>
                        <el-table-column type="index" label="序号" align="center" width="60" fixed="left">
                            <template #default="scope">
                                <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="false" prop="transferNm" label="调拨单名称" width="200" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="transferNo" label="调拨单号" width="200" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="transferLn" label="调拨单行号" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemCd" label="物料编码" width="150" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemNm" label="物料名称" width="150" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemType" label="物料类型" width="150" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="specType" label="规格型号" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="quantity" label="调拨申请量" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="inQuantity" label="实际出库量" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="uom" label="单位" header-align="center" align="center"
                            width="100" show-overflow-tooltip :formatter="formatter">
                        </el-table-column>
                        <el-table-column v-if="true" prop="outStoreCd" label="调出库房编码" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="outStoreNm" label="调出库房" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="inStoreCd" label="调入库房编码" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="inStoreNm" label="调入库房" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="tradePartnerCode" label="供应商编码" width="180"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="tradePartnerName" label="供应商名称" width="180"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="reqSts" label="调拨状态" header-align="center" align="center"
                            min-width="100" show-overflow-tooltip :formatter="formatter">
                        </el-table-column>
                        <el-table-column v-if="false" prop="addDeptName" label="调拨部门" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="addName" label="调拨人" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="transferDt" label="调拨日期" width="200" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="requirePlanNo" label="需求计划" header-align="center"
                            align="center" width="160" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column label="操作" header-align="center" align="center" width="150px" fixed="right">
                            <template #default="{ row }">
                                <el-button plain type="primary" @click="handleAdd(row)">调拨</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-card>

                <el-card :body-style="cardBodyStyle">
                    <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes"
                        :total="totalRows" background="background" layout="total, sizes, prev, pager, next, jumper"
                        @size-change="handleSizeChange" @current-change="handleCurrentChange">
                    </el-pagination>
                </el-card>

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

        <el-tabs type="border-card">
            <el-tab-pane label="调拨记录">
                <el-card :body-style="cardBodyStyle">
                    <el-form :model="queryRecord" label-width="auto" label-position="right" ref="queryFormRef">
                        <el-row :gutter="10">
                            <el-col :span="5">
                                <el-form-item label="调拨单号" style="margin-bottom: 5px;" prop="pickRecordNo">
                                    <el-input v-model="queryRecord.pickRecordNo" placeholder="请输入库房名称"
                                        clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="库房名称" style="margin-bottom: 5px;" prop="storeNm">
                                    <el-input v-model="queryRecord.storeNm" placeholder="请输入库房名称" clearable></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="5">
                                <el-form-item label="物料名称" style="margin-bottom: 5px;" prop="itemNm">
                                    <el-input v-model="queryRecord.itemNm" placeholder="请输入物料名称" clearable></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-card>
                <ButtonBox @searchRecord="handleSearchRecord" area="bottom"></ButtonBox>
                <el-card :body-style="cardBodyStyle">
                    <el-table :data="tableDataRecord" border highlight-current-row
                        @selection-change="handleSelectionChange" >
                        <!--            <el-table-column type="selection" fixed></el-table-column>-->
                        <el-table-column type="index" label="序号" align="center" width="60">
                            <template #default="scope">
                                <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="true" prop="pickRecordNo" label="调拨业务单号" width="180"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemNm" label="物料名称" width="180" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="qty" label="调拨数量" width="140" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="pickType" label="调拨类型" width="140" header-align="center"
                            align="center" show-overflow-tooltip>
                            <template #default="scope">
                                <el-tag type="primary" v-if="scope.row.pickType == '1'"> 调拨 </el-tag>
                                <el-tag type="danger" v-else> 退料</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="true" prop="pickDate" label="调拨时间" width="140" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="storeCd" label="库房代码" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="storeNm" label="库房名称" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="areaCd" label="区号" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="stackCd" label="垛位号" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="storeType" label="库房类型" :formatter="formatter" width="120"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemCd" label="物料编码" width="180" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>

                        <el-table-column v-if="false" prop="qtyWet" label="湿基量" width="140" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="purOrdNo" label="采购订单号" width="300" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="purOrdLn" label="采购订单行号" width="300" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemType" label="物料类型" width="240" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="uom" label="计量单位" width="240" :formatter="formatter"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>


                        <el-table-column v-if="true" prop="remarks" label="备注" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>

                        <el-table-column v-if="true" prop="compCd" label="公司代码" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="deptCd" label="部门代码" width="160" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>


                        <!--            <el-table-column label="操作" header-align="center" align="center" width="180px" fixed="right">-->
                        <!--              <template #default="scope">-->
                        <!--                <el-button plain type="primary" @click="handleEdit(scope.row)">查看</el-button>-->
                        <!--            <el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>-->
                        <!--            <el-button plain type="danger" @click="handleDelete(scope.row )">删除</el-button>-->
                        <!--              </template>-->
                        <!--            </el-table-column>-->
                    </el-table>
                </el-card>
                <el-card :body-style="cardBodyStyle">
                    <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes"
                        :total="totalRows" background="background" layout="total, sizes, prev, pager, next, jumper"
                        @size-change="handleSizeChange" @current-change="handleCurrentChange">
                    </el-pagination>
                </el-card>
            </el-tab-pane>

        </el-tabs>
        
        <el-dialog :close-on-click-modal="false" draggable title="调拨" v-model="dialogVisible" width="1100px"
            class="diaClass" top="5vh" @open="openDialog">
            <el-card>
                <el-form :model="form" label-width="110" label-position="right" inline ref="ruleFormRef" :rules="rules">
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="出库时间" prop="transferDt">
                                <el-date-picker v-model="form.transferDt" type="datetime"
                                    value-format="YYYY-MM-DD HH:mm:ss" style="width: 210px;" :readonly="readonly" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="库存现有量">
                                <el-input-number disabled style="width: 100%" v-model="form.qty" class="mx-4" :min="0"
                                    controls-position="right" @change="handleChange" />

                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="本次调拨量">
                                <el-input-number style="width: 100%" v-model="form.qtyNew" class="mx-4" :min="0"
                                    :step="1" :step-strictly="true" controls-position="right" @change="handleChange" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="16">
                            <el-form-item label="备注">
                                <el-input v-model="form.remarks" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
                                    placeholder="" />
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-table :data="tableDataLine" border highlight-current-row
                        @selection-change="handleSelectionChangeLine">
                        <el-table-column type="selection" fixed></el-table-column>
                        <el-table-column type="index" label="序号" align="center" width="60" fixed="left">
                            <template #default="scope">
                                <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="false" prop="transferNm" label="调拨单名称" width="200" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="transferNo" label="调拨单号" width="200" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="transferLn" label="调拨单行号" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemCd" label="物料编码" width="150" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemNm" label="物料名称" width="150" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="itemType" label="物料类型" width="150" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="specType" label="规格型号" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="quantity" label="调拨申请量" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="inQuantity" label="实际出库量" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="uom" label="单位" header-align="center" align="center"
                            width="100" show-overflow-tooltip :formatter="formatter">
                        </el-table-column>
                        <el-table-column v-if="true" prop="outStoreCd" label="调出库房编码" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="outStoreNm" label="调出库房" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="inStoreCd" label="调入库房编码" width="120" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="inStoreNm" label="调入库房" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="tradePartnerCode" label="供应商编码" width="180"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="tradePartnerName" label="供应商名称" width="180"
                            header-align="center" align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="reqSts" label="调拨状态" header-align="center" align="center"
                            min-width="100" show-overflow-tooltip :formatter="formatter">
                        </el-table-column>
                        <el-table-column v-if="false" prop="addDeptName" label="调拨部门" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="addName" label="调拨人" width="100" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="false" prop="transferDt" label="调拨日期" width="200" header-align="center"
                            align="center" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column v-if="true" prop="requirePlanNo" label="需求计划" header-align="center"
                            align="center" width="160" show-overflow-tooltip>
                        </el-table-column>
                    </el-table>
                </el-form>

            </el-card>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="success" plain @click="handleSave(ruleFormRef)">保存</el-button>
                    <el-button type="danger" plain @click="handleCancelSave">取消</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog class="diaClass" :close-on-click-modal="false" draggable :title="title" v-model="dialogVisible1"
            width="1100px" top="5vh" @open="openDialog">
            <el-card>

                <el-form :model="form" label-width="100px" label-position="right" inline ref="ruleFormRef"
                    :rules="rules">
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="出库时间" prop="transferDt">
                                <el-date-picker v-model="form.transferDt" type="datetime"
                                    value-format="YYYY-MM-DD HH:mm:ss" style="width: 210px;" :readonly="readonly" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="调拨申请量" prop="quantity">
                                <el-input v-model="form.quantity" disabled style="width: 210px;"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="实际出库量" prop="inQuantity">
                                <el-input v-model="form.inQuantity" disabled style="width: 210px;"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="还需出库量" prop="inQuantity">
                                <el-input v-model="form.inQuantity" disabled style="width: 210px;"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="当前出库量" prop="qty">
                                <el-input-number v-model="form.qty" :precision="2" :step="0.1" :min="0"
                                    controls-position="right" clearable style="width: 210px;"></el-input-number>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="备注">
                                <el-input v-model="form.reamrks" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
                                    :readonly="readonly" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>

                <el-table :data="tableDataLine" border highlight-current-row
                    @selection-change="handleSelectionChangeLine">
                    <el-table-column type="selection" fixed></el-table-column>
                    <el-table-column type="index" label="序号" align="center" width="60" fixed="left">
                        <template #default="scope">
                            <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column v-if="true" prop="itemCd" label="物料编码" width="150" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="itemNm" label="物料名称" width="150" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="itemType" label="物料类型" width="150" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="specType" label="规格型号" width="100" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="qty" label="数量" width="100" header-align="center" align="center"
                        show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="qtyWet" label="湿重" width="100" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="uom" label="单位" header-align="center" align="center" width="100"
                        show-overflow-tooltip :formatter="formatter">
                    </el-table-column>
                    <el-table-column v-if="true" prop="storeCd" label="库房编码" width="120" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="storeNm" label="库房名称" width="100" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="areaCd" label="区位" width="120" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="stackCd" label="垛位" width="100" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="tradePartnerCode" label="供应商编码" width="180" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-if="true" prop="tradePartnerName" label="供应商名称" width="180" header-align="center"
                        align="center" show-overflow-tooltip>
                    </el-table-column>
                </el-table>
            </el-card>

            <template #footer>
                <div class="dialog-footer">
                    <el-button plain type="success" @click="handleSave(ruleFormRef)">出库</el-button>
                    <el-button plain type="danger" @click="handleCancelSave">取消</el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup>
import ButtonBar from '@/components/ButtonBar.vue'

import {
    ref,
    reactive,
    onMounted,
    getCurrentInstance
} from 'vue'

const {
    proxy
} = getCurrentInstance()

import tools from '@/tools'
import { Search } from '@element-plus/icons-vue'
import SearchBox from "@/components/SearchBox.vue";
import ButtonBox from "@/components/ButtonBox.vue";

const cardBodyStyle = ref(tools.style.card)
const inputStyle = ref(tools.style.input)

onMounted(() => {
    handleSearch()
    handleSearchRecord()

    dictData()
})


/**
 *   查询
 */




const query = ref({
    storeNm: '',
    areaCd: '',
    stackCd: '',
    itemNm: '',
    itemType: '',
})
const queryRecord = ref({
    storeNm: '',
    areaCd: '',
    stackCd: '',
    itemNm: '',
    itemType: '',
    pickRecordNo: '',
})
const tableData = ref([])
const tableDataRecord = ref([])
const handleSearch = () => {
    currentPage.value = 1
    getTableData()
}
const handleSearchRecord = () => {
    currentPageRecord.value = 1
    getTableDataRecord()
}

const getTableData = () => {
    var url = 'sto/Onhand/query'
    var param = {
        page: currentPage.value,
        rows: pageSize.value,
        params: JSON.stringify(query.value)
    }
    // tableData.value = list
    proxy.$axios.get(url, param).then(response => {
        if (response.data.code == '0') {
            tableData.value = response.data.data.records
            totalRows.value = response.data.data.total
        } else {
            ElMessage.error('操作失败！' + response.data.msg)
        }
    })
}
const getTableDataRecord = () => {
    var url = 'sto/PickRecord/query'
    var param = {
        page: currentPageRecord.value,
        rows: pageSizeRecord.value,
        params: JSON.stringify(queryRecord.value)
    }
    // tableData.value = list
    proxy.$axios.get(url, param).then(response => {
        if (response.data.code == '0') {
            tableDataRecord.value = response.data.data.records
            totalRowsRecord.value = response.data.data.total
        } else {
            ElMessage.error('操作失败！' + response.data.msg)
        }
    })
}
/**
 *   查询
 */

/**
 * 分页
 */
const currentPage = ref(1)
const totalRows = ref(0)
const pageSizes = ref([1, 20, 30, 40])
const pageSize = ref(1)

const currentPageRecord = ref(1)
const totalRowsRecord = ref(0)
const pageSizesRecord = ref([5, 10, 20, 30, 40])
const pageSizeRecord = ref(5)
const handleSizeChange = (val) => {
    pageSize.value = val
    getTableData()
}
const handleCurrentChange = (val) => {
    currentPage.value = val
    getTableData()
}
/**
 * 分页
 */


/**
 * 新增
 */
const dialogVisible = ref(false)
const form = ref({
    qtyNew: 0,
    qtyWetNew: 0,
    qty: 0,
    qtyWet: 0,
})
const ruleFormRef = ref()
const queryFormRef = ref()
const rules = reactive({})

const handleAdd = () => {
    form.value = {}
    dialogVisible.value = true
}
/**
 * 新增
 */


/**
 * 保存、修改、删除
 */

const openDialog = () => {
}

const handleSave = (ruleFormRef) => {
    ruleFormRef.validate((valid, fields) => {
        if (valid) {

            var param = {
                json: JSON.stringify(form.value),
            }
            onheadSave(param)

        } else {
            console.log('error submit!', fields)
        }
    })
}

const onheadSave = (param) => {
    var url = 'sto/Onhand/savePick'

    proxy.$axios.post(url, param).then(response => {
        if (response.data.code == 0) {

            ElMessage({
                message: '保存成功',
                type: 'success',
            })
            getTableData()
            getTableDataRecord()
            dialogVisible.value = false
        } else {
            // ElMessage.error('操作失败！' + response.data.msg)
            ElMessage({
                message: '操作失败' + response.data.msg,
                type: 'error'
            })
        }
    })
}
const stocktakingSave = (param) => {
    var url = 'sto/Stocktaking/save'

    proxy.$axios.post(url, param).then(response => {
        if (response.data.code == 0) {
            getTableData()
            dialogVisible.value = false
            ElMessage({
                message: '保存成功',
                type: 'success',
            })
        } else {
            // ElMessage.error('操作失败！' + response.data.msg)
            ElMessage({
                message: '操作失败' + response.data.msg,
                type: 'error'
            })
        }
    })
}
const handleCancelSave = () => {
    dialogVisible.value = false
}
const handleEdit = (row) => {
    dialogVisible.value = true
    form.value = row
    form.value.qtyNew = 0
    form.value.qtyWetNew = 0
}
const handleDelete = (row) => {
    ElMessageBox.confirm(
        '确定删除本条记录?',
        '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
    }
    )
        .then(() => {
            var url = 'sto/Onhand/remove'
            var param = {
                id: row.id
            }
            proxy.$axios.post(url, param).then(response => {
                if (response.data.code == 0) {
                    ElMessage({
                        type: 'success',
                        message: '删除成功',
                    })
                    getTableData()
                } else {
                    ElMessage({
                        type: 'error',
                        message: '删除失败' + response.data.msg
                    });
                }
            });
        })
        .catch(() => {
            ElMessage({
                type: 'info',
                message: '已取消',
            })
        })
}

/**
 * 保存、修改、删除
 */

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

const handleRemoveBatch = () => {
    console.log('handleRemoveBatch')

    if (multipleSelection.value.length < 1) {
        ElMessage({
            type: 'warning',
            message: '请选择要删除的数据!'
        })
        return
    }

    ElMessageBox.confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
    }).then(() => {
        var ids = []
        multipleSelection.value.forEach((item, index) => {
            ids.push(item.id)
        })
        var url = 'sto/Onhand/removeBatch'
        var param = {
            ids: JSON.stringify(ids)
        }
        proxy.$axios.post(url, param).then(response => {
            if (response.data.code == '0') {
                ElMessage({
                    type: 'success',
                    message: '操作成功!',
                });
                getTableData()
                dialogVisible.value = false
            } else {
                ElMessage({
                    type: 'error',
                    message: '操作失败!' + response.data.msg
                });
            }
        })
    }).catch(() => {
        ElMessage({
            type: 'info',
            message: '已取消删除'
        })
    })
}

const handleEditBatch = () => {
    console.log('handleEditBatch')
    if (multipleSelection.value.length != 1) {
        ElMessage({
            type: 'warning',
            message: '请选择一条数据编辑!'
        })
        return
    }
    handleEdit(multipleSelection.value[0])
}

const handleUpload = () => {
    console.log('handleUpload')
}

const handleDownload = () => {
    console.log('handleDownload')
}

const handleImport = () => {
    console.log('handleImport')
}

const handleExport = () => {
    console.log('handleExport')
}


const queryShow = ref(false)


const reset = (queryFormRef) => {
    if (!queryFormRef) return
    queryFormRef.resetFields()
}

const dictList = ref({})
const dictData = () => {
    var url = 'framework/Common/querySelectorList'
    var param = {
        type: JSON.stringify(['MEASURING_UNIT', 'item_sort3', 'STORE_TYPE'])
    }
    proxy.$axios.get(url, param).then(response => {
        if (response.data.code == '0') {
            dictList.value = response.data.data
        } else {
            ElMessage.error('操作失败！' + response.data.msg)
        }
    })

}

const formatter = (row, column, cellValue, index) => {
    if (!cellValue || cellValue == null || cellValue == '') {
        return cellValue
    }
    switch (column.property) {
        case 'storeType':
            cellValue = dictList.value && Array.isArray(dictList.value.STORE_TYPE)
                ? dictList.value.STORE_TYPE.find(item => item.dicCode == cellValue)?.dicName
                : undefined
            break
        case 'uom':
            cellValue = dictList.value && Array.isArray(dictList.value.MEASURING_UNIT)
                ? dictList.value.MEASURING_UNIT.find(item => item.dicCode == cellValue)?.dicName
                : undefined
            break
    }
    return cellValue
}

</script>

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

::v-deep .diaClass90 .el-form-item {
    width: 90%
}

::v-deep .el-dialog__body {
    background-color: #F2F6FC;
}
</style>