diff --git a/src/pages.json b/src/pages.json index 291c545..d7c3c62 100644 --- a/src/pages.json +++ b/src/pages.json @@ -1091,6 +1091,13 @@ "navigationStyle": "custom" } }, + { + "path": "moldRepair/moldSelect", + "style": { + "navigationBarTitleText": "选择模具", + "navigationStyle": "custom" + } + }, { "path": "moldInspectionItems/index", "style": { diff --git a/src/pages_function/pages/moldRepair/form.vue b/src/pages_function/pages/moldRepair/form.vue index 9e18705..a82ffec 100644 --- a/src/pages_function/pages/moldRepair/form.vue +++ b/src/pages_function/pages/moldRepair/form.vue @@ -93,18 +93,16 @@ - - - {{ selectedMoldLabel }} - - - + + {{ t('moldRepair.placeholderMold') }} + + @@ -334,7 +332,6 @@ const statusLabel = computed(() => { if (normalized === '1') return t('moldRepair.orderStatusDone') return t('moldRepair.orderStatusPending') }) -const moldLabels = computed(() => moldOptions.value.map((item) => item.label)) const faultLevelOptions = computed(() => { const dicts = dictStore.getDict(DICT_TYPE.FAILURE_LEVEL) || [] return dicts @@ -346,14 +343,6 @@ const faultLevelOptions = computed(() => { }) const acceptedByLabel = computed(() => resolveUserLabel(formData.acceptedBy, t('moldRepair.placeholderAcceptedBy'))) const confirmByLabel = computed(() => resolveUserLabel(formData.confirmBy, t('moldRepair.placeholderConfirmBy'))) -const moldIndex = computed(() => { - const index = moldOptions.value.findIndex((item) => String(item.value) === String(formData.moldId || '')) - return index >= 0 ? index : 0 -}) -const selectedMoldLabel = computed(() => { - const current = moldOptions.value.find((item) => String(item.value) === String(formData.moldId || '')) - return current?.label || t('moldRepair.placeholderMold') -}) const faultImageList = computed(() => splitImages(formData.faultImages)) const repairedImageList = computed(() => splitImages(formData.repairedImages)) @@ -373,6 +362,7 @@ onReady(() => { onShow(() => { applySelectedUser() + applySelectedMold() }) function focusKeywordNoKeyboard() { @@ -481,13 +471,12 @@ function onDateChange(field, event) { formData[field] = String(event?.detail?.value || '') } -function onMoldChange(event) { - const index = Number(event?.detail?.value || 0) - const current = moldOptions.value[index] - if (!current) return - applyMoldOption(current) +function openMoldSelect() { + if (readonlyBase.value) return + uni.navigateTo({ + url: `/pages_function/pages/moldRepair/moldSelect?selectedId=${encodeURIComponent(String(formData.moldId || ''))}` + }) } - function onMoldCodeSearch(event) { const code = (event?.detail?.value || '').trim() if (code) doMoldCodeSearch(code) @@ -606,14 +595,24 @@ function reFocusScanInput() { }) } +function normalizeMoldOption(item) { + const code = item?.code ?? item?.moldCode ?? item?.brandCode ?? '' + const name = item?.name ?? item?.moldName ?? item?.brandName ?? '' + const label = `${code} ${name}`.trim() || String(item?.id ?? '') + return { + value: item?.id, + label, + raw: item + } +} + function applyMoldOption(current) { formData.moldId = current.value - formData.moldCode = inputValue(current.raw?.code ?? current.raw?.moldCode) - formData.moldName = inputValue(current.raw?.name ?? current.raw?.moldName) + formData.moldCode = inputValue(current.raw?.code ?? current.raw?.moldCode ?? current.raw?.brandCode) + formData.moldName = inputValue(current.raw?.name ?? current.raw?.moldName ?? current.raw?.brandName) formData.specModel = inputValue(current.raw?.spec ?? current.raw?.moldSpec ?? current.raw?.machinerySpec) formData.brand = inputValue(current.raw?.brand ?? current.raw?.moldBrand ?? current.raw?.machineryBrand) } - function onShutdownChange(event) { const value = String(event?.detail?.value || '') if (value === 'true') selectShutdown(true) @@ -682,6 +681,18 @@ function applySelectedUser() { } } +function applySelectedMold() { + const result = getApp().globalData._moldRepairMoldSelectResult + if (!result?.mold) return + getApp().globalData._moldRepairMoldSelectResult = null + const mold = result.mold + const option = normalizeMoldOption(mold) + if (!moldOptions.value.some((item) => String(item.value) === String(option.value))) { + moldOptions.value = [option, ...moldOptions.value] + } + applyMoldOption(option) +} + function getTodayDate() { return formatPickerDate(Date.now()) } @@ -964,7 +975,7 @@ function goBack() { display: flex; align-items: center; justify-content: space-between; - gap: 16rpx; + // gap: 16rpx; } .form-textarea { @@ -989,44 +1000,21 @@ function goBack() { .mold-scan-input { flex: 1; min-width: 0; - height: 84rpx; - line-height: 84rpx; - padding: 0 20rpx; - border: 1rpx solid #d9dde5; - border-radius: 14rpx; - background: #ffffff; - font-size: 26rpx; - color: #374151; - box-sizing: border-box; } -.mold-picker { +.mold-select-field { flex-shrink: 0; - width: 180rpx; - height: 84rpx; - line-height: 84rpx; - padding: 0 14rpx; - font-size: 26rpx; - color: #111827; - display: flex; - align-items: center; - justify-content: space-between; - gap: 8rpx; - border: 1rpx solid #d9dde5; - border-radius: 14rpx; - background: #ffffff; - box-sizing: border-box; -} - -.mold-picker.is-placeholder { - color: #9ca3af; + width: 190rpx; + background: #1f4b79; + color: #ffffff; } -.mold-picker.is-disabled { - color: #9ca3af; +.mold-select-field.is-placeholder, +.mold-select-field.is-disabled { + color: #ffffff; } -.mold-picker .picker-field-text { +.mold-select-field .picker-field-text { flex: 1; min-width: 0; overflow: hidden; diff --git a/src/pages_function/pages/moldRepair/moldSelect.vue b/src/pages_function/pages/moldRepair/moldSelect.vue new file mode 100644 index 0000000..7aefbd4 --- /dev/null +++ b/src/pages_function/pages/moldRepair/moldSelect.vue @@ -0,0 +1,283 @@ + + + + + \ No newline at end of file