Browse Source

出差管理增加从钉钉同步

Lijy 2 năm trước cách đây
mục cha
commit
f47f627ff7

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

@@ -23,6 +23,8 @@ import VDistPicker from 'v-distpicker'
 Vue.component('v-distpicker',VDistPicker)
 
 import './day.js' // 加载 dayjs 初始化配置
+import dayjs from 'dayjs';
+Vue.prototype.dayjs = dayjs;
 
 import Viewer from 'v-viewer' // 图片预览
 import 'viewerjs/dist/viewer.css'

+ 75 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/awayOffice/awayOffice.vue

@@ -186,6 +186,10 @@
                     <div><span style="color: #606266">时间段</span>
                         <el-date-picker v-model="createDate" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @change="billss()" value-format="yyyy-MM-dd" placeholder="选择日期" size="small" clearable style="width:280px"></el-date-picker>
                     </div>
+                    <!-- 从顶顶同步按钮 -->
+                    <div style="margin: 0 0 0 20px">
+                        <el-button size="small" type="primary" @click="synchronizationDaying = true">从钉钉同步</el-button>
+                    </div>
                 </div>
         <!-- 出差列表 -->
                 <el-table :data="tableList" style="width: 100%" height="90%">
@@ -600,6 +604,26 @@
             </div>
         </el-dialog>
     </el-dialog>
+    <!-- 点击钉钉同步弹窗 -->
+    <el-dialog title="从钉钉同步" :visible.sync="synchronizationDaying" width="480px" :before-close="handleClose">
+        <div>
+            <div class="dingdingtongbu">
+                <span>选择人员</span>
+                <el-select v-model="ownerIdsId" placeholder="请选择人员" clearable 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>
+                </el-select>
+            </div>
+            <div class="dingdingtongbu" style="margin-top: 20px">
+                <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>
+            </div>
+        </div>
+        <span slot="footer" class="dialog-footer">
+            <el-button @click="synchronizationDaying = false">取 消</el-button>
+            <el-button type="primary" @click="listSynchronize()" :loading="synchronizeLoading">同 步</el-button>
+        </span>
+    </el-dialog>
 </section>
 </template>
 
@@ -730,7 +754,11 @@ export default {
                 endDate:[{required: true,message: '请选择结束日期',trigger: 'change'}],
                 projectId:[{required: true,message: '请选择要关联的项目',trigger: 'change'}],
             },
-            relationItemTemporaryDate: {}
+            relationItemTemporaryDate: {},
+            synchronizeLoading: false,
+            synchronizationDaying:false,
+            createDateList: [],
+            ownerIdsId: ''
         }
     },
     created(){
@@ -756,6 +784,47 @@ export default {
         // console.log("session",this.wuduData);
     },
     methods: {
+        // 从钉钉同步假期剩余表
+        listSynchronize(){
+            this.synchronizeLoading = true
+            let transmissionObj = {}
+            transmissionObj.userId = this.ownerIdsId
+            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")
+            }
+            // 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.synchronizeLoading = false
+                    this.$message({
+                        message: res.msg,
+                        type: 'error'
+                    })
+                }
+            },err => {
+                this.synchronizeLoading = false
+                this.$message({
+                    message: err,
+                    type: 'error'
+                })
+            })
+        },
         // 钉钉环境交互
         DingdingEditor(e){
             console.log(e);
@@ -1691,4 +1760,9 @@ export default {
     width: 35%;
     text-align: left;
 }
+.dingdingtongbu span {
+    display: inline-block;
+    width: 80px;
+    padding-left: 20px;
+}
 </style>