Commit 5949aa2c by linjinhong

添加防抖函数已经修改bug

parent 6721290f
...@@ -125,6 +125,11 @@ export default defineComponent({ ...@@ -125,6 +125,11 @@ export default defineComponent({
if (!formRef.value) return false if (!formRef.value) return false
return await formRef.value.validate() return await formRef.value.validate()
} }
// 表单验证方法
const clearValidate = async () => {
if (!formRef.value) return false
return await formRef.value.clearValidate()
}
// 重置表单 // 重置表单
const resetFields = async () => { const resetFields = async () => {
...@@ -158,6 +163,7 @@ export default defineComponent({ ...@@ -158,6 +163,7 @@ export default defineComponent({
getComponentAttrs, getComponentAttrs,
refashConfig, refashConfig,
tableConfig, tableConfig,
clearValidate,
} }
}, },
render() { render() {
......
...@@ -83,7 +83,7 @@ import { IFormConfig } from '@/components/CustomizeForm.tsx' ...@@ -83,7 +83,7 @@ import { IFormConfig } from '@/components/CustomizeForm.tsx'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
import { useValue } from './hooks/useValue' import { useValue } from './hooks/useValue'
import { showConfirm } from '@/utils/ui' import { showConfirm } from '@/utils/ui'
import { debounce } from 'lodash-es'
import { import {
DeclarationRuleList, DeclarationRuleList,
AddDeclarationRuleObj, AddDeclarationRuleObj,
...@@ -177,14 +177,15 @@ const formConfig = ref<IFormConfig[]>([ ...@@ -177,14 +177,15 @@ const formConfig = ref<IFormConfig[]>([
if (value === 2) { if (value === 2) {
editForm.value.fixedValue = '' editForm.value.fixedValue = ''
editForm.value.fixedWeight = '' editForm.value.fixedWeight = ''
editFormRef.value?.clearValidate()
} else { } else {
editForm.value.orderPercent = '' editForm.value.orderPercent = ''
editForm.value.valueUp = '' editForm.value.valueUp = ''
editForm.value.weightPercent = '' editForm.value.weightPercent = ''
editForm.value.weightUp = '' editForm.value.weightUp = ''
editFormRef.value?.clearValidate()
} }
editFormRef.value?.refashConfig(mapData.value.get(value) as string[]) editFormRef.value?.refashConfig(mapData.value.get(value) as string[])
editFormRef.value?.validate()
}, },
}, },
rules: [ rules: [
...@@ -442,7 +443,7 @@ async function checkData() { ...@@ -442,7 +443,7 @@ async function checkData() {
return { isValid, postData } return { isValid, postData }
} }
async function save() { const save = debounce(async () => {
const { isValid, postData } = await checkData() const { isValid, postData } = await checkData()
if (isValid) { if (isValid) {
try { try {
...@@ -467,7 +468,8 @@ async function save() { ...@@ -467,7 +468,8 @@ async function save() {
return return
} }
} }
} }, 400)
function addDialog() { function addDialog() {
dialogVisible.value = true dialogVisible.value = true
nextTick(() => { nextTick(() => {
......
...@@ -87,6 +87,7 @@ import usePageList from '@/utils/hooks/usePageList' ...@@ -87,6 +87,7 @@ import usePageList from '@/utils/hooks/usePageList'
import { useValue } from './hooks/useValue' import { useValue } from './hooks/useValue'
import { showConfirm } from '@/utils/ui' import { showConfirm } from '@/utils/ui'
import { Edit, Delete, List } from '@element-plus/icons-vue' import { Edit, Delete, List } from '@element-plus/icons-vue'
import { debounce } from 'lodash-es'
const [searchForm] = useValue({}) const [searchForm] = useValue({})
const [editForm, resetEditForm] = useValue<LogisticsMethod>({ const [editForm, resetEditForm] = useValue<LogisticsMethod>({
...@@ -538,7 +539,7 @@ async function checkData() { ...@@ -538,7 +539,7 @@ async function checkData() {
return { isValid, postData } return { isValid, postData }
} }
async function save() { const save = debounce(async () => {
const { isValid, postData } = await checkData() const { isValid, postData } = await checkData()
if (isValid) { if (isValid) {
try { try {
...@@ -563,7 +564,7 @@ async function save() { ...@@ -563,7 +564,7 @@ async function save() {
return return
} }
} }
} }, 400)
function addDialog() { function addDialog() {
dialogVisible.value = true dialogVisible.value = true
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
v-model="tableData" v-model="tableData"
:config="tableConfig" :config="tableConfig"
:merge-cells="mergeCells" :merge-cells="mergeCells"
@edit-closed="editClosed"
:tableEditConfig="{ :tableEditConfig="{
enabled: true, enabled: true,
}" }"
...@@ -92,6 +93,7 @@ import { useValue } from './hooks/useValue' ...@@ -92,6 +93,7 @@ import { useValue } from './hooks/useValue'
import { showConfirm } from '@/utils/ui' import { showConfirm } from '@/utils/ui'
import { Edit } from '@element-plus/icons-vue' import { Edit } from '@element-plus/icons-vue'
import { ElInput } from 'element-plus' import { ElInput } from 'element-plus'
import { debounce } from 'lodash-es'
const [searchForm] = useValue({}) const [searchForm] = useValue({})
const [editForm, resetEditForm] = useValue({ logisticsList: [] }) const [editForm, resetEditForm] = useValue({ logisticsList: [] })
...@@ -277,7 +279,7 @@ async function checkData() { ...@@ -277,7 +279,7 @@ async function checkData() {
return { isValid, postData } return { isValid, postData }
} }
async function save() { const save = debounce(async () => {
const { isValid, postData } = await checkData() const { isValid, postData } = await checkData()
if (isValid) { if (isValid) {
try { try {
...@@ -285,10 +287,6 @@ async function save() { ...@@ -285,10 +287,6 @@ async function save() {
await addLogisticsZone({ await addLogisticsZone({
...postData, ...postData,
}) })
} else {
await updateLogisticsZone({
...postData,
})
} }
ElMessage({ ElMessage({
message: '保存成功', message: '保存成功',
...@@ -302,7 +300,7 @@ async function save() { ...@@ -302,7 +300,7 @@ async function save() {
return return
} }
} }
} }, 400)
function addDialog() { function addDialog() {
dialogVisible.value = true dialogVisible.value = true
} }
...@@ -351,6 +349,7 @@ async function deleteFn() { ...@@ -351,6 +349,7 @@ async function deleteFn() {
} }
} }
const loading = ref(false) const loading = ref(false)
const editParams = ref({})
async function getList(data?) { async function getList(data?) {
loading.value = true loading.value = true
try { try {
...@@ -381,7 +380,18 @@ async function getList(data?) { ...@@ -381,7 +380,18 @@ async function getList(data?) {
edit: ({ row }) => { edit: ({ row }) => {
return ( return (
<div> <div>
{/* <ElInput v-model={row[key]?.codePrefix} /> */} <ElInput
style={{ height: '24px' }}
modelValue={row[key]?.codePrefix}
onInput={(e) => {
row[key].codePrefix = e
editParams.value = {
zoneName: row.zoneName,
logistics: key,
codePrefix: e || '',
}
}}
/>
</div> </div>
) )
}, },
...@@ -400,8 +410,6 @@ async function getList(data?) { ...@@ -400,8 +410,6 @@ async function getList(data?) {
} }
} }
tableConfig.value = [...oldConfig, ...newConfig] tableConfig.value = [...oldConfig, ...newConfig]
console.log('tableConfig', tableConfig.value)
console.log(' tableData', tableData.value)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
...@@ -505,13 +513,21 @@ async function exportExcel(file) { ...@@ -505,13 +513,21 @@ async function exportExcel(file) {
} }
} }
watch( async function editClosed() {
() => loading.value, console.log(1111111, editParams.value)
(val) => { try {
console.log(442, val) if (Object.keys(editParams.value).length) {
}, await updateLogisticsZone(editParams.value)
{ deep: true, immediate: true }, ElMessage.success('修改成功!')
) getList(searchForm.value)
}
} catch {
ElMessage.error('修改失败!')
getList(searchForm.value)
} finally {
editParams.value = {}
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -116,6 +116,7 @@ import usePageList from '@/utils/hooks/usePageList' ...@@ -116,6 +116,7 @@ import usePageList from '@/utils/hooks/usePageList'
import { useValue } from './hooks/useValue' import { useValue } from './hooks/useValue'
import { showConfirm } from '@/utils/ui' import { showConfirm } from '@/utils/ui'
import { Edit } from '@element-plus/icons-vue' import { Edit } from '@element-plus/icons-vue'
import { debounce } from 'lodash-es'
const [searchForm] = useValue({}) const [searchForm] = useValue({})
const [editForm, resetEditForm] = useValue({ unit: 'oz' }) const [editForm, resetEditForm] = useValue({ unit: 'oz' })
...@@ -477,7 +478,7 @@ async function checkData() { ...@@ -477,7 +478,7 @@ async function checkData() {
return { isValid, postData } return { isValid, postData }
} }
async function save() { const save = debounce(async () => {
const { isValid, postData } = await checkData() const { isValid, postData } = await checkData()
if (isValid) { if (isValid) {
try { try {
...@@ -502,7 +503,7 @@ async function save() { ...@@ -502,7 +503,7 @@ async function save() {
return return
} }
} }
} }, 400)
function addDialog() { function addDialog() {
dialogVisible.value = true dialogVisible.value = true
console.log(502, editForm.value) console.log(502, editForm.value)
......
...@@ -185,6 +185,7 @@ import { LogisticsQuotation } from './types/logisticsQuotation.ts' ...@@ -185,6 +185,7 @@ import { LogisticsQuotation } from './types/logisticsQuotation.ts'
import LogDialog from './components/LogDialog.tsx' import LogDialog from './components/LogDialog.tsx'
import CustomizeForm from '@/components/CustomizeForm.tsx' import CustomizeForm from '@/components/CustomizeForm.tsx'
import { Edit, Delete, List } from '@element-plus/icons-vue' import { Edit, Delete, List } from '@element-plus/icons-vue'
import { debounce } from 'lodash-es'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
import { useValue } from './hooks/useValue' import { useValue } from './hooks/useValue'
...@@ -293,14 +294,7 @@ const formConfig = ref<IFormConfig[]>([ ...@@ -293,14 +294,7 @@ const formConfig = ref<IFormConfig[]>([
placeholder: '请选择区', placeholder: '请选择区',
}, },
}, },
{
prop: 'cspAccount',
type: 'input',
label: 'CSP账号',
attrs: {
placeholder: '请输入CSP账号',
},
},
{ {
prop: 'postalCode', prop: 'postalCode',
type: 'input', type: 'input',
...@@ -355,14 +349,7 @@ const formConfig = ref<IFormConfig[]>([ ...@@ -355,14 +349,7 @@ const formConfig = ref<IFormConfig[]>([
placeholder: '请输入电话', placeholder: '请输入电话',
}, },
}, },
{
prop: 'rfcTaxId',
type: 'input',
label: 'RFC税号',
attrs: {
placeholder: '请输入RFC税号',
},
},
{ {
prop: 'swDefault', prop: 'swDefault',
type: 'switch', type: 'switch',
...@@ -432,7 +419,7 @@ async function checkData() { ...@@ -432,7 +419,7 @@ async function checkData() {
return { isValid, postData } return { isValid, postData }
} }
async function save() { const save = debounce(async () => {
const { isValid, postData } = await checkData() const { isValid, postData } = await checkData()
if (isValid) { if (isValid) {
try { try {
...@@ -457,7 +444,7 @@ async function save() { ...@@ -457,7 +444,7 @@ async function save() {
return return
} }
} }
} }, 400)
function addDialog() { function addDialog() {
dialogVisible.value = true dialogVisible.value = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment