Commit 5200b500530571f94a1dfd029224b0d02828111c
1 parent
ae19d4e5
优化快速报价盒型选择;
Showing
2 changed files
with
265 additions
and
39 deletions
src/components/QuickQuote/index.jsx
| 1 | /* eslint-disable */ | 1 | /* eslint-disable */ |
| 2 | -import React, { useRef, useEffect, useState, useCallback } from "react"; | ||
| 3 | -import { Button, Divider, Tabs, Tree, Radio, Image, Modal, Input, message } from "antd-v4"; | 2 | +import { useRef, useEffect, useState, useCallback, useMemo } from "react"; |
| 3 | +import { Button, Divider, Tabs, Tree, Radio, Image, Modal, Input, message, Badge } from "antd-v4"; | ||
| 4 | import { ArrowLeftOutlined, FolderFilled, FolderOpenFilled, FileTextFilled, PlusOutlined, MinusOutlined } from "@ant-design/icons"; | 4 | import { ArrowLeftOutlined, FolderFilled, FolderOpenFilled, FileTextFilled, PlusOutlined, MinusOutlined } from "@ant-design/icons"; |
| 5 | import { cloneDeep } from "lodash"; | 5 | import { cloneDeep } from "lodash"; |
| 6 | import commonConfig from "@/utils/config"; | 6 | import commonConfig from "@/utils/config"; |
| @@ -11,6 +11,7 @@ import * as commonBusiness from "@/components/Common/commonBusiness"; | @@ -11,6 +11,7 @@ import * as commonBusiness from "@/components/Common/commonBusiness"; | ||
| 11 | import CommonViewTable from "@/components/Common/CommonViewTable"; | 11 | import CommonViewTable from "@/components/Common/CommonViewTable"; |
| 12 | import StaticEditTable from "@/components/Common/CommonTable"; | 12 | import StaticEditTable from "@/components/Common/CommonTable"; |
| 13 | import ShowImgM from "@/components/Common/BoxShowImgMaterial/indexNew"; | 13 | import ShowImgM from "@/components/Common/BoxShowImgMaterial/indexNew"; |
| 14 | +import AntdDraggableModal from "@/components/Common/AntdDraggableModal"; | ||
| 14 | import styles from "./index.less"; | 15 | import styles from "./index.less"; |
| 15 | import Typesetting from "@/components/Common/Typesetting/typesetting"; | 16 | import Typesetting from "@/components/Common/Typesetting/typesetting"; |
| 16 | import DynamicSVG from "@/components/Common/BoxDesignCompontent/svg"; | 17 | import DynamicSVG from "@/components/Common/BoxDesignCompontent/svg"; |
| @@ -188,6 +189,7 @@ const QuickQuoteEvent = props => { | @@ -188,6 +189,7 @@ const QuickQuoteEvent = props => { | ||
| 188 | } else if (name.includes("slave")) { | 189 | } else if (name.includes("slave")) { |
| 189 | const boxModel = name.replace("slaveUp", "").replace("slaveDown", ""); | 190 | const boxModel = name.replace("slaveUp", "").replace("slaveDown", ""); |
| 190 | if (sFieldName === "sName") { | 191 | if (sFieldName === "sName") { |
| 192 | + if (!changeValue.sName) return; | ||
| 191 | const dropDownDataSelected = dropDownData.find(item => item.sName === changeValue.sName); | 193 | const dropDownDataSelected = dropDownData.find(item => item.sName === changeValue.sName); |
| 192 | const { sColumnNameConfig, sColumnNameConfigExclusion, sColumnNameConfigPic } = dropDownDataSelected; | 194 | const { sColumnNameConfig, sColumnNameConfigExclusion, sColumnNameConfigPic } = dropDownDataSelected; |
| 193 | const upAbleConfigsExtra = commonUtils.convertStrToObj(sColumnNameConfig, []).map(item => ({ | 195 | const upAbleConfigsExtra = commonUtils.convertStrToObj(sColumnNameConfig, []).map(item => ({ |
| @@ -885,6 +887,13 @@ const QuickQuoteEvent = props => { | @@ -885,6 +887,13 @@ const QuickQuoteEvent = props => { | ||
| 885 | props.onAdd(); | 887 | props.onAdd(); |
| 886 | }; | 888 | }; |
| 887 | 889 | ||
| 890 | + // 选择盒型弹窗 | ||
| 891 | + addState.onFieldPopupModal = (showConfig, name) => { | ||
| 892 | + if (showConfig.sName === "sName") { | ||
| 893 | + props.onSaveState({ boxModelSelectedModalVisible: true, currentBoxModel: name }); | ||
| 894 | + } | ||
| 895 | + }; | ||
| 896 | + | ||
| 888 | return { | 897 | return { |
| 889 | ...props, | 898 | ...props, |
| 890 | onDataChange0: props.onDataChange, | 899 | onDataChange0: props.onDataChange, |
| @@ -930,6 +939,7 @@ const QuickQuote = baseProps => { | @@ -930,6 +939,7 @@ const QuickQuote = baseProps => { | ||
| 930 | <ContentComponent {...props} /> | 939 | <ContentComponent {...props} /> |
| 931 | </div> | 940 | </div> |
| 932 | </div> | 941 | </div> |
| 942 | + <BoxModelSelectedModal {...props} /> | ||
| 933 | </div> | 943 | </div> |
| 934 | ); | 944 | ); |
| 935 | }; | 945 | }; |
| @@ -2019,4 +2029,175 @@ const ManyComponent = props => { | @@ -2019,4 +2029,175 @@ const ManyComponent = props => { | ||
| 2019 | ); | 2029 | ); |
| 2020 | }; | 2030 | }; |
| 2021 | 2031 | ||
| 2032 | +// 选择盒型弹窗 | ||
| 2033 | +const BoxModelSelectedModal = props => { | ||
| 2034 | + const { boxModelSelectedModalVisible } = props; | ||
| 2035 | + if (!boxModelSelectedModalVisible) return ""; | ||
| 2036 | + | ||
| 2037 | + const onCancel = () => { | ||
| 2038 | + props.onSaveState({ | ||
| 2039 | + boxModelSelectedModalVisible: false, | ||
| 2040 | + }); | ||
| 2041 | + }; | ||
| 2042 | + | ||
| 2043 | + const [boxConfig, setBoxConfig] = useState({ gdsconfigformslave: [] }); | ||
| 2044 | + const [boxColumn, setBoxColumn] = useState([]); | ||
| 2045 | + const [boxTypeList, setBoxTypeList] = useState([]); | ||
| 2046 | + const [boxData, setBoxData] = useState([]); | ||
| 2047 | + const [treeClassName, setTreeClassName] = useState(""); | ||
| 2048 | + const [boxTypeSelected, setBoxTypeSelected] = useState("全部"); | ||
| 2049 | + | ||
| 2050 | + useEffect(() => { | ||
| 2051 | + const boxList = [ | ||
| 2052 | + ["sId", "唯一ID"], | ||
| 2053 | + ["iOrder", "#", 60], | ||
| 2054 | + // ["sBoxId", "盒型ID"], | ||
| 2055 | + ["sName", "名称", 119], | ||
| 2056 | + ["sPackDetailPath", "刀线图", 300], | ||
| 2057 | + ["sPackPath", "3D图", 300], | ||
| 2058 | + ["operation", "操作", 80], | ||
| 2059 | + ]; | ||
| 2060 | + | ||
| 2061 | + const config = { | ||
| 2062 | + sId: commonUtils.createSid(), | ||
| 2063 | + // bisMutiSelect: true, | ||
| 2064 | + gdsconfigformslave: boxList.map(item => ({ | ||
| 2065 | + sId: commonUtils.createSid(), | ||
| 2066 | + sName: item[0], | ||
| 2067 | + showName: item[1], | ||
| 2068 | + iFitWidth: item[2] || 120, | ||
| 2069 | + bVisible: item[0] !== "sId", | ||
| 2070 | + })), | ||
| 2071 | + }; | ||
| 2072 | + setBoxConfig(config); | ||
| 2073 | + const column = commonFunc.getHeaderConfig(config); | ||
| 2074 | + setBoxColumn(column); | ||
| 2075 | + | ||
| 2076 | + const getSqlDropDownData = async ({ sId }, cb) => { | ||
| 2077 | + const url = `${commonConfig.server_host}business/getSelectLimit/${sId}`; | ||
| 2078 | + const body = { | ||
| 2079 | + sKeyUpFilterName: "", | ||
| 2080 | + pageNum: 1, | ||
| 2081 | + pageSize: 1000, | ||
| 2082 | + }; | ||
| 2083 | + const retrunData = await commonServices.postValueService(props.app.token, body, url); | ||
| 2084 | + const dropDownData = retrunData.data?.dataset?.rows; | ||
| 2085 | + cb(dropDownData); | ||
| 2086 | + }; | ||
| 2087 | + | ||
| 2088 | + getSqlDropDownData({ sId: "17428091410008594700322758474000" }, dropDownData => { | ||
| 2089 | + const boxTypeList = Array.from(new Set(dropDownData.map(item => item.sBoxType || "其它"))); | ||
| 2090 | + setBoxTypeList(boxTypeList); | ||
| 2091 | + setBoxData( | ||
| 2092 | + dropDownData.map((item, index) => ({ | ||
| 2093 | + ...item, | ||
| 2094 | + iOrder: index + 1, | ||
| 2095 | + })) | ||
| 2096 | + ); | ||
| 2097 | + }); | ||
| 2098 | + }, []); | ||
| 2099 | + | ||
| 2100 | + const renderTreeNodes = useMemo( | ||
| 2101 | + () => | ||
| 2102 | + ["全部", ...boxTypeList].map(boxType => ( | ||
| 2103 | + <Tree.TreeNode | ||
| 2104 | + title={ | ||
| 2105 | + <Badge | ||
| 2106 | + count={boxType === "全部" ? boxData.length : boxData.filter(item => (item.sBoxType || "其它") === boxType).length} | ||
| 2107 | + offset={[20, 8]} | ||
| 2108 | + color="#faad14" | ||
| 2109 | + > | ||
| 2110 | + <span>{boxType}</span> | ||
| 2111 | + </Badge> | ||
| 2112 | + } | ||
| 2113 | + key={boxType === "全部" ? 0 : commonUtils.createSid()} | ||
| 2114 | + treeData={boxType} | ||
| 2115 | + switcherIcon={<FolderFilled style={{ color: "#f7cc4f", fontSize: 20 }} />} | ||
| 2116 | + ></Tree.TreeNode> | ||
| 2117 | + )), | ||
| 2118 | + [boxTypeList.length] | ||
| 2119 | + ); | ||
| 2120 | + | ||
| 2121 | + const tableProps = { | ||
| 2122 | + ...commonBusiness.getTableTypes("box", { | ||
| 2123 | + ...props, | ||
| 2124 | + boxData: boxData.filter(item => (boxTypeSelected === "全部" ? true : (item.sBoxType || "其它") === boxTypeSelected)), | ||
| 2125 | + boxConfig, | ||
| 2126 | + boxColumn, | ||
| 2127 | + }), | ||
| 2128 | + enabled: false, | ||
| 2129 | + fixedHeight: "calc(100vh - 365px)", | ||
| 2130 | + noVlistTable: true, | ||
| 2131 | + onCostomColums: columns => { | ||
| 2132 | + columns | ||
| 2133 | + .filter(item => item.dataIndex?.includes("Path")) | ||
| 2134 | + .forEach(column => { | ||
| 2135 | + column.render = (value, record, index) => (value ? <img src={value} alt="" width={270} height={270} /> : "暂无图片"); | ||
| 2136 | + }); | ||
| 2137 | + | ||
| 2138 | + columns | ||
| 2139 | + .filter(item => item.dataIndex === "operation") | ||
| 2140 | + .forEach(column => { | ||
| 2141 | + column.fixed = "right"; | ||
| 2142 | + column.render = (value, record, index) => ( | ||
| 2143 | + <Button | ||
| 2144 | + style={{ marginLeft: 8 }} | ||
| 2145 | + onClick={() => { | ||
| 2146 | + props.onDataChange(props.currentBoxModel, "sName", { sName: record.sName }, record.sId, boxData); | ||
| 2147 | + props.onSaveState({ | ||
| 2148 | + boxModelSelectedModalVisible: false, | ||
| 2149 | + }); | ||
| 2150 | + }} | ||
| 2151 | + > | ||
| 2152 | + 选择 | ||
| 2153 | + </Button> | ||
| 2154 | + ); | ||
| 2155 | + }); | ||
| 2156 | + }, | ||
| 2157 | + }; | ||
| 2158 | + | ||
| 2159 | + return ( | ||
| 2160 | + <AntdDraggableModal | ||
| 2161 | + width="min(calc(100vw - 350px), 1100px)" | ||
| 2162 | + title="盒型选择" | ||
| 2163 | + visible={boxModelSelectedModalVisible} | ||
| 2164 | + onCancel={onCancel} | ||
| 2165 | + footer={ | ||
| 2166 | + <Button type="primary" onClick={onCancel}> | ||
| 2167 | + 关闭 | ||
| 2168 | + </Button> | ||
| 2169 | + } | ||
| 2170 | + > | ||
| 2171 | + <div className={styles.boxModal}> | ||
| 2172 | + <div | ||
| 2173 | + className={`${styles.boxTree} ${treeClassName}`} | ||
| 2174 | + onMouseEnter={() => { | ||
| 2175 | + setTreeClassName(styles.overFlow); | ||
| 2176 | + }} | ||
| 2177 | + onMouseLeave={() => { | ||
| 2178 | + setTreeClassName(""); | ||
| 2179 | + }} | ||
| 2180 | + > | ||
| 2181 | + {boxTypeList.length && ( | ||
| 2182 | + <Tree | ||
| 2183 | + className={"hide-file-icon"} | ||
| 2184 | + defaultExpandAll={true} | ||
| 2185 | + defaultSelectedKeys={["0"]} | ||
| 2186 | + onSelect={(e, select) => { | ||
| 2187 | + const { treeData } = select.node; | ||
| 2188 | + setBoxTypeSelected(treeData); | ||
| 2189 | + }} | ||
| 2190 | + > | ||
| 2191 | + {renderTreeNodes} | ||
| 2192 | + </Tree> | ||
| 2193 | + )} | ||
| 2194 | + </div> | ||
| 2195 | + <div className={styles.boxTable} key={boxTypeSelected}> | ||
| 2196 | + <StaticEditTable {...tableProps} /> | ||
| 2197 | + </div> | ||
| 2198 | + </div> | ||
| 2199 | + </AntdDraggableModal> | ||
| 2200 | + ); | ||
| 2201 | +}; | ||
| 2202 | + | ||
| 2022 | export default QuickQuote; | 2203 | export default QuickQuote; |
src/components/QuickQuote/index.less
| @@ -13,6 +13,10 @@ | @@ -13,6 +13,10 @@ | ||
| 13 | .ant-btn-primary { | 13 | .ant-btn-primary { |
| 14 | border-radius: 5px; | 14 | border-radius: 5px; |
| 15 | } | 15 | } |
| 16 | + | ||
| 17 | + .ant-col-23 { | ||
| 18 | + display: flex !important; | ||
| 19 | + } | ||
| 16 | } | 20 | } |
| 17 | 21 | ||
| 18 | .back { | 22 | .back { |
| @@ -24,43 +28,6 @@ | @@ -24,43 +28,6 @@ | ||
| 24 | border-right-width: 0; | 28 | border-right-width: 0; |
| 25 | } | 29 | } |
| 26 | 30 | ||
| 27 | - .leftTree { | ||
| 28 | - width: 250px; | ||
| 29 | - height: 100%; | ||
| 30 | - background: #3274b7; | ||
| 31 | - padding: 10px 0 0 10px; | ||
| 32 | - overflow: hidden; | ||
| 33 | - | ||
| 34 | - :global { | ||
| 35 | - .ant-tree { | ||
| 36 | - background: transparent; | ||
| 37 | - | ||
| 38 | - .ant-tree-treenode { | ||
| 39 | - padding-bottom: 10px; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - .ant-tree-title { | ||
| 43 | - color: #fff; | ||
| 44 | - font-size: 16px; | ||
| 45 | - font-weight: bold; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - .ant-tree-node-content-wrapper.ant-tree-node-selected { | ||
| 49 | - background-color: #00a183; | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - .ant-tree-node-content-wrapper:hover { | ||
| 53 | - background-color: #009688; | ||
| 54 | - } | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - } | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - .overFlow { | ||
| 61 | - overflow: auto; | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | .rightContent { | 31 | .rightContent { |
| 65 | flex: 1; | 32 | flex: 1; |
| 66 | background: #f8fafe; | 33 | background: #f8fafe; |
| @@ -368,4 +335,82 @@ | @@ -368,4 +335,82 @@ | ||
| 368 | } | 335 | } |
| 369 | } | 336 | } |
| 370 | } | 337 | } |
| 338 | +} | ||
| 339 | + | ||
| 340 | +.leftTree, | ||
| 341 | +.boxTree { | ||
| 342 | + width: 250px; | ||
| 343 | + height: 100%; | ||
| 344 | + background: #3274b7; | ||
| 345 | + padding: 10px 0 0 10px; | ||
| 346 | + overflow: hidden; | ||
| 347 | + | ||
| 348 | + :global { | ||
| 349 | + .ant-tree { | ||
| 350 | + background: transparent; | ||
| 351 | + | ||
| 352 | + .ant-tree-treenode { | ||
| 353 | + padding-bottom: 10px; | ||
| 354 | + } | ||
| 355 | + | ||
| 356 | + .ant-tree-title { | ||
| 357 | + color: #fff; | ||
| 358 | + font-size: 16px; | ||
| 359 | + font-weight: bold; | ||
| 360 | + } | ||
| 361 | + | ||
| 362 | + .ant-tree-node-content-wrapper.ant-tree-node-selected { | ||
| 363 | + background-color: #00a183; | ||
| 364 | + } | ||
| 365 | + | ||
| 366 | + .ant-tree-node-content-wrapper:hover { | ||
| 367 | + background-color: #009688; | ||
| 368 | + } | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + } | ||
| 372 | +} | ||
| 373 | + | ||
| 374 | +.boxTree { | ||
| 375 | + background: transparent; | ||
| 376 | + | ||
| 377 | + :global { | ||
| 378 | + .ant-tree { | ||
| 379 | + | ||
| 380 | + .ant-tree-title, | ||
| 381 | + .ant-badge { | ||
| 382 | + color: #5c6374; | ||
| 383 | + font-size: 16px; | ||
| 384 | + font-weight: bold; | ||
| 385 | + } | ||
| 386 | + | ||
| 387 | + .ant-tree-node-content-wrapper.ant-tree-node-selected { | ||
| 388 | + background-color: #bae7ff; | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + .ant-tree-node-content-wrapper:hover { | ||
| 392 | + background-color: #bae7ff; | ||
| 393 | + } | ||
| 394 | + } | ||
| 395 | + } | ||
| 396 | +} | ||
| 397 | + | ||
| 398 | +.overFlow { | ||
| 399 | + overflow: auto; | ||
| 400 | +} | ||
| 401 | + | ||
| 402 | +.boxModal { | ||
| 403 | + width: 100%; | ||
| 404 | + height: calc(100vh - 335px); | ||
| 405 | + display: flex; | ||
| 406 | + | ||
| 407 | + .boxTree { | ||
| 408 | + width: 200px; | ||
| 409 | + height: 100%; | ||
| 410 | + } | ||
| 411 | + | ||
| 412 | + .boxTable { | ||
| 413 | + width: calc(100% - 200px); | ||
| 414 | + height: 100%; | ||
| 415 | + } | ||
| 371 | } | 416 | } |
| 372 | \ No newline at end of file | 417 | \ No newline at end of file |