Browse Source

优化

master
陈裕财 3 years ago
parent
commit
f34c9a653a
  1. 47
      src/components/MdpSelectUserX/index.vue
  2. 31
      src/views/xm/core/components/MdpSelectUserXm/index.vue
  3. 2
      src/views/xm/core/xmTask/XmTaskEdit.vue

47
src/components/MdpSelectUserX/index.vue

@ -14,7 +14,7 @@
</div>
<div v-if="disabled!==true" class="field-oper" :value="myVal" :class="{disabled:disabled===true,enabled:disabled!==true}">
<slot name="oper">
<el-select v-model="myVal" @change="onSelectChange" :clearable="clearable">
<el-select v-model="myVal" @change="onSelectChange" :clearable="clearable" value-key="userid">
<el-option disabled value="" style="margin-bottom:5px;">
<el-row><el-button :type="deptUserVisible?'':'primary'" @click.stop="deptUserVisible=false">常用用户</el-button> <el-button :type="deptUserVisible?'primary':''" @click.stop="deptUserVisible=true"></el-button><el-button v-if="projectId" :type="projectVisible?'primary':''" @click.stop="projectVisible=true"></el-button> </el-row>
</el-option>
@ -23,7 +23,7 @@
<div class="avatar-wrapper">
<el-avatar class="user-avatar" :style="{backgroundColor:getMyColor(item)}">{{item.username}}</el-avatar>
<span class="username">{{item.username}}</span>
<i v-if="myVal.userid==item.userid" class="el-icon-check"></i>
<i v-if=" myVal && myVal.userid==item.userid" class="el-icon-check"></i>
<i v-else>&nbsp;&nbsp;</i>
</div>
</el-option>
@ -52,7 +52,7 @@
avaterCpd(){
var isEmpty=this.isEmpty(this.myVal)
var username=isEmpty?"":this.myVal.username?this.myVal.username:this.myVal.userid
var username=isEmpty?"":(this.myVal.username?this.myVal.username:this.myVal.userid)
var obj={isNull:isEmpty,icon:'el-icon-user',color:'#E4E7ED',innerText:username}
if(this.getColor||this.color){
if(this.getColor){
@ -79,7 +79,7 @@
},
data(){
return {
myVal:null,
myVal:{userid:'',username:''},
users:[],
deptUserVisible:false,
projectVisible:false,
@ -95,17 +95,15 @@
},
myVal(){
if(this.value instanceof String){
this.$emit('input',this.myVal)
}else if(this.value instanceof Object){
if(!this.myVal||!this.myVal.userid){
if(this.value[this.useridKey]){
if(this.value && this.value[this.useridKey]){
this.value[this.useridKey]=""
this.value[this.usernameKey]=""
this.$emit('input',this.value)
}
}else{
if(this.value){
if(this.value[this.useridKey]!=this.myVal.userid){
this.value[this.useridKey]=this.myVal.userid
this.value[this.usernameKey]=this.myVal.username
@ -168,24 +166,6 @@
return false;
},
getMyColor(item){
if(this.value instanceof String){
if(item){
if(this.getColor){
return this.getColor(item)
}
return util.getColor(item)
}else{
if(this.getColor){
return this.getColor("0")
}else{
return util.getColor(0)
}
}
}else if(this.value instanceof Object){
if(item&&item.userid){
@ -202,8 +182,6 @@
}
}
}
},
getMyIcon(item){
if(item){
@ -221,12 +199,13 @@
},
initData(){
if(this.value instanceof String){
this.myVal=this.value
}else if(this.value instanceof Object){
this.myVal={}
this.myVal.userid=this.value[this.useridKey]
this.myVal.username=this.value[this.usernameKey]
var myVal={}
if(this.value){
myVal.userid=this.value[this.useridKey]
myVal.username=this.value[this.usernameKey]
this.myVal=myVal
}else{
this.myVal={userid:'',username:''}
}
},

31
src/views/xm/core/components/MdpSelectUserXm/index.vue

@ -24,7 +24,7 @@
<div class="avatar-wrapper">
<el-avatar class="user-avatar" :style="{backgroundColor:getMyColor(item)}">{{item.username}}</el-avatar>
<span class="username">{{item.username}}</span>
<i v-if="myVal.userid==item.userid" class="el-icon-check"></i>
<i v-if="myVal && myVal.userid==item.userid" class="el-icon-check"></i>
<i v-else>&nbsp;&nbsp;</i>
</div>
</el-option>
@ -59,7 +59,7 @@
computed: {
avaterCpd(){
var isEmpty=this.isEmpty(this.myVal)
var username=isEmpty?"":this.myVal.username?this.myVal.username:this.myVal.userid
var username=isEmpty?"":(this.myVal.username?this.myVal.username:this.myVal.userid)
var obj={isNull:isEmpty,icon:'el-icon-user',color:'#E4E7ED',innerText:username}
if(this.getColor||this.color){
if(this.getColor){
@ -86,7 +86,7 @@
},
data(){
return {
myVal:null,
myVal:{userid:'',username:''},
users:[],
deptUserVisible:false,
projectVisible:false,
@ -103,13 +103,14 @@
myVal(){
if(!this.myVal||!this.myVal.userid){
if(this.value[this.useridKey]){
if(this.value && this.value[this.useridKey]){
this.value[this.useridKey]=""
this.value[this.usernameKey]=""
this.$emit('input',this.value)
}
}else{
if(this.value){
if(this.value[this.useridKey]!=this.myVal.userid){
this.value[this.useridKey]=this.myVal.userid
this.value[this.usernameKey]=this.myVal.username
@ -118,6 +119,8 @@
}
}
}
},
props: {
projectId:{
@ -192,27 +195,18 @@
}
}
},
getMyIcon(item){
if(item){
if(this.getIcon){
return this.getIcon(item)
}
return "el-icon-user";
}else{
if(this.getIcon){
return this.getIcon(this.myVal)
}else{
return "el-icon-user"
}
}
},
initData(){
var myVal={}
if(this.value){
myVal.userid=this.value[this.useridKey]
myVal.username=this.value[this.usernameKey]
this.myVal=myVal
}else{
this.myVal={userid:'',username:''}
}
},
onSelectChange(item){
@ -257,7 +251,6 @@
mounted(){
var us=localStorage.getItem("mdp-his-users")
this.users=us?JSON.parse(us):[]
this.initData();
}

2
src/views/xm/core/xmTask/XmTaskEdit.vue

@ -144,7 +144,7 @@
<mdp-select-user-xm label="负责人" v-model="editForm" userid-key="createUserid" username-key="createUsername" @change="editXmTaskSomeFields(editForm,'createUserid',$event)"></mdp-select-user-xm>
</el-col>
<el-col :span="8" v-if="editForm.ntype=='0'">
<mdp-field-x v-if="editForm.crowd=='1'" label="执行人" v-model="executorUsername">
<mdp-field-x v-if="editForm.crowd=='1'" label="执行人" v-model="editForm.executorUsername">
<el-button slot="oper" @click="activateTabPaneName='42'">去管理竞标人</el-button>
</mdp-field-x>
<mdp-select-user-xm v-if="editForm.crowd!='1'" label="执行人" v-model="editForm" userid-key="executorUserid" username-key="executorUsername" @change="editXmTaskSomeFields(editForm,'executorUserid',$event)"></mdp-select-user-xm>

Loading…
Cancel
Save