/* eslint-disable */ import React, { Component, useState, useEffect } from "react"; import CommonBase from "../../Common/CommonBase"; /* 获取配置及数据 */ import CommonSales from "../../Common/CommonBillEvent"; /* 继承销售模块业务功能 */ import * as commonFunc from "../../Common/commonFunc"; /* 通用单据方法 */ /* 通用单据方法 */ import { Form } from "@ant-design/compatible"; import { Spin, Tree, Select, Input } from "antd-v4"; import styles from "./index.less"; import { ArrowLeftOutlined, FolderFilled, FolderOpenFilled, FileTextFilled, PlusOutlined, MinusOutlined } from "@ant-design/icons"; import SvgBox from "./svg"; import img1 from "../../../assets/paiban1.png"; class BoxProject extends Component { constructor(props) { super(props); this.state = { boxList: [], }; } // 添加一个方法来更新 boxList updateBoxList = newBoxList => { this.setState({ boxList: newBoxList }); }; render() { const { pageLoading, masterData, fastOrderModalVisible } = this.props; const { boxList } = this.state; return ( ); } } const BoxProjectContent = Form.create({ mapPropsToFields(props) { const { masterData, masterConfig } = props; const obj = commonFunc.mapPropsToFields(masterData, Form, masterConfig); return obj; }, })(props => { const { updateBoxList, boxList } = props; // 获取父组件传递的更新方法 // 获取树形节点 const treeData = [ { title: "parent 1", key: "0-0", icon: , children: [ { title: "leaf", key: "0-0-0", icon: , }, { title: "leaf", key: "0-0-1", icon: ({ selected }) => (selected ? : ), }, ], }, ]; const options = [ { value: null, label: "", image: null }, { value: 0, label: "图片1", image: img1 }, { value: 1, label: "图片2", image: img1 }, // { value: 2, label: "图片3", image: img1 }, ]; // 生成盒型输入框数据并更新到父组件的 state useEffect( () => { let list = []; for (let index = 0; index < 9; index++) { const data = { isEditable: false, value: "", type: null, }; list.push(data); } updateBoxList(list); // 调用父组件的方法更新 boxList }, [updateBoxList] ); const handleFocus = (e, index) => { if (boxList && boxList.length) { const updatedBoxList = [...boxList]; updatedBoxList[index].isEditable = true; updateBoxList(updatedBoxList); } }; const handleBlur = (e, index) => { if (boxList && boxList.length) { const updatedBoxList = [...boxList]; updatedBoxList[index].isEditable = false; updateBoxList(updatedBoxList); } }; const handleChange = (e, index) => { const updatedBoxList = [...boxList]; updatedBoxList[index].value = e.target.value; updateBoxList(updatedBoxList); }; const handleSelect = (name, selectConfig, index) => { const updatedBoxList = [...boxList]; updatedBoxList[index].type = name; updateBoxList(updatedBoxList); }; const titleList = [ "上方盒舌", "盒底组件", "下方盒舌", "左(上)插位组件", "左贴边位", "左(下)插位组件", "右(上)插位组件", "右贴边位", "右(下)插位组件", ]; const svgProps = { ...props, boxList, showNew:0 }; // const renderTreeNodes = data => { // return data.map(item => { // const { showName, children = [], sId } = item; // const treeNodeProps = { // title: showName, // key: sId, // treeNode: item, // selectable: !children.length, // switcherIcon: params => { // const { expanded, isLeaf } = params; // let icon = ""; // if (isLeaf) { // icon = ; // } else if (expanded) { // icon = ; // } else { // icon = ; // } // return icon; // }, // }; // return {!!children.length && renderTreeNodes(children)}; // }); // }; return (
111
{ // props.setState(pre => ({ ...pre, selectedNode: select.selectedNodes[0]?.treeNode || {} })); }} // defaultSelectedKeys={[activeTree]} defaultExpandAll={true} selectedKeys={[1]} treeData={treeData} > {/* {renderTreeNodes(treeData)} */}
{/* 数值输入 */} {/* 上 */} {boxList && boxList.length ? (
{Array.from({ length: 3 }).map((_, index) => (
{titleList[index]}
参数:
handleChange(e, index)} onFocus={e => handleFocus(e, index)} onBlur={e => handleBlur(e, index)} readOnly={!boxList[index]?.isEditable} style={{ width: 180 }} />
))}
) : ( "" )} {/* 左 */} {boxList && boxList.length ? (
{Array.from({ length: 3 }, (_, i) => i + 3).map(index => (
{titleList[index]}
参数:
handleChange(e, index)} onFocus={e => handleFocus(e, index)} onBlur={e => handleBlur(e, index)} readOnly={!boxList[index]?.isEditable} style={{ width: 180 }} />
))}
) : ( "" )} {/* 右 */} {boxList && boxList.length ? (
{Array.from({ length: 3 }, (_, i) => i + 6).map(index => (
{titleList[index]}
参数:
handleChange(e, index)} onFocus={e => handleFocus(e, index)} onBlur={e => handleBlur(e, index)} readOnly={!boxList[index]?.isEditable} style={{ width: 180 }} />
))}
) : ( "" )}
); }); const SvgConten = props => { const [length, setLength] = useState(0); const [width, setWidth] = useState(0); const [height, setHeight] = useState(0); const handleChange = (e, index) => { if (index === 0) { setLength(e.target.value); } else if (index === 1) { setWidth(e.target.value); } else { setHeight(e.target.value); } }; const svgBoxProps = { ...props, boxSize:{ length, width, height } } return (
盒长 handleChange(e, 0)} />
盒宽 handleChange(e, 1)} />
盒高 handleChange(e, 2)} />
); }; export default CommonBase(CommonSales(BoxProject));