You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.3 KiB

2 months ago
<template>
<u-input input-align='right' :value="value||innerValue" disabled placeholder=""></u-input>
</template>
<script>
export default {
name: 'jnpf-open-data',
props: {
value: {
type: String,
default: ''
},
/**
* currUser - 当前用户
* currTime - 当前时间
* currOrganize - 所属组织
* currPosition - 所属岗位
*/
type: {
type: String,
default: ''
},
showLevel: {
type: String,
default: 'last'
},
},
data() {
return {
innerValue: '',
userInfo: ''
}
},
watch: {
showLevel() {
this.setDefault()
}
},
created() {
this.userInfo = uni.getStorageSync('userInfo') || {}
this.setDefault()
},
methods: {
setDefault() {
if (this.type === 'currUser') {
this.innerValue = this.userInfo.userName + '/' + this.userInfo.userAccount
if (!this.userInfo.userName && !this.userInfo.userAccount) this.innerValue = ""
}
if (this.type === 'currTime') {
this.innerValue = this.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
}
if (this.type === 'currOrganize') {
this.innerValue = this.showLevel === 'last' ? this.userInfo.departmentName : this.userInfo.organizeName
}
if (this.type === 'currPosition') {
this.innerValue = this.userInfo.positionName || ""
}
}
}
}
</script>