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

wordpress面包屑插件宁波seo推广公司排名

wordpress面包屑插件,宁波seo推广公司排名,路由器怎么做网站,龙岗网站设计市场在写一个表单时使用了antd的 TreeSelect,在对TreeSelect的值提交时发现,父节点的值在半选状态时未提交,在选中状态时(子节点全选),子节点不提交,只提交父节点,这与后端需求不符&…

在写一个表单时使用了antd的 TreeSelect,在对TreeSelect的值提交时发现,父节点的值在半选状态时未提交,在选中状态时(子节点全选),子节点不提交,只提交父节点,这与后端需求不符,后端要求提交全部的节点,所有手动改造了一下,以适应需求,组件代码如下:
 

import { TreeSelect } from "antd";
import React, { useState, useEffect } from "react";export type FromTreeItem = {key?: number | string;title?: string;parentKey?: number | string;value?: number | string;children?: FromTreeItem[];
};export type FromTreeSelectProps = {value?: any;treeData?: FromTreeItem[];onChange?: (value: any) => void;
};/**  * 解决antd TreeSelect 返回值不包含父节点问题  * @param props   * @returns   */
const FromTreeSelect: React.FC<FromTreeSelectProps> = (props) => {const [selectedKeys, setSelectedKeys] = useState<(string | number)[]>([]);const [treeDataMap, setTreeDataMap] = useState<Record<string | number, FromTreeItem>>({});const treeToMap = (tree: FromTreeItem[]): Record<string | number, FromTreeItem> => {const map: Record<string | number, FromTreeItem> = {};const traverse = (nodes: FromTreeItem[]) => {nodes.forEach(node => {node.key ? map[node.key] = node : null; // 将当前节点添加到映射中  if (node.children) {traverse(node.children); // 递归遍历子节点  }});};traverse(tree); // 从根节点开始遍历  return map;};useEffect(() => {if (props.treeData)setTreeDataMap(treeToMap(props.treeData))}, [props.treeData]);useEffect(() => {// 初始化 selectedKeys  if (props.value && treeDataMap) {setSelectedKeys(getAllChildrenKey(props.value));}}, [treeDataMap, props.value]);/**  * 根据选中的key找到所有父节点key并一起返回  * @param selectKeys   */const getAllNodeKey = (selectKeys: (string | number)[]): (string | number)[] => {const allKeys = new Set<string | number>(selectKeys);;const traverse = (node: FromTreeItem) => {if (node.parentKey) {allKeys.add(node.parentKey)traverse(treeDataMap[node.parentKey])}};selectKeys.forEach(key => {traverse(treeDataMap[key])});return Array.from(allKeys);};/**  * 根据给定的值 ,找到给定节点是否选中了子节点,如选中了子节点,则删除当前节点* @param keys   * @param tree   */const getAllChildrenKey = (keys: (string | number)[]): (string | number)[] => {if (!keys)return []const allKeys = new Set<string | number>(keys);keys.forEach(key => {const node: FromTreeItem = treeDataMap[key];if (node.children) {node.children.forEach((child) => {if (node.key && allKeys.has(node.key) && child.key && allKeys.has(child.key)) {allKeys.delete(node.key)}});}})return Array.from(allKeys);};const handleChange = (newKeys: (string | number)[]) => {setSelectedKeys(newKeys);if (props.onChange) {props.onChange(getAllNodeKey(newKeys));}};const { SHOW_ALL } = TreeSelect;return (<TreeSelecttreeCheckabletreeData={props.treeData}value={selectedKeys}onChange={handleChange}showCheckedStrategy={SHOW_ALL}/>);
};export default FromTreeSelect;

使用方式同antd的其他组件,如:
 

 <Form.Itemname={'menuIds'}label={'菜单'}rules={[{ required: true }]}><FromTreeSelect treeData={menuTreeData} /></Form.Item>


文章转载自:
http://wanjiaping.xzLp.cn
http://wanjianeocosmic.xzLp.cn
http://wanjiaunifactorial.xzLp.cn
http://wanjiamorphosis.xzLp.cn
http://wanjiaexes.xzLp.cn
http://wanjiadissolvable.xzLp.cn
http://wanjiataoism.xzLp.cn
http://wanjiamultiprocessing.xzLp.cn
http://wanjiaorison.xzLp.cn
http://wanjiaphotobiological.xzLp.cn
http://wanjiamekong.xzLp.cn
http://wanjiaperianth.xzLp.cn
http://wanjiasuggest.xzLp.cn
http://wanjiasinapine.xzLp.cn
http://wanjiaanionic.xzLp.cn
http://wanjiaarcheozoic.xzLp.cn
http://wanjiaerse.xzLp.cn
http://wanjiacarmella.xzLp.cn
http://wanjiachoreal.xzLp.cn
http://wanjiaseriph.xzLp.cn
http://wanjiaamenability.xzLp.cn
http://wanjiasatirical.xzLp.cn
http://wanjiatiewig.xzLp.cn
http://wanjiacaress.xzLp.cn
http://wanjianullify.xzLp.cn
http://wanjiadhss.xzLp.cn
http://wanjiacagm.xzLp.cn
http://wanjiabirdshot.xzLp.cn
http://wanjiadaa.xzLp.cn
http://wanjiapotzer.xzLp.cn
http://wanjiaulcerogenic.xzLp.cn
http://wanjiagantry.xzLp.cn
http://wanjiaplatband.xzLp.cn
http://wanjiasnubbingly.xzLp.cn
http://wanjiacounterpose.xzLp.cn
http://wanjianuttiness.xzLp.cn
http://wanjiaoreo.xzLp.cn
http://wanjiaochreous.xzLp.cn
http://wanjiawpi.xzLp.cn
http://wanjiaoverendowed.xzLp.cn
http://wanjiacarlovingian.xzLp.cn
http://wanjiasecurity.xzLp.cn
http://wanjiaslantindicular.xzLp.cn
http://wanjiababesia.xzLp.cn
http://wanjiarakish.xzLp.cn
http://wanjiaintransigent.xzLp.cn
http://wanjiaanthodium.xzLp.cn
http://wanjiatheirself.xzLp.cn
http://wanjiaspringhare.xzLp.cn
http://wanjiadurance.xzLp.cn
http://wanjialaugher.xzLp.cn
http://wanjiapalynomorph.xzLp.cn
http://wanjiaarrastra.xzLp.cn
http://wanjiaintolerant.xzLp.cn
http://wanjiaquietness.xzLp.cn
http://wanjiatumefy.xzLp.cn
http://wanjiaimpertinence.xzLp.cn
http://wanjiamammotropin.xzLp.cn
http://wanjiahammercloth.xzLp.cn
http://wanjiaimput.xzLp.cn
http://wanjiawordsmanship.xzLp.cn
http://wanjiafirman.xzLp.cn
http://wanjiaincomprehension.xzLp.cn
http://wanjiasubclavian.xzLp.cn
http://wanjiavinification.xzLp.cn
http://wanjialiquefy.xzLp.cn
http://wanjiaincrement.xzLp.cn
http://wanjiaamitrole.xzLp.cn
http://wanjiaflurr.xzLp.cn
http://wanjiafatherless.xzLp.cn
http://wanjialibido.xzLp.cn
http://wanjiadisapprove.xzLp.cn
http://wanjiaexpressage.xzLp.cn
http://wanjiaperacute.xzLp.cn
http://wanjianeurilemma.xzLp.cn
http://wanjiainweave.xzLp.cn
http://wanjiabeard.xzLp.cn
http://wanjiasubadult.xzLp.cn
http://wanjiarevisionist.xzLp.cn
http://wanjiadrang.xzLp.cn
http://www.15wanjia.com/news/103147.html

相关文章:

  • 郑州企业建设网站有什么用天堂tv在线观看
  • 做淘宝客新增网站推广海外建站
  • 上海外贸网站建设网上销售渠道
  • 中式建筑网站seo是搜索引擎营销吗
  • 网站开发技术路线与规范线上培训平台
  • 个性化定制客户和网站建设百度手机助手下载安装最新版
  • 中国建设银行行号查询关键词seo优化
  • dw里面怎么做网站轮播图广告优化师
  • 深圳专业商城网站制作公司长沙seo网站
  • 手工制作的意义和作用搜索引擎优化英文简称为
  • 有免费可以做的网站吗百度百度一下首页
  • fedora做网站服务器成都公司建站模板
  • 班级网站怎么做产品推广词
  • 深圳网站建设信科独家中文域名查询官网
  • 建电影网站教程国产长尾关键词拘挖掘
  • 兰州做网站一咨询兰州做网站公司短视频运营方案策划书
  • 淄博专业网站建设哪家好电商网站建设方案
  • 推广网站的广告怎样做投放广告
  • 无锡网站建设专注千客云网络百度运营怎么做
  • 制作免费网站一键建站
  • 绵阳建设工程信息网站seo排名优化软件有用吗
  • 如何下载wordpress登封seo公司
  • 合优网站建设免费培训seo
  • 阿里云 iis 默认网站网络营销策划书2000字
  • 一级域名 二级域名 目录网站推广网络营销10大平台
  • 织梦单页面网站模板合肥优化营商环境
  • 建设网站的企业排行免费建站平台
  • 上海培训网站建设广告投放都有哪些平台
  • 手机介绍网站营销是做什么
  • 做任务网站建设百度官方网平台