|
|
@@ -47,6 +47,7 @@
|
|
|
:label-width="listConfig.searchForm.labelWidth"
|
|
|
:item-width="listConfig.searchForm.itemWidth"
|
|
|
:previous-data-template="dataTemplate"
|
|
|
+ :setting="setting"
|
|
|
@search="search"
|
|
|
@close="handleRenderDialogClose"
|
|
|
/>
|
|
|
@@ -646,6 +647,12 @@ export default {
|
|
|
}
|
|
|
this.registerGrandChildMethod &&
|
|
|
this.registerGrandChildMethod(this.beforSearch)
|
|
|
+ // 添加全局回车键监听
|
|
|
+ this.addGlobalEnterListener()
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ // 移除全局回车键监听
|
|
|
+ this.removeGlobalEnterListener()
|
|
|
},
|
|
|
updated() {
|
|
|
this.handleRefreshTable()
|
|
|
@@ -1011,6 +1018,73 @@ export default {
|
|
|
formParams['filter_condition_key'] = this.filterConditionKey
|
|
|
return ActionUtils.formatParams(formParams, this.pagination, this.sorts)
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 添加全局回车键监听
|
|
|
+ */
|
|
|
+ addGlobalEnterListener() {
|
|
|
+ const handleGlobalEnter = (event) => {
|
|
|
+ // 检查是否按下了回车键 (keyCode 13 或 key 'Enter')
|
|
|
+ if (event.key === 'Enter' || event.keyCode === 13) {
|
|
|
+ // 检查焦点是否在可编辑元素中
|
|
|
+ const activeElement = document.activeElement
|
|
|
+ const isInEditableElement =
|
|
|
+ activeElement.tagName === 'INPUT' ||
|
|
|
+ activeElement.tagName === 'TEXTAREA' ||
|
|
|
+ activeElement.tagName === 'SELECT' ||
|
|
|
+ activeElement.contentEditable === 'true'
|
|
|
+
|
|
|
+ // 如果焦点在可编辑元素中,让原生事件处理(如搜索表单的handleEnter)
|
|
|
+ // 如果焦点不在可编辑元素中,则触发查询
|
|
|
+ if (!isInEditableElement) {
|
|
|
+ event.preventDefault()
|
|
|
+ event.stopPropagation()
|
|
|
+ this.handleGlobalEnter()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.globalEnterHandler = handleGlobalEnter
|
|
|
+ document.addEventListener('keydown', this.globalEnterHandler)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 移除全局回车键监听
|
|
|
+ */
|
|
|
+ removeGlobalEnterListener() {
|
|
|
+ if (this.globalEnterHandler) {
|
|
|
+ document.removeEventListener('keydown', this.globalEnterHandler)
|
|
|
+ this.globalEnterHandler = null
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理全局回车键事件
|
|
|
+ */
|
|
|
+ handleGlobalEnter() {
|
|
|
+ // 检查是否启用键盘回车查询功能(通过t_ipcc的setting里的内容)
|
|
|
+ const keyboardEnterEnabled = this.setting?.system?.keyboardEnterForsearch === true
|
|
|
+
|
|
|
+ if (!keyboardEnterEnabled) {
|
|
|
+ return // 未启用键盘回车查询功能,直接返回
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否有查询按钮权限
|
|
|
+ const hasSearchButton = this.listConfig.toolbars &&
|
|
|
+ this.listConfig.toolbars.some(button =>
|
|
|
+ button.button_type === 'search' || button.key === 'search'
|
|
|
+ )
|
|
|
+
|
|
|
+ if (hasSearchButton) {
|
|
|
+ // 模拟点击查询按钮
|
|
|
+ // 数据模板列表查询数据前先清除已选中数据,(弹框除外)
|
|
|
+ if (this.dataTemplate.type !== 'dialog') {
|
|
|
+ this.clearSelection()
|
|
|
+ }
|
|
|
+ ActionUtils.setFirstPagination(this.pagination)
|
|
|
+ this.search()
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 处理分页事件
|
|
|
*/
|