Commit d05c0fc8 authored by 邓超's avatar 邓超

fix: 数据库连接模块保存连接下面记录不刷新修复 数据库标准化管理,数据库连接配置报错修复 web配置显示修复 台账管理保存显示修复 产品配置不能保存修复

parent d05d6c72
Pipeline #33184 passed with stages
in 43 minutes 36 seconds
......@@ -18,22 +18,14 @@ import PageContainer from '@/components/BasePageContainer';
import { connect } from 'react-redux';
import {
setTableSQLDirName,
deleteConn,
deleteConnNew,
initDBv4,
initDBv4new,
getInitDBLog,
getInitDBLogNew,
getConnRecord,
getConnRecordNew,
getDataBaseConfig,
getDataBaseConfigNew,
saveConnection,
saveConnectionNew,
getDataBaseList,
updateConnDesc,
updateConnDescNew,
deleteInitDBLog,
deleteInitDBLogNew,
connectionTest,
} from '@/services/database/api';
......@@ -46,7 +38,7 @@ const formLables = {
password: '数据库用户密码',
dbName: '数据库名称',
};
let time = null
let time = null;
const InitDataBase = props => {
const [form] = Form.useForm();
const [tableLoading, setTableLoading] = useState(false); // 连接记录
......@@ -70,118 +62,69 @@ const InitDataBase = props => {
const [finish, setFinish] = useState(false);
const [initLoading, setInitLoading] = useState(false);
const scroll = useRef(null);
// 获取数据库链接记录
// 获取数据库配置信息
useEffect(() => {
setTableLoading(true);
// getConnRecord({
// _version: 9999,
// dc: Date.now(),
// })
// .then(res => {
// setTableLoading(false);
// if (res.length > 0) {
// let arr = res.map((item, index) => {
// item.key = index;
// return item;
// });
// setData(arr);
// }
// })
// .catch(err => {
// setTableLoading(false);
// console.error(err);
// });
getConnRecordNew().then(resnew => {
setTableLoading(false);
setCardLoading(true);
// 数据库连接记录初始化
getConnRecordData();
getDataBaseConfigNew().then(resnew => {
setCardLoading(false);
let res = resnew.data;
if (resnew.code == 0) {
let res = resnew.data
let arr = res.map((item, index) => {
item.key = index;
return item;
const { inUse } = res;
let obj = {};
Object.keys(dbForm).forEach(k => {
obj[k] = res[k];
});
setData(arr);
form.setFieldsValue(obj);
setDbForm(val => ({ ...val, ...obj }));
setAllSqulDir(res.allSqlDir);
if (res.allSqlDir.some(item => item === inUse)) {
setDefaultSqlDir(res.tableSQLDirName);
} else {
// 默认切换到第一个产品方案
handeleChangeSQLDirName(res.allSqlDir[0]);
setDefaultSqlDir(res.allSqlDir[0]);
}
}
}).catch(err => {
setTableLoading(false);
console.error(err);
});
return () => {
if (time) {
clearTimeout(time)
time = null
clearTimeout(time);
time = null;
}
}
}, [upData]);
// 获取数据库配置信息
useEffect(() => {
setCardLoading(true);
// getDataBaseConfig({
// _version: 9999,
// dc: Date.now(),
// })
// .then(res => {
// setCardLoading(false);
// if (res.success) {
// const { inUse } = res;
// let obj = {};
// Object.keys(dbForm).forEach(k => {
// obj[k] = res[k];
// });
// form.setFieldsValue(obj);
// setDbForm(val => ({ ...val, ...obj }));
// setAllSqulDir(res.allSqlDir);
// if (res.allSqlDir.some(item => item === inUse)) {
// setDefaultSqlDir(res.tableSQLDirName);
// } else {
// // 默认切换到第一个产品方案
// handeleChangeSQLDirName(res.allSqlDir[0]);
// setDefaultSqlDir(res.allSqlDir[0]);
// }
// }
// })
// .catch(err => {
// setCardLoading(false);
// console.error(err);
// });
getDataBaseConfigNew().then(
resnew => {
setCardLoading(false);
let res = resnew.data
};
}, []);
// 获取数据库连接记录
const getConnRecordData = () => {
setTableLoading(true);
getConnRecordNew()
.then(resnew => {
setTableLoading(false);
if (resnew.code == 0) {
const { inUse } = res;
let obj = {};
Object.keys(dbForm).forEach(k => {
obj[k] = res[k];
let res = resnew.data;
let arr = res.map((item, index) => {
item.key = index;
return item;
});
form.setFieldsValue(obj);
setDbForm(val => ({ ...val, ...obj }));
setAllSqulDir(res.allSqlDir);
if (res.allSqlDir.some(item => item === inUse)) {
setDefaultSqlDir(res.tableSQLDirName);
} else {
// 默认切换到第一个产品方案
handeleChangeSQLDirName(res.allSqlDir[0]);
setDefaultSqlDir(res.allSqlDir[0]);
}
setData(arr);
}
}
)
return () => {
if (time) {
clearTimeout(time)
time = null
}
}
}, []);
})
.catch(err => {
setTableLoading(false);
console.error(err);
});
};
// 获取日志
const doInitLog = () => {
setInitLoading(true)
setInitLoading(true);
getInitDBLogNew()
.then(res => {
if (res.code == 0) {
if (res.data.content) {
setInitLoading(false)
setInitLoading(false);
let arr = [];
arr.push(
res.data.content
......@@ -195,12 +138,11 @@ const InitDataBase = props => {
time = setTimeout(() => {
doInitLog();
}, 600);
}
else {
setInitLoading(false)
} else {
setInitLoading(false);
if (time) {
clearTimeout(time)
time = null
clearTimeout(time);
time = null;
}
}
}
......@@ -208,30 +150,6 @@ const InitDataBase = props => {
.catch(err => {
setFinish(true);
});
// getInitDBLogNew().
// then(resnew => {
// if (resnew.code == 0) {
// let res = resnew.data
// if (res.content) {
// let arr = [];
// arr.push(
// res.content
// .split(/(\r\n)|(\n)/)
// .map((item, index) => <p key={index}>{item}</p>),
// );
// setInitContent(arr);
// scroll.current.scrollTop = scroll.current.scrollHeight;
// }
// if (!res.finish) {
// setTimeout(() => {
// doInitLog();
// }, 600);
// }
// }
// })
// .catch(err => {
// setFinish(true);
// });
};
// 数据库初始化
const initClick = () => {
......@@ -240,41 +158,21 @@ const InitDataBase = props => {
setInitVisible(true);
let obj = form.getFieldsValue();
doInitLog();
// initDBv4({
// _version: 9999,
// _dc: Date.now(),
// ...obj,
// })
// .then(res => {
// setCardLoading(false);
// if (res.GetMe) {
// console.log(res);
// } else {
// notification.error({
// message: '提示',
// duration: 15,
// description: res.Say.Message || '初始化失败',
// });
// }
// })
// .catch(err => {
// setCardLoading(false);
// console.log(err);
// });
initDBv4new({
...obj
}).then(res => {
setCardLoading(false);
if (res.code == 0) {
console.log(res);
} else {
notification.error({
message: '提示',
duration: 15,
description: res.msg || '初始化失败',
});
}
...obj,
})
.then(res => {
setCardLoading(false);
if (res.code == 0) {
console.log(res);
} else {
notification.error({
message: '提示',
duration: 15,
description: res.msg || '初始化失败',
});
}
})
.catch(err => {
setCardLoading(false);
console.log(err);
......@@ -299,11 +197,12 @@ const InitDataBase = props => {
dbName: obj.dbName,
userName: obj.userName,
password: obj.password,
}).then(
resnew => {
})
.then(resnew => {
setCardLoading(false);
if (resnew.code == 0) {
setUpData(upData + 1);
// setUpData(upData + 1);
getConnRecordData();
notification.success({
message: '提示',
duration: 3,
......@@ -316,40 +215,11 @@ const InitDataBase = props => {
description: resnew.msg,
});
}
}
).catch(err => {
setCardLoading(false);
console.log(err);
});
// saveConnection({
// _version: 9999,
// _dc: new Date().getTime(),
// ip: obj.ip,
// dbName: obj.dbName,
// userName: obj.userName,
// password: obj.password,
// })
// .then(res => {
// setCardLoading(false);
// if (res.GetMe === true) {
// setUpData(upData + 1);
// notification.success({
// message: '提示',
// duration: 3,
// description: '保存成功',
// });
// } else {
// notification.error({
// message: '提示',
// duration: 15,
// description: res.Say.Message || '保存失败',
// });
// }
// })
// .catch(err => {
// setCardLoading(false);
// console.log(err);
// });
})
.catch(err => {
setCardLoading(false);
console.log(err);
});
};
// 测试连接
const onCheck = e => {
......@@ -467,7 +337,7 @@ const InitDataBase = props => {
// _version: 9999,
// _dc: Date.now(),
// });
deleteInitDBLogNew()
deleteInitDBLogNew();
};
// 弹窗确认回调
const modalOkCallback = () => {
......@@ -499,7 +369,8 @@ const InitDataBase = props => {
})
.then(res => {
setModalVisible(false);
setUpData(upData + 1);
// setUpData(upData + 1);
getConnRecordData();
})
.catch(err => {
console.error(err);
......@@ -516,7 +387,8 @@ const InitDataBase = props => {
.then(res => {
setTableLoading(false);
if (res.code === 0) {
setUpData(upData + 1);
// setUpData(upData + 1);
getConnRecordData();
notification.success({
message: '提示',
duration: 3,
......@@ -534,25 +406,6 @@ const InitDataBase = props => {
setTableLoading(false);
console.error(err);
});
// deleteConnNew({
// rowIndex: key
// }).then(res => {
// setTableLoading(false);
// if (res.code == 0) {
// setUpData(upData + 1);
// notification.success({
// message: '提示',
// duration: 3,
// description: '操作成功',
// });
// } else {
// notification.error({
// message: '提示',
// duration: 15,
// description: res.msg,
// });
// }
// })
};
const columns = [
{
......@@ -760,7 +613,7 @@ const InitDataBase = props => {
// _version: 9999,
// _dc: Date.now(),
// });
deleteInitDBLogNew()
deleteInitDBLogNew();
}}
width={800}
maskClosable={false}
......@@ -773,6 +626,7 @@ const InitDataBase = props => {
onClick={() => {
handleClick();
}}
key="back"
type="primary"
>
关闭窗口
......
......@@ -16,7 +16,7 @@ import {
tableCheckNew,
updateDateBase,
databaseStandardGetLog,
databaseStandardGetLogNew
databaseStandardGetLogNew,
} from '@/services/database/api';
const ManagementDataBase = () => {
......@@ -65,7 +65,7 @@ const ManagementDataBase = () => {
setCheckLoading(false);
console.log(resnew);
if (resnew.code == 0) {
let res = resnew.data
let res = resnew.data;
const { Autolist, ManualList } = res;
// 自动检测列表
let arr = Autolist.map((item, index) => {
......@@ -112,7 +112,7 @@ const ManagementDataBase = () => {
.then(resnew => {
setLogLoading(false);
if (resnew.code == 0) {
let res = resnew.data.list
let res = resnew.data.list;
let arr = [];
res.map((item, index) => {
item.key = index;
......@@ -138,7 +138,7 @@ const ManagementDataBase = () => {
setCheckLoading(false);
setCheckFlag(checkFlag + 1);
setUpFlag(upFlag + 1);
if (res.code===0) {
if (res.code === 0) {
notification.success({
message: '通知',
duration: 3,
......@@ -166,7 +166,7 @@ const ManagementDataBase = () => {
setModalVisible(true);
// setContent(text);
setContent(arr);
}
};
const handleLog = (text, val) => {
setModalTitle(val);
let arr = [];
......@@ -296,11 +296,11 @@ const ManagementDataBase = () => {
onClick={() => {
handleLog(text, '详细信息');
}}
style={{ backgroundColor: "red" }}
style={{ backgroundColor: 'red' }}
>
错误内容
</Button>
)
);
}
},
},
......@@ -366,7 +366,6 @@ const ManagementDataBase = () => {
size="small"
/>
</Card>
</PageContainer>
<Modal
......@@ -384,7 +383,11 @@ const ManagementDataBase = () => {
}}
style={{ top: '40px' }}
footer={[
<Button type="primary" onClick={() => setModalVisible(false)}>
<Button
type="primary"
onClick={() => setModalVisible(false)}
key="back"
>
关闭窗口
</Button>,
]}
......
......@@ -203,6 +203,7 @@ const SQLServerTable = props => {
size="small"
type="primary"
onClick={() => handleCon(val, item)}
key="testLink"
>
测试连接
</Button>,
......@@ -213,12 +214,14 @@ const SQLServerTable = props => {
color: '#faad14',
borderColor: '#ffe58f',
}}
key="bntEdit"
size="small"
onClick={() => handleEdit(val, item)}
>
编辑
</Button>,
<Popconfirm
key="btnDelete"
title={`是否删除连接${item.name}`}
cancelText="取消"
okText="确认"
......@@ -236,7 +239,7 @@ const SQLServerTable = props => {
<>
<ProTable
headerTitle="SQL数据库"
rowKey="key"
rowKey="name"
search={false}
columns={columns}
bordered
......
......@@ -161,7 +161,8 @@ const standingBook = props => {
newArr.push(item)
})
setAllData(arr);
setPickItem(newArr[0])
// 第一次进入展示第一页 不是第一次进入根据当前选择的来进行展示
flag === 0 ? setPickItem(newArr[0]) : setPickItem(pickItem);
console.log(newArr, 'newArr');
setTableData(newArr);
}
......
......@@ -25,7 +25,7 @@ import {
FormOutlined,
EditOutlined,
DeleteOutlined,
UserAddOutlined
UserAddOutlined,
} from '@ant-design/icons';
import {
setMenuToRole,
......@@ -47,7 +47,7 @@ import EditModal from './EditModal';
import EditGroup from './EditGroup';
import userStyles from '@/pages/userCenter/userManage/UserManage.less';
import iconStyles from '@/assets/font/omsfont/iconfont.css';
import UserModal from './UserModal'
import UserModal from './UserModal';
import { data } from '@/pages/platformCenter/messageManage/projectManage/components/Mock';
const { Search } = Input;
......@@ -131,7 +131,9 @@ const SiteManage = () => {
};
useEffect(() => {
console.log('进入');
if (!roleID) return;
console.log('选择后');
setLoading(true);
const defaultConfig = {
optionsList: [],
......@@ -146,8 +148,8 @@ const SiteManage = () => {
.then(res => {
const list = [];
// eslint-disable-next-line no-unused-expressions
res.code===0 &&
res.root.forEach(item => {
res.code === 0 &&
res.data.root.forEach(item => {
list.push({ ...defaultConfig, ...item });
});
const finalList = buildMap(list);
......@@ -189,7 +191,6 @@ const SiteManage = () => {
};
// 树形数据转换;
const transTree = val => {
let arr = val;
let newArr = [];
// 提取child里面的数组
......@@ -239,27 +240,44 @@ const SiteManage = () => {
{i.roleID && (
<>
<Tooltip title="编辑角色" className={styles.fs}>
<FormOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>editorUser(e,i)} />
</Tooltip><Tooltip title="删除角色" className={styles.fs}>
<DeleteOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>deletesUser(e,i)} />
</Tooltip><Tooltip title="关联用户" className={styles.fs}>
<UserAddOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>relevancyUser(e,i)} />
</Tooltip></>
<FormOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => editorUser(e, i)}
/>
</Tooltip>
<Tooltip title="删除角色" className={styles.fs}>
<DeleteOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => deletesUser(e, i)}
/>
</Tooltip>
<Tooltip title="关联用户" className={styles.fs}>
<UserAddOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => relevancyUser(e, i)}
/>
</Tooltip>
</>
)}
{!i.roleID && (
{!i.roleID && (
<Tooltip title="新增角色" className={styles.fs}>
<PlusSquareOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>addsUser(e,i)} />
<PlusSquareOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => addsUser(e, i)}
/>
</Tooltip>
)}
{i.groupflag && (
<Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>editorGroup(e,i)} />
<EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => editorGroup(e, i)}
/>
</Tooltip>
)}
</div>
</div>
)
);
i.key = i.roleID;
i.subSystemValue = item.visibleValue;
i.group = itemRole.visibleTitle;
......@@ -279,7 +297,6 @@ const SiteManage = () => {
setItemObj(itemRole);
// setCurrentSelectId(roleID);
}
}
itemRole.title = (
<div className={styles.title}>
......@@ -288,27 +305,44 @@ const SiteManage = () => {
{itemRole.roleID && (
<>
<Tooltip title="编辑角色" className={styles.fs}>
<FormOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>editorUser(e,itemRole)} />
</Tooltip><Tooltip title="删除角色" className={styles.fs}>
<DeleteOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>deletesUser(e,itemRole)} />
</Tooltip><Tooltip title="关联用户" className={styles.fs}>
<UserAddOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>relevancyUser(e,itemRole)} />
</Tooltip></>
<FormOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => editorUser(e, itemRole)}
/>
</Tooltip>
<Tooltip title="删除角色" className={styles.fs}>
<DeleteOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => deletesUser(e, itemRole)}
/>
</Tooltip>
<Tooltip title="关联用户" className={styles.fs}>
<UserAddOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => relevancyUser(e, itemRole)}
/>
</Tooltip>
</>
)}
{!itemRole.roleID && (
{!itemRole.roleID && (
<Tooltip title="新增角色" className={styles.fs}>
<PlusSquareOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>addsUser(e,itemRole)} />
<PlusSquareOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => addsUser(e, itemRole)}
/>
</Tooltip>
)}
{itemRole.groupflag && (
<Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>editorGroup(e,itemRole)} />
<EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => editorGroup(e, itemRole)}
/>
</Tooltip>
)}
</div>
</div>
)
);
return itemRole;
});
}
......@@ -320,62 +354,80 @@ const SiteManage = () => {
{item.roleID && (
<>
<Tooltip title="编辑角色" className={styles.fs}>
<FormOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>editorUser(e,item)} />
</Tooltip><Tooltip title="删除角色" className={styles.fs}>
<DeleteOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>deletesUser(e,item)} />
</Tooltip><Tooltip title="关联用户" className={styles.fs}>
<UserAddOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>relevancyUser(e,item)} />
</Tooltip></>
<FormOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => editorUser(e, item)}
/>
</Tooltip>
<Tooltip title="删除角色" className={styles.fs}>
<DeleteOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => deletesUser(e, item)}
/>
</Tooltip>
<Tooltip title="关联用户" className={styles.fs}>
<UserAddOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => relevancyUser(e, item)}
/>
</Tooltip>
</>
)}
{!item.roleID && (
{!item.roleID && (
<Tooltip title="新增角色" className={styles.fs}>
<PlusSquareOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>addsUser(e,item)} />
<PlusSquareOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => addsUser(e, item)}
/>
</Tooltip>
)}
{item.groupflag && (
<Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined style={{ fontSize: '16px', color: '#1890FF' }} onClick={e=>editorGroup(e,item)} />
<EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
onClick={e => editorGroup(e, item)}
/>
</Tooltip>
)}
</div>
</div>
)
);
return item;
});
return arr3;
};
//编辑角色
const editorUser = (e,record) => {
const editorUser = (e, record) => {
e.stopPropagation();
setItemObj(record);
setEditVisible(true);
}
};
//删除角色
const deletesUser = (e,record) => {
const deletesUser = (e, record) => {
e.stopPropagation();
setItemObj(record);
setDelVisible(true);
}
};
//关联用户
const relevancyUser = (e,record) => {
const relevancyUser = (e, record) => {
e.stopPropagation();
setItemObj(record);
setUserVisible(true)
}
setUserVisible(true);
};
//编辑分组
const editorGroup = (e,record) => {
console.log(record,'1212')
const editorGroup = (e, record) => {
console.log(record, '1212');
e.stopPropagation();
setItemObj(record);
setGroupVisible(true);
}
};
//新增角色
const addsUser = (e,record) => {
const addsUser = (e, record) => {
e.stopPropagation();
setItemObj(record);
setModalVisible(true);
}
};
const handleChange = e => {
const { value } = e.target;
setSearchWord(value);
......@@ -415,7 +467,7 @@ const SiteManage = () => {
setFlag(flag + 1);
setItemObj('');
handleTreeSelect(saveCurId);
}
};
const valueCallback = valueObj => {
setSubList(valueObj);
};
......@@ -437,7 +489,7 @@ const SiteManage = () => {
)
.then(res => {
setBtnLoading(false);
if (res.msg==='Ok') {
if (res.msg === 'Ok') {
setValueList([...results.flat()]);
notification.success({
message: '提示',
......@@ -457,8 +509,8 @@ const SiteManage = () => {
});
};
const handleUserAttach = () => {
setUserVisible(true)
}
setUserVisible(true);
};
return (
<PageContainer>
<div
......
......@@ -47,13 +47,13 @@ const EditForm = props => {
<Item
label="产品包名:"
name="PackageName"
rules={[
{
required: true,
pattern: new RegExp(/^[a-z0-9A-Z]+$/),
message: '产品包名必须是英文或者数字',
},
]}
// rules={[
// {
// required: true,
// pattern: new RegExp(/^[a-z0-9A-Z]+$/),
// message: '产品包名必须是英文或者数字',
// },
// ]}
>
<Input placeholder="请输入产品包名" allowClear disabled />
</Item>
......@@ -86,12 +86,12 @@ const EditForm = props => {
<Item
label="发布状态:"
name="PublishState"
rules={[
{
required: true,
message: '请选择发布状态',
},
]}
// rules={[
// {
// required: true,
// message: '请选择发布状态',
// },
// ]}
>
<Select placeholder="请选择发布状态" disabled>
{environmentList &&
......
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