108 lines
3.2 KiB
Vue
108 lines
3.2 KiB
Vue
<script setup>
|
|
import { ref, computed } from 'vue'
|
|
import { onShow } from '@dcloudio/uni-app'
|
|
import { listPlans } from '@/api/pl'
|
|
import { archiveStatusLabel, planCardSub, dash, planTypeLabel } from '@/utils/plLabels'
|
|
import { PAGE_PATHS } from '@/config/api'
|
|
|
|
const keyword = ref('')
|
|
const rows = ref([])
|
|
const total = ref(0)
|
|
const loading = ref(false)
|
|
const page = ref(1)
|
|
const finished = ref(false)
|
|
|
|
const list = computed(() => {
|
|
const kw = String(keyword.value || '')
|
|
.trim()
|
|
.toLowerCase()
|
|
if (!kw) return rows.value
|
|
return rows.value.filter((row) => {
|
|
const blob = [row.planNo, row.customerName, planCardSub(row)].join(' ').toLowerCase()
|
|
return blob.includes(kw)
|
|
})
|
|
})
|
|
|
|
const goBack = () => {
|
|
uni.navigateBack({
|
|
fail: () => uni.switchTab({ url: PAGE_PATHS.workbench })
|
|
})
|
|
}
|
|
|
|
const goDetail = (row) =>
|
|
uni.navigateTo({ url: `${PAGE_PATHS.plPlanDetail}?id=${row.id}&readonly=1` })
|
|
|
|
const load = async (reset = true) => {
|
|
if (loading.value) return
|
|
if (reset) {
|
|
page.value = 1
|
|
finished.value = false
|
|
rows.value = []
|
|
}
|
|
if (finished.value) return
|
|
loading.value = true
|
|
try {
|
|
const res = await listPlans({
|
|
archiveStatus: 'archived',
|
|
q: keyword.value.trim() || undefined,
|
|
page: page.value,
|
|
pageSize: 20
|
|
})
|
|
const next = res.rows || []
|
|
rows.value = reset ? next : rows.value.concat(next)
|
|
total.value = res.total || 0
|
|
if (!next.length || rows.value.length >= total.value) finished.value = true
|
|
else page.value += 1
|
|
} catch (e) {
|
|
uni.showToast({ title: e.message || '加载失败', icon: 'none' })
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
onShow(() => load(true))
|
|
</script>
|
|
|
|
<template>
|
|
<view class="mp-page mp-page--sub">
|
|
<view class="mp-header mp-header--pl">
|
|
<text class="mp-subpage-back" @click="goBack">← 工作台</text>
|
|
<text class="mp-header__title" style="margin-top: 16rpx">计划归档</text>
|
|
<view class="mp-header__search">
|
|
<view class="mp-header__search-dot" />
|
|
<input
|
|
v-model="keyword"
|
|
class="mp-header__search-input"
|
|
placeholder="计划号 / 客户"
|
|
confirm-type="search"
|
|
@confirm="load(true)"
|
|
/>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="mp-section">
|
|
<mp-empty v-if="!list.length && !loading" title="暂无已归档计划" />
|
|
<view v-else class="mp-list">
|
|
<view v-for="row in list" :key="row.id" class="mp-card" @click="goDetail(row)">
|
|
<view class="mp-card__head">
|
|
<view>
|
|
<text class="mp-card__title">{{ dash(row.planNo) }}</text>
|
|
<text class="mp-card__sub">{{ planCardSub(row) }}</text>
|
|
</view>
|
|
<text class="mp-tag" :class="'mp-tag--' + archiveStatusLabel(row.archiveStatus).tag">
|
|
{{ archiveStatusLabel(row.archiveStatus).text }}
|
|
</text>
|
|
</view>
|
|
<view class="mp-card__row">
|
|
<text>{{ planTypeLabel(row.planType) }}</text>
|
|
<text>{{ dash(row.planDate) }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-if="!finished && list.length" class="mp-load-more" @click="load(false)">
|
|
{{ loading ? '加载中…' : '加载更多' }}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|