translationOpenDataText.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div class="translation">
  3. <!-- 文本 -->
  4. <span v-if="corporateWeChat && openIdValue && !noRender.includes(openIdValue) ">
  5. <ww-open-data :type='type' :openid='openIdValue'></ww-open-data>
  6. </span>
  7. <span v-else-if="dingdingPlatform && openIdValue && !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. corporateWeChat: false, // 企业微信转译
  31. dingdingPlatform: false, // 钉钉转译
  32. openIdValue: '',
  33. noRender: ['全部人员', '未分配'],
  34. dingdingOpenType: {
  35. userName: 'userName',
  36. departmentName: 'deptName',
  37. }
  38. }
  39. },
  40. computed: {},
  41. watch: {
  42. openid: {
  43. handler(newVal, oldVal) {
  44. this.assignmentValue(newVal)
  45. },
  46. }
  47. },
  48. created() { },
  49. mounted() {
  50. this.dealWith()
  51. },
  52. methods: {
  53. dealWith() {
  54. const { userNameNeedTranslate, dingdingUserid } = this.user
  55. if (userNameNeedTranslate) {
  56. this.corporateWeChat = true
  57. if (dingdingUserid) {
  58. this.dingdingPlatform = true
  59. this.corporateWeChat = false
  60. } else {
  61. this.dingdingPlatform = false
  62. }
  63. } else {
  64. this.corporateWeChat = false
  65. this.dingdingPlatform = false
  66. }
  67. // console.log(this.corporateWeChat, this.dingdingPlatform, this.configurationItems)
  68. // console.log(this.corporateWeChat, '<=== 企业微信转译')
  69. // console.log(this.dingdingPlatform, '<=== 钉钉转译')
  70. this.assignmentValue(this.openid)
  71. },
  72. assignmentValue(value) {
  73. this.openIdValue = value
  74. if (this.user.dingdingUserid) {
  75. this.viewConfiguration()
  76. }
  77. },
  78. viewConfiguration() {
  79. setTimeout(() => {
  80. window.DTOpenData.update(document.querySelectorAll('dt-open-data'));
  81. }, 100);
  82. }
  83. },
  84. }
  85. </script>
  86. <style scoped lang='scss'>
  87. .translation {
  88. width: auto;
  89. display: inline-block;
  90. }
  91. </style>