Commit 5722a4a5 authored by wuhao's avatar wuhao 🎯

kiu

parent a5dffbe5
...@@ -11,7 +11,7 @@ export default { ...@@ -11,7 +11,7 @@ export default {
// localhost:8000/api/** -> https://preview.pro.ant.design/api/** // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
"/wms/": { "/wms/": {
// 要代理的地址 // 要代理的地址
target: "http://192.168.40.215:18040/", //39:18040 23/wms/ //60 翔 //18 target: "http://192.168.40.114:18040/", //39:18040 23/wms/ //60 翔 //18
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
"^/wms": "", "^/wms": "",
......
...@@ -84,7 +84,6 @@ export default (props) => { ...@@ -84,7 +84,6 @@ export default (props) => {
return <div style={{ height: 32, width: 64 }}></div> return <div style={{ height: 32, width: 64 }}></div>
} else { } else {
let strarr = props.pageextra ? props.pageextra.split(",") : ["add"]; let strarr = props.pageextra ? props.pageextra.split(",") : ["add"];
console.log(strarr);
return strarr.map((it, i) => { return strarr.map((it, i) => {
return <div style={{ marginRight: i == strarr.length - 1 ? 0 : 6 }}> return <div style={{ marginRight: i == strarr.length - 1 ? 0 : 6 }}>
{actionbtn[it]} {actionbtn[it]}
...@@ -95,22 +94,22 @@ export default (props) => { ...@@ -95,22 +94,22 @@ export default (props) => {
// screens.xs ? (
// <div
// style={{ display: "flex", flexDirection: "column", height: "100%" }}
// >
// {props.children && (
// <div style={{ marginBottom: 12 }}>{props.children}</div>
// )}
// <div>
// <Mcard {...props} pageextra={renderextra()}/>
// </div>
// </div>
// ) :
return ( return (
<div className="diycard"> <div className="diycard">
{screens.xs ? ( {props.withCard === false ? (
<div
style={{ display: "flex", flexDirection: "column", height: "100%" }}
>
{props.children && (
<div style={{ marginBottom: 12 }}>{props.children}</div>
)}
<div>
<Mcard {...props} />
</div>
</div>
) : props.withCard === false ? (
<div style={{ display: "flex", width: "100%" }}> <div style={{ display: "flex", width: "100%" }}>
{(props.childposition == "left" || !props.childposition) && {(props.childposition == "left" || !props.childposition) &&
props.children} props.children}
......
...@@ -124,7 +124,7 @@ class Mcard extends PureComponent { ...@@ -124,7 +124,7 @@ class Mcard extends PureComponent {
if ( if (
this.props.path != np.path || this.props.path != np.path ||
JSON.stringify(this.props.extraparams) != JSON.stringify(this.props.extraparams) !=
JSON.stringify(np.extraparams) || JSON.stringify(np.extraparams) ||
JSON.stringify(this.props.dataSource) != JSON.stringify(np.dataSource) JSON.stringify(this.props.dataSource) != JSON.stringify(np.dataSource)
) { ) {
this.lv.scrollTo(0); this.lv.scrollTo(0);
...@@ -192,16 +192,16 @@ class Mcard extends PureComponent { ...@@ -192,16 +192,16 @@ class Mcard extends PureComponent {
render() { render() {
let { let {
scrolltop, scrolltop,
dataSource, dataSource,
isLoading, isLoading,
refreshing, refreshing,
hasMore, hasMore,
isEmpty, isEmpty,
visible, visible,
fields, fields,
searchlist, searchlist,
} = this.state, } = this.state,
{ {
columns, columns,
cardtitle, cardtitle,
...@@ -214,6 +214,7 @@ class Mcard extends PureComponent { ...@@ -214,6 +214,7 @@ class Mcard extends PureComponent {
tabList, tabList,
} = this.props; } = this.props;
return ( return (
<div style={{ height: "100%" }}> <div style={{ height: "100%" }}>
<div className="fixedsearch"> <div className="fixedsearch">
...@@ -229,10 +230,15 @@ class Mcard extends PureComponent { ...@@ -229,10 +230,15 @@ class Mcard extends PureComponent {
<SearchOutlined style={{ color: "#fff" }} /> <SearchOutlined style={{ color: "#fff" }} />
</div> </div>
)} )}
{pageextra && {
pageextra.map((it) => { pageextra ?
return <div>{it}</div>; Array.isArray(pageextra) ?
})} pageextra.map((it) => {
return <div>{it}</div>;
}) :
pageextra
: null
}
</div> </div>
<Drawer <Drawer
...@@ -247,7 +253,7 @@ class Mcard extends PureComponent { ...@@ -247,7 +253,7 @@ class Mcard extends PureComponent {
> >
<InitForm <InitForm
fields={fields} fields={fields}
onChange={() => {}} onChange={() => { }}
reset={true} reset={true}
submitData={(values) => { submitData={(values) => {
this.onRefresh(this.props, values); this.onRefresh(this.props, values);
...@@ -327,8 +333,8 @@ class Mcard extends PureComponent { ...@@ -327,8 +333,8 @@ class Mcard extends PureComponent {
columns.filter((it) => it.valueType == "option").length == 0 columns.filter((it) => it.valueType == "option").length == 0
? null ? null
: columns : columns
.filter((it) => it.valueType == "option")[0] .filter((it) => it.valueType == "option")[0]
?.render(null, rowData, null, { type: "text" }) ?.render(null, rowData, null, { type: "text" })
} }
> >
<Row> <Row>
......
...@@ -29,7 +29,8 @@ class Mtable extends PureComponent { ...@@ -29,7 +29,8 @@ class Mtable extends PureComponent {
JSON.stringify(nextprops.extraparams) || JSON.stringify(nextprops.extraparams) ||
JSON.stringify(this.props.path) != JSON.stringify(nextprops.path) || JSON.stringify(this.props.path) != JSON.stringify(nextprops.path) ||
JSON.stringify(this.props.refreshDep) != JSON.stringify(this.props.refreshDep) !=
JSON.stringify(nextprops.refreshDep) JSON.stringify(nextprops.refreshDep) ||
this.props.columns != nextprops.columns
) { ) {
if (nextprops.actionRef) { if (nextprops.actionRef) {
nextprops.actionRef?.current?.reload(); nextprops.actionRef?.current?.reload();
......
import React, { useState, useEffect, memo } from "react";
import {
Table,
Divider,
Card,
Descriptions,
Typography,
Spin,
Row,
Col,
Tooltip,
Rate,
Image,
} from "antd";
import { doFetch, postFetch } from "@/utils/doFetch";
import AutoTable from "@/components/Tableform";
import styles from "./index.less";
const Details = (props) => {
/**
* dataSource: 整个页面的数据,Object
* totalPath: 整个详情页的接口,String
* totalParams: 整个详情页接口的参数
* totalCard: 整个页面的模块,Array
* col: 列数
*
* totalCard中的每一项变量:cardTitle每一个模块的标题;itemData每一个模块的数据信息(Array)
* itemData中的每一项变量:key所对应的字段;title每一项label标题;type每一项的类型(file,img,textarea,table,不填默认就是普通的展示类型);col每一项的占比;columns表格类型所用;path当类型为表格时,若该表格是单独查询出来的可以填入path;urlName 当传入文件为url为字符串时
*
*/
const {
totalPath = "",
dataSource,
totalCard,
totalParams,
col,
bottomNode,
topNode,
} = props;
const [pageData, cp] = useState({});
useEffect(() => {
if (dataSource) {
cp(dataSource);
} else if (!dataSource && !Array.isArray(totalPath)) {
doFetch({
url: totalPath,
params: totalParams ? { ...totalParams } : {},
}).then((res) => {
if (res.code == "0000") {
if (!res.data) {
return;
}
cp(res?.data?.data);
}
});
}
}, []);
const getCol = (itemcol) => {
if (itemcol) {
return itemcol;
} else {
return col ? col : { xs: 24, sm: 24, md: 12, lg: 8, xl: 8, xxl: 6 };
}
};
//获取每一项
const getItem = (itemData) => {
const {
type,
key,
title,
columns,
path,
urlName,
col,
rowKey,
expandable,
} = itemData,
value = pageData[key];
if (!type || type == "input") {
return value == 0 || value ? (
<Tooltip title={`${title}:${value}`}>
<pre className={col ? "" : styles.one}>{value}</pre>
</Tooltip>
) : (
<div>-</div>
);
} else if (type == "file") {
return (
<div style={{ display: "flex", flexFlow: "row wrap", width: "100%" }}>
{value && typeof value == "string" ? (
<a
href={value}
download={value}
style={{ margin: "0 10px 0 0", display: "block" }}
>
{urlName ? urlName : "下载"}
</a>
) : value && Array.isArray(value) && value?.length ? (
value?.map((el) => {
return (
<a
key={el.url}
href={el.url}
download={el.name}
style={{ margin: "0 10px 0 0", display: "block" }}
>
{el.name}
</a>
);
})
) : (
"-"
)}
</div>
);
} else if (type == "img") {
return (
<div style={{ display: "flex", flexFlow: "row wrap" }}>
{value && value?.length
? value?.map((el) => {
return (
<Image
style={{ margin: "0 10px 0 0" }}
src={el?.url}
width={30}
height={30}
key={el?.uid}
></Image>
);
})
: "-"}
</div>
);
} else if (type == "table") {
return (
<AutoTable
columns={columns || []}
path={path ? path : null}
bordered={false}
dataSource={path ? null : value}
rowKey={rowKey ?? "id"}
expandable={expandable ?? null}
></AutoTable>
);
} else if (type == "rate") {
return (
<Rate
bordered={false}
className={"simple"}
style={{ width: "100%" }}
disabled={itemData.disabled}
allowHalf={itemData.allowHalf ? itemData.allowHalf : false}
value={value || 0}
/>
);
}
};
return (
<div className={`${styles.bodyBox} detailCards`}>
<Spin spinning={false}>
{topNode && <div>{topNode}</div>}
{totalCard?.map((item, i) => {
return (
<Card
key={i}
title={item.cardTitle}
bordered={false}
style={{ marginBottom: 16 }}
bodyStyle={{ padding: "16px 10px" }}
>
<Row gutter={[12, 12]}>
{item?.itemData?.map((it, j) => {
return (
<Col key={j} {...getCol(it.col)}>
<div style={{ width: "100%", display: "flex" }}>
<div
style={{
flexShrink: 0,
display: `${it.title ? "block" : "none"}`,
textAlign: "right",
width: 126,
}}
>
{it.title}
</div>
{getItem(it)}
</div>
</Col>
);
})}
</Row>
</Card>
);
})}
{bottomNode && <div>{bottomNode}</div>}
</Spin>
</div>
);
};
export default memo(Details);
import InitForm from "../InitForm"; import InitForm from "../InitForm";
import { Drawer } from "antd"; import { Drawer } from "antd";
import React, { useState, memo } from "react"; import React, { useState, memo } from "react";
import Details from "../Details/detail";
// title="Basic Drawer" // title="Basic Drawer"
// placement="right" // placement="right"
// closable={false} // closable={false}
...@@ -10,20 +10,36 @@ import React, { useState, memo } from "react"; ...@@ -10,20 +10,36 @@ import React, { useState, memo } from "react";
// getContainer={false} // getContainer={false}
// style={{ position: 'absolute' }} // style={{ position: 'absolute' }}
// drawer props + initform props + detial props
function DrawInitForm(props) { function DrawInitForm(props) {
let newProps = { ...props }; let newProps = { ...props };
delete newProps.children; delete newProps.children;
const detailprops = {
totalPath: props.totalPath,
dataSource: props.detaildataSource,
totalCard: props.totalCard,
totalParams: props.totalParams,
col: props.col,
bottomNode: props.bottomNode,
topNode: props.topNode,
}
return ( return (
<Drawer <Drawer
maskClosable={false} maskClosable={false}
placement="right" placement="right"
closable={true} closable={true}
getContainer={false} getContainer={false}
style={{ position: "absolute",transform:"translateX(0)" }} style={{ position: "absolute", transform: "translateX(0)" }}
width={props.val == "detail" ? 1000 : props.width}
destroyOnClose={true}
{...props} {...props}
> >
{props.children} {props.children}
<InitForm {...newProps}></InitForm> {props.val == "detail" ? <Details {...detailprops}></Details> : <InitForm {...newProps}></InitForm>}
</Drawer> </Drawer>
); );
} }
......
import React, { useEffect } from "react"; import React, { useEffect, useRef } from "react";
import { EditableProTable } from "@ant-design/pro-table"; import { EditableProTable } from "@ant-design/pro-table";
import ProField from "@ant-design/pro-field"; import ProField from "@ant-design/pro-field";
import ProCard from "@ant-design/pro-card"; import ProCard from "@ant-design/pro-card";
...@@ -11,7 +11,9 @@ const EditTable = ({ ...@@ -11,7 +11,9 @@ const EditTable = ({
rowKey, rowKey,
recordCreatorProps, recordCreatorProps,
maxLength, maxLength,
linkconfig
}) => { }) => {
const editorFormRef = useRef()
return ( return (
<EditableProTable <EditableProTable
columns={columns} columns={columns}
...@@ -22,20 +24,91 @@ const EditTable = ({ ...@@ -22,20 +24,91 @@ const EditTable = ({
recordCreatorProps == "false" recordCreatorProps == "false"
? false ? false
: { : {
newRecordType: "dataSource", newRecordType: "dataSource",
record: () => ({ record: () => ({
[rowKey]: Date.now(), [rowKey]: Date.now(),
}), }),
} }
} }
editableFormRef={editorFormRef}
editable={{ editable={{
type: "multiple", type: "multiple",
editableKeys: value ? value.map((item) => item[rowKey]) : [], editableKeys: value ? value.map((item) => item[rowKey]) : [],
actionRender: (row, config, defaultDoms) => { actionRender: (row, config, defaultDoms) => {
return [defaultDoms.delete]; return [defaultDoms.delete];
}, },
onValuesChange: (record, recordList) => { onValuesChange: async (record, recordList) => {
onChange(recordList);
let { urlchangeval } = linkconfig ?? {};
let newvalue = [...recordList];
if (urlchangeval && record) {//根据url 改变 数据值
let { params, database, effectresult } = urlchangeval ?? {},
curvaluerow = value && value.length > 0 ? value.filter(it => it[rowKey] == record[rowKey])[0] : {}
//获取除本行之外已修改的value值
newvalue = newvalue.map((it, i) => {
if (!record) return it;
if (it[rowKey] == record[rowKey]) {
let freshvals = {}
Object.keys(effectresult).map(its => {
freshvals[its] = value[i][its]
})
it = {
...record,
...freshvals
}
} else {
it = value && value.length > 0 ? value.filter(its => its[rowKey] == it[rowKey])[0] : {}
}
return it
});
//参数获取
let parames = {};
let ifs = false;
Object.keys(params).map(it => {
if (params[it] == "linked") {
parames[it] = record[it]
if (record[it] == curvaluerow[it]) {
ifs = true;
}
} else {
parames[it] = params[it]
}
})
if (ifs) {
//值未变化
} else {
let res = await database(parames);
console.log(newvalue);
newvalue = newvalue.map((it, i) => {
if (it[rowKey] == record[rowKey]) {
Object.keys(effectresult).map(items => {
it[items] = res?.data?.data[effectresult[items]];
})
}
editorFormRef.current?.setRowData?.(i, it)
return it
})
};
}
onChange(newvalue);
}, },
}} }}
maxLength={maxLength ?? 1000} maxLength={maxLength ?? 1000}
......
...@@ -557,6 +557,9 @@ let InitForm = ({ ...@@ -557,6 +557,9 @@ let InitForm = ({
// formartSubmit(values); // formartSubmit(values);
}} }}
onValuesChange={(changedValues, values) => { onValuesChange={(changedValues, values) => {
console.log('====================================')
console.log(changedValues)
console.log('====================================')
let newvalue = {}; let newvalue = {};
let linkkey = Object.keys(changedValues)[0]; let linkkey = Object.keys(changedValues)[0];
//联动逻辑 //联动逻辑
...@@ -1187,6 +1190,7 @@ let InitForm = ({ ...@@ -1187,6 +1190,7 @@ let InitForm = ({
recordCreatorProps={item.recordCreatorProps} recordCreatorProps={item.recordCreatorProps}
value={item.value} value={item.value}
maxLength={item.maxLength} maxLength={item.maxLength}
linkconfig={item.linkconfig}
></EditTable> ></EditTable>
</Form.Item> </Form.Item>
</Col> </Col>
......
...@@ -273,7 +273,7 @@ const Materiel = (props) => { ...@@ -273,7 +273,7 @@ const Materiel = (props) => {
dataIndex: "option_dataindex", dataIndex: "option_dataindex",
key: "option_dataindex", key: "option_dataindex",
valueType: "option", valueType: "option",
width: 275, width: 160,
render: (text, row, _, action) => extraAction(text, row, _, action), render: (text, row, _, action) => extraAction(text, row, _, action),
}, },
]; ];
......
This diff is collapsed.
This diff is collapsed.
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