From ac4e2892a68bb4ef5b35e8e2e12e76d3ec3ede35 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 07 七月 2023 18:50:11 +0800
Subject: [PATCH] 2023-07-07

---
 src/tabviews/custom/components/calendar/index.jsx |   75 +++++++++++++++++++++++++++++++------
 1 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/src/tabviews/custom/components/calendar/index.jsx b/src/tabviews/custom/components/calendar/index.jsx
index c9ba92b..0d7c725 100644
--- a/src/tabviews/custom/components/calendar/index.jsx
+++ b/src/tabviews/custom/components/calendar/index.jsx
@@ -8,12 +8,12 @@
 import asyncComponent from '@/utils/asyncComponent'
 import UtilsDM from '@/utils/utils-datamanage.js'
 import MKEmitter from '@/utils/events.js'
+import CalendarBoard from './board'
 import './index.scss'
 
 const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader'))
 const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
 const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton'))
-const CalendarBoard = asyncComponent(() => import('./board'))
 
 class NormalCalendar extends Component {
   static propTpyes = {
@@ -25,7 +25,7 @@
     BID: '',                   // 涓婄骇ID
     config: null,              // 鍥捐〃閰嶇疆淇℃伅
     loading: false,            // 鏁版嵁鍔犺浇鐘舵��
-    data: null,                // 鏁版嵁
+    data: [],                // 鏁版嵁
     search: '',
     year: new Date().getFullYear(),
     BData: ''
@@ -55,6 +55,10 @@
       _config.setting.$re_year = true
     }
 
+    if (_config.wrap.colorField && (!_config.wrap.signs || _config.wrap.signs.length === 0)) {
+      _config.wrap.colorField = ''
+    }
+
     this.setState({
       BID: BData ? (BData.$BID || '') : '',
       BData: BData,
@@ -81,13 +85,19 @@
       Api.getLCacheConfig(config.uuid).then(res => {
         if (!res || this.loaded) return
 
-        this.setState({data: res.map((item, index) => {
+        let data = []
+        res.forEach((item, index) => {
           item.key = index
           item.$$uuid = item[config.setting.primaryKey] || ''
-          item.$Index = index + 1 + ''
-          
-          return item
-        })})
+
+          let pass = this.resetLine(item)
+
+          if (pass) {
+            data.push(item)
+          }
+        })
+
+        this.setState({data: data})
       })
     }
   }
@@ -196,19 +206,24 @@
         Api.writeCacheConfig(config.uuid, result.data || '')
       }
 
-      let data = result.data.map((item, index) => {
+      let data = []
+      result.data.forEach((item, index) => {
         item.key = index
         item.$$uuid = item[config.setting.primaryKey] || ''
         item.$$BID = BID || ''
 
-        return item
+        let pass = this.resetLine(item)
+
+        if (pass) {
+          data.push(item)
+        }
       })
 
       this.setState({
         data: data,
         loading: false
       })
-
+      
       if (result.message) {
         if (result.ErrCode === 'Y') {
           Modal.success({
@@ -242,6 +257,42 @@
     }
   }
 
+  resetLine = (item) => {
+    const { config: { wrap } } = this.state
+
+    let startTime = item[wrap.timeField] || ''
+    let endTime = item[wrap.endField || wrap.timeField] || ''
+
+    item.$message = item[wrap.remarkField]
+
+    if (!/^(1|2)\d{3}(-|\/)\d{2}(-|\/)\d{2}/.test(startTime)) return false
+    if (!/^(1|2)\d{3}(-|\/)\d{2}(-|\/)\d{2}/.test(endTime)) return false
+    if (!item.$message) return false
+
+    if (wrap.colorField) {
+      let sign = item[wrap.colorField] || ''
+
+      wrap.signs.forEach(cell => {
+        if (cell.sign !== sign) return
+
+        item.$style = cell.style
+        item.$color = cell.background
+        item.$level = cell.$index
+      })
+    }
+
+    let equal = endTime.substr(0, 4) === startTime.substr(0, 4)
+
+    item.$startM = +(startTime.substr(0, 4) + startTime.substr(5, 2))
+    item.$endM = +(endTime.substr(0, 4) + endTime.substr(5, 2))
+    item.$start = +(startTime.substr(0, 4) + startTime.substr(5, 2) + startTime.substr(8, 2))
+    item.$end = +(endTime.substr(0, 4) + endTime.substr(5, 2) + endTime.substr(8, 2))
+    item.$startTime = equal ? `${startTime.substr(5, 2)}-${startTime.substr(8, 2)}` : `${startTime.substr(0, 4)}-${startTime.substr(5, 2)}-${startTime.substr(8, 2)}`
+    item.$endTime = equal ?  `${endTime.substr(5, 2)}-${endTime.substr(8, 2)}` : `${endTime.substr(0, 4)}-${endTime.substr(5, 2)}-${endTime.substr(8, 2)}`
+    
+    return true
+  }
+
   refreshbysearch = (searches) => {
     this.setState({
       search: searches
@@ -257,7 +308,7 @@
       <div className="normal-calendar-box" id={'anchor' + config.uuid} style={{...config.style}}>
         {loading ?
           <div className="loading-mask">
-            {data ? <div className="ant-spin-blur"></div> : null}
+            <div className="ant-spin-blur"></div>
             <Spin />
           </div> : null
         }
@@ -268,7 +319,7 @@
         {config.action[0] ? 
           <PopupButton disabled={false} BID={BID} btn={config.action[0]} BData={BData} setting={config.setting} selectedData={[]}/> : null
         }
-        <CalendarBoard config={config} />
+        <CalendarBoard config={config} data={data}/>
       </div>
     )
   }

--
Gitblit v1.8.0