| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <!-- 厂房 -->
- <el-select
- v-model="selectVal"
- filterable
- v-bind="$attrs"
- v-on="$listeners"
- clearable
- >
- <el-option
- v-for="item in dictList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- @click.native="returnName(item)"
- ></el-option>
- </el-select>
- </template>
- <script>
- import { getFactoryarea, factoryworkstation } from '@/api/factoryModel';
- export default {
- model: {
- prop: 'value',
- event: 'updateVal'
- },
- props: {
- value: {
- type: [String, Number, Array],
- default: ''
- },
- init: {
- type: Boolean,
- default: true
- },
- augr: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- dictList: []
- };
- },
- computed: {
- selectVal: {
- set(val) {
- this.$emit('updateVal', val);
- this.$emit(
- 'selfChange',
- val,
- this.dictList.find((i) => i.id === val)
- );
- },
- get() {
- return this.value;
- }
- }
- },
- created() {
- if (this.init) {
- this.getList();
- }
- },
- methods: {
- returnName(item) {
- this.$emit('returnName', item.name);
- this.$emit('returnItem', item);
- },
- async getList() {
- let params = {
- pageNum: -1,
- size: -1,
- type: this.augr
- };
- if (this.augr == 0) {
- delete params.type;
- const res = await factoryworkstation(params);
- console.log('res-------', res);
- this.dictList = res.list;
- return;
- }
- const res = await getFactoryarea(params);
- this.dictList = res.list;
- }
- }
- };
- </script>
|