Commit 406ebf91 authored by wuhao's avatar wuhao 🎯

kildler

parent 2b7e6c2d
...@@ -2,6 +2,7 @@ import React, { Component } from "react"; ...@@ -2,6 +2,7 @@ import React, { Component } from "react";
import { Resizable } from "react-resizable"; import { Resizable } from "react-resizable";
function Resizecell({ onResize, onResizeStop, width, onClick, ...restProps }) { function Resizecell({ onResize, onResizeStop, width, onClick, ...restProps }) {
return ( return (
<Resizable <Resizable
width={width??1} width={width??1}
......
...@@ -4,7 +4,6 @@ import Mtable from "./mtable"; ...@@ -4,7 +4,6 @@ import Mtable from "./mtable";
import getPrem from "@/utils/getPrem"; //权限判断fn import getPrem from "@/utils/getPrem"; //权限判断fn
import { ExportOutlined } from "@ant-design/icons"; import { ExportOutlined } from "@ant-design/icons";
const { useBreakpoint } = Grid; const { useBreakpoint } = Grid;
function isString(obj) { function isString(obj) {
...@@ -43,57 +42,62 @@ function isString(obj) { ...@@ -43,57 +42,62 @@ function isString(obj) {
// onTabChange // onTabChange
// } // }
export default (props) => { export default (props) => {
const screens = useBreakpoint(); const screens = useBreakpoint();
const actionbtn = { const actionbtn = {
add: <Button add: (
<Button
key={"add"} key={"add"}
disabled={props?.addconfig?.disabled || !getPrem(props?.addconfig?.premkey ?? "", "ifs")} disabled={
props?.addconfig?.disabled ||
!getPrem(props?.addconfig?.premkey ?? "", "ifs")
}
type="primary" type="primary"
{...props?.addconfig?.btnprops} {...props?.addconfig?.btnprops}
onClick={() => { onClick={() => {
props?.addconfig?.onClick?.() props?.addconfig?.onClick?.();
}} }}
> >
新增 新增
</Button>, </Button>
export: <Button ),
export: (
<Button
key={"add"} key={"add"}
disabled={props?.exportconfig?.disabled || !getPrem(props?.exportconfig?.premkey ?? "", "ifs")} disabled={
props?.exportconfig?.disabled ||
!getPrem(props?.exportconfig?.premkey ?? "", "ifs")
}
type="danger" type="danger"
icon={<ExportOutlined />} icon={<ExportOutlined />}
{...props?.exportconfig?.btnprops} {...props?.exportconfig?.btnprops}
onClick={() => { onClick={() => {
props?.exportconfig?.onClick?.() props?.exportconfig?.onClick?.();
}} }}
> >
导出 导出
</Button> </Button>
),
} };
//右上角 pageextra 类型 1.reactDom 2.string 以逗号隔开 为none时不显示 //右上角 pageextra 类型 1.reactDom 2.string 以逗号隔开 为none时不显示
const renderextra = () => { const renderextra = () => {
if (props.pageextra && !isString(props.pageextra)) { if (props.pageextra && !isString(props.pageextra)) {
return props.pageextra return props.pageextra;
} else if (props.pageextra === "none") { } else if (props.pageextra === "none") {
return <div style={{ height: 32, width: 64 }}></div> return <div style={{ height: 32, width: 64 }}></div>;
} else if (props.pageextra) { } else if (props.pageextra) {
let strarr = props.pageextra ? props.pageextra.split(",") : ["add"]; let strarr = props.pageextra ? props.pageextra.split(",") : ["add"];
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]}
</div> </div>
}) );
} });
} }
};
// screens.xs ? ( // screens.xs ? (
// <div // <div
// style={{ display: "flex", flexDirection: "column", height: "100%" }} // style={{ display: "flex", flexDirection: "column", height: "100%" }}
......
import React, { PureComponent } from "react";
import ProTable from "@ant-design/pro-table";
import request from "umi-request";
import Resizecell from "./Resizecell";
import { Tooltip } from "antd";
import { doFetch } from "@/utils/doFetch";
import bodyParse from "@/utils/bodyParse";
let defaultsize = localStorage.getItem("size"); //设置缓存
class Mtable extends PureComponent {
constructor(props) {
super(props);
let { columns } = this.props;
this.state = {
total: 0,
size: defaultsize ? defaultsize : "small",
columns: columns,
valueColumns: {},
};
}
actionRefs = React.createRef();
formRefs = React.createRef();
componentWillReceiveProps(nextprops) {
if (
JSON.stringify(this.props.extraparams) !=
JSON.stringify(nextprops.extraparams) ||
JSON.stringify(this.props.path) != JSON.stringify(nextprops.path) ||
JSON.stringify(this.props.refreshDep) !=
JSON.stringify(nextprops.refreshDep) ||
this.props.columns != nextprops.columns
) {
if (nextprops.actionRef) {
nextprops.actionRef?.current?.reset();
} else {
this.actionRefs?.current?.reset();
}
this.initDrage(nextprops);
}
}
componentDidMount() {
this.initDrage();
}
//初始化操作数据
initDrage = (nextprops) => {
let curprops = nextprops ?? this.props;
let { extraparams, path, activeTabKey, columns } = curprops;
if (!path) return;
doFetch({
url: "/ngic-base-business/paFieldScene/queryContro",
params: {
sceneMark: extraparams
? path + bodyParse(extraparams)
: activeTabKey
? path + activeTabKey
: path,
},
}).then((res) => {
if (res.code == "0000") {
//datalist:接口返回状态
let datalist = {};
res?.data?.dataList &&
res.data.dataList.map((it) => {
const { fieldKey, fieldWidth, fieldOrder, fieldFixed, fieldShow } =
it ?? {};
datalist[fieldKey] = {
width: fieldWidth,
order: fieldOrder,
fixed:
fieldKey == "option" || fieldKey == "option_dataindex"
? "right"
: fieldFixed,
show: fieldShow,
};
});
//allcol 默认状态设置 valueColumns 为columns全列设置
let allcol = {};
columns.map((it, i) => {
if (it.valueType == "option") {
allcol.option = {
order: columns.length - 1,
show: true,
fixed: "right",
...datalist.option,
};
} else {
allcol[it.key] = {
order: i,
show: true,
...datalist[it.key],
};
}
});
//columns 列属性添加
let columnes = columns.map((it, index) => {
if (it.valueType == "select" || it.valueType == "checkbox") {
if (Array.isArray(it.options)) {
it.fieldProps = {
options: [...it.options],
};
} else {
it.request = async function () {
let list = await it.options.database(it.options.params);
return list.data.dataList;
};
}
}
if (it.valueType == "option") {
it.key = "option";
it.dataIndex = "option";
it.fixed = "right";
}
let itemwidth = allcol[it.key]?.width
? allcol[it.key].width
: it.width
? it.width
: 160;
return {
...it,
width: itemwidth,
onHeaderCell: (column) => ({
width: column.width ?? itemwidth,
onResize: this.handleResize(index),
onResizeStop: this.handleResizeStop(index),
}),
render: it.render
? it.render
: (text, row) => {
return (
<Tooltip title={row[it.dataIndex]} placement="topLeft">
<span className="table-cell">
{row[it.dataIndex] ?? "-"}
</span>
</Tooltip>
);
},
};
});
this.setState({
valueColumns: allcol,
columns: columnes,
});
}
});
};
//缩放表格
handleResize =
(index) =>
(e, { size }) => {
e.stopImmediatePropagation();
this.setState(({ columns }) => {
const nextColumns = [...columns];
nextColumns[index] = {
...nextColumns[index],
width: size.width,
};
return { columns: nextColumns };
});
};
//更新表格缩放
handleResizeStop =
(index) =>
(e, { size }) => {
e.stopImmediatePropagation();
let { extraparams, activeTabKey, path } = this.props;
let submitdata = this.state.valueColumns ?? {},
curkey = Object.keys(submitdata)[index];
submitdata[curkey].width = parseInt(size.width);
this.setState(
{
valueColumns: submitdata,
},
() => {
doFetch({
url: "/ngic-base-business/paFieldScene/save",
params: {
sceneMark: extraparams
? path + bodyParse(extraparams)
: activeTabKey
? path + activeTabKey
: path,
controList: Object.keys(submitdata).map((it, i) => {
return {
fieldKey: it,
fieldWidth:
i == index ? parseInt(size.width) : submitdata[it].width,
fieldOrder: submitdata[it].order,
fieldFixed: submitdata[it].fixed,
fieldShow: submitdata[it].show,
};
}),
},
});
}
);
};
render() {
let {
pageSize,
x,
y,
style,
dataSource,
onSearchChange,
defaultPageSize,
pagination, //分页
rowKey, //行key
actionRef, //操作ref
formRef, //查询表单ref
path, //路径
activeTabKey, //当前tab
extraparams, //拓展查询参数
rowSelection, //行选择
tableRender, //表格布局自定义
getDefaultSelected, //获取默认选中的数据
rowClassNameFn, //选中后行样式
showQuickJumper, //false字符串 不显示
expandable, //是否可展开
onRow,
} = this.props,
{ total, size } = this.state;
let tabledataProps =
dataSource && Array.isArray(dataSource)
? {
dataSource,
pagination: {
showTotal: (total, range) => <span>{total}</span>,
showQuickJumper: false,
showSizeChanger: true,
defaultPageSize: defaultPageSize ? defaultPageSize : 15,
pageSizeOptions: [10, 15, 30, 50, 100, 200],
total: dataSource.length,
},
search: {
filterType: "light", //轻量模式
},
toolBarRender: false,
}
: {
request: async (params = {}) => {
//表格数据获取 只需要传入url自动获得数据
if (!path) {
return;
}
//设置token
let token = localStorage.getItem("TOKENS")
? localStorage.getItem("TOKENS")
: "9410b3f7de5d63f2be42d80ec8241d2d";
let headers = {
"Content-Type": "application/json",
token: token ? token : "",
},
newextraparams = extraparams ?? {};
//处理传参 extraparams为除列筛选外的自定义传参
let newparams = {
...params,
...newextraparams, //父组件传参
pageIndex: params.current,
pageSize: params.pageSize || pageSize,
};
delete newparams.current;
if (pagination == "false") {
delete newparams.pageIndex;
delete newparams.pageSize;
}
let res = await request("/wms" + path, {
body: JSON.stringify(newparams ? newparams : {}),
headers,
method: "POST",
});
return {
data: res.data,
total: res?.data?.total || res?.data?.dataList?.length,
};
},
pagination: {
showTotal: (total, range) => <span>{total}</span>,
showQuickJumper: !showQuickJumper ? true : false,
showSizeChanger: true,
pageSizeOptions: [5, 10, 15, 30, 50, 100, 200],
defaultPageSize: pageSize || 15,
total,
},
search: {
filterType: "light", //轻量模式
},
};
return (
<ProTable
size={size}
onSubmit={(params) => {
onSearchChange && onSearchChange(params);
}}
onSizeChange={(size) => {
localStorage.setItem("size", size); //设置全局表格规格缓存
this.setState({
size,
});
}}
columns={this.state.columns}
style={style || {}}
actionRef={actionRef ? actionRef : this.actionRefs}
formRef={formRef ? formRef : this.formRefs}
rowKey={rowKey ? rowKey : "id"} //表格每行数据的key
dateFormatter="string"
postData={(data) => {
if (data.page) {
this.setState({
total: data.page.total,
});
} else {
this.setState({
total: data.dataList.length,
});
}
//分页or不分页获取数据
getDefaultSelected && getDefaultSelected(data); //存在默认选中向上返回选中值
let defaultval =
pagination == "false"
? data.dataList
: data.page
? data.page.list
: []; //分页或不分页的接口返回数据
return defaultval;
}}
components={{
header: {
cell: Resizecell,
},
}}
rowSelection={rowSelection ? rowSelection : false}
tableRender={
tableRender ? (_, dom) => tableRender(_, dom) : (_, dom) => dom
} //自定义表格主体
rowClassName={
rowClassNameFn ? (record, index) => rowClassNameFn(record, index) : ""
} //自定义行高亮
columnsState={{
value: this.state.valueColumns,
onChange: (val, state) => {
let submitdata = {
...this.state.valueColumns,
...val,
};
this.setState(
{
valueColumns: submitdata,
},
(state) => {
if (!this.props.path) return;
doFetch({
url: "/ngic-base-business/paFieldScene/save",
params: {
sceneMark: extraparams
? path + bodyParse(extraparams)
: activeTabKey
? path + activeTabKey
: path,
controList: Object.keys(submitdata).map((it) => {
return {
fieldKey: it,
fieldWidth: submitdata[it].width,
fieldOrder: submitdata[it].order,
fieldFixed: submitdata[it].fixed,
fieldShow: submitdata[it].show,
};
}),
},
});
}
);
},
}}
scroll={{
x: x ?? 1024,
}}
{...tabledataProps}
{...expandable}
onRow={onRow ? (record) => onRow(record) : null}
/>
);
}
}
export default Mtable;
import React, { PureComponent } from "react"; import React, {
PureComponent,
useEffect,
useRef,
useState,
useMemo,
} from "react";
import ProTable from "@ant-design/pro-table"; import ProTable from "@ant-design/pro-table";
import request from "umi-request"; import request from "umi-request";
import Resizecell from "./Resizecell"; import Resizecell from "./Resizecell";
import { Tooltip } from "antd"; import { Tooltip } from "antd";
import { doFetch } from "@/utils/doFetch"; import { doFetch } from "@/utils/doFetch";
import bodyParse from "@/utils/bodyParse"; import { useAsyncEffect } from "ahooks";
let defaultsize = localStorage.getItem("size"); //设置缓存 const Mtable = (props) => {
const {
actionRef, //表格动作
formRef, //表单Ref
rowKey, // key
columns, //columns
style, //style
path, //接口地址
extraparams, //额外参数
pageSize, //修改默认pageSize
pagination, //分页设置
x, //横向滚动
activeTabKey, //激活的tabKey 拖拽表格唯一标识使用 其他情况用不到
refreshDep, //依赖刷新 (已废弃)
} = props;
class Mtable extends PureComponent { const actionRefs = actionRef ?? useRef(),
constructor(props) { formRefs = formRef ?? useRef(),
super(props); ifspagination = pagination == "false" || pagination === false,
let { columns } = this.props; [size, setsize] = useState("small"),
this.state = { [valueColumns, setvalueColumns] = useState([]);
total: 0, const [columnes, setcolumnes] = useState(columns ?? []);
size: defaultsize ? defaultsize : "small",
columns: columns, //调用接口
valueColumns: {}, const request = async (params, sort, filter) => {
if (!path) return;
let newparams = {
...params,
...extraparams, //父组件传参
pageIndex: params.current,
pageSize: params.pageSize || pageSize,
}; };
delete newparams.current;
if (ifspagination) {
delete newparams.pageIndex;
delete newparams.pageSize;
} }
const result = await doFetch({ url: path, params: newparams });
actionRefs = React.createRef(); //分页结果
formRefs = React.createRef(); let data = result?.data?.page?.list,
success = true,
componentWillReceiveProps(nextprops) { total = result?.data?.page?.total;
if ( //不带分页获取结果
JSON.stringify(this.props.extraparams) != if (ifspagination) {
JSON.stringify(nextprops.extraparams) || data = result?.data?.dataList;
JSON.stringify(this.props.path) != JSON.stringify(nextprops.path) || total = result?.data?.dataList?.length;
JSON.stringify(this.props.refreshDep) != }
JSON.stringify(nextprops.refreshDep) || console.log(result, {
this.props.columns != nextprops.columns data,
) { success,
if (nextprops.actionRef) { total,
nextprops.actionRef?.current?.reset(); });
} else { return {
this.actionRefs?.current?.reset(); data,
success,
total,
};
};
//更新 columns
useEffect(() => {
setcolumnes((s) => {
return s.map((it, index) => {
let itemwidth = valueColumns[it.key]?.width
? valueColumns[it.key].width
: it.width
? it.width
: 160;
let options = {};
if (it.valueType == "select" || it.valueType == "checkbox") {
if (Array.isArray(it.options)) {
options = {
fieldProps: {
options: [...it.options],
},
};
} else if (it.options) {
options = {
request: async (params) => {
console.log(it.options.database);
let list = await it?.options?.database(
it.options?.params ?? {}
);
return list.data.dataList;
},
};
} }
this.initDrage(nextprops);
} }
if (it.valueType == "option") {
options = {
key: "option",
dataIndex: "option",
fixed: "right",
};
} }
if (!it.render) {
componentDidMount() { options = {
this.initDrage(); ...options,
render: (text, row) => {
return (
<Tooltip title={row[it.dataIndex]} placement="topLeft">
<span className="table-cell">{row[it.dataIndex] ?? "-"}</span>
</Tooltip>
);
},
};
} }
options = {
...options,
width: itemwidth,
};
return {
...it,
...options,
onHeaderCell: (column) => ({
width: column.width ?? itemwidth,
onResize: handleResize(index),
onResizeStop: handleResizeStop(index),
}),
};
});
});
}, [columns, valueColumns]);
//初始化操作数据 //初始化操作数据
initDrage = (nextprops) => { const initDrage = async () => {
let curprops = nextprops ?? this.props;
let { extraparams, path, activeTabKey, columns } = curprops;
if (!path) return; if (!path) return;
doFetch({ let res = await doFetch({
url: "/ngic-base-business/paFieldScene/queryContro", url: "/ngic-base-business/paFieldScene/queryContro",
params: { params: {
sceneMark: extraparams sceneMark: extraparams
...@@ -58,7 +149,7 @@ class Mtable extends PureComponent { ...@@ -58,7 +149,7 @@ class Mtable extends PureComponent {
? path + activeTabKey ? path + activeTabKey
: path, : path,
}, },
}).then((res) => { });
if (res.code == "0000") { if (res.code == "0000") {
//datalist:接口返回状态 //datalist:接口返回状态
let datalist = {}; let datalist = {};
...@@ -94,91 +185,41 @@ class Mtable extends PureComponent { ...@@ -94,91 +185,41 @@ class Mtable extends PureComponent {
}; };
} }
}); });
//columns 列属性添加 setvalueColumns(allcol);
let columnes = columns.map((it, index) => {
if (it.valueType == "select" || it.valueType == "checkbox") {
if (Array.isArray(it.options)) {
it.fieldProps = {
options: [...it.options],
};
} else {
it.request = async function () {
let list = await it.options.database(it.options.params);
return list.data.dataList;
};
}
}
if (it.valueType == "option") {
it.key = "option";
it.dataIndex = "option";
it.fixed = "right";
} }
let itemwidth = allcol[it.key]?.width
? allcol[it.key].width
: it.width
? it.width
: 160;
return {
...it,
width: itemwidth,
onHeaderCell: (column) => ({
width: column.width ?? itemwidth,
onResize: this.handleResize(index),
onResizeStop: this.handleResizeStop(index),
}),
render: it.render
? it.render
: (text, row) => {
return (
<Tooltip title={row[it.dataIndex]} placement="topLeft">
<span className="table-cell">
{row[it.dataIndex] ?? "-"}
</span>
</Tooltip>
);
},
}; };
});
this.setState({ //调用重新渲染表格
valueColumns: allcol, useAsyncEffect(async () => {
columns: columnes, await initDrage();
}); }, [extraparams, path, activeTabKey, refreshDep]);
}
});
};
//缩放表格 //缩放表格
handleResize = const handleResize =
(index) => (index) =>
(e, { size }) => { (e, { size }) => {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
this.setState(({ columns }) => { setcolumnes((s) => {
const nextColumns = [...columns]; const nextColumns = [...s];
nextColumns[index] = { nextColumns[index] = {
...nextColumns[index], ...nextColumns[index],
width: size.width, width: size.width,
}; };
return { columns: nextColumns }; return nextColumns;
}); });
}; };
//更新表格缩放 //更新表格缩放
handleResizeStop = const handleResizeStop =
(index) => (index) =>
(e, { size }) => { (e, { size }) => {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
let { extraparams, activeTabKey, path } = this.props; setcolumnes((s) => {
let submitdata = this.state.valueColumns ?? {}, const nextColumns = [...s];
curkey = Object.keys(submitdata)[index]; nextColumns[index] = {
submitdata[curkey].width = parseInt(size.width); ...nextColumns[index],
this.setState( width: size.width,
{ };
valueColumns: submitdata,
},
() => {
doFetch({ doFetch({
url: "/ngic-base-business/paFieldScene/save", url: "/ngic-base-business/paFieldScene/save",
params: { params: {
...@@ -187,178 +228,56 @@ class Mtable extends PureComponent { ...@@ -187,178 +228,56 @@ class Mtable extends PureComponent {
: activeTabKey : activeTabKey
? path + activeTabKey ? path + activeTabKey
: path, : path,
controList: Object.keys(submitdata).map((it, i) => { controList: Object.keys(nextColumns).map((it, i) => {
return { return {
fieldKey: it, fieldKey: it,
fieldWidth: fieldWidth:
i == index ? parseInt(size.width) : submitdata[it].width, i == index ? parseInt(size.width) : nextColumns[it].width,
fieldOrder: submitdata[it].order, fieldOrder: nextColumns[it].order,
fieldFixed: submitdata[it].fixed, fieldFixed: nextColumns[it].fixed,
fieldShow: submitdata[it].show, fieldShow: nextColumns[it].show,
}; };
}), }),
}, },
}); });
} return nextColumns;
);
};
render() {
let {
pageSize,
x,
y,
style,
dataSource,
onSearchChange,
defaultPageSize,
pagination, //分页
rowKey, //行key
actionRef, //操作ref
formRef, //查询表单ref
path, //路径
activeTabKey, //当前tab
extraparams, //拓展查询参数
rowSelection, //行选择
tableRender, //表格布局自定义
getDefaultSelected, //获取默认选中的数据
rowClassNameFn, //选中后行样式
showQuickJumper, //false字符串 不显示
expandable, //是否可展开
onRow,
} = this.props,
{ total, size } = this.state;
let tabledataProps =
dataSource && Array.isArray(dataSource)
? {
dataSource,
pagination: {
showTotal: (total, range) => <span>{total}</span>,
showQuickJumper: false,
showSizeChanger: true,
defaultPageSize: defaultPageSize ? defaultPageSize : 15,
pageSizeOptions: [10, 15, 30, 50, 100, 200],
total: dataSource.length,
},
search: {
filterType: "light", //轻量模式
},
toolBarRender: false,
}
: {
request: async (params = {}) => {
//表格数据获取 只需要传入url自动获得数据
if (!path) {
return;
}
//设置token
let token = localStorage.getItem("TOKENS")
? localStorage.getItem("TOKENS")
: "9410b3f7de5d63f2be42d80ec8241d2d";
let headers = {
"Content-Type": "application/json",
token: token ? token : "",
},
newextraparams = extraparams ?? {};
//处理传参 extraparams为除列筛选外的自定义传参
let newparams = {
...params,
...newextraparams, //父组件传参
pageIndex: params.current,
pageSize: params.pageSize || pageSize,
};
delete newparams.current;
if (pagination == "false") {
delete newparams.pageIndex;
delete newparams.pageSize;
}
let res = await request("/wms" + path, {
body: JSON.stringify(newparams ? newparams : {}),
headers,
method: "POST",
}); });
return {
data: res.data,
total: res?.data?.total || res?.data?.dataList?.length,
};
},
pagination: {
showTotal: (total, range) => <span>{total}</span>,
showQuickJumper: !showQuickJumper ? true : false,
showSizeChanger: true,
pageSizeOptions: [5, 10, 15, 30, 50, 100, 200],
defaultPageSize: pageSize || 15,
total,
},
search: {
filterType: "light", //轻量模式
},
}; };
return ( return (
<ProTable <ProTable
{...props}
size={size} size={size}
onSubmit={(params) => { onSubmit={(params) => {
onSearchChange && onSearchChange(params); console.log(params, "onSubmit");
}} }}
onSizeChange={(size) => { onSizeChange={(size) => {
localStorage.setItem("size", size); //设置全局表格规格缓存 localStorage.setItem("size", size); //设置全局表格规格缓存
this.setState({ setsize(size);
size,
});
}} }}
columns={this.state.columns} columns={columnes ?? []}
style={style || {}} style={style || {}}
actionRef={actionRef ? actionRef : this.actionRefs} actionRef={actionRefs}
formRef={formRef ? formRef : this.formRefs} formRef={formRefs}
rowKey={rowKey ? rowKey : "id"} //表格每行数据的key rowKey={rowKey ?? "id"} //表格每行数据的key
dateFormatter="string" dateFormatter="string"
postData={(data) => { request={request}
if (data.page) { scroll={{
this.setState({ x: x ?? 1024,
total: data.page.total,
});
} else {
this.setState({
total: data.dataList.length,
});
}
//分页or不分页获取数据
getDefaultSelected && getDefaultSelected(data); //存在默认选中向上返回选中值
let defaultval =
pagination == "false"
? data.dataList
: data.page
? data.page.list
: []; //分页或不分页的接口返回数据
return defaultval;
}} }}
components={{ components={{
header: { header: {
cell: Resizecell, cell: Resizecell,
}, },
}} }}
rowSelection={rowSelection ? rowSelection : false}
tableRender={
tableRender ? (_, dom) => tableRender(_, dom) : (_, dom) => dom
} //自定义表格主体
rowClassName={
rowClassNameFn ? (record, index) => rowClassNameFn(record, index) : ""
} //自定义行高亮
columnsState={{ columnsState={{
value: this.state.valueColumns, value: valueColumns,
onChange: (val, state) => { onChange: (val, state) => {
let submitdata = { let submitdata = {
...this.state.valueColumns, ...valueColumns,
...val, ...val,
}; };
this.setState( setcolumnes(submitdata);
{
valueColumns: submitdata,
},
(state) => {
if (!this.props.path) return;
doFetch({ doFetch({
url: "/ngic-base-business/paFieldScene/save", url: "/ngic-base-business/paFieldScene/save",
params: { params: {
...@@ -378,19 +297,24 @@ class Mtable extends PureComponent { ...@@ -378,19 +297,24 @@ class Mtable extends PureComponent {
}), }),
}, },
}); });
}
);
}, },
}} }}
scroll={{ pagination={
x: x ?? 1024, ifspagination
? false
: {
showTotal: (total, range) => <span>{total}</span>,
showQuickJumper: true,
showSizeChanger: true,
pageSizeOptions: [5, 10, 15, 30, 50, 100, 200],
defaultPageSize: pageSize || 15,
}
}
search={{
filterType: "light", //轻量模式
}} }}
{...tabledataProps}
{...expandable}
onRow={onRow ? (record) => onRow(record) : null}
/> />
); );
} };
}
export default Mtable; export default Mtable;
...@@ -511,7 +511,7 @@ export default function CheckTable({ ...@@ -511,7 +511,7 @@ export default function CheckTable({
)} )}
</div> </div>
)} )}
rowClassNameFn={(record, index) => { rowClassName={(record, index) => {
if (currentkey === record[rowKey]) { if (currentkey === record[rowKey]) {
return "selectedRow"; return "selectedRow";
} }
...@@ -733,7 +733,7 @@ export default function CheckTable({ ...@@ -733,7 +733,7 @@ export default function CheckTable({
)} )}
</div> </div>
)} )}
rowClassNameFn={(record, index) => { rowClassName={(record, index) => {
if (currentkey === record[rowKey]) { if (currentkey === record[rowKey]) {
return "selectedRow"; return "selectedRow";
} }
......
import React, { useEffect, useMemo, useRef, useState } from "react"; import React, { useEffect, useMemo, useRef, useState } from "react";
import { import { Dropdown, Menu, Button, Tooltip } from "antd";
Dropdown, import { ProTable } from "@ant-design/pro-table";
Menu, import { doFetch } from "@/utils/doFetch";
Button,
message,
} from "antd";
import AutoTable from "@/components/AutoTable"; import AutoTable from "@/components/AutoTable";
function Instore(props) {
const actionRef = useRef(),
ChildRef = null;
function Instore(props) {
const columns = [ const columns = [
{ {
"title": "操作时间", title: "操作时间",
"dataIndex": "operateTime", dataIndex: "operateTime",
"key": "operateTimeList", key: "operateTimeList",
"valueType": "dateRange", valueType: "dateRange",
"render": (_, row) => { return (<div>{row.operateTime}</div>) }, render: (_, row) => {
return <div>{row.operateTime}</div>;
},
}, },
{ {
"title": "操作人", title: "操作人",
"dataIndex": "operateUserName", dataIndex: "operateUserName",
"key": "operateUserName" key: "operateUserName",
}, },
{ {
"title": "物料编码", title: "物料编码",
"dataIndex": "materieCode", dataIndex: "materieCode",
"key": "materieCode" key: "materieCode",
}, },
{ {
"title": "物料名称", title: "物料名称",
"dataIndex": "materieName", dataIndex: "materieName",
"key": "materieName" key: "materieName",
}, },
{ {
"title": "批次号/SN号", title: "批次号/SN号",
"dataIndex": "materieControlNo", dataIndex: "materieControlNo",
"key": "materieControlNo" key: "materieControlNo",
}, },
{ {
"title": "当时库存数量", title: "当时库存数量",
"dataIndex": "currentNum", dataIndex: "currentNum",
"key": "currentNum", key: "currentNum",
"search": false search: false,
}, },
{ {
"title": "操作数量", title: "操作数量",
"dataIndex": "operateNum", dataIndex: "operateNum",
"key": "operateNum", key: "operateNum",
"search": false search: false,
}, },
{ {
"title": "库存单位", title: "库存单位",
"dataIndex": "productionUnitName", dataIndex: "productionUnitName",
"key": "productionUnitName", key: "productionUnitName",
"search": false search: false,
}, },
{ {
"title": "操作类型", title: "操作类型",
"dataIndex": "stockDetailTypeName", dataIndex: "stockDetailTypeName",
"key": "stockDetailTypeName", key: "stockDetailTypeName",
}, },
{ {
"title": "仓库名称", title: "出库仓库",
"dataIndex": "storeName", dataIndex: "storeName",
"key": "storeId", key: "storeName",
fieldProps: {
allowClear: true,
showSearch: true,
},
options: { options: {
database: () => doFetch({ url: "/ngic-auth/sysStore/selectionBox", params: { factoryIdList: [] } }), database: () =>
params: {} doFetch({
url: "/ngic-auth/sysStore/selectionBox",
params: { factoryIdList: [] },
}),
params: {},
}, },
valueType: "select", valueType: "select",
}, },
{ {
"title": "库位", title: "库位",
"dataIndex": "storePositionName", dataIndex: "storePositionName",
"key": "storePositionName" key: "storePositionName",
}, },
{ {
"title": "相关单号", title: "相关单号",
"dataIndex": "relatedNo", dataIndex: "relatedNo",
"key": "relatedNo" key: "relatedNo",
} },
] ]
const tableprops = {
...props,
pageextra: "none",
columns,
path: "/ngic-workmanship/wmsMaterieStockRecord/queryList"
}
return ( return (
<div> <div>
<AutoTable <AutoTable
{ {...props}
...tableprops pageextra="none"
} path="/ngic-workmanship/wmsMaterieStockRecord/queryList"
actionRef={actionRef} columns={columns}
onRef={(node) => (ChildRef = node)}
></AutoTable> ></AutoTable>
</div> </div>
); );
......
...@@ -212,7 +212,7 @@ const one = { ...@@ -212,7 +212,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -350,7 +350,7 @@ const one = { ...@@ -350,7 +350,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -473,7 +473,7 @@ const one = { ...@@ -473,7 +473,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -493,7 +493,7 @@ const one = { ...@@ -493,7 +493,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -616,7 +616,7 @@ const one = { ...@@ -616,7 +616,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -636,7 +636,7 @@ const one = { ...@@ -636,7 +636,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -704,10 +704,6 @@ const one = { ...@@ -704,10 +704,6 @@ const one = {
title: "相关单号", title: "相关单号",
key: "businessNo", key: "businessNo",
}, },
{
title: "备注",
key: "remark",
},
{ {
title: "创建人", title: "创建人",
key: "createUserName", key: "createUserName",
...@@ -723,8 +719,14 @@ const one = { ...@@ -723,8 +719,14 @@ const one = {
title: "完成时间", title: "完成时间",
key: "finishTime", key: "finishTime",
}, },
{
title: "备注",
key: "remark",
noshow:"100%",
},
{ {
title: "工单二维码", title: "工单二维码",
noshow:true,
key: "qrCodeUrl", key: "qrCodeUrl",
type: "img", type: "img",
width: 100, width: 100,
......
import React, { useEffect, useMemo, useRef, useState } from "react"; import React, { useEffect, useMemo, useRef, useState } from "react";
import { import { Dropdown, Menu, Button, message } from "antd";
Dropdown,
Menu,
Button,
message,
} from "antd";
import AutoTable from "@/components/AutoTable"; import AutoTable from "@/components/AutoTable";
import defaultFields from "./fields"; import defaultFields from "./fields";
import { doFetch } from "@/utils/doFetch"; import { doFetch } from "@/utils/doFetch";
import DrawInitForm from "@/components/DrawInitForm"; import DrawInitForm from "@/components/DrawInitForm";
import getPrem from '@/utils/getPrem';//权限判断fn import getPrem from "@/utils/getPrem"; //权限判断fn
import { useReactToPrint } from 'react-to-print'; import { useReactToPrint } from "react-to-print";
import { useCallback } from "react"; import { useModel } from "umi";
import { useModel } from 'umi'; import PrintDom from "./printdom";
const keytoval = { const keytoval = {
"one": 1, one: 1,
"two": 2, two: 2,
"three": 3, three: 3,
"four": 4 four: 4,
}, items = [
{
key: 'one',
label: (
<a>
采购入库
</a>
),
}, },
items = [
{ {
key: 'two', key: "one",
label: ( label: <a>采购入库</a>,
<a>
生产入库
</a>
),
}, },
{ {
key: 'three', key: "two",
label: ( label: <a>生产入库</a>,
<a>
退料入库
</a>
),
}, },
{ {
key: 'four', key: "three",
label: ( label: <a>退料入库</a>,
<a>
其他入库
</a>
),
}, },
],itemz = { {
one:"采购入库", key: "four",
two:"生产入库", label: <a>其他入库</a>,
three:"退料入库", },
four:"其他入库" ],
} itemz = {
one: "采购入库",
two: "生产入库",
three: "退料入库",
four: "其他入库",
};
function Instore(props) { function Instore(props) {
const { initialState, setInitialState } = useModel("@@initialState"); const { initialState, setInitialState } = useModel("@@initialState");
...@@ -65,14 +47,14 @@ function Instore(props) { ...@@ -65,14 +47,14 @@ function Instore(props) {
title: "", title: "",
visible: false, visible: false,
onClose: () => { onClose: () => {
setdrawprops(s => ({ setdrawprops((s) => ({
...s, ...s,
visible: false, visible: false,
fields:{} fields: {},
})) }));
}, },
fields: {}, fields: {},
width: 1200 width: 1200,
}), }),
actionRef = useRef(), actionRef = useRef(),
ChildRef = null, ChildRef = null,
...@@ -83,326 +65,380 @@ function Instore(props) { ...@@ -83,326 +65,380 @@ function Instore(props) {
actionRef.current.reload(); actionRef.current.reload();
ChildRef?.onRefresh(); ChildRef?.onRefresh();
message.success("操作成功"); message.success("操作成功");
setdrawprops(s => ({ setdrawprops((s) => ({
...s, ...s,
visible: false, visible: false,
fields:{} fields: {},
})) }));
} }
const handlePrint = useReactToPrint({ const handlePrint = useReactToPrint({
content: () => printRef.current, content: () => printRef.current.dom.current,
}); });
const columns = useMemo(() => { const columns = useMemo(() => {
if (activeTabKey == "1") { if (activeTabKey == "1") {
return [ return [
{ {
"title": "入库单号", title: "入库单号",
"dataIndex": "materieInstoreNo", dataIndex: "materieInstoreNo",
"key": "materieInstoreNo", key: "materieInstoreNo",
"render": (dom, record) => { render: (dom, record) => {
return <a return (
<a
onClick={async () => { onClick={async () => {
setdrawprops(s => ({ setdrawprops((s) => ({
...s, ...s,
visible: true, visible: true,
//查看详情 props //查看详情 props
val: "detail", val: "detail",
title: `查看详情`, title: `查看详情`,
...defaultFields?.detail, ...defaultFields?.detail,
totalPath: "/ngic-workmanship/wmsMaterieInstore/getInStoreInfoById", totalPath:
"/ngic-workmanship/wmsMaterieInstore/getInStoreInfoById",
totalParams: { id: record.id }, totalParams: { id: record.id },
printRef: printRef, extra: (
extra: (<Button <Button
onClick={async () => { onClick={async () => {
handlePrint() handlePrint();
}} }}
> >
打印 打印
</Button>) </Button>
})) ),
}));
}} }}
>{dom}</a> >
} {dom}
</a>
);
},
}, },
{ {
"title": "入库类型", title: "入库类型",
"dataIndex": "instoreTypeName", dataIndex: "instoreTypeName",
"key": "instoreType", key: "instoreType",
"valueType": "select", valueType: "select",
"options": [ options: [
{ {
"label": "采购入库", label: "采购入库",
"value": "1" value: "1",
}, },
{ {
"label": "生产入库", label: "生产入库",
"value": "2" value: "2",
}, },
{ {
"label": "退料入库", label: "退料入库",
"value": "3" value: "3",
}, },
{ {
"label": "其他入库", label: "其他入库",
"value": "4" value: "4",
} },
] ],
}, },
{ {
"title": "入库仓库", title: "入库仓库",
"dataIndex": "storeName", dataIndex: "storeName",
"key": "storeId", key: "storeId",
fieldProps: {
allowClear: true,
showSearch: true
},
options: { options: {
database: () => doFetch({ url: "/ngic-auth/sysStore/selectionBox", params: { factoryIdList: [] } }), database: () =>
params: {} doFetch({
url: "/ngic-auth/sysStore/selectionBox",
params: { factoryIdList: [] },
}),
params: {},
}, },
valueType: "select", valueType: "select",
}, },
{ {
"title": "相关单号", title: "相关单号",
"dataIndex": "businessNo", dataIndex: "businessNo",
"key": "businessNo" key: "businessNo",
}, },
{ {
"title": "备注", title: "备注",
"dataIndex": "remark", dataIndex: "remark",
"key": "remark", key: "remark",
"search": false search: false,
}, },
{ {
"title": "创建人", title: "创建人",
"dataIndex": "createUserName", dataIndex: "createUserName",
"key": "createUserName" key: "createUserName",
}, },
{ {
"title": "创建时间", title: "创建时间",
"dataIndex": "createTime", dataIndex: "createTime",
"key": "createTime", key: "createTime",
"valueType": "dateRange", valueType: "dateRange",
formItemProps:{ formItemProps: {
name:"createTimeList" name: "createTimeList",
} },
}, },
{ {
"title": "状态", title: "状态",
"dataIndex": "statusName", dataIndex: "statusName",
"key": "status", key: "status",
"valueType": "select", valueType: "select",
"options": [ options: [
{ {
"label": "待上架", label: "待上架",
"value": "0" value: "0",
}, },
{ {
"label": "上架中", label: "上架中",
"value": "1" value: "1",
} },
] ],
}, },
{ {
"title": "操作", title: "操作",
"valueType": "option", valueType: "option",
"width": 240, width: 240,
"render": (text, record, _, action) => { render: (text, record, _, action) => {
return [ return [
getPrem("equipmentCustomer_save", action, '上架采集', async () => { getPrem(
let extra = defaultFields.doinsert(record.id,record.storeId); "equipmentCustomer_save",
setdrawprops(s => ({ action,
"上架采集",
async () => {
let extra = defaultFields.doinsert(record.id, record.storeId);
setdrawprops((s) => ({
...s, ...s,
visible: true, visible: true,
//查看详情 props //查看详情 props
val: "detail", val: "detail",
title: `上架采集`, title: `上架采集`,
totalPath: "/ngic-workmanship/wmsMaterieInstore/getInStoreInfoById", totalPath:
"/ngic-workmanship/wmsMaterieInstore/getInStoreInfoById",
totalParams: { id: record.id }, totalParams: { id: record.id },
extra:null, extra: null,
...extra, ...extra,
})) }));
setInitialState(s => { setInitialState((s) => {
return ({ return {
...s, ...s,
submit: {} submit: {},
}) };
}) });
}), }
getPrem("equipmentCustomer_deleteById", action, '关单', null, { ),
getPrem("equipmentCustomer_deleteById", action, "关单", null, {
title: "确认关单?", title: "确认关单?",
onConfirm: () => { onConfirm: () => {
doFetch({ url: "/ngic-workmanship/wmsMaterieInstore/close", params: { id: record.id } }).then(res => { doFetch({
url: "/ngic-workmanship/wmsMaterieInstore/close",
params: { id: record.id },
}).then((res) => {
if (res.code == "0000") { if (res.code == "0000") {
reload() reload();
}
})
} }
});
},
}), }),
record.status==0 && getPrem("equipmentCustomer_deleteById", action, '删除', null, { record.status == 0 &&
getPrem("equipmentCustomer_deleteById", action, "删除", null, {
title: "确认删除?", title: "确认删除?",
onConfirm: () => { onConfirm: () => {
doFetch({ url: "/ngic-workmanship/wmsMaterieInstore/deleteById", params: { id: record.id } }).then(res => { doFetch({
url: "/ngic-workmanship/wmsMaterieInstore/deleteById",
params: { id: record.id },
}).then((res) => {
if (res.code == "0000") { if (res.code == "0000") {
reload() reload();
}
})
} }
}) });
},
}),
];
},
},
]; ];
}
}
]
} else { } else {
return [ return [
{ {
"title": "入库单号", title: "入库单号",
"dataIndex": "materieInstoreNo", dataIndex: "materieInstoreNo",
"key": "materieInstoreNo", key: "materieInstoreNo",
"render": (dom, record) => { render: (dom, record) => {
return <a return (
<a
onClick={() => { onClick={() => {
setdrawprops(s => ({ setdrawprops((s) => ({
...s, ...s,
visible: true, visible: true,
//查看详情 props //查看详情 props
val: "detail", val: "detail",
title: `查看详情`, title: `查看详情`,
...defaultFields?.detail, ...defaultFields?.detail,
totalPath: "/ngic-workmanship/wmsMaterieInstoreHis/getInStoreInfoById", totalPath:
totalParams: { id: record.id } "/ngic-workmanship/wmsMaterieInstoreHis/getInStoreInfoById",
})) totalParams: { id: record.id },
extra:null
}));
}} }}
>{dom}</a> >
} {dom}
</a>
);
},
}, },
{ {
"title": "入库类型", title: "入库类型",
"dataIndex": "instoreTypeName", dataIndex: "instoreTypeName",
"key": "instoreType", key: "instoreType",
"valueType": "select", valueType: "select",
"options": [ options: [
{ {
"label": "采购入库", label: "采购入库",
"value": "1" value: "1",
}, },
{ {
"label": "生产入库", label: "生产入库",
"value": "2" value: "2",
}, },
{ {
"label": "退料入库", label: "退料入库",
"value": "3" value: "3",
}, },
{ {
"label": "其他入库", label: "其他入库",
"value": "4" value: "4",
} },
] ],
}, },
{ {
"title": "入库仓库", title: "入库仓库",
"dataIndex": "storeName", dataIndex: "storeName",
"key": "storeId", key: "storeId",
fieldProps: {
allowClear: true,
showSearch: true
},
options: { options: {
database: () => doFetch({ url: "/ngic-auth/sysStore/selectionBox", params: { factoryIdList: [] } }), database: () =>
params: {} doFetch({
url: "/ngic-auth/sysStore/selectionBox",
params: { factoryIdList: [] },
}),
params: {},
}, },
valueType: "select", valueType: "select",
}, },
{ {
"title": "相关单号", title: "相关单号",
"dataIndex": "businessNo", dataIndex: "businessNo",
"key": "businessNo" key: "businessNo",
}, },
{ {
"title": "备注", title: "备注",
"dataIndex": "remark", dataIndex: "remark",
"key": "remark", key: "remark",
"search": false search: false,
}, },
{ {
"title": "创建人", title: "创建人",
"dataIndex": "createUserName", dataIndex: "createUserName",
"key": "createUserName" key: "createUserName",
}, },
{ {
"title": "创建时间", title: "创建时间",
"dataIndex": "createTime", dataIndex: "createTime",
"key": "createTime", key: "createTime",
"valueType": "dateRange", valueType: "dateRange",
formItemProps:{ formItemProps: {
name:"createTimeList" name: "createTimeList",
} },
}, },
{ {
"title": "完成时间", title: "完成时间",
"dataIndex": "finishTime", dataIndex: "finishTime",
"key": "finishTime", key: "finishTime",
"valueType": "dateRange", valueType: "dateRange",
formItemProps:{ formItemProps: {
name:"finishTimeList" name: "finishTimeList",
} },
}, },
{ {
"title": "状态", title: "状态",
"dataIndex": "statusName", dataIndex: "statusName",
"key": "status", key: "status",
"valueType": "select", valueType: "select",
"options": [ options: [
{ {
"label": "已上架", label: "已上架",
"value": "2" value: "2",
}, },
{ {
"label": "已关单", label: "已关单",
"value": "4" value: "4",
} },
] ],
} },
] ];
} }
}, [activeTabKey]) }, [activeTabKey]);
const tableprops = { const tableprops = {
...props, ...props,
pageextra: activeTabKey == "1" ? <Dropdown placement="bottomRight" overlay={<Menu pageextra:
activeTabKey == "1" ? (
<Dropdown
placement="bottomRight"
overlay={
<Menu
onClick={(e) => { onClick={(e) => {
setdrawprops(s => ({ setdrawprops((s) => ({
...s, ...s,
visible: true, visible: true,
title: "新增"+itemz[e.key], title: "新增" + itemz[e.key],
fields: defaultFields[e.key], fields: defaultFields[e.key],
instoreType: keytoval[e.key], instoreType: keytoval[e.key],
val: "add", //类型 val: "add", //类型
extra:null extra: null,
})) }));
}} }}
items={items} items={items}
/>}> />
}
>
<Button type="primary">新增</Button> <Button type="primary">新增</Button>
</Dropdown> : "none", </Dropdown>
) : (
"none"
),
tabList: [ tabList: [
{ {
tab: "未完成", tab: "未完成",
key: "1" key: "1",
}, { },
{
tab: "已完成", tab: "已完成",
key: "2" key: "2",
} },
], ],
activeTabKey, activeTabKey,
onTabChange, onTabChange,
columns, columns,
path: activeTabKey == "1" ? "/ngic-workmanship/wmsMaterieInstore/queryList" : "/ngic-workmanship/wmsMaterieInstoreHis/queryList" path:
} activeTabKey == "1"
? "/ngic-workmanship/wmsMaterieInstore/queryList"
: "/ngic-workmanship/wmsMaterieInstoreHis/queryList",
};
return ( return (
<div> <div>
<div style={{ display: "none" }}>
<PrintDom ref={printRef} {...drawprops} />
</div>
<AutoTable <AutoTable
{ {...tableprops}
...tableprops
}
actionRef={actionRef} actionRef={actionRef}
onRef={(node) => (ChildRef = node)} onRef={(node) => (ChildRef = node)}
></AutoTable> ></AutoTable>
...@@ -410,7 +446,10 @@ function Instore(props) { ...@@ -410,7 +446,10 @@ function Instore(props) {
{...drawprops} {...drawprops}
submitData={async (value) => { submitData={async (value) => {
if (drawprops.val == "add") { if (drawprops.val == "add") {
let res = await doFetch({ url: "/ngic-workmanship/wmsMaterieInstore/saveInStore", params: { ...value, instoreType: drawprops.instoreType } }) let res = await doFetch({
url: "/ngic-workmanship/wmsMaterieInstore/saveInStore",
params: { ...value, instoreType: drawprops.instoreType },
});
if (res.code == "0000") { if (res.code == "0000") {
reload(); reload();
} }
......
import { doFetch } from "@/utils/doFetch";
import React, {
useState,
useImperativeHandle,
forwardRef,
useRef,
} from "react";
import { useEffect } from "react";
import AutoTable from "@/components/AutoTable";
function PrintDom({ totalPath, val, totalParams, totalCard }, ref) {
let printRef = useRef();
const [data, setdata] = useState({});
useImperativeHandle(ref, () => ({
dom: printRef,
}));
useEffect(() => {
if (val == "detail") {
doFetch({ url: totalPath, params: totalParams }).then((res) => {
setdata(res?.data?.data);
});
} else {
}
}, [val]);
return (
val == "detail" && (
<div
ref={printRef}
style={{
position: "fixed",
top: 0,
left: 0,
zIndex: 999,
width: "100%",
height: "100%",
}}
>
<h1
style={{
textAlign: "center",
width: "100%",
paddingTop: 12,
paddingBottom: 16,
}}
>
入库工单
</h1>
<img
style={{
position: "absolute",
right: 12,
top: 12,
width: 86,
height: "auto",
}}
src={data?.qrCodeUrl}
alt=""
/>
<div style={{ display: "flex", flexWrap: "wrap", paddingLeft: "2%" }}>
{totalCard &&
totalCard[0].itemData
.filter((it) => !(it.noshow === true))
.map((it) => {
return (
<div
style={{
width: it.noshow ?? "32%",
backgroundColor: "#f9f9f9",
marginRight: "1%",
marginBottom: 10,
padding: "4px",
fontSize: 16,
overflow: "hidden",
}}
>
<b>{it.title}: </b>
<span>{data[it.key] || "-"}</span>
</div>
);
})}
</div>
<p style={{ margin: 0, padding: "4px 2%", fontSize: 18 }}>
<b>{totalCard && totalCard[1].cardTitle}</b>
</p>
<div style={{ margin: 0, padding: "4px 2%", fontSize: 18 }}>
<AutoTable
dataSource={data?.materialList}
x="96%"
style={{ marginTop: 8 }}
withCard={false}
pagination={"false"}
columns={[
{
title: "物料编码 - 名称",
dataIndex: "materieName",
key: "materieName",
search: false,
render: (dom, row) => {
return (
(row.materieCode ?? "") + " - " + (row.materieName ?? "")
);
},
},
{
title: "供应商编号 - 名称",
dataIndex: "supplierNo",
key: "supplierNo",
search: false,
render: (dom, row) => {
return (
(row.supplierNo ?? "") + " - " + (row.supplierName ?? "")
);
},
},
{
title: "批次号/SN号",
dataIndex: "materieControlNo",
key: "materieControlNo",
search: false,
},
{
title: "入库数量",
dataIndex: "instroeNum",
key: "instroeNum",
search: false,
},
{
title: "库存单位",
dataIndex: "productionUnitName",
key: "productionUnitName",
search: false,
},
]}
></AutoTable>
</div>
</div>
)
);
}
export default forwardRef(PrintDom);
...@@ -234,7 +234,7 @@ const one = { ...@@ -234,7 +234,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -357,7 +357,7 @@ const one = { ...@@ -357,7 +357,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -478,7 +478,7 @@ const one = { ...@@ -478,7 +478,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -599,7 +599,7 @@ const one = { ...@@ -599,7 +599,7 @@ const one = {
return res?.data?.dataList return res?.data?.dataList
}, },
"fieldProps": { "fieldProps": {
allowClear: false, allowClear: true,
showSearch: true showSearch: true
}, },
"formItemProps": () => { "formItemProps": () => {
...@@ -667,10 +667,6 @@ const one = { ...@@ -667,10 +667,6 @@ const one = {
title: "相关单号", title: "相关单号",
key: "businessNo", key: "businessNo",
}, },
{
title: "备注",
key: "remark",
},
{ {
title: "创建人", title: "创建人",
key: "createUserName", key: "createUserName",
...@@ -687,10 +683,16 @@ const one = { ...@@ -687,10 +683,16 @@ const one = {
title: "完成时间", title: "完成时间",
key: "finishTime", key: "finishTime",
}, },
{
title: "备注",
key: "remark",
noshow:"100%",
},
{ {
title: "工单二维码", title: "工单二维码",
key: "qrCodeUrl", key: "qrCodeUrl",
type: "img", type: "img",
noshow:true,
width: 100, width: 100,
height: 100 height: 100
}, },
......
...@@ -7,6 +7,7 @@ import DrawInitForm from "@/components/DrawInitForm"; ...@@ -7,6 +7,7 @@ import DrawInitForm from "@/components/DrawInitForm";
import getPrem from "@/utils/getPrem"; //权限判断fn import getPrem from "@/utils/getPrem"; //权限判断fn
import { useReactToPrint } from "react-to-print"; import { useReactToPrint } from "react-to-print";
import { useModel } from "umi"; import { useModel } from "umi";
import PrintDom from "./printdom";
const keytoval = { const keytoval = {
one: 1, one: 1,
...@@ -72,7 +73,7 @@ function Outstore(props) { ...@@ -72,7 +73,7 @@ function Outstore(props) {
} }
const handlePrint = useReactToPrint({ const handlePrint = useReactToPrint({
content: () => printRef.current, content: () => printRef.current.dom.current,
}); });
const columns = useMemo(() => { const columns = useMemo(() => {
...@@ -96,7 +97,6 @@ function Outstore(props) { ...@@ -96,7 +97,6 @@ function Outstore(props) {
totalPath: totalPath:
"/ngic-workmanship/wmsMaterieOutstore/getOutStoreInfoById", "/ngic-workmanship/wmsMaterieOutstore/getOutStoreInfoById",
totalParams: { id: record.id }, totalParams: { id: record.id },
printRef: printRef,
extra: ( extra: (
<Button <Button
onClick={async () => { onClick={async () => {
...@@ -142,6 +142,10 @@ function Outstore(props) { ...@@ -142,6 +142,10 @@ function Outstore(props) {
title: "出库仓库", title: "出库仓库",
dataIndex: "storeName", dataIndex: "storeName",
key: "storeId", key: "storeId",
fieldProps: {
allowClear: true,
showSearch: true
},
options: { options: {
database: () => database: () =>
doFetch({ doFetch({
...@@ -315,12 +319,12 @@ function Outstore(props) { ...@@ -315,12 +319,12 @@ function Outstore(props) {
title: "出库仓库", title: "出库仓库",
dataIndex: "storeName", dataIndex: "storeName",
key: "storeId", key: "storeId",
fieldProps: {
allowClear: true,
showSearch: true
},
options: { options: {
database: () => database: () =>doFetch({url: "/ngic-auth/sysStore/selectionBox",params: { factoryIdList: [] }}),
doFetch({
url: "/ngic-auth/sysStore/selectionBox",
params: { factoryIdList: [] },
}),
params: {}, params: {},
}, },
valueType: "select", valueType: "select",
...@@ -428,6 +432,9 @@ function Outstore(props) { ...@@ -428,6 +432,9 @@ function Outstore(props) {
return ( return (
<div> <div>
<div style={{ display: "none" }}>
<PrintDom ref={printRef} {...drawprops} />
</div>
<AutoTable <AutoTable
{...tableprops} {...tableprops}
actionRef={actionRef} actionRef={actionRef}
...@@ -493,7 +500,7 @@ function Outstore(props) { ...@@ -493,7 +500,7 @@ function Outstore(props) {
key: "materieId", key: "materieId",
valueType: "select", valueType: "select",
fieldProps: { fieldProps: {
allowClear: false, allowClear: true,
showSearch: true, showSearch: true,
options options
}, },
......
import { doFetch } from "@/utils/doFetch";
import React, {
useState,
useImperativeHandle,
forwardRef,
useRef,
} from "react";
import { useEffect } from "react";
import AutoTable from "@/components/AutoTable";
function PrintDom({ totalPath, val, totalParams, totalCard }, ref) {
let printRef = useRef();
const [data, setdata] = useState({});
useImperativeHandle(ref, () => ({
dom: printRef,
}));
useEffect(() => {
if (val == "detail") {
doFetch({ url: totalPath, params: totalParams }).then((res) => {
setdata(res?.data?.data);
});
} else {
}
}, [val]);
return (
val == "detail" && (
<div
ref={printRef}
style={{
position: "fixed",
top: 0,
left: 0,
zIndex: 999,
width: "100%",
height: "100%",
}}
>
<h1
style={{
textAlign: "center",
width: "100%",
paddingTop: 12,
paddingBottom: 16,
}}
>
出库工单
</h1>
<img
style={{
position: "absolute",
right: 12,
top: 12,
width: 86,
height: "auto",
}}
src={data?.qrCodeUrl}
alt=""
/>
<div style={{ display: "flex", flexWrap: "wrap", paddingLeft: "2%" }}>
{totalCard &&
totalCard[0].itemData
.filter((it) => !(it.noshow === true))
.map((it) => {
return (
<div
style={{
width: it.noshow ?? "32%",
backgroundColor: "#f9f9f9",
marginRight: "1%",
marginBottom: 10,
padding: "4px",
fontSize: 16,
overflow: "hidden",
}}
>
<b>{it.title}: </b>
<span>{data[it.key] || "-"}</span>
</div>
);
})}
</div>
<p style={{ margin: 0, padding: "4px 2%", fontSize: 18 }}>
<b>{totalCard && totalCard[1].cardTitle}</b>
</p>
<div style={{ margin: 0, padding: "4px 2%", fontSize: 18 }}>
<AutoTable
dataSource={data?.materialList}
x="96%"
style={{ marginTop: 8 }}
withCard={false}
pagination={"false"}
columns={[
{
title: "物料编码 - 名称",
dataIndex: "materieName",
key: "materieName",
search: false,
render: (dom, row) => {
return (
(row.materieCode ?? "") + " - " + (row.materieName ?? "")
);
},
},
{
title: "出库数量",
dataIndex: "outstroeNum",
key: "outstroeNum",
search: false,
},
{
title: "库存单位",
dataIndex: "productionUnitName",
key: "productionUnitName",
search: false,
},
]}
></AutoTable>
</div>
</div>
)
);
}
export default forwardRef(PrintDom);
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