Commit fdb6386a by fukai

还原公共组件

parent 50f5f0a6
<template> <template>
<el-select <el-select
:id="id" :id="id" v-model="model" v-bind="attrs"
v-model="model" v-on="$listeners" v-bind:disabled="isDisable" :clearable="clearable" @click.native="handleClick" >
v-bind="attrs" <slot></slot>
v-on="$listeners"
v-bind:disabled="isDisable"
:clearable="clearable"
@click.native="handleClick"
>
<el-option
v-for="item in code"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select> </el-select>
</template> </template>
...@@ -23,66 +11,61 @@ export default { ...@@ -23,66 +11,61 @@ export default {
props: { props: {
value: { value: {
type: [String, Array, Number], type: [String, Array, Number],
default: undefined, default: undefined
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
clearable: { clearable: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
id: { id: {
type: String, type: String,
default: undefined, default: undefined
}, }
code: {
type: Array,
default: function () {
return [];
},
},
}, },
computed: { computed: {
model: { model: {
get() { get() {
return this.value; return this.value
}, },
set(newVal) { set(newVal) {
this.$emit("input", newVal); this.$emit('input', newVal)
}, }
}, },
mode() { mode() {
return this.$store.state.Status.mode; return this.$store.state.Status.mode
}, },
isDisable: { isDisable: {
get() { get() {
return this.mode === "display" || this.disabled; return this.mode === 'display' || this.disabled
}, }
}, },
highlight() { highlight () {
return this.$store.state.Status.highlights.indexOf(this.id) !== -1; return this.$store.state.Status.highlights.indexOf(this.id) !== -1
}, },
attrs() { attrs(){
if (this.mode === "display" || this.disabled) { if(this.mode === 'display' || this.disabled)
let { placeholder, ...rest } = this.$attrs; {
rest = { placeholder: " ", ...rest }; let {placeholder,...rest} = this.$attrs
return rest; rest = {placeholder:" ",...rest}
return rest
}
return this.$attrs
} }
return this.$attrs;
},
}, },
methods: { methods: {
handleClick: function (e) { handleClick: function (e) {
let ev = new Event("click", { bubbles: true }); let ev = new Event("click", {"bubbles": true})
let node = e.target; let node = e.target
if (node.parentElement) { if (node.parentElement) {
node.parentElement.dispatchEvent(ev); node.parentElement.dispatchEvent(ev)
} }
}, }
}, }
}; }
</script> </script>
<style> <style>
......
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