Browse Source

提交工时管家移动端的项目服务,查看全部任务的权限

Lijy 1 year ago
parent
commit
47950eca62

+ 3 - 0
fhKeeper/formulahousekeeper/timesheet/src/permissions.js

@@ -18,6 +18,7 @@ const StringUtil = {
         projectPhase: false, // 项目阶段管理 // 
         projectCodeAndName: false, // 编辑负责项目编码和名称 //
         projectEditDefaultFolder: false, // 修改默认文件夹 //
+        projectViewAllTasks: false, // 查看全部任务 //
 
         // 合同管理
         contractNew: false, // 新增合同 // 
@@ -241,6 +242,8 @@ const StringUtil = {
         arr[i] == '负责项目子项目工时成本' ? obj.reportResponsibleManhourCost = true : ''
         arr[i] == '修改默认文件夹' ? obj.projectEditDefaultFolder = true : ''
         arr[i] == '费用发放' ? obj.costExpenseRelease = true : ''
+        
+        arr[i] == '查看全部任务' ? obj.projectViewAllTasks = true : ''
     }
     return obj
   }

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/task/list.vue

@@ -87,7 +87,7 @@
         <div style="display: flex;width: 100%;">
             <div class="classification">
                 <div>
-                    <p :class="idx == 0 ? 'on' : ''" @click="switchs(0)" v-if="permissions.projectView || permissions.projectManagement">{{ $t('alltaskss') }}</p>
+                    <p :class="idx == 0 ? 'on' : ''" @click="switchs(0)" v-if="permissions.projectView || permissions.projectManagement || permissions.projectViewAllTasks">{{ $t('alltaskss') }}</p>
                     <p :class="idx == 1 ? 'on' : ''" @click="switchs(1)">{{ $t('perform') }}</p>
                     <p :class="idx == 2 ? 'on' : ''" @click="switchs(2)">{{ $t('created') }}</p>
                 </div>

+ 141 - 19
fhKeeper/formulahousekeeper/timesheet_h5/src/views/task/editask.vue

@@ -113,20 +113,40 @@
                         </template>
                     </van-field>
                     <van-icon v-if="index != 0 && canEdit" class="delete_executor" name="delete-o" @click.stop="deleteExecutor(index)" />
+
+                    <van-cell-group v-if="user.companyId == '3092'">
+                        <van-cell title="项目服务" :value="`${item.serviceName || ''} - ${item.serviceCode || ''}`" is-link @click="searchServiceCli(item,index)">
+                            <template #right-icon>
+                                <div class="iconBox">
+                                    <!-- <van-icon name="close" size="18" class="iconRight" /> -->
+                                    <!-- <van-icon name="arrow" size="18" class="iconRight" /> -->
+                                </div>
+                            </template>
+                        </van-cell>
+                    </van-cell-group>
                 </div>
 
+                <!-- 选择项目服务 -->
+                <van-popup v-model="select_sapServiceList_show" position="bottom" style="height: 90%">
+                    <div class="popupDiv">
+                        <div class="popupSearch">
+                            <van-search v-model.trim="sapServiceVal" placeholder="搜索" @search="onSearchService" @clear="onSearchService" shape="round" background="#F4F4F4"></van-search>
+                        </div>
+                        <div class="popupCon conBorder">
+                            <van-radio-group v-model="sapServiceChange" class="popupItem marginNone borderNone">
+                                <van-radio v-for="uitem in sapServiceList" :key="uitem.id" :name="uitem" style="padding:10px">
+                                    <span class="userNameClass_left">{{ uitem.serviceName }}</span>
+                                    <span class="userNameClass_right">{{ uitem.serviceCode }}</span>
+                                </van-radio>
+                            </van-radio-group>
+                        </div>
+                        <div class="popupBtn">
+                            <van-button style="width:100%;background: #1989fa;color: #ffffff;position: -webkit-sticky;position: sticky;bottom: 0;" round @click="searchExecutorBtn()">确定</van-button>
+                        </div>
+                    </div>
+                </van-popup>
+
                 <van-popup v-model="executor.show" position="bottom" v-if="canEdit" style="height: 90%">
