<template>
    <ifrm ref="ifrm">
        <!-- 镀后接收 -->
        <uni-forms ref="form" err-show-type="toast">
            <uni-forms-item name="allegation"><input type="text" v-model="value" @confirm="confirm"
                    class="uni-input-border" placeholder="流程卡" /></uni-forms-item>
        </uni-forms>
        <t-table style="margin-top:20rpx">
            <t-tr>
                <t-td>流程卡号</t-td>
                <t-td>{{ tableObj.prWorkOrder.pjYieldOrder.cardNo }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>车间订单号</t-td>
                <t-td>{{ tableObj.woCode }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>批单号</t-td>
                <t-td>{{ tableObj.prWorkOrder.batchNo }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>零件编码</t-td>
                <t-td>{{ tableObj.prWorkOrder.pjYieldOrder.partCode }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>零件名称</t-td>
                <t-td>{{ tableObj.prWorkOrder.pjYieldOrder.partName }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>上序号</t-td>
                <t-td>{{ tableObj.frontOrders }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>上序名称</t-td>
                <t-td>{{ tableObj.frontProcedureSet.ppsName }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>工序号</t-td>
                <t-td>{{ tableObj.orders }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>工序名称</t-td>
                <t-td>{{ tableObj.procedureSet.ppsName }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>班组</t-td>
                <t-td>{{ tableObj.prWorkOrder.currentMakeTeam.tsName }}</t-td>
            </t-tr>
            <t-tr>
                <t-td>数量</t-td>
                <t-td>{{ tableObj.prWorkOrder.makeQty }}</t-td>
            </t-tr>
        </t-table>
        <!-- <view class="buttonBox"><button class="button" type="primary" :disabled="!(Object.keys(tableObj).length>0)"
                @click="submitClick">接收</button></view> -->
    </ifrm>
</template>

<script>
    import ifrm from '@/pages/index/ifrm';
    import tTable from '@/components/t-table/t-table.vue';
    import tTh from '@/components/t-table/t-th.vue';
    import tTr from '@/components/t-table/t-tr.vue';
    import tTd from '@/components/t-table/t-td.vue';
    import scan from '../../mixin/scan.js';
    export default {
        mixins: [scan],
        components: {
            ifrm,
            tTable,
            tTh,
            tTr,
            tTd
        },
        data() {
            return {
                value: '',
                tableObj: {
                    frontProcedureSet: {},
                    procedureSet: {},
                    prWorkOrder: {
                        pjYieldOrder: {},
                        currentMakeTeam: {},
                    },
                },
                qty: ''
            };
        },
        methods: {},
        onNavigationBarButtonTap(btn) {
            this.$refs.ifrm.topMenuClick(btn);
        },
        onShow() {},
        methods: {
            getBarCode(code, isConfirm = false) {
                this.getData(code);
            },
            confirm(e) {
                this.getBarCode(e.target.value, true);
            },
            getData(code) {
                if (!code) return;
                this.value = code;
                this.$ajax.request({
                    url: 'prWorkPlan/afterPlaReceive/' + code,
                    method: 'GET',
                    success: data => {
                        if (data.length == 0) {
                            return uni.showToast({
                                icon: "none",
                                title: '该流程卡暂无对应数据'
                            });
                        }
                        this.value = '';
                        this.tableObj = data[0];
                        this.submitClick()
                    }
                });
            },
            submitClick() {
                this.$ajax.request({
                    url: 'prWorkPlan/workPlanReceive/' + this.tableObj.wpId,
                    method: 'POST',
                    success: data => {
                        uni.showToast({
                            title: '接收成功'
                        });
                    }
                });
            }
        }
    };
</script>

<style scoped></style>