This commit is contained in:
xiaozhiyong
2023-07-10 10:22:28 +08:00
parent e49eab5fa1
commit 29b5fdc39b
2 changed files with 23 additions and 34 deletions

View File

@@ -11,15 +11,6 @@
@clear="list = []" @clear="list = []"
@change="change" @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> <template>
<el-option v-for="(item, index) in list" :key="index" :label="labelHandler(item)" :value="item[config.valueKey]"> </el-option> <el-option v-for="(item, index) in list" :key="index" :label="labelHandler(item)" :value="item[config.valueKey]"> </el-option>
</template> </template>
@@ -33,17 +24,17 @@ export default {
config: Object config: Object
// config: { // config: {
// serveTarget: {}, // 远程搜索接口 // serveTarget: {}, // 远程搜索接口
// autocompleteKey: "", //远程搜索接口参数名 // autocompleteKey: "" || {}, // 远程搜索接口参数名
// labelKey: [] || '', //接口返回数据label // labelKey: "" || [], // 接口返回数据label
// valueKey: "", //接口返回数据id // valueKey: "", // 接口返回数据id
// querykey: "", //查询接口参数名 // querykey: "", // 查询接口参数名
// echoId:'', // // echoId: "", // 用于回显的id
// echoName: "", // 用于回显的name
// }, // },
}, },
data() { data() {
return { return {
text: '', text: '',
// labelIsMore: false,
list: [], list: [],
isDisabled: false isDisabled: false
} }
@@ -51,7 +42,6 @@ export default {
watch: { watch: {
'config.echoId': { 'config.echoId': {
handler(nval, oval) { handler(nval, oval) {
console.log('nvalnvalnvalnvalnval', nval)
this.list = [] this.list = []
let type = this.$utils.typeJudgment(this.config.echoName) let type = this.$utils.typeJudgment(this.config.echoName)
if (nval && ['String'].includes(type)) { if (nval && ['String'].includes(type)) {
@@ -77,11 +67,8 @@ export default {
created() { created() {
let { labelKey } = this.config let { labelKey } = this.config
let type = this.$utils.typeJudgment(labelKey) let type = this.$utils.typeJudgment(labelKey)
// if (type === 'Array') { // 重构labelHandler
// this.labelIsMore = true
// }
this.labelHandler = this.labelHandler(type) this.labelHandler = this.labelHandler(type)
// console.log(this.labelHandler())
}, },
methods: { methods: {
labelHandler(type) { labelHandler(type) {
@@ -99,7 +86,6 @@ export default {
}, },
// 远程搜索 // 远程搜索
remoteMethod(query) { remoteMethod(query) {
console.log('query', query)
if (query !== '') { if (query !== '') {
this.loading = true this.loading = true
let type = this.$utils.typeJudgment(this.config.autocompleteKey) let type = this.$utils.typeJudgment(this.config.autocompleteKey)

View File

@@ -17,32 +17,35 @@ export function parseTime(time) {
} }
const formatRes = { const formatRes = {
y: date.getFullYear(), y: date.getFullYear(),
M: date.getMonth() + 1, M: (date.getMonth() + 1 + '').padStart(2, 0),
d: date.getDate(), d: (date.getDate() + '').padStart(2, 0),
h: date.getHours(), h: (date.getHours() + '').padStart(2, 0),
m: date.getMinutes(), m: (date.getMinutes() + '').padStart(2, 0),
s: date.getSeconds(), s: (date.getSeconds() + '').padStart(2, 0),
week: ['日', '一', '二', '三', '四', '五', '六'][date.getDay()] week: ['日', '一', '二', '三', '四', '五', '六'][date.getDay()]
} }
formatRes.M < 10 && (formatRes.M = '0' + formatRes.M) // formatRes.M < 10 && (formatRes.M = '0' + formatRes.M)
formatRes.d < 10 && (formatRes.d = '0' + formatRes.d) // formatRes.d < 10 && (formatRes.d = '0' + formatRes.d)
formatRes.h < 10 && (formatRes.h = '0' + formatRes.h) // formatRes.h < 10 && (formatRes.h = '0' + formatRes.h)
formatRes.m < 10 && (formatRes.m = '0' + formatRes.m) // formatRes.m < 10 && (formatRes.m = '0' + formatRes.m)
formatRes.s < 10 && (formatRes.s = '0' + formatRes.s) // formatRes.s < 10 && (formatRes.s = '0' + formatRes.s)
return formatRes return formatRes
} }
// 防抖 // 防抖
export function debounce(fn, delay) { export function debounce(fn, delay) {
let timer = null let timer = null
return function () { function _implementer(...args) {
if (timer) clearTimeout(timer) if (timer) clearTimeout(timer)
let _this = this let _this = this
let _arguments = arguments
timer = setTimeout(function () { timer = setTimeout(function () {
fn.apply(_this, _arguments) fn.call(_this, ...args)
}, delay) }, delay)
} }
_implementer.cancel = () => {
clearTimeout(timer)
}
return _implementer
} }
// 车牌校验 // 车牌校验
export function isLicensePlate(number) { export function isLicensePlate(number) {