| <template> | 
|     <div class="tl"> | 
|         <V-WorkOrderInfo :info="info"></V-WorkOrderInfo> | 
|         <div class="tl_title"> | 
|             <div class="tl_title_left"> | 
|                 <div class="tl_title_left_x"></div> | 
|                 <span>产出信息</span> | 
|                 <span v-show="total > 0">{{total}}{{info.umodel ? info.umodel.name : ''}}</span> | 
|             </div> | 
|             <div class="tl_title_right" @click="add"> | 
|                 <img src="@/assets/icon/gongdan_ic_shoudong@2x.png" alt="" /> | 
|                 <span>增加产出</span> | 
|             </div> | 
|         </div> | 
|         <van-swipe-cell v-for="(item, index) in formList" :key="index"> | 
|             <div class="tl_list"> | 
|                 <div class="tl_list_item" @click="open1(index)"> | 
|                     <div class="tl_list_item_label">选择工装</div> | 
|                     <div class="tl_list_item_go"> | 
|                         <span :style="item.workClothesName ? 'color: #000000;' : ''"> | 
|                             <span v-if="!item.attributeType">点击选择工装</span> | 
|                             <span class="black" v-else-if="item.attributeType === Attribute.HH">{{'[' + item.attribute + ']'}}</span> | 
|                             <span class="red" v-else-if="item.attributeType === Attribute.BF">{{'[' + item.attribute + ']'}}</span> | 
|                             <span class="yellow" v-else-if="item.attributeType === Attribute.BL">{{'[' + item.attribute + ']'}}</span> | 
|                             <span class="green" v-else-if="item.attributeType === Attribute.HG">{{'[' + item.attribute + ']'}}</span> | 
|                             <span v-if="item.attributeType" class="black">{{item.workClothesName}}</span> | 
|                         </span> | 
|                         <van-icon name="arrow" color="#999999" /> | 
|                     </div> | 
|                 </div> | 
|                 <div class="tl_list_item"> | 
|                     <div class="tl_list_item_label">产出数量({{info.umodel ? info.umodel.name : ''}})</div> | 
|                     <div class="tl_list_item_go"> | 
|                         <input type="text" @blur="changeNumber(item.num, index)" v-model="item.num" /> | 
|                     </div> | 
|                 </div> | 
|             </div> | 
|             <template #right> | 
|                 <van-button square style="height: 100%;" type="danger" text="删除" @click="dele(index)" /> | 
|             </template> | 
|         </van-swipe-cell> | 
|         <div class="tl_zw"></div> | 
|         <div class="tl_footer"> | 
|             <button class="tl_footer_copy" @click="copy">复制投料</button> | 
|             <div class="tl_z"></div> | 
|             <button class="tl_footer_submit" v-preventReClick @click="submit">提交</button> | 
|         </div> | 
|     </div> | 
|     <!--  工装器具  --> | 
|     <Tooling :show="gzShow" :classification="true" :attribute="info.type === 2 ? `${Attribute.BF},${Attribute.HG}` : ''" @close="close" @value="getValue" /> | 
| </template> | 
|   | 
| <script setup lang="ts"> | 
|     import { ref, onMounted, watch } from 'vue' | 
|     import { Toast } from 'vant' | 
|     import { useRoute, useRouter } from "vue-router" | 
|     import {queryById, createProduce, getOrocessRecord} from '@/apis/WorkOrderAPI' | 
|     import { REGULAR } from '@/utils/utils' | 
|     import { Attribute } from '@/enum' | 
|     import VWorkOrderInfo from '@/components/common/WorkOrderInfo.vue' | 
|     import Tooling from '@/components/common/Tooling.vue' | 
|   | 
|     const route = useRoute() | 
|   | 
|     const router = useRouter() | 
|   | 
|     let info: any = ref({}) | 
|   | 
|     // 投料索引 | 
|     let indexs = ref<number>() | 
|     let total = ref<number>(0) | 
|     let gzShow = ref<boolean>(false) | 
|   | 
|     // 投料信息数组 | 
|     let formList: any = ref([ | 
|         { | 
|             id: Date.now(), | 
|             toolingTypeId: '',    // 工装类型 | 
|             toolingTypeName: '',// 工装类型名称 | 
|             workClothesId: '',    // 工装 | 
|             workClothesName: '',// 工装名称 | 
|             num: route.query.num,              // 数量 | 
|             attribute: '',         // 工装属性 | 
|             attributeType: ''         // 工装属性类型 | 
|         } | 
|     ]) | 
|   | 
|     // 复制投料 | 
|     const copy = () => { | 
|         getOrocessRecord({ | 
|             workorderId: route.query.id, | 
|             type: 0 | 
|         }).then(res => { | 
|             if (res.code === 200) { | 
|                 if (res.data && res.data.length === 0) { | 
|                     Toast({ message: '暂无投料' }) | 
|                     return | 
|                 } | 
|                 formList.value = [] | 
|                 res.data.forEach((element: any) => { | 
|                     formList.value.push({ | 
|                         id: Date.now(), | 
|                         toolingTypeId: element.amodel.type,    // 工装类型 | 
|                         toolingTypeName: element.amodel.categoryId, // 工装类型名称 | 
|                         workClothesId: element.amodel.id,    // 工装 | 
|                         workClothesName: element.amodel.code, // 工装名称 | 
|                         num: element.num,              // 数量 | 
|                         attribute: element.smodelCode,         // 工装属性 | 
|                         attributeType: element.smodelLabel        // 工装属性类型 | 
|                     }) | 
|                 }) | 
|             } | 
|         }) | 
|     } | 
|   | 
|     const close = () => { | 
|         gzShow.value = false | 
|     } | 
|   | 
|     // 获取工装数据 | 
|     const getValue = (item: any) => { | 
|         formList.value[indexs.value as number].toolingTypeId = item.cmodel1BigName | 
|         formList.value[indexs.value as number].toolingTypeName = item.categoryId | 
|         formList.value[indexs.value as number].workClothesId = item.id | 
|         formList.value[indexs.value as number].workClothesName = item.code | 
|         formList.value[indexs.value as number].attribute = item.smodelCode | 
|         formList.value[indexs.value as number].attributeType = item.smodelLabel | 
|         gzShow.value = false | 
|     } | 
|   | 
|     // 失去焦点验证整数小数 | 
|     const changeNumber = (num: any, index: number): void => { | 
|         if (info.value.umodel.attributeData === 0 && num !== '') { | 
|             if(!REGULAR.positiveInteger.test(num)){ | 
|                 Toast({ message: '只能输入正整数' }) | 
|                 formList.value[index].num = '' | 
|             } | 
|         } else if (info.value.umodel.attributeData === 1 && num !== '') { | 
|             if(!REGULAR.number.test(num)){ | 
|                 Toast({ message: '只能输入正整数或小数(最多四位)' }) | 
|                 formList.value[index].num = '' | 
|             } | 
|         } | 
|     } | 
|   | 
|     // 打开工装弹框 | 
|     const open1 = (index: number): void => { | 
|         indexs.value = index | 
|         gzShow.value = true | 
|     } | 
|   | 
|     // 添加投料信息 | 
|     const add = (): void => { | 
|       formList.value.unshift({ id: Date.now(), toolingTypeId: '', toolingTypeName: '', workClothesId: '', workClothesName: '', num: formList.value[formList.value.length - 1].num }) | 
|     } | 
|   | 
|     // 删除投料信息 | 
|     const dele = (index: number): void => { | 
|       if (formList.value.length === 1) { | 
|         Toast('至少保留一条投料信息') | 
|         return | 
|       } | 
|       formList.value.splice(index, 1) | 
|     } | 
|   | 
|     // 查询工单详情 | 
|     const queryByIds = () => { | 
|         queryById(route.query.id).then(res => { | 
|             if (res.code === 200) { | 
|                 info.value = res.data | 
|             } | 
|         }) | 
|     } | 
|   | 
|     // 提交产出 | 
|     const submit = () => { | 
|   | 
|       let isOpen: any = true | 
|   | 
|       formList.value.forEach((item: any) => { | 
|         if (item.toolingTypeId === '' || item.workClothesId === '' || item.num === '') { | 
|           isOpen = false | 
|         } | 
|       }) | 
|   | 
|       if (isOpen) { | 
|         let recordList: any = [] | 
|         formList.value.forEach((item: any) => { | 
|             recordList.push({ applianceId: item.workClothesId, num: item.num }) | 
|         }) | 
|         createProduce({ | 
|           id: route.query.id, | 
|           recordList: recordList | 
|         }).then(res => { | 
|           if (res.code === 200) { | 
|             Toast.success({ | 
|               message: '产出成功', | 
|               duration: 2000, | 
|               forbidClick: true | 
|             }) | 
|             setTimeout(() => [ | 
|               router.go(-1) | 
|             ], 2000) | 
|           } | 
|         }) | 
|       } else { | 
|         Toast({ | 
|           message: '请先完善产出信息', | 
|           duration: 2000 | 
|         }) | 
|       } | 
|     } | 
|   | 
|     watch(() => formList.value, (news) => { | 
|         total.value = 0 | 
|         news.forEach((element: any) => { | 
|             total.value = total.value + Number(element.num) | 
|         }) | 
|     }, { deep: true }) | 
|   | 
|     onMounted(() => { | 
|         queryByIds() | 
|     }) | 
| </script> | 
|   | 
| <style lang="scss" scoped> | 
|     .tl { | 
|         width: 100%; | 
|         height: 100%; | 
|         position: absolute; | 
|         background: #F7F7F7; | 
|         .tl_title { | 
|             display: flex; | 
|             align-items: center; | 
|             justify-content: space-between; | 
|             padding: 30px; | 
|             .tl_title_left { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 .tl_title_left_x { | 
|                     width: 8px; | 
|                     height: 30px; | 
|                     background: $nav-color; | 
|                     border-radius: 2px; | 
|                     margin-right: 12px; | 
|                 } | 
|                 span { | 
|                     font-size: 32px; | 
|                     font-weight: 500; | 
|                     color: #222222; | 
|                     &:nth-child(3) { | 
|                         font-size: 28px; | 
|                         font-weight: 500; | 
|                         color: $nav-color; | 
|                         margin-left: 10px; | 
|                     } | 
|                 } | 
|             } | 
|             .tl_title_right { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 img { | 
|                     width: 28px; | 
|                     height: 28px; | 
|                     margin-right: 12px; | 
|                 } | 
|                 span { | 
|                     font-size: 28px; | 
|                     font-weight: 400; | 
|                     color: $nav-color; | 
|                 } | 
|             } | 
|         } | 
|         .tl_list { | 
|             display: flex; | 
|             flex-direction: column; | 
|             background: white; | 
|             padding: 0 30px; | 
|             margin-bottom: 20px; | 
|             .tl_list_item { | 
|                 height: 98px; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: space-between; | 
|                 /*padding-bottom: 30px;*/ | 
|                 /*margin-top: 30px;*/ | 
|                 border-bottom: 1px solid #E5E5E5; | 
|                 &:first-child { | 
|                     margin-top: 0 !important; | 
|                 } | 
|                 &:last-child { | 
|                     padding-bottom: 0 !important; | 
|                     border: none !important; | 
|                 } | 
|                 .tl_list_item_label { | 
|                     font-size: 30px; | 
|                     font-weight: 400; | 
|                     color: #222222; | 
|                     flex-shrink: 0; | 
|                 } | 
|                 .tl_list_item_go { | 
|                     flex: 1; | 
|                     display: flex; | 
|                     align-items: center; | 
|                     justify-content: flex-end; | 
|                     input { | 
|                         text-align: right; | 
|                         width: 180px; | 
|                         height: 60px; | 
|                         border-radius: 8px; | 
|                         border: 1px solid #E5E5E5; | 
|                         padding: 0 30px; | 
|                         box-sizing: border-box; | 
|                         font-size: 28px; | 
|                         font-weight: 400; | 
|                         color: #333333; | 
|                     } | 
|                     span { | 
|                         font-size: 28px; | 
|                         font-weight: 400; | 
|                         color: #999999; | 
|                         margin-right: 10px; | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|         .tl_zw { | 
|             height: 160px; | 
|         } | 
|         .tl_footer { | 
|             width: 100%; | 
|             position: fixed; | 
|             bottom: 0; | 
|             left: 0; | 
|             padding: 0 30px 68px 30px; | 
|             box-sizing: border-box; | 
|             display: flex; | 
|             align-items: center; | 
|             justify-content: space-between; | 
|             .tl_z { | 
|                 width: 20px; | 
|             } | 
|             .tl_footer_copy { | 
|                 flex: 1; | 
|                 height: 88px; | 
|                 background: #FFFFFF; | 
|                 border-radius: 8px; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: center; | 
|                 font-size: 30px; | 
|                 font-weight: 500; | 
|                 color: $nav-color; | 
|                 border: none !important; | 
|                 box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.08); | 
|             } | 
|             .tl_footer_submit { | 
|                 flex: 1; | 
|                 height: 88px; | 
|                 background: $nav-color; | 
|                 box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.08); | 
|                 border-radius: 8px; | 
|                 font-size: 30px; | 
|                 font-weight: 500; | 
|                 color: #FFFFFF; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: center; | 
|                 border: none; | 
|             } | 
|         } | 
|     } | 
| </style> |