Commit 8cdbc8eb by chenwq1

refactor: 更新组件导入路径及优化评分表单逻辑

- 修改 components.d.ts 中的组件导入路径,将 'customizeForm' 更改为 'CustomizeForm' 以符合新的目录结构。
- 在 ScoreForm.vue 中添加键盘事件处理,限制输入为数字,优化用户输入体验。
- 更新 car-detail 组件中的评分表单,确保评分输入逻辑更加清晰和高效。
- 调整样式以改善界面显示,确保一致性和可读性。
1 parent 36081662
...@@ -7,18 +7,18 @@ export {} ...@@ -7,18 +7,18 @@ export {}
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
ButtonSelect: typeof import('./components/customizeForm/buttonSelect.vue')['default'] ButtonSelect: typeof import('./components/CustomizeForm/buttonSelect.vue')['default']
CustomizeUploadFile: typeof import('./components/customizeForm/customizeUploadFile.vue')['default'] CustomizeUploadFile: typeof import('./components/CustomizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/customizeForm/Index.vue')['default'] Index: typeof import('./components/CustomizeForm/Index.vue')['default']
Layouts: typeof import('./layouts/index.vue')['default'] Layouts: typeof import('./layouts/index.vue')['default']
LogoutConfirmModal: typeof import('./components/LogoutConfirmModal.vue')['default'] LogoutConfirmModal: typeof import('./components/LogoutConfirmModal.vue')['default']
PageTitle: typeof import('./components/PageTitle.vue')['default'] PageTitle: typeof import('./components/PageTitle.vue')['default']
PageTop: typeof import('./components/PageTop.vue')['default'] PageTop: typeof import('./components/PageTop.vue')['default']
RadioSelect: typeof import('./components/customizeForm/radioSelect.vue')['default'] RadioSelect: typeof import('./components/CustomizeForm/radioSelect.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView'] RouterView: typeof import('vue-router')['RouterView']
SelectDatePicker: typeof import('./components/customizeForm/selectDatePicker.vue')['default'] SelectDatePicker: typeof import('./components/CustomizeForm/selectDatePicker.vue')['default']
SelectDropdown: typeof import('./components/customizeForm/selectDropdown.vue')['default'] SelectDropdown: typeof import('./components/CustomizeForm/selectDropdown.vue')['default']
VanActionSheet: typeof import('vant/es')['ActionSheet'] VanActionSheet: typeof import('vant/es')['ActionSheet']
VanButton: typeof import('vant/es')['Button'] VanButton: typeof import('vant/es')['Button']
VanCheckbox: typeof import('vant/es')['Checkbox'] VanCheckbox: typeof import('vant/es')['Checkbox']
......
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
<input class="score-input" <input class="score-input"
inputmode="numeric" inputmode="numeric"
maxlength="3" maxlength="3"
pattern="[0-9]*"
type="text" type="text"
:value="String(form.appearanceScore)" :value="String(form.appearanceScore)"
@input="onAppearanceScoreInput" /> @input="onAppearanceScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span> <span class="score-unit">分</span>
</div> </div>
</div> </div>
...@@ -133,9 +135,11 @@ ...@@ -133,9 +135,11 @@
<input class="score-input" <input class="score-input"
inputmode="numeric" inputmode="numeric"
maxlength="3" maxlength="3"
pattern="[0-9]*"
type="text" type="text"
:value="String(form.overallScore)" :value="String(form.overallScore)"
@input="onOverallScoreInput" /> @input="onOverallScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span> <span class="score-unit">分</span>
</div> </div>
</div> </div>
...@@ -317,6 +321,28 @@ function clampScoreFromInput(raw: string): number { ...@@ -317,6 +321,28 @@ function clampScoreFromInput(raw: string): number {
return Math.min(100, Math.max(0, n)); return Math.min(100, Math.max(0, n));
} }
/** 阻止键入非数字;粘贴仍走 @input + clampScoreFromInput */
function onScoreInputKeydown(e: KeyboardEvent) {
if (e.isComposing) return;
if (e.ctrlKey || e.metaKey || e.altKey) return;
const navKeys = new Set([
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowUp",
"Backspace",
"Delete",
"End",
"Enter",
"Escape",
"Home",
"Tab",
]);
if (navKeys.has(e.key)) return;
if (/^\d$/.test(e.key)) return;
e.preventDefault();
}
function onAppearanceScoreInput(e: Event) { function onAppearanceScoreInput(e: Event) {
form.appearanceScore = clampScoreFromInput((e.target as HTMLInputElement).value); form.appearanceScore = clampScoreFromInput((e.target as HTMLInputElement).value);
} }
...@@ -493,8 +519,8 @@ defineExpose({ validate, getCompleteInspectionPayload }); ...@@ -493,8 +519,8 @@ defineExpose({ validate, getCompleteInspectionPayload });
.rating-btn-check { .rating-btn-check {
position: absolute; position: absolute;
top: 2px; top: -3px;
right: 2px; right: 0px;
width: 14px; width: 14px;
height: 14px; height: 14px;
object-fit: contain; object-fit: contain;
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
@click="onOpenModulePicker"> @click="onOpenModulePicker">
<span class="nav-module-name">{{ activeBigModule?.label || "加载中..." }}</span> <span class="nav-module-name">{{ activeBigModule?.label || "加载中..." }}</span>
<van-icon class="nav-module-arrow" <van-icon class="nav-module-arrow"
name="arrow-down" color="#333333"
name="arrow"
size="13" /> size="13" />
</div> </div>
</div> </div>
...@@ -675,7 +676,8 @@ onMounted(() => { ...@@ -675,7 +676,8 @@ onMounted(() => {
} }
.nav-module-arrow { .nav-module-arrow {
color: $color-text-secondary; color: #333333;
font-weight: 600;
transition: $transition-fast; transition: $transition-fast;
} }
} }
......
...@@ -125,7 +125,7 @@ void onRefresh(); ...@@ -125,7 +125,7 @@ void onRefresh();
</div> </div>
</PageTop> </PageTop>
<div ref="scroller" class="list-wrap"> <div ref="scroller" class="list-wrap">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh"> <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<div v-if="listEmpty" <div v-if="listEmpty"
class="list-empty"> class="list-empty">
...@@ -203,6 +203,15 @@ void onRefresh(); ...@@ -203,6 +203,15 @@ void onRefresh();
.search-wrap { .search-wrap {
padding: 0 12px; padding: 0 12px;
:deep(.van-search) {
padding: 0;
background: transparent;
}
:deep(.van-search__content) {
background: #fff;
}
} }
.list-wrap { .list-wrap {
......
...@@ -115,9 +115,15 @@ async function fillMore() { ...@@ -115,9 +115,15 @@ async function fillMore() {
finished.value = !!res.last || next.length === 0; finished.value = !!res.last || next.length === 0;
} }
/**
* van-list 在 emit load 前会先 `update:loading` 为 true,若此处再判断 `loading` 会直接 return,
* 且不会走 finally,导致 loading 一直为 true,`listEmpty` 永远为 false,空列表不显示「暂无数据」。
*/
async function onLoad() { async function onLoad() {
if (loading.value || finished.value) return; if (refreshing.value || finished.value) {
loading.value = true; loading.value = false;
return;
}
try { try {
await fillMore(); await fillMore();
} finally { } finally {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!