From 11745b05b3ecdd3a3dc6f64793dc83a095de2b09 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 12 五月 2022 10:19:52 +0800 Subject: [PATCH] 2022-05-12 --- src/tabviews/custom/components/chart/antv-scatter/index.jsx | 2 src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 2 src/tabviews/custom/components/code/sand-box/index.jsx | 2 src/tabviews/custom/components/chart/antv-dashboard/index.jsx | 2 src/tabviews/custom/components/editor/braft-editor/index.jsx | 2 src/tabviews/custom/components/tree/antd-tree/index.jsx | 2 src/menu/components/form/formaction/actionform/index.jsx | 2 src/utils/utils-custom.js | 85 +++++ src/menu/components/card/cardcellcomponent/elementform/index.jsx | 27 + src/tabviews/custom/components/carousel/data-card/index.jsx | 2 src/tabviews/custom/components/table/edit-table/index.jsx | 2 src/menu/components/form/formaction/index.jsx | 3 src/menu/components/chart/antv-dashboard/chartcompile/formconfig.jsx | 2 src/tabviews/zshare/actionList/normalbutton/index.jsx | 5 src/tabviews/custom/components/chart/custom-chart/index.jsx | 2 src/tabviews/custom/components/card/data-card/index.jsx | 2 src/menu/components/form/formaction/formconfig.jsx | 11 src/tabviews/custom/components/form/tab-form/index.jsx | 2 src/tabviews/custom/components/card/table-card/index.jsx | 2 src/tabviews/custom/components/card/cardcellList/index.jsx | 12 src/tabviews/custom/components/card/prop-card/index.jsx | 2 src/menu/components/card/cardcellcomponent/index.jsx | 7 src/menu/stylecontroller/index.jsx | 2 src/tabviews/zshare/fileupload-pice/index.scss | 53 +++ src/templates/zshare/formconfig.jsx | 2 src/menu/components/share/actioncomponent/formconfig.jsx | 13 src/tabviews/custom/components/table/normal-table/index.jsx | 2 src/mob/components/menubar/normal-menubar/menucomponent/options.jsx | 2 src/tabviews/custom/components/chart/antv-pie/index.jsx | 2 src/tabviews/custom/components/timeline/normal-timeline/index.jsx | 2 src/menu/components/share/actioncomponent/index.jsx | 3 src/tabviews/custom/components/form/normal-form/index.jsx | 2 src/menu/components/card/cardcellcomponent/formconfig.jsx | 12 src/menu/components/share/actioncomponent/actionform/index.jsx | 6 src/tabviews/custom/components/carousel/prop-card/index.jsx | 2 src/tabviews/zshare/fileupload/index.jsx | 112 +----- src/tabviews/zshare/fileupload-pice/index.jsx | 498 +++++++++++++++++++++++++++++++ src/tabviews/zshare/fileupload/index.scss | 12 38 files changed, 778 insertions(+), 127 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/elementform/index.jsx b/src/menu/components/card/cardcellcomponent/elementform/index.jsx index 9dc0f21..9e5c2c1 100644 --- a/src/menu/components/card/cardcellcomponent/elementform/index.jsx +++ b/src/menu/components/card/cardcellcomponent/elementform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Select, Radio, Tooltip, InputNumber } from 'antd' +import { Form, Row, Col, Input, Select, Radio, Tooltip, InputNumber, Cascader } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' import { formRule } from '@/utils/option.js' @@ -15,7 +15,7 @@ const cardTypeOptions = { sequence: ['eleType', 'width'], - text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link', 'noValue', 'bgImage', 'fixStyle'], + text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link', 'anchors', 'noValue', 'bgImage', 'fixStyle'], number: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'noValue', 'fixStyle'], picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'maxWidth', 'link', 'noValue'], video: ['eleType', 'datatype', 'width', 'aspectRatio', 'autoPlay', 'loop', 'noValue'], @@ -507,6 +507,29 @@ </Form.Item> </Col> ) + } else if (item.type === 'cascader') { + fields.push( + <Col span={12} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}> + <QuestionCircleOutlined className="mk-form-tip" /> + {item.label} + </Tooltip> : item.label + }> + {getFieldDecorator(item.key, { + initialValue: item.initVal || [], + rules: [ + { + required: !!item.required, + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Cascader options={item.options || []} expandTrigger="hover" placeholder=""/> + )} + </Form.Item> + </Col> + ) } }) return fields diff --git a/src/menu/components/card/cardcellcomponent/formconfig.jsx b/src/menu/components/card/cardcellcomponent/formconfig.jsx index 594f08a..1bfeece 100644 --- a/src/menu/components/card/cardcellcomponent/formconfig.jsx +++ b/src/menu/components/card/cardcellcomponent/formconfig.jsx @@ -8,7 +8,7 @@ * @param {*} card * @param {*} type */ -export function getCardCellForm (card, type, subtype, cardCell) { +export function getCardCellForm (card, type, subtype, cardCell, anchors) { let _options = [ { value: 'text', text: '鏂囨湰'}, { value: 'number', text: '鏁板��'}, @@ -326,6 +326,14 @@ options: [] }, { + type: 'cascader', + key: 'anchors', + label: '璺宠浆閿氱偣', + initVal: card.anchors || [], + required: false, + options: anchors + }, + { type: 'number', key: 'barHeight', min: 5, @@ -553,7 +561,7 @@ type: 'number', key: 'fixSize', min: 10, - max: 100, + max: 300, label: '瀛椾綋澶у皬', initVal: card.fixSize || 14, tooltip: '鍓嶇紑銆佸悗缂�鐨勫瓧浣撳ぇ灏忋��', diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index c88cf52..c3a5a91 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -269,10 +269,12 @@ if (card.eleType === 'button') { this.handleAction(card) } else { + let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || [] + this.setState({ visible: true, card: card, - formlist: getCardCellForm(card, cards.type, cards.subtype, cardCell) + formlist: getCardCellForm(card, cards.type, cards.subtype, cardCell, anchors) }) } } @@ -311,11 +313,12 @@ } let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, cards.uuid) || [] + let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || [] this.setState({ actvisible: true, card: card, - formlist: getActionForm(card, functip, cards, usefulFields, 'card', menulist, modules) + formlist: getActionForm(card, functip, cards, usefulFields, 'card', menulist, modules, anchors) }) } diff --git a/src/menu/components/chart/antv-dashboard/chartcompile/formconfig.jsx b/src/menu/components/chart/antv-dashboard/chartcompile/formconfig.jsx index 3add00e..f60d210 100644 --- a/src/menu/components/chart/antv-dashboard/chartcompile/formconfig.jsx +++ b/src/menu/components/chart/antv-dashboard/chartcompile/formconfig.jsx @@ -239,7 +239,7 @@ label: '瀛椾綋澶у皬', initVal: card.fontSize || 28, min: 12, - max: 200, + max: 300, decimal: 0, required: true }, diff --git a/src/menu/components/form/formaction/actionform/index.jsx b/src/menu/components/form/formaction/actionform/index.jsx index 4a4ecf1..319f771 100644 --- a/src/menu/components/form/formaction/actionform/index.jsx +++ b/src/menu/components/form/formaction/actionform/index.jsx @@ -54,7 +54,7 @@ } else if (card.type === 'next') { return ['type', 'label', 'enable'] } - let _options = ['type', 'label', 'intertype', 'syncComponent', 'linkmenu', 'open', 'enable', 'output', 'reload'] // 閫夐」鍒楄〃 + let _options = ['type', 'label', 'intertype', 'syncComponent', 'anchors', 'linkmenu', 'open', 'enable', 'output', 'reload'] // 閫夐」鍒楄〃 if (_intertype === 'custom') { _options.pop() diff --git a/src/menu/components/form/formaction/formconfig.jsx b/src/menu/components/form/formaction/formconfig.jsx index 01b6326..5700279 100644 --- a/src/menu/components/form/formaction/formconfig.jsx +++ b/src/menu/components/form/formaction/formconfig.jsx @@ -9,7 +9,7 @@ * @param {*} type 鎸夐挳绫诲瀷锛岀敤浜庡尯鍒嗗彲閫夌殑鎵撳紑鏂瑰紡 */ -export function getActionForm (card, functip, tableName, usefulFields, modules) { +export function getActionForm (card, functip, tableName, usefulFields, modules, anchors) { const appType = sessionStorage.getItem('appType') let _type = '鎻愪氦' if (card.type === 'prev') { @@ -287,6 +287,15 @@ options: modules }, { + type: 'cascader', + key: 'anchors', + label: '璺宠浆閿氱偣', + initVal: card.anchors || [], + tooltip: '鎵ц鎴愬姛鍚庯紝闇�瑕佽烦杞殑閿氱偣', + required: false, + options: anchors + }, + { type: 'radio', key: 'reload', label: '涓婁竴椤�', diff --git a/src/menu/components/form/formaction/index.jsx b/src/menu/components/form/formaction/index.jsx index 5a19faa..35ebf53 100644 --- a/src/menu/components/form/formaction/index.jsx +++ b/src/menu/components/form/formaction/index.jsx @@ -102,11 +102,12 @@ </div> let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid) || [] + let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, config.uuid) || [] this.setState({ visible: true, card: card, - formlist: getActionForm(card, functip, config.setting.tableName, usefulFields, modules) + formlist: getActionForm(card, functip, config.setting.tableName, usefulFields, modules, anchors) }) } diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index 10f04ea..dc8f3c3 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -11,9 +11,9 @@ const { TextArea } = Input const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) const acTyOptions = { - pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'switchTab', 'width', 'openmenu', 'open', 'refreshTab', 'position', 'tipTitle', 'hidden'], - prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'switchTab', 'width', 'openmenu', 'open', 'refreshTab', 'position', 'tipTitle', 'hidden'], - exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'switchTab', 'width', 'openmenu', 'open', 'refreshTab', 'hidden'], + pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'open', 'refreshTab', 'position', 'tipTitle', 'hidden'], + prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'open', 'refreshTab', 'position', 'tipTitle', 'hidden'], + exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'open', 'refreshTab', 'hidden'], excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'color', 'sheet', 'execSuccess', 'execError', 'resetPageIndex', 'syncComponent', 'switchTab', 'width', 'hidden'], excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'resetPageIndex', 'pagination', 'search', 'width', 'hidden'], popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'color', 'popClose', 'resetPageIndex', 'width', 'display', 'ratio', 'syncComponent', 'clickouter', 'hidden'], diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index 819b4ba..7dd44d3 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -12,7 +12,7 @@ * @param {*} usefulFields 瀛樺偍杩囩▼鍙敤鐨勫紑濮嬪瓧娈� * @param {*} type 鎸夐挳绫诲瀷锛岀敤浜庡尯鍒嗗彲閫夌殑鎵撳紑鏂瑰紡 */ -export function getActionForm (card, functip, config, usefulFields, type, menulist = [], modules = []) { +export function getActionForm (card, functip, config, usefulFields, type, menulist = [], modules = [], anchors = []) { let appType = sessionStorage.getItem('appType') let viewType = sessionStorage.getItem('editMenuType') // 寮圭獥 popview let printTemps = sessionStorage.getItem('printTemps') @@ -646,6 +646,15 @@ }, { type: 'cascader', + key: 'anchors', + label: '璺宠浆閿氱偣', + initVal: card.anchors || [], + tooltip: '鎵ц鎴愬姛鍚庯紝闇�瑕佽烦杞殑閿氱偣', + required: false, + options: anchors + }, + { + type: 'cascader', key: 'refreshTab', label: '鍒锋柊鑿滃崟', initVal: card.refreshTab || [], @@ -719,7 +728,7 @@ precision: 0, label: '姣斾緥', initVal: card.ratio || 85, - tooltip: '灏忎簬100涓哄搴︼紙鎴栭珮搴︼級鐧惧垎姣旓紝澶т簬100涓哄儚绱犲�笺��', + tooltip: '妯℃�佹鎴栨娊灞夌殑瀹藉害锛屽皬浜�100涓虹獥鍙e搴︼紙鎴栭珮搴︼級鐧惧垎姣旓紝澶т簬100涓哄儚绱犲�笺��', required: true }, { diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index e215195..8204e57 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -186,11 +186,12 @@ } let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid) || [] + let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, config.uuid) || [] this.setState({ visible: true, card: card, - formlist: getActionForm(card, functip, config, usefulFields, this.props.type, menulist, modules) + formlist: getActionForm(card, functip, config, usefulFields, this.props.type, menulist, modules, anchors) }) } diff --git a/src/menu/stylecontroller/index.jsx b/src/menu/stylecontroller/index.jsx index a6143e6..dcb8024 100644 --- a/src/menu/stylecontroller/index.jsx +++ b/src/menu/stylecontroller/index.jsx @@ -430,7 +430,7 @@ {options.includes('font') ? <Panel header="瀛椾綋" key="font"> <Col span={12}> <Form.Item colon={false} label={<FontSizeOutlined title="瀛椾綋澶у皬"/>}> - <InputNumber defaultValue={card.fontSize || 14} min={12} max={100} precision={0} onChange={this.changeFontSize} /> + <InputNumber defaultValue={card.fontSize || 14} min={12} max={300} precision={0} onChange={this.changeFontSize} /> </Form.Item> </Col> <Col span={12}> diff --git a/src/mob/components/menubar/normal-menubar/menucomponent/options.jsx b/src/mob/components/menubar/normal-menubar/menucomponent/options.jsx index ed3e96c..3e8bc87 100644 --- a/src/mob/components/menubar/normal-menubar/menucomponent/options.jsx +++ b/src/mob/components/menubar/normal-menubar/menucomponent/options.jsx @@ -136,7 +136,7 @@ label: '瀛椾綋澶у皬', initval: setting.iconFont || 20, min: 12, - max: 200, + max: 300, precision: 0, required: true }, diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 04bd074..b7da02b 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -73,6 +73,14 @@ openNewView = (e, card) => { const { cardCell, data, cards } = this.props + if (data.$disabled) return + + if (card.anchors && card.anchors.length > 0) { + let id = card.anchors[card.anchors.length - 1] + let node = document.getElementById('anchor' + id) + node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'}) + } + if (!card.link) return e.stopPropagation() @@ -349,9 +357,11 @@ } } - if (card.link) { + if (card.link || (card.anchors && card.anchors.length > 0)) { _style.cursor = 'pointer' } + + if (!card.link) if (card.bgImage && data[card.bgImage]) { _style.backgroundImage = `url('${data[card.bgImage]}')` diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 3b9a2bc..ff0e6b9 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -744,7 +744,7 @@ } return ( - <div className="custom-data-card-box" style={config.style}> + <div className="custom-data-card-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> {data ? <div className="ant-spin-blur"></div> : null} diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index 7afcd7a..34bbdfd 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -420,7 +420,7 @@ if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null return ( - <div className="custom-prop-card-box" style={config.style}> + <div className="custom-prop-card-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index 845703f..bdc334c 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -422,7 +422,7 @@ if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null return ( - <div className="custom-table-card-box" style={{...config.style}}> + <div className="custom-table-card-box" id={'anchor' + config.uuid} style={{...config.style}}> {loading ? <div className="loading-mask"> {data ? <div className="ant-spin-blur"></div> : null} diff --git a/src/tabviews/custom/components/carousel/data-card/index.jsx b/src/tabviews/custom/components/carousel/data-card/index.jsx index 9fe7608..b4ca598 100644 --- a/src/tabviews/custom/components/carousel/data-card/index.jsx +++ b/src/tabviews/custom/components/carousel/data-card/index.jsx @@ -258,7 +258,7 @@ if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null return ( - <div className="custom-data-carousel-box" style={config.style}> + <div className="custom-data-carousel-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> {data ? <div className="ant-spin-blur"></div> : null} diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx index f4f51b7..10555d9 100644 --- a/src/tabviews/custom/components/carousel/prop-card/index.jsx +++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx @@ -276,7 +276,7 @@ if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null return ( - <div className="custom-prop-carousel-box" style={config.style}> + <div className="custom-prop-carousel-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index 2184ac3..5da0967 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -1781,7 +1781,7 @@ } return ( - <div className="custom-line-chart-plot-box" style={style}> + <div className="custom-line-chart-plot-box" id={'anchor' + config.uuid} style={style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx index 280fa16..dd536e5 100644 --- a/src/tabviews/custom/components/chart/antv-dashboard/index.jsx +++ b/src/tabviews/custom/components/chart/antv-dashboard/index.jsx @@ -642,7 +642,7 @@ const { config, loading } = this.state return ( - <div className="custom-dashboard-plot-box" style={config.style}> + <div className="custom-dashboard-plot-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx index be6d309..8599ad4 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.jsx +++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx @@ -1054,7 +1054,7 @@ } return ( - <div className="custom-pie-chart-plot-box" style={style}> + <div className="custom-pie-chart-plot-box" id={'anchor' + config.uuid} style={style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/chart/antv-scatter/index.jsx b/src/tabviews/custom/components/chart/antv-scatter/index.jsx index 9a9d578..c650f3f 100644 --- a/src/tabviews/custom/components/chart/antv-scatter/index.jsx +++ b/src/tabviews/custom/components/chart/antv-scatter/index.jsx @@ -447,7 +447,7 @@ } return ( - <div className="custom-scatter-plot-box" style={style}> + <div className="custom-scatter-plot-box" id={'anchor' + config.uuid} style={style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/chart/custom-chart/index.jsx b/src/tabviews/custom/components/chart/custom-chart/index.jsx index 41cc2ac..5598d77 100644 --- a/src/tabviews/custom/components/chart/custom-chart/index.jsx +++ b/src/tabviews/custom/components/chart/custom-chart/index.jsx @@ -380,7 +380,7 @@ const { config, loading, empty, BID } = this.state return ( - <div className="custom-chart-plot-box" style={config.style}> + <div className="custom-chart-plot-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx index e7c6a74..0938216 100644 --- a/src/tabviews/custom/components/code/sand-box/index.jsx +++ b/src/tabviews/custom/components/code/sand-box/index.jsx @@ -208,7 +208,7 @@ const { config, loading, html } = this.state return ( - <div className="custom-sand-box" style={{...config.style}}> + <div className="custom-sand-box" id={'anchor' + config.uuid} style={{...config.style}}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/editor/braft-editor/index.jsx b/src/tabviews/custom/components/editor/braft-editor/index.jsx index 54ee6a6..437de06 100644 --- a/src/tabviews/custom/components/editor/braft-editor/index.jsx +++ b/src/tabviews/custom/components/editor/braft-editor/index.jsx @@ -177,7 +177,7 @@ const { config, loading, data } = this.state return ( - <div className="custom-braft-editor-box" style={config.style}> + <div className="custom-braft-editor-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/form/normal-form/index.jsx b/src/tabviews/custom/components/form/normal-form/index.jsx index 1fdc49f..a8ad272 100644 --- a/src/tabviews/custom/components/form/normal-form/index.jsx +++ b/src/tabviews/custom/components/form/normal-form/index.jsx @@ -359,7 +359,7 @@ const { config, loading, BID, data, group, dict, step } = this.state return ( - <div className="custom-normal-form-box" style={{...config.style}}> + <div className="custom-normal-form-box" id={'anchor' + config.uuid} style={{...config.style}}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/form/tab-form/index.jsx b/src/tabviews/custom/components/form/tab-form/index.jsx index a3f9f60..de65619 100644 --- a/src/tabviews/custom/components/form/tab-form/index.jsx +++ b/src/tabviews/custom/components/form/tab-form/index.jsx @@ -307,7 +307,7 @@ const { config, loading, BID, data, group, dict } = this.state return ( - <div className="custom-tab-form-box" style={{...config.style}}> + <div className="custom-tab-form-box" id={'anchor' + config.uuid} style={{...config.style}}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx index 613acf2..13e6ea1 100644 --- a/src/tabviews/custom/components/table/edit-table/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/index.jsx @@ -589,7 +589,7 @@ const { BID, setting, searchlist, actions, config, columns, BData, selectedData, lock } = this.state return ( - <div className="custom-edit-table" style={config.style}> + <div className="custom-edit-table" id={'anchor' + config.uuid} style={config.style}> <NormalHeader config={config}/> {searchlist && searchlist.length ? <MainSearch BID={BID} setting={config.wrap} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 8337aed..b592956 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -643,7 +643,7 @@ } return ( - <div className="custom-normal-table" style={style}> + <div className="custom-normal-table" id={'anchor' + config.uuid} style={style}> {config.wrap.collapse === 'true' ? <Collapse bordered={false} defaultActiveKey="1" expandIconPosition="right"> <Panel forceRender={true} header={<NormalHeader config={config}/>} key="1"> {searchlist && searchlist.length ? diff --git a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx index c3353c1..2a62ef0 100644 --- a/src/tabviews/custom/components/timeline/normal-timeline/index.jsx +++ b/src/tabviews/custom/components/timeline/normal-timeline/index.jsx @@ -318,7 +318,7 @@ const { config, loading, data } = this.state return ( - <div className="normal-timeline-box" style={{...config.style}}> + <div className="normal-timeline-box" id={'anchor' + config.uuid} style={{...config.style}}> {loading ? <div className="loading-mask"> {data ? <div className="ant-spin-blur"></div> : null} diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx index 305d461..da54069 100644 --- a/src/tabviews/custom/components/tree/antd-tree/index.jsx +++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx @@ -462,7 +462,7 @@ const { config, loading, treeNodes, expandedKeys, selectedKeys } = this.state return ( - <div className="custom-tree-box" style={config.style}> + <div className="custom-tree-box" id={'anchor' + config.uuid} style={config.style}> {loading ? <div className="loading-mask"> <div className="ant-spin-blur"></div> diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 7b3b4dc..3eff1c7 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -1556,6 +1556,11 @@ let node = document.getElementById('tab' + id) node && node.click() } + if (btn.anchors && btn.anchors.length > 0) { + let id = btn.anchors[btn.anchors.length - 1] + let node = document.getElementById('anchor' + id) + node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'}) + } if (btn.openmenu && btn.openmenu.length > 0 && btn.MenuID) { let newtab = { diff --git a/src/tabviews/zshare/fileupload-pice/index.jsx b/src/tabviews/zshare/fileupload-pice/index.jsx new file mode 100644 index 0000000..5148154 --- /dev/null +++ b/src/tabviews/zshare/fileupload-pice/index.jsx @@ -0,0 +1,498 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import moment from 'moment' +import { Upload, Button, Progress, notification } from 'antd' +import { UploadOutlined } from '@ant-design/icons' +import SparkMD5 from 'spark-md5' +import Api from '@/api' +import './index.scss' + +let service = '' +if (process.env.NODE_ENV === 'production') { + service = document.location.origin + '/' + window.GLOB.service +} else { + service = window.GLOB.location + '/' + window.GLOB.service +} + +class FileUpload extends Component { + static propTpyes = { + config: PropTypes.object, // 琛ㄥ崟淇℃伅 + onChange: PropTypes.func, // 琛ㄥ崟鍙樺寲 + } + + state = { + percent: 0, + accept: '', + accepts: null, + maxFile: null, + rduri: '', + limit: 2, + compress: false, + fileType: 'text', + showprogress: false, + filelist: [] + } + + UNSAFE_componentWillMount () { + const { config } = this.props + + let filelist = [] + if (config.initval) { + if (/^data:image/.test(config.initval)) { + filelist = [{ + uid: '0', + name: 'data:image/jpeg;base64', + status: 'done', + url: config.initval, + origin: true + }] + } else { + try { + filelist = config.initval.split(',').map((url, index) => { + return { + uid: `${index}`, + name: url.slice(url.lastIndexOf('/') + 1), + status: 'done', + url: url, + origin: true + } + }) + } catch (e) { + filelist = [] + } + } + } + + let accept = '' + let accepts = null + let compress = false + let maxFile = config.maxfile && config.maxfile > 0 ? config.maxfile : null + if (config.compress === 'true' || config.compress === 'base64') { + compress = true + accepts = ['.jpg', '.png', '.gif', '.jpeg'] + accept = accepts.join(',') + if (config.compress === 'base64') { + maxFile = 1 + } + } else if (config.suffix) { + accepts = config.suffix.split(',').map(item => { + if (!/^\./ig.test(item)) { + item = '.' + item + } + return item + }) + accept = accepts.join(',') + } + let rduri = config.rduri || '' + + if (window.GLOB.systemType === 'production') { + rduri = config.proRduri || '' + } + + this.setState({ + rduri, + accept, + accepts, + filelist, + compress, + limit: config.limit || 2, + maxFile: maxFile, + fileType: config.fileType || 'text' + }) + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + onChange = ({ fileList }) => { + fileList = fileList.map(item => { + if (item.status === 'error' && /^<!DOCTYPE html>/.test(item.response)) { + item.response = '' + } + return item + }) + + this.setState({filelist: fileList}) + } + + onRemove = file => { + const files = this.state.filelist.filter(v => v.uid !== file.uid) + + this.setState({filelist: files}) + + let vals = [] + + files.forEach(item => { + if (item.origin && item.url) { + vals.push(item.url) + } else if (!item.origin && item.status === 'done' && item.response) { + vals.push(item.response) + } + }) + + this.props.onChange(vals.join(',')) + } + + onUpdate = (url) => { + let filelist = fromJS(this.state.filelist).toJS() + + if (filelist[filelist.length -1]) { + filelist[filelist.length -1].status = 'done' + filelist[filelist.length -1].response = url + filelist[filelist.length -1].origin = false + } + + filelist = filelist.filter(item => !!(item.url || item.response)) + + let vals = [] + + filelist.forEach(item => { + if (item.origin && item.url) { + vals.push(item.url) + } else if (!item.origin && item.status === 'done' && item.response) { + vals.push(item.response) + } + }) + + this.setState({filelist}) + this.props.onChange(vals.join(',')) + } + + onFail = (msg) => { + let filelist = this.state.filelist.map(item => { + if (!item.url && !item.response && !item.status) { + item.status = 'error' + } + return item + }) + + this.setState({filelist, showprogress: false, percent: 0}) + + notification.warning({ + top: 92, + message: msg || '鏂囦欢涓婁紶澶辫触锛�', + duration: 5 + }) + } + + shardupload = (params) => { + let param = params.chunks.shift() + let form = new FormData() + + form.append('file', param.binary) + form.append('fileMd5', params.file.fileMd5) + form.append('shardingMd5', param.chunkMd5) + form.append('baseDomain', service) + form.append('rootPath', 'Content/images/upload/') + form.append('fileName', params.file.fileName) + form.append('fileExt', params.file.fileType) + form.append('shardingCnt', param.chunks) + form.append('shardingNo', param.chunk) + form.append('LoginUID', sessionStorage.getItem('LoginUID') || '') + form.append('UserID', sessionStorage.getItem('UserID') || '') + + Api.getLargeFileUpload(form).then(res => { + if (res.status) { + if (params.chunks.length > 0) { + this.setState({ + percent: Math.floor(100 * (param.chunk / param.chunks)) + }) + this.shardupload(params) + } else { + if (res.urlPath) { + this.onUpdate(res.urlPath) + } else { + this.onFail() + } + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) + } + } else { + this.onFail(res.message) + } + }) + } + + getuuid = () => { + let uuid = [] + let _options = '0123456789abcdefghigklmnopqrstuv' + for (let i = 0; i < 19; i++) { + uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) + } + uuid = uuid.join('') + return uuid + } + + beforeUpload = (file) => { + const { accepts, compress, limit, rduri } = this.state + + if (accepts && file.name) { + let pass = false + accepts.forEach(type => { + if (new RegExp(type + '$', 'ig').test(file.name)) { + pass = true + } + }) + + if (!pass) { + setTimeout(() => { + this.onFail('鏂囦欢鏍煎紡閿欒锛�') + }, 10) + return false + } + } + + this.setState({ + showprogress: true, + percent: 0 + }) + + if (compress) { + let reader = new FileReader() + let fileSize = file.size / 1024 / 1024 + let compressRate = 0.9 + + if (fileSize / limit > 5) { + compressRate = 0.4 + } else if (fileSize / limit > 4) { + compressRate = 0.5 + } else if (fileSize / limit > 3) { + compressRate = 0.6 + } else if (fileSize / limit > 2) { + compressRate = 0.7 + } else if (fileSize > limit) { + compressRate = 0.8 + } + + reader.onload = (e) => { + let img = new Image() + let maxW = 640 + + img.onload = () => { + let cvs = document.createElement( 'canvas') + let ctx = cvs.getContext( '2d') + + if (img.width > maxW) { + img.height *= maxW / img.width + img.width = maxW + } + + cvs.width = img.width + cvs.height = img.height + + ctx.clearRect(0, 0, cvs.width, cvs.height) + ctx.drawImage(img, 0, 0, img.width, img.height) + + let param = {Base64Img: cvs.toDataURL('image/jpeg', compressRate)} + + if (this.props.config.compress === 'base64') { + this.onUpdate(param.Base64Img) + + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) + } else { + if (rduri) { + param.rduri = rduri + } + + Api.fileuploadbase64(param).then(result => { + if (result.status && result.Images) { + let url = service + result.Images + + if (rduri) { + url = rduri.replace(/webapi(.*)$/, '') + result.Images + } + + this.onUpdate(url) + + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) + } else { + this.onFail(result.message) + } + }) + } + } + + img.onerror = () => { + this.onFail('鍥剧墖璇诲彇澶辫触锛�') + } + + img.src = e.target.result + } + + reader.onerror = () => { + this.onFail('鏂囦欢璇诲彇澶辫触锛�') + } + + reader.readAsDataURL(file) + return false + } + + // 鍏煎鎬х殑澶勭悊 + let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice + let chunkSize = 1024 * 1024 * 2 // 鍒囩墖姣忔2M + let chunks = Math.ceil(file.size / chunkSize) // 鍒囩墖鎬绘暟 + let currentChunk = 0 // 褰撳墠涓婁紶鐨刢hunk + let spark = new SparkMD5.ArrayBuffer() // 瀵筧rrayBuffer鏁版嵁杩涜md5鍔犲瘑锛屼骇鐢熶竴涓猰d5瀛楃涓� + let chunkFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘瘡涓猚hunkMd5 + let totalFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘�绘枃浠剁殑fileMd5 + let params = {chunks: [], file: {}} // 鐢ㄤ簬涓婁紶鎵�鏈夊垎鐗囩殑md5淇℃伅 + + params.file.fileName = file.name.replace(/\.{1}[^.]*$/ig, '') // 鏂囦欢鍚嶏紙鍘婚櫎鍚庣紑鍚嶏級 + params.file.fileType = file.name.replace(/^.*\.{1}/ig, '') // 鏂囦欢绫诲瀷 + params.file.fileSize = file.size // 鏂囦欢澶у皬 + params.file.fileChunks = chunks // 璁板綍鎵�鏈塩hunks鐨勯暱搴� + + if (!/^[A-Za-z0-9]+$/.test(params.file.fileName)) { // 鏂囦欢鍚嶇О鍚湁鑻辨枃鍙婃暟瀛椾箣澶栧瓧绗︽椂锛屽悕绉扮郴缁熺敓鎴� + params.file.fileName = moment().format('YYYYMMDDHHmmss') + this.getuuid() + } + + totalFileReader.readAsArrayBuffer(file) + totalFileReader.onload = (e) => { // 瀵规暣涓猼otalFile鐢熸垚md5 + spark.append(e.target.result) + params.file.fileMd5 = spark.end() // 璁$畻鏁翠釜鏂囦欢鐨刦ileMd5 + + let _param = new FormData() + _param.append('fileMd5', params.file.fileMd5) + + Api.getFilePreUpload(_param).then(res => { + if (res.status && res.urlPath) { + this.onUpdate(res.urlPath) + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) + } else if (res.shardings && res.shardings.length > 0) { + res.shardings.forEach(shard => { + if (shard.shardingNo && parseInt(shard.shardingNo) > currentChunk) { + currentChunk = parseInt(shard.shardingNo) + } + }) + loadNext() + } else { + loadNext() + } + }) + } + + chunkFileReader.onload = (e) => { + spark.append(e.target.result) // 瀵规瘡涓�鐗囧垎鐗囪繘琛宮d5鍔犲瘑 + + params.chunks[params.chunks.length - 1].chunkMd5 = spark.end() // 娣诲姞鍒囩墖md5 + + currentChunk++ // 姣忎竴娆″垎鐗噊nload,currentChunk閮介渶瑕佸鍔狅紝浠ヤ究鏉ヨ绠楀垎鐗囩殑娆℃暟 + + if (currentChunk < chunks) { // 褰撳墠鍒囩墖鎬绘暟娌℃湁杈惧埌鎬绘暟鏃� + loadNext() + } else { + this.shardupload(params) + } + } + + chunkFileReader.onerror = () => { + this.onFail('鏂囦欢璇诲彇澶辫触锛�') + } + totalFileReader.onerror = () => { + this.onFail('鏂囦欢璇诲彇澶辫触锛�') + } + + let loadNext = () => { + let start = currentChunk * chunkSize // 璁$畻鍒嗙墖鐨勮捣濮嬩綅缃� + let end = Math.min(file.size, start + chunkSize) // 璁$畻鍒嗙墖鐨勭粨鏉熶綅缃� + + let obj = { // 姣忎竴涓垎鐗囬渶瑕佸寘鍚殑淇℃伅 + chunk: currentChunk + 1, + binary: file.slice(start, end), + start: start, + end: end, + chunks + } + + params.chunks.push(obj) + chunkFileReader.readAsArrayBuffer(blobSlice.call(file, start, end)) + } + + return false + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + render() { + const { showprogress, percent, filelist, maxFile, fileType, accept } = this.state + + let uploadable = 'fileupload-form-container ' + + if (maxFile && filelist.length >= maxFile) { + uploadable += 'limit-fileupload' + } + + const props = { + name: 'file', + disabled: showprogress, + listType: fileType, + fileList: filelist, + action: null, + accept: accept, + method: 'post', + multiple: false, + onChange: this.onChange, + onRemove: this.onRemove, + beforeUpload: this.beforeUpload, + className: uploadable + } + + return ( + <Upload {...props}> + {fileType !== 'picture-card' ? <Button> + <UploadOutlined /> 鐐瑰嚮涓婁紶 + </Button> : null} + {fileType === 'picture-card' ? <span style={{whiteSpace: 'nowrap'}}> + <UploadOutlined /> 鐐瑰嚮涓婁紶 + </span> : null} + {showprogress ? <Progress percent={percent} size="small" /> : null} + </Upload> + ) + } +} + +export default FileUpload \ No newline at end of file diff --git a/src/tabviews/zshare/fileupload-pice/index.scss b/src/tabviews/zshare/fileupload-pice/index.scss new file mode 100644 index 0000000..86f8505 --- /dev/null +++ b/src/tabviews/zshare/fileupload-pice/index.scss @@ -0,0 +1,53 @@ +.fileupload-form-container { + .ant-progress-small.ant-progress-line { + position: absolute; + bottom: -20px; + left: 0px; + } + + .ant-upload-select-picture-card { + .ant-progress-small.ant-progress-line { + bottom: 0px; + } + } + .ant-upload-list-picture-card-container { + width: 90px; + height: 90px; + } + // .ant-upload-list-picture-card .ant-upload-list-item-undefined { + // border-color: #f5222d; + // .ant-upload-list-item-name { + // color: #f5222d; + // } + // } + .ant-upload-list-picture-card .ant-upload-list-item { + width: 90px; + height: 90px; + } + .ant-upload.ant-upload-select-picture-card { + width: 90px; + height: 90px; + } + a[href^="data"] { + pointer-events: none; + .anticon-eye-o { + display: none; + } + } +} +.fileupload-form-container.limit-fileupload { + > .ant-upload { + display: inline; + >.ant-upload { + >input { + display: none; + } + >button { + display: none; + } + } + } + > .ant-upload-select-picture-card { + display: none; + } +} \ No newline at end of file diff --git a/src/tabviews/zshare/fileupload/index.jsx b/src/tabviews/zshare/fileupload/index.jsx index 5148154..637a480 100644 --- a/src/tabviews/zshare/fileupload/index.jsx +++ b/src/tabviews/zshare/fileupload/index.jsx @@ -177,46 +177,38 @@ }) } - shardupload = (params) => { - let param = params.chunks.shift() + shardupload = (param) => { let form = new FormData() form.append('file', param.binary) - form.append('fileMd5', params.file.fileMd5) - form.append('shardingMd5', param.chunkMd5) + form.append('fileMd5', param.fileMd5) + form.append('shardingMd5', param.fileMd5) form.append('baseDomain', service) form.append('rootPath', 'Content/images/upload/') - form.append('fileName', params.file.fileName) - form.append('fileExt', params.file.fileType) - form.append('shardingCnt', param.chunks) - form.append('shardingNo', param.chunk) + form.append('fileName', param.fileName) + form.append('fileExt', param.fileType) + form.append('shardingCnt', 1) + form.append('shardingNo', 1) form.append('LoginUID', sessionStorage.getItem('LoginUID') || '') form.append('UserID', sessionStorage.getItem('UserID') || '') Api.getLargeFileUpload(form).then(res => { if (res.status) { - if (params.chunks.length > 0) { - this.setState({ - percent: Math.floor(100 * (param.chunk / param.chunks)) - }) - this.shardupload(params) + if (res.urlPath) { + this.onUpdate(res.urlPath) } else { - if (res.urlPath) { - this.onUpdate(res.urlPath) - } else { - this.onFail() - } - this.setState({ - percent: 100 - }, () => { - setTimeout(() => { - this.setState({ - showprogress: false, - percent: 0 - }) - }, 200) - }) + this.onFail() } + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) } else { this.onFail(res.message) } @@ -356,31 +348,25 @@ } // 鍏煎鎬х殑澶勭悊 - let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice - let chunkSize = 1024 * 1024 * 2 // 鍒囩墖姣忔2M - let chunks = Math.ceil(file.size / chunkSize) // 鍒囩墖鎬绘暟 - let currentChunk = 0 // 褰撳墠涓婁紶鐨刢hunk let spark = new SparkMD5.ArrayBuffer() // 瀵筧rrayBuffer鏁版嵁杩涜md5鍔犲瘑锛屼骇鐢熶竴涓猰d5瀛楃涓� - let chunkFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘瘡涓猚hunkMd5 let totalFileReader = new FileReader() // 鐢ㄤ簬璁$畻鍑烘�绘枃浠剁殑fileMd5 - let params = {chunks: [], file: {}} // 鐢ㄤ簬涓婁紶鎵�鏈夊垎鐗囩殑md5淇℃伅 + let param = {} - params.file.fileName = file.name.replace(/\.{1}[^.]*$/ig, '') // 鏂囦欢鍚嶏紙鍘婚櫎鍚庣紑鍚嶏級 - params.file.fileType = file.name.replace(/^.*\.{1}/ig, '') // 鏂囦欢绫诲瀷 - params.file.fileSize = file.size // 鏂囦欢澶у皬 - params.file.fileChunks = chunks // 璁板綍鎵�鏈塩hunks鐨勯暱搴� + param.fileName = file.name.replace(/\.{1}[^.]*$/ig, '') // 鏂囦欢鍚嶏紙鍘婚櫎鍚庣紑鍚嶏級 + param.fileType = file.name.replace(/^.*\.{1}/ig, '') // 鏂囦欢绫诲瀷 - if (!/^[A-Za-z0-9]+$/.test(params.file.fileName)) { // 鏂囦欢鍚嶇О鍚湁鑻辨枃鍙婃暟瀛椾箣澶栧瓧绗︽椂锛屽悕绉扮郴缁熺敓鎴� - params.file.fileName = moment().format('YYYYMMDDHHmmss') + this.getuuid() + if (!/^[A-Za-z0-9]+$/.test(param.fileName)) { // 鏂囦欢鍚嶇О鍚湁鑻辨枃鍙婃暟瀛椾箣澶栧瓧绗︽椂锛屽悕绉扮郴缁熺敓鎴� + param.fileName = moment().format('YYYYMMDDHHmmss') + this.getuuid() } totalFileReader.readAsArrayBuffer(file) totalFileReader.onload = (e) => { // 瀵规暣涓猼otalFile鐢熸垚md5 spark.append(e.target.result) - params.file.fileMd5 = spark.end() // 璁$畻鏁翠釜鏂囦欢鐨刦ileMd5 + param.fileMd5 = spark.end() // 璁$畻鏁翠釜鏂囦欢鐨刦ileMd5 + param.binary = file let _param = new FormData() - _param.append('fileMd5', params.file.fileMd5) + _param.append('fileMd5', param.fileMd5) Api.getFilePreUpload(_param).then(res => { if (res.status && res.urlPath) { @@ -395,54 +381,14 @@ }) }, 200) }) - } else if (res.shardings && res.shardings.length > 0) { - res.shardings.forEach(shard => { - if (shard.shardingNo && parseInt(shard.shardingNo) > currentChunk) { - currentChunk = parseInt(shard.shardingNo) - } - }) - loadNext() } else { - loadNext() + this.shardupload(param) } }) } - chunkFileReader.onload = (e) => { - spark.append(e.target.result) // 瀵规瘡涓�鐗囧垎鐗囪繘琛宮d5鍔犲瘑 - - params.chunks[params.chunks.length - 1].chunkMd5 = spark.end() // 娣诲姞鍒囩墖md5 - - currentChunk++ // 姣忎竴娆″垎鐗噊nload,currentChunk閮介渶瑕佸鍔狅紝浠ヤ究鏉ヨ绠楀垎鐗囩殑娆℃暟 - - if (currentChunk < chunks) { // 褰撳墠鍒囩墖鎬绘暟娌℃湁杈惧埌鎬绘暟鏃� - loadNext() - } else { - this.shardupload(params) - } - } - - chunkFileReader.onerror = () => { - this.onFail('鏂囦欢璇诲彇澶辫触锛�') - } totalFileReader.onerror = () => { this.onFail('鏂囦欢璇诲彇澶辫触锛�') - } - - let loadNext = () => { - let start = currentChunk * chunkSize // 璁$畻鍒嗙墖鐨勮捣濮嬩綅缃� - let end = Math.min(file.size, start + chunkSize) // 璁$畻鍒嗙墖鐨勭粨鏉熶綅缃� - - let obj = { // 姣忎竴涓垎鐗囬渶瑕佸寘鍚殑淇℃伅 - chunk: currentChunk + 1, - binary: file.slice(start, end), - start: start, - end: end, - chunks - } - - params.chunks.push(obj) - chunkFileReader.readAsArrayBuffer(blobSlice.call(file, start, end)) } return false diff --git a/src/tabviews/zshare/fileupload/index.scss b/src/tabviews/zshare/fileupload/index.scss index 4f0cf99..86f8505 100644 --- a/src/tabviews/zshare/fileupload/index.scss +++ b/src/tabviews/zshare/fileupload/index.scss @@ -14,12 +14,12 @@ width: 90px; height: 90px; } - .ant-upload-list-picture-card .ant-upload-list-item-undefined { - border-color: #f5222d; - .ant-upload-list-item-name { - color: #f5222d; - } - } + // .ant-upload-list-picture-card .ant-upload-list-item-undefined { + // border-color: #f5222d; + // .ant-upload-list-item-name { + // color: #f5222d; + // } + // } .ant-upload-list-picture-card .ant-upload-list-item { width: 90px; height: 90px; diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index a5e2a61..f81c734 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -1405,7 +1405,7 @@ precision: 0, label: '姣斾緥', initVal: card.ratio || 85, - tooltip: '灏忎簬100涓哄搴︼紙鎴栭珮搴︼級鐧惧垎姣旓紝澶т簬100涓哄儚绱犲�笺��', + tooltip: '妯℃�佹鎴栨娊灞夌殑瀹藉害锛屽皬浜�100涓虹獥鍙e搴︼紙鎴栭珮搴︼級鐧惧垎姣旓紝澶т簬100涓哄儚绱犲�笺��', required: true }, { diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index 0d109b5..eafbca4 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -85,6 +85,91 @@ } /** + * @description 鑾峰彇涓嬬骇妯″潡 + * @return {String} selfId 褰撳墠缁勪欢id + */ + static getAnchors (components, selfId) { + let modules = components.map(item => { + if (item.uuid === selfId) { + return { + children: null + } + } else if (item.type === 'tabs') { + let _item = { + type: 'tabs', + value: item.uuid, + label: item.name, + children: item.subtabs.map(f_tab => { + let subItem = { + type: 'tab', + value: f_tab.uuid, + label: f_tab.label, + children: this.getSubModules(f_tab.components, selfId) + } + + if (!subItem.children || subItem.children.length === 0) { + return {children: null} + } + return subItem + }) + } + + _item.children = _item.children.filter(t => t.children !== null) + + if (_item.children.length === 0) { + return {children: null} + } + + return _item + } else if (item.type === 'group') { + let _item = { + value: item.uuid, + label: item.name, + children: item.components.map(f_tab => { + if (f_tab.uuid === selfId) { + return { + children: null + } + } else if (f_tab.format) { + return { + value: f_tab.uuid, + label: f_tab.name + } + } + return { + children: null + } + }) + } + + _item.children = _item.children.filter(t => t.children !== null) + + if (_item.children.length === 0) { + return {children: null} + } + + return _item + } else if (!['login', 'navbar', 'topbar', 'tabs', 'search', 'group', 'balcony'].includes(item.type)) { // 鏁版嵁鏍煎紡锛屽瓨鍦ㄦ暟鎹簮 + return { + value: item.uuid, + label: item.name + } + } else { + return { + children: null + } + } + }) + + modules = modules.filter(mod => mod.children !== null) + + if (modules.length === 0) { + return null + } + return modules + } + + /** * @description 鑾峰彇涓婄骇妯″潡 * @return {String} selfId 褰撳墠缁勪欢id */ -- Gitblit v1.8.0