<template> 
 | 
    <div class="content"> 
 | 
        <div :class="{ 'content_top': status }" class="content_search"> 
 | 
            <v-Search ref="Search" @searchInput="searchInput" @submit="submit" @reset="reset" :isShow="true" placeholder="搜索物料名称/编码/工序名称"> 
 | 
                <template v-slot:content> 
 | 
                    <div class="Search_item"> 
 | 
                        <div class="Search_item_label">计划日期</div> 
 | 
                        <div class="Search_item_content" @click="openDate"> 
 | 
                            <div class="Search_item_content_a" :style="listData.startDate ? 'color: #000' : ''">{{ listData.startDate ? listData.startDate : '开始日期'}}</div> 
 | 
                            <span>-</span> 
 | 
                            <div class="Search_item_content_a" :style="listData.endDate ? 'color: #000' : ''">{{ listData.endDate ? listData.endDate : '结束日期'}}</div> 
 | 
                        </div> 
 | 
                    </div> 
 | 
                    <div class="Search_item"> 
 | 
                        <div class="Search_item_label">生产工厂</div> 
 | 
                        <div class="Search_item_content"> 
 | 
                            <div class="tag"> 
 | 
                                <div class="tag_item" :class="{'tag_active': item.isActive}" v-for="(item, i) in factoryList" :key="item.id" @click="changeTags(i, item.id)">{{item.name}}</div> 
 | 
                            </div> 
 | 
                        </div> 
 | 
                    </div> 
 | 
                    <div class="Search_item"> 
 | 
                        <div class="Search_item_label">工序</div> 
 | 
                        <div class="Search_item_content"> 
 | 
                            <div class="tag"> 
 | 
                                <div class="tag_item" :class="{'tag_active': item.isActive}" v-for="(item, i) in data" :key="item.id" @click="changeTag(i)">{{item.name}}</div> 
 | 
                            </div> 
 | 
                        </div> 
 | 
                    </div> 
 | 
                </template> 
 | 
            </v-Search> 
 | 
            <div class="content_search_x"></div> 
 | 
            <v-LableSelection :TagList="tagList" :isShow="true" @change="clickTag"></v-LableSelection> 
 | 
        </div> 
 | 
        <div class="content_total">共{{listData.total}}条数据</div> 
 | 
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh"> 
 | 
            <van-list 
 | 
                v-model:loading="loading" 
 | 
                :finished="finished" 
 | 
                finished-text="没有更多了~" 
 | 
                @load="getLists"> 
 | 
                <div class="content_list"> 
 | 
                    <div class="content_list_item" v-for="item in lists" :key="item.id" @click="jump(item)"> 
 | 
                        <div class="content_list_item_top"> 
 | 
                            <div class="content_list_item_top_left"> 
 | 
                                <span v-if="item.mmodel">{{item.mmodel.name}}</span> 
 | 
                                <div class="content_list_item_top_left_tag" v-if="item.urgent">优先{{item.urgent}}</div> 
 | 
                                <div class="content_list_item_top_left_tag warning" v-if="item.paused === 1">停</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_top_right"> 
 | 
                                <span v-if="item.status === 0">已生成</span> 
 | 
                                <span v-if="item.status === 1">已发布</span> 
 | 
                                <span v-if="item.status === 2">已撤回</span> 
 | 
                                <span v-if="item.status === 3">已取消</span> 
 | 
                                <span v-if="item.status === 4">已分配</span> 
 | 
                                <span v-if="item.status === 5">已暂停</span> 
 | 
                                <span v-if="item.status === 6">已完工</span> 
 | 
                                <span v-if="item.status === 7">已入库</span> 
 | 
                                <span v-if="item.status === 8">已关闭</span> 
 | 
    <!--                            <span class="warning" v-if="item.status === 0">待发布</span>--> 
 | 
    <!--                            <span class="green" v-else-if="item.status === 1 || item.status === 4">生产中</span>--> 
 | 
    <!--                            <span class="info" v-else-if="item.status === 6 || item.status === 7 || item.status === 3 || item.status === 8">已完成</span>--> 
 | 
                            </div> 
 | 
                        </div> 
 | 
                        <div class="content_list_item_content"> 
 | 
                            <div class="content_list_item_content_item" v-if="item.pmodel"> 
 | 
                                <div class="content_list_item_content_item_label">工序名称:</div> 
 | 
                                <div class="content_list_item_content_item_nr">{{item.pmodel.name}}</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_content_item"> 
 | 
                                <div class="content_list_item_content_item_label">计划日期:</div> 
 | 
                                <div class="content_list_item_content_item_nr">{{item.planDate}}</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_content_item"> 
 | 
                                <div class="content_list_item_content_item_label">物料编码:</div> 
 | 
                                <div class="content_list_item_content_item_nr" v-if="item.mmodel">{{item.mmodel.code}}</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_content_item"> 
 | 
                                <div class="content_list_item_content_item_label">计划数量:</div> 
 | 
                                <div class="content_list_item_content_item_nr" v-if="item.umodel">{{item.num}}{{item.umodel.name}}</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_content_item"> 
 | 
                                <div class="content_list_item_content_item_label">生产批次:</div> 
 | 
                                <div class="content_list_item_content_item_nr">{{item.batch}}</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_content_item"> 
 | 
                                <div class="content_list_item_content_item_label">发布日期:</div> 
 | 
                                <div class="content_list_item_content_item_nr">{{item.publishDate ? item.publishDate : '-'}}</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_content_item"> 
 | 
                                <div class="content_list_item_content_item_label">计划人员:</div> 
 | 
                                <div class="content_list_item_content_item_nr">{{item.usermodel.realname}}</div> 
 | 
                            </div> 
 | 
                            <div class="content_list_item_content_item"> 
 | 
                                <div class="content_list_item_content_item_label">生产工厂:</div> 
 | 
                                <div class="content_list_item_content_item_nr">{{item.fmodel.name}}</div> 
 | 
                            </div> 
 | 
                        </div> 
 | 
                    </div> 
 | 
                </div> 
 | 
            </van-list> 
 | 
        </van-pull-refresh> 
 | 
        <van-calendar v-model:show="isOpenDate" :min-date="minDate" :max-date="maxDate" type="range" @confirm="onConfirm" color="#4275FC" /> 
 | 
    </div> 
 | 
