From e1cee96b38805bcccf48e7bcb9d296f2bc54c720 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 24 一月 2025 11:10:32 +0800
Subject: [PATCH] 2025-01-24

---
 src/menu/components/share/searchcomponent/dragsearch/card.jsx |   51 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/src/menu/components/share/searchcomponent/dragsearch/card.jsx b/src/menu/components/share/searchcomponent/dragsearch/card.jsx
index 7961d92..f13b469 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, Radio } from 'antd'
 import { EditOutlined, CopyOutlined, CloseOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
@@ -21,14 +21,20 @@
   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.5 : 1
@@ -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)
@@ -59,6 +67,7 @@
   }
 
   let formItem = null
+  let type = ''
   if (card.type === 'text') {
     if (card.inputType !== 'search') {
       formItem = <Input placeholder={card.label} value={card.initval} />
@@ -96,11 +105,31 @@
       format={format}
       className="data-range"
       placeholder={['BeginTime', 'EndTime']}
-      renderExtraFooter={() => 'extra footer'}
+      renderExtraFooter={() => 'extra footer'} 
       value={_defaultValue}
     />
   } 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 === 'radio') {
+    let options = card.options
+    if (options.length === 0) {
+      options = [{Value: '1', Text: '閫夐」1'}, {Value: '2', Text: '閫夐」2'}]
+    }
+    formItem = (<Radio.Group value={card.initval} style={{lineHeight: '40px', whiteSpace: 'nowrap'}}>
+      {options.map((item, i) => (<Radio key={i} value={item.Value}> {item.Text} </Radio>))}
+    </Radio.Group>)
+  } else if (card.type === 'check') {
+    formItem = <Checkbox style={{lineHeight: '36px', whiteSpace: 'nowrap'}} checked={card.initval === card.openVal}>{card.checkTip || ''}</Checkbox>
+  } else if (card.type === 'range') {
+    type = 'range-wrap'
+    let vals = card.initval.split(',')
+    formItem = (<>
+      <Input style={{marginTop: '4px'}} value={vals[0] || ''} />
+      鑷�
+      <Input style={{marginTop: '4px'}} value={vals[1] || ''} />
+    </>)
   }
 
   let labelwidth = card.labelwidth || 33.3
@@ -116,7 +145,7 @@
         <CloseOutlined className="close" title="鍒犻櫎" onClick={() => delCard(id)} />
       </div>
     } trigger="hover">
-      <div className={'page-card ' + (card.labelShow || '')} style={{ opacity: opacity}}>
+      <div className={`page-card ${type} ${card.labelShow || ''}`} style={{ opacity: opacity}}>
         <div ref={node => drag(drop(node))}>
           <Form.Item
             labelCol={{style: {width: labelwidth + '%'}}}

--
Gitblit v1.8.0