소스 검색

移动端按周填报加自定义维度的多选和单选

Lijy 1 년 전
부모
커밋
fd14087563

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2886 - 0
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/weekEdit-03.vue


+ 113 - 15
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/weekEdit.vue

@@ -168,9 +168,31 @@
 
 
                         <!-- 相关维度 -->
-                        <van-field :value="item.weiduName" v-if="item.projectId && user.timeType.customDegreeActive == 1"  readonly  name="id" clickable :label="user.timeType.customDegreeName" placeholder="请选择" @click="clickPickers(index)"/>
-                        <van-popup v-model="item.showPickDegree" position="bottom">
+                        <van-field :value="item.weiduName" v-if="item.projectId && user.timeType.customDegreeActive == 1" :disabled="item.state<=1"  readonly  name="id" clickable :label="user.timeType.customDegreeName" placeholder="请选择" @click="clickPickers(index, item)"/>
+                        <!-- <van-popup v-model="item.showPickDegree" position="bottom">
                             <van-picker show-toolbar :columns="item.wuduList" value-key="name" @confirm="choseProjects" @cancel="item.showPickDegree = false;$forceUpdate()" />
+                        </van-popup> -->
+
+                        <van-popup v-model="item.showPickDegree" position="bottom">
+                            <div class="chooseSomeone" v-if="item.showPickDegree">
+                                <div class="chooseSomeoneFlex1">
+                                    <!-- 复选 -->
+                                    <van-radio-group v-model="item.radioPickDegree" v-if="!user.timeType.customDegreeMultiple">
+                                        <van-radio v-for="uitem in item.wuduList" :key="uitem.id" :name="uitem.id" style="padding:10px">
+                                            {{ uitem.name ? uitem.name : '' }}
+                                        </van-radio>
+                                    </van-radio-group>
+                                    <!-- 多选 -->
+                                    <van-checkbox-group v-model="item.radioPickDegree" v-if="user.timeType.customDegreeMultiple">
+                                        <van-checkbox v-for="uitem in item.wuduList" :key="uitem.id" :name="uitem.id" style="padding:10px">
+                                            {{ uitem.name ? uitem.name : '' }}
+                                        </van-checkbox>
+                                    </van-checkbox-group>
+                                </div>
+                                <van-button @click="choseProjects(item.radioPickDegree, item.wuduList)">
+                                    确定
+                                </van-button>
+                            </div>
                         </van-popup>
 
                         <!-- 自定义数值 -->
@@ -901,6 +923,8 @@
                 }
                 this.getKaoqin()
                 this.getWorkTime()
+
+                this.getWeeklyReportData()
             },
             // 周日期按钮状态
             canSelect(item){
@@ -1571,8 +1595,10 @@
                 //     }
                 // });
             },
-            clickPickers(i) {
+            clickPickers(i, item) {
                 // if (!this.canEdit) return;
+                const { state } = item
+                if(state < 1) return
                 this.clickIndex = i;
                 this.currentForm.domains[this.clickIndex].showPickDegree = true;
                 var proId = this.currentForm.domains[this.clickIndex].projectId
@@ -1597,13 +1623,25 @@
                 this.$forceUpdate();
             },
 
-            choseProjects(value, index) {
-                // console.log(value)
+            choseProjects(value, arrList) {
+                console.log(value)
+                // return
+                const { timeType } = this.user
                 if(value){
-                    this.currentForm.domains[this.clickIndex].weiduName = value.name;
-                    this.currentForm.domains[this.clickIndex].degreeId = value.id;
+                    if(!timeType.customDegreeMultiple) { // 单选
+                        let list = arrList.filter(item => item.id == value)[0]
+                        this.currentForm.domains[this.clickIndex].weiduName = list.name;
+                        this.currentForm.domains[this.clickIndex].degreeId = list.id;
+                    }   
+                    if(timeType.customDegreeMultiple) { // 多选
+                        let list = arrList.filter(s => value.includes(+s.id))
+                        this.currentForm.domains[this.clickIndex].weiduName = list.map(item => item.name).join(',');
+                        this.currentForm.domains[this.clickIndex].degreeId = list.map(item => item.id).join(',');
+                    }
                 }
                 this.currentForm.domains[this.clickIndex].showPickDegree = false;
+
+                console.log(this.currentForm.domains[this.clickIndex], '再次')
                 this.$forceUpdate();
             },
 
@@ -1690,11 +1728,32 @@
                         }).catch(err=> {this.$toast.clear();});
             },
             // 获取维度
