| <template> | 
|     <div class="inspection"> | 
|         <div class="inspection_list"> | 
|             <div class="inspection_list_item"> | 
|                 <span>检验类型</span> | 
|                 <!-- <div class="right"> | 
|                     <div class="right_item" :class="{ 'active': item.active }" v-for="(item, index) in status" :key="index" @click="changeItem(index, item.id)">{{item.name}}</div> | 
|                 </div> --> | 
|                 <div class="right"> | 
|                     <!-- <div class="right_item active">巡线</div> --> | 
|                     <div class="right_item active">巡检</div> | 
|                     <!-- <div class="right_item active" v-if="form.status == '2'">完工检</div> --> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|         <div class="x"></div> | 
|         <div class="inspection_list"> | 
|             <div class="inspection_list_item" @click="jumpGD"> | 
|                 <span>检验工单</span> | 
|                 <div class="right1"> | 
|                     <span :style="form.gdmc ? 'color: #000;' : ''">{{ form.gdmc ? form.gdmc : '点击选择检验工单'}}</span> | 
|                     <van-icon name="arrow" color="#999999" size="18" /> | 
|                 </div> | 
|             </div> | 
|             <div class="inspection_list_item" v-if="form.gdmc"> | 
|                 <span>计划数量</span> | 
|                 <div class="right1"> | 
|                     <span style="color: black;">{{data.info.planNum}}{{data.info.umodel ? data.info.umodel.name : ''}}</span> | 
|                 </div> | 
|             </div> | 
|             <!-- <div class="inspection_list_item" @click="openGZ"> | 
|                 <span>检验工装</span> | 
|                 <div class="right1"> | 
|                     <span :style="form.jygzmc ? 'color: #000' : ''">{{ form.jygzmc ? form.jygzmc : '点击选择检验工装'}}</span> | 
|                     <van-icon name="arrow" color="#999999" size="18" /> | 
|                 </div> | 
|             </div> --> | 
|         </div> | 
|         <div class="x"></div> | 
|         <div class="inspection_list"> | 
|             <div class="inspection_list_item"> | 
|                 <span>良品数</span> | 
|                 <div class="right1"> | 
|                     <input type="number" v-model="form.hgsl" placeholder="0" /> | 
|                     <span class="dw" v-if="data.info.umodel">{{data.info.umodel.name}}</span> | 
|                 </div> | 
|             </div> | 
|             <div class="inspection_list_item"> | 
|                 <span>不良数量</span> | 
|                 <div class="right1"> | 
|                     <input type="number" v-model="form.blsl" placeholder="0" /> | 
|                     <span class="dw" v-if="data.info.umodel">{{data.info.umodel.name}}</span> | 
|                 </div> | 
|             </div> | 
|             <!-- <div class="inspection_list_item" @click="openBLGZ" v-show="form.blsl > 0"> | 
|                 <span>不良工装</span> | 
|                 <div class="right1"> | 
|                     <span :style="form.blgzmc ? 'color: #000;' : ''">{{ form.blgzmc ? form.blgzmc : '点击选择工装'}}</span> | 
|                     <van-icon name="arrow" color="#999999" size="18" /> | 
|                 </div> | 
|             </div> --> | 
|             <div class="inspection_list_item" @click="openBL" v-show="form.blsl > 0"> | 
|                 <span>不良说明</span> | 
|                 <div class="right1"> | 
|                     <span :style="form.blsm ? 'color: #000;' : ''">{{ form.blsm ? form.blsm : '点击选择不良原因'}}</span> | 
|                     <van-icon name="arrow" color="#999999" size="18" /> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|         <div class="inspection_footer"> | 
|             <button class="inspection_footer_sub" @click="submit" v-preventReClick>提交</button> | 
|         </div> | 
|         <!--    不良说明    --> | 
|         <van-popup v-model:show="data.show1" position="bottom" round :style="{ height: '50%' }"> | 
|             <van-picker | 
|                 title="请选择不良说明" | 
|                 :columns="data.columns1" | 
|                 @confirm="onConfirm1" | 
|                 @cancel="onCancel1" | 
|             /> | 
|         </van-popup> | 
|         <!--    工装    --> | 
|         <Tooling :show="gzShow1" :classification="true" :statusname="'1,2,3'" :attribute="Attribute.HG" @close="close1" @value="getValue1" /> | 
|         <!--    不良工装    --> | 
|         <Tooling :show="gzShow" :attribute="Attribute.BF + ',' + Attribute.BL" @close="close" @value="getValue" /> | 
|     </div> | 
| </template> | 
|   | 
| <script setup lang="ts"> | 
|     import { ref, reactive, onMounted, onActivated } from 'vue' | 
|     import { useRouter } from "vue-router" | 
|     import { Toast } from 'vant' | 
|     import { REGULAR } from '@/utils/utils' | 
|     import { Attribute } from '@/enum' | 
|     import { createStandard } from '@/apis/QualityAPI' | 
|     import { checkAllList, getListByCondition, toolingQueryById } from "@/apis/WorkOrderAPI" | 
|     import Tooling from '@/components/common/Tooling.vue' | 
|   | 
|     const router = useRouter() | 
|   | 
|     let gzShow = ref<boolean>(false) | 
|   | 
|     let gzShow1 = ref<boolean>(false) | 
|   | 
|     let data = reactive<any>({ | 
|         info: {}, | 
|         show1: false, | 
|         columns: [], | 
|         columns1: [] | 
|     }) | 
|   | 
|     let form = reactive({ | 
|         status: '1', | 
|         gdid: '', | 
|         gdmc: '', | 
|         jygz: '', | 
|         jygzmc: '', | 
|         hgsl: 0, | 
|         blsl: 0, | 
|         blgz: '', | 
|         blgzmc: '', | 
|         blsm: '', | 
|         dw: '' | 
|     }) | 
|   | 
|     let status = ref<Array<object>>([ | 
|         { id: '0', name: '巡线', active: true }, | 
|         { id: '1', name: '巡检', active: false }, | 
|         { id: '2', name: '完工检', active: false } | 
|     ]) | 
|   | 
|     // 关闭不良工装 | 
|     const close = () => { | 
|         gzShow.value = false | 
|     } | 
|   | 
|     // 关闭工装 | 
|     const close1 = () => { | 
|         gzShow1.value = false | 
|     } | 
|   | 
|     // 获取不良工装数据 | 
|     const getValue = (item: any) => { | 
|         form.blgzmc = item.code | 
|         form.blgz = item.id | 
|         gzShow.value = false | 
|     } | 
|   | 
|     // 获取工装数据 | 
|     const getValue1 = (item: any) => { | 
|         form.dw = item.umodelData | 
|         form.jygz = item.id | 
|         form.jygzmc = item.code | 
|         gzShow1.value = false | 
|     } | 
|   | 
|     // 打开检验工装 | 
|     const openGZ = () => { | 
|         gzShow1.value = true | 
|     } | 
|   | 
|     // 去选择设备 | 
|     const jumpGD = () => { | 
|         router.push({ name: 'selectWorkOrder' }) | 
|     } | 
|   | 
|     const openBL = () => { | 
|         data.show1 = true | 
|     } | 
|   | 
|     const openBLGZ = () => { | 
|         gzShow.value = true | 
|     } | 
|   | 
|     const onConfirm1 = (value: any): void => { | 
|         form.blsm = value.text | 
|         data.show1 = false | 
|     } | 
|   | 
|     const onCancel1 = () => { | 
|         data.show1 = false | 
|     } | 
|   | 
|     // 切换状态 | 
|     const changeItem = (i: number, id: string): void => { | 
|         status.value.forEach((item: any, index: number) => { | 
|             item.active = i === index; | 
|         }) | 
|         form.status = id | 
|     } | 
|   | 
|     // 提交 | 
|     const submit = () => { | 
|         if (!form.gdid) return Toast.fail({ message: '工单不能为空' }) | 
|         // if (!form.jygz) return Toast.fail({ message: '检验工装不能为空' }) | 
|         if (form.hgsl || form.blsl) { | 
|             if (form.hgsl) { | 
|                 if (form.dw == '0') {   // 整数 | 
|                     if (!REGULAR.positiveInteger.test(form.hgsl as never)) return Toast.fail({ message: '良品数量只能为正整数' }) | 
|                 } else if (form.dw == '1') {    // 小数 | 
|                     if (!REGULAR.number.test(form.hgsl as never)) { | 
|                         return Toast.fail({ message: '良品数量只能为正整数或四位小数' }) | 
|                     } | 
|                 } | 
|             } | 
|             if (form.blsl) { | 
|                 if (form.dw == '0') {   // 整数 | 
|                     if (!REGULAR.positiveInteger.test(form.blsl as never)) return Toast.fail({ message: '不良数量只能为正整数' }) | 
|                 } else if (form.dw == '1') {    // 小数 | 
|                     if (!REGULAR.number.test(form.blsl as never)) { | 
|                         return Toast.fail({ message: '不良数量只能为正整数或四位小数' }) | 
|                     } | 
|                 } | 
|             } | 
|         } else { | 
|             return Toast.fail({ message: '良品和不良不能同时为空' }) | 
|         } | 
|         let total = (form.hgsl ? form.hgsl : 0) + (form.blsl ? form.blsl : 0) | 
|         if (total > data.info.planNum) { | 
|             return Toast.fail({ message: '合格不良相加不能超过计划数量' }) | 
|         } | 
|         if (Number(form.blsl) > 0) { | 
|             // if (!form.blgz) return Toast.fail({ message: '不良工装不能为空' }) | 
|             if (!form.blsm) return Toast.fail({ message: '不良说明不能为空' }) | 
|         } | 
|         createStandard({ | 
|             workorderId: form.gdid, | 
|             // appliancesId: form.jygz, | 
|             qualifiedNum: form.hgsl ? form.hgsl : 0, | 
|             unqualifiedNum: form.blsl ? form.blsl : 0, | 
|             // qualifiedApplianceId: form.blgz, | 
|             checkInfo: form.blsm, | 
|             checkType: form.status | 
|         }).then(res => { | 
|             if (res.code === 200) { | 
|                 Toast.success({ message: '检验成功!', duration: 2000, forbidClick: true }) | 
|                 setTimeout(() => { | 
|                     router.go(-1) | 
|                 }, 2000) | 
|             } | 
|         }) | 
|     } | 
|   | 
|     // 不良原因数据 | 
|     const checkAllLists = () => { | 
|         checkAllList({ bmodelCateType: '3' }) | 
|             .then(res => { | 
|                 if (res.code === 200) { | 
|                     res.data.forEach((item: any) => { | 
|                         data.columns1.push({ text: item.combinationName, id: item.id }) | 
|                     }) | 
|                 } | 
|             }) | 
|     } | 
|   | 
|     // 查询不良/报废工装 | 
|     const getListByConditions1 = () => { | 
|         data.columns2 = [] | 
|         getListByCondition({ | 
|             smodelLabel: 'APPLIANCE_OFFTEST,APPLIANCE_USELESS' | 
|         }).then(res => { | 
|             if (res.code === 200) { | 
|                 res.data.forEach((item: any) => { | 
|                     data.columns2.push({ text: '[' + item.smodelCode  + '] ' + item.code, id: item.id }) | 
|                 }) | 
|             } | 
|         }) | 
|     } | 
|   | 
|     // 获取所有工装 | 
|     const toolingQueryByIds = () => { | 
|         data.columns3 = [] | 
|         toolingQueryById({}) | 
|             .then(res => { | 
|                 if (res.code === 200) { | 
|                     res.data.forEach((item: any) => { | 
|                         data.columns3.push({ text: item.code, id: item.id }) | 
|                     }) | 
|                 } | 
|             }) | 
|     } | 
|   | 
|     onMounted(() => { | 
|         checkAllLists() | 
|         // /productionInspection/manualInspection | 
|         // getListByConditions1() | 
|         // toolingQueryByIds() | 
|     }) | 
|   | 
|     onActivated(() => { | 
|         let res: any = localStorage.getItem('workOder') | 
|         if (res) { | 
|             form.gdmc = JSON.parse(res).mmodel.name + '-' + JSON.parse(res).pgmodel.name | 
|             form.gdid = JSON.parse(res).id | 
|             data.info = JSON.parse(res) | 
|             localStorage.removeItem('workOder') | 
|         } | 
|     }) | 
| </script> | 
|   | 
| <style lang="scss" scoped> | 
| .inspection { | 
|     width: 100%; | 
|     height: 100%; | 
|     position: absolute; | 
|     background: #F7F7F7; | 
|     .x { | 
|         height: 20px; | 
|     } | 
|     .inspection_list { | 
|         padding: 0 30px; | 
|         background: white; | 
|         .inspection_list_item { | 
|             height: 98px; | 
|             display: flex; | 
|             align-items: center; | 
|             justify-content: space-between; | 
|             border-bottom: 1PX solid #E5E5E5; | 
|             &:last-child { | 
|                 border: none; | 
|             } | 
|             span { | 
|                 font-size: 30px; | 
|                 font-weight: 400; | 
|                 color: #222222; | 
|             } | 
|             .right1 { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 span { | 
|                     font-size: 28px; | 
|                     font-weight: 400; | 
|                     color: #999999; | 
|                     margin-right: 10px; | 
|                 } | 
|                 input { | 
|                     width: 180px; | 
|                     height: 60px; | 
|                     border-radius: 8px; | 
|                     border: 1PX solid #CCCCCC; | 
|                     margin-right: 10px; | 
|                     padding: 0 30px; | 
|                     box-sizing: border-box; | 
|                     font-size: 28px; | 
|                 } | 
|                 input::-webkit-input-placeholder { | 
|                     font-size: 28px; | 
|                     font-weight: 400; | 
|                     color: #999999; | 
|                 } | 
|                 .dw { | 
|                     font-size: 28px; | 
|                     font-weight: 400; | 
|                     color: #666666; | 
|                 } | 
|             } | 
|             .right { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 .active { | 
|                     background: $nav-color !important; | 
|                     color: #ffffff !important; | 
|                 } | 
|                 .right_item { | 
|                     padding: 18px 32px; | 
|                     background: #F2F2F2; | 
|                     border-radius: 8px; | 
|                     font-size: 26px; | 
|                     font-weight: 400; | 
|                     color: #333333; | 
|                     display: flex; | 
|                     align-items: center; | 
|                     justify-content: center; | 
|                     margin-left: 20px; | 
|                 } | 
|             } | 
|         } | 
|     } | 
|     .inspection_footer { | 
|         position: fixed; | 
|         bottom: 0; | 
|         left: 0; | 
|         width: calc(100% - 60px); | 
|         padding: 30px 30px 68px 30px; | 
|         background: #F7F7F7; | 
|         .inspection_footer_sub { | 
|             width: 100%; | 
|             height: 88px; | 
|             background: #4275FC; | 
|             box-shadow: 0 0 12px 0 rgba(0,0,0,0.0800); | 
|             border-radius: 8px; | 
|             font-size: 30px; | 
|             font-weight: 500; | 
|             color: #FFFFFF; | 
|             display: flex; | 
|             align-items: center; | 
|             justify-content: center; | 
|             border: none; | 
|         } | 
|     } | 
| } | 
| </style> |