<template>
    <div>
        <lj-win-common :title="title" :show-back="true" ref="baseWin">
            <div slot="body">
                <div class="lj-card-item">
                    <mu-row>
                        <mu-col span="3" class="lj-card-secondary-title">物料编码：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content">{{mainObject.mtrlcode}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title">物料名称：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content">{{mainObject.mtrlname}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title">物料规格：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content">{{mainObject.mtrlcode}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title">单位：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content">{{mainObject.unit}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title">物料来源：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content">{{mainObject.mtrloriginStr}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title">物料类别：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content">{{mainObject.mtrltype}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title" v-if="mainObject.status_config">标准配置：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content" v-if="mainObject.status_config">
                            {{mainObject.status_config}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title" v-if="mainObject.woodcode_config">标准配置1：
                        </mu-col>
                        <mu-col span="9" class="lj-card-secondary-content" v-if="mainObject.woodcode_config">
                            {{mainObject.woodcode_config}}</mu-col>
                        <mu-col span="3" class="lj-card-secondary-title" v-if="mainObject.pcode_config">标准配置2：</mu-col>
                        <mu-col span="9" class="lj-card-secondary-content" v-if="mainObject.pcode_config">
                            {{mainObject.pcode_config}}</mu-col>
                    </mu-row>
                </div>
                <div>
                    <lj-grid :table-data="dataList" :columns="gridColumns" :editing="false"/>
                </div>
            </div>
        </lj-win-common>
    </div>
</template>

<script>
import ljWinCommon from "components/lj-win-common";
import LjGrid from "components/lj-grid";
    export default {
        components: {
            ljWinCommon,
            LjGrid
        },
        data() {
            return {
                title: "",
                mainObject:{},
                type:0,
                dataList:[],
            }
        },
        created () {
            var pageParm = $lj.getPageParam();
            this.mainObject = pageParm.mainObject;
            this.title = this.mainObject.title;
            this.type = this.mainObject.type;
            this.refresh();
        },
        methods: {
            refresh(){
                let self = this;
                $lj.postLJRequest("GetL1APPMtrlWilluseTable", {
                    token: $lj.getStorage("token"),
                    mtrlid: this.mainObject.mtrlid,
                    status: this.mainObject.status_config ? this.mainObject.status_config : "",
                    woodcode: this.mainObject.woodcode_config ? this.mainObject.woodcode_config : "",
                    pcode: this.mainObject.pcode_config ? this.mainObject.pcode_config : "",
                    type:this.type
                }, function (ret) {
                    if (ret) {
                        var dataList = ret.tableData;
                        switch (self.type) {
                            case 1:
                                self.dataList = dataList.rqQtyList;
                                break;
                            case 2:
                                self.dataList = dataList.taskQtyList;
                                break;
                            case 3:
                                self.dataList = dataList.wfjgrqQtyList;
                                break;
                            case 4:
                                self.dataList = dataList.buytaskQtyList;
                                break;
                            case 5:
                                self.dataList = dataList.ordermlQtyList;
                                break;
                            case 6:
                                self.dataList = dataList.wfjgQtyList;
                                break;
                        }
                    }
                })
            }
        },
        computed: {
            gridColumns() {
                let result = [];
                switch (this.type) {
                    case 1:
                        result=[
                            {label: "计划编号", property: "ordercode", width: screen.width * 0.2},
                            {label: "领用工段", property: "wrkgrpname", width: screen.width * 0.2},
                            {label: "用料量", property: "rqqty", width: screen.width * 0.2},
                            {label: "已领数", property: "dstrqty", width: screen.width * 0.2},
                            {label: "未领数", property: "notdstrqty", width: screen.width * 0.2},
                        ]
                        break;
                    case 2:
                        result = [
                            {label: "订单编号", property: "taskcode", width: screen.width * 0.2},
                            {label: "交货日期", property: "requiredate", width: screen.width * 0.2},
                            {label: "订货数", property: "saleqty", width: screen.width * 0.2},
                            {label: "已发货数", property: "consignedqty", width: screen.width * 0.2},
                            {label: "终止数", property: "stopqty", width: screen.width * 0.2},
                            {label: "未到货数", property: "notassignqty", width: screen.width * 0.2},
                            {label: "客户编号", property: "cuscode", width: screen.width * 0.2},
                            {label: "客户名称", property: "name", width: screen.width * 0.2},
                        ];
                        break;
                    case 3:
                        result = [
                            {label: "计划编号", property: "taskcode", width: screen.width * 0.2},
                            {label: "相关编号", property: "relcode", width: screen.width * 0.2},
                            {label: "下单日期", property: "requiredate", width: screen.width * 0.2},
                            {label: "未领数", property: "notfinishqty", width: screen.width * 0.2},
                            {label: "计划发出数", property: "qty", width: screen.width * 0.2},
                            {label: "已领数", property: "dstrqty", width: screen.width * 0.2},
                            {label: "供应商编号", property: "sptcode", width: screen.width * 0.2},
                            {label: "供应商名称", property: "name", width: screen.width * 0.2},
                        ];
                        break;
                    case 4:
                        result = [
                            {label: "订单编号", property: "taskcode", width: screen.width * 0.2},
                            {label: "未到货数", property: "notassignqty", width: screen.width * 0.2},
                            {label: "订货数", property: "qty", width: screen.width * 0.2},
                            {label: "已到货数", property: "assignqty", width: screen.width * 0.2},
                            {label: "终止数", property: "stopqty", width: screen.width * 0.2},
                            {label: "下单日期", property: "buytaskRequiredate", width: screen.width * 0.2},
                            {label: "到货日期", property: "buytaskMxRequiredate", width: screen.width * 0.2},
                            {label: "供应商编号", property: "sptcode", width: screen.width * 0.2},
                            {label: "供应商名称", property: "name", width: screen.width * 0.2},
                        ];
                        break;
                    case 5:
                        result = [
                            {label: "指令单号", property: "ordercode", width: screen.width * 0.2},
                            {label: "未完成数", property: "notqty", width: screen.width * 0.2},
                            {label: "计划数", property: "orderqty", width: screen.width * 0.2},
                            {label: "已进仓数", property: "acmpqty", width: screen.width * 0.2},
                            {label: "终止数", property: "stopqty", width: screen.width * 0.2},
                            {label: "不参加物料运算数", property: "notmrpqty", width: screen.width * 0.2},
                            {label: "下单日期", property: "orderdate", width: screen.width * 0.2},
                            {label: "交货日期", property: "requiredate", width: screen.width * 0.2},
                        ];
                        break;
                    case 6:
                        result = [
                            {label: "计划编号", property: "taskcode", width: screen.width * 0.2},
                            {label: "相关单号", property: "relcode", width: screen.width * 0.2},
                            {label: "未到数", property: "notfinishqty", width: screen.width * 0.2},
                            {label: "加工数", property: "qty", width: screen.width * 0.2},
                            {label: "已到数", property: "consignedqty", width: screen.width * 0.2},
                            {label: "终止数", property: "stopqty", width: screen.width * 0.2},
                            {label: "损耗数", property: "wasteqty", width: screen.width * 0.2},
                            {label: "退回数", property: "thqty", width: screen.width * 0.2},
                            {label: "下单日期", property: "requiredate", width: screen.width * 0.2},
                            {label: "回厂日期", property: "wxMxRequiredate", width: screen.width * 0.2},
                            {label: "加工商编号", property: "sptcode", width: screen.width * 0.2},
                            {label: "加工商名称", property: "name", width: screen.width * 0.2},
                        ];
                        break;
                }
                return result
            }
        },
    }
</script>

<style>

</style>