Selaa lähdekoodia

提交初步的转译组件代码

Lijy 1 vuosi sitten
vanhempi
commit
6bfa4ac0fa

+ 101 - 0
fhKeeper/formulahousekeeper/timesheet/src/components/translationOpenData.vue

@@ -0,0 +1,101 @@
+<template>
+    <div class="translation">
+        <!-- 文本 -->
+        <template v-if="renderType[configuration.renderIndex] === 'text'">
+            <span v-if="corporateWeChat">
+                <ww-open-data :type='configuration.openType' :openid='translationValue'></ww-open-data>
+            </span>
+            <span v-if="dingdingPlatform">
+                <dt-open-data :open-type='configuration.openType' :open-id='translationValue'></dt-open-data>
+            </span>
+            <span v-if="!corporateWeChat && !dingdingPlatform">{{ translationValue }}</span>
+        </template>
+        <!-- 数组 -->
+        <template v-if="renderType[configuration.renderIndex] === 'array'">
+
+        </template>
+        <!-- 对象 -->
+        <template v-if="renderType[configuration.renderIndex] === 'object'">
+
+        </template>
+    </div>
+</template>
+
+<script>
+export default {
+    name: '',
+    components: {},
+    props: {
+        configurationItems: {
+            type: Object,
+            default: () => {
+                return {
+                    openType: 'userName',
+                    openId: '',
+                    renderIndex: 0, // 0: 纯文本,1:数组,2:显示工号
+                }
+            }
+        }
+    },
+    data() {
+        return {
+            user: JSON.parse(sessionStorage.getItem("user")),
+            renderType: ['text', 'array', 'object'],
+            corporateWeChat: false, // 企业微信转译
+            dingdingPlatform: false, // 钉钉转译
+
+            translationValue: '', // 文本转译值
+            translationValArray: [], // 数组转译值
+            translationValObject: {}, // 对象转译值
+
+            configuration: {
+                openType: 'userName',
+                openId: '',
+                renderIndex: 0,
+            }, // 配置对象
+        }
+    },
+    computed: {},
+    watch: {
+        configurationItems: {
+            handler(newVal, oldVal) {
+                this.assignmentValue(newVal)
+            },
+        }
+    },
+    created() { },
+    mounted() {
+        this.dealWith()
+    },
+    methods: {
+        dealWith() {
+            console.log(this.user)
+            const { userNameNeedTranslate, dingdingUserid } = this.user
+            if (userNameNeedTranslate) {
+                this.corporateWeChat = true
+                this.dingdingPlatform = dingdingUserid ? true : false
+            } else {
+                this.corporateWeChat = false
+                this.dingdingPlatform = false
+            }
+            console.log(this.corporateWeChat, this.dingdingPlatform, this.configurationItems)
+        },
+        assignmentValue(value) {
+            console.log(value)
+            const { openType, openId, renderIndex = 0 } = value
+            this.configuration = { openType, openId, renderIndex }
+            const type = this.renderType[renderIndex]
+            if(type === 'text') {
+                this.translationValue = openId
+            }
+            console.log(this.translationValue, '<==== this.translationValue')
+        }
+    },
+}
+</script>
+<style scoped lang='scss'>
+.translation {
+    width: auto;
+    display: inline-block;
+}
+</style>

+ 4 - 0
fhKeeper/formulahousekeeper/timesheet/src/main.js

@@ -74,6 +74,10 @@ Vue.use(VueTour)
 import Print from './assets/js/print.js'
 Vue.use(Print)
 
+// 全局转译组件
+import TranslationOpenData from '@/components/translationOpenData.vue'
+Vue.component('TranslationOpenData', TranslationOpenData)
+
 var addRouFlag = false; 
 //角色权限对应关系
 var userModules = [{role:0, modules:["工时报告","专业审核","部门审核","自动计时","费用报销","待办任务", "项目管理", "请假管理", "审批流设置"]},

+ 3 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/Home.vue

@@ -103,7 +103,7 @@
                 <el-dropdown trigger="hover" style="margin-left:10px;">
                     <span class="el-dropdown-link userinfo-inner">
                         <img src="../assets/image/userHead.png" />
-                        <span v-if="user.userNameNeedTranslate == 1">
+                        <!-- <span v-if="user.userNameNeedTranslate == 1">
                             <ww-open-data type='userName' :openid='sysUserName'></ww-open-data>
                         </span>
                         <span v-if="user.dingdingUserid">
@@ -111,7 +111,8 @@
                         </span>
                         <span v-if="user.userNameNeedTranslate != 1">
                             {{sysUserName}}
-                        </span>
+                        </span> -->
+                        <TranslationOpenData :configurationItems="{ openType: 'userName', openId: sysUserName, renderIndex: 0 }" />
                         <!-- {{sysUserName}} -->
                     </span>
                     <el-dropdown-menu slot="dropdown">