Browse Source

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min 1 year ago
parent
commit
aa2b91af89

+ 2 - 2
fhKeeper/formulahousekeeper/timesheet/index.html

@@ -8,6 +8,8 @@
         <meta http-equiv="expires" content="0"> -->
     <!-- 尝试清除打包缓存 -->
     <title>工时管家</title>
+    <!--接入钉钉前端组件,进行通讯录组件展示-->
+    <script src="https://auth.dingtalk.com/opendata-1.1.0.js"></script>
     <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
     <link href="./static/css/public.css" rel="stylesheet" type="text/css" />
     <!-- 引入样式 -->
@@ -15,8 +17,6 @@
       href="https://cdn.staticfile.org/element-ui/2.13.0/theme-chalk/index.css"
       rel="stylesheet"
     />
-    <!--接入钉钉前端组件,进行通讯录组件展示-->
-    <script src="https://auth.dingtalk.com/opendata-1.1.0.js"></script>
     <!-- <link rel="stylesheet" href="./static/js/element-uiCss.css"> -->
     <!-- 接入JQ  -->
     <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>

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

@@ -0,0 +1,127 @@
+<template>
+    <div class="translation">
+        <!-- 文本 -->
+        <template v-if="renderType[configuration.renderIndex] === 'text'">
+            <span v-if="corporateWeChat && !noRender.includes(translationValue)">
+                <ww-open-data :type='configuration.openType' :openid='translationValue'></ww-open-data>
+            </span>
+            <span v-else-if="dingdingPlatform && !noRender.includes(translationValue)">
+                <dt-open-data :open-type='configuration.openType' :open-id='translationValue'></dt-open-data>
+            </span>
+            <span v-else>{{ 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,
+            }, // 配置对象
+
+            noRender: ['全部人员', '未分配']
+        }
+    },
+    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
+                if (dingdingUserid) {
+                    this.dingdingPlatform = true
+                    this.corporateWeChat = false
+                } else {
+                    this.dingdingPlatform = false
+                }
+            } else {
+                this.corporateWeChat = false
+                this.dingdingPlatform = false
+            }
+            // console.log(this.corporateWeChat, this.dingdingPlatform, this.configurationItems)
+            // console.log(this.corporateWeChat, '<=== 企业微信转译')
+            // console.log(this.dingdingPlatform, '<=== 钉钉转译')
+            this.assignmentValue(this.configurationItems)
+        },
+        assignmentValue(value) {
+            const { openType, openId, renderIndex = 0 } = value
+            this.configuration = { openType, openId, renderIndex }
+            const type = this.renderType[renderIndex]
+
+            switch (type) {
+                case 'text':
+                    this.translationValue = openId
+                    break;
+                case 'array':
+                    this.translationValArray = openId.split(',')
+                    break;
+                case 'object':
+                    this.translationValObject = openId
+                    break;
+                default:
+                    break;
+            }
+            // console.log(this.translationValue, '<=== 转译文本')
+            if (this.user.dingdingUserid) {
+                this.viewConfiguration()
+            }
+        },
+        viewConfiguration() {
+            window.DTOpenData.update(document.querySelectorAll('dt-open-data'));
+        }
+    },
+}
+</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:["工时报告","专业审核","部门审核","自动计时","费用报销","待办任务", "项目管理", "请假管理", "审批流设置"]},

+ 25 - 7
fhKeeper/formulahousekeeper/timesheet/src/views/Home.vue

@@ -32,7 +32,6 @@
                         <el-dropdown-item divided  command="en">English</el-dropdown-item>
                     </el-dropdown-menu> 
                 </el-dropdown> -->
-
                 <el-dropdown trigger="hover" style="margin-right:30px;">
                     <span class="el-dropdown-link userinfo-inner">
                         <i class="el-icon-user" style="font-size:18px" ></i>
@@ -63,7 +62,6 @@
                         </el-dropdown-item>
                     </el-dropdown-menu>
                 </el-dropdown> 
-                    
                 {{$t('time.dueDate')}}:{{remainingTime}}
                 <el-badge class="itemNew" :value="num" :hidden="num == 0">
                     <i class="el-icon-message-solid" style="font-size:24px" v-popover:popover1 @click="drawer = true"></i>
@@ -84,7 +82,7 @@
                                             <span v-if="user.userNameNeedTranslate == 1">
                                                 {{scope.row.omg.textOne}}
                                                 <ww-open-data v-if="user.corpwxUserid != null" type='userName' :openid='scope.row.omg.textTwo'></ww-open-data>
-                                                <dd-open-data v-if="user.dingdingUserid != null" openType='userName' :openId='scope.row.omg.textTwo'></dd-open-data>
+                                                <dt-open-data v-if="user.dingdingUserid != null" open-type='userName' :open-id='scope.row.omg.textTwo'></dt-open-data>
                                                 {{scope.row.omg.textThree}}
                                             </span>
                                         </span>
