From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 12 十二月 2023 21:05:37 +0800
Subject: [PATCH] 2023-12-12

---
 src/menu/components/table/base-table/index.jsx |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/menu/components/table/base-table/index.jsx b/src/menu/components/table/base-table/index.jsx
index c05c3d4..95759e2 100644
--- a/src/menu/components/table/base-table/index.jsx
+++ b/src/menu/components/table/base-table/index.jsx
@@ -259,12 +259,23 @@
     config.cols.forEach(col => {
       if (!col.field) return
       if (['text', 'picture', 'video', 'textarea'].includes(col.type)) {
+        let datatype = `Nvarchar(${col.fieldlength || 50})`
+        let type = 'text'
+
+        if (col.type === 'text') {
+          if (col.textFormat === 'YYYY-MM-DD') {
+            datatype = 'date'
+          } else if (col.textFormat === 'YYYY-MM-DD HH:mm:ss') {
+            datatype = 'datetime'
+          }
+        }
+
         config.columns.push({
-          datatype: `Nvarchar(${col.fieldlength || 50})`,
+          datatype: datatype,
           field: col.field,
           fieldlength: col.fieldlength || 50,
           label: col.label,
-          type: 'text',
+          type: type,
           uuid: col.uuid
         })
       } else if (col.type === 'link') {
@@ -308,6 +319,14 @@
       config.absFields = null
     }
 
+    if (!config.setting.primaryKey && config.columns.length > 0) {
+      config.columns.forEach(col => {
+        if (col.field.toLowerCase() === 'id') {
+          config.setting.primaryKey = col.field
+        }
+      })
+    }
+
     this.updateComponent(config)
   }
 

--
Gitblit v1.8.0