Commit c09c0edaf880764b5738ab6d17612e3fe98e7049

Authored by 刘淇
1 parent 1594be1c

养护类型

pages-sub/daily/maintain-manage/type-list.vue
1 <template> 1 <template>
2 <view class="type-grid"> 2 <view class="type-grid">
3 - <!-- 按养护类型渲染计划卡片:同一类型下多个批次合并成一张卡,批次号/计划名称等每项一行,多批次时逐行列出 -->  
4 <template v-if="cardList.length > 0"> 3 <template v-if="cardList.length > 0">
5 <view class="type-card" v-for="item in cardList" :key="item.key" hover-class="type-card--hover" 4 <view class="type-card" v-for="item in cardList" :key="item.key" hover-class="type-card--hover"
6 @click="toNextPage(item)"> 5 @click="toNextPage(item)">
7 <view class="info-row" v-for="row in item.rows" :key="row.label"> 6 <view class="info-row" v-for="row in item.rows" :key="row.label">
8 - <text class="info-label">{{ row.label }}:</text> 7 + <!-- ✅计划类型:不渲染左侧label文字;其他行正常显示label -->
  8 + <text class="info-label" v-if="row.label !== '计划类型'">{{ row.label }}:</text>
9 <view class="info-value"> 9 <view class="info-value">
10 <view class="info-line" v-for="(value, idx) in row.values" :key="idx" 10 <view class="info-line" v-for="(value, idx) in row.values" :key="idx"
11 :class="{ 'info-line--count': row.label === '待完成数' }">{{ value }}</view> 11 :class="{ 'info-line--count': row.label === '待完成数' }">{{ value }}</view>
@@ -21,15 +21,13 @@ @@ -21,15 +21,13 @@
21 <script setup lang="ts"> 21 <script setup lang="ts">
22 import { ref } from 'vue' 22 import { ref } from 'vue'
23 import { onShow, onUnload } from '@dcloudio/uni-app'; 23 import { onShow, onUnload } from '@dcloudio/uni-app';
24 -  
25 const cardList = ref<Array<{ 24 const cardList = ref<Array<{
26 key: string 25 key: string
27 planTypeId: string | number 26 planTypeId: string | number
28 batchNos: string[] 27 batchNos: string[]
29 rows: Array<{ label: string; values: string[] }> 28 rows: Array<{ label: string; values: string[] }>
30 }>>([]) 29 }>>([])
31 -  
32 -/** 日期字段可能是 'yyyy-MM-dd' 字符串(LocalDate)或时间戳,统一转成 yyyy-MM-dd */ 30 +/** 日期字段可能是 'yyyy‑MM‑dd' 字符串(LocalDate)或时间戳,统一转成 yyyy‑MM‑dd */
33 const formatDate = (value: any) => { 31 const formatDate = (value: any) => {
34 if (value === null || value === undefined || value === '') return '--' 32 if (value === null || value === undefined || value === '') return '--'
35 if (Array.isArray(value)) { 33 if (Array.isArray(value)) {
@@ -39,15 +37,11 @@ const formatDate = (value: any) =&gt; { @@ -39,15 +37,11 @@ const formatDate = (value: any) =&gt; {
39 const d = new Date(value) 37 const d = new Date(value)
40 return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}` 38 return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
41 } 39 }
42 - // 'yyyy-MM-dd HH:mm:ss' 之类的字符串只取日期部分  
43 return String(value).slice(0, 10) 40 return String(value).slice(0, 10)
44 } 41 }
45 -  
46 /** 去重并保持原顺序,合并卡片时避免同一个值重复占一行 */ 42 /** 去重并保持原顺序,合并卡片时避免同一个值重复占一行 */
47 const uniq = (list: any[]) => Array.from(new Set(list.filter(v => v !== null && v !== undefined && v !== ''))) 43 const uniq = (list: any[]) => Array.from(new Set(list.filter(v => v !== null && v !== undefined && v !== '')))
48 -  
49 onShow(() => { 44 onShow(() => {
50 - // 从storage拿上一页传过来完整对象  
51 const item = uni.getStorageSync('temp_maintain_item') 45 const item = uni.getStorageSync('temp_maintain_item')
52 if (!item) { 46 if (!item) {
53 uni.showToast({ 47 uni.showToast({
@@ -57,7 +51,6 @@ onShow(() =&gt; { @@ -57,7 +51,6 @@ onShow(() =&gt; {
57 return 51 return
58 } 52 }
59 const roadName = item.roadName || '--' 53 const roadName = item.roadName || '--'
60 - // 接口已按养护类型分组,同一类型下的多个批次在这里合并成一张卡  
61 cardList.value = (item.planTypes || []).map((type: any) => { 54 cardList.value = (item.planTypes || []).map((type: any) => {
62 const batches = Array.isArray(type.batches) && type.batches.length 55 const batches = Array.isArray(type.batches) && type.batches.length
63 ? type.batches 56 ? type.batches
@@ -75,89 +68,85 @@ onShow(() =&gt; { @@ -75,89 +68,85 @@ onShow(() =&gt; {
75 planTypeId: type.planTypeId, 68 planTypeId: type.planTypeId,
76 batchNos, 69 batchNos,
77 rows: [ 70 rows: [
78 - { label: '批次号', values: batchNos.length ? batchNos : ['--'] },  
79 - { label: '计划名称', values: uniq(batches.map((batch: any) => batch.planName)).length  
80 - ? uniq(batches.map((batch: any) => batch.planName)) : ['--'] },  
81 - { label: '道路名称', values: [roadName] },  
82 { label: '计划类型', values: [type.planTypeName || '--'] }, 71 { label: '计划类型', values: [type.planTypeName || '--'] },
83 - { label: '执行时间', values: uniq(batches.map((batch: any) =>  
84 - `${formatDate(batch.beginTime)} - ${formatDate(batch.endTime)}`)) },  
85 { label: '待完成数', values: [`${pendingCount}次`] } 72 { label: '待完成数', values: [`${pendingCount}次`] }
86 ] 73 ]
87 } 74 }
88 }) 75 })
89 }); 76 });
90 -  
91 -// 点击卡片跳到期次列表,把该类型下所有批次号一起带过去  
92 const toNextPage = (item: any) => { 77 const toNextPage = (item: any) => {
93 uni.setStorageSync('temp_maintain_rawList', item.batchNos || []) 78 uni.setStorageSync('temp_maintain_rawList', item.batchNos || [])
94 uni.navigateTo({ 79 uni.navigateTo({
95 url: `/pages-sub/daily/maintain-manage/type-list-page?planTypeId=${item.planTypeId}` 80 url: `/pages-sub/daily/maintain-manage/type-list-page?planTypeId=${item.planTypeId}`
96 }) 81 })
97 } 82 }
98 -  
99 -// 页面卸载清理缓存,防止脏数据  
100 onUnload(()=>{ 83 onUnload(()=>{
101 uni.removeStorageSync('temp_maintain_item') 84 uni.removeStorageSync('temp_maintain_item')
102 }) 85 })
103 </script> 86 </script>
104 <style scoped lang="scss"> 87 <style scoped lang="scss">
105 -/* 卡片列表:页面 24rpx 内边距,卡片间距 16rpx */  
106 .type-grid { 88 .type-grid {
107 display: flex; 89 display: flex;
108 - flex-direction: column;  
109 - gap: 16rpx; 90 + flex-wrap: wrap;
  91 + gap: 24rpx;
110 padding: 24rpx; 92 padding: 24rpx;
111 } 93 }
112 -  
113 -/* 卡片:一张卡对应一个养护类型(多批次合并),撑满一行 */ 94 +/* 一行两张卡片,总宽度扣除中间间隙 */
114 .type-card { 95 .type-card {
  96 + width: calc((100% - 24rpx) / 2);
  97 + box-sizing: border-box;
115 display: flex; 98 display: flex;
116 flex-direction: column; 99 flex-direction: column;
117 - box-sizing: border-box;  
118 gap: 8rpx; 100 gap: 8rpx;
119 background: #ffffff; 101 background: #ffffff;
120 border-radius: 16rpx; 102 border-radius: 16rpx;
121 padding: 24rpx; 103 padding: 24rpx;
122 box-shadow: 0 4rpx 16rpx rgba(17, 24, 39, 0.06); 104 box-shadow: 0 4rpx 16rpx rgba(17, 24, 39, 0.06);
123 transition: background-color 0.15s ease; 105 transition: background-color 0.15s ease;
124 -  
125 &--hover { 106 &--hover {
126 background: #F4F5F7; 107 background: #F4F5F7;
127 } 108 }
128 } 109 }
129 -  
130 -/* 信息行:左侧字段名浅灰,右侧值右对齐;多个批次时值逐行显示 */  
131 .info-row { 110 .info-row {
132 display: flex; 111 display: flex;
133 align-items: flex-start; 112 align-items: flex-start;
134 } 113 }
135 .info-label { 114 .info-label {
136 - width: 130rpx !important;  
137 - flex-shrink: 0;  
138 - font-size: 26rpx;  
139 - color: #6B7280;  
140 - line-height: 1.5; 115 + width: 130rpx !important;
  116 + flex-shrink: 0; /* 标签禁止压缩 */
  117 + font-size: 26rpx;
  118 + color: #6B7280;
  119 + line-height: 1.5;
141 } 120 }
142 .info-value { 121 .info-value {
143 flex: 1; 122 flex: 1;
144 min-width: 0; 123 min-width: 0;
  124 + /* ✅计划类型没有label时,去掉左边padding,顶格显示 */
145 padding-left: 16rpx; 125 padding-left: 16rpx;
146 } 126 }
147 - 127 +/* 当该行没有label的时候,value不要左边边距 */
  128 +.info-row:not(:has(.info-label)) .info-value {
  129 + padding-left: 0;
  130 +}
148 .info-line { 131 .info-line {
149 font-size: 26rpx; 132 font-size: 26rpx;
150 color: #1F2937; 133 color: #1F2937;
151 line-height: 1.5; 134 line-height: 1.5;
152 - word-break: break-all;  
153 -  
154 - /* 待完成次数加重,便于一眼看到 */ 135 + /* 普通计划类型文字:超长省略 */
  136 + &:not(.info-line--count) {
  137 + overflow: hidden;
  138 + text-overflow: ellipsis;
  139 + white-space: nowrap;
  140 + }
  141 + /* ✅待完成数:禁止省略、禁止截断,数字必须完整显示 */
155 &--count { 142 &--count {
156 color: #2563EB; 143 color: #2563EB;
157 font-weight: 500; 144 font-weight: 500;
  145 + white-space: normal !important;
  146 + overflow: visible !important;
  147 + text-overflow: clip !important;
158 } 148 }
159 } 149 }
160 -  
161 .type-empty { 150 .type-empty {
162 padding: 120rpx 0; 151 padding: 120rpx 0;
163 text-align: center; 152 text-align: center;