Browse Source

feat: 客户统计时间转换

outaozhen 4 years atrás
parent
commit
28adfeb671
1 changed files with 17 additions and 7 deletions
  1. 17 7
      src/pages/Statistic/Product/CustomerAdditions/index.jsx

+ 17 - 7
src/pages/Statistic/Product/CustomerAdditions/index.jsx

@@ -19,11 +19,8 @@ const CustomerAdditions = () => {
     chart: {},
     type: 'month'
   })
-
-  const [type, setType] = useState('month')
   const [dates, setDates] = useState([])
   const [hackValue, setHackValue] = useState()
-  const [value, setValue] = useState()
   const tRef = useRef(null)
   const handleOptionChange = (type, ids) =>
     setState({ ...state, params: { ...state.params, optionType: type, dataIds: ids } })
@@ -31,9 +28,22 @@ const CustomerAdditions = () => {
     if (!dates || dates.length === 0) {
       return false
     }
-    const tooLate = dates[0] && current.diff(dates[0], 'month') > 10
-    const tooEarly = dates[1] && dates[1].diff(current, 'month') > 10
-    return tooEarly || tooLate
+    if (state.type === 'month') {
+      const tooLate = dates[0] && current.diff(dates[0], 'month') > 10
+      const tooEarly = dates[1] && dates[1].diff(current, 'month') > 10
+      return tooEarly || tooLate
+    }
+    if (state.type === 'week') {
+      const tooLate = dates[0] && current.diff(dates[0], 'weeks') > 11
+      const tooEarly = dates[1] && dates[1].diff(current, 'weeks') > 11
+      return tooEarly || tooLate
+    }
+    if (state.type === 'date') {
+      const tooLate = dates[0] && current.diff(dates[0], 'days') > 29
+      const tooEarly = dates[1] && dates[1].diff(current, 'days') > 29
+      return tooEarly || tooLate
+    }
+    // return tooEarly || tooLate
   }
   const onOpenChange = open => {
     if (open) {
@@ -103,7 +113,7 @@ const CustomerAdditions = () => {
                 <Option value="date">日</Option>
               </Select>
               <RangePicker
-                picker={type}
+                picker={state.type}
                 disabledDate={disabledDate}
                 onCalendarChange={val => setDates(val)}
                 onOpenChange={onOpenChange}