From 796289b86174721ee41ecba7add7a4526afe5ec4 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期二, 16 七月 2024 09:29:41 +0800
Subject: [PATCH] #
---
zy-asrs-admin/.babelrc | 10 ++
zy-asrs-admin/package.json | 1
zy-asrs-admin/src/views/system/operationRecord/index.vue | 174 +++++++++++++++++++---------------
zy-asrs-admin/package-lock.json | 1
zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/VueGenerator.java | 9 +
zy-asrs-admin/src/utils/tableUtils.jsx | 56 +++++++++++
zy-asrs-admin/src/views/system/language/index.vue | 11 ++
zy-asrs-framework/src/main/resources/templates/vue/Index.txt | 5 +
8 files changed, 186 insertions(+), 81 deletions(-)
diff --git a/zy-asrs-admin/.babelrc b/zy-asrs-admin/.babelrc
new file mode 100644
index 0000000..4f1f573
--- /dev/null
+++ b/zy-asrs-admin/.babelrc
@@ -0,0 +1,10 @@
+{
+ "plugins": [
+ [
+ "@vue/babel-plugin-jsx",
+ {
+ "theme": "vue3"
+ }
+ ]
+ ]
+}
\ No newline at end of file
diff --git a/zy-asrs-admin/package-lock.json b/zy-asrs-admin/package-lock.json
index 8451b2f..52b0401 100644
--- a/zy-asrs-admin/package-lock.json
+++ b/zy-asrs-admin/package-lock.json
@@ -19,6 +19,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
+ "@vue/babel-plugin-jsx": "^1.2.2",
"vite": "^5.3.1"
}
},
diff --git a/zy-asrs-admin/package.json b/zy-asrs-admin/package.json
index 4ba2ff9..e34b532 100644
--- a/zy-asrs-admin/package.json
+++ b/zy-asrs-admin/package.json
@@ -20,6 +20,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
+ "@vue/babel-plugin-jsx": "^1.2.2",
"vite": "^5.3.1"
}
}
diff --git a/zy-asrs-admin/src/utils/tableUtils.jsx b/zy-asrs-admin/src/utils/tableUtils.jsx
new file mode 100644
index 0000000..d7f675e
--- /dev/null
+++ b/zy-asrs-admin/src/utils/tableUtils.jsx
@@ -0,0 +1,56 @@
+import { formatMessage } from '@/utils/localeUtils.js';
+import { ref } from 'vue';
+
+export default function useTableSearch() {
+ const searchText = ref('');
+ const searchedColumn = ref('');
+
+ const handleSearch = (selectedKeys, confirm, dataIndex) => {
+ confirm();
+ searchText.value = selectedKeys[0];
+ searchedColumn.value = dataIndex;
+ };
+
+ const handleReset = (clearFilters) => {
+ clearFilters({
+ confirm: true,
+ });
+ searchText.value = '';
+ };
+
+ const getColumnSearchProps = (dataIndex) => ({
+ filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
+ <div style="padding: 8px">
+ <a-input
+ v-model:value={selectedKeys[0]}
+ placeholder={formatMessage('common.search.placeholder','璇锋悳绱�')}
+ style="width: 188px; margin-bottom: 8px; display: block;"
+ onChange={(e) => setSelectedKeys(e.target.value ? [e.target.value] : [])}
+ onPressEnter={() => handleSearch(selectedKeys, confirm, dataIndex)}
+ />
+ <a-button
+ type="primary"
+ onClick={() => handleSearch(selectedKeys, confirm, dataIndex)}
+ size="small"
+ style="width: 90px; margin-right: 8px"
+ >
+ {formatMessage('common.search','鎼滅储')}
+ </a-button>
+ <a-button onClick={() => handleReset(clearFilters)} size="small" style="width: 90px">
+ {formatMessage('common.reset','閲嶇疆')}
+ </a-button>
+ </div>
+ ),
+ onFilter: (value, record) =>
+ record[dataIndex]
+ ? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase())
+ : '',
+ });
+
+ return {
+ searchText,
+ searchedColumn,
+ getColumnSearchProps,
+ };
+}
+
diff --git a/zy-asrs-admin/src/views/system/language/index.vue b/zy-asrs-admin/src/views/system/language/index.vue
index f16883d..796145a 100644
--- a/zy-asrs-admin/src/views/system/language/index.vue
+++ b/zy-asrs-admin/src/views/system/language/index.vue
@@ -6,6 +6,7 @@
import { logout } from '@/config.js';
import EditView from './edit.vue'
import { formatMessage } from '@/utils/localeUtils.js';
+import useTableSearch from '@/utils/tableUtils.jsx';
const context = getCurrentInstance()?.appContext.config.globalProperties;
const router = useRouter();
@@ -19,42 +20,52 @@
let tableData = ref([]);
getPage();
+const {
+ getColumnSearchProps,
+} = useTableSearch();
+
const columns = [
{
title: formatMessage('db.sys_language.name', '鍚嶇О'),
dataIndex: 'name',
width: 140,
ellipsis: true,
+ ...getColumnSearchProps('name'),
},
{
title: formatMessage('db.sys_language.language_id', '鍥介檯鍖朓D'),
dataIndex: 'languageId',
width: 140,
ellipsis: true,
+ ...getColumnSearchProps('languageId'),
},
{
title: formatMessage('db.sys_language.locale', '鍦板尯'),
dataIndex: 'locale',
width: 140,
ellipsis: true,
+ ...getColumnSearchProps('locale'),
},
{
title: formatMessage('db.sys_language.create_time', '娣诲姞鏃堕棿'),
dataIndex: 'createTime$',
width: 140,
ellipsis: true,
+ ...getColumnSearchProps('createTime$'),
},
{
title: formatMessage('db.sys_language.update_time', '淇敼鏃堕棿'),
dataIndex: 'updateTime$',
width: 140,
ellipsis: true,
+ ...getColumnSearchProps('updateTime$'),
},
{
title: formatMessage('db.sys_language.memo', '澶囨敞'),
dataIndex: 'memo',
width: 140,
ellipsis: true,
+ ...getColumnSearchProps('memo'),
},
{
diff --git a/zy-asrs-admin/src/views/system/operationRecord/index.vue b/zy-asrs-admin/src/views/system/operationRecord/index.vue
index e041f71..d235645 100644
--- a/zy-asrs-admin/src/views/system/operationRecord/index.vue
+++ b/zy-asrs-admin/src/views/system/operationRecord/index.vue
@@ -6,6 +6,7 @@
import { logout } from '@/config.js';
import EditView from './edit.vue'
import { formatMessage } from '@/utils/localeUtils.js';
+import useTableSearch from '@/utils/tableUtils.jsx';
const context = getCurrentInstance()?.appContext.config.globalProperties;
const router = useRouter();
@@ -19,85 +20,102 @@
let tableData = ref([]);
getPage();
+const {
+ getColumnSearchProps,
+} = useTableSearch();
+
const columns = [
- {
- title: formatMessage('db.sys_operation_record.namespace', '鍚嶇О绌洪棿'),
- dataIndex: 'namespace',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.url', '鎺ュ彛鍦板潃'),
- dataIndex: 'url',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.appkey', '骞冲彴瀵嗛挜'),
- dataIndex: 'appkey',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.timestamp', '鏃堕棿鎴�'),
- dataIndex: 'timestamp',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.client_ip', '瀹㈡埛绔疘P'),
- dataIndex: 'clientIp',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.request', '璇锋眰鍐呭'),
- dataIndex: 'request',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.response', '鍝嶅簲鍐呭'),
- dataIndex: 'response',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.spend_time', '娑堣�楁椂闂�'),
- dataIndex: 'spendTime',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.err', '寮傚父鍐呭'),
- dataIndex: 'err',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.result', '缁撴灉'),
- dataIndex: 'result$',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.user_id', '鐢ㄦ埛'),
- dataIndex: 'userId$',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.create_time', '娣诲姞鏃堕棿'),
- dataIndex: 'createTime$',
- width: 140,
- ellipsis: true,
- },
- {
- title: formatMessage('db.sys_operation_record.memo', '澶囨敞'),
- dataIndex: 'memo',
- width: 140,
- ellipsis: true,
- },
+ {
+ title: formatMessage('db.sys_operation_record.namespace', '鍚嶇О绌洪棿'),
+ dataIndex: 'namespace',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('namespace'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.url', '鎺ュ彛鍦板潃'),
+ dataIndex: 'url',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('url'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.appkey', '骞冲彴瀵嗛挜'),
+ dataIndex: 'appkey',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('appkey'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.timestamp', '鏃堕棿鎴�'),
+ dataIndex: 'timestamp',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('timestamp'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.client_ip', '瀹㈡埛绔疘P'),
+ dataIndex: 'clientIp',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('clientIp'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.request', '璇锋眰鍐呭'),
+ dataIndex: 'request',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('request'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.response', '鍝嶅簲鍐呭'),
+ dataIndex: 'response',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('response'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.spend_time', '娑堣�楁椂闂�'),
+ dataIndex: 'spendTime',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('spendTime'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.err', '寮傚父鍐呭'),
+ dataIndex: 'err',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('err'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.result', '缁撴灉'),
+ dataIndex: 'result$',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('result$'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.user_id', '鐢ㄦ埛'),
+ dataIndex: 'userId$',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('userId$'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.create_time', '娣诲姞鏃堕棿'),
+ dataIndex: 'createTime$',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('createTime$'),
+ },
+ {
+ title: formatMessage('db.sys_operation_record.memo', '澶囨敞'),
+ dataIndex: 'memo',
+ width: 140,
+ ellipsis: true,
+ ...getColumnSearchProps('memo'),
+ },
{
title: formatMessage('common.operation', '鎿嶄綔'),
diff --git a/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/VueGenerator.java b/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/VueGenerator.java
index 8a3488f..e04e49e 100644
--- a/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/VueGenerator.java
+++ b/zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/VueGenerator.java
@@ -783,15 +783,18 @@
sb.append(" {\n")
.append(" title: formatMessage('db.").append(table).append(".").append(column.getName()).append("', '").append(column.getComment()).append("'),").append("\n")
.append(" dataIndex: '");
+ StringBuilder rowKey = new StringBuilder();
if ("Date".equals(column.getType()) || !Cools.isEmpty(column.getEnums()) || !Cools.isEmpty(column.getForeignKeyMajor())){
// 鏃堕棿銆佹灇涓� 鏍煎紡鍖� 涓婚敭淇グ
- sb.append(column.getHumpName()).append("\\$");
+ rowKey.append(column.getHumpName()).append("\\$");
} else {
- sb.append(column.getHumpName());
+ rowKey.append(column.getHumpName());
}
+ sb.append(rowKey);
sb.append("',\n")
.append(" width: 140,\n")
- .append(" ellipsis: true,\n");
+ .append(" ellipsis: true,\n")
+ .append(" ...getColumnSearchProps('").append(rowKey).append("'),\n");
// if (!Cools.isEmpty(column.getEnums())) {
// sb.append(" customRender: (column) => {\n");
// sb.append(" let typeMap = {");
diff --git a/zy-asrs-framework/src/main/resources/templates/vue/Index.txt b/zy-asrs-framework/src/main/resources/templates/vue/Index.txt
index 7c707ba..367711a 100644
--- a/zy-asrs-framework/src/main/resources/templates/vue/Index.txt
+++ b/zy-asrs-framework/src/main/resources/templates/vue/Index.txt
@@ -6,6 +6,7 @@
import { logout } from '@/config.js';
import EditView from './edit.vue'
import { formatMessage } from '@/utils/localeUtils.js';
+import useTableSearch from '@/utils/tableUtils.jsx';
const context = getCurrentInstance()?.appContext.config.globalProperties;
const router = useRouter();
@@ -19,6 +20,10 @@
let tableData = ref([]);
getPage();
+const {
+ getColumnSearchProps,
+} = useTableSearch();
+
const columns = [
@{TABLECOLUMNS}
{
--
Gitblit v1.9.1