From a1e9b18a4dbfd21e1bf4d5cb60974ac2f0115efd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 30 五月 2025 15:18:44 +0800
Subject: [PATCH] 2025-05-30

---
 src/tabviews/zshare/mutilform/mkDatePicker/index.jsx |   51 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx b/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx
index b2acd83..1f96b82 100644
--- a/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx
@@ -3,6 +3,8 @@
 import { DatePicker } from 'antd'
 import moment from 'moment'
 
+import MKEmitter from '@/utils/events.js'
+
 const { MonthPicker } = DatePicker
 
 /**
@@ -20,19 +22,25 @@
     if (config.type === 'datemonth') {
       mode = 'month'
       format = 'YYYY-MM'
-    } else if (config.type === 'datetime') {
-      mode = 'datetime'
+    } else if (config.precision === 'day') {
+      format = 'YYYY-MM-DD'
+    } else if (config.precision === 'hour') {
+      format = 'YYYY-MM-DD HH'
+    } else if (config.precision === 'minute') {
+      format = 'YYYY-MM-DD HH:mm'
+    } else if (config.precision === 'second') {
       format = 'YYYY-MM-DD HH:mm:ss'
     }
+
     let value = config.initval || null
     if (value) {
-      value = moment(value, format)
+      value = moment(value, 'YYYY-MM-DD HH:mm:ss')
     }
 
     this.state = {
       value,
-      minDate: config.minDate ? moment().add(config.minDate, 'days').endOf('day') : '',
-      maxDate: config.maxDate ? moment().add(config.maxDate, 'days').endOf('day') : '',
+      minDate: config.minDate ? moment(config.minDate).startOf('day') : '',
+      maxDate: config.maxDate ? moment(config.maxDate).endOf('day') : '',
       mode,
       format
     }
@@ -49,9 +57,30 @@
   }
 
   onChange = (val) => {
-    const { format } = this.state
+    const { config } = this.props
+    const { format, mode } = this.state
+    let _val = val ? moment(val).format(format) : ''
 
-    this.props.onChange(val ? moment(val).format(format) : '')
+    if (mode === 'date' && _val) {
+      if (config.precision === 'hour') {
+        _val = _val + ':00:00'
+      } else if (config.precision === 'minute') {
+        _val = _val + ':00'
+      }
+    }
+
+    this.props.onChange(_val)
+
+    if (!config.enter || config.enter === 'false') return
+
+    setTimeout(() => {
+      if (config.enter === 'tab') {
+        MKEmitter.emit('mkFC', 'focus', config.tabUuid)
+      } else if (config.enter === 'sub') {
+        config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid)
+        this.props.onSubmit(config.tabUuid, config.errTabUuid)
+      }
+    }, 50)
   }
 
   disabledDate = (current) => {
@@ -60,7 +89,7 @@
     if (!current || (!maxDate && !minDate)) {
       return false
     }
-    
+
     if (!maxDate) {
       return current < minDate
     } else if (!minDate) {
@@ -72,14 +101,12 @@
 
   render() {
     const { config } = this.props
-    const { value, mode } = this.state
+    const { value, mode, format } = this.state
 
     if (mode === 'date') {
-      return <DatePicker defaultValue={value} disabledDate={this.disabledDate} disabled={config.readonly} onChange={this.onChange}/>
+      return <DatePicker dropdownClassName={'mk-date-picker ' + config.precision} showTime={format !== 'YYYY-MM-DD'} format={format} defaultValue={value} disabledDate={this.disabledDate} disabled={config.readonly} onChange={this.onChange}/>
     } else if (mode === 'month') {
       return <MonthPicker defaultValue={value} disabled={config.readonly} onChange={this.onChange}/>
-    } else if (mode === 'datetime') {
-      return <DatePicker defaultValue={value} disabledDate={this.disabledDate} showTime disabled={config.readonly} onChange={this.onChange}/>
     }
   }
 }

--
Gitblit v1.8.0