Просмотр исходного кода

工时报表 时间选择改为前月26-当月25

XuZinan 2 лет назад
Родитель
Сommit
a33e392545

+ 21 - 12
src/pages/PurchaseAdmin/PurchaseList/Report/Department.js

@@ -10,16 +10,25 @@ import * as echarts from 'echarts';
 import { CloseOutlined } from '@ant-design/icons';
 
 const { RangePicker } = DatePicker;
-const initData = [
-  // 上个月第一天
-  moment()
-    .subtract(1, 'month')
-    .startOf('month'),
-  // 上个月最后一天
-  moment()
-    .subtract(1, 'month')
-    .endOf('month'),
-];
+//按天取前月26-当月25
+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),
+  ];
+}
 
 function Department(props) {
   const { dispatch, loading, dep } = props;
@@ -122,8 +131,8 @@ function Department(props) {
   const renderSearch = () => {
     return (
       <Form layout="inline" form={form}>
-        <Form.Item label="时间" name="time" initialValue={initData}>
-          <RangePicker placeholder="选择时间" allowClear={false} picker="month" />
+        <Form.Item label="时间" name="time" initialValue={initDate}>
+          <RangePicker placeholder="选择时间" allowClear={false} />
         </Form.Item>
         <Form.Item>
           <Button type="primary" loading={loading} onClick={handleSearch}>

+ 21 - 6
src/pages/PurchaseAdmin/PurchaseList/Report/Finance/Resources.js

@@ -25,6 +25,25 @@ function FinanceResource(props) {
     { title: '招采中心执行人日数', dataIndex: 'purchase_exe_workload' },
   ];
 
+  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 handleSearch = () => {
     const { time } = form.getFieldsValue();
     let s_time = time[0] ? moment(time[0]).format('YYYY-MM') : null;
@@ -42,12 +61,8 @@ function FinanceResource(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>
           <Button type="primary" loading={loading} onClick={handleSearch}>

+ 21 - 6
src/pages/PurchaseAdmin/PurchaseList/Report/ProjectTree.js

@@ -18,6 +18,25 @@ function ProjectTree(props) {
     dep: false,
   });
 
+  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 = useMemo(() => {
     let arr = [
       {
@@ -114,12 +133,8 @@ function ProjectTree(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>
           <Button type="primary" loading={loading} onClick={handleSearch}>