浏览代码

feat: 整改单提交增加时间选择限制

lanjianrong 4 年之前
父节点
当前提交
f70c6049f6

+ 2 - 1
src/components/DatePicker.tsx

@@ -1,7 +1,8 @@
 import generatePicker from 'antd/es/date-picker/generatePicker'
 import 'antd/es/date-picker/style/index'
-import { Dayjs } from 'dayjs'
+import  { Dayjs } from 'dayjs'
 import 'dayjs/locale/zh-cn'
+// dayjs.locale('zh-cn')
 import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs'
 
 const DatePicker = generatePicker<Dayjs>(dayjsGenerateConfig)

+ 2 - 3
src/pages/Contract/Content/Summary/components/Content/index.tsx

@@ -67,7 +67,6 @@ const Content: React.FC<iContentProps> = ({ data, type }) => {
 
   const dualAxesConfig: DualAxesConfig = {
     data: [ data.returnDate, data.returnDate ],
-    autoFit: true,
     // padding: 'auto',
     xField: 'month',
     yField: [ 'value', 'count' ],
@@ -87,12 +86,12 @@ const Content: React.FC<iContentProps> = ({ data, type }) => {
     yAxis: {
       value: {
         label: {
-          formatter: (val) => `${val} 元`
+          formatter: (val) => `${val}元`
         }
       },
       count: {
         label: {
-          formatter: (val) => `${val} %`
+          formatter: (val) => `${val}%`
         }
       }
     },

+ 1 - 1
src/pages/Dashboard/index.tsx

@@ -70,7 +70,7 @@ const Index = () => {
                                 <span className={[ 'pi-pd-lr-15', 'pi-height-18', messageType[item.dataType]?.class ].join(' ')}>{messageType[item.dataType]?.title}</span>
                                 <span className="pi-pd-lr-15">
                                   <span>{item.bidsectionName}</span>
-                                  <Link to={{ pathname: messageType[item.dataType]?.path, state: { id: item.dataId } }}>{item.inspectionDetail}</Link>
+                                  <Link to={{ pathname: messageType[item.dataType]?.path, state: { id: item.dataId } }}>{item.inspection}</Link>
                                 </span>
                               </div>
                               <ZhButton size="small"><Link to={{ pathname: messageType[item.dataType]?.path, state: { id: item.dataId } }}>审批</Link></ZhButton>

+ 5 - 4
src/pages/Quality/Content/Info/Detail/index.tsx

@@ -15,7 +15,6 @@ import { auditProgress } from '@/utils/common/constStatus'
 import consts from '@/utils/consts'
 import { dayjsFormat } from '@/utils/util'
 import { Button, Input, message, Pagination, Tooltip } from 'antd'
-import locale from 'antd/es/date-picker/locale/zh_CN'
 import dayjs from 'dayjs'
 import React, { useEffect, useState } from 'react'
 import { RouteComponentProps } from 'react-router'
@@ -281,6 +280,10 @@ const Detail: React.FC<RouteComponentProps> = props => {
     setModalObj({ ...modalObj, auditModal: false })
   }
 
+  const disabledDate = (current: dayjs.Dayjs) => {
+    return current.add(1, 'day') < dayjs(detail.createTime)
+  }
+
   return (
     <div className="wrap-contaniner">
       <Header title="质量巡检">
@@ -348,7 +351,6 @@ const Detail: React.FC<RouteComponentProps> = props => {
                   ) : (
                       <DatePicker
                         size="small"
-                        locale={locale}
                         allowClear={false}
                         value={dayjs(detail.createTime)}
                         onChange={value => setDetail({ ...detail, createTime: value?.format() })} />
@@ -384,9 +386,8 @@ const Detail: React.FC<RouteComponentProps> = props => {
                   <td>
                     <DatePicker
                       size="small"
-                      locale={locale}
                       allowClear={false}
-                      value={dayjs(detail.checkOrder.create_time)}
+                      disabledDate={disabledDate}
                       onChange={value => setDetail({ ...detail, checkOrder: { ...detail.checkOrder, create_time: value?.format() } })} />
                   </td>
                 </tr>

+ 3 - 1
src/pages/Safe/Content/Info/Detail/api.ts

@@ -14,7 +14,9 @@ export async function apiGetSafeDetail(id: string) {
       auditHistory.unshift(history)
     }
   }
-  data.data.auditHistory = auditHistory
+  if (data && data.data && data.data.auditHistory) {
+    data.data.auditHistory = auditHistory
+  }
   return data
 }
 

+ 6 - 6
src/pages/Safe/Content/Info/Detail/index.tsx

@@ -15,9 +15,8 @@ import { auditProgress } from '@/utils/common/constStatus'
 import consts from '@/utils/consts'
 import { dayjsFormat } from '@/utils/util'
 import { Button, Input, message, Pagination, Tooltip } from 'antd'
-import locale from 'antd/es/date-picker/locale/zh_CN'
 import dayjs from 'dayjs'
-import React, { useEffect, useState, useMemo } from 'react'
+import React, { useEffect, useState } from 'react'
 import { RouteComponentProps } from 'react-router'
 import { apiGetSafeDetail, apiResfulSafeAudit } from './api'
 import AuditModal from '@/pages/Quality/Content/Info/Detail/components/Modal'
@@ -59,7 +58,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
       name: '',
       status: 0,
       opinion: '',
-      create_time: new Date().toDateString()
+      create_time: undefined
     },
     auditHistory: [],
     rectifiedInfo: [],
@@ -273,6 +272,9 @@ const Detail: React.FC<RouteComponentProps> = props => {
 
   const auditData = { auditors: detail.auditors, auditHistory: detail.auditHistory, status: detail.status, uName: detail.auditName, uid: detail.uid }
 
+  const disabledDate = (current: dayjs.Dayjs) => {
+    return current.add(1, 'day') < dayjs(detail.createTime)
+  }
   return (
     <div className="wrap-contaniner">
       <Header title="安全巡检">
@@ -323,7 +325,6 @@ const Detail: React.FC<RouteComponentProps> = props => {
                     isEdited ? <span>{detail.createTime && dayjsFormat(detail.createTime, 'YYYY-MM-DD')}</span> :
                       <DatePicker
                         size="small"
-                        locale={locale}
                         allowClear={false}
                         value={dayjs(detail.createTime)}
                         onChange={value => setDetail({ ...detail, createTime: value?.format() })} />
@@ -359,9 +360,8 @@ const Detail: React.FC<RouteComponentProps> = props => {
                     <td>
                       <DatePicker
                         size="small"
-                        locale={locale}
                         allowClear={false}
-                        value={dayjs(detail.checkOrder.create_time)}
+                        disabledDate={disabledDate}
                         onChange={value => setDetail({ ...detail, checkOrder: { ...detail.checkOrder, create_time: value?.format() } })} />
                     </td>
                   </tr>

+ 1 - 0
src/types/dashboard.d.ts

@@ -17,6 +17,7 @@ interface ApproverDatum {
   dataId: string;
   status: number;
   code: string;
+  inspection: string;
   inspectionDetail: string;
   name: string;
   position: string;