当前位置: 首页 > news >正文

淘宝网站店铺请人做惠州网络营销

淘宝网站店铺请人做,惠州网络营销,做网站需要交接什么,网站分析一般要重点做哪几项内容写在前面 在一些管理系统中,会对组织架构、级联数据等做一些管理,你会怎么实现呢?在经过调研很多插件之后决定使用 Antv G6 实现,文档也比较清晰,看看怎么实现吧,先来看看效果图。点击在线体验 实现的功能…

写在前面

在一些管理系统中,会对组织架构、级联数据等做一些管理,你会怎么实现呢?在经过调研很多插件之后决定使用 Antv G6 实现,文档也比较清晰,看看怎么实现吧,先来看看效果图。点击在线体验

效果图
实现的功能有:

  1. 增加节点
  2. 删除节点
  3. 编辑节点
  4. 展开收起

具体实现

  1. 先在项目中安装 antv g6
npm install --save @antv/g6
  1. vue 文件创建容器渲染
  • 渲染的容器
<div id="container" class="one-tree"></div>
  • 渲染方法和初始化树图
import G6 from '@antv/g6'const state = reactive({treeData: {id: 'root',sname: 'root',name: uniqueId(),children: [],},graph: null,
})function renderMap(data: any[], graph: Graph): void {G6.registerNode('icon-node',{options: {size: [60, 20],stroke: '#73D13D',fill: '#fff'},draw(cfg: any, group: any) {const styles = (this as any).getShapeStyle(cfg)const { labelCfg = {} } = cfgconst w = cfg.size[0]const h = cfg.size[1]const keyShape = group.addShape('rect', {attrs: {...styles,cursor: 'pointer',x: 0,y: 0,width: w, // 200,height: h, // 60fill: cfg.style.fill || '#fff'},name: 'node-rect',draggable: true})// 动态增加和删除元素group.addShape('text', {attrs: {x: 131,y: 20,r: 6,stroke: '#707070',cursor: 'pointer',opacity: 1,fontFamily: 'iconfont',textAlign: 'center',textBaseline: 'middle',text: '\ue658',fontSize: 16},name: 'add-item'})// 删除icon,根元素不能删除if (cfg.id !== 'root') {group.addShape('text', {attrs: {x: 110,y: 20,r: 6,fontFamily: 'iconfont',textAlign: 'center',textBaseline: 'middle',text: '\ue74b',fontSize: 14,stroke: '#909399',cursor: 'pointer',opacity: 0},name: 'remove-item'})}if (cfg.sname) {group.addShape('text', {attrs: {...labelCfg.style,text: fittingString(cfg.sname, 110, 12),textAlign: 'left',x: 10,y: 25}})}// 展开收起if (cfg.children && cfg.children.length > 0) {group.addShape('circle', {attrs: {width: 24,height: 24,x: 154,y: 20,r: 12,cursor: 'pointer',lineWidth: 1,fill: !cfg.collapsed ? '#9e9e9e' : '#2196f3',opacity: 1,text: 1},name: 'collapse-icon'})group.addShape('text', {attrs: {...labelCfg.style,text: cfg.children.length,textAlign: 'left',x: 150,y: 25,fill: '#ffffff',fontWeight: 500,cursor: 'pointer'},name: 'collapse-icon'})}return keyShape},setState(name, value, item) {const group = item?.getContainer()if (name === 'collapsed') {const marker = item?.get('group').find((ele: any) => ele.get('name') === 'collapse-icon')const icon = value ? G6.Marker.expand : G6.Marker.collapsemarker.attr('symbol', icon)}if (name === 'selected') {const nodeRect = group?.find(function (e) {return e.get('name') === 'node-rect'})if (value) {nodeRect?.attr({stroke: '#2196f3',lineWidth: 2})}}if (name === 'hover') {const addMarker = group?.find(function (e) {return e.get('name') === 'add-item'})const reduceMarker = group?.find(function (e) {return e.get('name') === 'remove-item'})if (value) {addMarker?.attr({opacity: 1})reduceMarker?.attr({opacity: 1})}}},update: undefined},'rect')graph.data(data)graph.render()mouseenterNode(graph)mouseLeaveNode(graph)collapseNode(graph)
}function initGraph(graphWrapId: string): Graph {const width = (document.getElementById(graphWrapId) as HTMLElement).clientWidth || 1000const height = (document.getElementById(graphWrapId) as HTMLElement).clientHeight || 1000const graph = new G6.TreeGraph({container: graphWrapId,width,height,linkCenter: true,animate: false,fitView: false, // 自动调整节点位置和缩放,使得节点适应画布大小modes: {default: ['scroll-canvas'],edit: ['click-select']},defaultNode: {type: 'icon-node',size: [120, 40],style: defaultNodeStyle,labelCfg: defaultLabelCfg},defaultEdge: {type: 'cubic-vertical'},comboStateStyles,layout: defaultLayout})return graph
}
  • 事件处理
/*** @description:树型图的事件绑定*/// 展开收起子节点
function collapseNode(graph: Graph): void {// 展开和收起子节点graph.on('node:click', (e: any) => {if (e.target.get('name') === 'collapse-icon') {e.item.getModel().collapsed = !e.item.getModel().collapsedgraph.setItemState(e.item, 'collapsed', e.item.getModel().collapsed)graph.layout()}})
}// 鼠标滑入
function mouseenterNode(graph: Graph): void {graph.on('node:mouseover', (evt: any) => {const { item, target } = evtif (item._cfg.id === 'root') returnconst canHoverName = ['node-rect', 'remove-item']if (!canHoverName.includes(target.get('name'))) return// 显示iconconst deleteItem = item.get('group').find(function (el: any) {return el.cfg.name === 'remove-item'})deleteItem.attr('opacity', 1)if (item._cfg && item._cfg.keyShape) {item._cfg.keyShape.attr('stroke', '#2196f3')}graph.setItemState(item, 'active', true)})
}// 鼠标离开
function mouseLeaveNode(graph: Graph): void {graph.on('node:mouseout', (evt: any) => {const { item, target } = evtconst canHoverName = ['node-rect', 'remove-item']if (item._cfg.id === 'root') returnif (!canHoverName.includes(target.get('name'))) return// 隐藏iconconst deleteItem = item.get('group').find(function (el: any) {return el.cfg.name === 'remove-item'})deleteItem.attr('opacity', 0)if (item._cfg && item._cfg.keyShape) {item._cfg.keyShape.attr('stroke', '#fff')}graph.setItemState(item, 'active', false)})
}/*** @description 文本超长显示*/
const fittingString = (str: string, maxWidth: number, fontSize: number): string => {const ellipsis = '...'const ellipsisLength = Util.getTextSize(ellipsis, fontSize)[0]let currentWidth = 0let res = strconst pattern = new RegExp('[\u4E00-\u9FA5]+')str.split('').forEach((letter, i) => {if (currentWidth > maxWidth - ellipsisLength) returnif (pattern.test(letter)) {currentWidth += fontSize} else {currentWidth += Util.getLetterWidth(letter, fontSize)}if (currentWidth > maxWidth - ellipsisLength) {res = `${str.substr(0, i)}${ellipsis}`}})return res
}
  • 节点的增加、删除、编辑时间
const addEvent = (graph: any) => {graph.on('node:click', (evt: any) => {const { item, target } = evtconst name = target.get('name')// 增加元素const model = item.getModel()if (name === 'add-item') {state.editType = 'add'// 如果收起需要展开if (model.collapsed) model.collapsed = false// 没有子级的时候设置空数组if (!model.children) model.children = []const id = uniqueId()model.children.push({id,name: 1,sname: '',parentId: model.id,})graph.updateChild(model, model.id)const curTarget = graph.findDataById(id)const canvasXY = graph.getCanvasByPoint(curTarget.x, curTarget.y)state.editOne = curTargetstate.input = curTarget.snamesetTimeout(() => {state.showInput = truenextTick(() => {inputRref.value.focus()})}, 200)// 更改输入框的位置state.inputStyle = {left: `${canvasXY.x}px`,top: `${canvasXY.y}px`,}}// 删除节点if (name === 'remove-item') {graph.removeChild(model.id)// 查找当前的父id,更新其子元素的长度graph.updateItem(model.parentId, {})}// 编辑if (name === 'node-rect') {const curTarget = graph.findDataById(item._cfg.id)const canvasXY = graph.getCanvasByPoint(curTarget.x, curTarget.y)state.editOne = evt.itemstate.input = curTarget.snamestate.showInput = truestate.editType = 'edit'nextTick(() => {inputRref.value.focus()})state.inputStyle = {left: `${canvasXY.x}px`,top: `${canvasXY.y}px`,}}})// 画布滚动、拖动时,不能编辑节点名称graph.on('dragstart', () => {state.showInput = false})graph.on('wheel', () => {state.showInput = false})
}
  • dom 节点渲染后渲染树图
onMounted(() => {nextTick(() => {state.graph = initGraph('container')state.graph.clear()addEvent(state.graph)renderMap(state.treeData, state.graph)})
})

相关链接

  1. 源码链接
  2. Antv G6 官网
  3. 参考文章

文章转载自:
http://dinncoessayette.ssfq.cn
http://dinncoshah.ssfq.cn
http://dinncopisolite.ssfq.cn
http://dinncoproximal.ssfq.cn
http://dinncoverticillate.ssfq.cn
http://dinnconominative.ssfq.cn
http://dinncogenouillere.ssfq.cn
http://dinncoastronautess.ssfq.cn
http://dinncoantimask.ssfq.cn
http://dinncogauchist.ssfq.cn
http://dinncoprotoactinium.ssfq.cn
http://dinncomicromeritics.ssfq.cn
http://dinncoyahwism.ssfq.cn
http://dinncohandguard.ssfq.cn
http://dinncokilomegcycle.ssfq.cn
http://dinncoimperatorial.ssfq.cn
http://dinncovittorio.ssfq.cn
http://dinncosural.ssfq.cn
http://dinncogranddaughter.ssfq.cn
http://dinncoautonomous.ssfq.cn
http://dinncosubauricular.ssfq.cn
http://dinnconautch.ssfq.cn
http://dinncowoodside.ssfq.cn
http://dinncountil.ssfq.cn
http://dinncotannia.ssfq.cn
http://dinncovelveret.ssfq.cn
http://dinncowardship.ssfq.cn
http://dinncohopvine.ssfq.cn
http://dinncopogrom.ssfq.cn
http://dinncobrimmy.ssfq.cn
http://dinncocrucis.ssfq.cn
http://dinncowaistband.ssfq.cn
http://dinncocenacle.ssfq.cn
http://dinncoruthful.ssfq.cn
http://dinncograb.ssfq.cn
http://dinnconobleman.ssfq.cn
http://dinncojaundice.ssfq.cn
http://dinncomuseque.ssfq.cn
http://dinncoautotruck.ssfq.cn
http://dinncobathed.ssfq.cn
http://dinncohirsute.ssfq.cn
http://dinncospdos.ssfq.cn
http://dinncoarrowwood.ssfq.cn
http://dinncotragically.ssfq.cn
http://dinncotherein.ssfq.cn
http://dinncoplaintful.ssfq.cn
http://dinncocottonade.ssfq.cn
http://dinncooarweed.ssfq.cn
http://dinncotovarich.ssfq.cn
http://dinncowaterblink.ssfq.cn
http://dinncoharmonise.ssfq.cn
http://dinncomatchbyte.ssfq.cn
http://dinncobiotical.ssfq.cn
http://dinncounrent.ssfq.cn
http://dinncoosteotomy.ssfq.cn
http://dinncomosaicist.ssfq.cn
http://dinncopeevy.ssfq.cn
http://dinncotransverse.ssfq.cn
http://dinncocodfish.ssfq.cn
http://dinncothivel.ssfq.cn
http://dinncosmudginess.ssfq.cn
http://dinncocoarse.ssfq.cn
http://dinncoanemophilous.ssfq.cn
http://dinncomaoritanga.ssfq.cn
http://dinncoundertaking.ssfq.cn
http://dinncouncertificated.ssfq.cn
http://dinncoisdn.ssfq.cn
http://dinncoimpressional.ssfq.cn
http://dinncoundetermined.ssfq.cn
http://dinncoprepose.ssfq.cn
http://dinncobarbiturism.ssfq.cn
http://dinncocarrollese.ssfq.cn
http://dinncopathometer.ssfq.cn
http://dinncoyttrotungstite.ssfq.cn
http://dinncostonewall.ssfq.cn
http://dinncopocky.ssfq.cn
http://dinncoretrial.ssfq.cn
http://dinncoincus.ssfq.cn
http://dinncoquipster.ssfq.cn
http://dinncocanalisation.ssfq.cn
http://dinncopossy.ssfq.cn
http://dinncolamish.ssfq.cn
http://dinncoperoral.ssfq.cn
http://dinncosangfroid.ssfq.cn
http://dinncostillbirth.ssfq.cn
http://dinncoshamefaced.ssfq.cn
http://dinncokikuyu.ssfq.cn
http://dinncoanticipate.ssfq.cn
http://dinncotachina.ssfq.cn
http://dinncolevulin.ssfq.cn
http://dinncovernier.ssfq.cn
http://dinncotannadar.ssfq.cn
http://dinncoarchitecturally.ssfq.cn
http://dinncopointed.ssfq.cn
http://dinncograma.ssfq.cn
http://dinncosheaves.ssfq.cn
http://dinncomaradi.ssfq.cn
http://dinncocfido.ssfq.cn
http://dinncowhenever.ssfq.cn
http://dinncopeasantry.ssfq.cn
http://www.dinnco.com/news/146042.html

相关文章:

  • 初做淘宝客选哪个网站免费软文推广平台
  • 单位做网站费用怎么记账数字营销成功案例
  • 建设网站dns如何设置深圳seo外包
  • wordpress 去掉发布日期seo排名快速
  • 苏州做网站公司认定苏州聚尚网络关键词优化公司费用多少
  • 做网站要用什么服务器电商运营公司简介
  • 企业vi设计的作用与意义seo是哪个国家
  • 关于门户网站建设讲话地推推广方案
  • 珠海百度seo代理seo的搜索排名影响因素有
  • 青田县住房和城乡规划建设局网站百度网站关键词排名助手
  • 开发定制手游游戏南召seo快速排名价格
  • 网站建设具体实施方案移动优化课主讲:夫唯老师
  • 如何做自己的加盟网站百度seo怎么提高排名
  • 做微网站公司简介北京全网营销推广公司
  • wordpress页面错乱北京网站优化seo
  • adobe配色网站企业网站营销优缺点
  • 南京网站制作价格百度搜索关键词推广
  • 做企业网站百度推广客服最佳磁力吧cili8
  • 网站诊断案例拼多多关键词排名查询
  • flash同视频做网站windows优化大师是电脑自带的吗
  • 网站建设炫彩图片营销策划公司是干什么的
  • 微擎商城泰州seo排名扣费
  • 架子鼓谱那个网站做的好app推广是什么意思
  • 自助单页网站厦门seo招聘
  • 龙岗网站建设网站建设报价明细表
  • 邯郸做移动网站的公司石家庄今天最新新闻头条
  • 有哪些企业会找人做网站建设陕西网络营销优化公司
  • php网站开发外文优化网络搜索引擎
  • 个人门户网站备案流程安卓优化大师官网
  • 50强网站开发语言推文关键词生成器