From 2c573446cd5059b09c06c8673eaf1f51f43967ce Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 14 六月 2024 13:44:27 +0800 Subject: [PATCH] 2024-06-14 --- src/menu/components/card/cardcellcomponent/formconfig.jsx | 404 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 318 insertions(+), 86 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/formconfig.jsx b/src/menu/components/card/cardcellcomponent/formconfig.jsx index 02e8d29..32da945 100644 --- a/src/menu/components/card/cardcellcomponent/formconfig.jsx +++ b/src/menu/components/card/cardcellcomponent/formconfig.jsx @@ -1,34 +1,120 @@ +import React from 'react' +import MenuUtils from '@/utils/utils-custom.js' + /** * @description 鑾峰彇鍏冪礌閰嶇疆淇℃伅 * @param {*} card * @param {*} type */ -export function getCardCellForm (card, type, subtype, cardCell, anchors) { +export function getCardCellForm (card, cards, cardCell) { + let appType = sessionStorage.getItem('appType') + let _options = [ { value: 'text', text: '鏂囨湰'}, { value: 'number', text: '鏁板��'}, { value: 'picture', text: '鍥剧墖'}, { value: 'video', text: '瑙嗛'}, - { value: 'icon', text: '鍥炬爣'}, + { value: 'icon', text: '鎻愮ず锛堝浘鏍囷級'}, { value: 'slider', text: '杩涘害鏉�'}, { value: 'splitline', text: '鍒嗗壊绾�'}, { value: 'barcode', text: '鏉″舰鐮�'}, { value: 'qrcode', text: '浜岀淮鐮�'}, { value: 'currentDate', text: '褰撳墠鏃堕棿'}, { value: 'formula', text: '鍏紡'}, + { value: 'tag', text: '鏍囩'}, + { value: 'color', text: '棰滆壊'}, ] - if (type === 'table' || (type === 'card' && subtype === 'datacard')) { + let anchors = [] + if (window.GLOB.customMenu.Template === 'BaseTable') { + anchors = null + } else { + anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || [] + } + + if (cards.type === 'table' || (cards.type === 'card' && cards.subtype !== 'propcard')) { _options.push({value: 'sequence', text: '搴忓彿'}) } else if (card.eleType === 'sequence') { // 鎷栨嫿娣诲姞绫诲瀷杞崲 card.eleType = 'text' } + if (card.eleType === 'icon' && card.datatype === 'dynamic' && !card.field) { // 鎷栨嫿娣诲姞绫诲瀷杞崲 + card.datatype = 'static' + } - let appMenus = [] - const isApp = sessionStorage.getItem('appType') === 'pc' + let tooltip = '' + if (cardCell.$cardType === 'extendCard') { + tooltip = '鍦ㄦ墿灞曞崱鐗囦腑锛屽姩鎬佹暟鎹樉绀哄�间负鑾峰彇鍒扮殑绗竴琛屾暟鎹��' + } - if (isApp) { - appMenus = sessionStorage.getItem('appMenus') + let isHeader = false + if (cardCell.$cardType === 'extendCard' && cardCell.setting.cardRole === 'header') { + isHeader = true + anchors = null + card.link = '' + _options = [{ value: 'text', text: '鏂囨湰'}] + } + + let width = card.width === undefined ? 12 : card.width + if (/x/.test(card.width)) { + width = +width.replace(/x/, '.5') + } + + let linkTypes = [ + { value: 'tel', text: '鐢佃瘽' }, + { value: 'email', text: '閭' }, + { value: 'linkmenu', text: '鍏宠仈鑿滃崟' }, + { value: 'download', text: '涓嬭浇' }, + { value: 'other', text: '鍏朵粬' } + ] + + if (appType === 'mob') { + linkTypes = [ + { value: 'tel', text: '鐢佃瘽' }, + { value: 'email', text: '閭' }, + { value: 'qywx', text: '浼佷笟寰俊' }, + { value: 'linkmenu', text: '鍏宠仈鑿滃崟' }, + { value: 'download', text: '涓嬭浇' }, + { value: 'other', text: '鍏朵粬' } + ] + } else if (appType === 'pc') { + linkTypes = [ + { value: 'tel', text: '鐢佃瘽' }, + { value: 'email', text: '閭' }, + { value: 'linkmenu', text: '鍏宠仈鑿滃崟' }, + { value: 'download', text: '涓嬭浇' }, + { value: 'other', text: '鍏朵粬' } + ] + } + + if (card.linkType === 'qywx') { + if (appType !== 'mob') { + card.link = '' + card.linkType = '' + card.linkurl = '' + } + // } else if (card.linkType === 'linkmenu') { + // if (appType !== 'mob' && appType !== 'pc') { + // card.link = '' + // card.linkType = '' + // card.linkurl = '' + // card.linkmenu = '' + // } + } + + let menulist = sessionStorage.getItem('fstMenuList') + + if (appType === '' && menulist) { + try { + menulist = JSON.parse(menulist) + } catch (e) { + menulist = [] + } + } else { + menulist = [] + } + + let appMenus = sessionStorage.getItem('appMenus') + if (['pc', 'mob'].includes(appType)) { if (appMenus) { try { appMenus = JSON.parse(appMenus) @@ -38,11 +124,18 @@ } else { appMenus = [] } + appMenus.push({value: 'goback', text: '杩斿洖锛堜笂涓�椤碉級'}) } - let tooltip = '' - if (cardCell.$cardType === 'extendCard') { - tooltip = '鍦ㄦ墿灞曞崱鐗囦腑锛屽姩鎬佹暟鎹樉绀哄�间负鑾峰彇鍒扮殑绗竴琛屾暟鎹��' + let fields = [] + let isStatic = (cards.subtype === 'propcard' || cards.type === 'balcony') && cards.wrap.datatype === 'static' + if (isStatic) { + if (cards.wrap.supModule && cards.wrap.supModule.length) { + let cell = MenuUtils.getComponent(cards.wrap.supModule[cards.wrap.supModule.length - 1]) + if (cell && cell.columns) { + fields = cell.columns.map(col => ({ value: col.field })) + } + } } let forms = [ @@ -53,13 +146,6 @@ initVal: card.eleType, required: true, options: _options - }, - { - type: 'icon', - key: 'icon', - label: '鍥炬爣', - initVal: card.icon, - required: true }, { type: 'radio', @@ -74,12 +160,35 @@ ] }, { - type: 'select', + type: 'radio', + key: 'tipType', + label: '鎻愮ず鍐呭', + initVal: card.tipType || 'icon', + required: false, + options: [ + { value: 'icon', text: '鍥炬爣' }, + { value: 'text', text: '鏂囨湰' } + ] + }, + { + type: isStatic ? 'text' : 'select', key: 'field', label: '瀛楁', initVal: card.field || '', + tooltip: isStatic ? '鍙粦瀹氫笂绾х粍浠跺瓧娈碉紝涓嶅瓨鍦ㄤ笂绾х粍浠舵椂鍙粦瀹歶rl鍙傛暟瀛楁銆�' : '', required: true, - options: [] + options: fields, + rules: [{ + pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯-' + }] + }, + { + type: 'icon', + key: 'icon', + label: '鍥炬爣', + initVal: card.icon, + required: true }, { type: 'text', @@ -87,7 +196,7 @@ min: 0, label: '鍐呭', initVal: card.value || '', - tooltip: '鏂囨湰绫诲瀷锛屼細鏇挎崲鍐呭涓殑@username@銆丂fullName@銆丂mk_city@銆丂appname@銆丂bid@銆�', + // tooltip: '鏂囨湰绫诲瀷锛屼細鏇挎崲鍐呭涓殑@username@銆丂fullName@銆丂mk_city@銆丂appname@銆丂bid@銆丂month@銆丂week@銆丂day@', required: true }, { @@ -151,11 +260,30 @@ required: true }, { - type: 'select', + type: isStatic ? 'text' : 'select', key: 'posterField', label: '棰勮鍦板潃', initVal: card.posterField || '', - required: true + required: true, + options: fields + }, + { + type: 'radio', + key: 'eval', + label: '瑙f瀽鏂瑰紡', + initVal: card.eval || 'false', + tooltip: '褰撳叕寮忓唴瀹规秹鍙婅绠楁椂璇烽�夋嫨鈥滆绠椻�濓紝褰撳叕寮忓唴瀹逛负瀛楁鎷兼帴鏃惰閫夋嫨鈥滃瓧娈垫浛鎹⑩�濓紝浣跨敤鍑芥暟鏃跺叆鍙備负data锛堟暟缁勶級銆�', + required: false, + options: [{ + value: 'false', + text: '瀛楁鏇挎崲' + }, { + value: 'true', + text: '璁$畻' + }, { + value: 'func', + text: '鍑芥暟' + }] }, { type: 'number', @@ -190,7 +318,8 @@ { value: 'MM鏈圖D鏃� ahh:mm', text: '鑷畾涔�2锛堜緥锛�12鏈�17鏃� 涓婂崍10:57锛�' }, { value: 'calendar1', text: '鑷畾涔�3锛堜緥锛氫粖澶� 涓婂崍10:57锛�' }, { value: 'calendar2', text: '鑷畾涔�4锛堜緥锛氬垰鍒氥�佹槰澶┿��5澶╁墠锛�' }, - ] + ], + forbid: isHeader }, { type: 'select', @@ -204,6 +333,7 @@ { value: 'YYYY-MM', text: 'YYYY-MM' }, { value: 'YYYY-MM-DD HH:mm', text: 'YYYY-MM-DD HH:mm' }, { value: 'YYYY-MM-DD HH:mm:ss', text: 'YYYY-MM-DD HH:mm:ss' }, + { value: 'YYYY骞碝M鏈圖D鏃�', text: 'YYYY骞碝M鏈圖D鏃�' }, ] }, { @@ -225,7 +355,8 @@ key: 'tooltip', label: '鎻愮ず淇℃伅', initVal: card.tooltip || '', - tooltip: '榧犳爣鎮诞鏃舵樉绀恒��', + tooltip: '榧犳爣鎮诞鏃舵樉绀恒�傛敞锛氬浣跨敤鍔ㄦ�佷俊鎭紝璇峰湪姝ゅ濉啓鐩稿簲鐨勫瓧娈靛悕銆�', + forbid: appType === 'mob', required: false }, { @@ -329,12 +460,12 @@ { type: 'number', key: 'width', - min: 1, + min: 0, max: 24, - precision: 0, + precision: 1, label: '鍏冪礌瀹藉害', - initVal: card.width || 12, - tooltip: '鏍呮牸甯冨眬锛屾瘡琛岀瓑鍒嗕负24鍒椼��', + initVal: width, + tooltip: '鏍呮牸甯冨眬锛屾瘡琛岀瓑鍒嗕负24鍒楋紝鍙缃崐鍒楀嵆.5銆傛敞锛氫负0鏃跺搴︿緷鎹唴瀹硅嚜閫傚簲锛堟枃鏈�佹暟鍊笺�佹彁绀猴紙鍥炬爣锛夈�佸綋鍓嶆椂闂淬�佸叕寮忥級銆�', required: true }, { @@ -348,14 +479,15 @@ required: false }, { - type: 'select', + type: isStatic ? 'text' : 'select', key: 'bgImage', label: '鍔ㄦ�佽儗鏅�', initVal: card.bgImage || '', tooltip: '缁戝畾鏁版嵁婧愬瓧娈碉紝鍙牴鎹繑鍥炲�兼敼鍙樿儗鏅浘銆�', required: false, allowClear: true, - options: [] + options: fields, + forbid: isHeader }, { type: 'cascader', @@ -364,7 +496,8 @@ initVal: card.anchors || [], tooltip: sessionStorage.getItem('appType') === 'mob' ? '娉細灏忕▼搴忎腑鏃犳晥' : '', required: false, - options: anchors + options: anchors, + forbid: !anchors }, { type: 'number', @@ -440,6 +573,18 @@ { value: '9:16', text: '9:16' }, ] }, + // { + // type: 'radio', + // key: 'backgroundSize', + // label: '鍥惧儚澶у皬', + // initVal: card.backgroundSize || 'cover', + // required: false, + // options: [ + // { value: 'cover', text: '瑕嗙洊' }, + // { value: 'contain', text: '鍖呭惈' }, + // { value: 'auto', text: '鑷�傚簲' }, + // ] + // }, { type: 'number', key: 'maxWidth', @@ -467,25 +612,22 @@ key: 'link', label: '閾炬帴', initVal: card.link || '', - tooltip: '鍔ㄦ�佸湴鍧�涓虹粦瀹氬瓧娈靛�笺��', + tooltip: '鍔ㄦ�佸湴鍧�涓虹粦瀹氬瓧娈靛�笺�備娇鐢� 鍔ㄦ��-鍏宠仈鑿滃崟 鏃讹紝璇峰湪鈥滈摼鎺ュ湴鍧�鈥濆瓧娈佃繑鍥炶彍鍗旾D銆�', required: false, options: [ { value: '', text: '鏃�' }, { value: 'dynamic', text: '鍔ㄦ��' }, { value: 'static', text: '闈欐��' } - ] + ], + forbid: isHeader }, { - type: 'radio', + type: 'select', key: 'linkType', label: '閾炬帴绫诲瀷', initVal: card.linkType || 'other', required: false, - options: [ - { value: 'tel', text: '鐢佃瘽' }, - { value: 'email', text: '閭' }, - { value: 'other', text: '鍏朵粬' } - ] + options: linkTypes }, { type: 'radio', @@ -503,79 +645,107 @@ key: 'linkmenu', label: '鍏宠仈鑿滃崟', initVal: card.linkmenu || '', + tooltip: '琛屼俊鎭紙瀛楁闆嗕腑鍓�40涓暱搴︿笉瓒呰繃256鐨勫瓧娈碉級灏嗕紶閫掕嚦姝よ彍鍗曪紝鍙湪url鍙橀噺銆佽〃鍗曪紙鍏宠仈涓昏〃锛夈�侀潤鎬佸睘鎬у崱銆佹诞鍔ㄥ崱涓娇鐢ㄣ��', required: true, - forbid: !isApp, - options: appMenus + options: appMenus || [], + forbid: !['pc', 'mob'].includes(appType) }, - // { - // type: 'radio', - // key: 'open', - // label: '鎵撳紑鏂瑰紡', - // initVal: card.open || 'blank', - // required: false, - // forbid: !isApp, - // options: [ - // { value: 'blank', text: '鏂伴〉闈�' }, - // { value: 'self', text: '褰撳墠椤甸潰' } - // ] - // }, { - type: 'select', + type: 'cascader', + key: 'linkmenu', + label: '鍏宠仈鑿滃崟', + initVal: card.linkmenu || [], + tooltip: '琛屼俊鎭皢浼犻�掕嚦姝よ彍鍗曪紝鍙湪url鍙橀噺銆佽〃鍗曪紙鍏宠仈涓昏〃锛夈�侀潤鎬佸睘鎬у崱銆佹诞鍔ㄥ崱涓娇鐢ㄣ��', + required: true, + options: menulist, + forbid: ['pc', 'mob'].includes(appType) + }, + { + type: isStatic ? 'text' : 'select', + defType: isStatic ? 'text' : 'select', key: 'linkurl', label: '閾炬帴鍦板潃', initVal: card.linkurl || '', + tooltip: '鍦ㄩ摼鎺ヤ腑浠***@褰㈠紡鎷兼帴鐨勫瓧娈碉紙瀛楁鏉ユ簮浜庡瓧娈甸泦涓紝姝ゅ id銆乤ppkey銆乽serid銆丩oginUID 涓虹郴缁熷瓧娈碉級锛岃烦杞椂灏嗘浛鎹负瀵瑰簲鍊硷紝渚嬪锛歨ttp://sso.mk9h.cn/doc/index.html?appkey=@appkey@&LoginUID=@LoginUID@锛屽叾涓璦ppkey涓嶭oginUID灏嗚鏇挎崲銆�' + (['pc', 'mob'].includes(appType) ? '褰撻摼鎺ョ被鍨嬩负鈥滃叾浠栤�濓紝涓旈摼鎺ュ湴鍧�浠menuid@寮�澶存椂锛屽叾鍚庡唴瀹瑰皢琚涓鸿彍鍗旾D銆�' : ''), + toolWidth: 350, required: true, - options: [] + options: fields }, { type: 'radio', - key: 'joint', - label: '鎷兼帴鍙傛暟', - initVal: card.joint || 'true', - required: false, - options: [{ - value: 'true', - text: '鏄�' - }, { - value: 'false', - text: '鍚�' - }] + key: 'open', + label: '鎵撳紑鏂瑰紡', + initVal: card.open || 'blank', + tooltip: '鑿滃崟鎵撳紑鏂瑰紡锛岄摼鎺ユ棤鏁堛��', + required: true, + forbid: !['pc', 'mob'].includes(appType), + options: [ + {value: 'blank', text: appType !== 'mob' ? '鏂扮獥鍙�' : '鏂伴〉闈�'}, + {value: 'self', text: appType !== 'mob' ? '褰撳墠绐楀彛' : '褰撳墠椤甸潰'}, + ] }, { - type: 'radio', - key: 'eval', - label: '瑙f瀽', - initVal: card.eval || 'true', - tooltip: '褰撳叕寮忓唴瀹规秹鍙婅绠楁椂璇烽�夋嫨鈥滄槸鈥濓紝褰撳叕寮忓唴瀹逛负瀛楁鎷兼帴鏃惰閫夋嫨鈥滃惁鈥濄��', - required: false, - options: [{ - value: 'true', - text: '鏄�' - }, { - value: 'false', - text: '鍚�' - }] - }, - { - type: 'textarea', + type: 'codemirror', key: 'formula', label: '鍏紡', initVal: card.formula || '', - tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋滐紝鍦ㄤ笉浣跨敤瑙f瀽鏃舵崲琛岀鎴栫┖鏍间細鏇挎崲涓洪〉闈㈠厓绱犮�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛�', + tooltip: '鎵ц鏃朵細浣跨敤鏌ヨ鍒扮殑鏁版嵁鏇挎崲鐩稿簲鐨勫瓧娈碉紝灞曠ず鑾峰緱鐨勭粨鏋滐紝鍦ㄤ笉浣跨敤瑙f瀽鏃舵崲琛岀鎴栫┖鏍间細鏇挎崲涓洪〉闈㈠厓绱犮�傚彲浣跨敤JS鐨勪竴浜涜娉曪紝濡傦細涓夊厓琛ㄨ揪寮� @field1@ > @field2@ ? 0 : 1锛汳ath瀵硅薄锛屽彇缁濆鍊� Math.abs(@field@)銆佸洓鑸嶄簲鍏� Math.round(@field@)绛夈�傛敞锛氫細鏇挎崲鍏紡涓殑@username@銆丂fullName@銆丂bid@銆�', + toolWidth: 450, placeholder: '渚嬪锛欯price@ * @number@', required: true + }, + { + type: 'checkbox', + key: 'evalchars', + label: '鏇挎崲瀛楃', + initVal: card.evalchars || ['enter', 'space'], + tooltip: '鍏紡瑙f瀽鍚庯紝鍙浛鎹㈠洖杞︺�佺┖鏍肩瓑瀛楃锛屽疄鐜版崲琛屻�佸瓧闂磋窛鎺у埗绛夐〉闈㈡晥鏋溿��', + required: false, + options: [{ + value: 'enter', + text: '鍥炶溅绗�' + }, { + value: 'space', + text: '绌烘牸' + }] }, { type: 'radio', key: 'noValue', label: '绌哄��', initVal: card.noValue || 'show', - tooltip: '褰撳厓绱犲唴瀹逛负绌烘椂锛屾槸鍚︽樉绀哄綋鍓嶅厓绱犮��', + tooltip: '褰撳厓绱犲唴瀹逛负绌烘椂锛屾槸鍚︽樉绀哄綋鍓嶅厓绱犮�傛敞锛氭暟鍊肩被鍨嬪厓绱犲寘鎷暟瀛�0锛堥潪鏂囨湰锛夈��', required: false, options: [ { value: 'show', text: '鏄剧ず' }, { value: 'hide', text: '闅愯棌' } ] + }, + { + type: 'radio', + key: 'lostTip', + label: '鍥剧墖缂哄け', + initVal: card.lostTip || 'true', + tooltip: '鍥剧墖鍦板潃涓嶅瓨鍦ㄦ椂锛屾槸鍚︽彁绀哄浘鐗囦涪澶便��', + required: false, + options: [ + { value: 'true', text: '鎻愮ず' }, + { value: 'false', text: '涓嶆彁绀�' } + ] + }, + { + type: 'radio', + key: 'alignItems', + label: '鍨傜洿瀵归綈', + initVal: card.alignItems || '', + tooltip: '鍨傜洿鏂瑰悜鐨勫榻愭柟寮忋�傛敞锛氶珮搴︼紙琛岋級澶т簬1鏃舵湁鏁堛��', + required: false, + options: [ + { value: '', text: '灞呬笂' }, + { value: 'center', text: '灞呬腑' }, + { value: 'end', text: '灞呬笅' } + ], + forbid: isHeader }, { type: 'radio', @@ -587,7 +757,8 @@ options: [ { value: '', text: '缁熶竴鏍峰紡' }, { value: 'alone', text: '鐙珛鏍峰紡' } - ] + ], + forbid: isHeader }, { type: 'radio', @@ -599,7 +770,8 @@ options: [ { value: 'true', text: '鏄�' }, { value: 'false', text: '鍚�' } - ] + ], + forbid: isHeader }, { type: 'number', @@ -639,6 +811,66 @@ tooltip: '鍓嶇紑銆佸悗缂�鐨勫彸杈硅窛銆�', required: false }, + { + type: 'select', + key: 'sortField', + label: '鎺掑簭瀛楁', + initVal: card.sortField || '', + required: false, + allowClear: true, + options: [], + forbid: !isHeader + }, + { + type: 'table', + key: 'signs', + label: '鏍囪', + initVal: card.signs || [], + tooltip: '鍙緷鎹爣绛惧唴瀹硅缃笉鍚屾牱寮忋��', + required: false, + actions: ['edit', 'del', 'add', 'move'], + columns: [ + { + title: '鍊�', + dataIndex: 'value', + inputType: 'text', + editable: true, + required: true, + unique: true, + width: '20%' + }, + { + title: '鑳屾櫙', + dataIndex: 'background', + inputType: 'color', + className: 'mini-color', + editable: true, + required: true, + width: '20%', + render: (text) => <span className="mk-color-value" style={{background: text}}></span>, + }, + { + title: '鏂囧瓧', + dataIndex: 'color', + inputType: 'color', + className: 'mini-color', + editable: true, + required: true, + width: '20%', + render: (text) => <span className="mk-color-value" style={{background: text}}></span>, + }, + { + title: '杈规', + dataIndex: 'border', + inputType: 'color', + className: 'mini-color', + editable: true, + required: true, + width: '20%', + render: (text) => <span className="mk-color-value" style={{background: text}}></span>, + }, + ] + }, ] return forms -- Gitblit v1.8.0