恢复修改的数据
This commit is contained in:
@@ -69,7 +69,7 @@ const isProcessing = computed(() => props.afterSales?.status === '处理中')
|
||||
|
||||
<style lang="less" scoped>
|
||||
.project-after-sales {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-base;
|
||||
padding: @spacing-lg @spacing-xl;
|
||||
border-radius: @radius-lg;
|
||||
@@ -77,7 +77,7 @@ const isProcessing = computed(() => props.afterSales?.status === '处理中')
|
||||
box-shadow: @shadow-base;
|
||||
|
||||
&__card {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-sm;
|
||||
padding: @spacing-base;
|
||||
border: 1px solid @border-color;
|
||||
|
||||
@@ -64,7 +64,7 @@ const emit = defineEmits<{
|
||||
|
||||
<style lang="less" scoped>
|
||||
.project-files {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-base;
|
||||
padding: @spacing-lg @spacing-xl;
|
||||
border-radius: @radius-lg;
|
||||
@@ -78,7 +78,7 @@ const emit = defineEmits<{
|
||||
}
|
||||
|
||||
&__list {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-sm;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ const emit = defineEmits<{
|
||||
}
|
||||
|
||||
&__info {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { FilterPanel, type FilterChip } from '@/components'
|
||||
import { formatBusinessType } from '@/utils/format'
|
||||
import type { BusinessType } from '@/types/api'
|
||||
import type { ProjectQuery, ProjectStatus } from '@/types/business/project'
|
||||
import { computed, ref } from 'vue'
|
||||
import { PROJECT_STATUS_LABEL, PROJECT_STATUS_OPTIONS, PROJECT_TIME_OPTIONS } from '@/utils/projectMeta'
|
||||
import type { ProjectQuery, ProjectTypeCount } from '@/types/business/project'
|
||||
|
||||
/**
|
||||
* 项目中心左侧筛选栏(按项目中心设计稿还原)。
|
||||
*
|
||||
* <p>⚠️ 业务类型的**值域、文案、件数全部来自 store**(`typeCounts` ← `GET /web/requirementPool/getFilterConditions`
|
||||
* 的 `businessTypeCounts`,全量口径),组件内不定义业务值域;
|
||||
* 只有后端未下发的组(项目状态 / 提交时间)才用 `utils/projectMeta.ts` 里的前端常量。</p>
|
||||
*
|
||||
* <p>「不限」统一用**空串**表示(不是 'all'):空串不会出现在 querystring 里,
|
||||
* 正好对上后端 `eqIfText` 的「有值才等值匹配」。</p>
|
||||
*/
|
||||
|
||||
interface Props {
|
||||
query: ProjectQuery
|
||||
/** 当前筛选命中的项目数(确定筛选按钮上的「N个结果」) */
|
||||
total: number
|
||||
typeCounts: ProjectTypeCount[]
|
||||
}
|
||||
|
||||
interface Chip {
|
||||
key: string
|
||||
label: string
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
@@ -18,48 +34,31 @@ const emit = defineEmits<{
|
||||
reset: []
|
||||
}>()
|
||||
|
||||
const businessTypeOptions: Array<{ label: string; value: BusinessType | 'all' }> = [
|
||||
{ label: '全部', value: 'all' },
|
||||
{ label: '互联网软件', value: 'internet' },
|
||||
{ label: '硬件电路', value: 'hardware' },
|
||||
{ label: '物联网全案', value: 'iot' },
|
||||
{ label: '生产制造', value: 'manufacturing' },
|
||||
]
|
||||
/** 自选时间区间是否展开(设计稿只给了按钮态,展开后是两个原生日期输入) */
|
||||
const rangeOpen = ref(false)
|
||||
|
||||
const statusOptions: Array<{ label: string; value: ProjectStatus | 'all' }> = [
|
||||
{ label: '全部', value: 'all' },
|
||||
{ label: '待立项', value: '待立项' },
|
||||
{ label: '进行中', value: '进行中' },
|
||||
{ label: '待验收', value: '待验收' },
|
||||
{ label: '已完成', value: '已完成' },
|
||||
{ label: '售后中', value: '售后中' },
|
||||
{ label: '已取消', value: '已取消' },
|
||||
]
|
||||
|
||||
const timeShortcuts: Array<{ label: string; value: ProjectQuery['timeShortcut'] }> = [
|
||||
{ label: '全部', value: 'all' },
|
||||
{ label: '近3个月', value: '3m' },
|
||||
{ label: '近半年', value: '6m' },
|
||||
{ label: '近一年', value: '1y' },
|
||||
]
|
||||
|
||||
const keyword = computed({
|
||||
get: () => props.query.keyword,
|
||||
set: (value: string) => emit('update:query', { ...props.query, keyword: value }),
|
||||
const rangeLabel = computed(() => {
|
||||
const { startDate, endDate } = props.query
|
||||
if (!startDate && !endDate) return '开始时间—结束时间'
|
||||
return `${startDate || '不限'} — ${endDate || '不限'}`
|
||||
})
|
||||
|
||||
const chips = computed<FilterChip[]>(() => {
|
||||
const list: FilterChip[] = []
|
||||
if (props.query.businessType !== 'all') {
|
||||
list.push({ key: 'businessType', label: formatBusinessType(props.query.businessType) })
|
||||
const chips = computed<Chip[]>(() => {
|
||||
const list: Chip[] = []
|
||||
if (props.query.businessType) {
|
||||
const found = props.typeCounts.find((item) => item.value === props.query.businessType)
|
||||
list.push({ key: 'businessType', label: found?.label ?? props.query.businessType })
|
||||
}
|
||||
if (props.query.status !== 'all') {
|
||||
list.push({ key: 'status', label: props.query.status })
|
||||
if (props.query.status) {
|
||||
list.push({ key: 'status', label: PROJECT_STATUS_LABEL[props.query.status] ?? props.query.status })
|
||||
}
|
||||
if (props.query.timeShortcut !== 'all') {
|
||||
const label = timeShortcuts.find((item) => item.value === props.query.timeShortcut)?.label ?? ''
|
||||
const label = PROJECT_TIME_OPTIONS.find((item) => item.value === props.query.timeShortcut)?.label ?? ''
|
||||
list.push({ key: 'time', label })
|
||||
}
|
||||
if (props.query.startDate || props.query.endDate) {
|
||||
list.push({ key: 'range', label: `${props.query.startDate || '不限'}~${props.query.endDate || '不限'}` })
|
||||
}
|
||||
return list
|
||||
})
|
||||
|
||||
@@ -67,125 +66,386 @@ function patch(partial: Partial<ProjectQuery>): void {
|
||||
emit('update:query', { ...props.query, ...partial })
|
||||
}
|
||||
|
||||
/** 快捷区间与自选区间互斥:点快捷区间会清掉自选日期 */
|
||||
function onPickShortcut(value: ProjectQuery['timeShortcut']): void {
|
||||
rangeOpen.value = false
|
||||
patch({ timeShortcut: value, startDate: '', endDate: '' })
|
||||
}
|
||||
|
||||
/** 选了自选日期就把快捷区间复位(避免两组条件同时生效) */
|
||||
function onPickDate(partial: { startDate?: string; endDate?: string }): void {
|
||||
patch({ timeShortcut: 'all', ...partial })
|
||||
}
|
||||
|
||||
function onRemoveChip(key: string): void {
|
||||
if (key === 'businessType') patch({ businessType: 'all' })
|
||||
else if (key === 'status') patch({ status: 'all' })
|
||||
if (key === 'businessType') patch({ businessType: '' })
|
||||
else if (key === 'status') patch({ status: '' })
|
||||
else if (key === 'time') patch({ timeShortcut: 'all' })
|
||||
else if (key === 'range') patch({ startDate: '', endDate: '' })
|
||||
}
|
||||
|
||||
function onClearChips(): void {
|
||||
emit('update:query', {
|
||||
...props.query,
|
||||
businessType: 'all',
|
||||
status: 'all',
|
||||
businessType: '',
|
||||
status: '',
|
||||
timeShortcut: 'all',
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FilterPanel
|
||||
v-model:keyword="keyword"
|
||||
:chips="chips"
|
||||
:show-result-count="true"
|
||||
:result-count="total"
|
||||
search-label="确定筛选"
|
||||
@search="emit('search')"
|
||||
@reset="emit('reset')"
|
||||
@remove-chip="onRemoveChip"
|
||||
@clear-chips="onClearChips"
|
||||
>
|
||||
<!-- 业务类型(单选) -->
|
||||
<div class="project-filter__group">
|
||||
<span class="project-filter__group-title">业务类型</span>
|
||||
<div class="project-filter__options">
|
||||
<button
|
||||
v-for="option in businessTypeOptions"
|
||||
:key="option.value"
|
||||
class="project-filter__option"
|
||||
:class="{ 'is-active': query.businessType === option.value }"
|
||||
@click="patch({ businessType: option.value })"
|
||||
>
|
||||
{{ option.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<aside class="project-filter">
|
||||
<h2 class="project-filter__title">
|
||||
筛选条件
|
||||
</h2>
|
||||
|
||||
<!-- 项目状态(单选) -->
|
||||
<div class="project-filter__group">
|
||||
<span class="project-filter__group-title">项目状态</span>
|
||||
<div class="project-filter__options">
|
||||
<!-- 业务类型:复选外观的单选列表(值域 / 件数均来自后端统计) -->
|
||||
<section class="project-filter__group">
|
||||
<h3 class="project-filter__group-title">
|
||||
业务类型
|
||||
</h3>
|
||||
<ul class="project-filter__list">
|
||||
<li v-for="item in typeCounts" :key="item.value">
|
||||
<button
|
||||
type="button"
|
||||
class="project-filter__row"
|
||||
:class="{ 'is-active': query.businessType === item.value }"
|
||||
@click="patch({ businessType: item.value === 'all' ? '' : item.value })"
|
||||
>
|
||||
<span class="project-filter__box" aria-hidden="true" />
|
||||
<span class="project-filter__row-label">{{ item.label }}</span>
|
||||
<span class="project-filter__row-count">{{ item.count }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- 项目状态:2 列胶囊网格 -->
|
||||
<section class="project-filter__group">
|
||||
<h3 class="project-filter__group-title">
|
||||
项目状态
|
||||
</h3>
|
||||
<div class="project-filter__grid">
|
||||
<button
|
||||
v-for="option in statusOptions"
|
||||
v-for="option in PROJECT_STATUS_OPTIONS"
|
||||
:key="option.value"
|
||||
class="project-filter__option"
|
||||
type="button"
|
||||
class="project-filter__pill"
|
||||
:class="{ 'is-active': query.status === option.value }"
|
||||
@click="patch({ status: option.value })"
|
||||
>
|
||||
{{ option.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 提交时间(快捷区间) -->
|
||||
<div class="project-filter__group">
|
||||
<span class="project-filter__group-title">提交时间</span>
|
||||
<div class="project-filter__options">
|
||||
<!-- 提交时间:快捷区间 + 自选区间 -->
|
||||
<section class="project-filter__group">
|
||||
<h3 class="project-filter__group-title">
|
||||
提交时间
|
||||
</h3>
|
||||
<div class="project-filter__grid">
|
||||
<button
|
||||
v-for="shortcut in timeShortcuts"
|
||||
:key="shortcut.value"
|
||||
class="project-filter__option"
|
||||
:class="{ 'is-active': query.timeShortcut === shortcut.value }"
|
||||
@click="patch({ timeShortcut: shortcut.value })"
|
||||
v-for="option in PROJECT_TIME_OPTIONS"
|
||||
:key="option.value"
|
||||
type="button"
|
||||
class="project-filter__pill"
|
||||
:class="{ 'is-active': query.timeShortcut === option.value && !query.startDate && !query.endDate }"
|
||||
@click="onPickShortcut(option.value)"
|
||||
>
|
||||
{{ shortcut.label }}
|
||||
{{ option.label }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="project-filter__pill project-filter__pill--wide"
|
||||
:class="{ 'is-active': rangeOpen || Boolean(query.startDate || query.endDate) }"
|
||||
@click="rangeOpen = !rangeOpen"
|
||||
>
|
||||
{{ rangeLabel }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="rangeOpen" class="project-filter__range">
|
||||
<input
|
||||
class="project-filter__date"
|
||||
type="date"
|
||||
:value="query.startDate"
|
||||
aria-label="开始时间"
|
||||
@change="onPickDate({ startDate: ($event.target as HTMLInputElement).value })"
|
||||
>
|
||||
<span class="project-filter__range-sep">—</span>
|
||||
<input
|
||||
class="project-filter__date"
|
||||
type="date"
|
||||
:value="query.endDate"
|
||||
aria-label="结束时间"
|
||||
@change="onPickDate({ endDate: ($event.target as HTMLInputElement).value })"
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 已选条件 -->
|
||||
<section class="project-filter__chips">
|
||||
<div class="project-filter__chips-head">
|
||||
<span class="project-filter__chips-title">已选条件({{ chips.length }}个)</span>
|
||||
<button
|
||||
type="button"
|
||||
class="project-filter__chips-clear"
|
||||
@click="onClearChips"
|
||||
>
|
||||
清空
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="chips.length > 0" class="project-filter__chips-list">
|
||||
<button
|
||||
v-for="chip in chips"
|
||||
:key="chip.key"
|
||||
type="button"
|
||||
class="project-filter__chip"
|
||||
@click="onRemoveChip(chip.key)"
|
||||
>
|
||||
{{ chip.label }}
|
||||
<span class="project-filter__chip-x" aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 底部操作 -->
|
||||
<div class="project-filter__actions">
|
||||
<button
|
||||
type="button"
|
||||
class="project-filter__reset"
|
||||
@click="emit('reset')"
|
||||
>
|
||||
重置
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="project-filter__submit"
|
||||
@click="emit('search')"
|
||||
>
|
||||
确定筛选({{ total }}个结果)
|
||||
</button>
|
||||
</div>
|
||||
</FilterPanel>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.project-filter {
|
||||
// 左栏固定宽(设计稿实测 313 / 卡片间距 17 / 容器 1353)
|
||||
flex: 0 0 313px;
|
||||
padding: 20px 28px 24px;
|
||||
border-radius: @radius-base;
|
||||
background: @white;
|
||||
|
||||
&__title {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
color: @heading-color;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
&__group {
|
||||
.flex(row, flex-start);
|
||||
gap: @spacing-base;
|
||||
margin-top: 18px;
|
||||
|
||||
&:first-of-type {
|
||||
margin-top: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
&__group-title {
|
||||
flex-shrink: 0;
|
||||
width: 70px;
|
||||
padding-top: 5px;
|
||||
font-size: @font-size-base;
|
||||
margin-bottom: 12px;
|
||||
font-size: @font-size-lg;
|
||||
font-weight: 600;
|
||||
color: @heading-color;
|
||||
}
|
||||
|
||||
&__options {
|
||||
.flex(row, flex-start, center);
|
||||
flex-wrap: wrap;
|
||||
gap: @spacing-sm;
|
||||
// ── 业务类型列表 ──
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
&__option {
|
||||
height: 28px;
|
||||
padding: 0 @spacing-sm;
|
||||
border: 1px solid transparent;
|
||||
&__row {
|
||||
.flex(row, flex-start, center);
|
||||
width: 100%;
|
||||
height: 31px;
|
||||
padding: 0 6px;
|
||||
border-radius: @radius-sm;
|
||||
background: @bg-color;
|
||||
font-size: @font-size-base;
|
||||
color: @heading-color;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: @bg-color;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: @filter-selected-bg;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
&__box {
|
||||
flex-shrink: 0;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin-right: 10px;
|
||||
border: 1px solid @border-color-dark;
|
||||
border-radius: 2px;
|
||||
background: @white;
|
||||
}
|
||||
|
||||
&__row-label {
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
.ellipsis();
|
||||
}
|
||||
|
||||
&__row-count {
|
||||
flex-shrink: 0;
|
||||
margin-left: @spacing-sm;
|
||||
font-size: @font-size-base;
|
||||
color: @text-color;
|
||||
font-size: @font-size-sm;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
// ── 胶囊网格(项目状态 / 提交时间)──
|
||||
&__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 9px;
|
||||
}
|
||||
|
||||
&__pill {
|
||||
height: 27px;
|
||||
padding: 0 @spacing-sm;
|
||||
border-radius: @radius-round;
|
||||
background: @pill-bg;
|
||||
color: @text-color;
|
||||
font-size: @font-size-base;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
border-color: @primary-color;
|
||||
background: @primary-color;
|
||||
color: @white;
|
||||
}
|
||||
|
||||
&--wide {
|
||||
grid-column: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
// ── 自选日期区间(点开后才出现)──
|
||||
&__range {
|
||||
.flex(row, space-between, center);
|
||||
margin-top: 9px;
|
||||
gap: @spacing-xs;
|
||||
}
|
||||
|
||||
&__date {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 27px;
|
||||
padding: 0 @spacing-xs;
|
||||
border: 1px solid @border-color;
|
||||
border-radius: @radius-sm;
|
||||
background: @white;
|
||||
color: @text-color;
|
||||
font-size: @font-size-sm;
|
||||
}
|
||||
|
||||
&__range-sep {
|
||||
color: @text-color-secondary;
|
||||
}
|
||||
|
||||
// ── 已选条件 ──
|
||||
&__chips {
|
||||
margin-top: 18px;
|
||||
padding: 12px;
|
||||
border-radius: @radius-base;
|
||||
background: @chips-panel-bg;
|
||||
}
|
||||
|
||||
&__chips-head {
|
||||
.flex(row, space-between, center);
|
||||
}
|
||||
|
||||
&__chips-title {
|
||||
font-size: @font-size-sm;
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
&__chips-clear {
|
||||
font-size: @font-size-sm;
|
||||
color: @primary-color;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.75;
|
||||
}
|
||||
}
|
||||
|
||||
&__chips-list {
|
||||
.flex(row, flex-start, center);
|
||||
flex-wrap: wrap;
|
||||
margin-top: 8px;
|
||||
gap: @spacing-sm;
|
||||
}
|
||||
|
||||
&__chip {
|
||||
.flex(row, center, center);
|
||||
height: 22px;
|
||||
padding: 0 10px;
|
||||
border-radius: @radius-round;
|
||||
background: @white;
|
||||
color: @primary-color;
|
||||
font-size: @font-size-sm;
|
||||
|
||||
&:hover {
|
||||
background: @primary-light;
|
||||
}
|
||||
}
|
||||
|
||||
&__chip-x {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
// ── 底部操作 ──
|
||||
&__actions {
|
||||
.flex(row, space-between, center);
|
||||
margin-top: 16px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
&__reset {
|
||||
flex: 0 0 32%;
|
||||
height: 26px;
|
||||
border-radius: @radius-round;
|
||||
background: @pill-bg;
|
||||
color: @text-color;
|
||||
font-size: @font-size-base;
|
||||
|
||||
&:hover {
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
&__submit {
|
||||
flex: 1;
|
||||
height: 26px;
|
||||
border-radius: @radius-round;
|
||||
background: @primary-color;
|
||||
color: @white;
|
||||
font-size: @font-size-base;
|
||||
|
||||
&:hover {
|
||||
background: @primary-hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -130,7 +130,7 @@ const BILL_VARIANTS: Record<ProjectBill['status'], 'primary' | 'success' | 'warn
|
||||
|
||||
<style lang="less" scoped>
|
||||
.project-finance {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-base;
|
||||
padding: @spacing-lg @spacing-xl;
|
||||
border-radius: @radius-lg;
|
||||
@@ -150,7 +150,7 @@ const BILL_VARIANTS: Record<ProjectBill['status'], 'primary' | 'success' | 'warn
|
||||
}
|
||||
|
||||
&__plan {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-sm;
|
||||
width: 320px;
|
||||
padding: @spacing-base;
|
||||
@@ -171,7 +171,7 @@ const BILL_VARIANTS: Record<ProjectBill['status'], 'primary' | 'success' | 'warn
|
||||
}
|
||||
|
||||
&__plan-meta {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-xs;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ const BILL_VARIANTS: Record<ProjectBill['status'], 'primary' | 'success' | 'warn
|
||||
}
|
||||
|
||||
&__files {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-sm;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ const BILL_VARIANTS: Record<ProjectBill['status'], 'primary' | 'success' | 'warn
|
||||
}
|
||||
|
||||
&__file-info {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ const STATUS_VARIANTS: Record<ProjectStatus, 'primary' | 'success' | 'warning' |
|
||||
'待立项': 'info',
|
||||
'进行中': 'primary',
|
||||
'待验收': 'warning',
|
||||
'待内部验收': 'warning',
|
||||
'已完成': 'success',
|
||||
'售后中': 'warning',
|
||||
'已取消': 'info',
|
||||
@@ -70,7 +71,7 @@ const STATUS_VARIANTS: Record<ProjectStatus, 'primary' | 'success' | 'warning' |
|
||||
}
|
||||
|
||||
&__meta-item {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: @spacing-xs;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ defineProps<Props>()
|
||||
}
|
||||
|
||||
&__body {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { StatusTag } from '@/components'
|
||||
import { formatBusinessType } from '@/utils/format'
|
||||
import type { Project, ProjectStatus } from '@/types/business/project'
|
||||
import { computed } from 'vue'
|
||||
import { PROJECT_STATUS_LABEL } from '@/utils/projectMeta'
|
||||
import type { ProjectTypeCount, RdProjectVo } from '@/types/business/project'
|
||||
|
||||
/**
|
||||
* 项目中心列表(按设计稿还原 + 后端 RdProjectVo 契约)。
|
||||
*
|
||||
* <p>设计稿要点:表头浅灰底 + 加粗居中、整表 #bbbbbb 网格线、行高约 76、
|
||||
* 进度列**只给百分比文字**(不画进度条)、状态列是纯文字(不是彩色标签)、
|
||||
* 最后一列是操作(「详情」,已完成的额外给「申请售后」)。</p>
|
||||
*
|
||||
* <p>三处「后端没有 / 前端不能编」的兜底:<br>
|
||||
* 1. 业务类型列:SQL 里 `businessType` 已 JOIN 提报表**翻译成中文类型名**(如「互联网软件」),
|
||||
* 直接渲染即可;`typeLabels`(提报 id → 名称)当前命不中,只作为后端改回下发 id 时的兜底。<br>
|
||||
* 2. 进度列:`progress` 取项目表(未立项必为 null)⇒ 显示「—」,不假装成 0%。<br>
|
||||
* 3. 状态列:取 `COALESCE(项目状态, 需求状态)`,未立项回落 `INITIATING`(待立项)。</p>
|
||||
*/
|
||||
|
||||
interface Props {
|
||||
projects: Project[]
|
||||
projects: RdProjectVo[]
|
||||
/** 业务类型件数列表(含「全部」);用它建 id → 中文 的映射 */
|
||||
typeCounts: ProjectTypeCount[]
|
||||
/** 是否处于筛选态(决定空态文案:没筛过 = 本来就没项目,筛过 = 没有符合条件的) */
|
||||
filtered: boolean
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
view: [id: string]
|
||||
afterSales: [id: string]
|
||||
}>()
|
||||
|
||||
const STATUS_VARIANTS: Record<ProjectStatus, 'primary' | 'success' | 'warning' | 'danger' | 'info'> = {
|
||||
'待立项': 'info',
|
||||
'进行中': 'primary',
|
||||
'待验收': 'warning',
|
||||
'已完成': 'success',
|
||||
'售后中': 'warning',
|
||||
'已取消': 'info',
|
||||
/** businessTypeId → 业务类型中文 */
|
||||
const typeLabels = computed<Record<string, string>>(() => {
|
||||
const map: Record<string, string> = {}
|
||||
for (const item of props.typeCounts) {
|
||||
if (item.value !== 'all') map[item.value] = item.label
|
||||
}
|
||||
return map
|
||||
})
|
||||
|
||||
function typeLabel(value: string | null | undefined): string {
|
||||
if (!value) return '—'
|
||||
return typeLabels.value[value] ?? value
|
||||
}
|
||||
|
||||
function statusLabel(value: string | null | undefined): string {
|
||||
if (!value) return '—'
|
||||
return PROJECT_STATUS_LABEL[value] ?? value
|
||||
}
|
||||
|
||||
function progressLabel(value: number | null | undefined): string {
|
||||
return value == null ? '—' : `${value}%`
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -35,7 +67,7 @@ const STATUS_VARIANTS: Record<ProjectStatus, 'primary' | 'success' | 'warning' |
|
||||
<th>业务类型</th>
|
||||
<th>进度</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -45,37 +77,30 @@ const STATUS_VARIANTS: Record<ProjectStatus, 'primary' | 'success' | 'warning' |
|
||||
<td class="project-table__name" :title="item.projectName">
|
||||
{{ item.projectName }}
|
||||
</td>
|
||||
<td>{{ formatBusinessType(item.businessType) }}</td>
|
||||
<td>
|
||||
<div class="project-table__progress">
|
||||
<div class="project-table__track">
|
||||
<div
|
||||
class="project-table__bar"
|
||||
:style="{ width: `${item.progress}%` }"
|
||||
/>
|
||||
</div>
|
||||
<span class="project-table__percent">{{ item.progress }}%</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<StatusTag :label="item.status" :variant="STATUS_VARIANTS[item.status]" />
|
||||
</td>
|
||||
<td class="project-table__actions">
|
||||
<button class="project-table__btn" @click="emit('view', item.id)">
|
||||
详情
|
||||
</button>
|
||||
<td>{{ typeLabel(item.businessType) }}</td>
|
||||
<td>{{ progressLabel(item.progress) }}</td>
|
||||
<td>{{ statusLabel(item.status) }}</td>
|
||||
<td class="project-table__ops">
|
||||
<button
|
||||
v-if="item.status === '已完成'"
|
||||
class="project-table__btn project-table__btn--accent"
|
||||
v-if="item.status === 'COMPLETED'"
|
||||
type="button"
|
||||
class="project-table__link"
|
||||
@click="emit('afterSales', item.id)"
|
||||
>
|
||||
申请售后
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="project-table__link"
|
||||
@click="emit('view', item.id)"
|
||||
>
|
||||
详情
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="projects.length === 0">
|
||||
<td colspan="7" class="project-table__empty text-secondary">
|
||||
暂无符合条件的项目
|
||||
<td colspan="7" class="project-table__empty">
|
||||
{{ filtered ? '暂无符合条件的项目' : '暂无项目' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -86,98 +111,71 @@ const STATUS_VARIANTS: Record<ProjectStatus, 'primary' | 'success' | 'warning' |
|
||||
<style lang="less" scoped>
|
||||
.project-table {
|
||||
overflow-x: auto;
|
||||
border-radius: @radius-lg;
|
||||
background: @white;
|
||||
box-shadow: @shadow-base;
|
||||
.scrollbar();
|
||||
|
||||
&__grid {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
font-size: @font-size-base;
|
||||
|
||||
th,
|
||||
td {
|
||||
padding: @spacing-base @spacing-base;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid @border-color;
|
||||
white-space: nowrap;
|
||||
border: 1px solid @project-table-line;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
// 设计稿表格正文实测 12px(比左栏正文小一号),沿用 14px 会把操作列挤到换行
|
||||
font-size: @font-size-sm;
|
||||
}
|
||||
|
||||
th {
|
||||
background: @bg-color-light;
|
||||
height: 44px;
|
||||
background: @project-table-head-bg;
|
||||
color: @heading-color;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
td {
|
||||
color: @text-color;
|
||||
height: 76px;
|
||||
color: @heading-color;
|
||||
}
|
||||
|
||||
tbody tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
tbody tr:hover td {
|
||||
background: @bg-color-light;
|
||||
}
|
||||
// 列宽按设计稿实测比例(1002 总宽 → 61/294/218/107/144/90/88)
|
||||
th:nth-child(1) { width: 6.09%; }
|
||||
th:nth-child(2) { width: 29.34%; }
|
||||
th:nth-child(3) { width: 21.76%; }
|
||||
th:nth-child(4) { width: 10.68%; }
|
||||
th:nth-child(5) { width: 14.37%; }
|
||||
th:nth-child(6) { width: 8.98%; }
|
||||
th:nth-child(7) { width: 8.78%; }
|
||||
}
|
||||
|
||||
&__name {
|
||||
max-width: 220px;
|
||||
color: @heading-color;
|
||||
padding: 0 @spacing-sm;
|
||||
.ellipsis();
|
||||
}
|
||||
|
||||
&__progress {
|
||||
.flex(row, center);
|
||||
gap: @spacing-sm;
|
||||
min-width: 140px;
|
||||
&__ops {
|
||||
.flex(row, center, center);
|
||||
gap: 10px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__track {
|
||||
flex: 1;
|
||||
height: 6px;
|
||||
border-radius: @radius-round;
|
||||
background: @bg-color;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&__bar {
|
||||
height: 100%;
|
||||
border-radius: @radius-round;
|
||||
background: @primary-color;
|
||||
transition: width 0.3s;
|
||||
}
|
||||
|
||||
&__percent {
|
||||
flex-shrink: 0;
|
||||
font-size: @font-size-sm;
|
||||
color: @text-color-secondary;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
.flex(row, center);
|
||||
gap: @spacing-sm;
|
||||
}
|
||||
|
||||
&__btn {
|
||||
font-size: @font-size-base;
|
||||
&__link {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
color: @primary-color;
|
||||
font-size: @font-size-sm;
|
||||
white-space: nowrap;
|
||||
transition: opacity 0.2s;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
&--accent {
|
||||
color: @warning-color;
|
||||
}
|
||||
}
|
||||
|
||||
&__empty {
|
||||
padding: @spacing-xl 0;
|
||||
text-align: center;
|
||||
color: @text-color-secondary;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -73,7 +73,7 @@ defineProps<Props>()
|
||||
}
|
||||
|
||||
&__info {
|
||||
.flex(column, flex-start);
|
||||
.flex(column, flex-start, stretch);
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user