Browse Source

财务报表 项目维度 填报人选择

XuZinan 2 năm trước cách đây
mục cha
commit
ad8e4e7a4d

+ 37 - 9
src/pages/PurchaseAdmin/PurchaseList/Report/Finance/Project.js

@@ -9,11 +9,30 @@ import { queryFinanceProjDetail } from '@/services/workHours';
 const { RangePicker } = DatePicker;
 
 function FinanceProject(props) {
-  const { dispatch, loading, project } = props;
+  const { dispatch, loading, project, userList } = props;
   const [form] = Form.useForm();
   const [visible, setVisible] = useState(false);
   const [current, setCurrent] = useState(null);
 
+  var initDate;
+  if (moment().date() > 25) {
+    initDate = [
+      moment()
+        .subtract(1, 'month')
+        .set('date', 26),
+      moment().set('date', 25),
+    ];
+  } else {
+    initDate = [
+      moment()
+        .subtract(2, 'month')
+        .set('date', 26),
+      moment()
+        .subtract(1, 'month')
+        .set('date', 25),
+    ];
+  }
+
   const columns = [
     // {
     //   title: '序号',
@@ -44,7 +63,7 @@ function FinanceProject(props) {
     });
   };
   const handleSearch = () => {
-    const { time } = form.getFieldsValue();
+    const { time, name } = form.getFieldsValue();
     filterRef.current.s_time = time[0] ? moment(time[0]).format('YYYY-MM') : null;
     filterRef.current.e_time = time[1] ? moment(time[1]).format('YYYY-MM') : null;
 
@@ -70,12 +89,17 @@ function FinanceProject(props) {
   const renderSearch = () => {
     return (
       <Form layout="inline" form={form}>
-        <Form.Item
-          label="时间"
-          name="time"
-          initialValue={[moment().subtract(1, 'month'), moment().subtract(1, 'month')]}
-        >
-          <RangePicker placeholder="选择时间" allowClear={false} picker="month" />
+        <Form.Item label="时间" name="time" initialValue={initDate}>
+          <RangePicker placeholder="选择时间" allowClear={false} />
+        </Form.Item>
+        <Form.Item label="填报人" name="name">
+          <Select
+            options={userList}
+            fieldNames={{ label: 'CName', value: 'ID' }}
+            style={{ width: 150 }}
+            showSearch
+            filterOption={(inputValue, option) => option.CName.includes(inputValue)}
+          />
         </Form.Item>
         <Form.Item>
           <Button type="primary" loading={loading} onClick={handleSearch}>
@@ -87,6 +111,9 @@ function FinanceProject(props) {
   };
   useEffect(() => {
     handleSearch();
+    dispatch({
+      type: 'user/fetch',
+    });
   }, []);
 
   return (
@@ -154,7 +181,8 @@ function FinanceProjectModal(props) {
   );
 }
 
-export default connect(({ finance, loading }) => ({
+export default connect(({ finance, user, loading }) => ({
   project: finance.project,
+  userList: user.list,
   loading: loading.models.finance,
 }))(FinanceProject);