浏览代码

提交移动端的可选部门

Lijy 1 年之前
父节点
当前提交
809d64a6fd
共有 1 个文件被更改,包括 63 次插入2 次删除
  1. 63 2
      fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue

+ 63 - 2
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue

@@ -69,8 +69,14 @@
                         type="default"><span style="color:#666;padding: 0 5px;">删除</span></van-tag>
                 </div>
                 <!-- <van-icon v-if="index>0&&canEdit" class="form_del" name="delete" @click="delPro(index)" /> -->
-
                 <van-cell-group :title="(user.companyId == 781 ? '任务' : '项目') + (index + 1)">
+                    <van-field readonly name="userReportDeptName" v-if="user.timeType.userWithMultiDept == 1 && userReportDeptList.length > 0"
+                        :value="item.userReportDeptName" :label="'填报部门'" placeholder="请选择部门" @click="selectDeptPopup(index, item)">
+                        <template #input>
+                            <TranslationOpenDataText type='departmentName' :openid='item.userReportDeptName'></TranslationOpenDataText>
+                        </template>
+                    </van-field>
+
                     <!-- <div>请选择投入项目</div> -->
                     <van-field readonly name="projectId" clickable :value="item.projectName"
                         :label="user.companyId == 781 ? '工作任务' : '投入项目'"
@@ -536,6 +542,19 @@
                 </div>
             </div>
         </van-popup>
+
+        <van-popup v-model="showSelectDeptPopup" position="bottom" style="height: 84%">
+            <div class="popupDiv">
+                <div class="popupCon">
+                    <div v-for="(item, index) in userReportDeptList" :key="item.value" class="popupItem paddingDiv"
+                        @click="selectedDeptId(item, index)">
+                        <p class="popupItemOne">
+                            <TranslationOpenDataText type='departmentName' :openid='item.departmentName'></TranslationOpenDataText>
+                        </p>
+                    </div>
+                </div>
+            </div>
+        </van-popup>
     </div>
 </template>
 <script>
@@ -649,6 +668,9 @@ export default {
                 name: '',
                 id: ''
             }, //  代填人员信息
+
+            userReportDeptList: [], // 可选部门
+            showSelectDeptPopup: false
         };
     },
 
@@ -1639,6 +1661,8 @@ export default {
                                     sapServiceId: list[i].sapServiceId,
                                     sapServiceName: list[i].sapServiceName,
                                     serviceList: list[i].serviceList,
+                                    userReportDeptName: list[i].userReportDeptName,
+                                    reportTargetDeptId: list[i].deptId
                                 })
                                 if (list[i].state >= 2) {
                                     this.canEdit = true;
@@ -1767,7 +1791,18 @@ export default {
             item.showPickerStage = true;
             this.$forceUpdate();
         },
-
+        selectDeptPopup(i, item) {
+            this.clickIndex = i;
+            this.showSelectDeptPopup = true;
+            this.$forceUpdate();
+        },
+        selectedDeptId(item) {
+            const { label, value } = item
+            this.form.domains[this.clickIndex].userReportDeptName = label
+            this.form.domains[this.clickIndex].reportTargetDeptId = value
+            this.showSelectDeptPopup = false;
+            this.$forceUpdate();
+        },
         // 选择项目
         clickPicker(i, item) {
             if (!item.canEdit) return;
@@ -2503,6 +2538,10 @@ export default {
                     this.$toast.fail("请选择[" + this.form.domains[i].projectName + "]项目的任务分组");
                     return;
                 }
+
+                if(this.user.timeType.userWithMultiDept == 1) {
+                    formData.append('reportTargetDeptId', this.form.domains[i].reportTargetDeptId || '');
+                }
             }
             if (!this.flgLg) {
                 return
@@ -2594,6 +2633,24 @@ export default {
                 }
             });
         },
+        // 获取可选部门
+        getReportDeptList() {
+            this.$axios.post("/user/getUserInfo", {userId: this.user.id})
+            .then(res => {
+                if(res.code == "ok") {
+                    let lists = res.data.userReportDeptList || []
+                    const optimizedList = lists.map(item => ({
+                        ...item,
+                        label: item.departmentName,
+                        value: item.departmentId,
+                    }));
+                    this.userReportDeptList = optimizedList
+                    console.log(this.userReportDeptList, '<==== 返回的数据')
+                } else {
+                    this.$toast.fail('获取失败:'+res.msg);
+                }
+            }).catch(err=> {this.$toast.clear();});
+        }
     },
 
     mounted() {
@@ -2649,6 +2706,10 @@ export default {
             this.getJobResponList();
         }
 
+        if(this.user.timeType.userWithMultiDept) {
+            this.getReportDeptList()
+        }
+
         // if(localStorage.getItem("formVal")) {
         //     var obj = localStorage.getItem("formVal")
         //     this.form = JSON.parse(obj)