Commit bfdc43b1 by 放生的三文鱼

修复部分资产草稿bug

parent 39b640b9
...@@ -28,6 +28,7 @@ const AssetManagementTable = () => { ...@@ -28,6 +28,7 @@ const AssetManagementTable = () => {
dirId: "", dirId: "",
draftId: "", draftId: "",
templateType: "", templateType: "",
readonly: false,
}); });
const [importModalVisible, setImportModalVisible] = useState(false); const [importModalVisible, setImportModalVisible] = useState(false);
...@@ -228,6 +229,24 @@ const AssetManagementTable = () => { ...@@ -228,6 +229,24 @@ const AssetManagementTable = () => {
scroll={{ x: true }} scroll={{ x: true }}
rowSelection={rowSelection} rowSelection={rowSelection}
rowKey={"id"} rowKey={"id"}
onRow={(record) => {
return {
onClick: (event) => {
// 阻止事件冒泡,避免与内部按钮点击冲突
event.stopPropagation();
// 只有点击行本身(不是按钮)时才触发
if (!event.target.closest("button")) {
setDraftParams({
visible: true,
dirId: record?.dirId,
draftId: record?.id,
templateType: currentTemplate,
readonly: true,
});
}
},
};
}}
/> />
<Pagination <Pagination
style={{ margin: "12px auto", textAlign: "center" }} style={{ margin: "12px auto", textAlign: "center" }}
...@@ -250,6 +269,7 @@ const AssetManagementTable = () => { ...@@ -250,6 +269,7 @@ const AssetManagementTable = () => {
dirId: "", dirId: "",
draftId: "", draftId: "",
templateType: "", templateType: "",
readonly: false,
}); });
}} }}
/> />
......
import { useEffect, useState } from "react"; import { useEffect, useState,useContext } from "react";
import { Tooltip, Typography, Button, Tag, Popconfirm, message } from "antd"; import { Tooltip, Typography, Button, Tag, Popconfirm, message } from "antd";
import { import {
getTemplates, getTemplates,
...@@ -10,11 +10,13 @@ import { ...@@ -10,11 +10,13 @@ import {
import { AssetItem } from "../../AssetManage/Component/AssetTable"; import { AssetItem } from "../../AssetManage/Component/AssetTable";
import { showMessage, showErrorNotifaction } from "../../../../util"; import { showMessage, showErrorNotifaction } from "../../../../util";
import LocalStorage from "local-storage"; import LocalStorage from "local-storage";
import { appId } from "../../../../App"; import { appId, AppContext } from "../../../../App";
const { Text } = Typography; const { Text } = Typography;
// ../standardmanage/hooks/sourceMap
export function useGetAssetDraft({ setDraftParams, sendFlow }) { export function useGetAssetDraft({ setDraftParams, sendFlow }) {
const app = useContext(AppContext);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [templates, setTemplates] = useState(); const [templates, setTemplates] = useState();
const [currentTemplate, setCurrentTemplate] = useState(); const [currentTemplate, setCurrentTemplate] = useState();
...@@ -30,6 +32,7 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -30,6 +32,7 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
const [dataLoading, setDataLoading] = useState(false); const [dataLoading, setDataLoading] = useState(false);
const [draftData, setDraftData] = useState(); const [draftData, setDraftData] = useState();
const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRowKeys, setSelectedRowKeys] = useState([]);
// 批量删除 // 批量删除
const batchDelete = async (id = "") => { const batchDelete = async (id = "") => {
try { try {
...@@ -48,6 +51,7 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -48,6 +51,7 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
showErrorNotifaction("提示", message, 3); showErrorNotifaction("提示", message, 3);
} }
}; };
// 批量送审 // 批量送审
const batchPublish = async (id = "", reason = "") => { const batchPublish = async (id = "", reason = "") => {
try { try {
...@@ -83,7 +87,7 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -83,7 +87,7 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
setLoading(false); setLoading(false);
} }
}; };
// 获取模板
useEffect(() => { useEffect(() => {
getTemplatesList(); getTemplatesList();
}, []); }, []);
...@@ -97,8 +101,8 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -97,8 +101,8 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
let _columns = []; let _columns = [];
let index = 0, let index = 0,
_metadataIndex = ""; _metadataIndex = "";
(data || []).forEach((group) => { (data || [])?.forEach((group) => {
(group.names || []).forEach((name, i) => { (group?.names || []).forEach((name, i) => {
index++; index++;
const params = { const params = {
title: name, title: name,
...@@ -112,25 +116,8 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -112,25 +116,8 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
); );
}, },
}; };
// if (name === "编号") {
// params.width = 60;
// // params.fixed = 'left';
// } else if (name === "中文名称") {
// params.width = 160;
// // params.fixed = 'left';
// } else if (name === "英文名称") {
// // params.fixed = 'left';
// // params.render = (text, record) => {
// // return (
// // <Tooltip title={text||''}>
// // <a onClick={()=>{detailAsset(record);}}>
// // {text||''}
// // </a>
// // </Tooltip>
// // );
// // }
if (name === "资产项") { if (name === "资产项") {
// params.width = 120;
params.render = (metadata, _) => { params.render = (metadata, _) => {
return <AssetItem metadata={metadata} />; return <AssetItem metadata={metadata} />;
}; };
...@@ -220,18 +207,29 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -220,18 +207,29 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
_columns.push({ _columns.push({
title: "操作", title: "操作",
key: "action", key: "action",
width: 160, width: 280,
render: (text, record) => { render: (text, record) => {
const disabled = record?.draftState !== "draft"; const disabled = record?.draftState !== "draft";
const handleEdit = (record) => { const handleEdit = (record) => {
// 编辑操作逻辑
console.log("编辑记录:", record);
setDraftParams({ setDraftParams({
visible: true, visible: true,
dirId: record?.dirId, dirId: record?.dirId,
draftId: record?.id, draftId: record?.id,
templateType: currentTemplate, templateType: currentTemplate,
readonly: false,
});
};
// 流转进程点击处理
const handleShowApproval = () => {
app?.setGlobalState &&
app?.setGlobalState?.({
message: "data-govern-show-approval-message",
data: {
workOrderId: record?.proceInstId, // 使用草稿ID
type: "draft", // 根据业务需要设置类型
},
}); });
}; };
return ( return (
...@@ -257,10 +255,18 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -257,10 +255,18 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
> >
编辑 编辑
</Button> </Button>
<Button
size="small"
waring
type="link"
onClick={handleShowApproval} // 绑定点击事件
>
流转进程
</Button>
<Popconfirm <Popconfirm
title="确认删除草稿?" title="确认删除草稿?"
onConfirm={() => { onConfirm={() => {
batchPublish([record?.id]); batchDelete([record?.id]); // 修正为删除操作
}} }}
> >
<Button disabled={disabled} size="small" type="link" danger> <Button disabled={disabled} size="small" type="link" danger>
...@@ -285,7 +291,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -285,7 +291,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
const getDraftData = async () => { const getDraftData = async () => {
try { try {
// 设置数据加载状态为true,表示开始加载
setDataLoading(true); setDataLoading(true);
const data = await getDraftDataAsset({ const data = await getDraftDataAsset({
...pagination, ...pagination,
...@@ -295,7 +300,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -295,7 +300,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
}); });
const _assets = []; const _assets = [];
(data.data || []).forEach((asset) => { (data.data || []).forEach((asset) => {
let _asset = { ...asset }, let _asset = { ...asset },
index = 0; index = 0;
...@@ -314,7 +318,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -314,7 +318,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
} }
}); });
}); });
_assets.push(_asset); _assets.push(_asset);
}); });
...@@ -326,7 +329,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) { ...@@ -326,7 +329,6 @@ export function useGetAssetDraft({ setDraftParams, sendFlow }) {
setDataLoading(false); setDataLoading(false);
} catch (error) { } catch (error) {
setDataLoading(false); setDataLoading(false);
} finally {
} }
}; };
......
...@@ -28,6 +28,7 @@ import './AssetAction.less'; ...@@ -28,6 +28,7 @@ import './AssetAction.less';
const AssetAction = (props) => { const AssetAction = (props) => {
const { id, dirId, draftId,action, terms, onChange, reference, form, onMetadataChange, onElementsChange, readonly = false, permissionId ,templateType} = props; const { id, dirId, draftId,action, terms, onChange, reference, form, onMetadataChange, onElementsChange, readonly = false, permissionId ,templateType} = props;
console.log('props',props);
const [ currentAction, setCurrentAction ] = useState(action); const [ currentAction, setCurrentAction ] = useState(action);
const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [], attributesFoldMap: {} }); const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [], attributesFoldMap: {} });
......
...@@ -4,7 +4,7 @@ import { getTemplateType } from '../../../../util/axios'; ...@@ -4,7 +4,7 @@ import { getTemplateType } from '../../../../util/axios';
import AssetAction from './AssetAction'; import AssetAction from './AssetAction';
const AssetDetailDrawer = (props) => { const AssetDetailDrawer = (props) => {
const { onCancel, visible, id, dirId, reference, templateType='', draftId='' } = props; const { onCancel, visible, id, dirId, reference, templateType='', draftId='',readonly='' } = props;
const [ form ] = Form.useForm(); const [ form ] = Form.useForm();
const currentTemplateType = templateType || getTemplateType(); const currentTemplateType = templateType || getTemplateType();
return ( return (
...@@ -20,7 +20,7 @@ const AssetDetailDrawer = (props) => { ...@@ -20,7 +20,7 @@ const AssetDetailDrawer = (props) => {
}} }}
> >
{ {
visible && <AssetAction templateType={currentTemplateType} reference={reference} form={form} id={id} dirId={dirId} draftId={draftId} action='detail' onChange={() => { visible && <AssetAction readonly={readonly} templateType={currentTemplateType} reference={reference} form={form} id={id} dirId={dirId} draftId={draftId} action='detail' onChange={() => {
onCancel?.(true); onCancel?.(true);
}} /> }} />
} }
......
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