Commit 99a689db30eea31d4d6240e62b22dd4950c096d7

Authored by 邱嘉伟
1 parent 1142c2ad

fix:样式+部分逻辑更新

... ... @@ -99,6 +99,49 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
99 99 const [searchValue, setSearchValue] = useState('');
100 100 const [mExpandedKeys, setMExpandedKeys] = useState(expandedKeys);
101 101 const [isExpand, setIsExpand] = useState(true);
  102 + const fixedElement = document.getElementById('fixed-element');
  103 + const fixedElement1 = document.querySelector('.ant-table-header');
  104 + // 获取元素距离顶部的距离
  105 + const fixedElementTop =
  106 + fixedElement1?.offsetTop < 100
  107 + ? 205
  108 + : fixedElement1?.offsetTop > 205
  109 + ? 205
  110 + : fixedElement1?.offsetTop;
  111 + // 获取元素的高度
  112 + if (document.querySelector('.ant-modal-body')) {
  113 + document.querySelector('.ant-modal-body').addEventListener('scroll', () => {
  114 + // console.log('scrollTop', document.querySelector('.ant-modal-body').scrollTop)
  115 +
  116 + // 当页面滚动到固定位置时,将元素固定在指定位置
  117 + if (document.querySelector('.ant-modal-body').scrollTop > 0) {
  118 + if (!document.getElementById('mask')) {
  119 + const placeholder = document.createElement('div');
  120 + placeholder.id = 'mask';
  121 + placeholder.style.height = '90px';
  122 + fixedElement.parentNode.insertBefore(
  123 + placeholder,
  124 + fixedElement.nextSibling,
  125 + );
  126 + }
  127 + fixedElement.style.position = 'fixed';
  128 + fixedElement1.style.position = 'fixed';
  129 + fixedElement1.style.width = '1148px';
  130 + fixedElement1.style.zIndex = 19;
  131 + fixedElement1.style.top = `${fixedElementTop}px`;
  132 + } else {
  133 + if (!!document.getElementById('mask')) {
  134 + const mask = document.getElementById('mask');
  135 + mask.parentNode.removeChild(mask);
  136 + }
  137 + // 恢复元素的默认位置
  138 + fixedElement.style.position = 'relative';
  139 + fixedElement.style.top = 'auto';
  140 + fixedElement1.style.position = 'relative';
  141 + fixedElement1.style.top = 'auto';
  142 + }
  143 + });
  144 + }
102 145
103 146 // const [form] = Form.useForm()
104 147 //判断数组是否只有一个子节点
... ... @@ -156,28 +199,31 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
156 199 ),
157 200 dataIndex: 'code',
158 201 className: 'ps-table-cell-header',
159   - width: '190px',
  202 + width: '220px',
  203 + fixed: 'left',
160 204 key: 'code',
161 205 render: (text, record) => {
162 206 const strTitle = (text as string) || '';
163 207 const index = strTitle.indexOf(searchValue);
164 208 return (
165   - <Input
166   - style={{
167   - color: index > -1 && searchValue ? '#1890ff' : '',
168   - maxWidth: '110px',
169   - minWidth: '50px',
170   - }}
171   - draggable={true}
172   - onDragStart={(event) => {
173   - event.stopPropagation();
174   - event.preventDefault();
175   - }}
176   - defaultValue={record.code}
177   - bordered={false}
178   - disabled={record.disabled || typeDis}
179   - onBlur={(e) => handleChange(e, record, 'code')}
180   - />
  209 + <>
  210 + <Input
  211 + style={{
  212 + color: index > -1 && searchValue ? '#1890ff' : '',
  213 + maxWidth: '110px',
  214 + minWidth: '50px',
  215 + }}
  216 + draggable={true}
  217 + onDragStart={(event) => {
  218 + event.stopPropagation();
  219 + event.preventDefault();
  220 + }}
  221 + defaultValue={record.code}
  222 + bordered={false}
  223 + disabled={record.disabled || typeDis}
  224 + onBlur={(e) => handleChange(e, record, 'code')}
  225 + />
  226 + </>
181 227 );
182 228 },
183 229 },
... ... @@ -190,6 +236,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
190 236 ),
191 237 dataIndex: 'title',
192 238 width: '120px',
  239 + fixed: 'left',