-            dimension(projectId) {
+            dimension(projectId, index, flag = false, customDegreeMultiple, newClickIndex) {
                 this.$axios.post("/project/getDegreeList", {projectId: projectId})
                 .then(res => {
                     if(res.code == "ok") {
+                        res.data.forEach(item => {
+                            item.id = +item.id
+                        })
+                        // if(flag) {
+                        //     this.clickIndex = newClickIndex
+                        // }
                         this.currentForm.domains[this.clickIndex].wuduList = res.data;
+                        // let degreeId = this.currentForm.domains[this.clickIndex].degreeId
+                        // for(let i in degreeId) {
+                        //     degreeId[i] = +degreeId[i]
+                        // }
+                        // if(flag) {
+                        //     if(!customDegreeMultiple) { // 单选
+                        //         this.currentForm.domains[this.clickIndex].radioPickDegree = res.data.filter(item => item.id == degreeId)[0]
+                        //         this.currentForm.domains[this.clickIndex].weiduName = res.data.filter(item => item.id == degreeId)[0].name
+                        //     } else {
+                        //         let arr = res.data.filter(s => degreeId.includes(+s.id)).map(s => s.name);
+                        //         this.currentForm.domains[this.clickIndex].weiduName = arr.join(',')
+                        //     }
+                        // }
+
+                        // console.log(this.currentForm.domains[this.clickIndex])
                         this.$forceUpdate();
                     } else {
                         this.$toast.fail('获取失败');
@@ -2036,10 +2095,18 @@
 
 
                         if (this.user.timeType.customDegreeActive == 1) {
+                            let customDegreeMultiple = this.user.timeType.customDegreeMultiple
                             if(this.form[formIndex].domains[i].degreeId) {
-                                formData.append("degreeId", this.form[formIndex].domains[i].degreeId);
+                                // formData.append("degreeId", this.form[formIndex].domains[i].degreeId);
+                                if(!customDegreeMultiple) { // 单选
+                                    formData.append("degreeId", this.form[formIndex].domains[i].degreeId);
+                                } else {
+                                    console.log(this.form[formIndex].domains[i].degreeId)
+                                    let newDegreeId = this.form[formIndex].domains[i].degreeId.split(',')
+                                    formData.append("multiDegrId", JSON.stringify(newDegreeId).replace(/,/g, '@'))
+                                }
                             } else {
-                                formData.append("degreeId", -1);
+                                formData.append("degreeId", !customDegreeMultiple ? -1 : "[]");
                             }
                         } else {
                             formData.append("degreeId", -1);
@@ -2497,7 +2564,7 @@
             // 处理按周填报回显数据
             handleWeeklyReportData(array) {
                 console.log(array, 'array')
-
+                const { timeType } = this.user
                 let objectItem = {
                     auditorFirst: {id: '', name: ''},
                     auditorSec: {id: '', name: ''},
@@ -2529,16 +2596,31 @@
                                 endTime, startTime, content, groupId, groupName,
                                 projectAuditorId, projectAuditorName, projectId,
                                 projectName, state, taskId, taskName, overtimeHours,
-                                stage, taskGroups, isOvertime, workingTime, subProjectId, progress
+                                stage, taskGroups, isOvertime, workingTime, subProjectId, progress,
+                                multiDegrId, degreeId, degreeList
                             } = arrayItem.reportList[j]
 
+                            let newMultiDegrId = []
+                            let newWeiduName = degreeList.filter(s => s.id == degreeId).map(s => s.name).join(',')
+                            if(timeType.customDegreeMultiple) {
+                                newMultiDegrId = multiDegrId ? JSON.parse(multiDegrId.replace(/@/g, ',')) : [] 
+                                newMultiDegrId = newMultiDegrId.map(item => {
+                                    return parseInt(item, 10);
+                                })
+
+                                newWeiduName = degreeList.filter(s => newMultiDegrId.includes(+s.id)).map(s => s.name).join(',');
+                            }
+
                             let newObj = {
                                 ...objectItem, id,
                                 endTime, startTime, content, groupId, groupName,
                                 projectAuditorId, projectAuditorName, projectId,
                                 projectName, state, taskId, taskName, overtimeHours,
                                 stage, taskGroups, workingTime, subProjectId, progress,
-                                isOvertime: isOvertime == 1 ? true : false
+                                isOvertime: isOvertime == 1 ? true : false,
+                                degreeId: !timeType.customDegreeMultiple ? degreeId : newMultiDegrId.join(','),
+                                radioPickDegree: !timeType.customDegreeMultiple ? degreeId : newMultiDegrId,
+                                wuduList: degreeList, weiduName: newWeiduName
                             }
                             list.push(newObj)
                         }
@@ -2557,13 +2639,17 @@
                     return
                 }
                 console.log(arrItem, '<=== 处理的数据')
+                const { timeType } = this.user
                 let newArrItem = JSON.parse(JSON.stringify(arrItem))
                 const { domains } = newArrItem
                 for(let i in domains) {
-                    const { projectId, projectName, stage, groupId, groupName } = domains[i]
+                    const { projectId, projectName, stage, groupId, groupName, degreeId } = domains[i]
                     if(projectId) {
                         this.fZr({ projectId, projectName }, 0, true, i)
-                    }
+                        // if(timeType.customDegreeActive == 1) {
+                        //     this.dimension(projectId, 0, true, timeType.customDegreeMultiple, i)
+                        // }
+                    }   
 
                     if(groupId) {
                         this.choseTaskGroup({ id: groupId, name: groupName }, 0, true, i)
@@ -2640,6 +2726,18 @@
 </script>
 
 <style lang="less" scope>
+.chooseSomeone {
+    height: 80vh;
+    display: flex;
+    flex-direction: column;
+    .chooseSomeoneFlex1 {
+        flex: 1;
+        overflow: auto;
+    }
+    .chooseSomeoneBtn {
+        width:100%;
+    }
+}
 .currentState {
     position: absolute;
     top: 15px;