<template>
    <ifrm ref="ifrm">
        <view class="contentBox">
            <!-- 生产追溯维护 -->
            <uni-forms ref="wrForm" :modelValue="formData" class="formBox" style="width:100%">
                <uni-forms-item name="allegation"><input type="text" v-model="twoInput" @input="twoInputBlur"
                        class="uni-input-border" placeholder="流程卡" /></uni-forms-item>
            </uni-forms>
            <view class="tableBox">
                <view class="cusTableBox" style="min-height:30px;max-height: 180px;overflow-y: auto;">
                    <t-table>
                        <t-tr>
                            <t-td style="min-width:100px">操作</t-td>
                            <t-td style="min-width:120px">车间订单号</t-td>
                            <t-td style="min-width:120px">流程卡号</t-td>
                            <t-td style="min-width:120px">批次号</t-td>
                            <t-td style="min-width:120px">当前工序</t-td>
                        </t-tr>
                        <t-tr v-for="(item,index) in tableObjList">
                            <t-td style="min-width: 100px;"><button size="mini" class="button" type="primary"
                                    @click="removeClick(index)">删除</button></t-td>
                            <t-td style="min-width:120px">{{ item.woCode }}</t-td>
                            <t-td style="min-width:120px">{{ item.cardNo }}</t-td>
                            <t-td style="min-width:120px">{{ item.batchNo }}</t-td>
                            <t-td style="min-width:120px">{{ item.currentWpTitle }}</t-td>
                        </t-tr>

                    </t-table>
                </view>

                <t-table style="margin-top:10rpx;width:100%">
                    <t-tr>
                        <t-td>设备编码</t-td>
                        <t-td>
                            <lin-select :list="badnessArr" value-key="name" max-height="180" placeholder="请选择设备"
                                @input="linSelect" v-model="ecId" @clickConFirm="clickConFirm" />
                        </t-td>
                    </t-tr>
                    <t-tr>
                        <t-td>模板</t-td>
                        <t-td>
                            <uni-data-select v-model="rfpId" :localdata="preserveSlotTemplate"
                                @change="preserveSlotChange"></uni-data-select>
                        </t-td>
                    </t-tr>
                    <t-tr>
                        <!--  <t-td>下线后/上线前</t-td>
                        <t-td> <switch checked @change="switchChange" /> </t-td> -->
                        <t-td>
                            <uni-data-checkbox v-model="line" :localdata="lineList" />
                        </t-td>
                    </t-tr>
                </t-table>

                <view class="cusTableBox">
                    <table class="cusTable" cellspacing="0">
                        <tr>
                            <td colspan="4" style="min-width:100px">槽位/工步</td>
                            <td colspan="3" style="min-width:180px">实际参数</td>
                            <td colspan="4" style="min-width:170px">工艺要求</td>
                        </tr>
                        <template v-for="(itemSlot,indexSlot) in preserveSlotList">
                            <!-- 模板一 -->
                            <template v-if="itemSlot.rfpsType == 1">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="3" colspan="4">{{ itemSlot.slotName }} </td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }} </td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td colspan="2"> {{ itemChild.detailName }} </td>
                                        <td colspan="2">{{ itemChild.ask }} </td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板二 -->
                            <template v-else-if="itemSlot.rfpsType == 2">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="4" colspan="4"> {{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }} </td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                        <td v-if="indexChild > 1" colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td v-if="indexChild > 1" colspan="2"> {{ itemChild.detailName }}</td>
                                        <td v-if="indexChild > 1" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板三 -->
                            <template v-else-if="itemSlot.rfpsType == 3">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="5" colspan="4">{{ itemSlot.slotName }} </td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild == 0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild == 0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild == 1">{{ itemChild.paramName }} </td>
                                        <td v-if="indexChild == 1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild == 0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild == 0" :rowspan="2" colspan="2">{{ itemChild.ask }} </td>
                                        <td v-if="indexChild > 1" colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td v-if="indexChild > 1" colspan="2">{{ itemChild.detailName }}</td>
                                        <td v-if="indexChild > 1" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板四 -->
                            <template v-else-if="itemSlot.rfpsType == 4">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="4" colspan="4">{{ itemSlot.slotName }} </td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }} </td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板五 -->
                            <template v-else-if="itemSlot.rfpsType == 5">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="6" colspan="4">{{ itemSlot.slotName }} </td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild == 0" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="5" v-if="indexChild == 1" style="min-width: 180px;">
                                            <input v-model="itemChild.paramValue"
                                                @input="oneInputBlur($event,itemChild,itemSlot)"
                                                placeholder="请扫描物料条码" />
                                        </td>
                                        <td colspan="5" v-if="indexChild != 1" style="min-width: 180px;">
                                            <input v-model="itemChild.paramValue" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板六 -->
                            <template v-else-if="itemSlot.rfpsType == 6">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="7" colspan="4"> {{ itemSlot.slotName }} </td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild <= 1" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="5" v-if="indexChild == 2">
                                            <input v-model="itemChild.paramValue"
                                                @input="oneInputBlur($event,itemChild,itemSlot)"
                                                placeholder="请扫描物料条码" />
                                        </td>
                                        <td colspan="5" v-else>{{itemChild.paramValue}}</td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板七 -->
                            <template v-else-if="itemSlot.rfpsType == 7">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td colspan="4"> {{ itemSlot.slotName }} </td>
                                    <td colspan="3">
                                        <input v-model="itemSlot.childrenList[0].paramValue" placeholder="请输入内容" />
                                    </td>
                                    <td colspan="2">{{ itemSlot.childrenList[0].detailName }}</td>
                                    <td colspan="2">{{ itemSlot.childrenList[0].ask }}</td>
                                </tr>
                            </template>
                            <!-- 模板八 -->
                            <template v-else-if="itemSlot.rfpsType == 8">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="3" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板九 -->
                            <template v-else-if="itemSlot.rfpsType == 9">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="6" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild <=1" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十 -->
                            <template v-else-if="itemSlot.rfpsType == 10">
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="4">{{ itemSlot.slotName }}</td>
                                        <td colspan="3">
                                            <switch checked style="transform:scale(0.7)"
                                                @change="slotSwitchChange($event,itemChild)" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十一 -->
                            <template v-else-if="itemSlot.rfpsType == 11">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="5" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild <=1" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild==2" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild==3" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="4">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十二 -->
                            <template v-else-if="itemSlot.rfpsType == 12">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="4" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td>{{ itemChild.paramName }}</td>
                                        <td colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="3" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="3" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十三 -->
                            <template v-else-if="itemSlot.rfpsType == 13">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="11" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="5" v-if="indexChild == 0">
                                            <input v-model="itemChild.paramValue"
                                                @input="oneInputBlur($event,itemChild,itemSlot)"
                                                placeholder="请扫描物料条码" />
                                        </td>
                                        <td colspan="5" v-else-if="0<indexChild && indexChild<4">
                                            {{itemChild.paramValue}}
                                        </td>
                                        <td colspan="5" v-else-if="indexChild >= 4">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十四 -->
                            <template v-else-if="itemSlot.rfpsType == 14">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="13" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild <=1" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 2" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 3" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td>{{ itemChild.paramName }}</td>
                                        <td colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="5" v-if="indexChild == 4 || indexChild == 8">
                                            <input v-model="itemChild.paramValue"
                                                @input="oneInputBlur($event,itemChild,itemSlot)"
                                                placeholder="请扫描物料条码" />
                                        </td>
                                        <td colspan="5" v-else>{{itemChild.paramValue}}</td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十五 -->
                            <template v-else-if="itemSlot.rfpsType == 15">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="15" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild <=1" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 2" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 3 || indexChild == 4"
                                        :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td :colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td v-if="indexChild == 3" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild == 3" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 5" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td>{{ itemChild.paramName }}</td>
                                        <td colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="5" v-if="indexChild == 6 || indexChild == 10">
                                            <input v-model="itemChild.paramValue"
                                                @input="oneInputBlur($event,itemChild,itemSlot)"
                                                placeholder="请扫描物料条码" />
                                        </td>
                                        <td colspan="5" v-else>{{itemChild.paramValue}}</td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十六 -->
                            <template v-else-if="itemSlot.rfpsType == 16">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="17" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild <=1" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 2" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 3" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td>{{ itemChild.paramName }}</td>
                                        <td colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="5" v-if="indexChild == 4 || indexChild == 8|| indexChild == 12">
                                            <input v-model="itemChild.paramValue"
                                                @input="oneInputBlur($event,itemChild,itemSlot)"
                                                placeholder="请扫描物料条码" />
                                        </td>
                                        <td colspan="5" v-else>{{itemChild.paramValue}}</td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十七 -->
                            <template v-else-if="itemSlot.rfpsType == 17">
                                <tr :key="itemSlot.slotName+indexSlot">
                                    <td :rowspan="9" colspan="4">{{ itemSlot.slotName }}</td>
                                </tr>
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr v-if="indexChild <=1" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td v-if="indexChild ==0">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==0" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==1">{{ itemChild.paramName }}</td>
                                        <td v-if="indexChild ==1" colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.detailName }}
                                        </td>
                                        <td v-if="indexChild ==0" :rowspan="2" colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 2" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="3">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else-if="indexChild == 3" :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td>{{ itemChild.paramName }}</td>
                                        <td colspan="2">
                                            <uni-datetime-picker type="datetime" v-model="itemChild.rfpdTime" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                        <td colspan="2">{{ itemChild.ask }}</td>
                                    </tr>
                                    <tr v-else :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="5" v-if="indexChild == 4">
                                            <input v-model="itemChild.paramValue"
                                                @input="oneInputBlur($event,itemChild,itemSlot)"
                                                placeholder="请扫描物料条码" />
                                        </td>
                                        <td colspan="5" v-else>{{itemChild.paramValue}}</td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                            <!-- 模板十八 -->
                            <template v-else-if="itemSlot.rfpsType == 18">
                                <template v-for="(itemChild,indexChild) in itemSlot.childrenList">
                                    <tr :key="itemSlot.slotName+indexSlot+indexChild">
                                        <td colspan="4">{{ itemSlot.slotName }} </td>
                                        <td colspan="5">
                                            <input v-model="itemChild.paramValue" placeholder="请输入内容" />
                                        </td>
                                        <td colspan="2">{{ itemChild.detailName }}</td>
                                    </tr>
                                </template>
                            </template>
                        </template>
                    </table>
                </view>
            </view>
            <view class="buttonBox"><button class="button" type="primary" :disabled="!(tableObjList.length>0)"
                    @click="submitClick">保存</button></view>
        </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 inputBlur from '@/mixin/inputBlur.js';
    export default {
        mixins: [inputBlur],
        components: {
            ifrm,
            tTable,
            tTh,
            tTr,
            tTd
        },
        data() {
            return {
                tableObjList: [],
                text1: null,
                rfpId: null,
                ecId: null,
                line: 1,
                equipmentCardList: [],
                preserveSlotTemplate: [],
                preserveSlotList: [],
                badnessArr: [],
                ecDeviceArr: [],
                formData: {
                    prWorkPlan: {
                        wpId: null
                    }
                },
                lineList: [{
                    text: '上线前',
                    value: 1
                }, {
                    text: '下线后',
                    value: 0
                }],
            };
        },
        onNavigationBarButtonTap(btn) {
            this.$refs.ifrm.topMenuClick(btn);
        },
        onShow() {
            this.getEquipmentCard()
        },
        methods: {
            oneInputBlur(e, itemChild, itemSlot) {
                clearTimeout(this.time)
                if (e.detail.value.length == 0) {
                    return
                }
                this.time = setTimeout(() => {
                    this.oneInputData(e.detail.value, itemChild, itemSlot)
                }, 1800);
            },
            oneInputData(code, itemChild, itemSlot) {
                this.mterialMessData(code, itemChild, itemSlot)
            },
            twoInputData(code) {
                this.getData(code)
            },
            removeClick(index) {
                this.tableObjList.splice(index, 1)
            },
            mterialMessData(code, itemChild, itemSlot) {
                if (!code) return;
                this.$ajax.request({
                    url: 'prMakeRec/getMaterialMess',
                    method: 'POST',
                    data: {
                        goodsCode: code
                    },
                    success: data => {
                        console.log(data);
                        if (coGoods) {
                            const {
                                goodsName,
                                checkoutCode,
                                releasenoTime
                            } = data.coGoods;
                            if (itemSlot.rfpsType == 5) { // 模板六
                                itemSlot.childrenList[1].paramValue = code;
                                itemSlot.childrenList[2].paramValue = goodsName;
                                itemSlot.childrenList[3].paramValue = checkoutCode;
                                itemSlot.childrenList[4].paramValue = releasenoTime;
                            } else if (itemSlot.rfpsType == 6) { // 模板六
                                itemSlot.childrenList[2].paramValue = code;
                                itemSlot.childrenList[3].paramValue = goodsName;
                                itemSlot.childrenList[4].paramValue = checkoutCode;
                                itemSlot.childrenList[5].paramValue = releasenoTime;
                            } else if (itemSlot.rfpsType == 13) { // 模板十三
                                itemSlot.childrenList[0].paramValue = code;
                                itemSlot.childrenList[1].paramValue = goodsName;
                                itemSlot.childrenList[2].paramValue = checkoutCode;
                                itemSlot.childrenList[3].paramValue = releasenoTime;
                            } else if (itemSlot.rfpsType == 14) { // 模板十四
                                if (itemChild.detailIndex == 5) {
                                    itemSlot.childrenList[4].paramValue = code;
                                    itemSlot.childrenList[5].paramValue = goodsName;
                                    itemSlot.childrenList[6].paramValue = checkoutCode;
                                    itemSlot.childrenList[7].paramValue = releasenoTime;
                                } else if (itemChild.detailIndex == 9) {
                                    itemSlot.childrenList[8].paramValue = code;
                                    itemSlot.childrenList[9].paramValue = goodsName;
                                    itemSlot.childrenList[10].paramValue = checkoutCode;
                                    itemSlot.childrenList[11].paramValue = releasenoTime;
                                }

                            } else if (itemSlot.rfpsType == 15) { // 模板十五
                                if (itemChild.detailIndex == 7) {
                                    itemSlot.childrenList[6].paramValue = code;
                                    itemSlot.childrenList[7].paramValue = goodsName;
                                    itemSlot.childrenList[8].paramValue = checkoutCode;
                                    itemSlot.childrenList[9].paramValue = releasenoTime;
                                } else if (itemChild.detailIndex == 11) {
                                    itemSlot.childrenList[10].paramValue = code;
                                    itemSlot.childrenList[11].paramValue = goodsName;
                                    itemSlot.childrenList[12].paramValue = checkoutCode;
                                    itemSlot.childrenList[13].paramValue = releasenoTime;
                                }
                            } else if (itemSlot.rfpsType == 16) { // 模板十六
                                if (itemChild.detailIndex == 5) {
                                    itemSlot.childrenList[4].paramValue = code;
                                    itemSlot.childrenList[5].paramValue = goodsName;
                                    itemSlot.childrenList[6].paramValue = checkoutCode;
                                    itemSlot.childrenList[7].paramValue = releasenoTime;
                                } else if (itemChild.detailIndex == 9) {
                                    itemSlot.childrenList[8].paramValue = code;
                                    itemSlot.childrenList[9].paramValue = goodsName;
                                    itemSlot.childrenList[10].paramValue = checkoutCode;
                                    itemSlot.childrenList[11].paramValue = releasenoTime;
                                } else if (itemChild.detailIndex == 13) {
                                    itemSlot.childrenList[12].paramValue = code;
                                    itemSlot.childrenList[13].paramValue = goodsName;
                                    itemSlot.childrenList[14].paramValue = checkoutCode;
                                    itemSlot.childrenList[15].paramValue = releasenoTime;
                                }
                            } else if (itemSlot.rfpsType == 17) { // 模板十七
                                itemSlot.childrenList[4].paramValue = code;
                                itemSlot.childrenList[5].paramValue = goodsName;
                                itemSlot.childrenList[6].paramValue = checkoutCode;
                                itemSlot.childrenList[7].paramValue = releasenoTime;
                            }
                        }
                        uni.showToast({
                            title: '数据获取成功'
                        });

                    }
                });
            },
            getData(code) {
                if (!code) return;
                this.twoInput = code;
                this.$ajax.request({
                    url: 'pdaLoad/loadCurrentWp/' + code,
                    method: 'GET',
                    success: data => {
                        this.twoInput = '';
                        if (data.status == 2) {
                            const obj = this.tableObjList.find(item => {
                                return item.currentWpId == data.currentWpId
                            })
                            if (obj != null) {
                                return uni.showToast({
                                    icon: 'none',
                                    title: '此订单已存在'
                                });
                            }

                            this.tableObjList.push(data);
                            uni.showToast({
                                title: '数据获取成功'
                            });
                            this.getPreserveSlot(data.currentWpId)
                        } else {
                            return uni.showToast({
                                icon: 'none',
                                title: '此工序不在加工中'
                            });
                        }

                    }
                });
            },
            submitClick() {
                if (
                    (this.ecId != null && this.rfpId == null) ||
                    (this.ecId == null && this.rfpId != null)
                ) {
                    return uni.showToast({
                        title: '维护的电子档案中设备与模板都需选择！！！',
                        icon: 'none'
                    });
                }
                let line = this.line == 1 ? true : false
                const wpIdList = []
                this.tableObjList.forEach(item => {
                    wpIdList.push(item.currentWpId)
                })
                this.$ajax.request({
                    url: 'prMakeRec/saveRetrospectDefend',
                    data: {
                        wpIdList,
                        ecId: this.ecId,
                        rfpId: this.rfpId,
                        line,
                        preserveSlotList: this.preserveSlotList,
                    },
                    method: 'POST',
                    success: data => {
                        this.tableObjList = [];
                        this.rfpId = null;
                        this.line = 1
                        this.preserveSlotTemplate = []
                        this.preserveSlotList = []
                        uni.showToast({
                            title: '维护成功'
                        });
                        this.twoInput = '';
                        this.formData = {
                            prWorkPlan: {
                                wpId: null
                            }
                        };
                    }
                });
            },
            switchChange: function(e) {
                this.line = e.detail.value
                console.log(this.line);
            },

            slotSwitchChange(e, itemChild) {
                itemChild.qualified = e.detail.value
            },
            getPreserveSlot(wpId) {
                this.$ajax.request({
                    url: 'dsRbFilePreserve/getRbFilePreserveByWpId',
                    method: 'POST',
                    data: {
                        wpId
                    },
                    success: data => {
                        if (data.length > 0) {
                            data.forEach(item => {
                                this.preserveSlotTemplate.push({
                                    value: item.rfpId,
                                    text: item.name
                                })
                            })
                        }
                    }
                });
            },
            linSelect(val) {
                setTimeout(() => {
                    this.badnessArr = []
                    this.ecDeviceArr.forEach(item => {
                        if (item.name.includes(val)) {
                            this.badnessArr.push(item)
                        }
                    })
                }, 600)
            },
            clickConFirm(item) {
                this.ecId = item.value
            },
            getEquipmentCard() {
                this.$ajax.request({
                    url: 'comBox/basic/queryEquipmentCard',
                    method: 'POST',
                    data: {
                        "paging": {
                            "pageSize": 999999,
                            "pageNumber": 1
                        }
                    },
                    success: data => {
                        if (data.list.length > 0) {
                            data.list.forEach(item => {
                                this.ecDeviceArr.push({
                                    label: item.deviceName,
                                    value: item.ecId,
                                    name: item.deviceName
                                })
                            })
                            this.badnessArr = [...this.ecDeviceArr]
                        }
                    }
                });
            },
            preserveSlotChange(e) {
                this.rfpId = e
                this.$ajax.request({
                    url: 'dsRbFilePreserveSlot/getByRfpId/' + this.rfpId,
                    method: 'GET',
                    success: data => {
                        console.log(data);
                        this.preserveSlotList = data.preserveSlotList
                    }
                });
            },
            equipmentCardChange(e) {
                this.ecId = e
            },
        }
    };
</script>

<style scoped lang="scss">
    .contentBox {
        position: relative;
        height: 96vh;

        .formBox {
            position: absolute;
            height: 10vh;
        }

        .tableBox {
            position: absolute;
            top: 10vh;
            height: 76vh;
            width: 100%;
            overflow: auto;

            .cusTableBox {
                width: 100%;
                overflow-x: auto;

                .cusTable {

                    tr {
                        page-break-inside: avoid;
                    }

                    td {
                        height: 30px;
                        border: 1px solid #000;
                        background: transparent;
                        color: #000;
                        font-size: 14px;
                        text-align: center;
                        padding: 0;
                        margin: 0;

                        // ::v-deep .input__inner {
                        //     text-align: center;
                        //     height: 26px !important;
                        //     width: 80% !important;
                        // }
                    }
                }
            }

        }

        .buttonBox {
            position: absolute;
            height: 10vh;
            bottom: -1vh;
            left: 50%;
            transform: translate(-50%);
        }
    }
</style>