@@ -105,12 +103,16 @@
                 <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">
+                            <dt-open-data open-type='userName' :open-id='user.dingdingUserid'></dt-open-data>
+                        </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">
@@ -860,6 +862,21 @@
                         return false;
                     }
                 });
+            },
+
+            setDDOpenData() {
+                const ddUrl = new URL(window.location.href);
+                const ddCorpid = ddUrl.searchParams.get("corpid") || ''
+                let ddOpenDataInit = window.DTOpenData.init(ddCorpid)
+                console.log(ddOpenDataInit, '<=== 钉钉执行 window.DTOpenData.init(ddCorpid) 的判断')
+                if (ddOpenDataInit) {
+                    setTimeout(() => {
+                        console.log('<==== 执行 window.DTOpenData.update(document.querySelectorAll(dt-open-data))')
+                        window.DTOpenData.update(document.querySelectorAll('dt-open-data'));
+                    }, 300)
+                }else {
+                    console.log('钉钉没有触发')
+                }
             }
         },
         mounted() {
@@ -903,8 +920,6 @@
             }
 
             // 判断是否为新用户
-            // console.log(this.firstTourFalse, '数据书数据123', 'true' == true)
-            // if(this.firstTourFalse != 'false') {
             if(this.user.isFirstLogin == 1 && this.user.roleName == '超级管理员' && this.firstTourFalse != 'false' && this.user.createTime[0] > '2022') {
                 var thats = this
                 this.tourFlg = true
@@ -921,6 +936,9 @@
             if(this.jobNumberCheckCompanyId.includes(companyId) && !jobNumber) {
                 this.perfectJobNumber = true
             }
+            if(this.user.dingdingUserid) {
+                this.setDDOpenData()
+            }
         },
     };
 </script>

+ 12 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/Login.vue

@@ -199,6 +199,11 @@
                     }
                 } else {
                     if(href.indexOf("corpid") > 0) {
+                        if(!(window.location.href.indexOf("ddLoginUnique") > 0)) {
+                            this.tryDingDingUrlRedirect()
+                            return
+                        }
+ 
                         // 钉钉登陆
                         //检查环境,如果是钉钉有$CORPID$
                         var key = '?corpid=';
@@ -359,6 +364,13 @@
                 var weixinUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+encodeURI(url)+"&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
                 window.location.href = weixinUrl;
             },
+            tryDingDingUrlRedirect() {
+                let currentAddress = window.location.href+'?ddLoginUnique=true';
+                let ddFixedPrefix = 'http://auth.dingtalk.com/login?redirectUri='
+                let ddFixedUrl = 'https://login.dingtalk.com/oauth2/auth?response_type=code&client_id=dingwa4tibze6jwz7mgv&scope=openid&state=dddd&redirect_uri=' + encodeURIComponent(`${ddFixedPrefix}${currentAddress}`)
+                window.location.href = ddFixedUrl;
+                // window.location.href = window.location.href+'?ddLoginUnique=true';
+            },
             loginByUserId(userId, path) {
                 this.http.post("/user/loginByUserId", {userId:userId} , res => {
                             if (res.code == "ok") {

+ 4 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -375,7 +375,7 @@
                           <span style="float: right; color: #8492a6; font-size: 13px">{{ item.jobNumber }}</span>
                         </el-option>
                     </el-select>
-                    <selectCat :size="'medium'" :filterable="true" :widthStr="'360'" v-if="user.userNameNeedTranslate == '1' && departmentVisible" :subject="users" :subjectId="depForm.otherManagerIds" :distinction="'4'" :clearable="true" @selectCal="selectCal"></selectCat>
+                    <selectCat :subject="users" :subjectId="depForm.otherManagerIds" :size="'medium'" :filterable="true" :widthStr="'360'" :multiSelect="true" v-if="user.userNameNeedTranslate == '1' && departmentVisible"  :distinction="'4'" :clearable="true" @selectCal="selectCal"></selectCat>
                 </el-form-item>
                 <!-- 直属领导 -->
                 <el-form-item :label="$t('leadership')" prop="reportAuditUserid" v-if="user.timeType.needDeptAudit">
@@ -3668,8 +3668,10 @@ export default {
     } ,
     // 自定义组件事件
     selectCal(obj) {
+      console.log(obj, '<=== 返回的数据')
       if(obj.distinction == '4') {
-        this.depForm.otherManagerIds = obj.id
+        let userList = obj.arrUserList || []
+        this.depForm.otherManagerIds = userList.map(item => item.id)
       } else if(obj.distinction == '3') {
         this.depForm.managerId = obj.id
       } else if(obj.distinction == '5'){