|
@@ -1,14 +1,17 @@
|
|
|
<template>
|
|
|
- <el-select v-model="value" :placeholder="allText ? allText : '全部'" :disabled="disabled">
|
|
|
- <el-option :label="allText ? allText : '全部'" :value="''" v-if="showAll"></el-option>
|
|
|
- <el-option v-for="item in filterOptions" :key="item.id" :label="item.roleName" :value="item.id"></el-option>
|
|
|
- </el-select>
|
|
|
+ <span v-if="this.options.length" :key="key">
|
|
|
+ <el-select v-model="value" :placeholder="allText ? allText : '全部'" :disabled="disabled">
|
|
|
+ <el-option :label="allText ? allText : '全部'" :value="''" v-if="showAll"></el-option>
|
|
|
+ <el-option v-for="item in filterOptions" :key="filterOptions.length+'全部'+item.id" :label="item.roleName" :value="item.id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </span>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import selectComponentJs from '../select'
|
|
|
import { getRoleList,getListByDeptId } from '@/request/config'
|
|
|
import axios from 'axios'
|
|
|
+// import { $forceUpdate } from 'vue'
|
|
|
|
|
|
const extObj = selectComponentJs()
|
|
|
|
|
@@ -17,18 +20,14 @@ extObj.props = [...extObj.props, 'maxLeave', 'disabled','deptId']
|
|
|
extObj.computed = {
|
|
|
...extObj.computed,
|
|
|
filterOptions() {
|
|
|
- if (!this.maxLeave) {
|
|
|
+ console.log(this.options)
|
|
|
return this.options
|
|
|
- } else {
|
|
|
- return this.options.filter(({id}) => Number(id) >= Number(this.maxLeave))
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
extObj.watch = {
|
|
|
...extObj.watch,
|
|
|
deptId() {
|
|
|
- console.log('setup',this.deptId);
|
|
|
this.value = ''
|
|
|
this.getOptions()
|
|
|
}
|
|
@@ -37,21 +36,26 @@ extObj.watch = {
|
|
|
export default {
|
|
|
...extObj,
|
|
|
|
|
|
- async mounted() {
|
|
|
- console.log('mounted',this.deptId);
|
|
|
+ async created() {
|
|
|
+ console.log('mounted',this.deptId, this.key);
|
|
|
if(this.deptId){
|
|
|
this.getOptions()
|
|
|
}else{
|
|
|
let res = await axios.post(getRoleList, {})
|
|
|
this.options = res.data.map(item => ({...item, id: item.id.toString()}))
|
|
|
}
|
|
|
- extObj.mounted.call(this)
|
|
|
+ console.log(this)
|
|
|
+ // extObj.mounted.call(this)
|
|
|
},
|
|
|
+
|
|
|
methods:{
|
|
|
...extObj.methods,
|
|
|
async getOptions(){
|
|
|
let res = await axios.get(getListByDeptId, {params:{deptId:this.deptId}})
|
|
|
this.options = res.data.map(item => ({...item, id: item.id.toString()}))
|
|
|
+ setTimeout(() => {
|
|
|
+ this.key = '2'
|
|
|
+ }, 200)
|
|
|
}
|
|
|
}
|
|
|
}
|