Commit bfdc43b1 by 放生的三文鱼

修复部分资产草稿bug

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