Commit c09c0edaf880764b5738ab6d17612e3fe98e7049

Authored by 刘淇
1 parent 1594be1c

养护类型

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