<template>
|
<el-form-item label="任务">
|
<el-select
|
v-model="index"
|
@change="handleChange"
|
placeholder="选择任务"
|
size="small"
|
class="w-150"
|
>
|
<el-option
|
v-for="(s, i) in missionList"
|
:key="i"
|
:label="s.missionCode"
|
:value="i"
|
/>
|
</el-select>
|
</el-form-item>
|
</template>
|
|
<script>
|
import { mapStores } from 'pinia';
|
import missionApi from '@/api/missionApi';
|
import { useFetchData } from '@/composables/fetchData';
|
import { useMissionStore } from '@/stores/mission';
|
|
export default {
|
setup() {
|
const { loading, fetchData } = useFetchData();
|
return { loading, fetchData };
|
},
|
props: {
|
type: String,
|
modelValue: String
|
},
|
emits: ['update:modelValue', 'change'],
|
data() {
|
return {
|
missionList: [],
|
index: undefined
|
};
|
},
|
computed: {
|
...mapStores(useMissionStore)
|
},
|
methods: {
|
fetchMission() {
|
this.fetchData((page, pageSize) => {
|
return missionApi
|
.fethchMission({ type: this.type, page, pageSize })
|
.then((res) => {
|
this.missionList = res.data;
|
this.missionStore.missionList = res.data;
|
// if (this.missionList.length > 0) {
|
// this.handleChange(0);
|
// }
|
return res.head;
|
});
|
});
|
},
|
handleChange(value) {
|
this.$emit('update:modelValue', this.missionList[value]);
|
// this.$emit('change', this.missionList[value]);
|
}
|
},
|
mounted() {
|
this.fetchMission();
|
}
|
};
|
</script>
|
<style>
|
/* :deep() .el-form-item__label {
|
color: red !important;
|
} */
|
</style>
|