| <template> | 
|     <div class="fp"> | 
|         <div class="fp_header"> | 
|             <v-Search @searchInput="searchInput" placeholder="搜索物料名称/编码"></v-Search> | 
|             <div class="fp_header_x" v-if="tagList.length > 0"></div> | 
|             <v-LableSelection v-if="tagList.length > 0" :TagList="tagList" :isShow="false" @change="clickTag"></v-LableSelection> | 
|         </div> | 
|         <div class="fp_x">共{{search.total}}条数据</div> | 
|         <van-pull-refresh v-model="refreshing" @refresh="onRefresh"> | 
|             <van-list | 
|                 v-model:loading="loading" | 
|                 :finished="finished" | 
|                 finished-text="没有更多了~" | 
|                 @load="getLists"> | 
|                 <div class="fp_list"> | 
|                     <div class="fp_list_item" v-for="(item, i) in list" :key="item.id" @click="clickItem(i)"> | 
|                         <div class="fp_list_item_header"> | 
|                             <input type="checkbox" :checked="item.isActive" /> | 
|                             <span v-if="item.mmodel">{{item.mmodel.name}}</span> | 
|                             <div class="tags" v-if="item.urgent">优先{{item.urgent}}</div> | 
|                             <div class="warning" v-if="item.type === 2">返工</div> | 
|                             <div class="warning success" v-else-if="item.type === 0">正常</div> | 
|                             <div class="warning fail" v-else-if="item.type === 1">异常</div> | 
|                         </div> | 
|                         <div class="fp_list_item_nr"> | 
|                             <div class="item" v-if="item.pmodel"> | 
|                                 <div class="item_label">工序名称:</div> | 
|                                 <div class="item_nr">{{item.pmodel.name}}</div> | 
|                             </div> | 
|                             <div class="item"> | 
|                                 <div class="item_label">计划日期:</div> | 
|                                 <div class="item_nr">{{item.planDate}}</div> | 
|                             </div> | 
|                             <div class="item"> | 
|                                 <div class="item_label">计划数量:</div> | 
|                                 <div class="item_nr">{{item.num}}</div> | 
|                             </div> | 
|                             <div class="item"> | 
|                                 <div class="item_label">生产批次:</div> | 
|                                 <div class="item_nr">{{item.batch}}</div> | 
|                             </div> | 
|                             <div class="item"> | 
|                                 <div class="item_label">库存:</div> | 
|                                 <div class="item_nr">{{item.isStock === 0 ? '不满足' : '满足'}}</div> | 
|                             </div> | 
|                         </div> | 
|                     </div> | 
|                 </div> | 
|             </van-list> | 
|         </van-pull-refresh> | 
|         <div class="fp_zw"></div> | 
|         <div class="fp_footer"> | 
|             <div class="fp_footer_button" @click="submit">分配</div> | 
|         </div> | 
|     </div> | 
| </template> | 
|   | 
| <script setup lang="ts"> | 
|     import { Toast } from 'vant' | 
|     import { reactive, ref } from "vue" | 
|     import { useRouter } from "vue-router" | 
|     import { useStore } from "vuex" | 
|     import { getWorkingProcedure, getList, getSelfList } from '@/apis/PlanningAPI' | 
|     import { model } from '@/interface' | 
|     import vLableSelection from '@/components/common/LabelSelection.vue' | 
|   | 
|     // 搜索接口 | 
|     interface search extends model { | 
|         gxId: number | string, | 
|         total: number, | 
|         first: boolean, | 
|     } | 
|   | 
|     const store = useStore() | 
|   | 
|     const router = useRouter() | 
|   | 
|     let list: any = ref([]) | 
|     const loading = ref(false) | 
|     const finished = ref(false) | 
|     const refreshing = ref(false) | 
|   | 
|     const search = reactive<search>({ | 
|         gxId: '', | 
|         capacity: 10, | 
|         page: 0, | 
|         total: 0, | 
|         mixParam: '', | 
|         first: true // 用于判断是否是第一次进入页面 | 
|     }) | 
|   | 
|     // 标签搜索项 | 
|     let tagList: any = ref([]) | 
|   | 
|     // 点击当前项 | 
|     const clickItem = (i: number) => { | 
|         list.value.forEach((item: any, index: number) => { | 
|             item.isActive = i === index; | 
|         }) | 
|     } | 
|   | 
|     // 搜索 | 
|     const searchInput = (e: string) => { | 
|         search.mixParam = e | 
|         search.page = 0 | 
|         list.value = [] | 
|         finished.value = false | 
|         getLists() | 
|     } | 
|   | 
|     // 点击 | 
|     const clickTag = (id: any): void => { | 
|         search.gxId = id | 
|         list.value = [] | 
|         search.page = 0 | 
|         finished.value = false | 
|         getLists() | 
|     } | 
|   | 
|     // 分配 | 
|     const submit = () => { | 
|         let data: any; | 
|         list.value.forEach((item: any) => { | 
|             if (item.isActive) { | 
|                 data = item | 
|             } | 
|         }) | 
|         if (!data) { | 
|             return Toast('至少选择一项计划!') | 
|         } | 
|         router.push({ path: '/distribution/assignUsers', query: { gxid: data.procedureId, jhid: data.id, num: data.workorderDistributNum ? data.num - data.workorderDistributNum : data.num } }) | 
|     } | 
|   | 
|     // 获取当前用户所分配的工序 | 
|     const getWorkingProcedures = async (): Promise<boolean> => { | 
|         let res = await getSelfList({}) | 
|         if (res.code === 200 && res.data.length > 0) { | 
|             let arr: { name: any; id: any }[] = [] | 
|             res.data.forEach((item: any) => { | 
|                 arr.push({ name: item.name, id: item.id }) | 
|             }) | 
|             search.gxId = arr[0].id | 
|             tagList.value = arr | 
|             return true | 
|         } | 
|         return false | 
|     } | 
|   | 
|     // 获取计划列表数据 | 
|     const getLists = async () => { | 
|         if (!finished.value) {  // 判断数据是否全部加载完成 | 
|             loading.value = true | 
|             search.page = search.page + 1 | 
|             if (search.first) {     // 如果是第一次,先请求工序 | 
|                 await getWorkingProcedures() | 
|                 let res = await getList({ | 
|                     capacity: search.capacity, | 
|                     page: search.page, | 
|                     model: { | 
|                         mixParam: search.mixParam, | 
|                         procedureId: search.gxId, | 
|                         statusList: [1, 4] | 
|                     } | 
|                 }) | 
|                 loading.value = false | 
|                 if (refreshing.value) { | 
|                     list.value = [] | 
|                     refreshing.value = false; | 
|                 } | 
|                 if (res.code === 200 && res.data.records.length !== 0) { | 
|                     search.total = res.data.total | 
|                     res.data.records.forEach((item: any) => { | 
|                         item.isActive = false | 
|                     }) | 
|                     list.value.push(...res.data.records) | 
|                 } else { | 
|                     finished.value = true; | 
|                 } | 
|                 search.first = false | 
|             } else { | 
|                 let res = await getList({ | 
|                     capacity: search.capacity, | 
|                     page: search.page, | 
|                     model: { | 
|                         mixParam: search.mixParam, | 
|                         procedureId: search.gxId, | 
|                         statusList: [1, 4] | 
|                     } | 
|                 }) | 
|                 if (refreshing.value) { | 
|                     list.value = [] | 
|                     refreshing.value = false; | 
|                 } | 
|                 loading.value = false | 
|                 if (res.code === 200 && res.data.records.length !== 0) { | 
|                     res.data.records.forEach((item: any) => { | 
|                         item.isActive = false | 
|                     }) | 
|                     list.value.push(...res.data.records) | 
|                     search.total = res.data.total | 
|                 } else { | 
|                     finished.value = true; | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|     // 下拉刷新优化页面 | 
|     const onRefresh = () => { | 
|         finished.value = false; | 
|         search.page = 0 | 
|         loading.value = true; | 
|         getLists(); | 
|     } | 
| </script> | 
|   | 
| <style lang="scss" scoped> | 
| .fp { | 
|     .fp_header { | 
|         padding: 30px; | 
|         background: #ffffff; | 
|         .Search_item { | 
|             margin-bottom: 40px; | 
|             .Search_item_label { | 
|                 font-size: 30px; | 
|                 font-weight: 500; | 
|                 color: #222222; | 
|             } | 
|             .Search_item_content { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: space-between; | 
|                 margin-top: 30px; | 
|                 .tag { | 
|                     display: flex; | 
|                     flex-wrap: wrap; | 
|                     align-items: center; | 
|                     .tag_active { | 
|                         background: $nav-color !important; | 
|                         color: #ffffff !important; | 
|                     } | 
|                     .tag_item { | 
|                         width: 156px; | 
|                         height: 70px; | 
|                         box-sizing: border-box; | 
|                         background: #F2F2F2; | 
|                         border-radius: 8px; | 
|                         font-size: 26px; | 
|                         font-weight: 400; | 
|                         color: #333333; | 
|                         display: flex; | 
|                         align-items: center; | 
|                         justify-content: center; | 
|                         margin-right: 22px; | 
|                         margin-bottom: 22px; | 
|                         &:nth-child(4n) { | 
|                             margin-right: 0; | 
|                         } | 
|                     } | 
|                 } | 
|                 span { | 
|                     font-size: 26px; | 
|                     font-weight: 400; | 
|                     color: #333333; | 
|                 } | 
|                 .Search_item_content_a { | 
|                     width: 308px; | 
|                     height: 70px; | 
|                     background: #F7F7F7; | 
|                     border-radius: 8px; | 
|                     border: 1px solid #EEEEEE; | 
|                     font-size: 26px; | 
|                     font-weight: 400; | 
|                     color: #B2B2B2; | 
|                     display: flex; | 
|                     align-items: center; | 
|                     justify-content: center; | 
|                 } | 
|             } | 
|         } | 
|         .fp_header_x { | 
|             height: 24px; | 
|         } | 
|     } | 
|     .fp_x { | 
|         padding: 24px 30px; | 
|         background: #F7F7F7; | 
|         font-size: 24px; | 
|         font-weight: 400; | 
|         color: #666666; | 
|     } | 
|     .fp_list { | 
|         display: flex; | 
|         flex-direction: column; | 
|         .fp_list_item { | 
|             background: white; | 
|             display: flex; | 
|             flex-direction: column; | 
|             padding: 30px; | 
|             border-bottom: 1px solid #ececec; | 
|             .fp_list_item_header { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 input { | 
|                     width: 30px; | 
|                     height: 30px; | 
|                 } | 
|                 span { | 
|                     max-width: 64%; | 
|                     overflow: hidden; | 
|                     white-space: nowrap; | 
|                     text-overflow: ellipsis; | 
|                     -o-text-overflow: ellipsis; | 
|                     font-size: 32px; | 
|                     font-weight: 500; | 
|                     color: #333333; | 
|                     margin-left: 20px; | 
|                 } | 
|                 .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; | 
|                 .item { | 
|                     display: flex; | 
|                     align-items: flex-start; | 
|                     width: 50%; | 
|                     margin-top: 24px; | 
|                     &:nth-child(1) { | 
|                         margin-top: 0!important; | 
|                     } | 
|                     &:nth-child(2) { | 
|                         margin-top: 0!important; | 
|                     } | 
|                     .item_label { | 
|                         width: 130px; | 
|                         flex-shrink: 0; | 
|                         font-size: 24px; | 
|                         font-weight: 400; | 
|                         color: #666666; | 
|                         text-align: right; | 
|                     } | 
|                     .item_nr { | 
|                         font-size: 24px; | 
|                         font-weight: 400; | 
|                         color: #222222; | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|     } | 
|     .fp_zw { | 
|         height: 150px; | 
|     } | 
|     .fp_footer { | 
|         width: 100%; | 
|         position: fixed; | 
|         bottom: 0; | 
|         left: 0; | 
|         background: #ffffff; | 
|         .fp_footer_button { | 
|             width: 272px; | 
|             height: 98px; | 
|             background: $nav-color; | 
|             font-size: 32px; | 
|             font-weight: 500; | 
|             color: #FFFFFF; | 
|             display: flex; | 
|             align-items: center; | 
|             justify-content: center; | 
|             float: right; | 
|         } | 
|     } | 
| } | 
| </style> |