From 135d70da091ca0554f9c55dbb5702e9b91c41f6d Mon Sep 17 00:00:00 2001 From: calvin Date: Wed, 2 Nov 2022 21:40:39 +0800 Subject: [PATCH] support to use the clearable button of components to search (#12668) --- .../src/views/projects/list/index.tsx | 10 +++++ .../projects/task/definition/batch-task.tsx | 21 ++++++++++ .../projects/task/instance/batch-task.tsx | 42 +++++++++++++++++++ .../projects/task/instance/stream-task.tsx | 42 +++++++++++++++++++ .../projects/workflow/definition/index.tsx | 12 ++++++ .../components/process-instance-condition.tsx | 24 +++++++++++ 6 files changed, 151 insertions(+) diff --git a/dolphinscheduler-ui/src/views/projects/list/index.tsx b/dolphinscheduler-ui/src/views/projects/list/index.tsx index 6af0b72bc9..51fb519af5 100644 --- a/dolphinscheduler-ui/src/views/projects/list/index.tsx +++ b/dolphinscheduler-ui/src/views/projects/list/index.tsx @@ -60,6 +60,14 @@ const list = defineComponent({ requestData() } + const onClearSearch = () => { + variables.page = 1 + getTableData({ + pageSize: variables.pageSize, + pageNo: variables.page + }) + } + const onCancelModal = () => { variables.showModalRef = false } @@ -93,6 +101,7 @@ const list = defineComponent({ handleSearch, onCancelModal, onConfirmModal, + onClearSearch, handleChangePageSize, trim } @@ -118,6 +127,7 @@ const list = defineComponent({ v-model={[this.searchVal, 'value']} placeholder={t('project.list.project_tips')} clearable + onClear={this.onClearSearch} /> diff --git a/dolphinscheduler-ui/src/views/projects/task/definition/batch-task.tsx b/dolphinscheduler-ui/src/views/projects/task/definition/batch-task.tsx index 86f9f21d64..783baef0b1 100644 --- a/dolphinscheduler-ui/src/views/projects/task/definition/batch-task.tsx +++ b/dolphinscheduler-ui/src/views/projects/task/definition/batch-task.tsx @@ -75,6 +75,21 @@ const BatchTaskDefinition = defineComponent({ requestData() } + const onClearSearchTaskName = () => { + variables.searchTaskName = null + onSearch() + } + + const onClearSearchWorkflowName = () => { + variables.searchWorkflowName = null + onSearch() + } + + const onClearSearchTaskType = () => { + variables.taskType = null + onSearch() + } + const onRefresh = () => { variables.showVersionModalRef = false variables.showMoveModalRef = false @@ -110,6 +125,9 @@ const BatchTaskDefinition = defineComponent({ ...toRefs(variables), ...toRefs(task), onSearch, + onClearSearchTaskName, + onClearSearchWorkflowName, + onClearSearchTaskType, requestData, onUpdatePageSize, onRefresh, @@ -145,6 +163,7 @@ const BatchTaskDefinition = defineComponent({ clearable v-model={[this.searchTaskName, 'value']} placeholder={t('project.task.task_name')} + onClear={this.onClearSearchTaskName} /> diff --git a/dolphinscheduler-ui/src/views/projects/task/instance/batch-task.tsx b/dolphinscheduler-ui/src/views/projects/task/instance/batch-task.tsx index 548e9c500d..02f1aeb49a 100644 --- a/dolphinscheduler-ui/src/views/projects/task/instance/batch-task.tsx +++ b/dolphinscheduler-ui/src/views/projects/task/instance/batch-task.tsx @@ -70,6 +70,36 @@ const BatchTaskInstance = defineComponent({ requestTableData() } + const onClearSearchTaskName = () => { + variables.searchVal = '' + onSearch() + } + + const onClearSearchProcessInstanceName = () => { + variables.processInstanceName = null + onSearch() + } + + const onClearSearchExecutorName = () => { + variables.executorName = null + onSearch() + } + + const onClearSearchHost = () => { + variables.host = null + onSearch() + } + + const onClearSearchStateType = () => { + variables.stateType = null + onSearch() + } + + const onClearSearchTime = () => { + variables.datePickerRange = null + onSearch() + } + const onConfirmModal = () => { variables.showModalRef = false } @@ -135,6 +165,12 @@ const BatchTaskInstance = defineComponent({ requestTableData, onUpdatePageSize, onSearch, + onClearSearchTaskName, + onClearSearchProcessInstanceName, + onClearSearchExecutorName, + onClearSearchHost, + onClearSearchStateType, + onClearSearchTime, onConfirmModal, refreshLogs, trim @@ -161,6 +197,7 @@ const BatchTaskInstance = defineComponent({ size='small' placeholder={t('project.task.task_name')} clearable + onClear={this.onClearSearchTaskName} /> diff --git a/dolphinscheduler-ui/src/views/projects/task/instance/stream-task.tsx b/dolphinscheduler-ui/src/views/projects/task/instance/stream-task.tsx index 5a6493af09..3cd063dc60 100644 --- a/dolphinscheduler-ui/src/views/projects/task/instance/stream-task.tsx +++ b/dolphinscheduler-ui/src/views/projects/task/instance/stream-task.tsx @@ -58,6 +58,36 @@ const BatchTaskInstance = defineComponent({ getTableData() } + const onClearSearchTaskName = () => { + variables.searchVal = null + onSearch() + } + + const onClearSearchWorkFlowName = () => { + variables.processDefinitionName = null + onSearch() + } + + const onClearSearchExecutorName = () => { + variables.executorName = null + onSearch() + } + + const onClearSearchHost = () => { + variables.host = null + onSearch() + } + + const onClearSearchStateType = () => { + variables.stateType = null + onSearch() + } + + const onClearSearchTime = () => { + variables.datePickerRange = null + onSearch() + } + const onConfirmModal = () => { variables.showModalRef = false } @@ -130,6 +160,12 @@ const BatchTaskInstance = defineComponent({ getTableData, onUpdatePageSize, onSearch, + onClearSearchTaskName, + onClearSearchWorkFlowName, + onClearSearchExecutorName, + onClearSearchHost, + onClearSearchStateType, + onClearSearchTime, onConfirmModal, refreshLogs, trim @@ -156,6 +192,7 @@ const BatchTaskInstance = defineComponent({ size='small' placeholder={t('project.task.task_name')} clearable + onClear={this.onClearSearchTaskName} /> diff --git a/dolphinscheduler-ui/src/views/projects/workflow/definition/index.tsx b/dolphinscheduler-ui/src/views/projects/workflow/definition/index.tsx index 688c1610aa..77663545f7 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/definition/index.tsx +++ b/dolphinscheduler-ui/src/views/projects/workflow/definition/index.tsx @@ -82,6 +82,15 @@ export default defineComponent({ requestData() } + const onClearSearch = () => { + variables.page = 1 + getTableData({ + pageSize: variables.pageSize, + pageNo: variables.page, + searchVal: '' + }) + } + const handleChangePageSize = () => { variables.page = 1 requestData() @@ -106,6 +115,7 @@ export default defineComponent({ return { requestData, handleSearch, + onClearSearch, handleUpdateList, createDefinition, handleChangePageSize, @@ -149,6 +159,8 @@ export default defineComponent({ size='small' placeholder={t('resource.function.enter_keyword_tips')} v-model={[this.searchVal, 'value']} + clearable + onClear={this.onClearSearch} /> diff --git a/dolphinscheduler-ui/src/views/projects/workflow/instance/components/process-instance-condition.tsx b/dolphinscheduler-ui/src/views/projects/workflow/instance/components/process-instance-condition.tsx index 29289712d7..7064fdb368 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/instance/components/process-instance-condition.tsx +++ b/dolphinscheduler-ui/src/views/projects/workflow/instance/components/process-instance-condition.tsx @@ -56,6 +56,21 @@ export default defineComponent({ }) } + const onClearSearchVal = () => { + searchValRef.value = '' + handleSearch() + } + + const onClearSearchHost = () => { + hostRef.value = '' + handleSearch() + } + + const onClearSearchExecutor = () => { + executorNameRef.value = '' + handleSearch() + } + const trim = getCurrentInstance()?.appContext.config.globalProperties.trim return { @@ -65,6 +80,9 @@ export default defineComponent({ stateTypeRef, startEndTimeRef, handleSearch, + onClearSearchVal, + onClearSearchExecutor, + onClearSearchHost, trim } }, @@ -79,18 +97,24 @@ export default defineComponent({ size='small' v-model:value={this.searchValRef} placeholder={t('project.workflow.name')} + clearable + onClear={this.onClearSearchVal} />