index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <u-input input-align='right' :modelValue="modelValue" placeholder="系统自动生成" disabled />
  3. </template>
  4. <script>
  5. export default {
  6. name: 'jnpf-open-data',
  7. props: {
  8. modelValue: {
  9. type: String,
  10. default: ''
  11. },
  12. /**
  13. * currUser - 当前用户
  14. * currTime - 当前时间
  15. * currOrganize - 所属组织
  16. * currPosition - 所属岗位
  17. */
  18. type: {
  19. type: String,
  20. default: ''
  21. },
  22. showLevel: {
  23. type: String,
  24. default: 'last'
  25. },
  26. },
  27. data() {
  28. return {
  29. innerValue: '',
  30. userInfo: ''
  31. }
  32. },
  33. watch: {
  34. showLevel() {
  35. this.setDefault()
  36. }
  37. },
  38. created() {
  39. this.userInfo = uni.getStorageSync('userInfo') || {}
  40. this.setDefault()
  41. },
  42. methods: {
  43. setDefault() {
  44. if (this.type === 'currUser') {
  45. this.innerValue = this.userInfo.userName + '/' + this.userInfo.userAccount
  46. if (!this.userInfo.userName && !this.userInfo.userAccount) this.innerValue = ""
  47. }
  48. if (this.type === 'currTime') {
  49. this.innerValue = this.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
  50. }
  51. if (this.type === 'currOrganize') {
  52. this.innerValue = this.showLevel === 'last' ? this.userInfo.departmentName : this.userInfo.organizeName
  53. }
  54. if (this.type === 'currPosition') {
  55. this.innerValue = this.userInfo.positionName || ""
  56. }
  57. }
  58. }
  59. }
  60. </script>