Browse Source

优化

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

71
src/components/MdpSelectUserX/index.vue

@ -14,7 +14,7 @@
</div> </div>
<div v-if="disabled!==true" class="field-oper" :value="myVal" :class="{disabled:disabled===true,enabled:disabled!==true}"> <div v-if="disabled!==true" class="field-oper" :value="myVal" :class="{disabled:disabled===true,enabled:disabled!==true}">
<slot name="oper"> <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-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-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> </el-option>
@ -23,7 +23,7 @@
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<el-avatar class="user-avatar" :style="{backgroundColor:getMyColor(item)}">{{item.username}}</el-avatar> <el-avatar class="user-avatar" :style="{backgroundColor:getMyColor(item)}">{{item.username}}</el-avatar>
<span class="username">{{item.username}}</span> <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> <i v-else>&nbsp;&nbsp;</i>
</div> </div>
</el-option> </el-option>
@ -52,7 +52,7 @@
avaterCpd(){ avaterCpd(){
var isEmpty=this.isEmpty(this.myVal) 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} var obj={isNull:isEmpty,icon:'el-icon-user',color:'#E4E7ED',innerText:username}
if(this.getColor||this.color){ if(this.getColor||this.color){
if(this.getColor){ if(this.getColor){
@ -79,7 +79,7 @@
}, },
data(){ data(){
return { return {
myVal:null,
myVal:{userid:'',username:''},
users:[], users:[],
deptUserVisible:false, deptUserVisible:false,
projectVisible:false, projectVisible:false,
@ -95,25 +95,23 @@
}, },
myVal(){ 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.myVal||!this.myVal.userid){
if(this.value && this.value[this.useridKey]){
this.value[this.useridKey]="" this.value[this.useridKey]=""
this.value[this.usernameKey]="" this.value[this.usernameKey]=""
this.$emit('input',this.value) this.$emit('input',this.value)
} }
}else{ }else{
if(this.value[this.useridKey]!=this.myVal.userid){
this.value[this.useridKey]=this.myVal.userid
this.value[this.usernameKey]=this.myVal.username
this.$emit('input',this.value)
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
this.$emit('input',this.value)
}
} }
}
}
}
} }
}, },
@ -167,25 +165,7 @@
} }
return false; 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){
getMyColor(item){
if(item&&item.userid){ if(item&&item.userid){
@ -200,9 +180,7 @@
}else{ }else{
return util.getColor(0) return util.getColor(0)
} }
}
}
}
}, },
getMyIcon(item){ getMyIcon(item){
@ -218,16 +196,17 @@
return "el-icon-user" return "el-icon-user"
} }
} }
},
},
initData(){ 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:''}
}
}, },
onSelectChange(item){ onSelectChange(item){

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

@ -24,7 +24,7 @@
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<el-avatar class="user-avatar" :style="{backgroundColor:getMyColor(item)}">{{item.username}}</el-avatar> <el-avatar class="user-avatar" :style="{backgroundColor:getMyColor(item)}">{{item.username}}</el-avatar>
<span class="username">{{item.username}}</span> <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> <i v-else>&nbsp;&nbsp;</i>
</div> </div>
</el-option> </el-option>
@ -59,7 +59,7 @@
computed: { computed: {
avaterCpd(){ avaterCpd(){
var isEmpty=this.isEmpty(this.myVal) 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} var obj={isNull:isEmpty,icon:'el-icon-user',color:'#E4E7ED',innerText:username}
if(this.getColor||this.color){ if(this.getColor||this.color){
if(this.getColor){ if(this.getColor){
@ -86,7 +86,7 @@
}, },
data(){ data(){
return { return {
myVal:null,
myVal:{userid:'',username:''},
users:[], users:[],
deptUserVisible:false, deptUserVisible:false,
projectVisible:false, projectVisible:false,
@ -103,18 +103,21 @@
myVal(){ myVal(){
if(!this.myVal||!this.myVal.userid){ 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.useridKey]=""
this.value[this.usernameKey]="" this.value[this.usernameKey]=""
this.$emit('input',this.value) this.$emit('input',this.value)
} }
}else{ }else{
if(this.value[this.useridKey]!=this.myVal.userid){
this.value[this.useridKey]=this.myVal.userid
this.value[this.usernameKey]=this.myVal.username
this.$emit('input',this.value)
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
this.$emit('input',this.value)
}
} }
} }
} }
@ -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(){ initData(){
var myVal={} var myVal={}
myVal.userid=this.value[this.useridKey]
myVal.username=this.value[this.usernameKey]
this.myVal=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){ onSelectChange(item){
@ -256,8 +250,7 @@
}, },
mounted(){ mounted(){
var us=localStorage.getItem("mdp-his-users") var us=localStorage.getItem("mdp-his-users")
this.users=us?JSON.parse(us):[]
this.users=us?JSON.parse(us):[]
this.initData(); 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> <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>
<el-col :span="8" v-if="editForm.ntype=='0'"> <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> <el-button slot="oper" @click="activateTabPaneName='42'">去管理竞标人</el-button>
</mdp-field-x> </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> <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