translationOpenDataText.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="translation">
  3. <!-- 文本 -->
  4. <span v-if="corporateWeChat && !noRender.includes(openIdValue)">
  5. <ww-open-data :type='type' :openid='openIdValue'></ww-open-data>
  6. </span>
  7. <span v-else-if="dingdingPlatform && !noRender.includes(openIdValue)">
  8. <dt-open-data :open-type='dingdingOpenType[type]' :open-id='openIdValue'></dt-open-data>
  9. </span>
  10. <span v-else>{{ openIdValue }}</span>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: '',
  16. components: {},
  17. props: {
  18. type: {
  19. type: String,
  20. default: 'userName'
  21. },
  22. openid: {
  23. type: [String, Number],
  24. default: ''
  25. }
  26. },
  27. data() {
  28. return {
  29. // user: JSON.parse(sessionStorage.getItem("user")),
  30. user: JSON.parse(localStorage.getItem("userInfo")),
  31. corporateWeChat: false, // 企业微信转译
  32. dingdingPlatform: false, // 钉钉转译
  33. openIdValue: '',
  34. noRender: ['全部人员', '未分配'],
  35. dingdingOpenType: {
  36. userName: 'userName',
  37. departmentName: 'deptName',
  38. }
  39. }
  40. },
  41. computed: {},
  42. watch: {
  43. openid: {
  44. handler(newVal, oldVal) {
  45. this.assignmentValue(newVal)
  46. },
  47. }
  48. },
  49. created() { },
  50. mounted() {
  51. this.dealWith()
  52. },
  53. methods: {
  54. dealWith() {
  55. console.log(this.user)
  56. const { userNameNeedTranslate, dingdingUserid } = this.user
  57. if (userNameNeedTranslate) {
  58. this.corporateWeChat = true
  59. if (dingdingUserid) {
  60. this.dingdingPlatform = true
  61. this.corporateWeChat = false
  62. } else {
  63. this.dingdingPlatform = false
  64. }
  65. } else {
  66. this.corporateWeChat = false
  67. this.dingdingPlatform = false
  68. }
  69. // console.log(this.corporateWeChat, this.dingdingPlatform, this.configurationItems)
  70. // console.log(this.corporateWeChat, '<=== 企业微信转译')
  71. // console.log(this.dingdingPlatform, '<=== 钉钉转译')
  72. this.assignmentValue(this.openid)
  73. },
  74. assignmentValue(value) {
  75. this.openIdValue = value
  76. if (this.user.dingdingUserid) {
  77. this.viewConfiguration()
  78. }
  79. },
  80. viewConfiguration() {
  81. setTimeout(() => {
  82. window.DTOpenData.update(document.querySelectorAll('dt-open-data'));
  83. }, 100);
  84. }
  85. },
  86. }
  87. </script>
  88. <style scoped>
  89. .translation {
  90. width: auto;
  91. display: inline-block;
  92. }
  93. </style>