调整预订事项字段展示与基础信息编辑
This commit is contained in:
1 parent
08c8b0165b
commit
891a4aa6cf
10 files changed
+212
-65
No files matched your search
@@ -7,9 +7,8 @@
|
||||
:class="{ 'v4-field--readonly': !isEditable(field) }"
|
||||
>
|
||||
<span class="v4-field__label">
|
||||
{{ field.display_name }}
|
||||
{{ fieldDisplayName(field) }}
|
||||
<sup v-if="field.required">*</sup>
|
||||
<em v-if="!isEditable(field)">{{ t('taskV4.field.readonly') }}</em>
|
||||
</span>
|
||||
|
||||
<select
|
||||
@@ -99,11 +98,7 @@
|
||||
</span>
|
||||
|
||||
<small
|
||||
v-if="field.control_hint"
|
||||
class="v4-field__hint"
|
||||
>{{ field.control_hint }}</small>
|
||||
<small
|
||||
v-for="hint in lookupHints(field)"
|
||||
v-for="hint in visibleLookupHints(field)"
|
||||
:key="hint.key"
|
||||
class="v4-field__hint"
|
||||
:class="`v4-field__hint--${hint.tone}`"
|
||||
@@ -227,6 +222,11 @@ function fieldKey(field: ReservationV4TaskCardFieldResult): string {
|
||||
return reservationV4FieldKey(field)
|
||||
}
|
||||
|
||||
function fieldDisplayName(field: ReservationV4TaskCardFieldResult): string {
|
||||
const labelKey = fieldLabelKey(field)
|
||||
return labelKey ? t(labelKey) : field.display_name
|
||||
}
|
||||
|
||||
function dateFieldInputId(field: ReservationV4TaskCardFieldResult): string {
|
||||
return `v4-date-${fieldKey(field).replace(/[^a-zA-Z0-9_-]/g, '-')}`
|
||||
}
|
||||
@@ -402,6 +402,10 @@ function lookupHints(field: ReservationV4TaskCardFieldResult): LookupHint[] {
|
||||
return hints
|
||||
}
|
||||
|
||||
function visibleLookupHints(field: ReservationV4TaskCardFieldResult): LookupHint[] {
|
||||
return lookupHints(field).filter((hint) => hint.tone === 'error')
|
||||
}
|
||||
|
||||
function visibleFieldErrors(field: ReservationV4TaskCardFieldResult): string[] {
|
||||
return [
|
||||
...(field.validation_errors ?? []),
|
||||
@@ -645,6 +649,62 @@ function isExactLookupLoading(field: ReservationV4TaskCardFieldResult): boolean
|
||||
function exactLookupKey(kind: ReservationV4LookupKind, code: string): string {
|
||||
return `${props.hotelId ?? ''}:${kind}:${code}`
|
||||
}
|
||||
|
||||
function fieldLabelKey(field: ReservationV4TaskCardFieldResult): string | null {
|
||||
const key = normalizeFieldKey(field)
|
||||
if (key === '/basic_information/account_code') {
|
||||
return 'taskV4.fieldLabels.basicInformation.accountCode'
|
||||
}
|
||||
if (key === '/basic_information/market_code') {
|
||||
return 'taskV4.fieldLabels.basicInformation.marketCode'
|
||||
}
|
||||
if (key === '/basic_information/source_code') {
|
||||
return 'taskV4.fieldLabels.basicInformation.sourceCode'
|
||||
}
|
||||
if (key === '/room_information/final_values/group_block_name') {
|
||||
return 'taskV4.roomInformation.groupBlockName'
|
||||
}
|
||||
if (key === '/room_information/final_values/fit_name') {
|
||||
return 'taskV4.roomInformation.fitName'
|
||||
}
|
||||
if (key === '/room_information/final_values/arrival_date') {
|
||||
return 'taskV4.roomInformation.arrivalDate'
|
||||
}
|
||||
if (key === '/room_information/final_values/departure_date') {
|
||||
return 'taskV4.roomInformation.departureDate'
|
||||
}
|
||||
if (key === '/room_information/final_values/nights') {
|
||||
return 'taskV4.roomInformation.nights'
|
||||
}
|
||||
if (key === '/room_information/final_values/rate_code') {
|
||||
return 'taskV4.roomInformation.rateCode'
|
||||
}
|
||||
if (key === '/room_information/final_values/breakfast_included') {
|
||||
return 'taskV4.roomInformation.breakfastIncluded'
|
||||
}
|
||||
if (key === '/room_information/final_values/group_booking_status') {
|
||||
return 'taskV4.roomInformation.groupBookingStatus'
|
||||
}
|
||||
if (key === '/room_information/final_values/block_id') {
|
||||
return 'taskV4.roomInformation.blockId'
|
||||
}
|
||||
if (key === '/room_information/final_values/confirmation_number') {
|
||||
return 'taskV4.roomInformation.confirmationNumber'
|
||||
}
|
||||
if (/^\/room_information\/final_values\/room_items\/\d+\/room_type_code$/.test(key)) {
|
||||
return 'taskV4.roomInformation.roomTypeCode'
|
||||
}
|
||||
if (/^\/room_information\/final_values\/room_items\/\d+\/room_count$/.test(key)) {
|
||||
return 'taskV4.roomInformation.roomCount'
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function normalizeFieldKey(field: ReservationV4TaskCardFieldResult): string {
|
||||
return reservationV4FieldKey(field)
|
||||
.replace(/\./g, '/')
|
||||
.replace(/^([^/])/, '/$1')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -672,15 +732,6 @@ function exactLookupKey(kind: ReservationV4LookupKind, code: string): string {
|
||||
color: var(--th-color-danger);
|
||||
}
|
||||
|
||||
.v4-field__label em {
|
||||
border-radius: 999px;
|
||||
background: var(--th-color-slate-100);
|
||||
color: var(--th-color-slate-500);
|
||||
font-size: 11px;
|
||||
font-style: normal;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
|
||||
.v4-field__control,
|
||||
.v4-field__static {
|
||||
min-height: 38px;
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<span class="trace-field__label">
|
||||
{{ field.display_name }}
|
||||
<sup v-if="field.required">*</sup>
|
||||
<em v-if="!isEditable(field)">{{ t('taskV4.field.readonly') }}</em>
|
||||
</span>
|
||||
|
||||
<select
|
||||
@@ -94,14 +93,9 @@
|
||||
</span>
|
||||
|
||||
<small
|
||||
v-if="field.control_hint"
|
||||
class="trace-field__hint"
|
||||
>{{ field.control_hint }}</small>
|
||||
<small
|
||||
v-for="hint in lookupHints(field)"
|
||||
:key="hint"
|
||||
class="trace-field__hint"
|
||||
>{{ hint }}</small>
|
||||
v-if="lookupError(field)"
|
||||
class="trace-field__hint trace-field__hint--error"
|
||||
>{{ lookupError(field) }}</small>
|
||||
<small
|
||||
v-for="error in visibleFieldErrors(field)"
|
||||
:key="error"
|
||||
@@ -298,17 +292,14 @@ function selectDisabled(field: ReservationV4TaskCardFieldResult): boolean {
|
||||
(roomTypeLookup.loading || Boolean(roomTypeLookup.error))
|
||||
}
|
||||
|
||||
function lookupHints(field: ReservationV4TaskCardFieldResult): string[] {
|
||||
function lookupError(field: ReservationV4TaskCardFieldResult): string {
|
||||
if (reservationV4LookupKindForOptionsSource(field.options_source) !== 'ROOM_TYPE') {
|
||||
return []
|
||||
}
|
||||
if (roomTypeLookup.loading) {
|
||||
return [t('taskV4.lookup.loading')]
|
||||
return ''
|
||||
}
|
||||
if (roomTypeLookup.error) {
|
||||
return [roomTypeLookup.error]
|
||||
return roomTypeLookup.error
|
||||
}
|
||||
return []
|
||||
return ''
|
||||
}
|
||||
|
||||
function visibleFieldErrors(field: ReservationV4TaskCardFieldResult): string[] {
|
||||
@@ -488,15 +479,6 @@ function isRecord(value: unknown): value is ReservationRecord {
|
||||
color: var(--th-color-danger);
|
||||
}
|
||||
|
||||
.trace-field__label em {
|
||||
border-radius: 999px;
|
||||
background: var(--th-color-slate-100);
|
||||
color: var(--th-color-slate-500);
|
||||
font-size: 11px;
|
||||
font-style: normal;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
|
||||
.trace-field__control,
|
||||
.trace-field__static {
|
||||
min-height: 38px;
|
||||
@@ -529,6 +511,11 @@ function isRecord(value: unknown): value is ReservationRecord {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.trace-field__hint--error {
|
||||
color: var(--th-color-danger);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.trace-field__error {
|
||||
color: var(--th-color-danger);
|
||||
font-size: 12px;
|
||||
|
||||
Reference in new issue
Block a user