| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <template>
- <el-select
- v-model="selectVal"
- :disabled="isProhibit"
- style="width: 100%"
- v-bind="$attrs"
- v-on="$listeners"
- filterable
- >
- <el-option
- v-for="item in dictList"
- :key="item[valueName]"
- :value="item[valueName]"
- :label="
- ChinEng ? item[labelName] + '-' + item[valueName] : item[labelName]
- "
- ></el-option>
- </el-select>
- </template>
- <script>
- import dictEnum from '@/enum/dict';
- import { mapActions, mapGetters } from 'vuex';
- export default {
- model: {
- prop: 'value',
- event: 'updateVal'
- },
- props: {
- value: {
- type: [String, Number],
- default: ''
- },
- isProhibit: {
- type: Boolean,
- default: false
- },
- dictName: {
- type: String,
- required: true
- },
- labelName: {
- type: String,
- default: 'dictValue'
- },
- valueName: {
- type: String,
- default: 'dictCode'
- },
- ChinEng: {
- Boolean,
- default: false
- }
- },
- data() {
- return {};
- },
- computed: {
- ...mapGetters(['dict', 'getDict']),
- dictList() {
- return this.dict[dictEnum[this.dictName]] || [];
- },
- selectVal: {
- set(val) {
- this.$emit('updateVal', val);
- // change获取选中项所有数据
- this.$emit('itemChange', this.getDict(this.dictName, val));
- },
- get() {
- return this.value;
- }
- }
- },
- created() {
- if (this.dictName) {
- this.requestDict(this.dictName);
- }
- },
- methods: {
- ...mapActions('dict', ['requestDict'])
- }
- };
- </script>
|