Commit f87b56b0 authored by 田翔's avatar 田翔

fix: 代码优化

parent 2a5d3887
{
"name": "panda-xform",
"version": "5.9.26",
"description": "5.9.26 时间增加时间段优化3",
"version": "5.9.27",
"description": "5.9.27 代码优化",
"keywords": [
"panda-xform"
],
......
......@@ -67,7 +67,6 @@ const Account = (props, ref) => {
const [treeShow, setTreeShow] = useState(true);
const [treeData, setTreeData] = useState([]);
const [expandedKeys, setExpandedKeys] = useState([]);
const [treeValue, setTreeValue] = useState([accountName]);
const [detailShow, setDetailShow] = useState(false);
const [params, setParams] = useState(initParams);
const [loading, setLoading] = useState(false);
......@@ -100,12 +99,12 @@ const Account = (props, ref) => {
if (type === '重置') {
tablePackRef.current.setFilteredInfo({});
tablePackRef.current.setSortedInfo({});
setParams({ ...initParams, accountName: treeData?.[0]?.accountName || accountName });
getDataSource({ ...initParams, accountName: treeData?.[0]?.accountName || accountName });
setParams({ ...initParams, accountName: params.accountName });
getDataSource({ ...initParams, accountName: params.accountName });
}
if (type === '编辑' || type === '详情') {
setOperation({ type, id: row.ID });
const { code, data, msg } = await GetTableDataInfo({ accountName, id: row.ID });
const { code, data, msg } = await GetTableDataInfo({ accountName: params.accountName, id: row.ID });
if (code === 0) {
saveClick(editField, formJson, data, type);
} else {
......@@ -114,7 +113,7 @@ const Account = (props, ref) => {
}
if (type === '删除') {
setOperation({ type, id: row.ID });
const { code, data, msg } = await DeleteTableDataInfo({ accountTable: accountName, ids: row.ID });
const { code, data, msg } = await DeleteTableDataInfo({ accountTable: params.accountName, ids: row.ID });
if (code === 0) {
message.success('删除成功!');
getDataSource();
......@@ -181,7 +180,7 @@ const Account = (props, ref) => {
content: keys.length > 0 ? `共选择${keys.length}条数据,确定要导出吗` : '确定要导出全部数据吗?',
onOk: async () => {
return await new Promise(async (resolve, reject) => {
const blob = await ExportAccountData({ accountName: accountName, ids: keys.join(','), exportAll });
const blob = await ExportAccountData({ accountName: params.accountName, ids: keys.join(','), exportAll });
const reader = new FileReader();
reader.onload = function () {
const text = reader.result;
......@@ -212,7 +211,7 @@ const Account = (props, ref) => {
};
const exportTemplate = async ({ exportAll }) => {
let res = await ExportAccountModel({ accountName: accountName, exportAll });
let res = await ExportAccountModel({ accountName: params.accountName, exportAll });
if (res && res.code === -1) {
message.error(res.msg);
reject();
......@@ -268,8 +267,8 @@ const Account = (props, ref) => {
const { type, id } = operation;
setSubmitLoading(true);
if (type === '添加') {
let params = { userID, accountTable: accountName, id: operation.id, values: formValue, relationForm };
const { code, data, msg } = await SaveTableDataInfo(params);
let param = { userID, accountTable: params.accountName, id: operation.id, values: formValue, relationForm };
const { code, data, msg } = await SaveTableDataInfo(param);
if (code === 0) {
message.success('保存成功!');
setDetailShow(false);
......@@ -279,8 +278,8 @@ const Account = (props, ref) => {
}
}
if (type === '编辑') {
let params = { userID, accountTable: accountName, id: operation.id, values: formValue, relationForm };
const { code, data, msg } = await EditTableDataInfo(params);
let param = { userID, accountTable: params.accountName, id: operation.id, values: formValue, relationForm };
const { code, data, msg } = await EditTableDataInfo(param);
if (code === 0) {
message.success('修改成功!');
setSubmitLoading(false);
......@@ -302,7 +301,7 @@ const Account = (props, ref) => {
const { code, data, msg } = await GetAccountConfigInfo(accountName);
if (code === 0) {
setConfig({ ...data, formJson: isJson(data.formJson) ? JSON.parse(data.formJson) : {} });
setParams({ ...params, pageSize: data.pageSize || 20 });
setParams({ ...params, pageSize: data.pageSize || 20, accountName });
let param = {
condition: data?.sqlFilter ? window.btoa(encodeURIComponent(data?.sqlFilter)) : '',
siteFilter: Boolean(data.enableSiteFilter),
......@@ -358,7 +357,6 @@ const Account = (props, ref) => {
const treeChange = value => {
if (value.length) {
setTreeValue(value);
getConfig({ accountName: value[0] });
}
};
......@@ -535,7 +533,8 @@ const Account = (props, ref) => {
</div>
<Tree
style={{ overflow: 'hidden' }}
checkable
defaultSelectedKeys={[accountName]}
// checkable
checkStrictly
showIcon
blockNode
......@@ -543,7 +542,7 @@ const Account = (props, ref) => {
onExpand={expandedKeys => setExpandedKeys(expandedKeys)}
fieldNames={{ title: 'accountName', key: 'accountName', children: 'children' }}
switcherIcon={<DownOutlined />}
checkedKeys={treeValue}
// checkedKeys={treeValue}
treeData={treeData}
onSelect={treeChange}
/>
......
......@@ -144,7 +144,7 @@ const XRender = (props, ref) => {
<div className={styles.formRender}>
<FormRender
configProvider={{ prefixCls: pandaXform }}
removeHiddenData={true}
removeHiddenData={false}
form={form}
schema={schemaForm}
mapping={{
......
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