193 240 className: 'ps-table-cell',
194 241 key: 'title',
195 242 render: (text, record) => {
... ... @@ -224,6 +271,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
224 271 key: 'type',
225 272 render: (text, record) => (
226 273 <Select
  274 + style={{ width: '100%' }}
227 275 bordered={false}
228 276 disabled={record.disabled || typeDis}
229 277 defaultValue={record.type}
... ... @@ -313,7 +361,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
313 361 dataIndex: 'description',
314 362 className: 'ps-table-cell',
315 363 key: 'description',
316   - width: '120px',
  364 + width: '122px',
317 365 render: (text, record) => (
318 366 <Input
319 367 draggable={true}
... ... @@ -338,6 +386,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
338 386 key: 'action',
339 387 className: 'ps-table-cell',
340 388 width: '110px',
  389 + fixed: 'right',
341 390 render: (text, record) => {
342 391 const isShowAdd = record && checkShowAdd(record);
343 392 const isShowTree = record && checkShowTree(record);
... ... @@ -594,8 +643,10 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
594 643 width: '86px',
595 644 render: (text, record) => (
596 645 <Select
  646 + style={{ width: '100%' }}
597 647 defaultValue={text || false}
598 648 bordered={false}
  649 + popupMatchSelectWidth
599 650 disabled={record.disabled || typeDis}
600 651 onSelect={(e) => props.handleChange(e, record, 'required')}
601 652 >
... ... @@ -615,6 +666,7 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
615 666
616 667 useEffect(() => {
617 668 if (visible) {
  669 + handleDrop(treeData);
618 670 if (data.length == 0) {
619 671 handleAdd('');
620 672 }
... ... @@ -623,11 +675,6 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
623 675
624 676 useEffect(() => {
625 677 setMExpandedKeys(expandedKeys);
626   - // if (visible) {
627   - // if (data.length == 0) {
628   - // handleAdd('');
629   - // }
630   - // }
631 678 }, [expandedKeys]);
632 679
633 680 useEffect(() => {
... ... @@ -865,7 +912,15 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
865 912 </Col>
866 913 </Row>
867 914 ) : (
868   - <Row>
  915 + <Row
  916 + id="fixed-element"
  917 + style={{
  918 + zIndex: 18,
  919 + backgroundColor: '#fff',
  920 + height: '50px',
  921 + width: '1148px',
  922 + }}
  923 + >
869 924 <Col span={12}>
870 925 <Button
871 926 size={'small'}
... ... @@ -953,14 +1008,21 @@ const ParameterModal: React.FC<ParameterSettingProps> = (props) => {
953 1008 />
954 1009 </>
955 1010 ) : record.disabled ? (
956   - <></>
  1011 + <span
  1012 + style={{ width: '14px', display: 'inline-flex' }}
  1013 + ></span>
957 1014 ) : (
958   - <Icon component={SubDropIcon} className="drop-icon" />
  1015 + <>
  1016 + <Icon component={SubDropIcon} className="drop-icon" />
  1017 + <span
  1018 + style={{ width: '14px', display: 'inline-flex' }}
  1019 + ></span>
  1020 + </>
959 1021 ),
960 1022 }}
961 1023 className="parameter-setting-table"
962 1024 onRow={onRow}
963   - scroll={{ y: 350 }}
  1025 + scroll={{ y: 850 }}
964 1026 bordered
965 1027 pagination={false}
966 1028 size={'small'}
... ...
... ... @@ -15,7 +15,6 @@ Demo:
15 15 import { QxParameterSetting, request } from '@qx/common';
16 16 import { Input } from 'antd';
17 17 import React, { useState } from 'react';
18   -import { node, nodes } from './mock-node';
19 18 export default () => {
20 19 const [value, setValue] = useState([
21 20 {
... ... @@ -185,11 +184,11 @@ export default () => {
185 184 // nodeItem={nodeItem}
186 185 // componentItem={componentItem}
187 186 onChange={handleChange}
188   - isHideSearch={isHide}
  187 + // isHideSearch={isHide}
189 188 isShowField={true}
190 189 // node={node}
191 190 // nodes={nodes}
192   - title={titleDom}
  191 + // title={titleDom}
193 192 // type={'preview'}
194 193 // component={QxTagsInput}
195 194 request={request}
... ...
... ... @@ -29,8 +29,8 @@ import { uidGen } from './stringUtil';
29 29
30 30 import './style.less';
31 31
32   -import { SubDropIcon, SubNodeIcon } from './sub-node-icon';
33 32 import { formatEnum } from '../constant';
  33 +import { SubDropIcon, SubNodeIcon } from './sub-node-icon';
34 34 const valueOptions = [
35 35 { key: 'STRING', label: '文本' },
36 36 { key: 'NUMBER', label: '数字' },
... ... @@ -214,7 +214,6 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
214 214
215 215 // @ts-ignore
216 216 const handleChange = (e?: any, data?: any, code?: string) => {
217   - console.log('handleChange');
218 217 let value,
219 218 oldValue,
220 219 _qxProps = {};
... ... @@ -239,7 +238,6 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
239 238 } else {
240 239 value = null;
241 240 }
242   - console.log('value', value);
243 241 }
244 242 if (code == 'type') {
245 243 if (data.child && data.child.length > 0) {
... ... @@ -255,7 +253,7 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
255 253 data.code = value;
256 254 const codeValid = validateCode(data);
257 255 if (!codeValid) {
258   - message.error('变量名不可重复');
  256 + message.error('参数编码不可重复');
259 257 return;
260 258 }
261 259 }
... ... @@ -538,6 +536,8 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
538 536 const onAddTree = (key: string) => {
539 537 const id = uidGen();
540 538 const code = uidGen(undefined, 6);
  539 + let level = [];
  540 + const treeList = generateList(treeData);
541 541
542 542 function addNode(pid: string, data: any) {
543 543 data.forEach((item) => {
... ... @@ -555,8 +555,27 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
555 555 });
556 556 return data;
557 557 }
  558 +
  559 + const loop = (pid: string) => {
  560 + if (!!pid) {
  561 + const index = treeList.findIndex((o: any) => o.id === pid);
  562 + level.push(treeList[index]);
  563 + loop(treeList[index].pid || '');
  564 + } else {
  565 + return level;
  566 + }
  567 + };
  568 +
  569 + loop(key);
558 570 const _treeData = JSON.parse(JSON.stringify(treeData));
559   - const _treeDataNew = addNode(key, _treeData);
  571 + let _treeDataNew = _treeData;
  572 + // console.log('level', level)
  573 + if (!!level && level.length < 6) {
  574 + _treeDataNew = addNode(key, _treeData);
  575 + } else if (!!level && level.length > 5) {
  576 + message.error('子级最多只能有5层');
  577 + return;
  578 + }
560 579 setInputKey(inputKey + 1);
561 580 setTreeData(_treeDataNew);
562 581 props?.onChange(_treeDataNew);
... ... @@ -610,7 +629,7 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
610 629 if (!val || isEmpty(val)) {
611 630 return;
612 631 }
613   - console.log('changeField', val);
  632 + // console.log('changeField', val);
614 633 const _newData = cloneDeep(treeData);
615 634 const loopChangeTree = (treeList: ParamDesignModel[]) => {
616 635 let newMappingValues = [],
... ... @@ -656,9 +675,9 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
656 675
657 676 // const test = document.getElementByClassName('ant-tree-node-content-wrapper')
658 677 // console.log('test', test)
659   - const treeLevel2 = !!nodeData.pid ? level.length : 0;
660   - const treeLevel = nodeData.child && nodeData.child.length > 0 ? 1 : 0;
661   - const leftD = 22 + treeLevel * 22 + treeLevel2 * 24;
  678 + const treeLevel2 = !!nodeData.pid ? level.length : 0; //判断是多少层的子级
  679 + const treeLevel = nodeData.child && nodeData.child.length > 0 ? 1 : 0; //判断是否有子级(是否有箭头)
  680 + const leftD = 22 + treeLevel * 22 + treeLevel2 * 20;
662 681 const strTitle = (nodeData.title as string) || '';
663 682 const index = strTitle.indexOf(searchValue);
664 683 const isShowTree = checkShowTree(nodeData);
... ... @@ -709,7 +728,9 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
709 728 onClick={() => onAddTree(nodeData.id)}
710 729 />
711 730 ) : (
712   - <div style={{ opacity: 0, height: 16, width: 16 }} />
  731 + <div
  732 + style={{ opacity: 0, height: 16, width: 22, marginLeft: 8 }}
  733 + />
713 734 )}
714 735 <Button
715 736 className="title-btn-del"
... ... @@ -823,7 +844,7 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
823 844 style={{ fontSize: '16px' }}
824 845 type={'qx-icon-plus'}
825 846 />
826   - 添加参数
  847 + <span style={{ marginInlineStart: '4px' }}>添加参数</span>
827 848 </Button>
828 849 </Dropdown>
829 850 )}
... ... @@ -841,7 +862,7 @@ export const QxParameterSetting: React.FC<ParameterSettingProps> = (props) => {
841 862 style={{ fontSize: '16px' }}
842 863 type={'icon-app-terminal-box-line'}
843 864 />
844   - 高级设置
  865 + <span style={{ marginInlineStart: '4px' }}>高级设置</span>
845 866 </Button>
846 867 </div>
847 868 {!props.isHideSearch && (
... ...
... ... @@ -36,7 +36,7 @@
36 36 width: 0;
37 37 margin-top: 11.5px;
38 38 display: flex;
39   - // justify-content: flex-end;
  39 + justify-content: center;
40 40 }
41 41
42 42 .ant-tree-switcher_open,
... ... @@ -45,7 +45,6 @@
45 45 margin-right: 10px;
46 46 margin-left: 10px;
47 47 display: flex;
48   - justify-content: flex-end;
49 48 }
50 49
51 50 .drop-icon {
... ... @@ -229,6 +228,8 @@
229 228 margin: 0;
230 229
231 230 .qx-field-setter {
  231 + border-color: #d9d9d9;
  232 +
232 233 .qx-tags-input {
233 234 background-color: #fff;
234 235 }
... ... @@ -253,9 +254,16 @@
253 254 flex-direction: row;
254 255 justify-content: flex-start;
255 256 flex-wrap: nowrap;
  257 + height: 30px;
256 258
257 259 .ant-btn-default {
258 260 border: 0;
  261 + background-color: transparent;
  262 + box-shadow: 0 0 0 0;
  263 + }
  264 +
  265 + .ant-input-number-handler-wrap {
  266 + background: transparent;
259 267 }
260 268
261 269 .range-cell {
... ... @@ -264,6 +272,12 @@
264 272 flex-wrap: nowrap;
265 273 flex-direction: row;
266 274 align-items: center;
  275 +
  276 + .ant-input-number {
  277 + align-items: center;
  278 + height: 100%;
  279 + display: flex;
  280 + }
267 281 }
268 282
269 283 .ant-input-affix-wrapper,
... ... @@ -278,6 +292,7 @@
278 292
279 293 .editable-cell-default {
280 294 overflow: auto;
  295 + height: 30px;
281 296 // overflow-x:hidden;
282 297
283 298 // ::-webkit-scrollbar{
... ... @@ -409,24 +424,40 @@
409 424 .ant-table-body {
410 425 .ps-table-cell {
411 426 transition: all 0s ease !important;
  427 + padding: 4px 6px 4px 5px !important;
412 428
413 429 .ant-select-selection-overflow {
414 430 flex-wrap: nowrap;
415 431 }
416 432
  433 + .ant-select-selector {
  434 + background-color: transparent !important;
  435 + height: 30px;
  436 + }
  437 +
  438 + .qx-field-setter--disabled {
  439 + background-color: transparent !important;
  440 + }
  441 +
417 442 &:hover {
418   - border: 1px solid @N6 !important;
419   - box-shadow: 0 0 4px 0 @N6 !important;
  443 + outline: 1px solid @N6;
  444 + outline-offset: -1px;
420 445 }
421 446
422 447 &-header {
423 448 transition: all 0s ease !important;
424   - display: flex;
  449 + // display: flex;
425 450 height: 41px !important;
  451 + padding: 4px 6px 4px 14px !important;
426 452
427 453 &:hover {
428   - border: 1px solid @N6 !important;
429   - box-shadow: 0 0 4px 0 @N6 !important;
  454 + outline: 1px solid @N6;
  455 + outline-offset: -1px;
  456 + // outline-style: solid;
  457 + // outline-color: @N6;
  458 + // outline-width: thin;
  459 + // border: 1px solid @N6 !important;
  460 + // box-shadow: 0 0 4px 0 @N6 !important;
430 461 // border-radius: 2px;
431 462 .drop-icon {
432 463 position: absolute;
... ... @@ -436,18 +467,25 @@
436 467 display: block;
437 468 }
438 469 }
  470 +
  471 + &:focus-within {
  472 + z-index: 99999;
  473 + // border: 1px solid @B8 !important;
  474 + outline: 1px solid @B8;
  475 + outline-offset: -1px;
  476 + box-shadow: 0 0 4px 0 @B8 !important;
  477 + // border-radius: 2px;
  478 + }
439 479 }
440 480
441 481 &:focus-within {
442   - border: 1px solid @B8 !important;
  482 + z-index: 10;
  483 + // border: 1px solid @B8 !important;
  484 + outline: 1px solid @B8;
  485 + outline-offset: -1px;
443 486 box-shadow: 0 0 4px 0 @B8 !important;
444 487 // border-radius: 2px;
445 488 }
446   -
447   - // display: flex;
448   - // .title-btn{
449   - // color: @B8;
450   - // }
451 489 }
452 490 }
453 491
... ... @@ -468,6 +506,14 @@
468 506 display: block;
469 507 }
470 508
  509 + .ant-tree-indent-unit {
  510 + width: 20px;
  511 + }
  512 +
  513 + .ant-tree-switcher-icon {
  514 + margin-right: 3px;
  515 + }
  516 +
471 517 &:hover {
472 518 background-color: @N3 !important;
473 519
... ... @@ -479,11 +525,16 @@
479 525 // display: block;
480 526 }
481 527
  528 + .ant-tree-switcher-icon {
  529 + margin-right: 0;
  530 + }
  531 +
482 532 .ant-tree-switcher {
483 533 transition: all 0.2s ease;
484 534 width: 24px !important;
485 535 margin-top: 11.5px;
486 536 display: flex;
  537 + justify-content: flex-end;
487 538 }
488 539
489 540 .title-btn-del,
... ... @@ -498,6 +549,7 @@
498 549
499 550 .ant-tree-node-content-wrapper {
500 551 width: 100%;
  552 + padding-left: 0;
501 553 }
502 554 }
503 555
... ... @@ -531,7 +583,7 @@
531 583
532 584 .table-expanded {
533 585 color: #7c7e86;
534   - margin-left: 8px;
  586 + // margin-left: 8px;
535 587 transition: transform 0.3s;
536 588 }
537 589
... ... @@ -545,17 +597,26 @@
545 597
546 598 .parameter-setting-table .ant-table-cell {
547 599 height: 40px;
548   - padding: 4px 16px 4px 14px !important;
  600 + padding: 4px 6px 4px 5px;
549 601 }
550 602
551 603 .qx-parameter-setting__modal {
552 604 .ant-modal-content {
553 605 min-height: 400px;
554 606 max-height: 600px;
  607 + padding-bottom: 24px;
555 608 // padding-bottom: 24px !important;
556 609 }
557 610
558 611 .ant-modal-body {
559   - overflow-y: hidden !important;
  612 + overflow-y: scroll !important;
  613 + padding: 0 18px 0 24px;
560 614 }
561 615 }
  616 +
  617 +.ant-table-body::-webkit-scrollbar {
  618 + width: 1px;
  619 + // position:absolute;
  620 + // right: 20px;
  621 + // display: none;
  622 +}
... ...