<template>
    <global-page
        ref="paging"
        :api="getQaDataList2Api"
        :padding="24"
        :params="searchData"
        auto
        isDataList
        loadingMoreEnabled
        navRightIcon="saixuan-01"
        navRightType="icon"
        refresherEnabled
        showNavRight
        title="品质分析"
        @handleRightClick="handleRightClick"
    >
        <template #default="{ item }">
            <view class="item" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="left">
                        <custom-state :value="useGetDictByValue('os_isOpen', item.isOpen)"></custom-state>
                    </view>
                    <view class="right">
                        <text class="txt u-line-1" v-if="item.ac">{{ item.ac }}</text>
                        <text class="txt u-line-1" v-if="item.acType">{{ item.acType }}</text>
                        <text class="txt u-line-1" v-if="item.acOwn">{{ item.acOwn }}</text>
                        <text class="txt u-line-1" v-if="item.acTerminal">{{ item.acTerminal }}</text>
                    </view>
                </view>
                <view class="item-content">
                    <view style="margin-bottom: 20rpx">事件编号 : {{ item.id }}</view>
                    <view class="u-line-3">{{ item.eventMsg || '无' }}</view>
                </view>
                <view class="item-footer">
                    <view class="label">
                        <global-icon icon="calendar"></global-icon>
                        <text class="txt">
                            {{ timeStampFormat(item.openTimeF) }}
                        </text>
                    </view>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import { onLoad, onUnload } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { timeStampFormat } from 'mocp/utils/tool'
import { getQaDataList2Api } from 'mocp/api/qualityAnalysis'
import useQualityAnalysisStore from 'mocp/store/qualityAnalysis'

//跳转
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/qualityAnalysis/details', {
        workbenchId: data.workbenchId
    })
}
//加载下拉框数据
const qualityAnalysisStore = useQualityAnalysisStore()
const { searchData } = storeToRefs(qualityAnalysisStore)
onLoad(() => {
    qualityAnalysisStore.getQaDimensionTree2()
})
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateTo('/panel/qualityAnalysis/search')
}
const paging = ref()
uni.$on('qualityAnalysisReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('qualityAnalysisReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
