| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <!-- 班次 -->
- <el-select
- v-model="selectVal"
- filterable
- style="width: 100%"
- v-bind="$attrs"
- v-on="$listeners"
- clearable
- >
- <el-option
- v-for="item in dictList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </template>
- <script>
- import { getteamtime } from '@/api/workforceManagement/classes';
- export default {
- model: {
- prop: 'value',
- event: 'updateVal'
- },
- props: {
- value: {
- type: [String, Number, Array],
- default: ''
- },
- init: {
- type: Boolean,
- default: true
- }
- },
- data () {
- return {
- selectName: 'classes'
- };
- },
- computed: {
- dictList () {
- return this.$store.state.selectCache[this.selectName] || [];
- },
- selectVal: {
- set (val) {
- this.$emit(
- 'selfChange',
- val,
- this.dictList.find((i) => i.id === val)
- );
- this.$emit('updateVal', val);
- },
- get () {
- return this.value;
- }
- }
- },
- created () {
- if (this.init) {
- this.getList();
- }
- },
- methods: {
- async getList () {
- if (this.dictList.length) return;
- const res = await getteamtime({
- pageNum: 1,
- size: -1
- });
- this.$store.commit('selectCache/ADD_SELECT', {
- name: this.selectName,
- dict: res.list
- });
- }
- }
- };
- </script>
|