Commit 754b9840 authored by chenshouchao's avatar chenshouchao

feat: 工作流模板文案同步

parent 8ddb3f4f
...@@ -11,6 +11,7 @@ interface IProductSelectProps { ...@@ -11,6 +11,7 @@ interface IProductSelectProps {
setProductId: any; setProductId: any;
okText?: string; okText?: string;
onConfirm?: any; onConfirm?: any;
title?: any;
} }
const ProductSelect = (props: IProductSelectProps) => { const ProductSelect = (props: IProductSelectProps) => {
...@@ -21,6 +22,7 @@ const ProductSelect = (props: IProductSelectProps) => { ...@@ -21,6 +22,7 @@ const ProductSelect = (props: IProductSelectProps) => {
okText = "下一步", okText = "下一步",
setOpen, setOpen,
onConfirm, onConfirm,
title,
} = props; } = props;
const { productListStore } = useStores(); const { productListStore } = useStores();
...@@ -43,7 +45,7 @@ const ProductSelect = (props: IProductSelectProps) => { ...@@ -43,7 +45,7 @@ const ProductSelect = (props: IProductSelectProps) => {
return ( return (
<MyDialog <MyDialog
open={open} open={open}
title="选择产品" title={title || "选择产品"}
okText={okText} okText={okText}
onClose={() => setOpen(false)} onClose={() => setOpen(false)}
onConfirm={() => handleConfirm()} onConfirm={() => handleConfirm()}
......
import React from "react";
import { useCallback, useEffect, useState, useRef } from "react";
import { Column, Table, AutoSizer } from "react-virtualized";
import "react-virtualized/styles.css"; // only needs to be imported once
type Order = "ASC" | "DESC"; // 升序为asc,降序为desc。
export type sortState = {
field: string | null | undefined | ""; // 根据哪个属性来排序
order: Order | null | undefined | "";
};
interface IVirtuallyTableProps {
rows: Array<any>; // 表格数据
headCells: Array<any>; // 表头配置
tableKey?: string; // 表格数据的key
loading?: boolean; // 是否正在加载数据
hasCheckbox?: boolean; // 是否有复选框
selectItems?: Array<any>; // 选中的项
setSelectItems?: any; // 设置选中的项
// fixedHead?: boolean; // 是否是固定表头
noDataText?: string; // 无数据提示文案
// hasTableFooter?: boolean; // 是否有分页组件
// page?: number; // 当前页
// pageChange?: any; // 页码改变
// count?: number; // 总页数
// totalElements?: number; // 数据总量 不止是列表渲染的长度
sortState?: sortState; // 排序状态
setSortState?: any; // 设置排序状态
// paginationType?: "simple" | "complex"; // 分页组件的类型 simple简洁式 complex复杂、带每页数量切换、总数等
// rowsPerPage?: number; // 每页多少条数据
// handleChangeRowsPerPage?: any; // 每页多少条数据变化
nodataText?: any; // 无数据文案
handleRow?: any; // 点击一行
activeId?: string; // 选中的一行的id
disableFn?: any; // 禁用时根据disableFn来判断是否禁用
}
const VirtuallyTable = (props: IVirtuallyTableProps) => {
const {
rows,
headCells,
tableKey = "id",
loading = false,
hasCheckbox = false,
selectItems = [],
setSelectItems,
sortState,
setSortState,
nodataText,
handleRow,
activeId,
disableFn,
} = props;
const virtuallyTableBoxRef: any = useRef(null);
const virtuallyTableRef: any = useRef(null);
const [width, setWidth] = useState(0);
const [height, setHeight] = useState(0);
// const list = [
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// { name: "Brian Vaughn", description: "Software engineer" },
// // And so on...
// ];
console.log(rows);
console.log(headCells);
// const getCodeWidth = () => {
// const addEnvironmentCodeElement =
// document.getElementById("addEnvironmentCode");
// setCodeWidth(addEnvironmentCodeElement?.offsetWidth || 0);
// };
// useEffect(() => {
// getCodeWidth();
// }, []);
const getTableWidthHeight = () => {
setWidth(virtuallyTableBoxRef?.current?.offsetWidth || 1000);
setHeight(virtuallyTableBoxRef?.current?.offsetHeight || 300);
};
useEffect(() => {
getTableWidthHeight();
}, []);
window.onresize = () => {
getTableWidthHeight();
};
return (
<div
ref={virtuallyTableBoxRef}
style={{ width: "100%", height: "100%", border: "1px solid red" }}
>
{width && height && (
<Table
ref={virtuallyTableRef}
width={width}
height={height}
headerHeight={20}
rowHeight={30}
rowCount={rows.length}
rowGetter={({ index }: any) => rows[index]}
>
{headCells.map((headCell) => {
return (
<Column
key={headCell.id}
label={headCell.label}
dataKey={headCell.id}
width={headCell.width}
flexGrow={headCell.flexGrow || 0}
cellRenderer={
headCell.cellRenderer
? (data: any) => {
headCell.cellRenderer(data);
}
: (data: any) => {
return data.cellData;
}
}
/>
);
})}
{/* <Column label="Name" dataKey="name" width={100} />
<Column width={200} label="Description" dataKey="description" /> */}
</Table>
)}
</div>
);
};
export default VirtuallyTable;
...@@ -185,18 +185,16 @@ const Tabs = (props: IProps) => { ...@@ -185,18 +185,16 @@ const Tabs = (props: IProps) => {
}} }}
> >
{title ? ( {title ? (
<> <span
<span className={classNames({
className={classNames({ [styles.titleBox]: true,
[styles.titleBox]: true, [titleClass]: titleClass,
[titleClass]: titleClass, })}
})} >
> {title}
{title} </span>
</span>
<div className={styles.titleBoxLine}></div>
</>
) : null} ) : null}
{title ? <div className={styles.titleBoxLine}></div> : null}
{tabList {tabList
?.filter((item) => !item.hide) ?.filter((item) => !item.hide)
.map((item, key) => { .map((item, key) => {
......
...@@ -165,7 +165,7 @@ const SaveOperator = (props: IProps) => { ...@@ -165,7 +165,7 @@ const SaveOperator = (props: IProps) => {
helperText={versionHelper.helperText} helperText={versionHelper.helperText}
style={{ marginBottom: "20px" }} style={{ marginBottom: "20px" }}
></MyInput> ></MyInput>
<div style={{ position: "relative" }}> <div style={{ position: "relative", paddingBottom: "20px" }}>
<MyInput <MyInput
value={description} value={description}
id="desc" id="desc"
......
...@@ -208,7 +208,7 @@ const AddProject = observer((props: IAddProjectProps) => { ...@@ -208,7 +208,7 @@ const AddProject = observer((props: IAddProjectProps) => {
</MenuItem> </MenuItem>
))} ))}
</MyInput> </MyInput>
<div style={{ position: "relative" }}> <div style={{ position: "relative", paddingBottom: "20px" }}>
<MyInput <MyInput
value={desc} value={desc}
error={descCheck.error} error={descCheck.error}
......
...@@ -545,6 +545,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -545,6 +545,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
<MyButton <MyButton
text="开始构建" text="开始构建"
onClick={() => handleSubmit()} onClick={() => handleSubmit()}
isLoadingButton={true}
loading={loading} loading={loading}
></MyButton> ></MyButton>
</div> </div>
......
...@@ -34,7 +34,7 @@ const TemplateItem = (props: ITemplateItemPorps) => { ...@@ -34,7 +34,7 @@ const TemplateItem = (props: ITemplateItemPorps) => {
</> </>
)} )}
<div className={style.templateTopLine}></div> <div className={style.templateTopLine}></div>
<div className={style.templateTopItem}>{templateInfo.version}</div> <div className={style.templateTopItem}>v{templateInfo.version}</div>
<div className={style.templateTopLine}></div> <div className={style.templateTopLine}></div>
<div className={style.templateTopItem}>{templateInfo.updatedTime}</div> <div className={style.templateTopItem}>{templateInfo.updatedTime}</div>
</div> </div>
......
...@@ -164,6 +164,8 @@ const UserResourcesTemplate = observer(() => { ...@@ -164,6 +164,8 @@ const UserResourcesTemplate = observer(() => {
setOpen={setShowProductSelect} setOpen={setShowProductSelect}
productId={productId} productId={productId}
setProductId={setProductId} setProductId={setProductId}
title="新建自定义模板"
okText="确定"
onConfirm={() => { onConfirm={() => {
setTemplateId(""); setTemplateId("");
setShowAddTemplate(true); setShowAddTemplate(true);
......
...@@ -76,7 +76,7 @@ const WorkflowOperator = observer(() => { ...@@ -76,7 +76,7 @@ const WorkflowOperator = observer(() => {
}, [searchParams.productId, searchParams.type]); }, [searchParams.productId, searchParams.type]);
return ( return (
<> <div>
<div className={styles.indexBox}> <div className={styles.indexBox}>
<div className={styles.headerBox}> <div className={styles.headerBox}>
<div> <div>
...@@ -163,7 +163,7 @@ const WorkflowOperator = observer(() => { ...@@ -163,7 +163,7 @@ const WorkflowOperator = observer(() => {
pageType={pageType} pageType={pageType}
/> />
)} )}
</> </div>
); );
}); });
......
...@@ -239,7 +239,7 @@ const SaveCustomTemplate = (props: IProps) => { ...@@ -239,7 +239,7 @@ const SaveCustomTemplate = (props: IProps) => {
helperText={versionHelper.helperText} helperText={versionHelper.helperText}
style={{ marginBottom: "20px" }} style={{ marginBottom: "20px" }}
></MyInput> ></MyInput>
<div style={{ position: "relative" }}> <div style={{ position: "relative", paddingBottom: "20px" }}>
<MyInput <MyInput
value={description} value={description}
id="desc" id="desc"
......
import VirtuallyList from "@/components/CommonComponents/VirtuallyList"; import VirtuallyList from "@/components/CommonComponents/VirtuallyList";
import VirtuallyTable from "@/components/CommonComponents/VirtuallyTable";
import MyButton from "@/components/mui/MyButton";
const VirtuallyListDemo = () => { const VirtuallyListDemo = () => {
let listData: Array<any> = []; let listData: Array<any> = [];
...@@ -16,10 +18,6 @@ const VirtuallyListDemo = () => { ...@@ -16,10 +18,6 @@ const VirtuallyListDemo = () => {
parent, parent,
style, style,
}: any) => { }: any) => {
// const name = listData[index].name;
// // const content = isScrolling ? "..." : <div>{name}</div>;
// const content = <div>{name}</div>;
return ( return (
<div key={key} style={style}> <div key={key} style={style}>
<div <div
...@@ -40,32 +38,81 @@ const VirtuallyListDemo = () => { ...@@ -40,32 +38,81 @@ const VirtuallyListDemo = () => {
</div> </div>
); );
}; };
const rows = [
{
a: "啊手动阀建行卡实际付款啦即使对方卢卡库上的飞机啊离开解放了;拉萨的飞机拉萨酱豆腐啊肌肤抵抗力就",
b: "werewrw",
c: "asdfasf",
d: "asdfasdf",
e: "asd4534",
id: "1",
},
];
for (let i = 0; i < 10000; i++) {
rows.push({
a: "xcgh",
b: "sdf",
c: "sdfg",
d: "sdfg",
e: "wertwe",
id: "12" + i,
});
}
const buttonHeadCells = [
{
id: "a",
label: "属性a",
width: 150,
},
{
id: "b",
label: "属性b",
width: 150,
},
{
id: "c",
label: "属性c",
width: 150,
flexGrow: 2,
},
{
id: "d",
label: "属性d",
width: 200,
flexGrow: 2,
},
{
id: "caozuo",
label: "操作",
width: 150,
cellRenderer: (data: any) => {},
},
];
return ( return (
<div> <div>
<div> <div>
<VirtuallyList list={listData} renderRow={renderRow}></VirtuallyList>; {/* <VirtuallyList list={listData} renderRow={renderRow}></VirtuallyList>; */}
</div> </div>
<div style={{ width: "300px", height: "300px", overflow: "auto" }}> <div style={{ height: "600px" }}>
{listData.map((item, index) => { <VirtuallyTable
return ( // rows={rows}
<div rows={rows.map((row) => {
key={index} return {
style={{ ...row,
display: "flex", // caozuo: (
justifyContent: "space-between", // <MyButton
alignItems: "center", // text="删除"
}} // onClick={() => {
> // // handleDelete(row.id);
<div>{listData[index].name}</div> // }}
<div>{listData[index].name}</div> // ></MyButton>
<div>{listData[index].name}</div> // ),
<div>{listData[index].name}</div> };
<div>{listData[index].name}</div> })}
<div>{listData[index].name}</div> headCells={buttonHeadCells}
<div>{listData[index].name}</div> />
</div>
);
})}
</div> </div>
</div> </div>
); );
......
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