From d8ede65a245e35f3c2bc50bb79152a38684828e0 Mon Sep 17 00:00:00 2001 From: bestlee Date: Fri, 13 Nov 2026 16:08:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4=E6=9F=A5=E7=9C=8B=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=AD=9B=E9=80=89=E4=B8=8E=E6=8E=92=E5=BA=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 5 +- src/api/change.ts | 2 +- src/views/Changes.vue | 349 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 305 insertions(+), 51 deletions(-) diff --git a/components.d.ts b/components.d.ts index 5a5feef..34b026d 100644 --- a/components.d.ts +++ b/components.d.ts @@ -16,21 +16,18 @@ declare module 'vue' { RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] VanButton: typeof import('vant/es')['Button'] - VanCell: typeof import('vant/es')['Cell'] + VanCalendar: typeof import('vant/es')['Calendar'] VanCellGroup: typeof import('vant/es')['CellGroup'] VanEmpty: typeof import('vant/es')['Empty'] VanField: typeof import('vant/es')['Field'] VanForm: typeof import('vant/es')['Form'] VanIcon: typeof import('vant/es')['Icon'] - VanImage: typeof import('vant/es')['Image'] VanList: typeof import('vant/es')['List'] VanLoading: typeof import('vant/es')['Loading'] - VanNavBar: typeof import('vant/es')['NavBar'] VanPicker: typeof import('vant/es')['Picker'] VanPopup: typeof import('vant/es')['Popup'] VanSearch: typeof import('vant/es')['Search'] VanTabbar: typeof import('vant/es')['Tabbar'] VanTabbarItem: typeof import('vant/es')['TabbarItem'] - VanTag: typeof import('vant/es')['Tag'] } } diff --git a/src/api/change.ts b/src/api/change.ts index 984522d..56c5b79 100644 --- a/src/api/change.ts +++ b/src/api/change.ts @@ -1,6 +1,6 @@ import request from '@/utils/request' -export type ChangeSort = 'apply' | 'plan' | 'status' +export type ChangeSort = 'apply' | 'applyDesc' | 'plan' | 'planDesc' | 'status' | 'statusDesc' export interface ChangeTag { text: string diff --git a/src/views/Changes.vue b/src/views/Changes.vue index d6d571c..42dc4ab 100644 --- a/src/views/Changes.vue +++ b/src/views/Changes.vue @@ -24,11 +24,53 @@ const page = ref(1) const pageSize = 10 const listScroll = ref(null) let requestId = 0 +// 类型筛选 +const filterType = ref('') +const typeOptions = [ + { label: '全部', value: '' }, + { label: '工艺', value: '工艺' }, + { label: '设备', value: '设备' }, + { label: '管理', value: '管理' }, +] +// 时限筛选 +const filterDuration = ref('') +const durationOptions = [ + { label: '全部', value: '' }, + { label: '永久', value: '永久' }, + { label: '临时', value: '临时' }, +] +// 时间筛选 +type TimeRangeKey = 'year' | 'halfYear' | 'threeMonths' | 'month' | 'custom' +const timeRange = ref('year') +const customStart = ref('') +const customEnd = ref('') +const timeOptions: Array<{ label: string; value: TimeRangeKey }> = [ + { label: '近一年', value: 'year' }, + { label: '近半年', value: 'halfYear' }, + { label: '近三个月', value: 'threeMonths' }, + { label: '近一个月', value: 'month' }, + { label: '自定义', value: 'custom' }, +] +// 状态筛选 +const filterStatus = ref('') +const statusOptions = [ + { label: '全部', value: '' }, + { label: '审批中', value: '审批中' }, + { label: '已批准', value: '已批准' }, + { label: '实施中', value: '实施中' }, + { label: '待PSSR', value: '待PSSR' }, + { label: '待验收', value: '待验收' }, + { label: '待关闭', value: '待关闭' }, + { label: '已关闭', value: '已关闭' }, +] // 排序选项 const sortOptions: Array<{ key: ChangeSort; label: string }> = [ - { key: 'apply', label: '最新申请' }, - { key: 'plan', label: '计划投用' }, - { key: 'status', label: '状态更新' }, + { key: 'apply', label: '申请时间 · 最新' }, + { key: 'applyDesc', label: '申请时间 · 最早' }, + { key: 'plan', label: '计划投用 · 最近' }, + { key: 'planDesc', label: '计划投用 · 最晚' }, + { key: 'status', label: '状态更新 · 最新' }, + { key: 'statusDesc', label: '状态更新 · 最早' }, ] // 组织选项 const orgOptions: Array<{ text: string; value: string }> = [ @@ -52,21 +94,112 @@ function onOrgConfirm(params: { showOrgPicker.value = false resetList() } +// 排序选择器显隐 +const showSortPicker = ref(false) +// 当前排序显示文本 +const sortLabel = computed( + () => sortOptions.find((item) => item.key === sort.value)?.label ?? '' +) +// 排序选择器数据源 +const sortColumns = sortOptions.map((item) => ({ + text: item.label, + value: item.key, +})) +// 确认排序选择 +function onSortConfirm(params: { + selectedOptions: Array<{ text: string; value: ChangeSort }> +}) { + sort.value = params.selectedOptions[0]?.value ?? 'apply' + showSortPicker.value = false + resetList() +} +// 格式化日期为 YYYY-MM-DD +function formatDate(date: Date) { + const m = String(date.getMonth() + 1).padStart(2, '0') + const d = String(date.getDate()).padStart(2, '0') + return `${date.getFullYear()}-${m}-${d}` +} +// 计算申请时间范围 +function applyTimeRange() { + if (timeRange.value === 'custom') { + return { start: customStart.value, end: customEnd.value } + } + const monthMap: Record, number> = { + month: 1, + threeMonths: 3, + halfYear: 6, + year: 12, + } + const start = new Date() + start.setMonth(start.getMonth() - monthMap[timeRange.value]) + return { start: formatDate(start), end: formatDate(new Date()) } +} +// 选择类型 +function selectType(value: string) { + if (filterType.value === value) return + filterType.value = value + resetList() +} +// 选择时限 +function selectDuration(value: string) { + if (filterDuration.value === value) return + filterDuration.value = value + resetList() +} +// 自定义时间选择器显隐 +const showCalendar = ref(false) +// 选择时间范围,自定义时打开日期选择 +function selectTime(value: TimeRangeKey) { + if (value === 'custom') { + showCalendar.value = true + return + } + if (timeRange.value === value) return + timeRange.value = value + resetList() +} +// 确认自定义时间范围 +function onCalendarConfirm(range: Date[]) { + const [start, end] = range + customStart.value = formatDate(start) + customEnd.value = formatDate(end) + timeRange.value = 'custom' + showCalendar.value = false + resetList() +} +// 选择状态 +function selectStatus(value: string) { + if (filterStatus.value === value) return + filterStatus.value = value + resetList() +} +// 重置筛选与排序 +function resetFilters() { + filterType.value = '' + filterDuration.value = '' + filterStatus.value = '' + timeRange.value = 'year' + customStart.value = '' + customEnd.value = '' + sort.value = 'apply' + resetList() +} // 搜索关键字变化时刷新列表 watch(keyword, resetList) // 变更列表 async function onLoad() { const currentRequest = requestId try { + const { start, end } = applyTimeRange() const res = await changeListApi({ kw: keyword.value, org_id: org.value, - type: '', + type: filterType.value, level: '', - duration: '', - status: '', - apply_time_start: '', - apply_time_end: '', + duration: filterDuration.value, + status: filterStatus.value, + apply_time_start: start, + apply_time_end: end, onlyOpen: mode.value === 'open', sort: sort.value, self: 1, @@ -108,12 +241,6 @@ function setMode(value: 'all' | 'open') { mode.value = value resetList() } -// 排序变更 -function selectSort(key: ChangeSort) { - if (sort.value === key) return - sort.value = key - resetList() -} // 审批状态类名 function approvalClass(value: ChangeItem['approval']) { if (value === '审批中') return 'pending' @@ -128,10 +255,6 @@ function goDetail(item: ChangeItem) { function goProgress(item: ChangeItem) { router.push(`/change/${item.id}/progress`) } -// 操作变更 -function onAction(action: string) { - showToast(`${action}功能建设中`) -} onMounted(() => { resetList() }) @@ -188,15 +311,80 @@ onMounted(() => {
- - {{ item.label }} - +
+ 类型 +
+ + {{ item.label }} + +
+
+ +
+ 时限 +
+ + {{ item.label }} + +
+
+ +
+ 时间 +
+ + {{ item.label }} + +
+
+ +
+ 状态 +
+ + {{ item.label }} + +
+
+ +
+ 排序 +
+ {{ sortLabel }} + +
+
+ + + 重置 + +
+
+
@@ -252,13 +440,6 @@ onMounted(() => {