From 823dc274628c3898090c736c58297fbce6b79a70 Mon Sep 17 00:00:00 2001
From: hrx <18603305412@163.com>
Date: Wed, 5 Aug 2026 10:18:32 +0800
Subject: [PATCH] =?UTF-8?q?8.5=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
f/web-kboss/src/utils/consultDict.js | 84 +++++++++++++++++++
.../MobileFullScreenConsultDialog.vue | 63 ++++++--------
.../src/views/homePage/dialog/talk/index.vue | 83 +++++++++---------
3 files changed, 154 insertions(+), 76 deletions(-)
create mode 100644 f/web-kboss/src/utils/consultDict.js
diff --git a/f/web-kboss/src/utils/consultDict.js b/f/web-kboss/src/utils/consultDict.js
new file mode 100644
index 0000000..6ca9e3d
--- /dev/null
+++ b/f/web-kboss/src/utils/consultDict.js
@@ -0,0 +1,84 @@
+export function isEnglishLocale(i18n) {
+ return !!(i18n && i18n.locale === 'en-US')
+}
+
+export function getDictLabel(item, isEn) {
+ if (!item) return ''
+ if (isEn) {
+ return item.dict_value_en || item.dict_value_zh || item.dict_value || ''
+ }
+ return item.dict_value_zh || item.dict_value || item.dict_value_en || ''
+}
+
+export function extractConsultOptionList(res) {
+ if (res && Array.isArray(res.data)) return res.data
+ if (res && res.data && Array.isArray(res.data.data)) return res.data.data
+ return []
+}
+
+export function normalizeDictOptions(list, type) {
+ return list
+ .filter(item => item && item.dict_type === type)
+ .sort((a, b) => Number(a.sort_order || 0) - Number(b.sort_order || 0))
+ .map(item => ({
+ id: String(item.dict_key),
+ nameZh: item.dict_value_zh || item.dict_value || '',
+ nameEn: item.dict_value_en || item.dict_value_zh || item.dict_value || ''
+ }))
+}
+
+export function parseDirectionParts(label, isEn) {
+ if (!label) {
+ return { title: '', desc: '' }
+ }
+
+ const text = String(label)
+ if (isEn) {
+ const match = text.match(/^(.+?)\s*\((.+)\)\s*$/)
+ return match
+ ? { title: match[1].trim(), desc: match[2].trim() }
+ : { title: text, desc: '' }
+ }
+
+ const match = text.match(/^(.+?)((.+?))$/)
+ return match
+ ? { title: match[1].trim(), desc: match[2].trim() }
+ : { title: text, desc: '' }
+}
+
+export function normalizeDirectionOptions(list) {
+ return list
+ .filter(item => item && item.dict_type === 'direction')
+ .sort((a, b) => Number(a.sort_order || 0) - Number(b.sort_order || 0))
+ .map(item => {
+ const nameZh = item.dict_value_zh || item.dict_value || ''
+ const nameEn = item.dict_value_en || nameZh
+ const parts = parseDirectionParts(nameZh, false)
+
+ return {
+ id: String(item.dict_key),
+ nameZh,
+ nameEn,
+ titleZh: parts.title,
+ descZh: parts.desc,
+ titleEn: parseDirectionParts(nameEn, true).title,
+ descEn: parseDirectionParts(nameEn, true).desc
+ }
+ })
+}
+
+export function localizeDictOptions(options, isEn) {
+ return (options || []).map(item => ({
+ ...item,
+ name: isEn ? item.nameEn : item.nameZh
+ }))
+}
+
+export function localizeDirectionOptions(options, isEn) {
+ return (options || []).map(item => ({
+ ...item,
+ name: isEn ? item.nameEn : item.nameZh,
+ title: isEn ? item.titleEn : item.titleZh,
+ desc: isEn ? item.descEn : item.descZh
+ }))
+}
diff --git a/f/web-kboss/src/views/H5/components/H5_dialog/MobileFullScreenConsultDialog.vue b/f/web-kboss/src/views/H5/components/H5_dialog/MobileFullScreenConsultDialog.vue
index acd2303..d376db4 100644
--- a/f/web-kboss/src/views/H5/components/H5_dialog/MobileFullScreenConsultDialog.vue
+++ b/f/web-kboss/src/views/H5/components/H5_dialog/MobileFullScreenConsultDialog.vue
@@ -63,7 +63,7 @@
import { reqConsultForm, reqProductConsult } from '@/api/H5'
+import {
+ extractConsultOptionList,
+ isEnglishLocale,
+ localizeDictOptions,
+ localizeDirectionOptions,
+ normalizeDictOptions as buildDictOptions,
+ normalizeDirectionOptions as buildDirectionOptions
+} from '@/utils/consultDict'
export default {
name: 'MobileFullScreenConsultDialog',
@@ -207,9 +215,21 @@ export default {
set(value) {
this.$emit('update:visible', value)
}
+ },
+ localizedEnterpriseOptions() {
+ return localizeDictOptions(this.enterpriseOptions, isEnglishLocale(this.$i18n))
+ },
+ localizedProvinceOptions() {
+ return localizeDictOptions(this.provinceOptions, isEnglishLocale(this.$i18n))
+ },
+ localizedConsultDirectionOptions() {
+ return localizeDirectionOptions(this.consultDirectionOptions, isEnglishLocale(this.$i18n))
}
},
watch: {
+ '$i18n.locale'() {
+ this.provinceSelectKey += 1
+ },
visible: {
immediate: true,
handler(newVal) {
@@ -256,44 +276,15 @@ export default {
this.dialogVisible = false
this.$emit('close')
},
- normalizeDictOptions(list, type) {
- return list
- .filter(item => item && item.dict_type === type)
- .sort((a, b) => Number(a.sort_order || 0) - Number(b.sort_order || 0))
- .map(item => ({
- id: String(item.dict_key),
- name: item.dict_value
- }))
- },
- normalizeDirectionOptions(list) {
- return list
- .filter(item => item && item.dict_type === 'direction')
- .sort((a, b) => Number(a.sort_order || 0) - Number(b.sort_order || 0))
- .map(item => {
- const value = item.dict_value || ''
- const match = value.match(/^(.+?)((.+?))$/)
- return {
- id: String(item.dict_key),
- name: value,
- title: match ? match[1] : value,
- desc: match ? match[2] : ''
- }
- })
- },
- extractConsultOptionList(res) {
- if (res && Array.isArray(res.data)) return res.data
- if (res && res.data && Array.isArray(res.data.data)) return res.data.data
- return []
- },
async fetchConsultOptions() {
try {
const res = await reqConsultForm()
- const list = this.extractConsultOptionList(res)
+ const list = extractConsultOptionList(res)
if (!list.length) return
- const enterpriseOptions = this.normalizeDictOptions(list, 'enterprise_type')
- const provinceOptions = this.normalizeDictOptions(list, 'region')
- const consultDirectionOptions = this.normalizeDirectionOptions(list)
+ const enterpriseOptions = buildDictOptions(list, 'enterprise_type')
+ const provinceOptions = buildDictOptions(list, 'region')
+ const consultDirectionOptions = buildDirectionOptions(list)
if (enterpriseOptions.length) this.enterpriseOptions = enterpriseOptions
if (provinceOptions.length) {
diff --git a/f/web-kboss/src/views/homePage/dialog/talk/index.vue b/f/web-kboss/src/views/homePage/dialog/talk/index.vue
index 52bb362..3a1cb2d 100644
--- a/f/web-kboss/src/views/homePage/dialog/talk/index.vue
+++ b/f/web-kboss/src/views/homePage/dialog/talk/index.vue
@@ -42,13 +42,14 @@
({
- ...item,
- name: this.getEnterpriseOptionName(item.name)
- }))
+ return localizeDictOptions(this.enterpriseOptions, isEnglishLocale(this.$i18n))
+ },
+ localizedProvinceOptions() {
+ return localizeDictOptions(this.provinceOptions, isEnglishLocale(this.$i18n))
}
},
watch: {
+ '$i18n.locale'() {
+ this.provinceSelectKey += 1
+ },
showTalk: {
immediate: true,
handler(value) {
@@ -176,23 +188,6 @@ export default Vue.extend({
}
},
methods: {
- getEnterpriseOptionName(name) {
- const map = {
- 大型企业: 'largeEnterprise',
- 中小企业: 'sme',
- OPC个人: 'opcIndividual',
- 高校科研机构: 'university',
- 高校: 'university',
- 政府: 'government',
- 其他: 'other'
- }
- const key = map[name]
- if (!key) return name
-
- const i18nKey = `contactSales.enterpriseOptions.${key}`
- const translated = this.$t(i18nKey)
- return translated === i18nKey ? name : translated
- },
getDefaultFormData() {
return {
content: '',
@@ -205,31 +200,20 @@ export default Vue.extend({
region: ''
}
},
- normalizeDictOptions(list, type) {
- return list
- .filter(item => item && item.dict_type === type)
- .sort((a, b) => Number(a.sort_order || 0) - Number(b.sort_order || 0))
- .map(item => ({
- id: item.dict_key,
- name: item.dict_value
- }))
- },
- extractConsultOptionList(res) {
- if (res && Array.isArray(res.data)) return res.data
- if (res && res.data && Array.isArray(res.data.data)) return res.data.data
- return []
- },
async fetchConsultOptions() {
try {
const res = await reqConsultForm()
- const list = this.extractConsultOptionList(res)
+ const list = extractConsultOptionList(res)
if (!list.length) return
- const enterpriseOptions = this.normalizeDictOptions(list, 'enterprise_type')
- const provinceOptions = this.normalizeDictOptions(list, 'region')
+ const enterpriseOptions = buildDictOptions(list, 'enterprise_type')
+ const provinceOptions = buildDictOptions(list, 'region')
if (enterpriseOptions.length) this.enterpriseOptions = enterpriseOptions
- if (provinceOptions.length) this.provinceOptions = provinceOptions
+ if (provinceOptions.length) {
+ this.provinceOptions = provinceOptions
+ this.provinceSelectKey += 1
+ }
} catch (error) {
// 字典接口异常时保持当前选项,避免影响基础提交。
}
@@ -397,7 +381,21 @@ export default Vue.extend({
}
.form-item--message {
+ width: 100%;
+}
+
+::v-deep .form-item--message .el-form-item__label {
+ width: 100% !important;
+ float: none;
+ line-height: 1.5;
+ white-space: normal;
+ word-break: normal;
+ overflow-wrap: break-word;
+}
+
+::v-deep .form-item--message .el-form-item__content {
width: calc(100% - 184px);
+ max-width: calc(100% - 184px);
}
.full-select {
@@ -541,6 +539,11 @@ export default Vue.extend({
width: 100%;
}
+ ::v-deep .form-item--message .el-form-item__content {
+ width: 100%;
+ max-width: 100%;
+ }
+
.agreement-checkbox {
max-width: 100%;
}