From d9d7e12615417e57d3fac95b8e84b7e5fc46af76 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 13 三月 2026 13:51:57 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/config/config.js |  270 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 264 insertions(+), 6 deletions(-)

diff --git a/src/main/webapp/static/js/config/config.js b/src/main/webapp/static/js/config/config.js
index 483f5c6..55aedab 100644
--- a/src/main/webapp/static/js/config/config.js
+++ b/src/main/webapp/static/js/config/config.js
@@ -850,6 +850,185 @@
         return result;
     }
 
+    fieldMeta = [
+        {
+            field: 'id',
+            columnName: 'id',
+            label: 'ID',
+            tableProp: 'id',
+            exportField: 'id',
+            kind: 'text',
+            valueType: 'number',
+            required: true,
+            primaryKey: true,
+            searchable: false,
+            sortable: true,
+            textarea: false,
+            minWidth: 90,
+            enumOptions: [],
+            foreignQuery: '',
+            checkboxActiveRaw: '1',
+            checkboxInactiveRaw: '0'
+        },
+        {
+            field: 'name',
+            columnName: 'name',
+            label: '鍚嶇О',
+            tableProp: 'name',
+            exportField: 'name',
+            kind: 'text',
+            valueType: 'string',
+            required: true,
+            primaryKey: false,
+            searchable: false,
+            sortable: false,
+            textarea: false,
+            minWidth: 180,
+            dialogSpan: 12,
+            enumOptions: [],
+            foreignQuery: '',
+            checkboxActiveRaw: 'Y',
+            checkboxInactiveRaw: 'N'
+        },
+        {
+            field: 'code',
+            columnName: 'code',
+            label: '缂栫爜',
+            tableProp: 'code',
+            exportField: 'code',
+            kind: 'text',
+            valueType: 'string',
+            required: true,
+            primaryKey: false,
+            searchable: true,
+            sortable: false,
+            textarea: false,
+            minWidth: 180,
+            dialogSpan: 12,
+            enumOptions: [],
+            foreignQuery: '',
+            checkboxActiveRaw: 'Y',
+            checkboxInactiveRaw: 'N'
+        },
+        {
+            field: 'value',
+            columnName: 'value',
+            label: '瀵瑰簲鍊�',
+            tableProp: 'value',
+            exportField: 'value',
+            kind: 'text',
+            valueType: 'string',
+            required: true,
+            primaryKey: false,
+            searchable: false,
+            sortable: false,
+            textarea: false,
+            minWidth: 220,
+            dialogSpan: 24,
+            enumOptions: [],
+            foreignQuery: '',
+            checkboxActiveRaw: 'Y',
+            checkboxInactiveRaw: 'N'
+        },
+        {
+            field: 'type',
+            columnName: 'type',
+            label: '绫诲瀷',
+            tableProp: 'type$',
+            exportField: 'type$',
+            kind: 'enum',
+            valueType: 'number',
+            required: true,
+            primaryKey: false,
+            searchable: false,
+            sortable: false,
+            textarea: false,
+            minWidth: 120,
+            dialogSpan: 12,
+            enumOptions: [
+                { rawValue: '1', label: 'String' },
+                { rawValue: '2', label: 'JSON' }
+            ],
+            foreignQuery: '',
+            checkboxActiveRaw: '1',
+            checkboxInactiveRaw: '0'
+        },
+        {
+            field: 'status',
+            columnName: 'status',
+            label: '鐘舵��',
+            tableProp: 'status$',
+            exportField: 'status$',
+            kind: 'enum',
+            valueType: 'number',
+            required: true,
+            primaryKey: false,
+            searchable: false,
+            sortable: false,
+            textarea: false,
+            minWidth: 120,
+            dialogSpan: 12,
+            enumOptions: [
+                { rawValue: '1', label: '姝e父' },
+                { rawValue: '0', label: '绂佺敤' }
+            ],
+            foreignQuery: '',
+            checkboxActiveRaw: '1',
+            checkboxInactiveRaw: '0'
+        },
+        {
+            field: 'selectType',
+            columnName: 'select_type',
+            label: '绛涢�夌被鍨�',
+            tableProp: 'selectType',
+            exportField: 'selectType',
+            kind: 'text',
+            valueType: 'string',
+            required: false,
+            primaryKey: false,
+            searchable: true,
+            sortable: false,
+            textarea: false,
+            minWidth: 140,
+            dialogSpan: 24,
+            enumOptions: [],
+            foreignQuery: '',
+            checkboxActiveRaw: 'Y',
+            checkboxInactiveRaw: 'N'
+        }
+    ];
+
+    function applySelectTypeOptions(options) {
+        var normalizedOptions = [];
+        (options || []).forEach(function (item) {
+            var rawValue = '';
+            var label = '';
+            if (item && typeof item === 'object') {
+                rawValue = item.value !== undefined ? item.value : (item.rawValue !== undefined ? item.rawValue : (item.label !== undefined ? item.label : ''));
+                label = item.label !== undefined ? item.label : rawValue;
+            } else {
+                rawValue = item;
+                label = item;
+            }
+            rawValue = isEmptyValue(rawValue) ? '' : String(rawValue);
+            label = isEmptyValue(label) ? rawValue : String(label);
+            if (!rawValue) {
+                return;
+            }
+            normalizedOptions.push({
+                rawValue: rawValue,
+                label: label
+            });
+        });
+        fieldMeta.forEach(function (field) {
+            if (field.field !== 'selectType') {
+                return;
+            }
+            field.kind = 'enum';
+            field.enumOptions = normalizedOptions;
+        });
+    }
+
     function isEmptyValue(value) {
         return value === null || value === undefined || value === '';
     }