-                    <!-- <van-search v-model="executor.searchText" placeholder="输入员工姓名搜索" @input="onSearch"></van-search>
-                    <div style="minHeight:300px;">
-                        <van-radio-group v-model="executor.item">
-                            <van-radio v-for="uitem in executor.searchList" :key="uitem.id" :name="uitem" style="padding:10px">
-                                <span v-if="user.userNameNeedTranslate != 1">{{uitem.name}}</span>
-                                <span v-else><ww-open-data type='userName' :openid='uitem.name'></ww-open-data></span>
-                                <span class="xinmingghao">{{uitem.jobNumber}}</span>
-                            </van-radio>
-                        </van-radio-group>
-                    <van-button style="width:100%;position: -webkit-sticky;position: sticky;bottom: 0;" @click="searchExecutor()">确定</van-button>
-                    </div> -->
                     <div class="popupDiv">
                         <div class="popupSearch" v-if="user.userNameNeedTranslate != '1'">
                             <van-search v-model="executor.searchText" placeholder="输入员工姓名搜索" @search="onSearch" shape="round" background="#F4F4F4"></van-search>
@@ -180,6 +200,8 @@
 </template>
 
 <script>
+import { S } from 'core-js/modules/_export'
+
 export default {
     data() {
         return {
@@ -239,7 +261,13 @@ export default {
             select_list_array: [],
             select_project_show_searchText: '',
 
-            integrationProjectList: []
+            integrationProjectList: [],
+
+            sapServiceList:[], // 项目服务
+            sapServiceListCoper:[], // 项目服务
+            select_sapServiceList_show: false,
+            sapServiceVal: '',
+            sapServiceChange: {}
         }
     },
     mounted() {
@@ -270,6 +298,11 @@ export default {
             }
         }
         this.getUsersList()
+
+        const { companyId } = this.user
+        if(companyId == 3092) {
+            this.getSapServiceList()
+        }
         console.log('mounted',this.taskId,null);
     },
     methods: {
@@ -456,20 +489,57 @@ export default {
             this.taskLevel.show = false
         },
 
+        executorProjectJudgment(arr) {
+            let arrList = JSON.parse(JSON.stringify(arr))
+            // 将填写的数据以执行人id相同处理成二维数据
+            const result = Object.values(arrList.reduce((acc, obj) => {
+            const { executorId } = obj;
+                if (!acc[executorId]) {
+                    acc[executorId] = [];
+                }
+                acc[executorId].push(obj);
+                return acc;
+            }, {}));
+            console.log(result, '<== 去重后的数据')
+            // 更具二维数据去判断项目服务是否相同
+            for(var i in result) {
+                const item = result[i]
+                if(item.length > 1) {
+                    let size=new Set(item.map(item=>item.serviceId)).size
+                   if(size != item.length) {
+                        return false
+                   } 
+                }
+            }
+
+            return true
+        },
+
         submitTask(){
             console.log('submitTask');
+            const { companyId } = this.user
             if(!this.taskform.name.replace(/^\s*|\s*$/g,"")){
                 return
             }
             
             // 执行人查重
-            let arr = this.taskform.executorList
-            let json={};
-            for(let i in arr){
-                if(!json[arr[i].executorId]){
-                    json[arr[i].executorId]=1;
-                }else{
-                    this.$toast.fail("执行人存在重复");
+            if(companyId != '3092') {
+                let arr = this.taskform.executorList
+                let json={};
+                for(let i in arr){
+                    if(!json[arr[i].executorId]){
+                        json[arr[i].executorId]=1;
+                    }else{
+                        this.$toast.fail("执行人存在重复");
+                        return
+                    }
+                }
+            }
+
+            // 针对依斯倍排除执行人相同和项目服务相同的任务
+            if(companyId == '3092') {
+                if(!this.executorProjectJudgment(this.taskform.executorList)) {
+                    this.$toast.fail("同一个项目服务执行人相同");
                     return
                 }
             }
@@ -495,6 +565,7 @@ export default {
             delete this.taskform.subTaskList;
             delete this.taskform.refTaskList;
             delete this.taskform.progress;
+
             this.submitTaskBtn = true
             // return
             this.$axios.post("/task/save", this.taskform)
@@ -575,6 +646,49 @@ export default {
                     this.$toast.fail('获取失败');
                 }
             }).catch(err=> {this.$toast.clear();console.log(err)});
+        },
+        getSapServiceList() {
+            this.$axios.post("/sap-project-service/sapServiceList", {})
+            .then(res => {
+                if(res.code == "ok") {
+                    this.sapServiceList = res.data
+                    this.sapServiceListCoper = JSON.parse(JSON.stringify(res.data))
+                } else {
+                    this.$toast.fail('获取失败');
+                }
+            }).catch(err=> {this.$toast.clear();console.log(err)});
+        },
+        onSearchService() {
+            if(!this.sapServiceVal) {
+                this.sapServiceList = JSON.parse(JSON.stringify(this.sapServiceListCoper))
+                return
+            }
+            let arr = JSON.parse(JSON.stringify(this.sapServiceListCoper.filter(item => item.serviceName.indexOf(this.sapServiceVal) != -1 || item.serviceCode.indexOf(this.sapServiceVal) != -1)))
+            this.sapServiceList = arr
+        },
+        searchExecutorBtn() {
+            console.log(this.sapServiceChange)
+            const { serviceName, serviceCode, id } = this.sapServiceChange
+            this.taskform.executorList[this.executor.index].serviceId = id
+            this.taskform.executorList[this.executor.index].serviceName = `${serviceName}`
+            this.taskform.executorList[this.executor.index].serviceCode = `${serviceCode}`
+            this.select_sapServiceList_show = false
+            console.log(this.taskform.executorList)
+        },
+        searchServiceCli(item,index) {
+            const { companyId } = this.user
+            this.executor.index = index
+            this.sapServiceListCoper.forEach(u=>{if (u.id == item.serviceId) {
+                console.log(u)
+                this.sapServiceChange = {
+                    serviceName: u.serviceName,
+                    serviceCode: u.serviceCode,
+                    id: u.id,
+                    companyId
+                }
+            }})
+            console.log(this.sapServiceChange, item)
+            this.select_sapServiceList_show = true
         }
     },
 }
@@ -606,6 +720,14 @@ export default {
     display: inline-block;
     float: right;
 }
+
+.iconBox {
+    position: relative;
+    top: 2px;
+}
+.iconRight {
+    margin-left: 10px;
+}
 .ewProjectlist {
     padding: 10px 10px 10px 20px;
     border-bottom: 1px solid #666;

+ 6 - 3
fhKeeper/formulahousekeeper/timesheet_h5/src/views/task/index.vue

@@ -64,7 +64,7 @@
                             <span v-else></span>
                         </div>
                         <div class="task_button">
-                            <van-button size="small" type="info" @click="toEditask(item.id)">编辑</van-button>
+                            <van-button size="small" type="info" @click="toEditask(item.id)" v-if="authorityEditing">编辑</van-button>
                             <van-button size="small" type="primary" @click="taskStatus(item.id,0)" v-if="select_state == '进行中'">完成</van-button>
                             <van-button size="small" color="#e6a23c" @click="taskStatus(item.id,1)" v-else>重启</van-button>
 
@@ -109,18 +109,21 @@ export default {
             downLoading: false,     // 下拉刷新
             listReLoading: false,   // 是否重新加载列表数据
 
-
+            authorityEditing: false, // 编辑项目内任务权限
 
         }
     },
     mounted() {
         for(let i in this.user.functionList){
-            if(this.user.functionList[i].name == '查看全部项目'){
+            if(this.user.functionList[i].name == '查看全部项目' || this.user.functionList[i].name == '查看全部任务'){
                 this.viewAlltask = true
             }
             if(this.user.functionList[i].name == '管理全部项目'){
                 this.viewAlltask = true
             }
+            if(this.user.functionList[i].name == '编辑项目内任务') {
+                this.authorityEditing = true
+            }
         }
         this.getList()
     },