Commit 9d47e966 by yancanhua

Merge branch 'release/venus-usedcar-h5/1.0.0' of http://192.168.3.233:8090/monor…

…epo/venus into release/venus-usedcar-h5/1.0.0
2 parents a9144f5c ccd2611c
Pipeline #107 for 9d47e966 failed in 0 seconds
......@@ -7,18 +7,18 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
ButtonSelect: typeof import('./components/customizeForm/buttonSelect.vue')['default']
CustomizeUploadFile: typeof import('./components/customizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/customizeForm/Index.vue')['default']
ButtonSelect: typeof import('./components/CustomizeForm/buttonSelect.vue')['default']
CustomizeUploadFile: typeof import('./components/CustomizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/CustomizeForm/Index.vue')['default']
Layouts: typeof import('./layouts/index.vue')['default']
LogoutConfirmModal: typeof import('./components/LogoutConfirmModal.vue')['default']
PageTitle: typeof import('./components/PageTitle.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']
RouterView: typeof import('vue-router')['RouterView']
SelectDatePicker: typeof import('./components/customizeForm/selectDatePicker.vue')['default']
SelectDropdown: typeof import('./components/customizeForm/selectDropdown.vue')['default']
SelectDatePicker: typeof import('./components/CustomizeForm/selectDatePicker.vue')['default']
SelectDropdown: typeof import('./components/CustomizeForm/selectDropdown.vue')['default']
VanActionSheet: typeof import('vant/es')['ActionSheet']
VanButton: typeof import('vant/es')['Button']
VanCheckbox: typeof import('vant/es')['Checkbox']
......
......@@ -8,9 +8,11 @@
<input class="score-input"
inputmode="numeric"
maxlength="3"
pattern="[0-9]*"
type="text"
:value="String(form.appearanceScore)"
@input="onAppearanceScoreInput" />
@input="onAppearanceScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span>
</div>
</div>
......@@ -133,9 +135,11 @@
<input class="score-input"
inputmode="numeric"
maxlength="3"
pattern="[0-9]*"
type="text"
:value="String(form.overallScore)"
@input="onOverallScoreInput" />
@input="onOverallScoreInput"
@keydown="onScoreInputKeydown" />
<span class="score-unit">分</span>
</div>
</div>
......@@ -317,6 +321,28 @@ function clampScoreFromInput(raw: string): number {
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) {
form.appearanceScore = clampScoreFromInput((e.target as HTMLInputElement).value);
}
......@@ -493,8 +519,8 @@ defineExpose({ validate, getCompleteInspectionPayload });
.rating-btn-check {
position: absolute;
top: 2px;
right: 2px;
top: -3px;
right: 0px;
width: 14px;
height: 14px;
object-fit: contain;
......
......@@ -12,7 +12,8 @@
@click="onOpenModulePicker">
<span class="nav-module-name">{{ activeBigModule?.label || "加载中..." }}</span>
<van-icon class="nav-module-arrow"
name="arrow-down"
color="#333333"
name="arrow"
size="13" />
</div>
</div>
......@@ -308,15 +309,16 @@ async function initializeInspection() {
/**
* @param bigModuleKey 大项 id
* @param syncSelection 为 false 时只拉取/填充 subTabs,不改当前 activeSubKey(用于后台匹配节点)
* @param force 为 true 时忽略已有 subTabs 缓存,重新请求 `getInspectionChildren`
*/
async function loadSubTabsForBigModule(bigModuleKey: number | string, syncSelection = true) {
async function loadSubTabsForBigModule(bigModuleKey: number | string, syncSelection = true, force = false) {
if (bigModuleKey === SCORE_BIG_KEY) return;
try {
const targetBigModule = bigModules.value.find((module) => module.key === bigModuleKey);
if (!targetBigModule) return;
if (targetBigModule.subTabs.length > 0) {
if (!force && targetBigModule.subTabs.length > 0) {
if (syncSelection) {
activeSubKey.value = targetBigModule.subTabs[0]!.key;
}
......@@ -391,13 +393,13 @@ async function switchToUncompletedInspectionNode(nodeId: number | string): Promi
);
if (rootHit) {
activeBigKey.value = rootHit.key;
await loadSubTabsForBigModule(rootHit.key);
await loadSubTabsForBigModule(rootHit.key, true, true);
activeSubKey.value = rootHit.subTabs[0]?.key ?? "";
return true;
}
for (const m of mains) {
await loadSubTabsForBigModule(m.key, false);
await loadSubTabsForBigModule(m.key, false, true);
const sub = m.subTabs.find(
(s) => String(s.key) === idStr || String(s.nodeId ?? "") === idStr,
);
......@@ -446,7 +448,7 @@ function advanceInspectionStep() {
if (activeMainIndex < mains.length - 1) {
const nextMain = mains[activeMainIndex + 1]!;
activeBigKey.value = nextMain.key;
loadSubTabsForBigModule(nextMain.key).then(() => {
loadSubTabsForBigModule(nextMain.key, true, true).then(() => {
activeSubKey.value = nextMain.subTabs[0]?.key ?? "";
});
} else {
......@@ -481,16 +483,6 @@ async function saveCurrentLeafInspectionRecord(nextFlag: boolean): Promise<boole
return true;
}
/** 下一步保存成功后同步当前二级 Tab 完成态,避免进度条与 Tab 勾选依赖再次拉模板 */
function markActiveSubTabCompletedLocally() {
if (activeBigKey.value === SCORE_BIG_KEY) return;
const mod = bigModules.value.find((m) => m.key === activeBigKey.value);
const sub = mod?.subTabs.find((s) => s.key === activeSubKey.value);
if (sub) {
sub.completedFlag = 1;
}
}
/** 切换大项 / 二级项前静默落库当前叶子数据 */
async function persistCurrentSubTabSilently() {
if (activeBigKey.value === SCORE_BIG_KEY) return;
......@@ -508,13 +500,17 @@ async function onSelectBigModule(selectedBigModule: BigModule) {
activeBigKey.value = selectedBigModule.key;
activeSubKey.value = "";
if (selectedBigModule.key !== SCORE_BIG_KEY) {
loadSubTabsForBigModule(selectedBigModule.key);
await loadSubTabsForBigModule(selectedBigModule.key, true, true);
}
}
async function onSelectSubTab(subTabKey: number | string) {
if (subTabKey === activeSubKey.value) return;
await persistCurrentSubTabSilently();
const bigKey = activeBigKey.value;
if (bigKey !== SCORE_BIG_KEY) {
await loadSubTabsForBigModule(bigKey, false, true);
}
activeSubKey.value = subTabKey;
}
......@@ -533,7 +529,9 @@ async function onNext() {
showToast("未获取到表单数据");
return;
}
markActiveSubTabCompletedLocally();
if (activeBigKey.value !== SCORE_BIG_KEY) {
await loadSubTabsForBigModule(activeBigKey.value, false, true);
}
advanceInspectionStep();
} catch (error) {
if (!isRequestFailureAlreadyHandled(error)) {
......@@ -559,7 +557,7 @@ async function onPrev() {
const lastMain = mains[mains.length - 1];
if (lastMain) {
activeBigKey.value = lastMain.key;
await loadSubTabsForBigModule(lastMain.key);
await loadSubTabsForBigModule(lastMain.key, true, true);
activeSubKey.value = lastMain.subTabs[lastMain.subTabs.length - 1]?.key ?? "";
}
return;
......@@ -571,14 +569,16 @@ async function onPrev() {
const activeSubIndex = subTabsOfActive.findIndex((subTab) => subTab.key === activeSubKey.value);
if (activeSubIndex > 0) {
activeSubKey.value = subTabsOfActive[activeSubIndex - 1]!.key;
const prevSubKey = subTabsOfActive[activeSubIndex - 1]!.key;
await loadSubTabsForBigModule(activeBigKey.value, false, true);
activeSubKey.value = prevSubKey;
} else {
const mains = mainInspectionBigModules.value;
const activeMainIndex = mains.findIndex((module) => module.key === activeBigKey.value);
if (activeMainIndex > 0) {
const previousMain = mains[activeMainIndex - 1]!;
activeBigKey.value = previousMain.key;
await loadSubTabsForBigModule(previousMain.key);
await loadSubTabsForBigModule(previousMain.key, true, true);
activeSubKey.value =
previousMain.subTabs[previousMain.subTabs.length - 1]?.key ?? "";
}
......@@ -675,7 +675,8 @@ onMounted(() => {
}
.nav-module-arrow {
color: $color-text-secondary;
color: #333333;
font-weight: 600;
transition: $transition-fast;
}
}
......
......@@ -125,7 +125,7 @@ void onRefresh();
</div>
</PageTop>
<div ref="scroller" class="list-wrap">
<div ref="scroller" class="list-wrap">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<div v-if="listEmpty"
class="list-empty">
......@@ -203,6 +203,15 @@ void onRefresh();
.search-wrap {
padding: 0 12px;
:deep(.van-search) {
padding: 0;
background: transparent;
}
:deep(.van-search__content) {
background: #fff;
}
}
.list-wrap {
......
......@@ -115,9 +115,15 @@ async function fillMore() {
finished.value = !!res.last || next.length === 0;
}
/**
* van-list 在 emit load 前会先 `update:loading` 为 true,若此处再判断 `loading` 会直接 return,
* 且不会走 finally,导致 loading 一直为 true,`listEmpty` 永远为 false,空列表不显示「暂无数据」。
*/
async function onLoad() {
if (loading.value || finished.value) return;
loading.value = true;
if (refreshing.value || finished.value) {
loading.value = false;
return;
}
try {
await fillMore();
} finally {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!