@@ -877,11 +1056,17 @@
     }
 
     function isSearchableField(field) {
-        return !!field && field.kind !== 'image' && !field.textarea;
+        return !!field && field.searchable !== false && field.kind !== 'image' && !field.textarea;
     }
 
     function isSortableField(field) {
         if (!field) {
+            return false;
+        }
+        if (field.sortable === true) {
+            return true;
+        }
+        if (field.sortable === false) {
             return false;
         }
         if (field.primaryKey) {
@@ -1217,6 +1402,7 @@
                         mode: 'create',
                         submitting: false
                     },
+                    tableHeight: 420,
                     layoutTimer: null,
                     tableResizeHandler: null,
                     dialogForm: createFormDefaults(),
@@ -1270,19 +1456,18 @@
                         };
                     });
                 },
-                tableHeight: function () {
-                    return this.advancedFiltersVisible && this.hasAdvancedFilters
-                        ? 'calc(100vh - 390px)'
-                        : 'calc(100vh - 300px)';
-                },
                 formTarget: function () {
                     return this.dialogForm;
                 },
                 displayTarget: function () {
                     return this.dialogDisplay;
+                },
+                isDialogReadonly: function () {
+                    return this.dialog.mode === 'detail';
                 }
             },
             created: function () {
+                this.fetchSelectTypeOptions();
                 this.loadTable();
             },
             mounted: function () {
@@ -1304,12 +1489,26 @@
                 }
             },
             methods: $.extend({}, sharedMethods, {
+                calculateTableHeight: function () {
+                    var viewportHeight = window.innerHeight || document.documentElement.clientHeight || 860;
+                    var tableWrap = this.$refs.tableWrap;
+                    var pagerBar = this.$refs.pagerBar;
+                    if (!tableWrap) {
+                        this.tableHeight = Math.max(360, viewportHeight - (this.advancedFiltersVisible ? 360 : 300));
+                        return;
+                    }
+                    var tableTop = tableWrap.getBoundingClientRect().top;
+                    var pagerHeight = pagerBar ? pagerBar.offsetHeight : 56;
+                    var bottomGap = 56;
+                    this.tableHeight = Math.max(320, Math.floor(viewportHeight - tableTop - pagerHeight - bottomGap));
+                },
                 requestTableLayout: function (delay) {
                     var self = this;
                     if (self.layoutTimer) {
                         clearTimeout(self.layoutTimer);
                     }
                     self.$nextTick(function () {
+                        self.calculateTableHeight();
                         self.layoutTimer = setTimeout(function () {
                             var table = self.$refs.dataTable;
                             if (table && typeof table.doLayout === 'function') {
@@ -1416,6 +1615,26 @@
                         }
                     });
                 },
+                fetchSelectTypeOptions: function () {
+                    var self = this;
+                    $.ajax({
+                        url: baseUrl + '/config/getSelectTypes',
+                        method: 'POST',
+                        headers: self.authHeaders(),
+                        success: function (res) {
+                            if (self.handleForbidden(res)) {
+                                return;
+                            }
+                            if (!res || res.code !== 200) {
+                                return;
+                            }
+                            applySelectTypeOptions(Array.isArray(res.data) ? res.data : []);
+                            self.fieldMeta = fieldMeta.slice();
+                            self.allColumns = fieldMeta.slice();
+                            self.requestTableLayout(80);
+                        }
+                    });
+                },
                 handleSearch: function () {
                     this.page.curr = 1;
                     this.loadTable();
@@ -1475,8 +1694,23 @@
                         }
                     });
                 },
+                openDetailDialog: function (row) {
+                    var self = this;
+                    self.dialog.mode = 'detail';
+                    self.dialog.visible = true;
+                    self.$nextTick(function () {
+                        self.resetDialogState();
+                        fillFormFromRow(row, self.dialogForm, self.dialogDisplay);
+                        if (self.$refs.dialogForm) {
+                            self.$refs.dialogForm.clearValidate();
+                        }
+                    });
+                },
                 submitDialog: function () {
                     var self = this;
+                    if (self.dialog.mode === 'detail') {
+                        return;
+                    }
                     if (!self.$refs.dialogForm) {
                         return;
                     }
@@ -1589,6 +1823,30 @@
                             self.$message.error('瀵煎嚭澶辫触');
                         }
                     });
+                },
+                refreshCache: function () {
+                    var self = this;
+                    self.$confirm('纭畾鍒锋柊Redis缂撳瓨鍚楋紵', '鎻愮ず', { type: 'warning' }).then(function () {
+                        $.ajax({
+                            url: baseUrl + '/config/refreshCache',
+                            method: 'POST',
+                            headers: self.authHeaders(),
+                            success: function (res) {
+                                if (self.handleForbidden(res)) {
+                                    return;
+                                }
+                                if (!res || res.code !== 200) {
+                                    self.$message.error((res && res.msg) ? res.msg : '鍒锋柊缂撳瓨澶辫触');
+                                    return;
+                                }
+                                self.$message.success('鍒锋柊缂撳瓨鎴愬姛');
+                                self.loadTable();
+                            },
+                            error: function () {
+                                self.$message.error('鍒锋柊缂撳瓨澶辫触');
+                            }
+                        });
+                    }).catch(function () {});
                 }
             })
         });

--
Gitblit v1.9.1