Browse Source

出差管理调整从钉钉同步的限制

Lijy 2 years ago
parent
commit
5f5922d62a

+ 67 - 48
fhKeeper/formulahousekeeper/timesheet/src/views/awayOffice/awayOffice.vue

@@ -188,7 +188,7 @@
                     </div>
                     </div>
                     <!-- 从顶顶同步按钮 -->
                     <!-- 从顶顶同步按钮 -->
                     <div style="margin: 0 0 0 20px">
                     <div style="margin: 0 0 0 20px">
-                        <el-button size="small" type="primary" @click="synchronizationDaying = true">从钉钉同步</el-button>
+                        <el-button size="small" type="primary" @click="dingdingClick()">从钉钉同步</el-button>
                     </div>
                     </div>
                 </div>
                 </div>
         <!-- 出差列表 -->
         <!-- 出差列表 -->
@@ -609,7 +609,7 @@
         <div>
         <div>
             <div class="dingdingtongbu">
             <div class="dingdingtongbu">
                 <span>选择人员</span>
                 <span>选择人员</span>
-                <el-select v-model="ownerIdsId" placeholder="请选择人员" clearable style="width:280px" size="small" filterable="true">
+                <el-select v-model="ownerIdsId" placeholder="请选择人员" style="width:280px" size="small" filterable="true">
                     <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id">
                     <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id">
                     </el-option>
                     </el-option>
                 </el-select>
                 </el-select>
@@ -617,6 +617,7 @@
             <div class="dingdingtongbu" style="margin-top: 20px">
             <div class="dingdingtongbu" style="margin-top: 20px">
                 <span>时间段</span>
                 <span>时间段</span>
                 <el-date-picker v-model="createDateList" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" placeholder="选择日期" size="small" clearable style="width:280px"></el-date-picker>
                 <el-date-picker v-model="createDateList" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" placeholder="选择日期" size="small" clearable style="width:280px"></el-date-picker>
+                <span style="width: 300px;color: #E6A23C;font-size: 10px;padding-left: 105px;margin-top: 10px"> <i class="el-icon-warning-outline"></i> 从钉钉同步 时间段不能超过七天</span>
             </div>
             </div>
         </div>
         </div>
         <span slot="footer" class="dialog-footer">
         <span slot="footer" class="dialog-footer">
@@ -772,13 +773,6 @@ export default {
             that.tableHeight = window.innerHeight - 195;
             that.tableHeight = window.innerHeight - 195;
         };
         };
         this.isDingding = this.wuduData.syncDingding
         this.isDingding = this.wuduData.syncDingding
-        let startDates = this.dayjs().add('-7','day').format("YYYY-MM-DD")
-        let endDates = this.dayjs().format("YYYY-MM-DD")
-        let arr = []
-        arr.push(startDates)
-        arr.push(endDates)
-        this.createDateList = arr
-        console.log(this.createDateList)
     },
     },
     mounted(){
     mounted(){
         if(this.isDingding){
         if(this.isDingding){
@@ -792,54 +786,79 @@ export default {
         // console.log("session",this.wuduData);
         // console.log("session",this.wuduData);
     },
     },
     methods: {
     methods: {
+        dingdingClick() {
+            this.synchronizationDaying = true
+            this.ownerIdsId = this.users[0].id
+            let startDates = this.dayjs().add('-7','day').format("YYYY-MM-DD")
+            let endDates = this.dayjs().format("YYYY-MM-DD")
+            let arr = []
+            arr.push(startDates)
+            arr.push(endDates)
+            this.createDateList = arr
+        },
+        // 判断日期
+        determineDate(startDate, endDate) {
+            let startTime = new Date(Date.parse(startDate.replace(/-/g, "/"))).getTime();
+            let endTime = new Date(Date.parse(endDate.replace(/-/g, "/"))).getTime();
+            let dates = Math.abs((startTime - endTime)) / (1000 * 60 * 60 * 24);
+            let flg = dates > 7 ? false : true
+            return flg ;
+        },
         // 从钉钉同步假期剩余表
         // 从钉钉同步假期剩余表
         listSynchronize(){
         listSynchronize(){
-            this.synchronizeLoading = true
-            let transmissionObj = {}
-            transmissionObj.userId = this.ownerIdsId
-            transmissionObj.companyId = this.userComLis.companyId
-            console.log(this.createDateList, '俺看')
-            if(this.createDateList != 'null' && this.createDateList != null) {
-                if(this.createDateList.length > 0) {
-                    transmissionObj.startDate = this.createDateList[0]
-                    transmissionObj.endDate = this.createDateList[1]
+            // 判断日期
+            let flgs = this.determineDate(this.createDateList[0], this.createDateList[1])
+            if(flgs) {
+                this.synchronizeLoading = true
+                let transmissionObj = {}
+                transmissionObj.userId = this.ownerIdsId
+                transmissionObj.companyId = this.userComLis.companyId
+                console.log(this.createDateList, '俺看')
+                if(this.createDateList != 'null' && this.createDateList != null) {
+                    if(this.createDateList.length > 0) {
+                        transmissionObj.startDate = this.createDateList[0]
+                        transmissionObj.endDate = this.createDateList[1]
+                    } else {
+                        transmissionObj.startDate = this.dayjs().add('-7','day').format("YYYY-MM-DD")
+                        transmissionObj.endDate = this.dayjs().format("YYYY-MM-DD")
+                    }
+                    
                 } else {
                 } else {
-                    transmissionObj.startDate = this.dayjs().add('-7','day').format("YYYY-MM-DD")
-                    transmissionObj.endDate = this.dayjs().format("YYYY-MM-DD")
+                    transmissionObj.startDate = ''
+                    transmissionObj.endDate = ''
                 }
                 }
-                
-            } else {
-                transmissionObj.startDate = ''
-                transmissionObj.endDate = ''
-            }
-            // console.log(transmissionObj)
-            // return
-            this.http.post('/dingding/syncUserWorkData',transmissionObj,
-            res => {
-                if(res.code == 'ok'){
-                    this.synchronizeLoading = false
-                    this.synchronizationDaying = false
-                    this.$message({
-                        message: '同步成功',
-                        type: 'success'
-                    })
-                    this.ownerIdsId = ''
-                    this.createDateList = []
-                    this.getTableList()
-                }else {
+                this.http.post('/dingding/syncUserWorkData',transmissionObj,
+                res => {
+                    if(res.code == 'ok'){
+                        this.synchronizeLoading = false
+                        this.synchronizationDaying = false
+                        this.$message({
+                            message: '同步成功',
+                            type: 'success'
+                        })
+                        // this.ownerIdsId = ''
+                        // this.createDateList = []
+                        this.getTableList()
+                    }else {
+                        this.synchronizeLoading = false
+                        this.$message({
+                            message: res.msg,
+                            type: 'error'
+                        })
+                    }
+                },err => {
                     this.synchronizeLoading = false
                     this.synchronizeLoading = false
                     this.$message({
                     this.$message({
-                        message: res.msg,
+                        message: err,
                         type: 'error'
                         type: 'error'
                     })
                     })
-                }
-            },err => {
-                this.synchronizeLoading = false
-                this.$message({
-                    message: err,
-                    type: 'error'
                 })
                 })
-            })
+            } else {
+                this.$message({
+                    message: '从钉钉同步消息时间段不能超过七天',
+                    type: 'warning'
+                });
+            }
         },
         },
         // 钉钉环境交互
         // 钉钉环境交互
         DingdingEditor(e){
         DingdingEditor(e){