Explorar o código

fix: 点击查询按钮才执行查询操作

ZhaoJun hai 1 ano
pai
achega
03ff6ca738
Modificáronse 1 ficheiros con 26 adicións e 14 borrados
  1. 26 14
      src/pages/PurchaseAdmin/PurchaseList/DailyRecord/index.js

+ 26 - 14
src/pages/PurchaseAdmin/PurchaseList/DailyRecord/index.js

@@ -23,7 +23,7 @@ const { confirm } = Modal;
 const DailyRecord = props => {
   const { currentUser, projects, loading: propsLoading, dispatch } = props;
 
-  const [date, setDate] = useState({});
+  const [queryListParams, setQueryListParams] = useState({ current: 1, pageSize: 9 });
   const [pageInfo, setPageInfo] = useState({ current: 1, pageSize: 9, total: 999 });
   const [writeVisible, setWriteVisible] = useState(false);
   const [detailVisible, setDetailVisible] = useState(false);
@@ -34,7 +34,7 @@ const DailyRecord = props => {
 
   // 请求列表
   const { data, run, loading: listLoading } = useRequest(approvalLogOwnList, {
-    defaultParams: [{ ...date, ...pageInfo }],
+    defaultParams: [{ ...queryListParams }],
     onSuccess: data => {
       if (data?.pagination) {
         setPageInfo(data.pagination);
@@ -52,7 +52,7 @@ const DailyRecord = props => {
   //     },
   //   }
   // );
-  console.log('-----------', logDetail);
+  // console.log('-----------', logDetail);
 
   // 添加日志
   const { run: runAdd, loading: addLoading } = useRequest(approvalAddLog, {
@@ -60,7 +60,7 @@ const DailyRecord = props => {
     onSuccess: () => {
       message.success('添加日志成功');
       setWriteVisible(false);
-      run();
+      run(queryListParams);
     },
   });
 
@@ -69,7 +69,7 @@ const DailyRecord = props => {
     manual: true,
     onSuccess: () => {
       message.success('删除日志成功');
-      run();
+      run({ currentPage: 1, pageSize: 9 });
     },
   });
 
@@ -79,7 +79,7 @@ const DailyRecord = props => {
     onSuccess: () => {
       message.success('编辑日志成功');
       setWriteVisible(false);
-      // run();
+      run(queryListParams);
     },
   });
 
@@ -146,7 +146,7 @@ const DailyRecord = props => {
         if (!time) {
           return '--';
         }
-        return moment(time).format('YYYY-DD-MM HH:mm');
+        return moment(time).format('YYYY-MM-DD HH:mm');
       },
     },
     {
@@ -174,20 +174,32 @@ const DailyRecord = props => {
   const handleDataPicked = (_date, dateString) => {
     let params = '';
     if (dateString) {
-      params = { ...pageInfo, s_time: `${dateString} 00:00:00`, e_time: `${dateString} 23:59:59` };
+      params = {
+        pageSize: 9,
+        currentPage: 1,
+        s_time: `${dateString} 00:00:00`,
+        e_time: `${dateString} 23:59:59`,
+      };
+    } else {
+      params = {
+        pageSize: 9,
+        currentPage: 1,
+      };
     }
-    run(params);
-    setDate(params);
+    setQueryListParams(params);
+  };
+
+  const handleQuery = () => {
+    run(queryListParams);
   };
 
   const handlePageChange = (page, pageSize) => {
     let params = '';
-    if (date) {
-      params = date;
-    }
+    params = queryListParams;
     params.currentPage = page;
     params.pageSize = pageSize;
     run(params);
+    setQueryListParams(params);
     setPageInfo({ ...pageInfo, current: page, pageSize: pageSize });
   };
 
@@ -196,7 +208,7 @@ const DailyRecord = props => {
       <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '20px' }}>
         <Space size={24}>
           <DatePicker onChange={handleDataPicked} />
-          <Button type="primary" onClick={() => {}}>
+          <Button type="primary" onClick={handleQuery}>
             查询
           </Button>
         </Space>