</template> 
 | 
  
 | 
<script setup lang="ts"> 
 | 
    import { reactive, ref, onMounted } from "vue" 
 | 
    import { useRouter } from "vue-router" 
 | 
    import { gsdate } from '@/utils/utils' 
 | 
    import { getList, pageCount } from '@/apis/PlanningAPI' 
 | 
    import { getWorkingProcedure, getOrganization } from '@/apis' 
 | 
    import { judgmentPlatform } from '@/utils/utils' 
 | 
    import { model } from '@/interface' 
 | 
    import vSearch from '@/components/common/Search.vue' 
 | 
    import vLableSelection from '@/components/common/LabelSelection.vue' 
 | 
  
 | 
    // 分页/查询-----接口 
 | 
    interface PagingType extends model { 
 | 
        total: number, 
 | 
        startDate: string, 
 | 
        endDate: string, 
 | 
        procedureIds: Array<any>, 
 | 
        departIds: string | number, 
 | 
        cateIds: Array<any> 
 | 
    } 
 | 
  
 | 
    // 分页/查询-----数据 
 | 
    const listData = reactive<PagingType>({ 
 | 
        capacity: 10, 
 | 
        page: 0, 
 | 
        total: 0, 
 | 
        startDate: '', 
 | 
        endDate: '', 
 | 
        procedureIds: [], 
 | 
        departIds: '', 
 | 
        mixParam: '', 
 | 
        cateIds: [] 
 | 
    }) 
 | 
  
 | 
    const router = useRouter() 
 | 
  
 | 
    const minDate: Date = new Date(2021, 0, 1) 
 | 
  
 | 
    const maxDate: Date = new Date(new Date().getFullYear() + 1, 12, 30) 
 | 
  
 | 
    // 工序数据 
 | 
    let data: any = ref([]) 
 | 
  
 | 
    // 工厂数据 
 | 
    let factoryList: any = ref([]) 
 | 
  
 | 
    // 列表数据 
 | 
    let lists: any = ref([]) 
 | 
  
 | 
    // 控制打开日历插件 
 | 
    const isOpenDate = ref<boolean>(false) 
 | 
  
 | 
    // 根据平台是否需要设置top 
 | 
    let status = ref<boolean>(false) 
 | 
  
 | 
    const list: any = ref<Array<object>>([]) 
 | 
    const loading = ref<boolean>(false) 
 | 
    const finished = ref<boolean>(true) 
 | 
    const refreshing = ref(false) 
 | 
  
 | 
    // 搜索标签数据 
 | 
    const tagList = reactive<Array<{ id: Array<number>, name: string, num: string }>>([ 
 | 
        { 
 | 
            id: [], 
 | 
            name: '全部', 
 | 
            num: '0' 
 | 
        }, 
 | 
        { 
 | 
            id: [0], 
 | 
            name: '待发布', 
 | 
            num: '0' 
 | 
        }, 
 | 
        { 
 | 
            id: [1, 4], 
 | 
            name: '生产中', 
 | 
            num: '0' 
 | 
        }, 
 | 
        { 
 | 
            id: [6, 7, 3, 8], 
 | 
            name: '已完成', 
 | 
            num: '0' 
 | 
        } 
 | 
    ]) 
 | 
  
 | 
    // 重置 
 | 
    const reset = () => { 
 | 
        listData.page = 0 
 | 
        finished.value = false 
 | 
        lists.value = [] 
 | 
        listData.mixParam = '' 
 | 
        listData.startDate = '' 
 | 
        listData.endDate = '' 
 | 
        listData.procedureIds = [] 
 | 
        if (factoryList.value.length > 0) { 
 | 
            listData.departIds = factoryList.value[0].id 
 | 
        } 
 | 
        data.value.forEach((item: any) => { item.isActive = false }) 
 | 
        getLists() 
 | 
        pageCounts() 
 | 
    } 
 | 
  
 | 
    // 获取列表统计 
 | 
    const pageCounts = () => { 
 | 
        pageCount({ 
 | 
            factoryId: listData.departIds, 
 | 
            procedureIdList: listData.procedureIds ? listData.procedureIds : [], 
 | 
            startDate: listData.startDate, 
 | 
            endDate: listData.endDate, 
 | 
            statusList: listData.cateIds 
 | 
        }) 
 | 
            .then(res => { 
 | 
                if (res.code === 200 && res.data) { 
 | 
                    tagList[0].num = res.data.allNum.toString() 
 | 
                    tagList[1].num = res.data.startNum.toString() 
 | 
                    tagList[2].num = res.data.ingNum.toString() 
 | 
                    tagList[3].num = res.data.endNum.toString() 
 | 
                } 
 | 
            }) 
 | 
    } 
 | 
  
 | 
    // 获取工厂数据 
 | 
    const getOrganizations = () => { 
 | 
        getOrganization({ 
 | 
            type: 1 
 | 
        }).then((res: any) => { 
 | 
            if (res.code === 200 && res.data && res.data.length !== 0) { 
 | 
                res.data.forEach((item: any, i: number) => { 
 | 
                    item.isActive = i === 0; 
 | 
                }) 
 | 
                if (res.data.length > 0) { 
 | 
                    factoryList.value = res.data 
 | 
                    listData.departIds = factoryList.value[0].id 
 | 
                    listData.procedureIds = '' as never 
 | 
                    finished.value = false 
 | 
                    getWorkingProcedures(factoryList.value[0].id) 
 | 
                    getLists() 
 | 
                    pageCounts() 
 | 
                } 
 | 
            } 
 | 
        }) 
 | 
    } 
 | 
  
 | 
    // 获取工序数据 
 | 
    const getWorkingProcedures = (orgId: string | number): void => { 
 | 
        data.value = [] 
 | 
        getWorkingProcedure({ orgId }) 
 | 
            .then((res: any) => { 
 | 
                if (res.code === 200 && res.data && res.data.length !== 0) { 
 | 
                    res.data.forEach((item: any, i: number) => { 
 | 
                        item.isActive = false; 
 | 
                    }) 
 | 
                    data.value = res.data 
 | 
                } 
 | 
            }) 
 | 
    } 
 | 
  
 | 
    // 获取计划列表数据 
 | 
    const getLists = (): void => { 
 | 
        if (!finished.value) { 
 | 
            loading.value = true 
 | 
            listData.page = listData.page + 1 
 | 
            getList({ 
 | 
                capacity: listData.capacity, 
 | 
                model: { 
 | 
                    mixParam: listData.mixParam, 
 | 
                    startDate: listData.startDate, 
 | 
                    endDate: listData.endDate, 
 | 
                    procedureIdList: listData.procedureIds ? listData.procedureIds : [], 
 | 
                    factoryId: listData.departIds, 
 | 
                    statusList: listData.cateIds 
 | 
                }, 
 | 
                page: listData.page, 
 | 
                sorts: [ 
 | 
                    { 
 | 
                        direction: 'ASC', 
 | 
                        property: 'publishDate' 
 | 
                    } 
 | 
                ] 
 | 
            }).then((res: any) => { 
 | 
                loading.value = false 
 | 
                listData.total = res.data.total 
 | 
                if (refreshing.value) { 
 | 
                    lists.value = [] 
 | 
                    refreshing.value = false; 
 | 
                } 
 | 
                if (res.code === 200 && res.data.records.length !== 0) { 
 | 
                    if (lists.value.length === 0) { 
 | 
                        lists.value = res.data.records 
 | 
                    } else { 
 | 
                        lists.value.push(...res.data.records) 
 | 
                    } 
 | 
                } else { 
 | 
                    finished.value = true 
 | 
                } 
 | 
            }).catch((err: any) => { 
 | 
                loading.value = false 
 | 
                finished.value = true 
 | 
                if (refreshing.value) { 
 | 
                    lists.value = [] 
 | 
                    refreshing.value = false; 
 | 
                } 
 | 
            }) 
 | 
        } 
 | 
    } 
 | 
  
 | 
    // 下拉刷新优化页面 
 | 
    const onRefresh = () => { 
 | 
        finished.value = false; 
 | 
        listData.page = 0 
 | 
        loading.value = true; 
 | 
        getLists(); 
 | 
        pageCounts() 
 | 
    } 
 | 
  
 | 
    // 接收子组件传来的输入框值 
 | 
    const searchInput = (val: string): void => { 
 | 
        listData.mixParam = val 
 | 
        listData.page = 0 
 | 
        finished.value = false 
 | 
        lists.value = [] 
 | 
        getLists() 
 | 
    } 
 | 
  
 | 
    // 搜索弹框提交 
 | 
    const submit = (): void => { 
 | 
        let pmodelOrgId: any[] = [] 
 | 
        data.value.forEach((item: any) => { 
 | 
            if (item.isActive) { 
 | 
                pmodelOrgId.push(item.id) 
 | 
            } 
 | 
        }) 
 | 
        listData.procedureIds = pmodelOrgId 
 | 
        listData.page = 0 
 | 
        finished.value = false 
 | 
        lists.value = [] 
 | 
        getLists() 
 | 
        pageCounts() 
 | 
    } 
 | 
  
 | 
    // 打开日期插件 
 | 
    const openDate = (): void => { 
 | 
        isOpenDate.value = true 
 | 
    } 
 | 
  
 | 
    // 确认选择时间 
 | 
    const onConfirm = (values: any): void => { 
 | 
        const [start, end] = values; 
 | 
        listData.startDate = gsdate(start) 
 | 
        listData.endDate = gsdate(end) 
 | 
        isOpenDate.value = false; 
 | 
    }; 
 | 
  
 | 
    // 点击标签搜索 
 | 
    const clickTag = (ids: any): void => { 
 | 
        listData.cateIds = ids 
 | 
        listData.page = 0 
 | 
        finished.value = false 
 | 
        lists.value = [] 
 | 
        getLists() 
 | 
    } 
 | 
  
 | 
    // 切换工厂 
 | 
    const changeTags = (i: any, id: string | number): void => { 
 | 
        listData.departIds = id 
 | 
        getWorkingProcedures(id) 
 | 
        factoryList.value.forEach((item: { isActive: boolean; }, index: any) => { 
 | 
            if (index === i) { 
 | 
                item.isActive = true 
 | 
            } else { 
 | 
                item.isActive = false 
 | 
            } 
 | 
            // item.isActive = index === i; 
 | 
        }) 
 | 
    } 
 | 
  
 | 
    // 切换工序 
 | 
    const changeTag = (i: any): void => { 
 | 
        data.value[i].isActive = !data.value[i].isActive 
 | 
    } 
 | 
  
 | 
    // 跳转详情 
 | 
    const jump = (item: any): void => { 
 | 
        router.push({ name: 'progressDetails', query: { id: item.id } }) 
 | 
    } 
 | 
  
 | 
    onMounted(() => { 
 | 
        status.value = judgmentPlatform() 
 | 
        getLists() 
 | 
        // pageCounts() 
 | 
        // getWorkingProcedures() 
 | 
        getOrganizations() 
 | 
    }) 
 | 
