Commit f87b56b0 authored by 田翔's avatar 田翔

fix: 代码优化

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