防抖优化

master
doublekou 9 months ago
parent 65a3106a2e
commit 36a1729c48

@ -98,6 +98,8 @@ import { doRequest } from '@/utils/axios/request'
// //
import useClipboard from 'vue-clipboard3' import useClipboard from 'vue-clipboard3'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
//
import { useDebounceFn } from '@vueuse/core'
const emits = defineEmits<{ const emits = defineEmits<{
(e: 'submit-success'): void (e: 'submit-success'): void
@ -135,7 +137,7 @@ const { submitLoading, validateAndSubmit, resetFields, validateInfos } = useAdmi
) )
// //
const handleSubmit = () => { const handleSubmit = useDebounceFn(() => {
validateAndSubmit(toRaw(formModel), { validateAndSubmit(toRaw(formModel), {
onSuccess: (res: any) => { onSuccess: (res: any) => {
// closeModal() // closeModal()
@ -147,7 +149,7 @@ const handleSubmit = () => {
submitLoading.value = false submitLoading.value = false
} }
}) })
} }, 300)
// //
const handleClose = () => { const handleClose = () => {

@ -67,6 +67,8 @@ import { doRequest } from '@/utils/axios/request'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { channelIdList, addChannelId, application } from '@/api/clueaccess/clueImport' import { channelIdList, addChannelId, application } from '@/api/clueaccess/clueImport'
import type { applicationData } from '@/api/clueaccess/clueImport/types' import type { applicationData } from '@/api/clueaccess/clueImport/types'
//
import { useDebounceFn } from '@vueuse/core'
interface MonitoringList { interface MonitoringList {
id?: number | undefined id?: number | undefined
@ -178,7 +180,7 @@ const handleCheckboxChange = (val: any) => {
} }
// () // ()
const onSubmit = () => { const onSubmit = useDebounceFn(() => {
formRef.value formRef.value
.validate() .validate()
.then(() => { .then(() => {
@ -196,7 +198,7 @@ const onSubmit = () => {
.catch((error: any) => { .catch((error: any) => {
return false return false
}) })
} }, 300)
const formRef = ref() const formRef = ref()
const inputRef = ref() const inputRef = ref()
</script> </script>

@ -204,6 +204,8 @@ import type { UnwrapRef } from 'vue'
import type { DefaultOptionType, SelectValue } from 'ant-design-vue/es/select' import type { DefaultOptionType, SelectValue } from 'ant-design-vue/es/select'
import type { SelectProps } from 'ant-design-vue' import type { SelectProps } from 'ant-design-vue'
import { doRequest } from '@/utils/axios/request' import { doRequest } from '@/utils/axios/request'
//
import { useDebounceFn } from '@vueuse/core'
const labelCol: ColProps = { sm: { span: 24 }, md: { span: 12 } } const labelCol: ColProps = { sm: { span: 24 }, md: { span: 12 } }
const wrapperCol: ColProps = { sm: { span: 24 }, md: { span: 10 } } const wrapperCol: ColProps = { sm: { span: 24 }, md: { span: 10 } }
@ -416,7 +418,7 @@ const { submitLoading, validateAndSubmit, resetFields, validateInfos } = useAdmi
) )
// //
const handleSubmit = () => { const handleSubmit = useDebounceFn(() => {
console.log('111') console.log('111')
const isEmpty = formState.selectedCompanys.every((item: optionItem) => { const isEmpty = formState.selectedCompanys.every((item: optionItem) => {
return item.content return item.content
@ -444,7 +446,7 @@ const handleSubmit = () => {
} }
}) })
} }
} }, 300)
// //
const handleClose = () => { const handleClose = () => {
selectedip.length = 0 selectedip.length = 0

@ -142,6 +142,8 @@ import DistributionTaskManagementSearch from '@/views/controlcenterstation/distr
import { FormAction } from '@/hooks/form' import { FormAction } from '@/hooks/form'
//() //()
import { updateDistributeConfigurationmenuDto } from '@/api/controlcenterstation/customerManagement' import { updateDistributeConfigurationmenuDto } from '@/api/controlcenterstation/customerManagement'
//
import { useDebounceFn } from '@vueuse/core'
defineOptions({ name: 'DistributionTaskManagement' }) defineOptions({ name: 'DistributionTaskManagement' })
@ -253,7 +255,7 @@ const columns: ProColumns[] = [
} }
] ]
// //
const open = (record: DistributeTaskManagementRecord) => { const open = useDebounceFn((record: DistributeTaskManagementRecord) => {
if (record.executeStatus === 0 || record.executeStatus === 3) { if (record.executeStatus === 0 || record.executeStatus === 3) {
doRequest(performTask(toRaw({ id: record.distributeTaskId })), { doRequest(performTask(toRaw({ id: record.distributeTaskId })), {
onSuccess: (res: any) => { onSuccess: (res: any) => {
@ -264,7 +266,7 @@ const open = (record: DistributeTaskManagementRecord) => {
} }
}) })
} }
} }, 300)
/// ///
const manualtaskOpen = (record: DistributeTaskManagementRecord) => { const manualtaskOpen = (record: DistributeTaskManagementRecord) => {

@ -271,6 +271,8 @@ import {
} from '@/api/controlcenterstation/customerManagement' } from '@/api/controlcenterstation/customerManagement'
// //
import 'dayjs/locale/zh-cn' import 'dayjs/locale/zh-cn'
//
import { useDebounceFn } from '@vueuse/core'
// import dayjs, { Dayjs } from 'dayjs' // import dayjs, { Dayjs } from 'dayjs'
// //
@ -555,7 +557,7 @@ const { submitLoading, validateAndSubmit, resetFields, validateInfos } = useAdmi
) )
// //
const handleSubmit = () => { const handleSubmit = useDebounceFn(() => {
formModel.users = [] formModel.users = []
formState.selectedCompanys.forEach((item: any) => { formState.selectedCompanys.forEach((item: any) => {
formModel.users?.push({ formModel.users?.push({
@ -593,7 +595,7 @@ const handleSubmit = () => {
} }
}) })
} }
} }, 300)
// //
const handleClose = () => { const handleClose = () => {

@ -100,6 +100,8 @@ import CustomerListEditModal from '@/views/customermanagement/customerList/custo
import { exportClueData, isEffective } from '@/api/customermanagement/customerList' import { exportClueData, isEffective } from '@/api/customermanagement/customerList'
import { remoteFileDownload } from '@/utils/file-utils' import { remoteFileDownload } from '@/utils/file-utils'
import { doRequest } from '@/utils/axios/request' import { doRequest } from '@/utils/axios/request'
//
import { useDebounceFn } from '@vueuse/core'
// import { useRoute } from 'vue-router' // import { useRoute } from 'vue-router'
// //
// import { doRequest } from '@/utils/axios/request' // import { doRequest } from '@/utils/axios/request'
@ -329,11 +331,13 @@ const switchChange = (record: any) => {
} }
} }
// //
function downloadTemplate() {
// function downloadTemplate() {
const downloadTemplate = useDebounceFn(() => {
exportClueData(searchParams).then(res => { exportClueData(searchParams).then(res => {
remoteFileDownload(res) remoteFileDownload(res)
}) })
} }, 300)
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.customerList-title { .customerList-title {

@ -72,6 +72,8 @@ import { updateResource } from '@/api/customermanagement/customerList'
//pageAccessLogs //pageAccessLogs
import { getResourcesDetail } from '@/api/salesmanagement/labelRule' import { getResourcesDetail } from '@/api/salesmanagement/labelRule'
import { containsProp } from '@vueuse/shared' import { containsProp } from '@vueuse/shared'
//
import { useDebounceFn } from '@vueuse/core'
//id //id
const resourcesId = ref<number>() const resourcesId = ref<number>()
@ -198,14 +200,14 @@ const { submitLoading, validateAndSubmit, resetFields } = useAdminForm(
) )
// //
const handleSubmit = () => { const handleSubmit = useDebounceFn(() => {
validateAndSubmit(toRaw(formModel), { validateAndSubmit(toRaw(formModel), {
onSuccess: () => { onSuccess: () => {
closeModal() closeModal()
emits('submit-success') emits('submit-success')
} }
}) })
} }, 300)
// //
const handleClose = () => { const handleClose = () => {

Loading…
Cancel
Save