index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. },
  23. data() {
  24. return {
  25. innerValue: '',
  26. userInfo: ''
  27. }
  28. },
  29. created() {
  30. this.userInfo = uni.getStorageSync('userInfo') || {}
  31. this.setDefault()
  32. },
  33. methods: {
  34. setDefault() {
  35. if (this.type === 'currUser') {
  36. this.innerValue = this.userInfo.userName + '/' + this.userInfo.userAccount
  37. if (!this.userInfo.userName && !this.userInfo.userAccount) this.innerValue = ""
  38. }
  39. if (this.type === 'currTime') {
  40. this.innerValue = this.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
  41. }
  42. if (this.type === 'currOrganize' && this.userInfo.organizeList?.length) {
  43. const list = this.userInfo.organizeList.map((o) => o.treeName);
  44. this.innerValue = list.join(',');
  45. }
  46. if (this.type === 'currPosition' && this.userInfo.positionList?.length) {
  47. const list = this.userInfo.positionList.map((o) => o.treeName);
  48. this.innerValue = list.join(',');
  49. }
  50. }
  51. }
  52. }
  53. </script>