From 051981a2211bb86f88a6d68f2e29816f8caeac20 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 04 八月 2023 09:18:10 +0800
Subject: [PATCH] 2023-08-04

---
 src/menu/components/share/searchcomponent/dragsearch/card.jsx |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/menu/components/share/searchcomponent/dragsearch/card.jsx b/src/menu/components/share/searchcomponent/dragsearch/card.jsx
index 1a5c88e..07df0ae 100644
--- a/src/menu/components/share/searchcomponent/dragsearch/card.jsx
+++ b/src/menu/components/share/searchcomponent/dragsearch/card.jsx
@@ -1,6 +1,6 @@
 import React from 'react'
 import { useDrag, useDrop } from 'react-dnd'
-import { Select, DatePicker, Input, Popover, Form } from 'antd'
+import { Select, DatePicker, Input, Popover, Form, Switch, Checkbox } from 'antd'
 import { EditOutlined, CopyOutlined, CloseOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
@@ -21,17 +21,23 @@
   const [, drop] = useDrop({
     accept: 'search',
     canDrop: () => true,
-    drop: ({ id: draggedId }) => {
-      if (!draggedId || draggedId === id) return
-
-      const { index: originIndex } = findCard(draggedId)
-      if (originIndex === -1) return
-
-      const { index: overIndex } = findCard(id)
-      moveCard(draggedId, overIndex)
+    drop: (item) => {
+      const { id: draggedId, originalIndex } = item
+      
+      if (originalIndex === undefined) {
+        item.dropTargetId = id
+      } else {
+        if (!draggedId || draggedId === id) return
+  
+        const { index: originIndex } = findCard(draggedId)
+        if (originIndex === -1) return
+  
+        const { index: overIndex } = findCard(id)
+        moveCard(draggedId, overIndex)
+      }
     }
   })
-  const opacity = isDragging ? 0 : 1
+  const opacity = isDragging ? 0.5 : 1
 
   let _defaultValue = '' // 涓嬫媺鎼滅储銆佹椂闂磋寖鍥寸被鍨嬶紝鍒濆鍊奸渶瑕侀澶勭悊
 
@@ -48,6 +54,8 @@
       _defaultValue = [moment().startOf('week'), moment().endOf('week')]
     } else if (card.initval === 'month') {
       _defaultValue = [moment().startOf('month'), moment().endOf('month')]
+    } else if (card.initval === 'lastMonth') {
+      _defaultValue = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')]
     } else if (card.initval) {
       try {
         let _initval = JSON.parse(card.initval)
@@ -101,6 +109,10 @@
     />
   } else if (card.type === 'group') {
     formItem = <DateGroup card={card} />
+  } else if (card.type === 'switch') {
+    formItem = (<Switch checkedChildren={card.openText || ''} unCheckedChildren={card.closeText || ''} style={{marginTop: '8px'}} checked={card.initval === card.openVal}/>)
+  } else if (card.type === 'check') {
+    formItem = <Checkbox style={{lineHeight: '36px'}} checked={card.initval === card.openVal}>{card.checkTip || ''}</Checkbox>
   }
 
   let labelwidth = card.labelwidth || 33.3

--
Gitblit v1.8.0