</script> 
 | 
  
 | 
<style lang="scss" scoped> 
 | 
.content { 
 | 
    .content_top { 
 | 
        top: 0 !important; 
 | 
    } 
 | 
    .content_search { 
 | 
        padding: 30px; 
 | 
        background: white; 
 | 
        position: sticky; 
 | 
        top: 88px; 
 | 
        z-index: 999; 
 | 
        .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 { 
 | 
                        padding: 22px 26px; 
 | 
                        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; 
 | 
                    } 
 | 
                } 
 | 
                span { 
 | 
                    font-size: 26px; 
 | 
                    font-weight: 400; 
 | 
                    color: #333333; 
 | 
                    margin: 0 30px; 
 | 
                } 
 | 
                .Search_item_content_a { 
 | 
                    padding: 20px 0; 
 | 
                    flex: 1; 
 | 
                    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; 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
        .content_search_x { 
 | 
            height: 24px; 
 | 
        } 
 | 
    } 
 | 
    .content_total { 
 | 
        padding: 24px 30px; 
 | 
        background: #F7F7F7; 
 | 
        font-size: 24px; 
 | 
        font-weight: 400; 
 | 
        color: #666666; 
 | 
    } 
 | 
    .content_list { 
 | 
        width: 100%; 
 | 
        height: 100%; 
 | 
        display: flex; 
 | 
        flex-direction: column; 
 | 
        .content_list_item { 
 | 
            background: white; 
 | 
            padding: 30px; 
 | 
            display: flex; 
 | 
            flex-direction: column; 
 | 
            border-bottom: 1px solid #ececec; 
 | 
            .content_list_item_top { 
 | 
                display: flex; 
 | 
                align-items: center; 
 | 
                justify-content: space-between; 
 | 
                .content_list_item_top_left { 
 | 
                    display: flex; 
 | 
                    align-items: center; 
 | 
                    width: 80%; 
 | 
                    span { 
 | 
                        font-size: 32px; 
 | 
                        font-weight: 500; 
 | 
                        color: #333333; 
 | 
                        overflow: hidden; 
 | 
                        text-overflow: ellipsis; 
 | 
                        white-space: nowrap; 
 | 
                    } 
 | 
                    .warning { 
 | 
                        background: $nav-stateColor5 !important; 
 | 
                    } 
 | 
                    .content_list_item_top_left_tag { 
 | 
                        flex-shrink: 0; 
 | 
                        padding: 5px 10px; 
 | 
                        background: $nav-stateColor4; 
 | 
                        border-radius: 8px; 
 | 
                        font-size: 22px; 
 | 
                        font-weight: 400; 
 | 
                        color: #FFFFFF; 
 | 
                        margin-left: 16px; 
 | 
                        display: flex; 
 | 
                        align-items: center; 
 | 
                        justify-content: center; 
 | 
                    } 
 | 
                } 
 | 
                .content_list_item_top_right { 
 | 
                    font-size: 26px; 
 | 
                    font-weight: 400; 
 | 
                    flex-shrink: 0; 
 | 
                    margin-left: 10px; 
 | 
                    .warning { 
 | 
                        color: $nav-stateColor5 !important; 
 | 
                    } 
 | 
                    .green { 
 | 
                        color: $nav-stateColor6 !important; 
 | 
                    } 
 | 
                    .info { 
 | 
                        color: $nav-stateColor3 !important; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            .content_list_item_content { 
 | 
                padding: 24px 30px; 
 | 
                background: #F7F7F7; 
 | 
                border-radius: 16px; 
 | 
                display: flex; 
 | 
                flex-wrap: wrap; 
 | 
                justify-content: space-between; 
 | 
                margin-top: 32px; 
 | 
                .content_list_item_content_item { 
 | 
                    width: 50%; 
 | 
                    display: flex; 
 | 
                    margin-top: 24px; 
 | 
                    &:nth-child(1) { 
 | 
                        margin-top: 0 !important; 
 | 
                    } 
 | 
                    &:nth-child(2) { 
 | 
                        margin-top: 0 !important; 
 | 
                    } 
 | 
                    .content_list_item_content_item_label { 
 | 
                        font-size: 24px; 
 | 
                        font-weight: 400; 
 | 
                        color: #666666; 
 | 
                        flex-shrink: 0; 
 | 
                    } 
 | 
                    .content_list_item_content_item_nr { 
 | 
                        font-size: 24px; 
 | 
                        font-weight: 400; 
 | 
                        color: #222222; 
 | 
                        margin-right: 10px; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
} 
 | 
</style> 
 |