|
@@ -1,4 +1,3 @@
|
|
|
-import { RootState } from "@/store";
|
|
|
|
|
import { Button, Form, Input, Modal, Popconfirm, Table } from "antd";
|
|
import { Button, Form, Input, Modal, Popconfirm, Table } from "antd";
|
|
|
import React, {
|
|
import React, {
|
|
|
useCallback,
|
|
useCallback,
|
|
@@ -13,17 +12,18 @@ import styles from "./index.module.scss";
|
|
|
import {
|
|
import {
|
|
|
IDUserScoreSaveAPI,
|
|
IDUserScoreSaveAPI,
|
|
|
getIDUserInfoByIdAPI,
|
|
getIDUserInfoByIdAPI,
|
|
|
|
|
+ getIDUserListAPI,
|
|
|
} from "@/store/action/A6IDUser";
|
|
} from "@/store/action/A6IDUser";
|
|
|
-import { IDUserType, SaveIDUserScoreType } from "@/types";
|
|
|
|
|
|
|
+import { IDUserTableType, IDUserType, SaveIDUserScoreType } from "@/types";
|
|
|
import { MessageFu } from "@/utils/message";
|
|
import { MessageFu } from "@/utils/message";
|
|
|
|
|
+import { RootState } from "@/store";
|
|
|
type Props = {
|
|
type Props = {
|
|
|
- id: number; //用户id
|
|
|
|
|
|
|
+ currentItem: IDUserTableType;
|
|
|
closeFu: () => void;
|
|
closeFu: () => void;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-function IntegralEdit({ id,closeFu }: Props) {
|
|
|
|
|
|
|
+function IntegralEdit({ currentItem, closeFu }: Props) {
|
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
|
-
|
|
|
|
|
const pageNumRef = useRef(1);
|
|
const pageNumRef = useRef(1);
|
|
|
const pagePageRef = useRef(10);
|
|
const pagePageRef = useRef(10);
|
|
|
// 筛选和分页
|
|
// 筛选和分页
|
|
@@ -35,24 +35,23 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
endTime: "",
|
|
endTime: "",
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // 获取当前用户信息
|
|
|
|
|
- const [curIDUser, setCurIDUser] = useState<IDUserType>({
|
|
|
|
|
- id: 1,
|
|
|
|
|
- name: "用户1",
|
|
|
|
|
- } as IDUserType);
|
|
|
|
|
|
|
+ const [results, setResults] = useState<IDUserType[]>([]);
|
|
|
|
|
|
|
|
const getInfoById = useCallback(async () => {
|
|
const getInfoById = useCallback(async () => {
|
|
|
- const res = await getIDUserInfoByIdAPI(id);
|
|
|
|
|
|
|
+ const res = await getIDUserInfoByIdAPI(currentItem.id);
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
- setCurIDUser(res.data);
|
|
|
|
|
|
|
+ setResults(res.data);
|
|
|
}
|
|
}
|
|
|
- }, [id]);
|
|
|
|
|
|
|
+ }, [currentItem.id]);
|
|
|
|
|
+
|
|
|
|
|
+ const [currentItemShow, setCurrentItemShow] = useState<IDUserTableType>();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
+ setCurrentItemShow(currentItem);
|
|
|
pageNumRef.current = tableSelect.pageNum;
|
|
pageNumRef.current = tableSelect.pageNum;
|
|
|
pagePageRef.current = tableSelect.pageSize;
|
|
pagePageRef.current = tableSelect.pageSize;
|
|
|
getInfoById();
|
|
getInfoById();
|
|
|
- }, [dispatch, getInfoById, tableSelect]);
|
|
|
|
|
|
|
+ }, [currentItem, dispatch, getInfoById, tableSelect]);
|
|
|
|
|
|
|
|
// ---------关于表格
|
|
// ---------关于表格
|
|
|
|
|
|
|
@@ -63,8 +62,6 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
setTableSelect({ ...tableSelect, pageNum, pageSize });
|
|
setTableSelect({ ...tableSelect, pageNum, pageSize });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const results = useSelector((state: RootState) => state.A7Log.tableInfo);
|
|
|
|
|
-
|
|
|
|
|
const columns = useMemo(() => {
|
|
const columns = useMemo(() => {
|
|
|
return [
|
|
return [
|
|
|
{
|
|
{
|
|
@@ -77,7 +74,7 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: "积分",
|
|
title: "积分",
|
|
|
- dataIndex: "type",
|
|
|
|
|
|
|
+ dataIndex: "score",
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: "说明",
|
|
title: "说明",
|
|
@@ -89,28 +86,36 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
// 修改积分弹窗开关
|
|
// 修改积分弹窗开关
|
|
|
const [editIntegralVisible, setEditIntegralVisible] = useState(false);
|
|
const [editIntegralVisible, setEditIntegralVisible] = useState(false);
|
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
|
|
|
+ const resultss = useSelector((state: RootState) => state.A6IDUser.tableInfo);
|
|
|
|
|
|
|
|
const onFinish = useCallback(
|
|
const onFinish = useCallback(
|
|
|
async (values: any) => {
|
|
async (values: any) => {
|
|
|
- if (values.numberVal) {
|
|
|
|
|
- const res: any = await IDUserScoreSaveAPI({} as SaveIDUserScoreType);
|
|
|
|
|
|
|
+ if (values) {
|
|
|
|
|
+ const res: any = await IDUserScoreSaveAPI({
|
|
|
|
|
+ description: values.description,
|
|
|
|
|
+ userId: currentItem.id,
|
|
|
|
|
+ score: values.score,
|
|
|
|
|
+ type: "编辑",
|
|
|
|
|
+ });
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
MessageFu.success("提交成功!");
|
|
MessageFu.success("提交成功!");
|
|
|
pageNumRef.current = tableSelect.pageNum;
|
|
pageNumRef.current = tableSelect.pageNum;
|
|
|
pagePageRef.current = tableSelect.pageSize;
|
|
pagePageRef.current = tableSelect.pageSize;
|
|
|
getInfoById();
|
|
getInfoById();
|
|
|
|
|
+ dispatch(getIDUserListAPI(tableSelect));
|
|
|
|
|
+ setCurrentItemShow({...currentItem,score: Number(currentItem.score) + Number(values.score)});
|
|
|
setEditIntegralVisible(false);
|
|
setEditIntegralVisible(false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- [getInfoById, tableSelect.pageNum, tableSelect.pageSize]
|
|
|
|
|
|
|
+ [currentItem, dispatch, getInfoById, tableSelect]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.IntegralEdit}>
|
|
<div className={styles.IntegralEdit}>
|
|
|
<div className="pageTitle">
|
|
<div className="pageTitle">
|
|
|
- <div>{curIDUser.name}</div>
|
|
|
|
|
- <div>当前积分:5000</div>
|
|
|
|
|
|
|
+ <div>{currentItemShow?.userName}</div>
|
|
|
|
|
+ <div>当前积分:{currentItemShow?.score}</div>
|
|
|
<div>
|
|
<div>
|
|
|
<Button
|
|
<Button
|
|
|
className="scoreLimitBtn"
|
|
className="scoreLimitBtn"
|
|
@@ -135,7 +140,7 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
<div className="tableMain">
|
|
<div className="tableMain">
|
|
|
<Table
|
|
<Table
|
|
|
scroll={{ y: 625 }}
|
|
scroll={{ y: 625 }}
|
|
|
- dataSource={results.list}
|
|
|
|
|
|
|
+ dataSource={results}
|
|
|
columns={columns}
|
|
columns={columns}
|
|
|
rowKey="id"
|
|
rowKey="id"
|
|
|
pagination={{
|
|
pagination={{
|
|
@@ -144,7 +149,7 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
showSizeChanger: true,
|
|
showSizeChanger: true,
|
|
|
current: tableSelect.pageNum,
|
|
current: tableSelect.pageNum,
|
|
|
pageSize: tableSelect.pageSize,
|
|
pageSize: tableSelect.pageSize,
|
|
|
- total: results.total,
|
|
|
|
|
|
|
+ total: results.length,
|
|
|
onChange: paginationChange,
|
|
onChange: paginationChange,
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
@@ -170,12 +175,12 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
>
|
|
>
|
|
|
<Form.Item
|
|
<Form.Item
|
|
|
label="积分变动"
|
|
label="积分变动"
|
|
|
- name="numberVal"
|
|
|
|
|
|
|
+ name="score"
|
|
|
style={{ marginTop: "40px" }}
|
|
style={{ marginTop: "40px" }}
|
|
|
rules={[{ required: true, message: "不能为空!" }]}
|
|
rules={[{ required: true, message: "不能为空!" }]}
|
|
|
hide-required-asterisk={true}
|
|
hide-required-asterisk={true}
|
|
|
getValueFromEvent={(e) =>
|
|
getValueFromEvent={(e) =>
|
|
|
- e.target.value.replace(/^(0+)|[^\d]+/g, "")
|
|
|
|
|
|
|
+ e.target.value.replace(/[-]?^|[^\d]+/g, "")
|
|
|
}
|
|
}
|
|
|
>
|
|
>
|
|
|
<Input
|
|
<Input
|
|
@@ -186,6 +191,7 @@ function IntegralEdit({ id,closeFu }: Props) {
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
<Form.Item
|
|
|
label="积分原因"
|
|
label="积分原因"
|
|
|
|
|
+ name="description"
|
|
|
style={{ marginTop: "40px" }}
|
|
style={{ marginTop: "40px" }}
|
|
|
hide-required-asterisk={true}
|
|
hide-required-asterisk={true}
|
|
|
>
|
|
>
|