Commit f8723115 by 张立顺

修复重复点击的问题

1 parent 7ebee955
...@@ -16,6 +16,26 @@ ...@@ -16,6 +16,26 @@
<script> <script>
export default { export default {
name: 'BaseDialog', name: 'BaseDialog',
directives: {
// 函数节流 监控输入框 提高性能
throttle: {
// 指令的定义
inserted: function (el, obj) {
let timerId = null
let flag = true
el.addEventListener('click', function () {
if (!flag) return
flag = false
timerId && clearTimeout(timerId)
timerId = setTimeout(function () {
flag = true
// 调用绑定在v-throttle上的方法search
obj.value()
}, 1000)
})
}
}
},
props: { props: {
dialogConfig: { dialogConfig: {
required: false, required: false,
......
...@@ -92,6 +92,7 @@ export default { ...@@ -92,6 +92,7 @@ export default {
data() { data() {
return { return {
// addressInfo: {}, // addressInfo: {},
throttleSubmit: false,
membraneTypeList, membraneTypeList,
drawer: false, drawer: false,
dialogShow: false, dialogShow: false,
...@@ -192,9 +193,13 @@ export default { ...@@ -192,9 +193,13 @@ export default {
} else { } else {
this.selectList = selectList this.selectList = selectList
this.dialogShow = true this.dialogShow = true
this.throttleSubmit = false
} }
}, },
handleSubmit() { handleSubmit() {
if (this.throttleSubmit) return
console.log(this.throttleSubmit)
console.log('submit')
const { contactAddress, contactName, contactPhone } = this.addressInfo const { contactAddress, contactName, contactPhone } = this.addressInfo
const params = { const params = {
orderDelivery: { orderDelivery: {
...@@ -204,11 +209,15 @@ export default { ...@@ -204,11 +209,15 @@ export default {
} }
// console.log(params) // console.log(params)
// return // return
this.throttleSubmit = true
purchaseOrderAdd(params).then((result) => { purchaseOrderAdd(params).then((result) => {
this.$message.success('提交成功')
this.getGoodsList()
this.drawer = false this.drawer = false
this.dialogShow = false this.dialogShow = false
this.$message.success('提交成功')
this.getGoodsList()
// this.$nextTick(() => {
// this.throttleSubmit = false
// }, 1000)
}) })
// purchaseOrderAdd // purchaseOrderAdd
// this.getGoodsList() // this.getGoodsList()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!