<template>
    <el-dialog
        :title="'查看库移'"
        :visible="dialogVisible"
        width="80%"
        :modal-append-to-body="true"
        :append-to-body="true"
        id="libraryShiftSearchPop"
        :top="'50px'"
    >
        <!-- 列表形式（使用库存事务页面） -->
        <!-- <InventoryTransaction
            :userTableColumns="transactionColumns"
            :userSetUTableHeight="280"
            :userFilterSet="userFilterSet"
            :userCurrenButtonData=[]
        ></InventoryTransaction> -->

        <!-- 详情形式 -->
        <div v-loading="loading" class="descriptionsContain">
            <el-descriptions v-if="infoData && !loading" :column="3" :border="true">
                <el-descriptions-item 
                    v-for="(item,key) in transactionColumns" 
                    :key="key"
                    :label=item.label
                >{{ infoData[item.prop] }}</el-descriptions-item>
            </el-descriptions>
            <div v-if="!infoData && !loading" style="text-align:center;line-height:180px">暂无相关信息</div>
        </div>

        <span slot="footer" class="dialog-footer">
            <el-button @click="close">关闭</el-button>
        </span>
    </el-dialog>
</template>

<script>
import { getPageList, getDetailed } from '@/api/wms-api'
import InventoryTransaction from "@/views/inventoryManage/InventoryQuery/InventoryTransaction-Query"
export default {
    name: "libraryShiftSearch",
    components:{InventoryTransaction},
    props:{
        rowData: {
            type: Object,
            default: null
        },
        isShow: {
            type: Boolean,
            default: false
        },
    },
    watch:{
        isShow(n,o){
            this.dialogVisible = n;
            if(n){this.getInfo()}
            else{this.infoData = null}
        },
    },
    data(){
        return {
            loading:false,
            dialogVisible:false,
            infoData:null,
            transactionColumns:[
                { label: "事务编号", prop: "transNumber",width: 180 },
                { label: "物品代码", prop: "itemCode" },
                { label: "物品名称", prop: "itemName" },
                { label: "物品描述1", prop: "itemDesc1" },
                { label: "物品描述2", prop: "itemDesc2" },
                { label: "配置", prop: "item_configurationFromFE",showProp:true },
                { label: "事务分类", prop: "transType",type: "filter", filters: "TransTypeBase" },
                { label: "子事务类型", prop: "transSubType", type: "filter", filters: "transSubType" },
                { label: "出库/入库", prop: "transInOut",type: "filter", filters: "transInOutStatus" },
                { label: "接口对应类型", prop: "interfaceType", width: '360px', showProp: true },
                { label: "事务数量", prop: "qty",isNumber:true },
                { label: "箱码", prop: "packingCode" },
                { label: "ERP储位", prop: "locationErpCode" },
                { label: "库位代码", prop: "locationCode" },
                { label: "批次", prop: "lot" },
                { label: "到货单位", prop: "uom" },
                { label: "库存状态", prop: "status",type: "filter", filters: "inventoryStage" },
                { label: "任务编号", prop: "jobNumber",width: 180 },
                { label: "事务时间", prop: "transTime" ,type: "dateTime" },
                { label: "操作员", prop: "worker" },
                { label: "单据号", prop: "docNumber" },
                { label: "库位组", prop: "locationGroup" },
                { label: "库区", prop: "locationArea" },
                { label: "到货日期", prop: "arriveDate",type: "dateTime" },
                { label: "生产日期", prop: "produceDate",type: "dateTime" },
                { label: "过期时间", prop: "expireDate",type: "dateTime" },
                { label: "标包数量", prop: "stdPackQty",isNumber:true },
                { label: "管理类型", prop: "manageType", type: "filter", filters: "manageType" },
                { label: "供应商批次", prop: "supplierBatch" },
                { label: "备注", prop: "remark" },
                { label: "生效日期", prop: 'activeDate', type: "dateTime" },
                { label: "创建时间", prop: "creationTime",type: "dateTime" },
                { label: "上次修改时间", prop: "lastModificationTime",type: "dateTime" },
                { label: "仓库代码", prop: 'warehouseCode' },
            ]
        }
    },
    methods:{
        close(){
            this.dialogVisible=false
            this.$emit("setClose",this.dialogVisible)
        },
        getInfo(){
            if(!this.rowData.row.tenantId){
                return
            }
            this.loading = true
            let _data = {
                condition: {
                    filters: [
                        {
                            logic: "And",
                            column: "transNumber",
                            action: "==",
                            value: this.rowData.row.tenantId,
                            // value: "562468800474120192",
                        },
                    ]
                },
                Sorting: "",
                SkipCount: 0,
                MaxResultCount: 20
            }
            getPageList(_data, 'wms/inventory/inventory-transaction').then(res => {
                this.infoData = res.items[0]
                console.log(128,this.infoData)
                this.loading = false
            }).catch(err => {
                this.loading = false
            })
        },
        userFilterSet(){
            // if(!this.rowData.row.tenantId){
            //     return false
            // }
            return {
                logic: "And",
                column: "transNumber",
                action: "==",
                value: this.rowData.row.tenantId,
                // value: "562468800474120192",
            }
        }
    }
}
</script>

<style lang="scss">
#libraryShiftSearchPop {
    // .el-dialog__body{
    //     padding-top:0 !important
    // }  
    .el-dialog{
        margin-bottom:0 !important
    }
    .descriptionsContain{
        height:calc(100vh - 290px);
        overflow: auto
    }
}
</style>