pull/24/head^2
xiaozhiyong 1 year ago
parent e49eab5fa1
commit 29b5fdc39b
  1. 28
      src/components/autocomplete/index.vue
  2. 29
      src/utils/index.js

@ -11,15 +11,6 @@
@clear="list = []"
@change="change"
>
<!-- <template v-if="labelIsMore">
<el-option
v-for="(item, index) in list"
:key="item.id + index"
:label="item[config.labelKey[0]] + '(' + item[config.labelKey[1]] + '-' + item[config.labelKey[2]] + ')'"
:value="item[config.valueKey]"
>
</el-option>
</template> -->
<template>
<el-option v-for="(item, index) in list" :key="index" :label="labelHandler(item)" :value="item[config.valueKey]"> </el-option>
</template>
@ -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)

@ -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) {

Loading…
Cancel
Save