| <template> | 
|     <van-popup | 
|         v-model:show="props.show" | 
|         :close-on-click-overlay="false" | 
|         position="bottom" | 
|         round | 
|         :style="{ height: '80%' }"> | 
|         <div class="content"> | 
|             <div class="content_search content_top"> | 
|                 <div class="title1"> | 
|                     <img class="close" src="@/assets/icon/ic_close@2x.png" alt="" style="opacity: 0;" /> | 
|                     <span>选择物料</span> | 
|                     <img class="close" src="@/assets/icon/ic_close@2x.png" alt="" @click="close" /> | 
|                 </div> | 
|                 <v-Search ref="V" @searchInput="searchInput" @submit="submit" :isShow="false" placeholder="搜索物料名称"></v-Search> | 
|             </div> | 
|             <div class="content_total">共{{form.total}}条数据</div> | 
|             <van-pull-refresh v-model="refreshing" @refresh="onRefresh"> | 
|                 <van-list | 
|                     v-model:loading="loading" | 
|                     :finished="finished" | 
|                     finished-text="没有更多了~" | 
|                     @load="onLoad"> | 
|                     <div class="fp_list"> | 
|                         <div class="fp_list_item" v-for="(item, i) in list" :key="i" @click="jump(item)"> | 
|                             <div class="fp_list_item_box"> | 
|                                 <div class="fp_list_item_header"> | 
|                                     <span>{{item.materialName}} | {{item.materialCode}}</span> | 
|                                     <span> | 
|                                         <span class="green" v-if="item.qualityType === '0'">合格</span> | 
|                                         <span class="yellow" v-if="item.qualityType === '1'">不良</span> | 
|                                         <span class="red" v-if="item.qualityType === '2'">报废</span> | 
|                                         |{{item.procedureName ? item.procedureName : '-'}}|{{item.batch ? item.batch : '-'}} | 
|                                     </span> | 
|                                     <span class="loacing">货位:{{item.locationName}}</span> | 
|                                 </div> | 
|                             </div> | 
|                             <input type="checkbox" :checked="item.isActive" /> | 
|                         </div> | 
|                     </div> | 
|                 </van-list> | 
|             </van-pull-refresh> | 
|             <div class="content_zw"></div> | 
|             <div class="content_footer"> | 
|                 <div class="content_footer_submit" @click="submitData">确认选择</div> | 
|             </div> | 
|         </div> | 
|     </van-popup> | 
| </template> | 
|   | 
| <script setup lang="ts"> | 
|     import { defineProps, defineEmits, onMounted, ref, reactive, watch } from 'vue' | 
|     import { choiceStockListPage } from '@/apis/agencyAPI' | 
|     import { model } from '@/interface' | 
|     import { judgmentPlatform } from "@/utils/utils" | 
|     import vSearch from '@/components/common/Search.vue' | 
|   | 
|     // 搜索数据接口 | 
|     interface form extends model { | 
|         total: number, | 
|         smodelLabel: string, | 
|         categoryId: string | 
|     } | 
|   | 
|     const form = reactive<form>({ | 
|         capacity: 50, | 
|         page: 0, | 
|         total: 0, | 
|         smodelLabel: '', | 
|         categoryId: '' | 
|     }) | 
|   | 
|     // 搜索分类标签 | 
|     let tagList = ref<Array<{id: string, name: string, num: string}>>([]) | 
|   | 
|     // 列表数据 | 
|     const list: any = ref([]); | 
|     const loading = ref(false); | 
|     const finished = ref(false); | 
|     const refreshing = ref(false) | 
|     const V = ref(null) | 
|     let isOpen = ref<boolean>(true) | 
|     let all = ref<boolean>(false) | 
|     let total = ref<number>(0) | 
|     let selected = ref<Array<any>>([]) | 
|   | 
|     // 提交数据 | 
|     const submitData = () => { | 
|         let arr: Array<any> = [] | 
|         list.value.forEach((element: any) => { | 
|             if (element.isActive) { | 
|                 arr.push(element) | 
|             } | 
|         }) | 
|         emit('value', arr) | 
|     } | 
|   | 
|     // 全选 | 
|     const selectAll = () => { | 
|         all.value = !all.value | 
|         list.value.forEach((element: any) => { | 
|             element.isActive = all.value | 
|         }) | 
|     } | 
|   | 
|     const test = () => { | 
|         const { text }: any = V.value | 
|         form.smodelLabel = '' | 
|         V.value.text = '' | 
|     } | 
|   | 
|     const clickTag = (tag: string): void => { | 
|         form.categoryId = tag | 
|         list.value = [] | 
|         finished.value = false | 
|         form.page = 0 | 
|         form.total = 0 | 
|         onLoad() | 
|     } | 
|   | 
|     // 搜索框 | 
|     const searchInput = (data: any) => { | 
|         form.page = 0 | 
|         finished.value = false | 
|         list.value = [] | 
|         form.smodelLabel = data | 
|         onLoad() | 
|     } | 
|   | 
|     // 搜索提交 | 
|     const submit = (): void => { | 
|         form.page = 0 | 
|         finished.value = false | 
|         list.value = [] | 
|         onLoad() | 
|     } | 
|   | 
|     // 返回上一页带参数 | 
|     const jump = (item: any) => { | 
|         item.isActive = !item.isActive | 
|     } | 
|   | 
|     // 获取工单列表数据 | 
|     const onLoad = async () => { | 
|         if (!finished.value) { | 
|             loading.value = true; | 
|             form.page = form.page + 1 | 
|             choiceStockListPage({ | 
|                 capacity: form.capacity, | 
|                 page: form.page, | 
|                 model: { | 
|                     warehouseId: props.id, | 
|                     warehouseQualityType: props.warehouseQualityType, | 
|                     ids: selected.value.length > 0 ? selected.value.join(',') : '' | 
|                 } | 
|             }).then(res => { | 
|                 if (refreshing.value) { | 
|                     list.value = [] | 
|                     refreshing.value = false; | 
|                 } | 
|                 loading.value = false; | 
|                 if (res.code === 200 && res.data.records && res.data.records.length !== 0) { | 
|                     form.total = res.data.total | 
|                     res.data.records.forEach((element: any) => { | 
|                         element.isActive = false | 
|                     }) | 
|                     // if (selected.value.length > 0) { | 
|                     //     selected.value.forEach((id: any) => { | 
|                     //         res.data.records.forEach((element: any, index: number) => { | 
|                     //             if (id === element.materialId) { | 
|                     //                 res.data.records.splice(index, 1) | 
|                     //             } | 
|                     //         }) | 
|                     //     }) | 
|                     // } | 
|                     list.value.push(...res.data.records) | 
|                 } else { | 
|                     finished.value = true; | 
|                 } | 
|             }).catch((err: any) => { | 
|                 loading.value = false; | 
|                 finished.value = true; | 
|                 if (refreshing.value) { | 
|                     list.value = [] | 
|                     refreshing.value = false; | 
|                 } | 
|             }) | 
|         } | 
|     } | 
|   | 
|     // 下拉刷新优化页面 | 
|     const onRefresh = () => { | 
|         finished.value = false; | 
|         form.page = 0 | 
|         loading.value = true; | 
|         onLoad() | 
|     } | 
|   | 
|     const props = defineProps({ | 
|         show: { | 
|             type: Boolean, | 
|             required: true | 
|         }, | 
|         id: { | 
|             type: String, | 
|             required: false | 
|         }, | 
|         warehouseQualityType: { | 
|             type: String, | 
|             required: false | 
|         } | 
|     }) | 
|   | 
|     const emit = defineEmits(['close', 'value']) | 
|   | 
|     let status = ref<boolean>(false) | 
|   | 
|     // 关闭回调 | 
|     const close = () => { | 
|         emit('close') | 
|     } | 
|   | 
|     watch(() => list.value, (news) => { | 
|         if (list.value.length > 0) { | 
|             total.value = 0 | 
|             list.value.forEach((element: any) => { | 
|                 if (element.isActive) { | 
|                     total.value = total.value + 1 | 
|                 } | 
|             }) | 
|         } | 
|     }, { deep: true }) | 
|   | 
|     watch(() => props.show, (news) => { | 
|         if (!news) { | 
|             test() | 
|         } else { | 
|             if (!isOpen.value) { | 
|                 list.value = [] | 
|                 finished.value = false; | 
|                 form.page = 0 | 
|                 loading.value = true; | 
|                 onLoad() | 
|             } | 
|             isOpen.value = false | 
|         } | 
|     }) | 
|   | 
|     defineExpose({ | 
|         selected | 
|     }) | 
|   | 
|     onMounted(() => { | 
|         status.value = judgmentPlatform() | 
|     }) | 
| </script> | 
|   | 
| <style lang="scss" scoped> | 
|     .title { | 
|         position: fixed; | 
|         right: 50px; | 
|         bottom: 230px; | 
|         z-index: 9; | 
|         .close { | 
|             width: 80px; | 
|             height: 80px; | 
|             border-radius: 50%; | 
|             background: #999999; | 
|             display: flex; | 
|             align-items: center; | 
|             justify-content: center; | 
|         } | 
|     } | 
|     .content { | 
|         .content_code { | 
|             position: fixed; | 
|             right: 30px; | 
|             bottom: 100px; | 
|             img { | 
|                 width: 138px; | 
|                 height: 138px; | 
|             } | 
|         } | 
|         .content_top { | 
|             top: 0 !important; | 
|         } | 
|         .content_search { | 
|             padding: 30px; | 
|             background: white; | 
|             position: sticky; | 
|             top: 88px; | 
|             z-index: 9; | 
|             .title1 { | 
|                 width: 100%; | 
|                 padding: 0 0 30px 0; | 
|                 box-sizing: border-box; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: space-between; | 
|                 span { | 
|                     font-size: 30px; | 
|                     font-family: PingFangSC-Medium, PingFang SC; | 
|                     font-weight: 500; | 
|                     color: #222222; | 
|                 } | 
|                 .close { | 
|                     width: 28px; | 
|                     height: 28px; | 
|                 } | 
|             } | 
|             .content_search_x { | 
|                 height: 24px; | 
|             } | 
|         } | 
|         .content_total { | 
|             padding: 24px 30px; | 
|             background: #F7F7F7; | 
|             font-size: 24px; | 
|             font-weight: 400; | 
|             position: sticky; | 
|             z-index: 99; | 
|             top: 195px; | 
|             color: #666666; | 
|         } | 
|         .fp_list { | 
|             display: flex; | 
|             flex-direction: column; | 
|             .fp_list_item { | 
|                 background: white; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: space-between; | 
|                 padding: 30px; | 
|                 border-bottom: 1px solid #ececec; | 
|                 input { | 
|                     flex-shrink: 0; | 
|                     width: 30px; | 
|                     height: 30px; | 
|                 } | 
|                 .fp_list_item_box { | 
|                     flex: 1; | 
|                     .fp_list_item_header { | 
|                         display: flex; | 
|                         flex-direction: column; | 
|                         .loacing { | 
|                             font-size: 26px !important; | 
|                             font-family: PingFangSC-Regular, PingFang SC; | 
|                             font-weight: 400 !important; | 
|                             color: #333333 !important; | 
|                             margin-top: 20px; | 
|                         } | 
|                         span { | 
|                             max-width: 64%; | 
|                             overflow: hidden; | 
|                             white-space: nowrap; | 
|                             text-overflow: ellipsis; | 
|                             -o-text-overflow: ellipsis; | 
|                             font-size: 32px; | 
|                             font-weight: 500; | 
|                             color: #333333; | 
|                             &:nth-child(2) { | 
|                                 font-size: 24px; | 
|                                 font-weight: 400; | 
|                                 color: #666666; | 
|                                 margin: 20px 0 0 0; | 
|                                 span { | 
|                                     font-size: 24px; | 
|                                 } | 
|                             } | 
|                         } | 
|                         .tags { | 
|                             flex-shrink: 0; | 
|                             margin-left: 16px; | 
|                             padding: 5px 10px; | 
|                             background: $nav-stateColor4; | 
|                             border-radius: 8px; | 
|                             display: flex; | 
|                             align-items: center; | 
|                             justify-content: center; | 
|                             font-size: 22px; | 
|                             font-weight: 400; | 
|                             color: #FFFFFF; | 
|                         } | 
|                         .fail { | 
|                             background: $nav-stateColor4 !important; | 
|                         } | 
|                         .success { | 
|                             background: $nav-stateColor2 !important; | 
|                         } | 
|                         .warning { | 
|                             flex-shrink: 0; | 
|                             margin-left: 16px; | 
|                             padding: 5px 10px; | 
|                             background: $nav-stateColor5; | 
|                             border-radius: 8px; | 
|                             display: flex; | 
|                             align-items: center; | 
|                             justify-content: center; | 
|                             font-size: 22px; | 
|                             font-weight: 400; | 
|                             color: #FFFFFF; | 
|                         } | 
|                     } | 
|                     .fp_list_item_nr { | 
|                         padding: 24px 30px; | 
|                         background: #F7F7F7; | 
|                         border-radius: 16px; | 
|                         margin-top: 32px; | 
|                         display: flex; | 
|                         align-items: flex-start; | 
|                         flex-wrap: wrap; | 
|                         flex-direction: column; | 
|                         .item { | 
|                             display: flex; | 
|                             align-items: flex-start; | 
|                             width: 100%; | 
|                             margin-top: 24px; | 
|                             &:nth-child(1) { | 
|                                 margin-top: 0!important; | 
|                             } | 
|                             .item_label { | 
|                                 flex-shrink: 0; | 
|                                 font-size: 24px; | 
|                                 font-weight: 400; | 
|                                 color: #666666; | 
|                                 text-align: right; | 
|                             } | 
|                             .item_nr { | 
|                                 font-size: 24px; | 
|                                 font-weight: 400; | 
|                                 color: #222222; | 
|                             } | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|         .content_zw { | 
|             height: 168px; | 
|         } | 
|         .content_footer { | 
|             position: fixed; | 
|             bottom: 0; | 
|             left: 0; | 
|             width: 100%; | 
|             height: 98px; | 
|             padding: 0 30px 68px 30px; | 
|             box-sizing: border-box; | 
|             // padding-bottom: 68px; | 
|             background: white; | 
|             display: flex; | 
|             align-items: center; | 
|             justify-content: space-between; | 
|             .content_footer_xz { | 
|                 flex: 1; | 
|                 height: 100%; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 margin-left: 30px; | 
|                 input { | 
|                     width: 30px; | 
|                     height: 30px; | 
|                     border-radius: 4px; | 
|                     border: 2px solid #B2B2B2; | 
|                 } | 
|                 span { | 
|                     font-size: 28px; | 
|                     font-weight: 400; | 
|                     color: #666666; | 
|                     margin-left: 10px; | 
|                 } | 
|             } | 
|             .content_footer_submit { | 
|                 flex: 1; | 
|                 height: 98px; | 
|                 background: #4275FC; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: center; | 
|                 font-size: 32px; | 
|                 font-weight: 500; | 
|                 color: #FFFFFF; | 
|             } | 
|         } | 
|     } | 
| </style> |