部分函数添加防抖机制

master
飘泊客 9 months ago
parent 5c979bfbe3
commit c75253733d

@ -18,9 +18,8 @@ const useAdminWebSocket = () => {
// ws地址 // ws地址
const baseUri = import.meta.env.VITE_API_URL const baseUri = import.meta.env.VITE_API_URL
const host = window.location.host const host = window.location.host
console.log(host, 'host') const wsUri = `wss://${host}${baseUri}/ws?access_token=${accessToken}`
const wsUri = `ws://${host}${baseUri}/ws?access_token=${accessToken}` console.log(wsUri, 'wsUri')
console.log(baseUri, 'baseUri')
//使用useWebSocket函数创建WebSocket连接并配置自动重连和心跳机制 //使用useWebSocket函数创建WebSocket连接并配置自动重连和心跳机制
useWebSocketReturn = useWebSocket(wsUri, { useWebSocketReturn = useWebSocket(wsUri, {

@ -78,9 +78,9 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import BallcatFooter from '@/layouts/components/Footer/BallcatFooter.vue' // import BallcatFooter from '@/layouts/components/Footer/BallcatFooter.vue'
import ProLayout from '#/layout/BasicLayout' import ProLayout from '#/layout/BasicLayout'
import SettingDrawer from '#/layout/components/SettingDrawer' // import SettingDrawer from '#/layout/components/SettingDrawer'
import MultiTab from '@/layouts/components/MultiTab' import MultiTab from '@/layouts/components/MultiTab'
import { useSettingStore } from '@/stores/setting-store' import { useSettingStore } from '@/stores/setting-store'
import type { Key } from 'ant-design-vue/es/_util/type' import type { Key } from 'ant-design-vue/es/_util/type'

@ -8,7 +8,7 @@
<!-- 批量操作更多操作 --> <!-- 批量操作更多操作 -->
<a-card :bordered="false" :body-style="{ paddingBottom: 0 }"> <a-card :bordered="false" :body-style="{ paddingBottom: 0 }">
<div class="download"> <div class="download">
<a-button @click.stop="downloadTemplate">导出</a-button> <a-button @click.stop="exportModel = true">导出</a-button>
</div> </div>
</a-card> </a-card>
<!-- 底部表格 --> <!-- 底部表格 -->
@ -71,6 +71,18 @@
</template> --> </template> -->
</template> </template>
</pro-table> </pro-table>
<a-modal v-model:visible="exportModel" title="导出" @cancel="cancelModel">
<!-- <a-input
v-model:value="searchData.nid"
placeholder="请输入号码"
allow-clear
style="width: 220px; margin-bottom: 10px"
/> -->
<a-range-picker v-model:value="searchData.exportDate" format="YYYY-MM-DD HH:mm:ss" show-time />
<template #footer>
<a-button key="submit" type="primary" @click="downloadTemplate"></a-button>
</template>
</a-modal>
<!-- 详情弹窗 --> <!-- 详情弹窗 -->
<customer-list-view-modal ref="customerListViewModalRef" @submit-success="reloadTable" /> <customer-list-view-modal ref="customerListViewModalRef" @submit-success="reloadTable" />
<!-- 编辑弹窗 --> <!-- 编辑弹窗 -->
@ -100,6 +112,7 @@ 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 type { Dayjs } from 'dayjs'
// import { useRoute } from 'vue-router' // import { useRoute } from 'vue-router'
// //
// import { doRequest } from '@/utils/axios/request' // import { doRequest } from '@/utils/axios/request'
@ -107,10 +120,16 @@ import { doRequest } from '@/utils/axios/request'
// const route = useRoute() // const route = useRoute()
defineOptions({ name: 'CustomerList' }) defineOptions({ name: 'CustomerList' })
type RangeValue = [Dayjs, Dayjs]
// //
import { useUserStore } from '@/stores/user-store' import { useUserStore } from '@/stores/user-store'
const { userInfo } = useUserStore() const { userInfo } = useUserStore()
const salesmanType = ref<number | undefined>() const salesmanType = ref<number | undefined>()
const exportModel = ref(false)
const searchData = reactive({
nid: '',
exportDate: []
})
onMounted(() => { onMounted(() => {
salesmanType.value = userInfo?.salesmanType salesmanType.value = userInfo?.salesmanType
const savedUserData = localStorage.getItem('clueId') const savedUserData = localStorage.getItem('clueId')
@ -175,7 +194,10 @@ const handleView = (record: CustomerListRecord, tabIndex: string) => {
customerListViewModalRef.value?.open(FormAction.UPDATE, record, tabIndex) customerListViewModalRef.value?.open(FormAction.UPDATE, record, tabIndex)
} }
} }
const cancelModel = () => {
searchData.nid = ''
searchData.exportDate = []
}
// //
const handleEdit = (record: CustomerListRecord, tabIndex: string) => { const handleEdit = (record: CustomerListRecord, tabIndex: string) => {
customerListEditModalRef.value?.open(FormAction.UPDATE, record, tabIndex) customerListEditModalRef.value?.open(FormAction.UPDATE, record, tabIndex)
@ -330,9 +352,20 @@ const switchChange = (record: any) => {
} }
// //
function downloadTemplate() { function downloadTemplate() {
exportClueData(searchParams).then(res => { const data: any = searchData
if (data.exportDate && data.exportDate.length == 2) {
data.startTime = data.exportDate[0].format('YYYY-MM-DD HH:mm:ss')
data.endTime = data.exportDate[1].format('YYYY-MM-DD HH:mm:ss')
delete data.exportDate
}
exportClueData(data)
.then(res => {
exportModel.value = false
remoteFileDownload(res) remoteFileDownload(res)
}) })
.catch(err => {
exportModel.value = false
})
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

@ -239,7 +239,9 @@
</div> </div>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
v-if="title === '新建预约' || title === '编辑预约' || title === '编辑' && activeKey === 0" v-if="
title === '新建预约' || title === '编辑预约' || (title === '编辑' && activeKey === 0)
"
style="display: flex; justify-content: center" style="display: flex; justify-content: center"
> >
<!-- 地图 --> <!-- 地图 -->
@ -468,7 +470,7 @@
<p>您提交的表单信息为</p> <p>您提交的表单信息为</p>
<p>称呼{{ formModel.customName }}</p> <p>称呼{{ formModel.customName }}</p>
<p>联系方式{{ formModel.customNid }}</p> <p>联系方式{{ formModel.customNid }}</p>
<p>备注{{ formModel.remark }}</p> <p>客户资料{{ formModel.customInformation }}</p>
<div v-if="formModel.customType === 0" style="overflow-y: auto; max-height: 100px"> <div v-if="formModel.customType === 0" style="overflow-y: auto; max-height: 100px">
<p v-for="(item, index) in formModel.customStoreEntities" :key="index"> <p v-for="(item, index) in formModel.customStoreEntities" :key="index">
<span>{{ `报名的门店${index + 1}` }}{{ item.storeName }}</span> <span>{{ `报名的门店${index + 1}` }}{{ item.storeName }}</span>
@ -503,6 +505,7 @@ import type { SelectProps } from 'ant-design-vue'
import type { Dayjs } from 'dayjs' import type { Dayjs } from 'dayjs'
import 'dayjs/locale/zh-cn' import 'dayjs/locale/zh-cn'
import { getfFindDirectSalesman } from '@/api/directResources/index' import { getfFindDirectSalesman } from '@/api/directResources/index'
import { useDebounceFn } from '@vueuse/core'
import { import {
addCustomer, addCustomer,
updateCustomer, updateCustomer,
@ -1394,9 +1397,13 @@ const submitOperate = () => {
} }
} }
// //
const handleOk = async () => { const handleOk = useDebounceFn(
async () => {
await submitOperate() await submitOperate()
} },
300,
{ maxWait: 5000 }
)
// //
const matchhandleOk = async (detailAddress: string) => { const matchhandleOk = async (detailAddress: string) => {
matchregisterVisible.value = false matchregisterVisible.value = false

@ -420,7 +420,7 @@
<p>您提交的表单信息为</p> <p>您提交的表单信息为</p>
<p>称呼{{ formModel.customName }}</p> <p>称呼{{ formModel.customName }}</p>
<p>联系方式{{ formModel.customNid }}</p> <p>联系方式{{ formModel.customNid }}</p>
<p>备注{{ formModel.remark }}</p> <p>客户资料{{ formModel.salesmanUserId }}</p>
<div v-if="formModel.customType === 0" style="overflow-y: auto; max-height: 100px"> <div v-if="formModel.customType === 0" style="overflow-y: auto; max-height: 100px">
<p v-for="(item, index) in formModel.customStoreEntities" :key="index"> <p v-for="(item, index) in formModel.customStoreEntities" :key="index">
<span>{{ `报名的门店${index + 1}` }}{{ item.storeName }}</span> <span>{{ `报名的门店${index + 1}` }}{{ item.storeName }}</span>
@ -449,6 +449,7 @@ import type { FormRequestMapping } from '@/hooks/form'
import { doRequest } from '@/utils/axios/request' import { doRequest } from '@/utils/axios/request'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue'
import { useDebounceFn } from '@vueuse/core'
// //
import type { SelectValue } from 'ant-design-vue/es/select' import type { SelectValue } from 'ant-design-vue/es/select'
import type { SelectProps } from 'ant-design-vue' import type { SelectProps } from 'ant-design-vue'
@ -1319,7 +1320,10 @@ const submitOperate = () => {
) )
const handleSuccess = (res: any) => { const handleSuccess = (res: any) => {
// //
console.log("🚀 ~ file: inspectionModal.vue:1323 ~ handleSuccess ~ formModel.enrollStatus:", formModel.enrollStatus) console.log(
'🚀 ~ file: inspectionModal.vue:1323 ~ handleSuccess ~ formModel.enrollStatus:',
formModel.enrollStatus
)
if (res.code === 200 && formModel.enrollStatus != 0) { if (res.code === 200 && formModel.enrollStatus != 0) {
message.success('保存成功') message.success('保存成功')
isSubmit.value = true isSubmit.value = true
@ -1354,9 +1358,13 @@ const submitOperate = () => {
} }
// //
const handleOk = async () => { const handleOk = useDebounceFn(
async () => {
await submitOperate() await submitOperate()
} },
300,
{ maxWait: 5000 }
)
// //
const matchhandleOk = async (detailAddress: string) => { const matchhandleOk = async (detailAddress: string) => {
matchregisterVisible.value = false matchregisterVisible.value = false
@ -1381,7 +1389,8 @@ const matchhandleOk = async (detailAddress: string) => {
// await submitOperate() // await submitOperate()
} }
// //
const temporaryStorage = async () => { const temporaryStorage = useDebounceFn(
async () => {
const fields = ['customName', 'customNid'] // const fields = ['customName', 'customNid'] //
formRef.value formRef.value
?.validateFields(fields) ?.validateFields(fields)
@ -1392,7 +1401,10 @@ const temporaryStorage = async () => {
.catch(err => { .catch(err => {
console.log('校验失败err', err) console.log('校验失败err', err)
}) })
} },
300,
{ maxWait: 5000 }
)
// //
const handleSubmit = () => { const handleSubmit = () => {

@ -146,6 +146,7 @@ import type { ShowSearchType } from 'ant-design-vue/es/cascader'
import { useAdminForm, useFormAction, FormAction, labelCol, wrapperCol } from '@/hooks/form' import { useAdminForm, useFormAction, FormAction, labelCol, wrapperCol } from '@/hooks/form'
import type { shopDetailVO } from '@/api/shopManage/types' import type { shopDetailVO } from '@/api/shopManage/types'
import type { FormInstance } from 'ant-design-vue/es/form/Form' import type { FormInstance } from 'ant-design-vue/es/form/Form'
import { useDebounceFn } from '@vueuse/core'
// //
import 'dayjs/locale/zh-cn' import 'dayjs/locale/zh-cn'
const emits = defineEmits<{ const emits = defineEmits<{
@ -273,7 +274,8 @@ const handleClose = () => {
} }
/* 表单提交处理 */ /* 表单提交处理 */
const handleSubmit = () => { const handleSubmit = useDebounceFn(
() => {
formRef.value?.validate().then(res => { formRef.value?.validate().then(res => {
if (!anchorData?.location && title.value == '添加门店') { if (!anchorData?.location && title.value == '添加门店') {
message.info('请先选择具体门店') message.info('请先选择具体门店')
@ -304,7 +306,10 @@ const handleSubmit = () => {
} }
) )
}) })
} },
300,
{ maxWait: 5000 }
)
defineExpose({ defineExpose({
async open(newFormAction: FormAction, record?: shopDetailVO) { async open(newFormAction: FormAction, record?: shopDetailVO) {
await selectUserList() await selectUserList()

@ -20,16 +20,16 @@ import { projectTitle } from './src/config'
import { antdvStyleDeps } from './src/utils/resolvers' import { antdvStyleDeps } from './src/utils/resolvers'
//xy //xy
export const serverAddress = 'http://172.18.0.225:8000' // export const serverAddress = 'http://172.18.0.225:8000'
//jt //jt
// export const serverAddress = 'http://172.18.1.8:8000' // export const serverAddress = 'http://172.18.1.8:8000'
//ts //ts
// export const serverAddress = 'http://172.18.0.228:8000' // export const serverAddress = 'http://172.18.0.228:8000'
//测试 //测试
export const serverAddress = 'http://39.100.77.21:8000' // export const serverAddress = 'http://39.100.77.21:8000'
//线上域名,现在用这个 //线上域名,现在用这个
// export const serverAddress = 'https://byffp.top' export const serverAddress = 'https://byffp.top'
export default defineConfig({ export default defineConfig({
server: { server: {

Loading…
Cancel
Save