Commit 0234cbca725a95567b123dab0e72c86ee9f2d5e0
1 parent
5a192b24
同步优化
Showing
17 changed files
with
1801 additions
and
329 deletions
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/locales/langs/en-US/foodLabeling.json
| @@ -40,16 +40,27 @@ | @@ -40,16 +40,27 @@ | ||
| 40 | "productCategory": "Product Category", | 40 | "productCategory": "Product Category", |
| 41 | "labelType": "Label Type", | 41 | "labelType": "Label Type", |
| 42 | "template": "Template", | 42 | "template": "Template", |
| 43 | - "status": "Status", | ||
| 44 | - "lastEdited": "Last Edited", | ||
| 45 | - "keyword": "Keyword", | ||
| 46 | - "selectProduct": "Select product", | ||
| 47 | - "selectLocation": "Select location", | ||
| 48 | - "selectCategory": "Select label category", | ||
| 49 | - "selectType": "Select label type", | ||
| 50 | - "selectTypeOptional": "Optional — select label type", | ||
| 51 | - "selectTemplate": "Select template", | ||
| 52 | - "action": "Actions", | 43 | + "status": "Status", |
| 44 | + "lastEdited": "Last Edited", | ||
| 45 | + "keyword": "Keyword", | ||
| 46 | + "company": "Company", | ||
| 47 | + "applicableRegion": "Applicable Region", | ||
| 48 | + "selectProduct": "Select product", | ||
| 49 | + "selectLocation": "Select location", | ||
| 50 | + "selectCategory": "Select label category", | ||
| 51 | + "selectType": "Select label type", | ||
| 52 | + "selectTypeOptional": "Optional — select label type", | ||
| 53 | + "selectTemplate": "Select template", | ||
| 54 | + "selectCompany": "Select company", | ||
| 55 | + "selectCompanyFirst": "Select company first", | ||
| 56 | + "selectRegion": "Select region", | ||
| 57 | + "selectCompanyRegionFirst": "Select company and region first", | ||
| 58 | + "selectProductCategory": "Select product category", | ||
| 59 | + "companyRequired": "Please select a company.", | ||
| 60 | + "regionRequired": "Please select an applicable region.", | ||
| 61 | + "productCategoryRequired": "Please select a product category.", | ||
| 62 | + "productRequired": "Please select a product.", | ||
| 63 | + "action": "Actions", | ||
| 53 | "labelCodeOptional": "Leave empty to auto-generate", | 64 | "labelCodeOptional": "Leave empty to auto-generate", |
| 54 | "deleteConfirm": "Delete this label?", | 65 | "deleteConfirm": "Delete this label?", |
| 55 | "bulkAdd": "Bulk Add", | 66 | "bulkAdd": "Bulk Add", |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/locales/langs/zh-CN/foodLabeling.json
| @@ -40,16 +40,27 @@ | @@ -40,16 +40,27 @@ | ||
| 40 | "productCategory": "产品分类", | 40 | "productCategory": "产品分类", |
| 41 | "labelType": "标签类型", | 41 | "labelType": "标签类型", |
| 42 | "template": "模板", | 42 | "template": "模板", |
| 43 | - "status": "状态", | ||
| 44 | - "lastEdited": "最后编辑", | ||
| 45 | - "keyword": "关键字", | ||
| 46 | - "selectProduct": "选择产品", | ||
| 47 | - "selectLocation": "选择门店", | ||
| 48 | - "selectCategory": "选择标签分类", | ||
| 49 | - "selectType": "选择标签类型", | ||
| 50 | - "selectTypeOptional": "可选,选择标签类型", | ||
| 51 | - "selectTemplate": "选择模板", | ||
| 52 | - "action": "操作", | 43 | + "status": "状态", |
| 44 | + "lastEdited": "最后编辑", | ||
| 45 | + "keyword": "关键字", | ||
| 46 | + "company": "公司", | ||
| 47 | + "applicableRegion": "适用区域", | ||
| 48 | + "selectProduct": "选择产品", | ||
| 49 | + "selectLocation": "选择门店", | ||
| 50 | + "selectCategory": "选择标签分类", | ||
| 51 | + "selectType": "选择标签类型", | ||
| 52 | + "selectTypeOptional": "可选,选择标签类型", | ||
| 53 | + "selectTemplate": "选择模板", | ||
| 54 | + "selectCompany": "选择公司", | ||
| 55 | + "selectCompanyFirst": "请先选择公司", | ||
| 56 | + "selectRegion": "选择区域", | ||
| 57 | + "selectCompanyRegionFirst": "请先选择公司和区域", | ||
| 58 | + "selectProductCategory": "选择产品分类", | ||
| 59 | + "companyRequired": "请选择公司。", | ||
| 60 | + "regionRequired": "请选择适用区域。", | ||
| 61 | + "productCategoryRequired": "请选择产品分类。", | ||
| 62 | + "productRequired": "请选择产品。", | ||
| 63 | + "action": "操作", | ||
| 53 | "labelCodeOptional": "留空则由后端生成", | 64 | "labelCodeOptional": "留空则由后端生成", |
| 54 | "deleteConfirm": "确认删除该标签吗?", | 65 | "deleteConfirm": "确认删除该标签吗?", |
| 55 | "bulkAdd": "批量新增", | 66 | "bulkAdd": "批量新增", |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/label-templates/data-entry/index.vue
| @@ -309,7 +309,7 @@ async function loadData() { | @@ -309,7 +309,7 @@ async function loadData() { | ||
| 309 | labelTypeList({ SkipCount: 1, MaxResultCount: 500 }), | 309 | labelTypeList({ SkipCount: 1, MaxResultCount: 500 }), |
| 310 | ]); | 310 | ]); |
| 311 | templateTitle.value = | 311 | templateTitle.value = |
| 312 | - (tpl.templateName ?? tpl.name ?? tpl.templateCode ?? tpl.id ?? '').trim() || templateCode.value; | 312 | + (tpl.name ?? tpl.templateName ?? tpl.templateCode ?? tpl.id ?? '').trim() || templateCode.value; |
| 313 | partners.value = partnerRes?.items ?? []; | 313 | partners.value = partnerRes?.items ?? []; |
| 314 | groups.value = groupRes?.items ?? []; | 314 | groups.value = groupRes?.items ?? []; |
| 315 | locations.value = locRes?.items ?? []; | 315 | locations.value = locRes?.items ?? []; |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/label-templates/editor/element-content.vue
| @@ -13,7 +13,18 @@ import { | @@ -13,7 +13,18 @@ import { | ||
| 13 | isPrintInputElement, | 13 | isPrintInputElement, |
| 14 | readLabelEditorFontFamilyChoice, | 14 | readLabelEditorFontFamilyChoice, |
| 15 | } from '../../../shared/label-template/label-template-model'; | 15 | } from '../../../shared/label-template/label-template-model'; |
| 16 | -import { elementRotationDegrees } from '../../../shared/text-element-layout'; | 16 | +import { |
| 17 | + elementRotationDegrees, | ||
| 18 | + readFontStyle, | ||
| 19 | + readFontWeight, | ||
| 20 | + readTextDecoration, | ||
| 21 | + readVerticalAlign, | ||
| 22 | +} from '../../../shared/text-element-layout'; | ||
| 23 | +import { | ||
| 24 | + INVERT_COLORS_BG, | ||
| 25 | + INVERT_COLORS_FG, | ||
| 26 | + readInvertColors, | ||
| 27 | +} from '../../../shared/invert-colors'; | ||
| 17 | import NutritionFactsPanel from './nutrition-facts-panel.vue'; | 28 | import NutritionFactsPanel from './nutrition-facts-panel.vue'; |
| 18 | import { | 29 | import { |
| 19 | normalizeBarcodeType, | 30 | normalizeBarcodeType, |
| @@ -38,15 +49,34 @@ const cfg = computed(() => (props.element.config ?? {}) as Record<string, unknow | @@ -38,15 +49,34 @@ const cfg = computed(() => (props.element.config ?? {}) as Record<string, unknow | ||
| 38 | const type = computed(() => canonicalElementType(props.element.type)); | 49 | const type = computed(() => canonicalElementType(props.element.type)); |
| 39 | const rotationDegrees = computed(() => elementRotationDegrees(props.element)); | 50 | const rotationDegrees = computed(() => elementRotationDegrees(props.element)); |
| 40 | const isVertical = computed(() => rotationDegrees.value === -90 || rotationDegrees.value === 90); | 51 | const isVertical = computed(() => rotationDegrees.value === -90 || rotationDegrees.value === 90); |
| 52 | +const inverted = computed(() => readInvertColors(cfg.value)); | ||
| 53 | + | ||
| 54 | +function verticalJustify(align: string): CSSProperties['justifyContent'] { | ||
| 55 | + if (align === 'center') return 'center'; | ||
| 56 | + if (align === 'bottom') return 'flex-end'; | ||
| 57 | + return 'flex-start'; | ||
| 58 | +} | ||
| 41 | 59 | ||
| 42 | const commonStyle = computed((): CSSProperties => ({ | 60 | const commonStyle = computed((): CSSProperties => ({ |
| 43 | fontSize: `${(cfg.value.fontSize as number) ?? 14}px`, | 61 | fontSize: `${(cfg.value.fontSize as number) ?? 14}px`, |
| 44 | - fontFamily: (cfg.value.fontFamily as string) ?? 'Arial', | ||
| 45 | - fontWeight: (cfg.value.fontWeight as string) ?? 'normal', | 62 | + fontFamily: readLabelEditorFontFamilyChoice(cfg.value), |
| 63 | + fontWeight: readFontWeight(cfg.value), | ||
| 64 | + fontStyle: readFontStyle(cfg.value), | ||
| 65 | + textDecoration: readTextDecoration(cfg.value), | ||
| 46 | textAlign: (cfg.value.textAlign as CSSProperties['textAlign']) ?? 'left', | 66 | textAlign: (cfg.value.textAlign as CSSProperties['textAlign']) ?? 'left', |
| 47 | - color: (cfg.value.color as string) ?? '#000', | 67 | + color: inverted.value ? INVERT_COLORS_FG : ((cfg.value.color as string) ?? '#000'), |
| 68 | + backgroundColor: inverted.value ? INVERT_COLORS_BG : undefined, | ||
| 69 | +})); | ||
| 70 | + | ||
| 71 | +const textBoxStyle = computed((): CSSProperties => ({ | ||
| 72 | + ...commonStyle.value, | ||
| 73 | + justifyContent: verticalJustify(readVerticalAlign(cfg.value)), | ||
| 48 | })); | 74 | })); |
| 49 | 75 | ||
| 76 | +const invertedInputClass = computed(() => | ||
| 77 | + inverted.value ? 'border-black bg-black text-white placeholder:text-gray-300' : '', | ||
| 78 | +); | ||
| 79 | + | ||
| 50 | const textRotationStyle = computed((): CSSProperties => { | 80 | const textRotationStyle = computed((): CSSProperties => { |
| 51 | const textLike = | 81 | const textLike = |
| 52 | type.value === 'TEXT_STATIC' || | 82 | type.value === 'TEXT_STATIC' || |
| @@ -298,7 +328,7 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | @@ -298,7 +328,7 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | ||
| 298 | <div | 328 | <div |
| 299 | v-if="isAppPrintField || isPrintInputElement(element)" | 329 | v-if="isAppPrintField || isPrintInputElement(element)" |
| 300 | class="flex h-full w-full flex-col justify-center overflow-hidden px-1 text-[11px] italic leading-tight text-gray-600 break-all" | 330 | class="flex h-full w-full flex-col justify-center overflow-hidden px-1 text-[11px] italic leading-tight text-gray-600 break-all" |
| 301 | - :style="{ ...commonStyle, ...textRotationStyle }" | 331 | + :style="{ ...textBoxStyle, ...textRotationStyle }" |
| 302 | > | 332 | > |
| 303 | {{ textStaticDisplay }} | 333 | {{ textStaticDisplay }} |
| 304 | </div> | 334 | </div> |
| @@ -307,7 +337,7 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | @@ -307,7 +337,7 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | ||
| 307 | type="number" | 337 | type="number" |
| 308 | readonly | 338 | readonly |
| 309 | class="pointer-events-none h-full w-full min-w-0 rounded border px-1" | 339 | class="pointer-events-none h-full w-full min-w-0 rounded border px-1" |
| 310 | - :class="inputSurfaceClass" | 340 | + :class="[inputSurfaceClass, invertedInputClass]" |
| 311 | :value="String(cfg.text ?? '0')" | 341 | :value="String(cfg.text ?? '0')" |
| 312 | :style="{ ...commonStyle, ...textRotationStyle, textAlign: 'right' }" | 342 | :style="{ ...commonStyle, ...textRotationStyle, textAlign: 'right' }" |
| 313 | /> | 343 | /> |
| @@ -316,15 +346,15 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | @@ -316,15 +346,15 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | ||
| 316 | type="text" | 346 | type="text" |
| 317 | readonly | 347 | readonly |
| 318 | class="pointer-events-none h-full w-full min-w-0 rounded border px-1" | 348 | class="pointer-events-none h-full w-full min-w-0 rounded border px-1" |
| 319 | - :class="inputSurfaceClass" | 349 | + :class="[inputSurfaceClass, invertedInputClass]" |
| 320 | :value="String(cfg.text ?? 'Text')" | 350 | :value="String(cfg.text ?? 'Text')" |
| 321 | :style="{ ...commonStyle, ...textRotationStyle }" | 351 | :style="{ ...commonStyle, ...textRotationStyle }" |
| 322 | /> | 352 | /> |
| 323 | <div | 353 | <div |
| 324 | v-else | 354 | v-else |
| 325 | - class="h-full w-full overflow-hidden whitespace-pre-wrap break-all px-1 leading-tight" | 355 | + class="flex h-full w-full flex-col overflow-hidden whitespace-pre-wrap break-all px-1 leading-tight" |
| 326 | :class="{ 'text-gray-400': cfg.inputType === 'options' && !(cfg.selectedOptionValues as string[] | undefined)?.length }" | 356 | :class="{ 'text-gray-400': cfg.inputType === 'options' && !(cfg.selectedOptionValues as string[] | undefined)?.length }" |
| 327 | - :style="{ ...commonStyle, ...textRotationStyle }" | 357 | + :style="{ ...textBoxStyle, ...textRotationStyle }" |
| 328 | > | 358 | > |
| 329 | {{ textStaticDisplay }} | 359 | {{ textStaticDisplay }} |
| 330 | </div> | 360 | </div> |
| @@ -333,8 +363,8 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | @@ -333,8 +363,8 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | ||
| 333 | <!-- TEXT_PRODUCT / TEXT_PRICE --> | 363 | <!-- TEXT_PRODUCT / TEXT_PRICE --> |
| 334 | <div | 364 | <div |
| 335 | v-else-if="type === 'TEXT_PRODUCT' || type === 'TEXT_PRICE'" | 365 | v-else-if="type === 'TEXT_PRODUCT' || type === 'TEXT_PRICE'" |
| 336 | - class="h-full w-full overflow-hidden whitespace-pre-wrap break-all px-1 leading-tight" | ||
| 337 | - :style="{ ...commonStyle, ...textRotationStyle }" | 366 | + class="flex h-full w-full flex-col overflow-hidden whitespace-pre-wrap break-all px-1 leading-tight" |
| 367 | + :style="{ ...textBoxStyle, ...textRotationStyle }" | ||
| 338 | > | 368 | > |
| 339 | {{ String(cfg.text ?? (type === 'TEXT_PRODUCT' ? 'Product name' : '0.00')) }} | 369 | {{ String(cfg.text ?? (type === 'TEXT_PRODUCT' ? 'Product name' : '0.00')) }} |
| 340 | </div> | 370 | </div> |
| @@ -403,7 +433,7 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | @@ -403,7 +433,7 @@ const nutritionFontFamily = computed(() => readLabelEditorFontFamilyChoice(cfg.v | ||
| 403 | readonly | 433 | readonly |
| 404 | value="2025-02-01" | 434 | value="2025-02-01" |
| 405 | class="pointer-events-none h-full w-full min-w-0 rounded border px-1 text-[10px]" | 435 | class="pointer-events-none h-full w-full min-w-0 rounded border px-1 text-[10px]" |
| 406 | - :class="inputSurfaceClass" | 436 | + :class="[inputSurfaceClass, invertedInputClass]" |
| 407 | :style="{ ...commonStyle, ...rotateBoxStyle }" | 437 | :style="{ ...commonStyle, ...rotateBoxStyle }" |
| 408 | /> | 438 | /> |
| 409 | <div v-else class="overflow-hidden whitespace-nowrap px-1" :style="{ ...commonStyle, ...rotateBoxStyle }"> | 439 | <div v-else class="overflow-hidden whitespace-nowrap px-1" :style="{ ...commonStyle, ...rotateBoxStyle }"> |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/label-templates/editor/elements-panel.vue
| @@ -108,43 +108,10 @@ const emit = defineEmits<{ | @@ -108,43 +108,10 @@ const emit = defineEmits<{ | ||
| 108 | openInstruction: []; | 108 | openInstruction: []; |
| 109 | }>(); | 109 | }>(); |
| 110 | 110 | ||
| 111 | -function sectionStyle(title: string): Record<string, string> { | ||
| 112 | - const t = title.trim().toLowerCase(); | ||
| 113 | - if (t === 'template') { | ||
| 114 | - return { | ||
| 115 | - backgroundColor: '#dbeafe', | ||
| 116 | - border: '1px solid #93c5fd', | ||
| 117 | - borderRadius: '8px', | ||
| 118 | - padding: '8px', | ||
| 119 | - }; | ||
| 120 | - } | ||
| 121 | - if (t === 'label') { | ||
| 122 | - return { | ||
| 123 | - backgroundColor: '#e0f2fe', | ||
| 124 | - border: '1px solid #7dd3fc', | ||
| 125 | - borderRadius: '8px', | ||
| 126 | - padding: '8px', | ||
| 127 | - }; | ||
| 128 | - } | ||
| 129 | - if (t === 'auto-generated') { | ||
| 130 | - return { | ||
| 131 | - backgroundColor: '#ede9fe', | ||
| 132 | - border: '1px solid #c4b5fd', | ||
| 133 | - borderRadius: '8px', | ||
| 134 | - padding: '8px', | ||
| 135 | - }; | ||
| 136 | - } | ||
| 137 | - if (t === 'print input') { | ||
| 138 | - return { | ||
| 139 | - backgroundColor: '#ffedd5', | ||
| 140 | - border: '1px solid #fdba74', | ||
| 141 | - borderRadius: '8px', | ||
| 142 | - padding: '8px', | ||
| 143 | - }; | ||
| 144 | - } | 111 | +function sectionStyle(): Record<string, string> { |
| 145 | return { | 112 | return { |
| 146 | - backgroundColor: '#f1f5f9', | ||
| 147 | - border: '1px solid #cbd5e1', | 113 | + backgroundColor: 'transparent', |
| 114 | + border: '1px solid #93c5fd', | ||
| 148 | borderRadius: '8px', | 115 | borderRadius: '8px', |
| 149 | padding: '8px', | 116 | padding: '8px', |
| 150 | }; | 117 | }; |
| @@ -154,28 +121,18 @@ function sectionStyle(title: string): Record<string, string> { | @@ -154,28 +121,18 @@ function sectionStyle(title: string): Record<string, string> { | ||
| 154 | <template> | 121 | <template> |
| 155 | <div class="h-full border-r border-slate-200 bg-slate-50"> | 122 | <div class="h-full border-r border-slate-200 bg-slate-50"> |
| 156 | <div | 123 | <div |
| 157 | - class="border-b border-slate-200 px-2 py-2 text-sm font-semibold text-slate-800" | ||
| 158 | - style="background-color: #eff6ff; border-bottom-color: #93c5fd" | 124 | + class="border-b border-[#93c5fd] bg-white px-2 py-2 text-sm font-semibold text-slate-800" |
| 159 | > | 125 | > |
| 160 | - <div class="flex items-center justify-between gap-2"> | ||
| 161 | - <span>{{ $t('foodLabeling.labelTemplates.elementsTitle') }}</span> | ||
| 162 | - <button | ||
| 163 | - type="button" | ||
| 164 | - class="text-xs font-normal text-blue-700 underline hover:text-blue-900" | ||
| 165 | - @click="emit('openInstruction')" | ||
| 166 | - > | ||
| 167 | - Instruction | ||
| 168 | - </button> | ||
| 169 | - </div> | 126 | + {{ $t('foodLabeling.labelTemplates.elementsTitle') }} |
| 170 | </div> | 127 | </div> |
| 171 | <div class="space-y-3 p-2"> | 128 | <div class="space-y-3 p-2"> |
| 172 | <div | 129 | <div |
| 173 | v-for="cat in ELEMENT_CATEGORIES" | 130 | v-for="cat in ELEMENT_CATEGORIES" |
| 174 | :key="cat.title" | 131 | :key="cat.title" |
| 175 | - :style="sectionStyle(cat.title)" | 132 | + :style="sectionStyle()" |
| 176 | > | 133 | > |
| 177 | <div | 134 | <div |
| 178 | - class="px-2 py-1 text-xs font-medium uppercase tracking-wide text-gray-600" | 135 | + class="px-2 py-1 text-xs font-semibold leading-snug text-gray-700" |
| 179 | > | 136 | > |
| 180 | {{ elementLibraryCategoryPanelTitle(cat.title) }} | 137 | {{ elementLibraryCategoryPanelTitle(cat.title) }} |
| 181 | </div> | 138 | </div> |
| @@ -187,14 +144,26 @@ function sectionStyle(title: string): Record<string, string> { | @@ -187,14 +144,26 @@ function sectionStyle(title: string): Record<string, string> { | ||
| 187 | v-for="(item, i) in cat.items" | 144 | v-for="(item, i) in cat.items" |
| 188 | :key="`${cat.title}-${item.label}-${i}`" | 145 | :key="`${cat.title}-${item.label}-${i}`" |
| 189 | type="button" | 146 | type="button" |
| 190 | - class="items-start justify-start whitespace-normal break-words rounded border border-transparent px-2 py-1.5 text-left text-xs leading-snug hover:border-gray-200 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40" | 147 | + :class="item.disabled === true |
| 148 | + ? 'items-start justify-start whitespace-normal break-words rounded border border-transparent bg-gray-100/70 px-2 py-1.5 text-left text-xs leading-snug text-gray-400 opacity-60 disabled:cursor-not-allowed' | ||
| 149 | + : 'items-start justify-start whitespace-normal break-words rounded border border-transparent px-2 py-1.5 text-left text-xs leading-snug hover:border-gray-200 hover:bg-gray-100'" | ||
| 191 | :disabled="item.disabled === true" | 150 | :disabled="item.disabled === true" |
| 151 | + :title="item.disabled === true ? 'Not available in the US version' : undefined" | ||
| 192 | @click="emit('addElement', item.type, item.config, cat.title, item.label)" | 152 | @click="emit('addElement', item.type, item.config, cat.title, item.label)" |
| 193 | > | 153 | > |
| 194 | {{ item.label }} | 154 | {{ item.label }} |
| 195 | </button> | 155 | </button> |
| 196 | </div> | 156 | </div> |
| 197 | </div> | 157 | </div> |
| 158 | + <div :style="sectionStyle()"> | ||
| 159 | + <button | ||
| 160 | + type="button" | ||
| 161 | + class="w-full rounded px-2 py-1.5 text-left text-xs font-medium text-gray-900 hover:bg-gray-100" | ||
| 162 | + @click="emit('openInstruction')" | ||
| 163 | + > | ||
| 164 | + Instruction | ||
| 165 | + </button> | ||
| 166 | + </div> | ||
| 198 | </div> | 167 | </div> |
| 199 | </div> | 168 | </div> |
| 200 | </template> | 169 | </template> |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/label-templates/editor/index.vue
| @@ -109,6 +109,16 @@ const printOrientation = computed( | @@ -109,6 +109,16 @@ const printOrientation = computed( | ||
| 109 | () => normalizePrintOrientation(template.value.printOrientation), | 109 | () => normalizePrintOrientation(template.value.printOrientation), |
| 110 | ); | 110 | ); |
| 111 | const templateBorder = computed(() => template.value.border ?? 'none'); | 111 | const templateBorder = computed(() => template.value.border ?? 'none'); |
| 112 | +const configRowClass = 'flex min-w-0 flex-wrap items-center gap-2'; | ||
| 113 | +const templateFieldClass = | ||
| 114 | + 'flex h-8 min-w-0 items-stretch overflow-hidden rounded-md border border-gray-300 bg-white'; | ||
| 115 | +const templateFieldLabelClass = | ||
| 116 | + 'flex shrink-0 items-center border-r border-gray-300 bg-gray-100 px-2 text-xs font-medium text-gray-700 whitespace-nowrap'; | ||
| 117 | +const templateFieldControlClass = 'flex min-h-0 min-w-0 flex-1 items-center'; | ||
| 118 | +const templateFieldInputClass = | ||
| 119 | + 'h-full min-h-0 w-full min-w-0 border-0 bg-transparent px-2 text-xs shadow-none'; | ||
| 120 | +const templateFieldSuffixClass = | ||
| 121 | + 'flex shrink-0 items-center border-l border-gray-300 bg-gray-50 px-2 text-xs text-gray-500'; | ||
| 112 | 122 | ||
| 113 | const selectedElement = computed(() => { | 123 | const selectedElement = computed(() => { |
| 114 | const el = template.value.elements.find((item) => item.id === selectedId.value) ?? null; | 124 | const el = template.value.elements.find((item) => item.id === selectedId.value) ?? null; |
| @@ -453,7 +463,8 @@ function updateElement(id: string, patch: Partial<LabelElement>) { | @@ -453,7 +463,8 @@ function updateElement(id: string, patch: Partial<LabelElement>) { | ||
| 453 | patch.height !== undefined || | 463 | patch.height !== undefined || |
| 454 | patch.rotation !== undefined; | 464 | patch.rotation !== undefined; |
| 455 | if (!geomTouched) return merged; | 465 | if (!geomTouched) return merged; |
| 456 | - if (readElementRotation(merged) === 'vertical' && merged.width > merged.height) { | 466 | + const mergedRotation = readElementRotation(merged); |
| 467 | + if ((mergedRotation === 'vertical' || mergedRotation === 'right') && merged.width > merged.height) { | ||
| 457 | merged = canonicalElementGeometry(merged); | 468 | merged = canonicalElementGeometry(merged); |
| 458 | } | 469 | } |
| 459 | const c = clampLabelElementBox( | 470 | const c = clampLabelElementBox( |
| @@ -664,138 +675,177 @@ function goBack() { | @@ -664,138 +675,177 @@ function goBack() { | ||
| 664 | <!-- Top form --> | 675 | <!-- Top form --> |
| 665 | <div class="shrink-0 border-b border-[#cfd9ea] bg-[#dde7f5] px-4 py-2"> | 676 | <div class="shrink-0 border-b border-[#cfd9ea] bg-[#dde7f5] px-4 py-2"> |
| 666 | <div class="rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-2"> | 677 | <div class="rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-2"> |
| 667 | - <div class="grid grid-cols-1 gap-2 md:grid-cols-3"> | ||
| 668 | - <div class="space-y-1"> | ||
| 669 | - <label class="text-[11px] font-semibold leading-tight text-[#1d3c8f]"> | ||
| 670 | - {{ $t('foodLabeling.labelTemplates.templateName') }} | ||
| 671 | - </label> | ||
| 672 | - <Input | ||
| 673 | - size="small" | ||
| 674 | - :value="template.name" | ||
| 675 | - @update:value="(v) => handleTemplateChange({ name: String(v) })" | ||
| 676 | - /> | ||
| 677 | - </div> | 678 | + <div class="flex flex-col gap-2"> |
| 679 | + <div :class="configRowClass"> | ||
| 680 | + <div :class="[templateFieldClass, 'min-w-[10rem] max-w-sm flex-[1_1_12rem]']"> | ||
| 681 | + <span :class="templateFieldLabelClass">Name:</span> | ||
| 682 | + <div :class="templateFieldControlClass"> | ||
| 683 | + <Input | ||
| 684 | + size="small" | ||
| 685 | + :class="templateFieldInputClass" | ||
| 686 | + :bordered="false" | ||
| 687 | + :value="template.name" | ||
| 688 | + placeholder="Enter template name" | ||
| 689 | + @update:value="(v) => handleTemplateChange({ name: String(v) })" | ||
| 690 | + /> | ||
| 691 | + </div> | ||
| 692 | + </div> | ||
| 678 | 693 | ||
| 679 | - <div class="space-y-1 md:col-span-2"> | ||
| 680 | - <label class="text-[11px] font-semibold leading-tight text-[#1d3c8f]"> | ||
| 681 | - {{ $t('foodLabeling.labelTemplates.ruler') }} | ||
| 682 | - </label> | ||
| 683 | - <div class="flex flex-wrap items-center gap-1.5"> | ||
| 684 | - <Select | ||
| 685 | - size="small" | ||
| 686 | - class="w-[72px]" | ||
| 687 | - :value="template.unit" | ||
| 688 | - @update:value="(v) => handleTemplateChange({ unit: v as 'cm' | 'inch', showRuler: true })" | ||
| 689 | - > | ||
| 690 | - <Select.Option value="inch">inch</Select.Option> | ||
| 691 | - <Select.Option value="cm">cm</Select.Option> | ||
| 692 | - </Select> | ||
| 693 | - <span class="text-[11px] font-semibold text-[#1d3c8f]">W</span> | ||
| 694 | - <InputNumber | ||
| 695 | - size="small" | ||
| 696 | - class="w-[72px]" | ||
| 697 | - :min="0.1" | ||
| 698 | - :value="template.width" | ||
| 699 | - @update:value="(v) => handleTemplateChange({ width: Math.max(0.1, Number(v) || 0), showRuler: true })" | ||
| 700 | - /> | ||
| 701 | - <span class="text-[11px] font-semibold text-[#1d3c8f]">H</span> | ||
| 702 | - <InputNumber | ||
| 703 | - size="small" | ||
| 704 | - class="w-[72px]" | ||
| 705 | - :min="0.1" | ||
| 706 | - :value="template.height" | ||
| 707 | - @update:value="(v) => handleTemplateChange({ height: Math.max(0.1, Number(v) || 0), showRuler: true })" | ||
| 708 | - /> | ||
| 709 | - <Select size="small" class="w-[118px]" :value="presetIndex()" @update:value="onPresetChange"> | ||
| 710 | - <Select.Option v-for="(p, i) in PRESET_LABEL_SIZES" :key="i" :value="String(i)"> | ||
| 711 | - {{ p.name }} | ||
| 712 | - </Select.Option> | ||
| 713 | - <Select.Option value="custom">Custom</Select.Option> | ||
| 714 | - </Select> | 694 | + <div :class="[templateFieldClass, 'w-[6.75rem] shrink-0']"> |
| 695 | + <span :class="templateFieldLabelClass">Unit:</span> | ||
| 696 | + <div :class="templateFieldControlClass"> | ||
| 697 | + <Select | ||
| 698 | + size="small" | ||
| 699 | + class="h-full w-full [&_.ant-select-selector]:!h-full [&_.ant-select-selector]:!border-0 [&_.ant-select-selector]:!bg-transparent [&_.ant-select-selection-item]:!text-xs" | ||
| 700 | + :value="template.unit" | ||
| 701 | + @update:value="(v) => handleTemplateChange({ unit: v as 'cm' | 'inch', showRuler: true })" | ||
| 702 | + > | ||
| 703 | + <Select.Option value="inch">Inch</Select.Option> | ||
| 704 | + <Select.Option value="cm">cm</Select.Option> | ||
| 705 | + </Select> | ||
| 706 | + </div> | ||
| 715 | </div> | 707 | </div> |
| 716 | - </div> | ||
| 717 | 708 | ||
| 718 | - <div class="space-y-1"> | ||
| 719 | - <label class="text-[11px] font-semibold leading-tight text-[#1d3c8f]"> | ||
| 720 | - {{ $t('foodLabeling.labelTemplates.starterTemplate') }} | ||
| 721 | - </label> | ||
| 722 | - <Select | ||
| 723 | - v-if="!isEdit" | ||
| 724 | - size="small" | ||
| 725 | - class="w-full" | ||
| 726 | - :loading="loadingStarter" | ||
| 727 | - :value="selectedStarterCode" | ||
| 728 | - @update:value="(v) => (selectedStarterCode = String(v))" | ||
| 729 | - > | ||
| 730 | - <Select.Option v-for="op in starterOptions" :key="op.code" :value="op.code"> | ||
| 731 | - {{ op.name }} | ||
| 732 | - </Select.Option> | ||
| 733 | - </Select> | ||
| 734 | - <Input v-else size="small" disabled :value="$t('foodLabeling.labelTemplates.currentTemplate')" /> | ||
| 735 | - </div> | 709 | + <div :class="[templateFieldClass, 'w-[5.25rem] shrink-0']"> |
| 710 | + <span :class="templateFieldLabelClass">W:</span> | ||
| 711 | + <div :class="templateFieldControlClass"> | ||
| 712 | + <InputNumber | ||
| 713 | + size="small" | ||
| 714 | + class="h-full w-full text-center [&_.ant-input-number-input]:!h-full [&_.ant-input-number-input]:!px-1 [&_.ant-input-number-input]:!text-center [&_.ant-input-number-input-wrap]:!h-full" | ||
| 715 | + :bordered="false" | ||
| 716 | + :controls="false" | ||
| 717 | + :min="0.1" | ||
| 718 | + :value="template.width" | ||
| 719 | + @update:value="(v) => handleTemplateChange({ width: Math.max(0.1, Number(v) || 0), showRuler: true })" | ||
| 720 | + /> | ||
| 721 | + </div> | ||
| 722 | + <span :class="templateFieldSuffixClass">{{ template.unit === 'inch' ? 'in' : 'cm' }}</span> | ||
| 723 | + </div> | ||
| 736 | 724 | ||
| 737 | - <div class="space-y-1"> | ||
| 738 | - <label class="text-[11px] font-semibold leading-tight text-[#1d3c8f]"> | ||
| 739 | - {{ $t('foodLabeling.labelTemplates.border') }} | ||
| 740 | - </label> | ||
| 741 | - <Select | ||
| 742 | - size="small" | ||
| 743 | - class="w-full" | ||
| 744 | - :value="templateBorder" | ||
| 745 | - @update:value="(v) => handleTemplateChange({ border: v as Border })" | ||
| 746 | - > | ||
| 747 | - <Select.Option value="none">none</Select.Option> | ||
| 748 | - <Select.Option value="line">line</Select.Option> | ||
| 749 | - <Select.Option value="dotted">dotted</Select.Option> | ||
| 750 | - </Select> | ||
| 751 | - </div> | 725 | + <div :class="[templateFieldClass, 'w-[5.25rem] shrink-0']"> |
| 726 | + <span :class="templateFieldLabelClass">H:</span> | ||
| 727 | + <div :class="templateFieldControlClass"> | ||
| 728 | + <InputNumber | ||
| 729 | + size="small" | ||
| 730 | + class="h-full w-full text-center [&_.ant-input-number-input]:!h-full [&_.ant-input-number-input]:!px-1 [&_.ant-input-number-input]:!text-center [&_.ant-input-number-input-wrap]:!h-full" | ||
| 731 | + :bordered="false" | ||
| 732 | + :controls="false" | ||
| 733 | + :min="0.1" | ||
| 734 | + :value="template.height" | ||
| 735 | + @update:value="(v) => handleTemplateChange({ height: Math.max(0.1, Number(v) || 0), showRuler: true })" | ||
| 736 | + /> | ||
| 737 | + </div> | ||
| 738 | + <span :class="templateFieldSuffixClass">{{ template.unit === 'inch' ? 'in' : 'cm' }}</span> | ||
| 739 | + </div> | ||
| 752 | 740 | ||
| 753 | - <div class="space-y-1"> | ||
| 754 | - <label class="text-[11px] font-semibold leading-tight text-[#1d3c8f]"> | ||
| 755 | - {{ $t('foodLabeling.labelTemplates.rotation') }} | ||
| 756 | - </label> | ||
| 757 | - <Select | ||
| 758 | - size="small" | ||
| 759 | - class="w-full" | ||
| 760 | - :value="printOrientation" | ||
| 761 | - @update:value="(v) => onPrintOrientationChange(v as PrintOrientation)" | ||
| 762 | - > | ||
| 763 | - <Select.Option value="horizontal">{{ $t('foodLabeling.labelTemplates.horizontal') }}</Select.Option> | ||
| 764 | - <Select.Option value="vertical">{{ $t('foodLabeling.labelTemplates.vertical') }}</Select.Option> | ||
| 765 | - </Select> | 741 | + <div :class="[templateFieldClass, 'w-[8.5rem] shrink-0']"> |
| 742 | + <span :class="templateFieldLabelClass">Size Preset:</span> | ||
| 743 | + <div :class="templateFieldControlClass"> | ||
| 744 | + <Select | ||
| 745 | + size="small" | ||
| 746 | + class="h-full w-full [&_.ant-select-selector]:!h-full [&_.ant-select-selector]:!border-0 [&_.ant-select-selector]:!bg-transparent [&_.ant-select-selection-item]:!text-xs" | ||
| 747 | + :value="presetIndex()" | ||
| 748 | + @update:value="onPresetChange" | ||
| 749 | + > | ||
| 750 | + <Select.Option v-for="(p, i) in PRESET_LABEL_SIZES" :key="i" :value="String(i)"> | ||
| 751 | + {{ p.name }} | ||
| 752 | + </Select.Option> | ||
| 753 | + <Select.Option value="custom">Custom</Select.Option> | ||
| 754 | + </Select> | ||
| 755 | + </div> | ||
| 756 | + </div> | ||
| 757 | + | ||
| 758 | + <div :class="[templateFieldClass, 'min-w-[9rem] flex-[1_1_10rem]']"> | ||
| 759 | + <span :class="templateFieldLabelClass">Starter Template:</span> | ||
| 760 | + <div :class="templateFieldControlClass"> | ||
| 761 | + <Select | ||
| 762 | + v-if="!isEdit" | ||
| 763 | + size="small" | ||
| 764 | + class="h-full w-full [&_.ant-select-selector]:!h-full [&_.ant-select-selector]:!border-0 [&_.ant-select-selector]:!bg-transparent [&_.ant-select-selection-item]:!text-xs" | ||
| 765 | + :loading="loadingStarter" | ||
| 766 | + :value="selectedStarterCode" | ||
| 767 | + @update:value="(v) => (selectedStarterCode = String(v))" | ||
| 768 | + > | ||
| 769 | + <Select.Option v-for="op in starterOptions" :key="op.code" :value="op.code"> | ||
| 770 | + {{ op.name }} | ||
| 771 | + </Select.Option> | ||
| 772 | + </Select> | ||
| 773 | + <Input | ||
| 774 | + v-else | ||
| 775 | + size="small" | ||
| 776 | + disabled | ||
| 777 | + :class="templateFieldInputClass" | ||
| 778 | + :bordered="false" | ||
| 779 | + :value="$t('foodLabeling.labelTemplates.currentTemplate')" | ||
| 780 | + /> | ||
| 781 | + </div> | ||
| 782 | + </div> | ||
| 783 | + | ||
| 784 | + <div :class="[templateFieldClass, 'w-[7.5rem] shrink-0']"> | ||
| 785 | + <span :class="templateFieldLabelClass">Border:</span> | ||
| 786 | + <div :class="templateFieldControlClass"> | ||
| 787 | + <Select | ||
| 788 | + size="small" | ||
| 789 | + class="h-full w-full [&_.ant-select-selector]:!h-full [&_.ant-select-selector]:!border-0 [&_.ant-select-selector]:!bg-transparent [&_.ant-select-selection-item]:!text-xs" | ||
| 790 | + :value="templateBorder" | ||
| 791 | + @update:value="(v) => handleTemplateChange({ border: v as Border })" | ||
| 792 | + > | ||
| 793 | + <Select.Option value="none">none</Select.Option> | ||
| 794 | + <Select.Option value="line">line</Select.Option> | ||
| 795 | + <Select.Option value="dotted">dotted</Select.Option> | ||
| 796 | + </Select> | ||
| 797 | + </div> | ||
| 798 | + </div> | ||
| 766 | </div> | 799 | </div> |
| 767 | 800 | ||
| 768 | - <div v-if="!isEdit" class="space-y-1"> | ||
| 769 | - <label class="text-[11px] font-semibold leading-tight text-[#1d3c8f]"> | ||
| 770 | - {{ $t('foodLabeling.labelTemplates.templateCode') }} | ||
| 771 | - </label> | ||
| 772 | - <Input | ||
| 773 | - size="small" | ||
| 774 | - :value="template.id" | ||
| 775 | - @update:value="(v) => handleTemplateChange({ id: String(v).trim() })" | 801 | + <div :class="[configRowClass, 'flex-nowrap']"> |
| 802 | + <div :class="[templateFieldClass, 'w-[8.5rem] shrink-0']"> | ||
| 803 | + <span :class="templateFieldLabelClass">Rotation:</span> | ||
| 804 | + <div :class="templateFieldControlClass"> | ||
| 805 | + <Select | ||
| 806 | + size="small" | ||
| 807 | + class="h-full w-full [&_.ant-select-selector]:!h-full [&_.ant-select-selector]:!border-0 [&_.ant-select-selector]:!bg-transparent [&_.ant-select-selection-item]:!text-xs" | ||
| 808 | + :value="printOrientation" | ||
| 809 | + @update:value="(v) => onPrintOrientationChange(v as PrintOrientation)" | ||
| 810 | + > | ||
| 811 | + <Select.Option value="horizontal">horizontal</Select.Option> | ||
| 812 | + <Select.Option value="vertical">vertical</Select.Option> | ||
| 813 | + </Select> | ||
| 814 | + </div> | ||
| 815 | + </div> | ||
| 816 | + | ||
| 817 | + <div v-if="!isEdit" :class="[templateFieldClass, 'w-[11rem] shrink-0']"> | ||
| 818 | + <span :class="templateFieldLabelClass">Template Code:</span> | ||
| 819 | + <div :class="templateFieldControlClass"> | ||
| 820 | + <Input | ||
| 821 | + size="small" | ||
| 822 | + :class="templateFieldInputClass" | ||
| 823 | + :bordered="false" | ||
| 824 | + :value="template.id" | ||
| 825 | + @update:value="(v) => handleTemplateChange({ id: String(v).trim() })" | ||
| 826 | + /> | ||
| 827 | + </div> | ||
| 828 | + </div> | ||
| 829 | + | ||
| 830 | + <span | ||
| 831 | + v-if="scopeCatalogLoading" | ||
| 832 | + class="min-w-0 flex-1 text-[11px] leading-tight text-[#1d3c8f]" | ||
| 833 | + > | ||
| 834 | + Loading company, region and location... | ||
| 835 | + </span> | ||
| 836 | + <TemplateScopeFields | ||
| 837 | + v-else | ||
| 838 | + :partners="partners" | ||
| 839 | + :groups="groups" | ||
| 840 | + :locations="locations" | ||
| 841 | + :require-company-selection="scopeAuth.requireCompanySelection" | ||
| 842 | + :fixed-partner-id="scopeAuth.fixedPartnerId" | ||
| 843 | + v-model:selected-partner-ids="scopePartnerIds" | ||
| 844 | + v-model:selected-region-ids="scopeRegionIds" | ||
| 845 | + v-model:selected-location-ids="scopeLocationIds" | ||
| 776 | /> | 846 | /> |
| 777 | </div> | 847 | </div> |
| 778 | </div> | 848 | </div> |
| 779 | - | ||
| 780 | - <div class="mt-2 flex flex-wrap items-end gap-2 border-t border-[#c2d1e8] pt-2"> | ||
| 781 | - <span | ||
| 782 | - v-if="scopeCatalogLoading" | ||
| 783 | - class="text-[11px] leading-tight text-[#1d3c8f]" | ||
| 784 | - > | ||
| 785 | - Loading company, region and location… | ||
| 786 | - </span> | ||
| 787 | - <TemplateScopeFields | ||
| 788 | - v-else | ||
| 789 | - :partners="partners" | ||
| 790 | - :groups="groups" | ||
| 791 | - :locations="locations" | ||
| 792 | - :require-company-selection="scopeAuth.requireCompanySelection" | ||
| 793 | - :fixed-partner-id="scopeAuth.fixedPartnerId" | ||
| 794 | - v-model:selected-partner-ids="scopePartnerIds" | ||
| 795 | - v-model:selected-region-ids="scopeRegionIds" | ||
| 796 | - v-model:selected-location-ids="scopeLocationIds" | ||
| 797 | - /> | ||
| 798 | - </div> | ||
| 799 | </div> | 849 | </div> |
| 800 | </div> | 850 | </div> |
| 801 | 851 |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/label-templates/editor/label-canvas.vue
| 1 | -<script lang="ts" setup> | 1 | +<script lang="ts" setup> |
| 2 | import type { Border, LabelElement, LabelTemplate, PrintOrientation } from '../../../shared/label-template/label-template-model'; | 2 | import type { Border, LabelElement, LabelTemplate, PrintOrientation } from '../../../shared/label-template/label-template-model'; |
| 3 | 3 | ||
| 4 | import { computed, onMounted, onUnmounted, ref, watch } from 'vue'; | 4 | import { computed, onMounted, onUnmounted, ref, watch } from 'vue'; |
| @@ -11,6 +11,7 @@ import type { LabelElementLivePatch } from '../../../shared/label-element-live-p | @@ -11,6 +11,7 @@ import type { LabelElementLivePatch } from '../../../shared/label-element-live-p | ||
| 11 | import { mergeLabelElementLivePatch } from '../../../shared/label-element-live-patch'; | 11 | import { mergeLabelElementLivePatch } from '../../../shared/label-element-live-patch'; |
| 12 | import type { PreviewRulerDisplayUnit } from '../../../shared/preview-ruler-units'; | 12 | import type { PreviewRulerDisplayUnit } from '../../../shared/preview-ruler-units'; |
| 13 | import { mapPointerDeltaToTemplateSpace, printContentLayerStyle, computeResizedElementBox } from '../../../shared/print-orientation'; | 13 | import { mapPointerDeltaToTemplateSpace, printContentLayerStyle, computeResizedElementBox } from '../../../shared/print-orientation'; |
| 14 | +import { elementRotationDegrees } from '../../../shared/text-element-layout'; | ||
| 14 | import AvailableElementsPanel from './available-elements-panel.vue'; | 15 | import AvailableElementsPanel from './available-elements-panel.vue'; |
| 15 | import ElementContent from './element-content.vue'; | 16 | import ElementContent from './element-content.vue'; |
| 16 | import RulerBarHorizontal from './ruler-bar-horizontal.vue'; | 17 | import RulerBarHorizontal from './ruler-bar-horizontal.vue'; |
| @@ -143,6 +144,10 @@ function resizeHandlesFor(el: LabelElement) { | @@ -143,6 +144,10 @@ function resizeHandlesFor(el: LabelElement) { | ||
| 143 | return elementResizeHandlesForBox(merged.width, merged.height, merged.rotation); | 144 | return elementResizeHandlesForBox(merged.width, merged.height, merged.rotation); |
| 144 | } | 145 | } |
| 145 | 146 | ||
| 147 | +function shouldAllowElementOverflow(el: LabelElement): boolean { | ||
| 148 | + return elementRotationDegrees(mergeElement(el)) !== 0; | ||
| 149 | +} | ||
| 150 | + | ||
| 146 | function resizeHandleStyle( | 151 | function resizeHandleStyle( |
| 147 | handle: ReturnType<typeof elementResizeHandlesForBox>[number], | 152 | handle: ReturnType<typeof elementResizeHandlesForBox>[number], |
| 148 | w: number, | 153 | w: number, |
| @@ -178,7 +183,7 @@ const showSafeMarginGuide = computed( | @@ -178,7 +183,7 @@ const showSafeMarginGuide = computed( | ||
| 178 | baseH.value > LABEL_CANVAS_SAFE_MARGIN_PX * 2, | 183 | baseH.value > LABEL_CANVAS_SAFE_MARGIN_PX * 2, |
| 179 | ); | 184 | ); |
| 180 | 185 | ||
| 181 | -/** 与美国版一致:安全区描边色、线宽、虚线 */ | 186 | +/** 涓庣編鍥界増涓€鑷达細瀹夊叏鍖烘弿杈硅壊銆佺嚎瀹姐€佽櫄绾?*/ |
| 182 | const SAFE_MARGIN_STROKE = '#2563eb'; | 187 | const SAFE_MARGIN_STROKE = '#2563eb'; |
| 183 | const SAFE_MARGIN_STROKE_WIDTH = 2; | 188 | const SAFE_MARGIN_STROKE_WIDTH = 2; |
| 184 | const SAFE_MARGIN_DASH = '10 6'; | 189 | const SAFE_MARGIN_DASH = '10 6'; |
| @@ -233,7 +238,7 @@ function applyElementDragVisual(id: string) { | @@ -233,7 +238,7 @@ function applyElementDragVisual(id: string) { | ||
| 233 | domEl.style.cursor = 'grabbing'; | 238 | domEl.style.cursor = 'grabbing'; |
| 234 | } | 239 | } |
| 235 | 240 | ||
| 236 | -/** 仅点击画布空白处时取消选中(避免元素 click 冒泡清空右侧属性) */ | 241 | +/** 浠呯偣鍑荤敾甯冪┖鐧藉鏃跺彇娑堥€変腑锛堥伩鍏嶅厓绱?click 鍐掓场娓呯┖鍙充晶灞炴€э級 */ |
| 237 | function onCanvasClick(e: MouseEvent) { | 242 | function onCanvasClick(e: MouseEvent) { |
| 238 | if (props.previewOnly) return; | 243 | if (props.previewOnly) return; |
| 239 | const target = e.target as HTMLElement; | 244 | const target = e.target as HTMLElement; |
| @@ -512,13 +517,62 @@ onUnmounted(() => { | @@ -512,13 +517,62 @@ onUnmounted(() => { | ||
| 512 | v-if="!hideToolbar && !previewOnly" | 517 | v-if="!hideToolbar && !previewOnly" |
| 513 | class="z-10 flex min-h-[44px] shrink-0 flex-nowrap items-center justify-between gap-3 border-b border-gray-200 bg-white px-4 py-2" | 518 | class="z-10 flex min-h-[44px] shrink-0 flex-nowrap items-center justify-between gap-3 border-b border-gray-200 bg-white px-4 py-2" |
| 514 | > | 519 | > |
| 515 | - <span class="min-w-0 shrink-0 truncate text-sm font-medium text-gray-700"> | ||
| 516 | - {{ $t('foodLabeling.labelTemplates.labelPreview') }} | ||
| 517 | - </span> | ||
| 518 | - <div class="flex min-w-0 shrink-0 flex-nowrap items-center justify-end gap-2"> | ||
| 519 | - <a-button size="small" @click="availableElementsOpen = !availableElementsOpen"> | 520 | + <div class="flex min-w-0 shrink-0 flex-nowrap items-center gap-2"> |
| 521 | + <span class="min-w-0 shrink-0 truncate text-sm font-medium text-gray-700"> | ||
| 522 | + {{ $t('foodLabeling.labelTemplates.labelPreview') }} | ||
| 523 | + </span> | ||
| 524 | + <button | ||
| 525 | + type="button" | ||
| 526 | + :class="[ | ||
| 527 | + 'h-8 shrink-0 rounded border px-3 text-xs font-medium shadow-sm transition-all active:scale-95', | ||
| 528 | + availableElementsOpen | ||
| 529 | + ? 'border-blue-300 bg-blue-50 text-blue-800 hover:bg-blue-100' | ||
| 530 | + : 'border-gray-300 bg-white text-gray-700 hover:bg-gray-50', | ||
| 531 | + ]" | ||
| 532 | + @click="availableElementsOpen = !availableElementsOpen" | ||
| 533 | + > | ||
| 520 | Available Elements | 534 | Available Elements |
| 521 | - </a-button> | 535 | + </button> |
| 536 | + </div> | ||
| 537 | + <div class="flex min-w-0 shrink-0 flex-nowrap items-center justify-end gap-2"> | ||
| 538 | + <div class="flex shrink-0 items-center gap-1" role="group" aria-label="Print orientation"> | ||
| 539 | + <button | ||
| 540 | + type="button" | ||
| 541 | + title="Landscape" | ||
| 542 | + aria-label="Landscape" | ||
| 543 | + :aria-pressed="printOrientation === 'horizontal'" | ||
| 544 | + :class="[ | ||
| 545 | + 'flex h-8 w-8 shrink-0 items-center justify-center rounded border shadow-sm transition-colors active:scale-95', | ||
| 546 | + printOrientation === 'horizontal' | ||
| 547 | + ? 'border-blue-600 bg-blue-600 text-white' | ||
| 548 | + : 'border-gray-300 bg-white text-gray-800 hover:bg-gray-50', | ||
| 549 | + ]" | ||
| 550 | + @click="emit('printOrientationChange', 'horizontal')" | ||
| 551 | + > | ||
| 552 | + <svg width="18" height="14" viewBox="0 0 18 14" aria-hidden="true" class="block"> | ||
| 553 | + <rect x="1" y="3" width="16" height="8" rx="1" fill="none" stroke="currentColor" stroke-width="1.25" /> | ||
| 554 | + <path d="M5 7h8M11 5.5l1.5 1.5L11 8.5M7 5.5L5.5 7 7 8.5" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round" /> | ||
| 555 | + </svg> | ||
| 556 | + </button> | ||
| 557 | + <button | ||
| 558 | + type="button" | ||
| 559 | + title="Portrait" | ||
| 560 | + aria-label="Portrait" | ||
| 561 | + :aria-pressed="printOrientation === 'vertical'" | ||
| 562 | + :class="[ | ||
| 563 | + 'flex h-8 w-8 shrink-0 items-center justify-center rounded border shadow-sm transition-colors active:scale-95', | ||
| 564 | + printOrientation === 'vertical' | ||
| 565 | + ? 'border-blue-600 bg-blue-600 text-white' | ||
| 566 | + : 'border-gray-300 bg-white text-gray-800 hover:bg-gray-50', | ||
| 567 | + ]" | ||
| 568 | + @click="emit('printOrientationChange', 'vertical')" | ||
| 569 | + > | ||
| 570 | + <svg width="14" height="18" viewBox="0 0 14 18" aria-hidden="true" class="block"> | ||
| 571 | + <rect x="3" y="1" width="8" height="16" rx="1" fill="none" stroke="currentColor" stroke-width="1.25" /> | ||
| 572 | + <path d="M7 5v8M5.5 11l1.5 1.5 1.5-1.5M5.5 7l1.5-1.5 1.5 1.5" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round" /> | ||
| 573 | + </svg> | ||
| 574 | + </button> | ||
| 575 | + </div> | ||
| 522 | <a-button size="small" @click="emit('preview')"> | 576 | <a-button size="small" @click="emit('preview')"> |
| 523 | {{ $t('foodLabeling.labelTemplates.preview') }} | 577 | {{ $t('foodLabeling.labelTemplates.preview') }} |
| 524 | </a-button> | 578 | </a-button> |
| @@ -531,7 +585,7 @@ onUnmounted(() => { | @@ -531,7 +585,7 @@ onUnmounted(() => { | ||
| 531 | class="flex h-6 w-6 items-center justify-center rounded text-sm font-medium text-gray-600 hover:bg-gray-100" | 585 | class="flex h-6 w-6 items-center justify-center rounded text-sm font-medium text-gray-600 hover:bg-gray-100" |
| 532 | @click="emit('zoomOut')" | 586 | @click="emit('zoomOut')" |
| 533 | > | 587 | > |
| 534 | - − | 588 | + - |
| 535 | </button> | 589 | </button> |
| 536 | <span class="min-w-[3rem] text-center text-xs font-medium text-gray-600"> | 590 | <span class="min-w-[3rem] text-center text-xs font-medium text-gray-600"> |
| 537 | {{ Math.round(scale * 100) }}% | 591 | {{ Math.round(scale * 100) }}% |
| @@ -586,7 +640,7 @@ onUnmounted(() => { | @@ -586,7 +640,7 @@ onUnmounted(() => { | ||
| 586 | /> | 640 | /> |
| 587 | </div> | 641 | </div> |
| 588 | <div class="flex w-full min-w-0 justify-center"> | 642 | <div class="flex w-full min-w-0 justify-center"> |
| 589 | - <!-- 外层占位(缩放后尺寸);内层画布逻辑坐标 baseW×baseH,与美国版一致 --> | 643 | + <!-- 澶栧眰鍗犱綅锛堢缉鏀惧悗灏哄锛夛紱鍐呭眰鐢诲竷閫昏緫鍧愭爣 baseW脳baseH锛屼笌缇庡浗鐗堜竴鑷?--> |
| 590 | <div | 644 | <div |
| 591 | class="relative shrink-0" | 645 | class="relative shrink-0" |
| 592 | :style="{ width: `${widthPx}px`, height: `${heightPx}px` }" | 646 | :style="{ width: `${widthPx}px`, height: `${heightPx}px` }" |
| @@ -614,8 +668,9 @@ onUnmounted(() => { | @@ -614,8 +668,9 @@ onUnmounted(() => { | ||
| 614 | v-for="el in template.elements" | 668 | v-for="el in template.elements" |
| 615 | :id="`element-${el.id}`" | 669 | :id="`element-${el.id}`" |
| 616 | :key="el.id" | 670 | :key="el.id" |
| 617 | - class="absolute box-border overflow-hidden bg-white/80" | 671 | + class="absolute box-border bg-white/80" |
| 618 | :class="[ | 672 | :class="[ |
| 673 | + shouldAllowElementOverflow(el) ? 'overflow-visible' : 'overflow-hidden', | ||
| 619 | elementBorderClass(el.border), | 674 | elementBorderClass(el.border), |
| 620 | selectedId === el.id && !previewOnly | 675 | selectedId === el.id && !previewOnly |
| 621 | ? 'ring-2 ring-blue-400 ring-offset-1' | 676 | ? 'ring-2 ring-blue-400 ring-offset-1' |
| @@ -639,7 +694,7 @@ onUnmounted(() => { | @@ -639,7 +694,7 @@ onUnmounted(() => { | ||
| 639 | @click.stop="onElementClick($event, el.id)" | 694 | @click.stop="onElementClick($event, el.id)" |
| 640 | @pointerdown="onElementPointerDown($event, el.id)" | 695 | @pointerdown="onElementPointerDown($event, el.id)" |
| 641 | > | 696 | > |
| 642 | - <!-- 内容层不接收指针事件,避免 img/SVG 触发浏览器原生拖拽 --> | 697 | + <!-- 鍐呭灞備笉鎺ユ敹鎸囬拡浜嬩欢锛岄伩鍏?img/SVG 瑙﹀彂娴忚鍣ㄥ師鐢熸嫋鎷?--> |
| 643 | <div class="pointer-events-none h-full w-full select-none"> | 698 | <div class="pointer-events-none h-full w-full select-none"> |
| 644 | <ElementContent :element="el" /> | 699 | <ElementContent :element="el" /> |
| 645 | </div> | 700 | </div> |
| @@ -655,7 +710,7 @@ onUnmounted(() => { | @@ -655,7 +710,7 @@ onUnmounted(() => { | ||
| 655 | </div> | 710 | </div> |
| 656 | </div> | 711 | </div> |
| 657 | 712 | ||
| 658 | - <!-- 安全边距:四条线从画布边缘贯穿(非内缩小框) --> | 713 | + <!-- 瀹夊叏杈硅窛锛氬洓鏉$嚎浠庣敾甯冭竟缂樿疮绌匡紙闈炲唴缂╁皬妗嗭級 --> |
| 659 | <svg | 714 | <svg |
| 660 | v-if="showSafeMarginGuide" | 715 | v-if="showSafeMarginGuide" |
| 661 | class="pointer-events-none absolute left-0 top-0 z-[12]" | 716 | class="pointer-events-none absolute left-0 top-0 z-[12]" |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/label-templates/editor/properties-panel.vue
| @@ -11,7 +11,7 @@ import { computed, onMounted, ref, watch } from 'vue'; | @@ -11,7 +11,7 @@ import { computed, onMounted, ref, watch } from 'vue'; | ||
| 11 | 11 | ||
| 12 | import { $t } from '@vben/locales'; | 12 | import { $t } from '@vben/locales'; |
| 13 | 13 | ||
| 14 | -import { Checkbox, Input, Radio, Select, Switch } from 'ant-design-vue'; | 14 | +import { Input, Radio, Select, Switch } from 'ant-design-vue'; |
| 15 | import { RotateLeftOutlined, RotateRightOutlined } from '@ant-design/icons-vue'; | 15 | import { RotateLeftOutlined, RotateRightOutlined } from '@ant-design/icons-vue'; |
| 16 | 16 | ||
| 17 | import { ImageUpload } from '#/components/upload'; | 17 | import { ImageUpload } from '#/components/upload'; |
| @@ -303,6 +303,30 @@ watch( | @@ -303,6 +303,30 @@ watch( | ||
| 303 | { immediate: true }, | 303 | { immediate: true }, |
| 304 | ); | 304 | ); |
| 305 | 305 | ||
| 306 | +watch( | ||
| 307 | + [ | ||
| 308 | + () => props.selectedElement?.id, | ||
| 309 | + () => (props.selectedElement?.config as Record<string, unknown> | undefined)?.multipleOptionId, | ||
| 310 | + () => (props.selectedElement?.config as Record<string, unknown> | undefined)?.multipleOptionName, | ||
| 311 | + () => multipleOptionRows.value, | ||
| 312 | + ], | ||
| 313 | + () => { | ||
| 314 | + if (!props.selectedElement || canonicalElementType(props.selectedElement.type) !== 'TEXT_STATIC') return; | ||
| 315 | + const cfg = props.selectedElement.config as Record<string, unknown>; | ||
| 316 | + if (cfg.inputType !== 'options') return; | ||
| 317 | + const selectedId = String(cfg.multipleOptionId ?? '').trim(); | ||
| 318 | + if (!selectedId || multipleOptionRows.value.length === 0) return; | ||
| 319 | + const row = multipleOptionRows.value.find((r) => r.id === selectedId); | ||
| 320 | + const name = String(row?.optionName ?? '').trim(); | ||
| 321 | + if (!row || !name) return; | ||
| 322 | + const current = String(cfg.multipleOptionName ?? '').trim(); | ||
| 323 | + if (name !== current) { | ||
| 324 | + patchConfig(props.selectedElement.id, props.selectedElement, { multipleOptionName: name }); | ||
| 325 | + } | ||
| 326 | + }, | ||
| 327 | + { immediate: true }, | ||
| 328 | +); | ||
| 329 | + | ||
| 306 | function onImageUploadChange(ossId: string | string[]) { | 330 | function onImageUploadChange(ossId: string | string[]) { |
| 307 | const val = Array.isArray(ossId) ? ossId[0] ?? '' : ossId; | 331 | const val = Array.isArray(ossId) ? ossId[0] ?? '' : ossId; |
| 308 | imageOssId.value = val; | 332 | imageOssId.value = val; |
| @@ -653,6 +677,74 @@ function onImageUploadChange(ossId: string | string[]) { | @@ -653,6 +677,74 @@ function onImageUploadChange(ossId: string | string[]) { | ||
| 653 | @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontSize: Number(v) || 14 })" | 677 | @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontSize: Number(v) || 14 })" |
| 654 | /> | 678 | /> |
| 655 | </div> | 679 | </div> |
| 680 | + <div> | ||
| 681 | + <label class="text-xs text-gray-600">Text Align</label> | ||
| 682 | + <Radio.Group | ||
| 683 | + class="fl-prop-radio-group mt-1" | ||
| 684 | + button-style="solid" | ||
| 685 | + :value="String((selectedElement.config as Record<string, unknown>).textAlign ?? 'right')" | ||
| 686 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { textAlign: v })" | ||
| 687 | + > | ||
| 688 | + <Radio.Button value="left">Left</Radio.Button> | ||
| 689 | + <Radio.Button value="center">Center</Radio.Button> | ||
| 690 | + <Radio.Button value="right">Right</Radio.Button> | ||
| 691 | + </Radio.Group> | ||
| 692 | + </div> | ||
| 693 | + <div> | ||
| 694 | + <label class="text-xs text-gray-600">Vertical Alignment</label> | ||
| 695 | + <Select | ||
| 696 | + size="small" | ||
| 697 | + class="mt-1 w-full" | ||
| 698 | + :value="readVerticalAlign(selectedElement.config as Record<string, unknown>)" | ||
| 699 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { verticalAlign: v })" | ||
| 700 | + > | ||
| 701 | + <Select.Option value="top">Top</Select.Option> | ||
| 702 | + <Select.Option value="center">Center</Select.Option> | ||
| 703 | + <Select.Option value="bottom">Bottom</Select.Option> | ||
| 704 | + </Select> | ||
| 705 | + </div> | ||
| 706 | + <div> | ||
| 707 | + <label class="text-xs text-gray-600">Font</label> | ||
| 708 | + <Select | ||
| 709 | + size="small" | ||
| 710 | + class="mt-1 w-full" | ||
| 711 | + :value="readLabelEditorFontFamilyChoice(selectedElement.config as Record<string, unknown>)" | ||
| 712 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontFamily: v })" | ||
| 713 | + > | ||
| 714 | + <Select.Option v-for="opt in LABEL_EDITOR_FONT_OPTIONS" :key="opt.value" :value="opt.value"> | ||
| 715 | + {{ opt.label }} | ||
| 716 | + </Select.Option> | ||
| 717 | + </Select> | ||
| 718 | + </div> | ||
| 719 | + <div class="flex flex-wrap gap-1"> | ||
| 720 | + <a-button | ||
| 721 | + size="small" | ||
| 722 | + :type="readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'primary' : 'default'" | ||
| 723 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 724 | + fontWeight: readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'normal' : 'bold', | ||
| 725 | + })" | ||
| 726 | + > | ||
| 727 | + B | ||
| 728 | + </a-button> | ||
| 729 | + <a-button | ||
| 730 | + size="small" | ||
| 731 | + :type="readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'primary' : 'default'" | ||
| 732 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 733 | + fontStyle: readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'normal' : 'italic', | ||
| 734 | + })" | ||
| 735 | + > | ||
| 736 | + I | ||
| 737 | + </a-button> | ||
| 738 | + <a-button | ||
| 739 | + size="small" | ||
| 740 | + :type="readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'primary' : 'default'" | ||
| 741 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 742 | + textDecoration: readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'none' : 'underline', | ||
| 743 | + })" | ||
| 744 | + > | ||
| 745 | + U | ||
| 746 | + </a-button> | ||
| 747 | + </div> | ||
| 656 | </template> | 748 | </template> |
| 657 | 749 | ||
| 658 | <template v-else-if="canonicalElementType(selectedElement.type) === 'BARCODE'"> | 750 | <template v-else-if="canonicalElementType(selectedElement.type) === 'BARCODE'"> |
| @@ -678,6 +770,31 @@ function onImageUploadChange(ossId: string | string[]) { | @@ -678,6 +770,31 @@ function onImageUploadChange(ossId: string | string[]) { | ||
| 678 | @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { data: v })" | 770 | @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { data: v })" |
| 679 | /> | 771 | /> |
| 680 | </div> | 772 | </div> |
| 773 | + <div class="grid grid-cols-2 gap-2"> | ||
| 774 | + <div> | ||
| 775 | + <label class="text-xs text-gray-600">Font Size</label> | ||
| 776 | + <Input | ||
| 777 | + type="number" | ||
| 778 | + size="small" | ||
| 779 | + class="mt-1" | ||
| 780 | + :value="Number((selectedElement.config as Record<string, unknown>).fontSize ?? 14)" | ||
| 781 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontSize: Number(v) || 14 })" | ||
| 782 | + /> | ||
| 783 | + </div> | ||
| 784 | + <div> | ||
| 785 | + <label class="text-xs text-gray-600">Text Align</label> | ||
| 786 | + <Select | ||
| 787 | + size="small" | ||
| 788 | + class="mt-1 w-full" | ||
| 789 | + :value="String((selectedElement.config as Record<string, unknown>).textAlign ?? 'center')" | ||
| 790 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { textAlign: v })" | ||
| 791 | + > | ||
| 792 | + <Select.Option value="left">Left</Select.Option> | ||
| 793 | + <Select.Option value="center">Center</Select.Option> | ||
| 794 | + <Select.Option value="right">Right</Select.Option> | ||
| 795 | + </Select> | ||
| 796 | + </div> | ||
| 797 | + </div> | ||
| 681 | <div class="flex items-center gap-2"> | 798 | <div class="flex items-center gap-2"> |
| 682 | <Switch | 799 | <Switch |
| 683 | :checked="(selectedElement.config as Record<string, unknown>).showText !== false" | 800 | :checked="(selectedElement.config as Record<string, unknown>).showText !== false" |
| @@ -752,6 +869,84 @@ function onImageUploadChange(ossId: string | string[]) { | @@ -752,6 +869,84 @@ function onImageUploadChange(ossId: string | string[]) { | ||
| 752 | <Select.Option :value="DATETIME_DEFAULT_FORMAT">{{ DATETIME_DEFAULT_FORMAT }}</Select.Option> | 869 | <Select.Option :value="DATETIME_DEFAULT_FORMAT">{{ DATETIME_DEFAULT_FORMAT }}</Select.Option> |
| 753 | </Select> | 870 | </Select> |
| 754 | </div> | 871 | </div> |
| 872 | + <div> | ||
| 873 | + <label class="text-xs text-gray-600">Font</label> | ||
| 874 | + <Select | ||
| 875 | + size="small" | ||
| 876 | + class="mt-1 w-full" | ||
| 877 | + :value="readLabelEditorFontFamilyChoice(selectedElement.config as Record<string, unknown>)" | ||
| 878 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontFamily: v })" | ||
| 879 | + > | ||
| 880 | + <Select.Option v-for="opt in LABEL_EDITOR_FONT_OPTIONS" :key="opt.value" :value="opt.value"> | ||
| 881 | + {{ opt.label }} | ||
| 882 | + </Select.Option> | ||
| 883 | + </Select> | ||
| 884 | + </div> | ||
| 885 | + <div> | ||
| 886 | + <label class="text-xs text-gray-600">Font Size</label> | ||
| 887 | + <Input | ||
| 888 | + type="number" | ||
| 889 | + size="small" | ||
| 890 | + class="mt-1" | ||
| 891 | + :value="cfgPickNum(selectedElement.config as Record<string, unknown>, ['fontSize', 'FontSize'], 14)" | ||
| 892 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontSize: Number(v) || 14 })" | ||
| 893 | + /> | ||
| 894 | + </div> | ||
| 895 | + <div> | ||
| 896 | + <label class="text-xs text-gray-600">Text Align</label> | ||
| 897 | + <Radio.Group | ||
| 898 | + class="fl-prop-radio-group mt-1" | ||
| 899 | + button-style="solid" | ||
| 900 | + :value="cfgPickStr(selectedElement.config as Record<string, unknown>, ['textAlign', 'TextAlign'], 'left')" | ||
| 901 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { textAlign: v })" | ||
| 902 | + > | ||
| 903 | + <Radio.Button value="left">Left</Radio.Button> | ||
| 904 | + <Radio.Button value="center">Center</Radio.Button> | ||
| 905 | + <Radio.Button value="right">Right</Radio.Button> | ||
| 906 | + </Radio.Group> | ||
| 907 | + </div> | ||
| 908 | + <div> | ||
| 909 | + <label class="text-xs text-gray-600">Vertical Alignment</label> | ||
| 910 | + <Select | ||
| 911 | + size="small" | ||
| 912 | + class="mt-1 w-full" | ||
| 913 | + :value="readVerticalAlign(selectedElement.config as Record<string, unknown>)" | ||
| 914 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { verticalAlign: v })" | ||
| 915 | + > | ||
| 916 | + <Select.Option value="top">Top</Select.Option> | ||
| 917 | + <Select.Option value="center">Center</Select.Option> | ||
| 918 | + <Select.Option value="bottom">Bottom</Select.Option> | ||
| 919 | + </Select> | ||
| 920 | + </div> | ||
| 921 | + <div class="flex flex-wrap gap-1"> | ||
| 922 | + <a-button | ||
| 923 | + size="small" | ||
| 924 | + :type="readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'primary' : 'default'" | ||
| 925 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 926 | + fontWeight: readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'normal' : 'bold', | ||
| 927 | + })" | ||
| 928 | + > | ||
| 929 | + B | ||
| 930 | + </a-button> | ||
| 931 | + <a-button | ||
| 932 | + size="small" | ||
| 933 | + :type="readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'primary' : 'default'" | ||
| 934 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 935 | + fontStyle: readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'normal' : 'italic', | ||
| 936 | + })" | ||
| 937 | + > | ||
| 938 | + I | ||
| 939 | + </a-button> | ||
| 940 | + <a-button | ||
| 941 | + size="small" | ||
| 942 | + :type="readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'primary' : 'default'" | ||
| 943 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 944 | + textDecoration: readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'none' : 'underline', | ||
| 945 | + })" | ||
| 946 | + > | ||
| 947 | + U | ||
| 948 | + </a-button> | ||
| 949 | + </div> | ||
| 755 | </template> | 950 | </template> |
| 756 | 951 | ||
| 757 | <template v-else-if="canonicalElementType(selectedElement.type) === 'TIME'"> | 952 | <template v-else-if="canonicalElementType(selectedElement.type) === 'TIME'"> |
| @@ -771,6 +966,84 @@ function onImageUploadChange(ossId: string | string[]) { | @@ -771,6 +966,84 @@ function onImageUploadChange(ossId: string | string[]) { | ||
| 771 | <Select.Option value="24 hr">24 hr - 14:00</Select.Option> | 966 | <Select.Option value="24 hr">24 hr - 14:00</Select.Option> |
| 772 | </Select> | 967 | </Select> |
| 773 | </div> | 968 | </div> |
| 969 | + <div> | ||
| 970 | + <label class="text-xs text-gray-600">Font</label> | ||
| 971 | + <Select | ||
| 972 | + size="small" | ||
| 973 | + class="mt-1 w-full" | ||
| 974 | + :value="readLabelEditorFontFamilyChoice(selectedElement.config as Record<string, unknown>)" | ||
| 975 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontFamily: v })" | ||
| 976 | + > | ||
| 977 | + <Select.Option v-for="opt in LABEL_EDITOR_FONT_OPTIONS" :key="opt.value" :value="opt.value"> | ||
| 978 | + {{ opt.label }} | ||
| 979 | + </Select.Option> | ||
| 980 | + </Select> | ||
| 981 | + </div> | ||
| 982 | + <div> | ||
| 983 | + <label class="text-xs text-gray-600">Font Size</label> | ||
| 984 | + <Input | ||
| 985 | + type="number" | ||
| 986 | + size="small" | ||
| 987 | + class="mt-1" | ||
| 988 | + :value="cfgPickNum(selectedElement.config as Record<string, unknown>, ['fontSize', 'FontSize'], 14)" | ||
| 989 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontSize: Number(v) || 14 })" | ||
| 990 | + /> | ||
| 991 | + </div> | ||
| 992 | + <div> | ||
| 993 | + <label class="text-xs text-gray-600">Text Align</label> | ||
| 994 | + <Radio.Group | ||
| 995 | + class="fl-prop-radio-group mt-1" | ||
| 996 | + button-style="solid" | ||
| 997 | + :value="cfgPickStr(selectedElement.config as Record<string, unknown>, ['textAlign', 'TextAlign'], 'left')" | ||
| 998 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { textAlign: v })" | ||
| 999 | + > | ||
| 1000 | + <Radio.Button value="left">Left</Radio.Button> | ||
| 1001 | + <Radio.Button value="center">Center</Radio.Button> | ||
| 1002 | + <Radio.Button value="right">Right</Radio.Button> | ||
| 1003 | + </Radio.Group> | ||
| 1004 | + </div> | ||
| 1005 | + <div> | ||
| 1006 | + <label class="text-xs text-gray-600">Vertical Alignment</label> | ||
| 1007 | + <Select | ||
| 1008 | + size="small" | ||
| 1009 | + class="mt-1 w-full" | ||
| 1010 | + :value="readVerticalAlign(selectedElement.config as Record<string, unknown>)" | ||
| 1011 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { verticalAlign: v })" | ||
| 1012 | + > | ||
| 1013 | + <Select.Option value="top">Top</Select.Option> | ||
| 1014 | + <Select.Option value="center">Center</Select.Option> | ||
| 1015 | + <Select.Option value="bottom">Bottom</Select.Option> | ||
| 1016 | + </Select> | ||
| 1017 | + </div> | ||
| 1018 | + <div class="flex flex-wrap gap-1"> | ||
| 1019 | + <a-button | ||
| 1020 | + size="small" | ||
| 1021 | + :type="readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'primary' : 'default'" | ||
| 1022 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1023 | + fontWeight: readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'normal' : 'bold', | ||
| 1024 | + })" | ||
| 1025 | + > | ||
| 1026 | + B | ||
| 1027 | + </a-button> | ||
| 1028 | + <a-button | ||
| 1029 | + size="small" | ||
| 1030 | + :type="readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'primary' : 'default'" | ||
| 1031 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1032 | + fontStyle: readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'normal' : 'italic', | ||
| 1033 | + })" | ||
| 1034 | + > | ||
| 1035 | + I | ||
| 1036 | + </a-button> | ||
| 1037 | + <a-button | ||
| 1038 | + size="small" | ||
| 1039 | + :type="readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'primary' : 'default'" | ||
| 1040 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1041 | + textDecoration: readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'none' : 'underline', | ||
| 1042 | + })" | ||
| 1043 | + > | ||
| 1044 | + U | ||
| 1045 | + </a-button> | ||
| 1046 | + </div> | ||
| 774 | </template> | 1047 | </template> |
| 775 | 1048 | ||
| 776 | <template v-else-if="canonicalElementType(selectedElement.type) === 'DURATION'"> | 1049 | <template v-else-if="canonicalElementType(selectedElement.type) === 'DURATION'"> |
| @@ -797,6 +1070,84 @@ function onImageUploadChange(ossId: string | string[]) { | @@ -797,6 +1070,84 @@ function onImageUploadChange(ossId: string | string[]) { | ||
| 797 | @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { durationValue: Number(v) || 0 })" | 1070 | @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { durationValue: Number(v) || 0 })" |
| 798 | /> | 1071 | /> |
| 799 | </div> | 1072 | </div> |
| 1073 | + <div> | ||
| 1074 | + <label class="text-xs text-gray-600">Font</label> | ||
| 1075 | + <Select | ||
| 1076 | + size="small" | ||
| 1077 | + class="mt-1 w-full" | ||
| 1078 | + :value="readLabelEditorFontFamilyChoice(selectedElement.config as Record<string, unknown>)" | ||
| 1079 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontFamily: v })" | ||
| 1080 | + > | ||
| 1081 | + <Select.Option v-for="opt in LABEL_EDITOR_FONT_OPTIONS" :key="opt.value" :value="opt.value"> | ||
| 1082 | + {{ opt.label }} | ||
| 1083 | + </Select.Option> | ||
| 1084 | + </Select> | ||
| 1085 | + </div> | ||
| 1086 | + <div> | ||
| 1087 | + <label class="text-xs text-gray-600">Font Size</label> | ||
| 1088 | + <Input | ||
| 1089 | + type="number" | ||
| 1090 | + size="small" | ||
| 1091 | + class="mt-1" | ||
| 1092 | + :value="cfgPickNum(selectedElement.config as Record<string, unknown>, ['fontSize', 'FontSize'], 14)" | ||
| 1093 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontSize: Number(v) || 14 })" | ||
| 1094 | + /> | ||
| 1095 | + </div> | ||
| 1096 | + <div> | ||
| 1097 | + <label class="text-xs text-gray-600">Text Align</label> | ||
| 1098 | + <Radio.Group | ||
| 1099 | + class="fl-prop-radio-group mt-1" | ||
| 1100 | + button-style="solid" | ||
| 1101 | + :value="cfgPickStr(selectedElement.config as Record<string, unknown>, ['textAlign', 'TextAlign'], 'left')" | ||
| 1102 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { textAlign: v })" | ||
| 1103 | + > | ||
| 1104 | + <Radio.Button value="left">Left</Radio.Button> | ||
| 1105 | + <Radio.Button value="center">Center</Radio.Button> | ||
| 1106 | + <Radio.Button value="right">Right</Radio.Button> | ||
| 1107 | + </Radio.Group> | ||
| 1108 | + </div> | ||
| 1109 | + <div> | ||
| 1110 | + <label class="text-xs text-gray-600">Vertical Alignment</label> | ||
| 1111 | + <Select | ||
| 1112 | + size="small" | ||
| 1113 | + class="mt-1 w-full" | ||
| 1114 | + :value="readVerticalAlign(selectedElement.config as Record<string, unknown>)" | ||
| 1115 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { verticalAlign: v })" | ||
| 1116 | + > | ||
| 1117 | + <Select.Option value="top">Top</Select.Option> | ||
| 1118 | + <Select.Option value="center">Center</Select.Option> | ||
| 1119 | + <Select.Option value="bottom">Bottom</Select.Option> | ||
| 1120 | + </Select> | ||
| 1121 | + </div> | ||
| 1122 | + <div class="flex flex-wrap gap-1"> | ||
| 1123 | + <a-button | ||
| 1124 | + size="small" | ||
| 1125 | + :type="readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'primary' : 'default'" | ||
| 1126 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1127 | + fontWeight: readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'normal' : 'bold', | ||
| 1128 | + })" | ||
| 1129 | + > | ||
| 1130 | + B | ||
| 1131 | + </a-button> | ||
| 1132 | + <a-button | ||
| 1133 | + size="small" | ||
| 1134 | + :type="readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'primary' : 'default'" | ||
| 1135 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1136 | + fontStyle: readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'normal' : 'italic', | ||
| 1137 | + })" | ||
| 1138 | + > | ||
| 1139 | + I | ||
| 1140 | + </a-button> | ||
| 1141 | + <a-button | ||
| 1142 | + size="small" | ||
| 1143 | + :type="readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'primary' : 'default'" | ||
| 1144 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1145 | + textDecoration: readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'none' : 'underline', | ||
| 1146 | + })" | ||
| 1147 | + > | ||
| 1148 | + U | ||
| 1149 | + </a-button> | ||
| 1150 | + </div> | ||
| 800 | </template> | 1151 | </template> |
| 801 | 1152 | ||
| 802 | <template v-else-if="canonicalElementType(selectedElement.type) === 'WEIGHT'"> | 1153 | <template v-else-if="canonicalElementType(selectedElement.type) === 'WEIGHT'"> |
| @@ -844,6 +1195,84 @@ function onImageUploadChange(ossId: string | string[]) { | @@ -844,6 +1195,84 @@ function onImageUploadChange(ossId: string | string[]) { | ||
| 844 | </Select.Option> | 1195 | </Select.Option> |
| 845 | </Select> | 1196 | </Select> |
| 846 | </div> | 1197 | </div> |
| 1198 | + <div> | ||
| 1199 | + <label class="text-xs text-gray-600">Font</label> | ||
| 1200 | + <Select | ||
| 1201 | + size="small" | ||
| 1202 | + class="mt-1 w-full" | ||
| 1203 | + :value="readLabelEditorFontFamilyChoice(selectedElement.config as Record<string, unknown>)" | ||
| 1204 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontFamily: v })" | ||
| 1205 | + > | ||
| 1206 | + <Select.Option v-for="opt in LABEL_EDITOR_FONT_OPTIONS" :key="opt.value" :value="opt.value"> | ||
| 1207 | + {{ opt.label }} | ||
| 1208 | + </Select.Option> | ||
| 1209 | + </Select> | ||
| 1210 | + </div> | ||
| 1211 | + <div> | ||
| 1212 | + <label class="text-xs text-gray-600">Font Size</label> | ||
| 1213 | + <Input | ||
| 1214 | + type="number" | ||
| 1215 | + size="small" | ||
| 1216 | + class="mt-1" | ||
| 1217 | + :value="cfgPickNum(selectedElement.config as Record<string, unknown>, ['fontSize', 'FontSize'], 14)" | ||
| 1218 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { fontSize: Number(v) || 14 })" | ||
| 1219 | + /> | ||
| 1220 | + </div> | ||
| 1221 | + <div> | ||
| 1222 | + <label class="text-xs text-gray-600">Text Align</label> | ||
| 1223 | + <Radio.Group | ||
| 1224 | + class="fl-prop-radio-group mt-1" | ||
| 1225 | + button-style="solid" | ||
| 1226 | + :value="cfgPickStr(selectedElement.config as Record<string, unknown>, ['textAlign', 'TextAlign'], 'left')" | ||
| 1227 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { textAlign: v })" | ||
| 1228 | + > | ||
| 1229 | + <Radio.Button value="left">Left</Radio.Button> | ||
| 1230 | + <Radio.Button value="center">Center</Radio.Button> | ||
| 1231 | + <Radio.Button value="right">Right</Radio.Button> | ||
| 1232 | + </Radio.Group> | ||
| 1233 | + </div> | ||
| 1234 | + <div> | ||
| 1235 | + <label class="text-xs text-gray-600">Vertical Alignment</label> | ||
| 1236 | + <Select | ||
| 1237 | + size="small" | ||
| 1238 | + class="mt-1 w-full" | ||
| 1239 | + :value="readVerticalAlign(selectedElement.config as Record<string, unknown>)" | ||
| 1240 | + @update:value="(v) => patchConfig(selectedElement!.id, selectedElement!, { verticalAlign: v })" | ||
| 1241 | + > | ||
| 1242 | + <Select.Option value="top">Top</Select.Option> | ||
| 1243 | + <Select.Option value="center">Center</Select.Option> | ||
| 1244 | + <Select.Option value="bottom">Bottom</Select.Option> | ||
| 1245 | + </Select> | ||
| 1246 | + </div> | ||
| 1247 | + <div class="flex flex-wrap gap-1"> | ||
| 1248 | + <a-button | ||
| 1249 | + size="small" | ||
| 1250 | + :type="readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'primary' : 'default'" | ||
| 1251 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1252 | + fontWeight: readFontWeight(selectedElement.config as Record<string, unknown>) === 'bold' ? 'normal' : 'bold', | ||
| 1253 | + })" | ||
| 1254 | + > | ||
| 1255 | + B | ||
| 1256 | + </a-button> | ||
| 1257 | + <a-button | ||
| 1258 | + size="small" | ||
| 1259 | + :type="readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'primary' : 'default'" | ||
| 1260 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1261 | + fontStyle: readFontStyle(selectedElement.config as Record<string, unknown>) === 'italic' ? 'normal' : 'italic', | ||
| 1262 | + })" | ||
| 1263 | + > | ||
| 1264 | + I | ||
| 1265 | + </a-button> | ||
| 1266 | + <a-button | ||
| 1267 | + size="small" | ||
| 1268 | + :type="readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'primary' : 'default'" | ||
| 1269 | + @click="patchConfig(selectedElement!.id, selectedElement!, { | ||
| 1270 | + textDecoration: readTextDecoration(selectedElement.config as Record<string, unknown>) === 'underline' ? 'none' : 'underline', | ||
| 1271 | + })" | ||
| 1272 | + > | ||
| 1273 | + U | ||
| 1274 | + </a-button> | ||
| 1275 | + </div> | ||
| 847 | </template> | 1276 | </template> |
| 848 | 1277 | ||
| 849 | <NutritionPropertiesSection | 1278 | <NutritionPropertiesSection |
| @@ -852,18 +1281,45 @@ function onImageUploadChange(ossId: string | string[]) { | @@ -852,18 +1281,45 @@ function onImageUploadChange(ossId: string | string[]) { | ||
| 852 | @config-change="(next) => patchConfig(selectedElement!.id, selectedElement!, next)" | 1281 | @config-change="(next) => patchConfig(selectedElement!.id, selectedElement!, next)" |
| 853 | /> | 1282 | /> |
| 854 | 1283 | ||
| 855 | - <div v-if="isCompanyAutoElement(selectedElement)" class="space-y-2"> | ||
| 856 | - <label class="text-xs font-medium text-gray-700">Company print fields</label> | ||
| 857 | - <div | ||
| 858 | - v-for="field in COMPANY_PRINT_FIELD_OPTIONS" | ||
| 859 | - :key="field.key" | ||
| 860 | - class="flex items-center gap-2" | ||
| 861 | - > | ||
| 862 | - <Checkbox | ||
| 863 | - :checked="readCompanyPrintFields(selectedElement.config as Record<string, unknown>)[field.key]" | ||
| 864 | - @update:checked="() => toggleCompanyPrintField(field.key)" | ||
| 865 | - /> | ||
| 866 | - <span class="text-xs">{{ field.label }}</span> | 1284 | + <div v-if="isCompanyAutoElement(selectedElement)" class="rounded-md border border-slate-200 bg-slate-50/80 p-2.5"> |
| 1285 | + <label class="text-xs font-medium text-gray-800">Company info on label</label> | ||
| 1286 | + <p class="mt-0.5 text-[10px] leading-snug text-gray-500"> | ||
| 1287 | + Company name is always printed. Select which fields to include on the label. | ||
| 1288 | + </p> | ||
| 1289 | + <div class="mt-2 grid grid-cols-2 gap-2"> | ||
| 1290 | + <button | ||
| 1291 | + v-for="field in COMPANY_PRINT_FIELD_OPTIONS" | ||
| 1292 | + :key="field.key" | ||
| 1293 | + type="button" | ||
| 1294 | + :aria-pressed="readCompanyPrintFields(selectedElement.config as Record<string, unknown>)[field.key]" | ||
| 1295 | + :class="[ | ||
| 1296 | + 'relative flex min-h-[4.5rem] flex-col items-center justify-center gap-1 rounded-lg border p-2 text-center shadow-sm transition-colors', | ||
| 1297 | + readCompanyPrintFields(selectedElement.config as Record<string, unknown>)[field.key] | ||
| 1298 | + ? 'border-blue-600 bg-blue-600 text-white' | ||
| 1299 | + : 'border-slate-200 bg-white hover:border-slate-300 hover:bg-slate-50', | ||
| 1300 | + ]" | ||
| 1301 | + @click="toggleCompanyPrintField(field.key)" | ||
| 1302 | + > | ||
| 1303 | + <span | ||
| 1304 | + v-if="readCompanyPrintFields(selectedElement.config as Record<string, unknown>)[field.key]" | ||
| 1305 | + class="absolute right-1 top-1 flex h-4 w-4 items-center justify-center rounded-full bg-white/25 text-[10px] font-bold text-white" | ||
| 1306 | + > | ||
| 1307 | + ✓ | ||
| 1308 | + </span> | ||
| 1309 | + <span | ||
| 1310 | + :class="[ | ||
| 1311 | + 'flex h-5 w-5 shrink-0 items-center justify-center rounded text-xs font-semibold', | ||
| 1312 | + readCompanyPrintFields(selectedElement.config as Record<string, unknown>)[field.key] | ||
| 1313 | + ? 'text-white' | ||
| 1314 | + : 'text-rose-900', | ||
| 1315 | + ]" | ||
| 1316 | + > | ||
| 1317 | + {{ field.label.slice(0, 1) }} | ||
| 1318 | + </span> | ||
| 1319 | + <span class="text-[10px] leading-tight"> | ||
| 1320 | + {{ field.label }} | ||
| 1321 | + </span> | ||
| 1322 | + </button> | ||
| 867 | </div> | 1323 | </div> |
| 868 | </div> | 1324 | </div> |
| 869 | 1325 |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/labels/data.ts
| @@ -131,12 +131,21 @@ export const columns: VxeGridProps['columns'] = [ | @@ -131,12 +131,21 @@ export const columns: VxeGridProps['columns'] = [ | ||
| 131 | ]; | 131 | ]; |
| 132 | 132 | ||
| 133 | export function modalSchema(options: { | 133 | export function modalSchema(options: { |
| 134 | + partnerOptions: SelectOption[]; | ||
| 135 | + regionOptions: SelectOption[]; | ||
| 136 | + productCategoryOptions: SelectOption[]; | ||
| 134 | locationOptions: SelectOption[]; | 137 | locationOptions: SelectOption[]; |
| 135 | categoryOptions: SelectOption[]; | 138 | categoryOptions: SelectOption[]; |
| 136 | typeOptions: SelectOption[]; | 139 | typeOptions: SelectOption[]; |
| 137 | templateOptions: SelectOption[]; | 140 | templateOptions: SelectOption[]; |
| 138 | productOptions: SelectOption[]; | 141 | productOptions: SelectOption[]; |
| 139 | isUpdate: boolean; | 142 | isUpdate: boolean; |
| 143 | + requireCompanySelection: boolean; | ||
| 144 | + regionDisabled: boolean; | ||
| 145 | + scopedFieldsDisabled: boolean; | ||
| 146 | + onPartnerIdChange?: (partnerId: string) => void; | ||
| 147 | + onRegionIdsChange?: (regionIds: string[]) => void; | ||
| 148 | + onProductCategoryIdChange?: (categoryId: string) => void; | ||
| 140 | onTemplateCodeChange?: (code: string) => void; | 149 | onTemplateCodeChange?: (code: string) => void; |
| 141 | onProductIdChange?: (productId: string) => void; | 150 | onProductIdChange?: (productId: string) => void; |
| 142 | onLabelTypeIdChange?: (labelTypeId: string) => void; | 151 | onLabelTypeIdChange?: (labelTypeId: string) => void; |
| @@ -152,6 +161,71 @@ export function modalSchema(options: { | @@ -152,6 +161,71 @@ export function modalSchema(options: { | ||
| 152 | }, | 161 | }, |
| 153 | }, | 162 | }, |
| 154 | { | 163 | { |
| 164 | + component: 'Select', | ||
| 165 | + fieldName: 'partnerId', | ||
| 166 | + label: $t('foodLabeling.labels.company'), | ||
| 167 | + dependencies: { | ||
| 168 | + show: () => options.requireCompanySelection, | ||
| 169 | + }, | ||
| 170 | + rules: 'required', | ||
| 171 | + componentProps: { | ||
| 172 | + options: options.partnerOptions, | ||
| 173 | + showSearch: true, | ||
| 174 | + optionFilterProp: 'label', | ||
| 175 | + placeholder: $t('foodLabeling.labels.selectCompany'), | ||
| 176 | + onChange: (v: string) => options.onPartnerIdChange?.(v), | ||
| 177 | + }, | ||
| 178 | + }, | ||
| 179 | + { | ||
| 180 | + component: 'Select', | ||
| 181 | + fieldName: 'regionIds', | ||
| 182 | + label: $t('foodLabeling.labels.applicableRegion'), | ||
| 183 | + rules: 'required', | ||
| 184 | + componentProps: { | ||
| 185 | + mode: 'multiple', | ||
| 186 | + options: options.regionOptions, | ||
| 187 | + disabled: options.regionDisabled, | ||
| 188 | + showSearch: true, | ||
| 189 | + optionFilterProp: 'label', | ||
| 190 | + placeholder: options.regionDisabled | ||
| 191 | + ? $t('foodLabeling.labels.selectCompanyFirst') | ||
| 192 | + : $t('foodLabeling.labels.selectRegion'), | ||
| 193 | + onChange: (v: string[]) => options.onRegionIdsChange?.(v), | ||
| 194 | + }, | ||
| 195 | + }, | ||
| 196 | + { | ||
| 197 | + component: 'Select', | ||
| 198 | + fieldName: 'productCategoryId', | ||
| 199 | + label: $t('foodLabeling.labels.productCategory'), | ||
| 200 | + rules: 'required', | ||
| 201 | + componentProps: { | ||
| 202 | + options: options.productCategoryOptions, | ||
| 203 | + disabled: options.scopedFieldsDisabled, | ||
| 204 | + showSearch: true, | ||
| 205 | + optionFilterProp: 'label', | ||
| 206 | + placeholder: options.scopedFieldsDisabled | ||
| 207 | + ? $t('foodLabeling.labels.selectCompanyRegionFirst') | ||
| 208 | + : $t('foodLabeling.labels.selectProductCategory'), | ||
| 209 | + onChange: (v: string) => options.onProductCategoryIdChange?.(v), | ||
| 210 | + }, | ||
| 211 | + }, | ||
| 212 | + { | ||
| 213 | + component: 'Select', | ||
| 214 | + fieldName: 'productId', | ||
| 215 | + label: $t('foodLabeling.labels.product'), | ||
| 216 | + rules: 'required', | ||
| 217 | + componentProps: { | ||
| 218 | + options: options.productOptions, | ||
| 219 | + disabled: options.scopedFieldsDisabled, | ||
| 220 | + showSearch: true, | ||
| 221 | + optionFilterProp: 'label', | ||
| 222 | + placeholder: options.scopedFieldsDisabled | ||
| 223 | + ? $t('foodLabeling.labels.selectCompanyRegionFirst') | ||
| 224 | + : $t('foodLabeling.labels.selectProduct'), | ||
| 225 | + onChange: (v: string) => options.onProductIdChange?.(v), | ||
| 226 | + }, | ||
| 227 | + }, | ||
| 228 | + { | ||
| 155 | component: 'Input', | 229 | component: 'Input', |
| 156 | fieldName: 'labelName', | 230 | fieldName: 'labelName', |
| 157 | label: $t('foodLabeling.labels.labelName'), | 231 | label: $t('foodLabeling.labels.labelName'), |
| @@ -164,9 +238,12 @@ export function modalSchema(options: { | @@ -164,9 +238,12 @@ export function modalSchema(options: { | ||
| 164 | rules: 'required', | 238 | rules: 'required', |
| 165 | componentProps: { | 239 | componentProps: { |
| 166 | options: options.templateOptions, | 240 | options: options.templateOptions, |
| 241 | + disabled: options.scopedFieldsDisabled, | ||
| 167 | showSearch: true, | 242 | showSearch: true, |
| 168 | optionFilterProp: 'label', | 243 | optionFilterProp: 'label', |
| 169 | - placeholder: $t('foodLabeling.labels.selectTemplate'), | 244 | + placeholder: options.scopedFieldsDisabled |
| 245 | + ? $t('foodLabeling.labels.selectCompanyRegionFirst') | ||
| 246 | + : $t('foodLabeling.labels.selectTemplate'), | ||
| 170 | onChange: (v: string) => options.onTemplateCodeChange?.(v), | 247 | onChange: (v: string) => options.onTemplateCodeChange?.(v), |
| 171 | }, | 248 | }, |
| 172 | }, | 249 | }, |
| @@ -177,9 +254,12 @@ export function modalSchema(options: { | @@ -177,9 +254,12 @@ export function modalSchema(options: { | ||
| 177 | rules: 'required', | 254 | rules: 'required', |
| 178 | componentProps: { | 255 | componentProps: { |
| 179 | options: options.locationOptions, | 256 | options: options.locationOptions, |
| 257 | + disabled: options.scopedFieldsDisabled, | ||
| 180 | showSearch: true, | 258 | showSearch: true, |
| 181 | optionFilterProp: 'label', | 259 | optionFilterProp: 'label', |
| 182 | - placeholder: $t('foodLabeling.labels.selectLocation'), | 260 | + placeholder: options.scopedFieldsDisabled |
| 261 | + ? $t('foodLabeling.labels.selectCompanyRegionFirst') | ||
| 262 | + : $t('foodLabeling.labels.selectLocation'), | ||
| 183 | }, | 263 | }, |
| 184 | }, | 264 | }, |
| 185 | { | 265 | { |
| @@ -189,9 +269,12 @@ export function modalSchema(options: { | @@ -189,9 +269,12 @@ export function modalSchema(options: { | ||
| 189 | rules: 'required', | 269 | rules: 'required', |
| 190 | componentProps: { | 270 | componentProps: { |
| 191 | options: options.categoryOptions, | 271 | options: options.categoryOptions, |
| 272 | + disabled: options.scopedFieldsDisabled, | ||
| 192 | showSearch: true, | 273 | showSearch: true, |
| 193 | optionFilterProp: 'label', | 274 | optionFilterProp: 'label', |
| 194 | - placeholder: $t('foodLabeling.labels.selectCategory'), | 275 | + placeholder: options.scopedFieldsDisabled |
| 276 | + ? $t('foodLabeling.labels.selectCompanyRegionFirst') | ||
| 277 | + : $t('foodLabeling.labels.selectCategory'), | ||
| 195 | }, | 278 | }, |
| 196 | }, | 279 | }, |
| 197 | { | 280 | { |
| @@ -201,29 +284,19 @@ export function modalSchema(options: { | @@ -201,29 +284,19 @@ export function modalSchema(options: { | ||
| 201 | ...(options.isUpdate ? { rules: 'required' as const } : {}), | 284 | ...(options.isUpdate ? { rules: 'required' as const } : {}), |
| 202 | componentProps: { | 285 | componentProps: { |
| 203 | options: options.typeOptions, | 286 | options: options.typeOptions, |
| 287 | + disabled: options.scopedFieldsDisabled, | ||
| 204 | showSearch: true, | 288 | showSearch: true, |
| 205 | optionFilterProp: 'label', | 289 | optionFilterProp: 'label', |
| 206 | allowClear: !options.isUpdate, | 290 | allowClear: !options.isUpdate, |
| 207 | - placeholder: options.isUpdate | 291 | + placeholder: options.scopedFieldsDisabled |
| 292 | + ? $t('foodLabeling.labels.selectCompanyRegionFirst') | ||
| 293 | + : options.isUpdate | ||
| 208 | ? $t('foodLabeling.labels.selectType') | 294 | ? $t('foodLabeling.labels.selectType') |
| 209 | : $t('foodLabeling.labels.selectTypeOptional'), | 295 | : $t('foodLabeling.labels.selectTypeOptional'), |
| 210 | onChange: (v: string) => options.onLabelTypeIdChange?.(v), | 296 | onChange: (v: string) => options.onLabelTypeIdChange?.(v), |
| 211 | }, | 297 | }, |
| 212 | }, | 298 | }, |
| 213 | { | 299 | { |
| 214 | - component: 'Select', | ||
| 215 | - fieldName: 'productId', | ||
| 216 | - label: $t('foodLabeling.labels.product'), | ||
| 217 | - rules: 'required', | ||
| 218 | - componentProps: { | ||
| 219 | - options: options.productOptions, | ||
| 220 | - showSearch: true, | ||
| 221 | - optionFilterProp: 'label', | ||
| 222 | - placeholder: $t('foodLabeling.labels.selectProduct'), | ||
| 223 | - onChange: (v: string) => options.onProductIdChange?.(v), | ||
| 224 | - }, | ||
| 225 | - }, | ||
| 226 | - { | ||
| 227 | component: 'RadioGroup', | 300 | component: 'RadioGroup', |
| 228 | fieldName: 'state', | 301 | fieldName: 'state', |
| 229 | label: $t('foodLabeling.labels.status'), | 302 | label: $t('foodLabeling.labels.status'), |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/labels/label-modal.vue
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
| 2 | -import type { LabelDto, LabelTemplateDto } from '#/api/food-labeling'; | 2 | +import type { |
| 3 | + AccountLocationDto, | ||
| 4 | + LabelCategoryDto, | ||
| 5 | + LabelDto, | ||
| 6 | + LabelTemplateDto, | ||
| 7 | + LabelTypeDto, | ||
| 8 | +} from '#/api/food-labeling'; | ||
| 3 | 9 | ||
| 4 | import { computed, ref, watch } from 'vue'; | 10 | import { computed, ref, watch } from 'vue'; |
| 5 | 11 | ||
| @@ -31,6 +37,11 @@ import { buildCreateLabelPreviewTemplate } from '../../shared/label-form-preview | @@ -31,6 +37,11 @@ import { buildCreateLabelPreviewTemplate } from '../../shared/label-form-preview | ||
| 31 | import { listNutritionElements } from '../../shared/nutrition-manual-entry'; | 37 | import { listNutritionElements } from '../../shared/nutrition-manual-entry'; |
| 32 | import { MOCK_LABELS } from '../../shared/mock-data'; | 38 | import { MOCK_LABELS } from '../../shared/mock-data'; |
| 33 | import { FOOD_LABELING_STATIC_ONLY } from '../../shared/static-mode'; | 39 | import { FOOD_LABELING_STATIC_ONLY } from '../../shared/static-mode'; |
| 40 | +import { useCategoryScopeAuth } from '../../shared/use-category-scope-auth'; | ||
| 41 | +import { | ||
| 42 | + locationsScopedForTemplateScope, | ||
| 43 | + regionOptionsForPartners, | ||
| 44 | +} from '../../shared/label-template/label-template-scope'; | ||
| 34 | import { modalSchema } from './data'; | 45 | import { modalSchema } from './data'; |
| 35 | import LabelTemplateInputPanel from './label-template-input-panel.vue'; | 46 | import LabelTemplateInputPanel from './label-template-input-panel.vue'; |
| 36 | import LabelPreviewOnly from './label-preview-only.vue'; | 47 | import LabelPreviewOnly from './label-preview-only.vue'; |
| @@ -44,15 +55,19 @@ const modalOpen = ref(false); | @@ -44,15 +55,19 @@ const modalOpen = ref(false); | ||
| 44 | 55 | ||
| 45 | const { | 56 | const { |
| 46 | loading: lookupsLoading, | 57 | loading: lookupsLoading, |
| 47 | - locationOptions, | ||
| 48 | - categoryOptions, | ||
| 49 | - typeOptions, | ||
| 50 | - templateOptions, | ||
| 51 | - productOptions, | 58 | + partners, |
| 59 | + groups, | ||
| 60 | + locations, | ||
| 61 | + labelCategories, | ||
| 62 | + labelTypes, | ||
| 63 | + templates, | ||
| 64 | + productCategories, | ||
| 52 | products, | 65 | products, |
| 53 | loadLookups, | 66 | loadLookups, |
| 54 | } = useLabelLookups(); | 67 | } = useLabelLookups(); |
| 55 | 68 | ||
| 69 | +const scopeAuth = useCategoryScopeAuth(); | ||
| 70 | + | ||
| 56 | const selectedTemplate = ref<LabelTemplateDto | null>(null); | 71 | const selectedTemplate = ref<LabelTemplateDto | null>(null); |
| 57 | const templateLoading = ref(false); | 72 | const templateLoading = ref(false); |
| 58 | const templateDataValues = ref<Record<string, string>>({}); | 73 | const templateDataValues = ref<Record<string, string>>({}); |
| @@ -72,6 +87,152 @@ const selectedProductCodeValue = computed(() => { | @@ -72,6 +87,152 @@ const selectedProductCodeValue = computed(() => { | ||
| 72 | 87 | ||
| 73 | const formValues = ref<Record<string, unknown>>({}); | 88 | const formValues = ref<Record<string, unknown>>({}); |
| 74 | 89 | ||
| 90 | +function stringId(raw: unknown): string { | ||
| 91 | + return String(raw ?? '').trim(); | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +function idList(raw: unknown): string[] { | ||
| 95 | + if (!Array.isArray(raw)) return []; | ||
| 96 | + return [...new Set(raw.map((x) => stringId(x)).filter(Boolean))]; | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +function intersects(a: string[], b: string[]): boolean { | ||
| 100 | + if (!a.length || !b.length) return false; | ||
| 101 | + const set = new Set(a); | ||
| 102 | + return b.some((id) => set.has(id)); | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +function optionFromIdName(id: string, label: string) { | ||
| 106 | + return { value: id, label: label || id }; | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +const effectivePartnerId = computed(() => { | ||
| 110 | + if (scopeAuth.requireCompanySelection.value) { | ||
| 111 | + return stringId(formValues.value.partnerId); | ||
| 112 | + } | ||
| 113 | + return stringId(scopeAuth.fixedPartnerId.value); | ||
| 114 | +}); | ||
| 115 | + | ||
| 116 | +const selectedRegionIds = computed(() => idList(formValues.value.regionIds)); | ||
| 117 | + | ||
| 118 | +const scopeReady = computed( | ||
| 119 | + () => !!effectivePartnerId.value && selectedRegionIds.value.length > 0, | ||
| 120 | +); | ||
| 121 | + | ||
| 122 | +const partnerOptions = computed(() => | ||
| 123 | + partners.value.map((p) => | ||
| 124 | + optionFromIdName(p.id, String(p.partnerName ?? '').trim()), | ||
| 125 | + ), | ||
| 126 | +); | ||
| 127 | + | ||
| 128 | +const regionOptions = computed(() => | ||
| 129 | + effectivePartnerId.value | ||
| 130 | + ? regionOptionsForPartners(groups.value, [effectivePartnerId.value]) | ||
| 131 | + : [], | ||
| 132 | +); | ||
| 133 | + | ||
| 134 | +const scopedLocations = computed(() => { | ||
| 135 | + if (!scopeReady.value) return [] as AccountLocationDto[]; | ||
| 136 | + return locationsScopedForTemplateScope( | ||
| 137 | + locations.value, | ||
| 138 | + partners.value, | ||
| 139 | + groups.value, | ||
| 140 | + [effectivePartnerId.value], | ||
| 141 | + selectedRegionIds.value, | ||
| 142 | + ); | ||
| 143 | +}); | ||
| 144 | + | ||
| 145 | +const scopedLocationIds = computed(() => scopedLocations.value.map((x) => x.id)); | ||
| 146 | + | ||
| 147 | +function matchesScope(row: { | ||
| 148 | + groupIds?: string[] | null; | ||
| 149 | + regionIds?: string[] | null; | ||
| 150 | + locationIds?: string[] | null; | ||
| 151 | + appliedLocationIds?: string[] | null; | ||
| 152 | + partnerId?: string | null; | ||
| 153 | + partnerIds?: string[] | null; | ||
| 154 | + companyIds?: string[] | null; | ||
| 155 | +}) { | ||
| 156 | + const partnerIds = idList([ | ||
| 157 | + ...(row.partnerIds ?? []), | ||
| 158 | + ...(row.companyIds ?? []), | ||
| 159 | + row.partnerId, | ||
| 160 | + ]); | ||
| 161 | + if (partnerIds.length && !partnerIds.includes(effectivePartnerId.value)) return false; | ||
| 162 | + | ||
| 163 | + const regionIds = idList([...(row.groupIds ?? []), ...(row.regionIds ?? [])]); | ||
| 164 | + if (regionIds.length && !intersects(regionIds, selectedRegionIds.value)) return false; | ||
| 165 | + | ||
| 166 | + const locationIds = idList([ | ||
| 167 | + ...(row.locationIds ?? []), | ||
| 168 | + ...(row.appliedLocationIds ?? []), | ||
| 169 | + ]); | ||
| 170 | + if (locationIds.length && !intersects(locationIds, scopedLocationIds.value)) return false; | ||
| 171 | + | ||
| 172 | + return true; | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +const scopedLocationOptions = computed(() => | ||
| 176 | + scopedLocations.value.map((loc) => | ||
| 177 | + optionFromIdName( | ||
| 178 | + loc.id, | ||
| 179 | + [loc.locationName, loc.locationCode].filter(Boolean).join(' - '), | ||
| 180 | + ), | ||
| 181 | + ), | ||
| 182 | +); | ||
| 183 | + | ||
| 184 | +const scopedProductCategoryOptions = computed(() => | ||
| 185 | + productCategories.value | ||
| 186 | + .filter((row) => row.state !== false && matchesScope(row)) | ||
| 187 | + .map((row) => | ||
| 188 | + optionFromIdName(row.id, String(row.categoryName ?? row.id).trim()), | ||
| 189 | + ), | ||
| 190 | +); | ||
| 191 | + | ||
| 192 | +const scopedProductOptions = computed(() => { | ||
| 193 | + const categoryId = stringId(formValues.value.productCategoryId); | ||
| 194 | + if (!categoryId || !scopeReady.value) return []; | ||
| 195 | + return products.value | ||
| 196 | + .filter( | ||
| 197 | + (row) => | ||
| 198 | + row.state !== false | ||
| 199 | + && stringId(row.categoryId) === categoryId | ||
| 200 | + && matchesScope(row), | ||
| 201 | + ) | ||
| 202 | + .map((row) => | ||
| 203 | + optionFromIdName( | ||
| 204 | + row.id, | ||
| 205 | + [row.productName, row.productCode].filter(Boolean).join(' - '), | ||
| 206 | + ), | ||
| 207 | + ); | ||
| 208 | +}); | ||
| 209 | + | ||
| 210 | +const scopedTemplateOptions = computed(() => | ||
| 211 | + templates.value | ||
| 212 | + .filter((row) => row.state !== false && matchesScope(row)) | ||
| 213 | + .map((row) => { | ||
| 214 | + const name = (row.name ?? row.templateName ?? '').trim() || row.id; | ||
| 215 | + const code = (row.templateCode ?? row.id ?? '').trim(); | ||
| 216 | + return { label: `${name} (${code})`, value: code }; | ||
| 217 | + }), | ||
| 218 | +); | ||
| 219 | + | ||
| 220 | +const scopedCategoryOptions = computed(() => | ||
| 221 | + labelCategories.value | ||
| 222 | + .filter((row: LabelCategoryDto) => row.state !== false && matchesScope(row)) | ||
| 223 | + .map((row) => | ||
| 224 | + optionFromIdName(row.id, String(row.categoryName ?? row.id).trim()), | ||
| 225 | + ), | ||
| 226 | +); | ||
| 227 | + | ||
| 228 | +const scopedTypeOptions = computed(() => | ||
| 229 | + labelTypes.value | ||
| 230 | + .filter((row: LabelTypeDto) => row.state !== false && matchesScope(row)) | ||
| 231 | + .map((row) => | ||
| 232 | + optionFromIdName(row.id, String(row.typeName ?? row.id).trim()), | ||
| 233 | + ), | ||
| 234 | +); | ||
| 235 | + | ||
| 75 | const hasTemplateSelected = computed(() => !!String(formValues.value.templateCode ?? '').trim()); | 236 | const hasTemplateSelected = computed(() => !!String(formValues.value.templateCode ?? '').trim()); |
| 76 | 237 | ||
| 77 | const showTemplateInputColumn = computed(() => { | 238 | const showTemplateInputColumn = computed(() => { |
| @@ -103,7 +264,7 @@ function resetTemplateInputState() { | @@ -103,7 +264,7 @@ function resetTemplateInputState() { | ||
| 103 | function labelTypeNameForId(labelTypeId: string): string { | 264 | function labelTypeNameForId(labelTypeId: string): string { |
| 104 | const ltid = labelTypeId.trim(); | 265 | const ltid = labelTypeId.trim(); |
| 105 | if (!ltid) return ''; | 266 | if (!ltid) return ''; |
| 106 | - const hit = typeOptions.value.find((o) => String(o.value) === ltid); | 267 | + const hit = scopedTypeOptions.value.find((o) => String(o.value) === ltid); |
| 107 | return String(hit?.label ?? '').trim(); | 268 | return String(hit?.label ?? '').trim(); |
| 108 | } | 269 | } |
| 109 | 270 | ||
| @@ -123,6 +284,10 @@ function applyTemplateInputStateFromForm() { | @@ -123,6 +284,10 @@ function applyTemplateInputStateFromForm() { | ||
| 123 | nutritionByElementId.value = state.nutritionByElementId; | 284 | nutritionByElementId.value = state.nutritionByElementId; |
| 124 | } | 285 | } |
| 125 | 286 | ||
| 287 | +function refreshSchema() { | ||
| 288 | + formApi.setState({ schema: buildFormSchema() }); | ||
| 289 | +} | ||
| 290 | + | ||
| 126 | async function loadSelectedTemplate(code: string) { | 291 | async function loadSelectedTemplate(code: string) { |
| 127 | const trimmed = code.trim(); | 292 | const trimmed = code.trim(); |
| 128 | if (!trimmed) { | 293 | if (!trimmed) { |
| @@ -156,19 +321,68 @@ async function onTemplateCodeChange(code: string) { | @@ -156,19 +321,68 @@ async function onTemplateCodeChange(code: string) { | ||
| 156 | await loadSelectedTemplate(String(code ?? '')); | 321 | await loadSelectedTemplate(String(code ?? '')); |
| 157 | } | 322 | } |
| 158 | 323 | ||
| 324 | +async function resetDownstream(values: Record<string, unknown>) { | ||
| 325 | + await formApi.setValues(values); | ||
| 326 | + await refreshFormValues(); | ||
| 327 | + refreshSchema(); | ||
| 328 | + resetTemplateInputState(); | ||
| 329 | +} | ||
| 330 | + | ||
| 331 | +async function onPartnerIdChange(partnerId: string) { | ||
| 332 | + await resetDownstream({ | ||
| 333 | + partnerId, | ||
| 334 | + regionIds: [], | ||
| 335 | + productCategoryId: '', | ||
| 336 | + productId: '', | ||
| 337 | + templateCode: '', | ||
| 338 | + locationId: '', | ||
| 339 | + labelCategoryId: '', | ||
| 340 | + labelTypeId: '', | ||
| 341 | + }); | ||
| 342 | +} | ||
| 343 | + | ||
| 344 | +async function onRegionIdsChange(regionIds: string[]) { | ||
| 345 | + await resetDownstream({ | ||
| 346 | + regionIds: idList(regionIds), | ||
| 347 | + productCategoryId: '', | ||
| 348 | + productId: '', | ||
| 349 | + templateCode: '', | ||
| 350 | + locationId: '', | ||
| 351 | + labelCategoryId: '', | ||
| 352 | + labelTypeId: '', | ||
| 353 | + }); | ||
| 354 | +} | ||
| 355 | + | ||
| 356 | +async function onProductCategoryIdChange(productCategoryId: string) { | ||
| 357 | + await formApi.setValues({ productCategoryId, productId: '' }); | ||
| 358 | + await refreshFormValues(); | ||
| 359 | + refreshSchema(); | ||
| 360 | + applyTemplateInputStateFromForm(); | ||
| 361 | +} | ||
| 362 | + | ||
| 159 | async function onProductOrTypeChange() { | 363 | async function onProductOrTypeChange() { |
| 160 | await refreshFormValues(); | 364 | await refreshFormValues(); |
| 161 | applyTemplateInputStateFromForm(); | 365 | applyTemplateInputStateFromForm(); |
| 162 | } | 366 | } |
| 163 | 367 | ||
| 164 | function buildFormSchema() { | 368 | function buildFormSchema() { |
| 369 | + const scopedDisabled = !scopeReady.value; | ||
| 165 | return modalSchema({ | 370 | return modalSchema({ |
| 166 | - locationOptions: locationOptions.value, | ||
| 167 | - categoryOptions: categoryOptions.value, | ||
| 168 | - typeOptions: typeOptions.value, | ||
| 169 | - templateOptions: templateOptions.value, | ||
| 170 | - productOptions: productOptions.value, | 371 | + partnerOptions: partnerOptions.value, |
| 372 | + regionOptions: regionOptions.value, | ||
| 373 | + productCategoryOptions: scopedProductCategoryOptions.value, | ||
| 374 | + locationOptions: scopedLocationOptions.value, | ||
| 375 | + categoryOptions: scopedCategoryOptions.value, | ||
| 376 | + typeOptions: scopedTypeOptions.value, | ||
| 377 | + templateOptions: scopedTemplateOptions.value, | ||
| 378 | + productOptions: scopedProductOptions.value, | ||
| 171 | isUpdate: isUpdate.value, | 379 | isUpdate: isUpdate.value, |
| 380 | + requireCompanySelection: scopeAuth.requireCompanySelection.value, | ||
| 381 | + regionDisabled: !effectivePartnerId.value, | ||
| 382 | + scopedFieldsDisabled: scopedDisabled, | ||
| 383 | + onPartnerIdChange, | ||
| 384 | + onRegionIdsChange, | ||
| 385 | + onProductCategoryIdChange, | ||
| 172 | onTemplateCodeChange, | 386 | onTemplateCodeChange, |
| 173 | onProductIdChange: onProductOrTypeChange, | 387 | onProductIdChange: onProductOrTypeChange, |
| 174 | onLabelTypeIdChange: onProductOrTypeChange, | 388 | onLabelTypeIdChange: onProductOrTypeChange, |
| @@ -226,7 +440,6 @@ const [BasicModal, modalApi] = useVbenModal({ | @@ -226,7 +440,6 @@ const [BasicModal, modalApi] = useVbenModal({ | ||
| 226 | resetTemplateInputState(); | 440 | resetTemplateInputState(); |
| 227 | 441 | ||
| 228 | await loadLookups(); | 442 | await loadLookups(); |
| 229 | - formApi.setState({ schema: buildFormSchema() }); | ||
| 230 | 443 | ||
| 231 | if (isUpdate.value && labelCode.value) { | 444 | if (isUpdate.value && labelCode.value) { |
| 232 | let record: LabelDto; | 445 | let record: LabelDto; |
| @@ -240,12 +453,18 @@ const [BasicModal, modalApi] = useVbenModal({ | @@ -240,12 +453,18 @@ const [BasicModal, modalApi] = useVbenModal({ | ||
| 240 | } | 453 | } |
| 241 | await formApi.setValues(dtoToForm(record)); | 454 | await formApi.setValues(dtoToForm(record)); |
| 242 | await refreshFormValues(); | 455 | await refreshFormValues(); |
| 456 | + refreshSchema(); | ||
| 243 | const code = String(record.templateCode ?? '').trim(); | 457 | const code = String(record.templateCode ?? '').trim(); |
| 244 | if (code) await loadSelectedTemplate(code); | 458 | if (code) await loadSelectedTemplate(code); |
| 245 | } else { | 459 | } else { |
| 246 | await formApi.resetForm(); | 460 | await formApi.resetForm(); |
| 247 | - await formApi.setValues({ state: true }); | 461 | + await formApi.setValues({ |
| 462 | + state: true, | ||
| 463 | + partnerId: scopeAuth.requireCompanySelection.value ? '' : scopeAuth.fixedPartnerId.value, | ||
| 464 | + regionIds: [], | ||
| 465 | + }); | ||
| 248 | await refreshFormValues(); | 466 | await refreshFormValues(); |
| 467 | + refreshSchema(); | ||
| 249 | } | 468 | } |
| 250 | modalApi.modalLoading(false); | 469 | modalApi.modalLoading(false); |
| 251 | }, | 470 | }, |
| @@ -255,8 +474,21 @@ function dtoToForm(d: LabelDto) { | @@ -255,8 +474,21 @@ function dtoToForm(d: LabelDto) { | ||
| 255 | const productIds = d.productIds ?? []; | 474 | const productIds = d.productIds ?? []; |
| 256 | const firstProduct = | 475 | const firstProduct = |
| 257 | Array.isArray(productIds) && productIds.length ? String(productIds[0]).trim() : ''; | 476 | Array.isArray(productIds) && productIds.length ? String(productIds[0]).trim() : ''; |
| 477 | + const loc = locations.value.find((x) => x.id === stringId(d.locationId)); | ||
| 478 | + const partner = | ||
| 479 | + partners.value.find((x) => stringId(x.partnerName) === stringId(loc?.partner)) | ||
| 480 | + ?? partners.value.find((x) => x.id === effectivePartnerId.value); | ||
| 481 | + const region = groups.value.find( | ||
| 482 | + (x) => | ||
| 483 | + stringId(x.groupName) === stringId(loc?.groupName) | ||
| 484 | + && (!loc?.partner || stringId(x.partnerName) === stringId(loc.partner)), | ||
| 485 | + ); | ||
| 486 | + const product = products.value.find((x) => x.id === firstProduct); | ||
| 258 | return { | 487 | return { |
| 259 | labelCode: d.labelCode ?? d.id ?? '', | 488 | labelCode: d.labelCode ?? d.id ?? '', |
| 489 | + partnerId: partner?.id ?? effectivePartnerId.value, | ||
| 490 | + regionIds: region?.id ? [region.id] : [], | ||
| 491 | + productCategoryId: product?.categoryId ?? '', | ||
| 260 | labelName: d.labelName ?? '', | 492 | labelName: d.labelName ?? '', |
| 261 | templateCode: d.templateCode ?? '', | 493 | templateCode: d.templateCode ?? '', |
| 262 | locationId: d.locationId ?? '', | 494 | locationId: d.locationId ?? '', |
| @@ -351,8 +583,21 @@ async function handleConfirm() { | @@ -351,8 +583,21 @@ async function handleConfirm() { | ||
| 351 | return; | 583 | return; |
| 352 | } | 584 | } |
| 353 | const values = cloneDeep(await formApi.getValues()); | 585 | const values = cloneDeep(await formApi.getValues()); |
| 586 | + if (scopeAuth.requireCompanySelection.value && !stringId(values.partnerId)) { | ||
| 587 | + message.error($t('foodLabeling.labels.companyRequired')); | ||
| 588 | + return; | ||
| 589 | + } | ||
| 590 | + if (!idList(values.regionIds).length) { | ||
| 591 | + message.error($t('foodLabeling.labels.regionRequired')); | ||
| 592 | + return; | ||
| 593 | + } | ||
| 594 | + if (!stringId(values.productCategoryId)) { | ||
| 595 | + message.error($t('foodLabeling.labels.productCategoryRequired')); | ||
| 596 | + return; | ||
| 597 | + } | ||
| 354 | const payload = formToPayload(values); | 598 | const payload = formToPayload(values); |
| 355 | if (!payload.productIds.length) { | 599 | if (!payload.productIds.length) { |
| 600 | + message.error($t('foodLabeling.labels.productRequired')); | ||
| 356 | return; | 601 | return; |
| 357 | } | 602 | } |
| 358 | if (FOOD_LABELING_STATIC_ONLY) { | 603 | if (FOOD_LABELING_STATIC_ONLY) { |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/labels/label-template-input-panel.vue
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
| 2 | import type { LabelTemplateDto } from '#/api/food-labeling/types'; | 2 | import type { LabelTemplateDto } from '#/api/food-labeling/types'; |
| 3 | 3 | ||
| 4 | -import type { LabelElement } from '../../../shared/label-template/label-template-model'; | 4 | +import type { LabelElement } from '../../shared/label-template/label-template-model'; |
| 5 | 5 | ||
| 6 | import { computed } from 'vue'; | 6 | import { computed } from 'vue'; |
| 7 | 7 | ||
| @@ -11,18 +11,18 @@ import { | @@ -11,18 +11,18 @@ import { | ||
| 11 | dataEntryColumnLabel, | 11 | dataEntryColumnLabel, |
| 12 | isDateTimeDataEntryField, | 12 | isDateTimeDataEntryField, |
| 13 | sortTemplateElementsForDisplay, | 13 | sortTemplateElementsForDisplay, |
| 14 | -} from '../../../shared/label-template/label-template-model'; | 14 | +} from '../../shared/label-template/label-template-model'; |
| 15 | import { | 15 | import { |
| 16 | LABEL_FORM_OFFSET_UNITS, | 16 | LABEL_FORM_OFFSET_UNITS, |
| 17 | offsetFieldUiStateFromStored, | 17 | offsetFieldUiStateFromStored, |
| 18 | serializePrintInputOffset, | 18 | serializePrintInputOffset, |
| 19 | -} from '../../../shared/label-form-date-preview'; | 19 | +} from '../../shared/label-form-date-preview'; |
| 20 | import { | 20 | import { |
| 21 | dataEntryUsesImageUpload, | 21 | dataEntryUsesImageUpload, |
| 22 | getCreateLabelTemplateInputElements, | 22 | getCreateLabelTemplateInputElements, |
| 23 | -} from '../../../shared/label-form-template-input'; | ||
| 24 | -import { listNutritionElements } from '../../../shared/nutrition-manual-entry'; | ||
| 25 | -import { isTemplateSectionBarcodeOrQrElement } from '../../../shared/product-code-value-template'; | 23 | +} from '../../shared/label-form-template-input'; |
| 24 | +import { listNutritionElements } from '../../shared/nutrition-manual-entry'; | ||
| 25 | +import { isTemplateSectionBarcodeOrQrElement } from '../../shared/product-code-value-template'; | ||
| 26 | import DataEntryImageUploadField from '../label-templates/data-entry/data-entry-image-upload-field.vue'; | 26 | import DataEntryImageUploadField from '../label-templates/data-entry/data-entry-image-upload-field.vue'; |
| 27 | import NutritionManualEntryForm from '../label-templates/editor/nutrition-manual-entry-form.vue'; | 27 | import NutritionManualEntryForm from '../label-templates/editor/nutrition-manual-entry-form.vue'; |
| 28 | 28 |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/labeling/labels/use-label-lookups.ts
| 1 | -import type { ProductDto } from '#/api/food-labeling/types'; | 1 | +import type { |
| 2 | + AccountLocationDto, | ||
| 3 | + GroupListItemDto, | ||
| 4 | + LabelCategoryDto, | ||
| 5 | + LabelTemplateDto, | ||
| 6 | + LabelTypeDto, | ||
| 7 | + PartnerDto, | ||
| 8 | + ProductCategoryDto, | ||
| 9 | + ProductDto, | ||
| 10 | +} from '#/api/food-labeling'; | ||
| 2 | 11 | ||
| 3 | import type { SelectProps } from 'ant-design-vue'; | 12 | import type { SelectProps } from 'ant-design-vue'; |
| 4 | 13 | ||
| @@ -8,8 +17,14 @@ import { | @@ -8,8 +17,14 @@ import { | ||
| 8 | MOCK_LABEL_CATEGORIES, | 17 | MOCK_LABEL_CATEGORIES, |
| 9 | MOCK_LABEL_TEMPLATES, | 18 | MOCK_LABEL_TEMPLATES, |
| 10 | MOCK_LABEL_TYPES, | 19 | MOCK_LABEL_TYPES, |
| 11 | - MOCK_LOCATION_OPTIONS, | ||
| 12 | } from '../../shared/mock-data'; | 20 | } from '../../shared/mock-data'; |
| 21 | +import { | ||
| 22 | + MOCK_GROUPS, | ||
| 23 | + MOCK_LOCATIONS, | ||
| 24 | + MOCK_PARTNERS, | ||
| 25 | + MOCK_PRODUCT_CATEGORIES, | ||
| 26 | + MOCK_PRODUCTS, | ||
| 27 | +} from '../../shared/mock-management-data'; | ||
| 13 | import { FOOD_LABELING_STATIC_ONLY } from '../../shared/static-mode'; | 28 | import { FOOD_LABELING_STATIC_ONLY } from '../../shared/static-mode'; |
| 14 | 29 | ||
| 15 | export type SelectOption = NonNullable<SelectProps['options']>[number]; | 30 | export type SelectOption = NonNullable<SelectProps['options']>[number]; |
| @@ -24,6 +39,12 @@ function toOptions<T extends { id: string }>( | @@ -24,6 +39,12 @@ function toOptions<T extends { id: string }>( | ||
| 24 | })); | 39 | })); |
| 25 | } | 40 | } |
| 26 | 41 | ||
| 42 | +function templateOption(row: LabelTemplateDto): SelectOption { | ||
| 43 | + const name = (row.name ?? row.templateName ?? '').trim() || row.id; | ||
| 44 | + const code = (row.templateCode ?? row.id ?? '').trim(); | ||
| 45 | + return { label: `${name} (${code})`, value: code }; | ||
| 46 | +} | ||
| 47 | + | ||
| 27 | export function useLabelLookups() { | 48 | export function useLabelLookups() { |
| 28 | const loading = ref(false); | 49 | const loading = ref(false); |
| 29 | const locationOptions = ref<SelectOption[]>([]); | 50 | const locationOptions = ref<SelectOption[]>([]); |
| @@ -31,71 +52,79 @@ export function useLabelLookups() { | @@ -31,71 +52,79 @@ export function useLabelLookups() { | ||
| 31 | const typeOptions = ref<SelectOption[]>([]); | 52 | const typeOptions = ref<SelectOption[]>([]); |
| 32 | const templateOptions = ref<SelectOption[]>([]); | 53 | const templateOptions = ref<SelectOption[]>([]); |
| 33 | const productOptions = ref<SelectOption[]>([]); | 54 | const productOptions = ref<SelectOption[]>([]); |
| 55 | + const partners = ref<PartnerDto[]>([]); | ||
| 56 | + const groups = ref<GroupListItemDto[]>([]); | ||
| 57 | + const locations = ref<AccountLocationDto[]>([]); | ||
| 58 | + const labelCategories = ref<LabelCategoryDto[]>([]); | ||
| 59 | + const labelTypes = ref<LabelTypeDto[]>([]); | ||
| 60 | + const templates = ref<LabelTemplateDto[]>([]); | ||
| 61 | + const productCategories = ref<ProductCategoryDto[]>([]); | ||
| 34 | const products = ref<ProductDto[]>([]); | 62 | const products = ref<ProductDto[]>([]); |
| 35 | 63 | ||
| 36 | async function loadLookups() { | 64 | async function loadLookups() { |
| 37 | loading.value = true; | 65 | loading.value = true; |
| 38 | try { | 66 | try { |
| 39 | if (FOOD_LABELING_STATIC_ONLY) { | 67 | if (FOOD_LABELING_STATIC_ONLY) { |
| 40 | - locationOptions.value = MOCK_LOCATION_OPTIONS; | ||
| 41 | - categoryOptions.value = toOptions(MOCK_LABEL_CATEGORIES, (r) => | ||
| 42 | - String(r.categoryName ?? r.id), | 68 | + partners.value = [...MOCK_PARTNERS]; |
| 69 | + groups.value = [...MOCK_GROUPS]; | ||
| 70 | + locations.value = [...MOCK_LOCATIONS]; | ||
| 71 | + labelCategories.value = [...MOCK_LABEL_CATEGORIES] as LabelCategoryDto[]; | ||
| 72 | + labelTypes.value = [...MOCK_LABEL_TYPES] as LabelTypeDto[]; | ||
| 73 | + templates.value = [...MOCK_LABEL_TEMPLATES] as LabelTemplateDto[]; | ||
| 74 | + productCategories.value = [...MOCK_PRODUCT_CATEGORIES]; | ||
| 75 | + products.value = [...MOCK_PRODUCTS]; | ||
| 76 | + } else { | ||
| 77 | + const { labelCategoryList } = await import( | ||
| 78 | + '#/api/food-labeling/label-category' | ||
| 79 | + ); | ||
| 80 | + const { labelTypeList } = await import( | ||
| 81 | + '#/api/food-labeling/label-type' | ||
| 82 | + ); | ||
| 83 | + const { labelTemplateList } = await import( | ||
| 84 | + '#/api/food-labeling/label-template' | ||
| 43 | ); | 85 | ); |
| 44 | - typeOptions.value = toOptions(MOCK_LABEL_TYPES, (r) => | ||
| 45 | - String(r.typeName ?? r.id), | 86 | + const { partnerList } = await import('#/api/food-labeling/partner'); |
| 87 | + const { groupList } = await import('#/api/food-labeling/group'); | ||
| 88 | + const { locationList } = await import('#/api/food-labeling/location'); | ||
| 89 | + const { productCategoryList } = await import( | ||
| 90 | + '#/api/food-labeling/product-category' | ||
| 46 | ); | 91 | ); |
| 47 | - templateOptions.value = MOCK_LABEL_TEMPLATES.map((r) => { | ||
| 48 | - const name = (r.templateName ?? r.name ?? '').trim() || '—'; | ||
| 49 | - const code = (r.templateCode ?? r.id ?? '').trim(); | ||
| 50 | - return { label: `${name} (${code})`, value: code }; | ||
| 51 | - }); | ||
| 52 | - productOptions.value = [ | ||
| 53 | - { label: 'Organic Apples · P001', value: 'prod-1' }, | ||
| 54 | - { label: 'Whole Milk · P002', value: 'prod-2' }, | ||
| 55 | - ]; | ||
| 56 | - products.value = [ | ||
| 57 | - { id: 'prod-1', productName: 'Organic Apples', productCode: 'P001', codeValue: '1234567890' }, | ||
| 58 | - { id: 'prod-2', productName: 'Whole Milk', productCode: 'P002', codeValue: '0987654321' }, | ||
| 59 | - ] as ProductDto[]; | ||
| 60 | - return; | 92 | + const { productList } = await import('#/api/food-labeling/product'); |
| 93 | + const lookupPage = { SkipCount: 1, MaxResultCount: 500 }; | ||
| 94 | + const lookupProductPage = { SkipCount: 1, MaxResultCount: 1000 }; | ||
| 95 | + const [ptn, grp, loc, cat, typ, tpl, pcat, prod] = await Promise.all([ | ||
| 96 | + partnerList(lookupPage), | ||
| 97 | + groupList(lookupPage), | ||
| 98 | + locationList(lookupPage), | ||
| 99 | + labelCategoryList(lookupPage), | ||
| 100 | + labelTypeList(lookupPage), | ||
| 101 | + labelTemplateList(lookupPage), | ||
| 102 | + productCategoryList(lookupPage), | ||
| 103 | + productList(lookupProductPage), | ||
| 104 | + ]); | ||
| 105 | + partners.value = ptn.items ?? []; | ||
| 106 | + groups.value = grp.items ?? []; | ||
| 107 | + locations.value = loc.items ?? []; | ||
| 108 | + labelCategories.value = cat.items ?? []; | ||
| 109 | + labelTypes.value = typ.items ?? []; | ||
| 110 | + templates.value = tpl.items ?? []; | ||
| 111 | + productCategories.value = pcat.items ?? []; | ||
| 112 | + products.value = prod.items ?? []; | ||
| 61 | } | 113 | } |
| 62 | - const { labelCategoryList } = await import( | ||
| 63 | - '#/api/food-labeling/label-category' | ||
| 64 | - ); | ||
| 65 | - const { labelTypeList } = await import('#/api/food-labeling/label-type'); | ||
| 66 | - const { labelTemplateList } = await import( | ||
| 67 | - '#/api/food-labeling/label-template' | ||
| 68 | - ); | ||
| 69 | - const { locationList, productList } = await import( | ||
| 70 | - '#/api/food-labeling/lookups' | ||
| 71 | - ); | ||
| 72 | - const lookupPage = { SkipCount: 1, MaxResultCount: 500 }; | ||
| 73 | - const lookupProductPage = { SkipCount: 1, MaxResultCount: 1000 }; | ||
| 74 | - const [loc, cat, typ, tpl, prod] = await Promise.all([ | ||
| 75 | - locationList(), | ||
| 76 | - labelCategoryList(lookupPage), | ||
| 77 | - labelTypeList(lookupPage), | ||
| 78 | - labelTemplateList(lookupPage), | ||
| 79 | - productList(lookupProductPage), | ||
| 80 | - ]); | ||
| 81 | - locationOptions.value = toOptions(loc.items ?? [], (r) => | ||
| 82 | - [r.locationName, r.locationCode].filter(Boolean).join(' · '), | 114 | + |
| 115 | + locationOptions.value = toOptions(locations.value, (r) => | ||
| 116 | + [r.locationName, r.locationCode].filter(Boolean).join(' - '), | ||
| 83 | ); | 117 | ); |
| 84 | - categoryOptions.value = toOptions(cat.items ?? [], (r) => | 118 | + categoryOptions.value = toOptions(labelCategories.value, (r) => |
| 85 | String(r.categoryName ?? r.id), | 119 | String(r.categoryName ?? r.id), |
| 86 | ); | 120 | ); |
| 87 | - typeOptions.value = toOptions(typ.items ?? [], (r) => | 121 | + typeOptions.value = toOptions(labelTypes.value, (r) => |
| 88 | String(r.typeName ?? r.id), | 122 | String(r.typeName ?? r.id), |
| 89 | ); | 123 | ); |
| 90 | - templateOptions.value = (tpl.items ?? []).map((r) => { | ||
| 91 | - const name = (r.templateName ?? r.name ?? '').trim() || '—'; | ||
| 92 | - const code = (r.templateCode ?? r.id ?? '').trim(); | ||
| 93 | - return { label: `${name} (${code})`, value: code }; | ||
| 94 | - }); | ||
| 95 | - productOptions.value = toOptions(prod.items ?? [], (r) => | ||
| 96 | - [r.productName, r.productCode].filter(Boolean).join(' · '), | 124 | + templateOptions.value = templates.value.map(templateOption); |
| 125 | + productOptions.value = toOptions(products.value, (r) => | ||
| 126 | + [r.productName, r.productCode].filter(Boolean).join(' - '), | ||
| 97 | ); | 127 | ); |
| 98 | - products.value = prod.items ?? []; | ||
| 99 | } finally { | 128 | } finally { |
| 100 | loading.value = false; | 129 | loading.value = false; |
| 101 | } | 130 | } |
| @@ -108,6 +137,13 @@ export function useLabelLookups() { | @@ -108,6 +137,13 @@ export function useLabelLookups() { | ||
| 108 | typeOptions, | 137 | typeOptions, |
| 109 | templateOptions, | 138 | templateOptions, |
| 110 | productOptions, | 139 | productOptions, |
| 140 | + partners, | ||
| 141 | + groups, | ||
| 142 | + locations, | ||
| 143 | + labelCategories, | ||
| 144 | + labelTypes, | ||
| 145 | + templates, | ||
| 146 | + productCategories, | ||
| 111 | products, | 147 | products, |
| 112 | loadLookups, | 148 | loadLookups, |
| 113 | }; | 149 | }; |
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/views/food-labeling/shared/invert-colors.ts
| 1 | export function readInvertColors(cfg: Record<string, unknown> | null | undefined): boolean { | 1 | export function readInvertColors(cfg: Record<string, unknown> | null | undefined): boolean { |
| 2 | - return cfg?.invertColors === true || cfg?.InvertColors === true; | 2 | + if (!cfg) return false; |
| 3 | + const raw = cfg.invertColors ?? cfg.InvertColors; | ||
| 4 | + if (raw === true || raw === 1) return true; | ||
| 5 | + if (typeof raw === 'string') { | ||
| 6 | + const v = raw.trim().toLowerCase(); | ||
| 7 | + return v === 'true' || v === '1' || v === 'yes'; | ||
| 8 | + } | ||
| 9 | + return false; | ||
| 3 | } | 10 | } |
| 4 | 11 | ||
| 12 | +export const INVERT_COLORS_BG = '#000000'; | ||
| 13 | +export const INVERT_COLORS_FG = '#ffffff'; | ||
| 14 | + | ||
| 5 | export function isTextLikeElementForInvertColors(type: string): boolean { | 15 | export function isTextLikeElementForInvertColors(type: string): boolean { |
| 6 | const t = String(type ?? '').toUpperCase(); | 16 | const t = String(type ?? '').toUpperCase(); |
| 7 | return ( | 17 | return ( |
美国版/Food Labeling Management App UniApp/src/utils/apiBase.ts
| @@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
| 2 | * 本地/打包未配置 VITE_US_API_BASE 时的兜底后端根地址(不含末尾 /)。 | 2 | * 本地/打包未配置 VITE_US_API_BASE 时的兜底后端根地址(不含末尾 /)。 |
| 3 | * 调试本地时请与 .env.development 保持一致;仅作 fallback,优先使用环境变量。 | 3 | * 调试本地时请与 .env.development 保持一致;仅作 fallback,优先使用环境变量。 |
| 4 | */ | 4 | */ |
| 5 | -// export const US_BACKEND_ORIGIN_FALLBACK = 'http://flus-test.3ffoodsafety.com' | ||
| 6 | -export const US_BACKEND_ORIGIN_FALLBACK = 'http://192.168.31.89:19001' | 5 | +export const US_BACKEND_ORIGIN_FALLBACK = 'http://flus-test.3ffoodsafety.com' |
| 6 | +// export const US_BACKEND_ORIGIN_FALLBACK = 'http://192.168.31.89:19001' | ||
| 7 | 7 | ||
| 8 | /** | 8 | /** |
| 9 | * 解析美国版后端根地址(不含末尾 /)。 | 9 | * 解析美国版后端根地址(不含末尾 /)。 |
美国版/Food Labeling Management Platform/.env.local
美国版/Food Labeling Management Platform/build/assets/index-BGlBsk9e.js
0 → 100644
No preview for this file type
美国版/Food Labeling Management Platform/build/index.html
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | <meta charset="UTF-8" /> | 5 | <meta charset="UTF-8" /> |
| 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 7 | <title>Food Labeling Management Platform</title> | 7 | <title>Food Labeling Management Platform</title> |
| 8 | - <script type="module" crossorigin src="/assets/index-CCZCnrrc.js"></script> | 8 | + <script type="module" crossorigin src="/assets/index-BGlBsk9e.js"></script> |
| 9 | <link rel="stylesheet" crossorigin href="/assets/index-C6CSIunP.css"> | 9 | <link rel="stylesheet" crossorigin href="/assets/index-C6CSIunP.css"> |
| 10 | </head> | 10 | </head> |
| 11 | 11 |