From 29b5fdc39b337bc0167dcdb8010ffeff39c89c75 Mon Sep 17 00:00:00 2001 From: xiaozhiyong Date: Mon, 10 Jul 2023 10:22:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/autocomplete/index.vue | 28 +++++++------------------- src/utils/index.js | 29 +++++++++++++++------------ 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/src/components/autocomplete/index.vue b/src/components/autocomplete/index.vue index 9293467..ba3e6d6 100644 --- a/src/components/autocomplete/index.vue +++ b/src/components/autocomplete/index.vue @@ -11,15 +11,6 @@ @clear="list = []" @change="change" > - @@ -33,17 +24,17 @@ export default { config: Object // config: { // serveTarget: {}, // 远程搜索接口 - // autocompleteKey: "", //远程搜索接口参数名 - // labelKey: [] || '', //接口返回数据label - // valueKey: "", //接口返回数据id - // querykey: "", //查询接口参数名 - // echoId:'', // + // autocompleteKey: "" || {}, // 远程搜索接口参数名 + // labelKey: "" || [], // 接口返回数据label + // valueKey: "", // 接口返回数据id + // querykey: "", // 查询接口参数名 + // echoId: "", // 用于回显的id + // echoName: "", // 用于回显的name // }, }, data() { return { text: '', - // labelIsMore: false, list: [], isDisabled: false } @@ -51,7 +42,6 @@ export default { watch: { 'config.echoId': { handler(nval, oval) { - console.log('nvalnvalnvalnvalnval', nval) this.list = [] let type = this.$utils.typeJudgment(this.config.echoName) if (nval && ['String'].includes(type)) { @@ -77,11 +67,8 @@ export default { created() { let { labelKey } = this.config let type = this.$utils.typeJudgment(labelKey) - // if (type === 'Array') { - // this.labelIsMore = true - // } + // 重构labelHandler this.labelHandler = this.labelHandler(type) - // console.log(this.labelHandler()) }, methods: { labelHandler(type) { @@ -99,7 +86,6 @@ export default { }, // 远程搜索 remoteMethod(query) { - console.log('query', query) if (query !== '') { this.loading = true let type = this.$utils.typeJudgment(this.config.autocompleteKey) diff --git a/src/utils/index.js b/src/utils/index.js index 1f9850f..69503b4 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -17,32 +17,35 @@ export function parseTime(time) { } const formatRes = { y: date.getFullYear(), - M: date.getMonth() + 1, - d: date.getDate(), - h: date.getHours(), - m: date.getMinutes(), - s: date.getSeconds(), + M: (date.getMonth() + 1 + '').padStart(2, 0), + d: (date.getDate() + '').padStart(2, 0), + h: (date.getHours() + '').padStart(2, 0), + m: (date.getMinutes() + '').padStart(2, 0), + s: (date.getSeconds() + '').padStart(2, 0), week: ['日', '一', '二', '三', '四', '五', '六'][date.getDay()] } - formatRes.M < 10 && (formatRes.M = '0' + formatRes.M) - formatRes.d < 10 && (formatRes.d = '0' + formatRes.d) - formatRes.h < 10 && (formatRes.h = '0' + formatRes.h) - formatRes.m < 10 && (formatRes.m = '0' + formatRes.m) - formatRes.s < 10 && (formatRes.s = '0' + formatRes.s) + // formatRes.M < 10 && (formatRes.M = '0' + formatRes.M) + // formatRes.d < 10 && (formatRes.d = '0' + formatRes.d) + // formatRes.h < 10 && (formatRes.h = '0' + formatRes.h) + // formatRes.m < 10 && (formatRes.m = '0' + formatRes.m) + // formatRes.s < 10 && (formatRes.s = '0' + formatRes.s) return formatRes } // 防抖 export function debounce(fn, delay) { let timer = null - return function () { + function _implementer(...args) { if (timer) clearTimeout(timer) let _this = this - let _arguments = arguments timer = setTimeout(function () { - fn.apply(_this, _arguments) + fn.call(_this, ...args) }, delay) } + _implementer.cancel = () => { + clearTimeout(timer) + } + return _implementer } // 车牌校验 export function isLicensePlate(number) {