From 47b9baefdeeb41f50a9b7abc1abcf5e90931a89d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 31 八月 2023 11:17:48 +0800 Subject: [PATCH] 2023-08-31 --- src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx | 649 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 523 insertions(+), 126 deletions(-) diff --git a/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx b/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx index 677001d..757c4e8 100644 --- a/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx +++ b/src/menu/components/chart/antv-bar/chartcompile/formconfig.jsx @@ -1,37 +1,272 @@ -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' +/** + * @description 鑾峰彇鍥捐〃瑙嗗浘閰嶇疆琛ㄥ崟 + * @param {object} card // 鍥捐〃瀵硅薄 + */ +export function getBaseForm (card, columns = []) { + let appType = sessionStorage.getItem('appType') + let roleList = sessionStorage.getItem('sysRoles') + let isprint = sessionStorage.getItem('MenuType') === 'billPrint' + let ispop = sessionStorage.getItem('editMenuType') === 'popview' + if (roleList) { + try { + roleList = JSON.parse(roleList) + } catch (e) { + roleList = [] + } + } else { + roleList = [] + } -const Formdict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS + let menulist = [] + + if (appType === 'pc') { + menulist = sessionStorage.getItem('appMenus') + if (menulist) { + try { + menulist = JSON.parse(menulist) + } catch (e) { + menulist = [] + } + } else { + menulist = [] + } + } else if (appType === '') { + menulist = sessionStorage.getItem('fstMenuList') + if (menulist) { + try { + menulist = JSON.parse(menulist) + } catch (e) { + menulist = [] + } + } else { + menulist = [] + } + } + + return [ + { + type: 'text', + key: 'title', + label: '鏍囬', + initVal: card.title, + required: false + }, + { + type: 'text', + key: 'name', + label: '缁勪欢鍚嶇О', + initVal: card.name, + tooltip: '鐢ㄤ簬缁勪欢闂寸殑鍖哄垎銆�', + required: true + }, + { + type: 'number', + key: 'width', + label: '瀹藉害', + initVal: card.width, + tooltip: '鏍呮牸甯冨眬锛屾瘡琛岀瓑鍒嗕负24鍒椼��', + min: 1, + max: 24, + decimal: 0, + required: true + }, + { + type: 'styleInput', + key: 'height', + label: '鍥捐〃楂樺害', + initVal: card.height, + tooltip: '鍥捐〃缁樺浘鍖哄煙鐨勯珮搴︼紝涓嶅寘鎷爣棰樺強鍐呭杈硅窛銆�', + required: true, + options: ['px', 'vh', 'vw'] + }, + { + type: 'radio', + key: 'permission', + label: '鏉冮檺楠岃瘉', + initVal: card.permission || 'false', + required: false, + options: [ + {value: 'true', text: '鍚敤'}, + {value: 'false', text: '绂佺敤'}, + ], + forbid: !appType || ispop || isprint + }, + { + type: 'radio', + key: 'cacheLocal', + label: '鏈湴缂撳瓨', + initVal: card.cacheLocal || 'true', + required: false, + options: [ + {value: 'true', text: '缁ф壙鑿滃崟'}, + {value: 'false', text: '绂佺敤'}, + ], + forbid: ispop || isprint + }, + { + type: 'select', + key: 'blacklist', + label: '榛戝悕鍗�', + initVal: card.blacklist || [], + multi: true, + required: false, + options: roleList, + forbid: !!appType || isprint + }, + { + type: 'radio', + key: 'click', + label: '鐐瑰嚮浜嬩欢', + initVal: card.click || '', + tooltip: '鐐瑰嚮鏌卞瓙鏃惰Е鍙戠殑浜嬩欢锛屽惎鐢ㄨ嚜瀹氫箟璁剧疆鏃舵棤鏁堛��', + required: false, + forbid: appType === 'mob' || card.chartType !== 'bar', + options: [ + {value: '', label: '鏁版嵁鍒囨崲'}, + {value: 'menu', label: '鑿滃崟'}, + {value: 'menus', label: '鑿滃崟缁�'} + ] + }, + { + type: appType === '' ? 'cascader' : 'select', + key: 'menu', + label: '鍏宠仈鑿滃崟', + initVal: card.menu || (appType === '' ? [] : ''), + tooltip: '鍦ㄤ娇鐢ㄦ煴褰㈠浘涓旀湭鍚敤鑷畾涔夎缃椂鏈夋晥銆�', + required: true, + forbid: appType === 'mob' || card.chartType !== 'bar', + hidden: card.click !== 'menu', + options: menulist + }, + { + type: 'select', + key: 'menuType', + label: '鑿滃崟绫诲瀷', + initVal: card.menuType || '', + required: true, + forbid: appType === 'mob' || card.chartType !== 'bar', + hidden: card.click !== 'menus', + options: columns, + }, + { + type: 'radio', + key: 'open', + label: '鎵撳紑鏂瑰紡', + initVal: card.open || 'blank', + required: false, + options: [ + {value: 'blank', label: '鏂扮獥鍙�'}, + {value: 'self', label: '褰撳墠绐楀彛'}, + ], + forbid: appType !== 'pc' || card.chartType !== 'bar', + hidden: card.click !== 'menu' && card.click !== 'menus' + }, + { + type: 'radio', + key: 'joint', + label: '鍙傛暟鎷兼帴', + initVal: card.joint || 'true', + required: false, + options: [ + {value: 'true', label: '鏄�'}, + {value: 'false', label: '鍚�'}, + ], + forbid: appType === 'mob' || card.chartType !== 'bar', + hidden: card.click !== 'menu' && card.click !== 'menus' + }, + { + type: 'table', + key: 'menus', + label: '鑿滃崟缁�', + initVal: card.menus || [], + required: true, + span: 24, + actions: ['view'], + forbid: appType === 'mob' || card.chartType !== 'bar', + hidden: card.click !== 'menus', + columns: [ + { + title: '鏍囪瘑', + dataIndex: 'sign', + inputType: 'input', + editable: true, + unique: true, + required: false, + width: '35%' + }, + { + title: '鑿滃崟', + dataIndex: 'menu', + inputType: !appType ? 'cascader' : 'select', + editable: true, + required: true, + extends: !appType ? 'Menu' : [{key: 'label', value: 'label'}], + width: '35%', + render: (text, record) => record.label, + options: menulist + } + ] + } + ] +} /** * @description 鑾峰彇鍥捐〃瑙嗗浘閰嶇疆琛ㄥ崟 * @param {object} card // 鍥捐〃瀵硅薄 * @param {Array} columns // 鏄剧ず鍒� */ -export function getBarOrLineChartOptionForm (card, columns) { +export function getOptionForm (card, columns) { + let appType = sessionStorage.getItem('appType') let shapes = [] if (card.chartType === 'line') { shapes = [ - { field: 'smooth', label: 'smooth' }, - { field: 'line', label: 'line' }, - { field: 'dot', label: 'dot' }, - { field: 'dash', label: 'dash' }, - { field: 'hv', label: 'hv' }, - { field: 'vh', label: 'vh' }, - { field: 'hvh', label: 'hvh' }, - { field: 'vhv', label: 'vhv' } + { field: 'smooth', label: 'smooth锛堝钩婊戠嚎锛�' }, + { field: 'line', label: 'line锛堢洿绾匡級' }, + { field: 'dot', label: 'dot锛堢偣鐘剁嚎锛�' }, + { field: 'dash', label: 'dash锛堣櫄绾匡級' }, + { field: 'hv', label: 'hv锛堟按骞�-鍨傜洿绾匡級' }, + { field: 'vh', label: 'vh锛堝瀭鐩�-姘村钩绾匡級' }, + { field: 'hvh', label: 'hvh锛堟按骞�-鍨傜洿-姘村钩绾匡級' }, + { field: 'vhv', label: 'vhv锛堝瀭鐩�-姘村钩-鍨傜洿绾匡級' } ] } else if (card.chartType === 'bar') { shapes = [ - { field: 'rect', label: 'rect' }, - { field: 'hollow-rect', label: 'hollow-rect' }, - { field: 'line', label: 'line' }, - { field: 'tick', label: 'tick' }, - { field: 'funnel', label: 'funnel' }, - { field: 'pyramid', label: 'pyramid' } + { field: 'rect', label: 'rect锛堢煩褰級' }, + { field: 'hollow-rect', label: 'hollow-rect锛堢┖蹇冪煩褰級' }, + { field: 'line', label: 'line锛堢嚎鏉★級' }, + { field: 'tick', label: 'tick锛堟尝鍔級' }, + // { field: 'funnel', label: 'funnel' }, + { field: 'pyramid', label: 'pyramid锛堣閿ワ級' } ] } + + let xfields = columns.filter(item => /^Nvarchar/ig.test(item.datatype)) + let yfields = columns.filter(item => /^(Int|Decimal)/ig.test(item.datatype)) + + let labelOptions = [{ + value: 'false', + text: '闅愯棌' + }, { + value: 'true', + text: '鏄剧ず' + }] + + if (card.chartType === 'bar') { + labelOptions[1].text = '澶栭儴' + labelOptions.push(...[{ + value: 'top', + text: '椤堕儴' + }, { + value: 'middle', + text: '涓棿' + }, { + value: 'bottom', + text: '搴曢儴' + }]) + } + + let _label = card.label || 'false' return [ { @@ -39,22 +274,57 @@ key: 'datatype', label: '鏁版嵁绫诲瀷', initVal: card.datatype || 'query', - tooltip: '缁熻鍥捐〃閫傜敤浜庤〃鏍间笉鍒嗛〉锛屼笖鏁版嵁闇�瑕佽浆鎹�', + tooltip: '缁熻鍥捐〃閫傜敤浜庡睍绀烘暟鎹被鍨嬩负鍔ㄦ�佸�笺��', required: false, options: [ - { value: 'query', text: Formdict['header.form.query'] }, - { value: 'statistics', text: Formdict['header.form.statistics'] } + { value: 'query', text: '鏌ヨ' }, + { value: 'statistics', text: '缁熻' } ] - }, - { + }, { type: 'select', key: 'Xaxis', label: 'X-杞�', initVal: card.Xaxis || '', required: true, - options: columns.filter(col => col.type === 'text') - }, - { + options: xfields + }, { + type: 'select', + key: 'InfoType', + label: '绫诲瀷', + initVal: card.InfoType || '', + hidden: card.datatype !== 'statistics', + required: true, + options: xfields + }, { + type: 'select', + key: 'InfoValue', + label: '鍊�', + initVal: card.InfoValue || '', + hidden: card.datatype !== 'statistics', + required: true, + options: yfields + }, { + type: 'select', + key: 'legend', + label: '鍥句緥浣嶇疆', + initVal: card.legend || 'bottom', + required: false, + options: [ + { field: 'bottom', label: '涓�' }, + { field: 'bottom-left', label: '涓嬪乏' }, + { field: 'bottom-right', label: '涓嬪彸' }, + { field: 'top', label: '涓�' }, + { field: 'top-left', label: '涓婂乏' }, + { field: 'top-right', label: '涓婂彸' }, + { field: 'right', label: '鍙�' }, + { field: 'right-top', label: '鍙充笂' }, + { field: 'right-bottom', label: '鍙充笅' }, + { field: 'left', label: '宸�' }, + { field: 'left-top', label: '宸︿笂' }, + { field: 'left-bottom', label: '宸︿笅' }, + { field: 'hidden', label: '闅愯棌' } + ] + }, { type: 'select', key: 'Yaxis', label: 'Y-杞�', @@ -62,60 +332,18 @@ multi: true, // 澶氶�� hidden: card.datatype === 'statistics', required: true, - options: columns.filter(col => col.type === 'number') - }, - { - type: 'select', - key: 'InfoType', - label: '绫诲瀷', - initVal: card.InfoType || '', - hidden: card.datatype !== 'statistics', - required: true, - options: columns.filter(col => col.type === 'text') - }, - { - type: 'select', - key: 'InfoValue', - label: '鍊�', - initVal: card.InfoValue || '', - hidden: card.datatype !== 'statistics', - required: true, - options: columns.filter(col => col.type === 'number') - }, - { - type: 'select', - key: 'legend', - label: '鍥句緥浣嶇疆', - initVal: card.legend || 'bottom', - required: false, - options: [ - { field: 'top', label: 'top' }, - { field: 'top-left', label: 'top-left' }, - { field: 'top-right', label: 'top-right' }, - { field: 'right', label: 'right' }, - { field: 'right-top', label: 'right-top' }, - { field: 'right-bottom', label: 'right-bottom' }, - { field: 'left', label: 'left' }, - { field: 'left-top', label: 'left-top' }, - { field: 'left-bottom', label: 'left-bottom' }, - { field: 'bottom', label: 'bottom' }, - { field: 'bottom-left', label: 'bottom-left' }, - { field: 'bottom-right', label: 'bottom-right' }, - { field: 'hidden', label: 'hidden' } - ] - }, - { + options: yfields + }, { type: 'select', key: 'shape', label: '褰㈢姸', initVal: card.shape || (shapes[0] && shapes[0].field), required: false, options: shapes - }, - { + }, { type: 'radio', key: 'tooltip', - label: '鎻愮ず淇℃伅', + label: '鎮诞鎻愮ず', initVal: card.tooltip || 'true', required: false, options: [{ @@ -125,22 +353,7 @@ value: 'false', text: '闅愯棌' }] - }, - { - type: 'radio', - key: 'coordinate', - label: '鍧愭爣', - initVal: card.coordinate || 'angle', - required: false, - options: [{ - value: 'angle', - text: '浜岀淮鍧愭爣' - }, { - value: 'polar', - text: '鏋佸潗鏍�' - }] - }, - { + }, { type: 'radio', key: 'point', label: '鐐瑰浘', @@ -154,48 +367,72 @@ value: 'false', text: '闅愯棌' }] - }, - { + }, { type: 'radio', key: 'transpose', label: '鍙樻崲', initVal: card.transpose || 'false', + tooltip: '妯旱鍧愭爣杞翠氦鎹�', required: false, options: [{ value: 'true', - text: Formdict['model.true'] + text: '鏄�' }, { value: 'false', - text: Formdict['model.false'] + text: '鍚�' }] - }, - { + }, { type: 'radio', key: 'show', - label: '鏄剧ず鍊�', + label: '鏄剧ず', initVal: card.show || 'value', + tooltip: '褰撲娇鐢ㄨ嚜瀹氫箟璁剧疆鏃讹紝鍙湪鏄剧ず锛堝��/%锛夊鍗曠嫭璁剧疆鏄剧ず绫诲瀷銆傛敞锛氳嚜瀹氫箟涓虹┖鏃朵娇鐢ㄦ澶勮缃��', required: false, options: [{ - value: 'percent', - text: '鐧惧垎姣�' - }, { value: 'value', text: '鏁板��' - }] - }, - { - type: 'radio', - key: 'label', - label: '鏍囨敞-鍊�', - initVal: card.label || 'false', - required: false, - options: [{ - value: 'true', - text: '鏄剧ず' }, { - value: 'false', - text: '闅愯棌' + value: 'percent', + text: '鐧惧垎姣�' }] + }, { + type: labelOptions.length > 20 ? 'select' : 'radio', + key: 'label', + label: '鏍囨敞', + initVal: _label, + tooltip: '鍥惧舰鑺傜偣澶勭殑鏁板�笺��', + required: false, + options: labelOptions + }, { + type: 'radio', + key: 'labelColor', + label: '鏍囨敞棰滆壊', + initVal: card.labelColor || 'system', + tooltip: '浣跨敤绯荤粺鑹叉椂锛屼娇鐢ㄨ壊绯婚�夐」璁剧疆鐨勭郴缁熼鑹诧紝浣跨敤鑷畾涔変负棰滆壊璁剧疆涓畾涔夌殑鍥惧舰棰滆壊銆�', + required: false, + hidden: _label !== 'true', + options: [{ + value: 'system', + text: '绯荤粺' + }, { + value: 'custom', + text: '鑷畾涔�' + }] + }, { + type: 'radio', + key: 'labelValue', + label: '鏍囨敞鍊�', + initVal: card.labelValue || 'default', + tooltip: '鏍囨敞鍊肩殑鏄剧ず瑙勫垯銆�', + required: false, + hidden: _label === 'false', + options: [{ + value: 'default', + text: '榛樿' + }, { + value: 'zero', + text: '闅愯棌 0 鍊�' + }], }, { type: 'radio', key: 'adjust', @@ -209,6 +446,21 @@ }, { value: 'stack', text: '鍫嗗彔' + }] + }, { + type: 'radio', + key: 'area', + label: '闈㈢Н鍥�', + initVal: card.area || 'false', + // tooltip: '浠呭湪褰㈢姸涓簊mooth鏃舵湁鏁堛��', + required: false, + forbid: ['bar'].includes(card.chartType), + options: [{ + value: 'true', + text: '鏄剧ず' + }, { + value: 'false', + text: '涓嶆樉绀�' }] }, { type: 'radio', @@ -227,27 +479,172 @@ text: '绱姞' }] }, { - type: 'number', - key: 'InfoDefNumber', - label: '灞曠ず鏁�', - tooltip: '榛樿鏄剧ず绫诲瀷鏁伴噺', - min: 1, - max: 50, - decimal: 0, - initVal: card.InfoDefNumber || 5, - hidden: card.datatype !== 'statistics', - required: true + type: 'radio', + key: 'coordinate', + label: '鍧愭爣', + initVal: card.coordinate || 'angle', + required: false, + options: [{ + value: 'angle', + text: '浜岀淮鍧愭爣' + }, { + value: 'polar', + text: '鏋佸潗鏍�' + }] + }, { + type: 'radio', + key: 'grid', + label: '缃戞牸绾�', + initVal: card.grid || 'show', + required: false, + options: [{ + value: 'show', + text: '鏄剧ず' + }, { + value: 'hidden', + text: '闅愯棌' + }] + }, { + type: 'radio', + key: 'y_line', + label: 'y杞磋竟绾�', + initVal: card.y_line || 'hidden', + tooltip: '鍥惧舰宸︿晶鎴栧彸渚х殑杈圭嚎銆�', + required: false, + options: [{ + value: 'show', + text: '鏄剧ず' + }, { + value: 'hidden', + text: '闅愯棌' + }] + }, { + type: 'radio', + key: 'download', + label: '瀵煎嚭鍥剧墖', + initVal: card.download || 'forbid', + required: false, + forbid: appType === 'mob', + options: [{ + value: 'forbid', + text: '绂佺敤' + }, { + value: 'enable', + text: '鍚敤' + }] + }, { + type: 'radio', + key: 'empty', + label: '绌哄�奸殣钘�', + initVal: card.empty || 'show', + tooltip: '褰撴煡璇㈡暟鎹负绌烘椂锛岄殣钘忚缁勪欢銆�', + required: false, + options: [ + {value: 'show', text: '鍚�'}, + {value: 'hidden', text: '鏄�'}, + ], }, { type: 'number', - key: 'correction', - label: '鏁版嵁淇', - tooltip: '褰撴暟鎹」灏戜簬璁剧疆鍊兼椂锛岀郴缁熶細鑷姩淇锛堥伩鍏嶆煴褰㈠浘杩囧锛�,鍦ㄨ嚜瀹氫箟涓紝璁剧疆涓烘姌绾垮浘鏃跺け鏁堛��', + key: 'barSize', + label: '鏌卞舰瀹藉害', + tooltip: '绌哄�兼椂锛屽搴﹁嚜閫傚簲銆�', min: 5, - max: 30, + max: 100, decimal: 0, - initVal: card.correction, + initVal: card.barSize, forbid: !['bar'].includes(card.chartType), required: false + }, { + type: 'number', + key: 'barRadius', + label: '鏌卞舰鍦嗚', + tooltip: '鏌卞舰鍥句笂绔渾瑙掋��', + min: 0, + max: 200, + decimal: 0, + initVal: card.barRadius || 0, + forbid: !['bar'].includes(card.chartType), + required: false + }, { + type: 'number', + key: 'min', + label: '鏈�灏忓��', + tooltip: 'y杞存渶灏忓�硷紝涓虹┖鏃惰嚜閫傚簲銆�', + initVal: card.min, + required: false + }, { + type: 'number', + key: 'max', + label: '鏈�澶у��', + tooltip: 'y杞存渶澶у�硷紝涓虹┖鏃惰嚜閫傚簲銆�', + initVal: card.max, + required: false + }, { + type: 'number', + key: 'XLimit', + min: 2, + label: '瀛楃闄愬埗', + tooltip: 'X杞存渶澶у瓧绗﹂檺鍒躲��', + initVal: card.XLimit || 11, + forbid: appType === 'mob', + required: false + }, { + type: 'color', + key: 'color', + label: '鑹茬郴', + initVal: card.color || 'rgba(0, 0, 0, 0.65)', + tooltip: '鍧愭爣杞存彁绀烘枃瀛楀強绀轰緥鐨勯鑹层��', + required: false + }, { + type: 'color', + key: 'lineColor', + label: '杞寸嚎棰滆壊', + initVal: card.lineColor, + tooltip: '鍧愭爣杞寸嚎鐨勯鑹诧紝鍖呮嫭x杞淬�亂杞村強缃戞牸绾裤��', + allowClear: true, + required: false + }, { + type: 'color', + key: 'selectColor', + label: '閫変腑棰滆壊', + initVal: card.selectColor || '', + tooltip: '閫変腑鏌卞舰鍥剧殑棰滆壊锛屽湪浜や簰鏁堟灉銆婂厓绱犻�変腑锛堝閫夛級銆嬪拰銆婂厓绱犻�変腑锛堝崟閫夛級銆嬩腑鏈夋晥锛屽惎鐢ㄨ嚜瀹氫箟璁剧疆鏃舵棤鏁堛��', + forbid: !['bar'].includes(card.chartType), + allowClear: true, + required: false + }, { + type: 'number', + key: 'rotate', + label: '鏃嬭浆', + tooltip: '鍧愭爣杞存爣娉ㄦ枃鏈殑鏃嬭浆瑙掑害銆�', + min: 0, + max: 360, + decimal: 0, + initVal: card.rotate, + forbid: appType !== 'mob', + required: false + }, { + type: 'select', + key: 'interaction', + label: '浜や簰鏁堟灉', + initVal: card.interaction || [], + multi: true, + required: false, + forbid: appType === 'mob', + options: [ + { value: 'element-active', label: '鍏冪礌鑱氱劍' }, + { value: 'element-selected', label: '鍏冪礌閫変腑锛堝閫夛級' }, + { value: 'element-single-selected', label: '鍏冪礌閫変腑锛堝崟閫夛級' }, + { value: 'active-region', label: '鑳屾櫙妗�' }, + { value: 'view-zoom', label: '瑙嗗浘缂╂斁' }, + { value: 'element-highlight', label: '鍏冪礌楂樹寒' }, + { value: 'element-highlight-by-color', label: '鍚岃壊鍏冪礌楂樹寒' }, + { value: 'element-highlight-by-x', label: '鍚孹杞村厓绱犻珮浜�' }, + { value: 'legend-filter', label: '鍥句緥杩囨护' }, + { value: 'legend-active', label: '鍥句緥鑱氱劍' }, + { value: 'legend-highlight', label: '鍥句緥楂樹寒' }, + { value: 'brush', label: '閫夋杩囨护' }, + ] } ] } -- Gitblit v1.8.0