Commit 5949aa2c by linjinhong

添加防抖函数已经修改bug

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