From 400fee62fb40006a9839f1c3a8244b82566b5057 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 08 五月 2025 16:30:39 +0800 Subject: [PATCH] Merge branch 'develop' --- src/utils/utils-custom.js | 435 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 390 insertions(+), 45 deletions(-) diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index 62635f2..e66d16d 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -2288,40 +2288,6 @@ duration: 5 }) return false - } else if (/,\./ig.test(sql)) { - let lines = [] - sql.split(/\n/).forEach((s, i) => { - if (/,\./ig.test(s)) { - lines.push(i + 1) - } - }) - - lines = lines.join('銆�') - lines = lines ? '(绗�' + lines + '琛�)' : '' - - notification.warning({ - top: 92, - message: label + `${lines}锛屼笉鍙嚭鐜拌嫳鏂囬�楀彿,.`, - duration: 5 - }) - return false - } else if (/\.,/ig.test(sql)) { - let lines = [] - sql.split(/\n/).forEach((s, i) => { - if (/\.,/ig.test(s)) { - lines.push(i + 1) - } - }) - - lines = lines.join('銆�') - lines = lines ? '(绗�' + lines + '琛�)' : '' - - notification.warning({ - top: 92, - message: label + `${lines}锛屼笉鍙嚭鐜拌嫳鏂囬�楀彿.,`, - duration: 5 - }) - return false } else if (/鈥榺鈥�/ig.test(sql)) { let lines = [] sql.split(/\n/).forEach((s, i) => { @@ -2424,6 +2390,38 @@ duration: 5 }) return false + } else if (/,\./ig.test(sql)) { + let lines = [] + sql.split(/\n/).forEach((s, i) => { + if (/,\./ig.test(s)) { + lines.push(i + 1) + } + }) + + lines = lines.join('銆�') + lines = lines ? '(绗�' + lines + '琛�)' : '' + + notification.warning({ + top: 92, + message: label + `${lines}锛屼笉鍙嚭鐜拌嫳鏂囬�楀彿,.`, + duration: 5 + }) + } else if (/\.,/ig.test(sql)) { + let lines = [] + sql.split(/\n/).forEach((s, i) => { + if (/\.,/ig.test(s)) { + lines.push(i + 1) + } + }) + + lines = lines.join('銆�') + lines = lines ? '(绗�' + lines + '琛�)' : '' + + notification.warning({ + top: 92, + message: label + `${lines}锛屼笉鍙嚭鐜拌嫳鏂囬�楀彿.,`, + duration: 5 + }) } return true @@ -2433,6 +2431,8 @@ * @description 鑾峰彇璇█杞崲淇℃伅 */ export function getLangTrans (config) { + if (sessionStorage.getItem('lang') !== 'zh-CN') return '' + let langList = sessionStorage.getItem('langList') let appType = sessionStorage.getItem('appType') @@ -2440,18 +2440,19 @@ langList = sessionStorage.getItem('applangList') } - if (!langList) return - - let defLang = '' + if (!langList) return '' try { langList = JSON.parse(langList) - defLang = langList[0] } catch (e) { - defLang = '' + langList = '' } - if (!defLang) return '' + if (!langList) return '' + + langList = langList.filter(n => n !== 'zh-CN') + + if (langList.length === 0) return '' let sql = [] let btn = [] @@ -2486,8 +2487,18 @@ let filterBtn = (btn) => { if (!btn.verify) return + btn.verify.columns && btn.verify.columns.forEach(col => { + if (col.Text) { + sql.push(col.Text) + } + }) + btn.verify.customverifys && btn.verify.customverifys.forEach(script => { filterSql(script.sql) + + if (script.errmsg) { + sql.push(script.errmsg) + } }) btn.verify.scripts && btn.verify.scripts.forEach(script => { filterSql(script.sql) @@ -2530,6 +2541,9 @@ } else { if (item.wrap && item.wrap.title) { sql.push(item.wrap.title) + } + if (item.plot && item.plot.title) { + sql.push(item.plot.title) } if (item.setting && (!item.wrap || !item.wrap.datatype || item.wrap.datatype === 'dynamic')) { @@ -2767,8 +2781,6 @@ let result = [] langList.forEach(lan => { - if (lan === defLang) return - list.forEach(n => { result.push(`'${lan}',${n}`) }) @@ -2901,8 +2913,24 @@ if (!btn.verify) return + btn.verify.columns && btn.verify.columns.forEach(col => { + if (col.Text) { + col.Text = replaceTitle(col.Text) + } + }) + + btn.verify.uniques && btn.verify.uniques.forEach(col => { + if (col.fieldlabel) { + col.fieldlabel = col.fieldlabel.split(',').map(n => replaceTitle(n)).join(',') + } + }) + btn.verify.customverifys && btn.verify.customverifys.forEach(script => { script.sql = filterSql(script.sql) + + if (script.errmsg) { + script.errmsg = replaceTitle(script.errmsg) + } }) btn.verify.scripts && btn.verify.scripts.forEach(script => { script.sql = filterSql(script.sql) @@ -2993,6 +3021,9 @@ } else { if (item.wrap && item.wrap.title) { item.wrap.title = replaceTitle(item.wrap.title) + } + if (item.plot && item.plot.title) { + item.plot.title = replaceTitle(item.plot.title) } if (item.wrap && (item.wrap.click === 'menu' || item.wrap.click === 'menus')) { if (item.wrap.click === 'menu') { @@ -3085,6 +3116,320 @@ } else if (card.setting.click === 'menu') { resetMenu(card.setting) } + card.elements && card.elements.forEach(cell => { + if (cell.eleType === 'button') { + filterBtn(cell) + if (cell.OpenType === 'popview' && cell.config) { + traversal(cell.config.components) + } else if (cell.OpenType === 'pop') { + if (cell.modal && cell.modal.fields.length) { + cell.modal.fields.forEach(n => { + filterForm(n) + }) + } + } + } else { + filterElement(cell) + } + }) + card.backElements && card.backElements.forEach(cell => { + if (cell.eleType === 'button') { + filterBtn(cell) + if (cell.OpenType === 'popview' && cell.config) { + traversal(cell.config.components) + } else if (cell.OpenType === 'pop') { + if (cell.modal && cell.modal.fields.length) { + cell.modal.fields.forEach(n => { + filterForm(n) + }) + } + } + } else { + filterElement(cell) + } + }) + }) + } else if (item.type === 'balcony') { + item.elements && item.elements.forEach(cell => { + if (cell.eleType === 'button') { + filterBtn(cell) + if (cell.OpenType === 'popview' && cell.config) { + traversal(cell.config.components) + } else if (cell.OpenType === 'pop') { + if (cell.modal && cell.modal.fields.length) { + cell.modal.fields.forEach(n => { + filterForm(n) + }) + } + } + } else { + filterElement(cell) + } + }) + } else if (item.type === 'table') { + let loopCol = (cols) => { + cols.forEach(col => { + if (col.label) { + col.label = replaceTitle(col.label) + } + if (col.prefix) { + col.prefix = replaceTitle(col.prefix) + } + if (col.postfix) { + col.postfix = replaceTitle(col.postfix) + } + if (col.type === 'colspan') { + loopCol(col.subcols) + } else if (col.type === 'custom') { + col.elements.forEach(cell => { + if (cell.eleType === 'button') { + filterBtn(cell) + if (cell.OpenType === 'popview' && cell.config) { + traversal(cell.config.components) + } else if (cell.OpenType === 'pop') { + if (cell.modal && cell.modal.fields.length) { + cell.modal.fields.forEach(n => { + filterForm(n) + }) + } + } + } else { + filterElement(cell) + } + }) + } + }) + } + loopCol(item.cols) + } else if (item.type === 'form') { + item.subcards.forEach(cell => { + filterBtn(cell.subButton) + cell.fields.forEach(n => { + filterForm(n) + }) + }) + } + } + }) + } + + if (config.interfaces) { + config.interfaces.forEach(item => { + if (item.setting.interType === 'system') { + item.setting.dataresource = filterSql(item.setting.dataresource) + item.scripts && item.scripts.forEach(script => { + script.sql = filterSql(script.sql) + }) + } + }) + } + + traversal(config.components) +} + +/** + * @description 璇█杞崲 + */ +export function setLangSingleTrans (config, btnDict, titDict, lisDict, menuDict, regs) { + let filterElement = (card) => { + if (card.datatype === 'static' && card.eleType === 'text' && !/@.+@/g.test(card.value)) { + if (card.value) { + card.value = replaceTitle(card.value) + } + } + if (card.prefix) { + card.prefix = replaceTitle(card.prefix) + } + if (card.postfix) { + card.postfix = replaceTitle(card.postfix) + } + } + + let replaceTitle = (val)聽=> { + if聽(/(:|锛�)$/g.test(val)) { + let _val = val.replace(/(:|锛�)$/g,聽'') + if聽(titDict[_val]) { + val = titDict[_val] + val.substr(-1) + }聽else if (titDict[val]) { + val = titDict[val] + } + }聽else if (titDict[val]) { + val = titDict[val] + } + + return val + } + + let getuuid = () => { + let uuid = [] + let _options = '0123456789abcdefghigklmnopqrstuv' + for (let i = 0; i < 19; i++) { + uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) + } + return uuid.join('') + } + + let filterSql = (sl) => { + if (!sl) return + + let arr = [] + + sl = sl.replace(/\/\*[^*/]+\*\//g, (word) => { + let uuid = getuuid() + arr.push({id: `/*${uuid}*/`, value: word}) + return `/*${uuid}*/` + }) + + regs.forEach(item => { + sl = sl.replace(item.reg, item.value) + }) + + arr.forEach(item => { + sl = sl.replace(item.id, item.value) + }) + + return sl + } + + let filterBtn = (btn) => { + if (btn.label && btnDict[btn.label]) { + btn.label = btnDict[btn.label] + } + + if (!btn.verify) return + + btn.verify.columns && btn.verify.columns.forEach(col => { + if (col.Text) { + col.Text = replaceTitle(col.Text) + } + }) + + btn.verify.uniques && btn.verify.uniques.forEach(col => { + if (col.fieldlabel) { + col.fieldlabel = col.fieldlabel.split(',').map(n => replaceTitle(n)).join(',') + } + }) + + btn.verify.customverifys && btn.verify.customverifys.forEach(script => { + script.sql = filterSql(script.sql) + + if (script.errmsg) { + script.errmsg = replaceTitle(script.errmsg) + } + }) + btn.verify.scripts && btn.verify.scripts.forEach(script => { + script.sql = filterSql(script.sql) + }) + btn.verify.cbScripts && btn.verify.cbScripts.forEach(script => { + script.sql = filterSql(script.sql) + }) + + if (btn.OpenType === 'funcbutton') { + if (btn.intertype === 'system' && btn.verify.dataType === 'custom' && btn.verify.setting) { + btn.verify.setting.dataresource = filterSql(btn.verify.setting.dataresource) + } + } else if (btn.OpenType === 'excelOut' && btn.verify.dataresource) { + btn.verify.dataresource = filterSql(btn.verify.dataresource) + } + } + + let filterForm = (n) => { + if (n.label) { + n.label = replaceTitle(n.label) + } + if (n.resourceType === '1') { + n.dataSource = filterSql(n.dataSource) + } else if (n.options) { + n.options.forEach(o => { + if (o.Text && lisDict[o.Text]) { + o.Text = lisDict[o.Text] + } + }) + } + } + + let traversal = (components) => { + if (!components) return + + components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (tab.label) { + tab.label = replaceTitle(tab.label) + } + traversal(tab.components) + }) + } else if (item.type === 'group') { + traversal(item.components) + } else { + if (item.wrap && item.wrap.title) { + item.wrap.title = replaceTitle(item.wrap.title) + } + if (item.plot && item.plot.title) { + item.plot.title = replaceTitle(item.plot.title) + } + if (item.setting && (!item.wrap || !item.wrap.datatype || item.wrap.datatype === 'dynamic')) { + if (item.setting.interType === 'system') { + item.setting.dataresource = filterSql(item.setting.dataresource) + item.scripts && item.scripts.forEach(script => { + script.sql = filterSql(script.sql) + }) + } + } + + if (item.columns) { + item.columns.forEach(cell => { + if (cell.label) { + cell.label = replaceTitle(cell.label) + } + }) + } + if (item.search) { + if (item.type === 'topbar') { + if (item.search.fields) { + item.search.fields.forEach(cell => { + filterForm(cell) + }) + } + if (item.search.groups) { + item.search.groups.forEach(group => { + if (group.fields) { + group.fields.forEach(cell => { + filterForm(cell) + }) + } + }) + } + } else { + item.search.forEach(cell => { + filterForm(cell) + }) + } + } + if (item.action) { + item.action.forEach(cell => { + filterBtn(cell) + if (cell.OpenType === 'popview' && cell.config) { + traversal(cell.config.components) + } else if (cell.OpenType === 'pop') { + if (cell.modal && cell.modal.fields.length) { + cell.modal.fields.forEach(n => { + filterForm(n) + }) + } + } + }) + } + + if (item.type === 'menubar') { + item.subMenus = item.subMenus.map(cell => { + if (cell.setting.name && menuDict[cell.setting.name]) { + cell.setting.name = menuDict[cell.setting.name] + } + return cell + }) + } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { + item.subcards.forEach(card => { card.elements && card.elements.forEach(cell => { if (cell.eleType === 'button') { filterBtn(cell) @@ -5012,7 +5357,7 @@ let sFields = getSearches(searches) let _columns = [] - if (item.subtype === 'dualdatacard') { + if (item.subtype === 'dualdatacard' && item.setting.subdata !== 'sub_data_string') { _columns = [...item.columns, ...item.subColumns] } else if (item.columns) { _columns = [...item.columns] @@ -5128,7 +5473,7 @@ } else if (item.setting.laypage === 'true' && item.setting.order) { LText = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows ` reps.push('pageSize', 'orderBy', 'pageIndex') - if (item.subtype === 'dualdatacard') { + if (item.subtype === 'dualdatacard' && item.setting.subdata !== 'sub_data_string') { DateCount = `select count(1) as total from (select distinct ${item.setting.primaryKey || 'ID'} from ${_dataresource} ${_search})a` } else { DateCount = `select count(1) as total from ${_dataresource} ${_search}` @@ -5155,7 +5500,7 @@ let parid = '' let sub_field = '' - if (item.subtype === 'dualdatacard') { + if (item.subtype === 'dualdatacard' && item.setting.subdata !== 'sub_data_string') { arr_field = item.columns.map(col => col.field).join(',') sub_name = item.setting.subdata tabid = item.setting.primaryKey || '' -- Gitblit v1.8.0