Commit c8ad5a21 authored by 皮倩雯's avatar 皮倩雯

fix: 'web配置功能路径选择参数保留'

parent 5d37fff3
Pipeline #77424 passed with stages
import React, { useState, useRef, useContext, useEffect } from 'react';
import { Modal, Form, Table, Input, Button, message, Select } from 'antd';
import { Modal, Form, Table, Input, Button, message, Select, Tag } from 'antd';
import { DeleteOutlined } from '@ant-design/icons';
import styles from './ParmarsModal.less';
const EditableContext = React.createContext(null);
......@@ -171,6 +171,7 @@ const ParmarsModal = props => {
});
setCount(finalArray.length);
setDataSource(newList);
debugger;
setSelectedRowKeys(select);
} else {
setDataSource([]);
......@@ -221,6 +222,17 @@ const ParmarsModal = props => {
width: 50,
render: (text, record, index) => <span>{index + 1}</span>,
},
{
title: '类型',
align: 'center',
width: 70,
render: (text, record) => {
if (record.releaseDate) {
return <Tag color="cyan">内置</Tag>;
}
return <Tag color="purple">自定义</Tag>;
},
},
{
title: '配置项',
dataIndex: 'name',
......@@ -251,7 +263,7 @@ const ParmarsModal = props => {
{
title: '操作',
dataIndex: '',
width: 80,
width: 50,
align: 'center',
render: (_, record) =>
dataSource.length >= 1 ? (
......
......@@ -5,7 +5,7 @@ import lodash from 'lodash';
import { FolderFilled, FileOutlined, InfoCircleOutlined, HomeOutlined } from '@ant-design/icons';
import styles from './TreeSelect.less';
const TreeSelect = (props, ref) => {
const { value, onChange, menuChange, code, initCurrentMenu } = props;
const { value, onChange, menuChange, code, initCurrentMenu, keepParams } = props;
const [menuWebList, setMenuWebList] = useState({});
const [treeList, setTreeList] = useState({});
const [visible, setVisible] = useState(false);
......@@ -123,6 +123,9 @@ const TreeSelect = (props, ref) => {
setExpandedKeys([...keys]);
// 调用函数,传入数组
let tree = arrayToTree(list, 'model', 'moduleName');
console.log(menuWebList);
console.log(tree);
debugger;
setTreeList(tree);
};
const changeValue = e => {
......@@ -132,8 +135,13 @@ const TreeSelect = (props, ref) => {
setVisible(true);
};
const onSelect = (selectedKeysValue, info) => {
console.log(info);
debugger;
menuChange(info.selectedNodes[0].param);
onChange(info.selectedNodes[0].param.path);
let str = info.selectedNodes[0].param.path.split('|')[0];
let newStr = `${str}|${keepParams}`;
let data = keepParams ? newStr : info.selectedNodes[0].param.path;
onChange(data);
setCurrentMenuParmar(info.selectedNodes[0].param);
setVisible(false);
};
......
......@@ -62,6 +62,7 @@ const EditForm = props => {
const [curretnMenu, setCurrentMenu] = useState({}); // 当前选中菜单数据
const [configContent, setConfigContent] = useState(''); // 配置文件内容
const treeSelectRef = useRef();
const [keepParams, setKeepParams] = useState('');
const layout = {
layout: 'horizontal',
labelCol: { span: 2 },
......@@ -72,6 +73,8 @@ const EditForm = props => {
useEffect(() => {
console.log(info, 'info');
console.log(infoAll, 'infoalll');
let str = infoAll.pageUrl?.split('|')[1];
setKeepParams(str);
if (!infoAll.code) {
setMenuParmar([]);
}
......@@ -89,7 +92,6 @@ const EditForm = props => {
arr.map(i => {
obj[i] = infoAll[i];
});
setVisibleChecked(infoAll.hideInMenu);
targetForm.setFieldsValue({ ...obj, shortName: infoAll.menuShortName });
if (info.length > 0) {
......@@ -333,6 +335,8 @@ const EditForm = props => {
};
const menuChange = val => {
console.log(keepParams);
debugger;
if (!val) {
return;
}
......@@ -340,16 +344,21 @@ const EditForm = props => {
setCodeParmar([]);
// form.resetFields();
console.log(form, 'form');
console.log(val);
let str = val.path?.split('|')[0];
let newStr = `${str}|${keepParams}`;
form.setFieldsValue({
menuName: val?.function,
shortName: val?.shortName,
imageUrl: val?.icon,
configName: val?.configName,
pageUrl: val?.pageUrl,
pageUrl: newStr || val?.path,
});
console.log(newStr);
setConfigContent(val.configContent);
setCurrentMenu(val);
setMenuParmar(val?.param);
debugger;
};
// 编辑完配置文件后回调
const wrapperFinish = val => {
......@@ -368,10 +377,21 @@ const EditForm = props => {
console.error(e);
});
};
// 表单参数监听
const onValuesChange = values => {
let keys = Object.keys(values);
if (keys.includes('pageUrl')) {
let str = values.pageUrl.split('|')[1];
setKeepParams(str);
debugger;
}
};
return (
<div style={{ marginTop: '10px' }}>
{nodeType === 1 && (
<Form form={form} name="editGroup" onFinish={onFinish}>
<Form form={form} name="editGroup" onFinish={onFinish} onValuesChange={onValuesChange}>
<Item
label="菜单名称"
name="menuName"
......@@ -444,8 +464,8 @@ const EditForm = props => {
menuChange={val => menuChange(val)}
code={infoAll?.code}
codeParam={infoAll?.codeParam}
keepParams={keepParams}
initCurrentMenu={value => {
console.log(value, 'value');
setCurrentMenu(value);
setMenuParmar(value.param);
}}
......@@ -617,11 +637,14 @@ const EditForm = props => {
pageUrl={form.getFieldValue('pageUrl')}
handleCancel={() => setShowParmarModal(false)}
visible={showParmarModal}
keepParams={keepParams}
parmarCallBack={(url, params) => {
form.setFieldsValue({ pageUrl: url });
setCurrentMenu({ ...curretnMenu, param: params });
setCodeParmar(params);
setShowParmarModal(false);
let str = url?.split('|')[1];
setKeepParams(str);
}}
/>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment