Browse Source

新版按周填报加载填报过的工时

seyason 1 year ago
parent
commit
4b882b4190
1 changed files with 81 additions and 23 deletions
  1. 81 23
      fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/weekEdit.vue

+ 81 - 23
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/weekEdit.vue

@@ -190,7 +190,8 @@
                         <!-- 常规选择时间的方式 -->
                         <!-- 常规选择时间的方式 -->
                         <!-- 全天上下午模式 -->
                         <!-- 全天上下午模式 -->
                         <div v-if="reportTimeType.multiWorktime==0">
                         <div v-if="reportTimeType.multiWorktime==0">
-                        <van-field v-if="reportTimeType.type < 2" readonly clickable  :value="reportTimeType.type==0?item.label:(parseFloat(item.workingTime).toFixed(1)+'h')" label="工作时长" placeholder="请选择工作时长(小时)" @click="clickTimePicker(index)"
+                        <van-field v-if="reportTimeType.type < 2" readonly clickable  :value="reportTimeType.type==0?item.label:(parseFloat(item.workingTime).toFixed(1)+'h')" label="工作时长" placeholder="请选择工作时长(小时)" 
+                        @click="clickTimePicker(index, item)"
                         :rules="[{ required: true, message: '请选择工作时长' }]"/>
                         :rules="[{ required: true, message: '请选择工作时长' }]"/>
                         <van-popup v-model="showPickerTime" position="bottom">
                         <van-popup v-model="showPickerTime" position="bottom">
                             <van-picker show-toolbar :columns="timeType"  value-key="label" @confirm="choseTimePick" @cancel="showPickerTime = false" />
                             <van-picker show-toolbar :columns="timeType"  value-key="label" @confirm="choseTimePick" @cancel="showPickerTime = false" />
@@ -247,7 +248,7 @@
                             </template>
                             </template>
                         </van-cell>
                         </van-cell>
                         <van-field class="form_input"
                         <van-field class="form_input"
-                        v-model="item.content" name="content" type="textarea" :label="user.companyId==781?'具体内容与结果':'工作事项'" placeholder="请输入" 
+                        v-model="item.content" name="content" type="textarea" :label="user.companyId==781?'具体内容与结果':'工作事项'" placeholder="请输入" :disabled="item.state<=1"
                         rows="3" autosize :rules="user.timeType.workContentState == 1 ? [{ required: true, message: user.companyId==781?'具体内容与结果':'工作事项' }] : null" />
                         rows="3" autosize :rules="user.timeType.workContentState == 1 ? [{ required: true, message: user.companyId==781?'具体内容与结果':'工作事项' }] : null" />
                         </div>
                         </div>
                         
                         
@@ -758,14 +759,17 @@
                 let date = new Date(shuldDate.getFullYear(),shuldDate.getMonth(),shuldDate.getDate()-shuldDate.getDay()+1)
                 let date = new Date(shuldDate.getFullYear(),shuldDate.getMonth(),shuldDate.getDate()-shuldDate.getDay()+1)
                 console.log(this.formatDate(date), '<=== date', this.formatDate(shuldDate), this.formatDate(nowWeekday))
                 console.log(this.formatDate(date), '<=== date', this.formatDate(shuldDate), this.formatDate(nowWeekday))
                 this.dateRange = []
                 this.dateRange = []
-
+                let newWeeklyDataList = [];
+                let serverPList = [];
                 if(enableNewWeeklyfill) { // 针对物奇
                 if(enableNewWeeklyfill) { // 针对物奇
                     let { data } = await this.$axios.post('/report/getWeeklyFillReportData', {
                     let { data } = await this.$axios.post('/report/getWeeklyFillReportData', {
                         targetDate: this.formatDate(date)
                         targetDate: this.formatDate(date)
                     })
                     })
+                    serverPList = data.projectList;
                     let { dateList } = data
                     let { dateList } = data
                     this.dateRange = dateList.map(item => new Date(item.date))
                     this.dateRange = dateList.map(item => new Date(item.date))
                     this.dateText = [dateList[0].date, dateList[dateList.length - 1].date]
                     this.dateText = [dateList[0].date, dateList[dateList.length - 1].date]
+                    newWeeklyDataList = dateList;
                 } else {
                 } else {
                     for(let i=0;i<this.weekIndex;i++){
                     for(let i=0;i<this.weekIndex;i++){
                         this.dateRange.push(new Date(date.getFullYear(),date.getMonth(),date.getDate()+i))
                         this.dateRange.push(new Date(date.getFullYear(),date.getMonth(),date.getDate()+i))
@@ -778,23 +782,71 @@
                 let startDateD = startDate.getDate()
                 let startDateD = startDate.getDate()
 
 
                 // let endDate = this.dateRange[this.weekIndex - 1]
                 // let endDate = this.dateRange[this.weekIndex - 1]
-                let endDate = this.dateRange.at(-1)
+                let endDate = this.dateRange[this.dateRange.length-1];
                 let endDateM = endDate.getMonth() + 1
                 let endDateM = endDate.getMonth() + 1
                 let endDateD = endDate.getDate()
                 let endDateD = endDate.getDate()
 
 
                 let startDateStr = startDate.getFullYear() + '-' + (startDateM < 10 ? '0' + startDateM : startDateM) + '-' + (startDateD < 10 ? '0' + startDateD : startDateD)
                 let startDateStr = startDate.getFullYear() + '-' + (startDateM < 10 ? '0' + startDateM : startDateM) + '-' + (startDateD < 10 ? '0' + startDateD : startDateD)
                 let endDateStr = endDate.getFullYear() + '-' + (endDateM < 10 ? '0' + endDateM : endDateM) + '-' + (endDateD < 10 ? '0' + endDateD : endDateD)
                 let endDateStr = endDate.getFullYear() + '-' + (endDateM < 10 ? '0' + endDateM : endDateM) + '-' + (endDateD < 10 ? '0' + endDateD : endDateD)
 
 
+                this.form = []
                 if(enableNewWeeklyfill != 1) {
                 if(enableNewWeeklyfill != 1) {
                     this.dateText = [startDateStr,endDateStr]
                     this.dateText = [startDateStr,endDateStr]
-                }
-
-                this.form = []
-                // for(let i=0;i<this.weekIndex;i++){
-                for(let i=0;i<this.dateRange.length;i++){
-                    let formItem = {
-                            createDate: this.format(this.dateRange[i],"yyyy-MM-dd"),
-                            domains: [{
+                    for(let i=0;i<this.dateRange.length;i++){
+                        let formItem = {
+                                createDate: this.format(this.dateRange[i],"yyyy-MM-dd"),
+                                domains: [{
+                                    id: null,
+                                    projectId: "",
+                                    projectName: "",
+                                    workingTime: this.user.timeType.allday,
+                                    content: "",
+                                    progress: 100,
+                                    state: 2,
+                                    multiWorktime:0,
+                                    worktimeList:[{}],
+                                    degreeId: '',
+
+                                    auditorFirst: {name:'',id:''},
+                                    auditorSec: {name:'',id:''},
+                                    auditorThird: {name:'',id:''},
+                                    ccUserid: {name:'',id:''}
+                                }],
+                            }
+                        this.form.push(formItem)
+                    }
+                } else {
+                    //启用了新版按周填报,加载接口返回的日报数据
+                    for(let i=0;i<newWeeklyDataList.length;i++){
+                        let oneDayItem = newWeeklyDataList[i];
+                        console.log('111',oneDayItem.date);
+                        let formItem = {
+                            createDate: oneDayItem.date,
+                            // domains: [{
+                            //     id: null,
+                            //     projectId: "",
+                            //     projectName: "",
+                            //     workingTime: this.user.timeType.allday,
+                            //     content: "",
+                            //     progress: 100,
+                            //     state: 2,
+                            //     multiWorktime:0,
+                            //     worktimeList:[{}],
+                            //     degreeId: '',
+
+                            //     auditorFirst: {name:'',id:''},
+                            //     auditorSec: {name:'',id:''},
+                            //     auditorThird: {name:'',id:''},
+                            //     ccUserid: {name:'',id:''}
+                            // }],
+                        }
+                        //日报数据
+                        let reportList = oneDayItem.reportList;
+                        reportList.forEach(r=>r.projectName = serverPList.filter(s=>s.id==r.projectId)[0].projectName);
+                        if (reportList.length > 0) {
+                            formItem.domains = reportList;
+                        } else {
+                            formItem.domains = [{
                                 id: null,
                                 id: null,
                                 projectId: "",
                                 projectId: "",
                                 projectName: "",
                                 projectName: "",
@@ -805,15 +857,19 @@
                                 multiWorktime:0,
                                 multiWorktime:0,
                                 worktimeList:[{}],
                                 worktimeList:[{}],
                                 degreeId: '',
                                 degreeId: '',
-
                                 auditorFirst: {name:'',id:''},
                                 auditorFirst: {name:'',id:''},
                                 auditorSec: {name:'',id:''},
                                 auditorSec: {name:'',id:''},
                                 auditorThird: {name:'',id:''},
                                 auditorThird: {name:'',id:''},
                                 ccUserid: {name:'',id:''}
                                 ccUserid: {name:'',id:''}
-                            }],
+                            }]
                         }
                         }
-                    this.form.push(formItem)
+                        this.form.push(formItem)
+                    }
                 }
                 }
+
+                
+
+                
                 this.currentForm = this.form[0]
                 this.currentForm = this.form[0]
                 if(this.reportBasecostList.length != 0 && this.user.company.packageProject == 1){
                 if(this.reportBasecostList.length != 0 && this.user.company.packageProject == 1){
                     this.currentForm.domains[0].basecostId = this.reportBasecostList[0].id;
                     this.currentForm.domains[0].basecostId = this.reportBasecostList[0].id;
@@ -1176,10 +1232,8 @@
                 }
                 }
       
       
             },
             },
-            clickTimePicker(i) {
-                // if (!this.canEdit) {
-                //     return;
-                // }
+            clickTimePicker(i, item) {
+                if (item.state <=1) return
                 this.clickTimeIndex = i;
                 this.clickTimeIndex = i;
                 
                 
                 if (this.reportTimeType.type == 0) {
                 if (this.reportTimeType.type == 0) {
@@ -1423,7 +1477,8 @@
 
 
             //点击选择审核人
             //点击选择审核人
             clickPickAuditor(i, item) {
             clickPickAuditor(i, item) {
-                // if (!this.canEdit) return;
+                //不可待审核和已通过不可编辑
+                if (item.state<2) return;
                 if (item.auditUserList.length<=1) return;
                 if (item.auditUserList.length<=1) return;
                 this.clickIndex = i;
                 this.clickIndex = i;
                 item.showPickerAuditor = true;
                 item.showPickerAuditor = true;
@@ -1441,7 +1496,8 @@
 
 
             //点击选择子项目
             //点击选择子项目
             clickPickSubProject(i, item) {
             clickPickSubProject(i, item) {
-                // if (!this.canEdit) return;
+                //不可待审核和已通过不可编辑
+                if (item.state<2) return;
                 this.clickIndex = i;
                 this.clickIndex = i;
                 item.showPickerSubProject = true;
                 item.showPickerSubProject = true;
                 this.$forceUpdate();
                 this.$forceUpdate();
@@ -1452,7 +1508,8 @@
                 this.$forceUpdate();
                 this.$forceUpdate();
             },
             },
             clickPickStage(i, item) {
             clickPickStage(i, item) {
-                // if (!this.canEdit) return;
+                //不可待审核和已通过不可编辑
+                if (item.state<2) return;
                 this.clickIndex = i;
                 this.clickIndex = i;
                 item.showPickerStage = true;
                 item.showPickerStage = true;
                 this.$forceUpdate();
                 this.$forceUpdate();
@@ -1460,7 +1517,8 @@
 
 
             // 选择项目
             // 选择项目
             clickPicker(i, item) {
             clickPicker(i, item) {
-                // if (!this.canEdit) return;
+                //不可待审核和已通过不可编辑
+                if (item.state<2) return;
                 // this.clickIndex = i;
                 // this.clickIndex = i;
                 // this.showPickerProject = true;
                 // this.showPickerProject = true;
                 // console.log(i, item, this.currentForm)
                 // console.log(i, item, this.currentForm)