Browse Source

优化

master
陈裕财 3 years ago
parent
commit
980c9a9245
  1. 33
      src/components/DictField/index.vue

33
src/components/DictField/index.vue

@ -7,12 +7,15 @@
<span class="field-value" v-if="!avaterCpd.isNull">{{avaterCpd.innerText}} </span> <span class="field-value" v-if="!avaterCpd.isNull">{{avaterCpd.innerText}} </span>
<span class="field-value" v-else><span class="label-font-color"></span></span> <span class="field-value" v-else><span class="label-font-color"></span></span>
<span class="field-label" >{{label}}</span> <span class="field-label" >{{label}}</span>
<dict-select :dict="dict" ref="selectRef" v-model="myVal" @change="onChange" :get-icon="getIcon" :get-color="getColor"></dict-select>
<dict-select :dict="dict" ref="selectRef" v-model="myVal" @change="onChange" :get-icon="getIcon" :get-color="getColor" :icon="icon"></dict-select>
</div> </div>
</div> </div>
</template> </template>
<script>
<script>
import util from '@/common/js/util'
export default { export default {
name: 'dict-field', name: 'dict-field',
components: { }, components: { },
@ -25,10 +28,14 @@
} }
}, },
avaterCpd(){ avaterCpd(){
var currentItem = null
if(this.dict){
currentItem= this.dict.find(k=>k.id==this.myVal)
}
var isEmpty=this.isEmpty(this.myVal) var isEmpty=this.isEmpty(this.myVal)
var obj={isNull:isEmpty,icon:'el-icon-full-screen',color:'#FFFFFF',innerText:''} var obj={isNull:isEmpty,icon:'el-icon-full-screen',color:'#FFFFFF',innerText:''}
if(this.getColor){ if(this.getColor){
obj.color= this.getColor(this.currentItem)
obj.color= this.getColor(currentItem)
}else{ }else{
if(!isEmpty){ if(!isEmpty){
obj.color= util.getColor(this.myVal) obj.color= util.getColor(this.myVal)
@ -36,24 +43,25 @@
} }
if(this.getIcon||this.icon){ if(this.getIcon||this.icon){
if(this.getIcon){ if(this.getIcon){
obj.icon= this.getIcon(this.currentItem)
obj.icon= this.getIcon(currentItem)
}else if(this.icon){ }else if(this.icon){
obj.icon=this.icon obj.icon=this.icon
}else {
if(!isEmpty){
obj.icon= ''
}
} }
}else {
if(!isEmpty){
obj.icon= ''
}
} }
debugger;
if(isEmpty){ if(isEmpty){
obj.innerText="" obj.innerText=""
}else{ }else{
if(currentItem==null){ if(currentItem==null){
obj.innerText=this.myVal obj.innerText=this.myVal
}else{ }else{
obj.innerText=this.currentItem.name
obj.innerText=currentItem.name
} }
}
}
return obj; return obj;
} }
}, },
@ -97,6 +105,10 @@
}, },
icon:{
type:String,
default:null,
},
getIcon:{ getIcon:{
type:Function type:Function
}, },
@ -160,6 +172,7 @@
this.$emit('change',data) this.$emit('change',data)
}, },
isEmpty(v) { isEmpty(v) {
debugger;
switch (typeof v) { switch (typeof v) {
case 'undefined': case 'undefined':
return true; return true;

Loading…
Cancel
Save