public without sharing class taskManageController { // 初始方法,获取当前所有任务,包括当前用户和当前用户下属的任务 @AuraEnabled public static Task getCurrentTask(string myTaskName, string myTaskType, string myTaskStatus, string myAccountID, Date myStartDate, Date myEndDate, String myTaskDifferent, //2021-09-28 mzy 任务管理改善 start string subTaskName, string subTaskType, string subSFDCPosition, string subTaskStatus, string subAccountID, Date subStartDate, Date subEndDate,String subTaskDifferent) { ID myUserID = UserInfo.getUserId(); // 检索出来当前用户的任务 list myTasks = TasksBuild( new list {myUserID}, myTaskName, myTaskType, '' , myTaskStatus, myAccountID, myStartDate, myEndDate ,myTaskDifferent); //2021-09-28 mzy 任务管理改善 start // 下属的ID set list subUserIDlist = new list(); // 检索当前用户是经理、部长、总监等等的下属 for (user tempUser : [select id from user where managerid = : myUserID or JingliApprovalManager__c = : myUserID or SalesManager__c = : myUserID or JingliEquipmentManager__c = : myUserID or BuchangApprovalManagerSales__c = : myUserID or BuchangApprovalManager__c = : myUserID or Buzhang_Equipment_Manager__c = : myUserID or ZongjianApprovalManager__c = : myUserID or TongkuoZongjian__c = : myUserID ]) { subUserIDlist.add(tempUser.id); } // 检索出来下属用户的任务 list subTasks = TasksBuild( subUserIDlist, subTaskName, subTaskType, subSFDCPosition, subTaskStatus, subAccountID, subStartDate, subEndDate ,subTaskDifferent); //2021-09-28 mzy 任务管理改善 start Task allTask = new Task(myTasks, subTasks ); return allTask; } // 确认或者延期 @AuraEnabled public static string confirmOrDelay(boolean isDelay, string delayReason, string delayReasonOther, string taskID,Boolean IsGeneratePlan,Date ActivityDate,Date feedbackPlanDate) { //2021-07-30 mzy SWAG-C5DAX8 update start UserResult u = UserInfo_Owner(); //2021-07-30 mzy SWAG-C5DAX8 update end try { Task__c tempTask = new Task__c(); tempTask.id = taskID; tempTask.isDelay__c = isDelay; tempTask.delayReason__c = delayReason; tempTask.delayReasonOther__c = delayReasonOther; //2021-07-30 mzy SWAG-C5DAX8 update start if(u.Job_Category!=null&&u.Job_Category.equals('销售服务')){ tempTask.delayReasonSelectFSE__c = delayReason; }else { tempTask.delayReasonSelect__c = delayReason; } //2021-07-30 mzy SWAG-C5DAX8 update end //2021-10-20 mzy 任务管理改善 start if(IsGeneratePlan == false){ //不生成计划 tempTask.taskStatus__c = '02 接受'; tempTask.GeneratePlan__c = IsGeneratePlan; tempTask.ConfirmDate__c = Date.today(); tempTask.Activity_Date__c = ActivityDate; tempTask.feedbackPlanDate__c = feedbackPlanDate; } //2021-10-20 mzy 任务管理改善 end update tempTask; //成功返回更新成功 return 'Success'; } catch (exception e) { //否则返回错误信息 return e.getMessage(); } } //合并任务 @AuraEnabled public static string mergeTask(List taskIdList) { try { List taskList = [select id,mergeTaskMain__c,CreateDate__c,Name,account__c,assignee__c,Assignment_Date__c,taskType__c,RelatedInformation_Text__c from task__c where id in :taskIdList]; Task__c mainTask = new task__c(); List opdList = [select id,mergeTaskMain__c,CreateDate__c,Name,account__c,assignee__c,Assignment_Date__c,taskType__c,RelatedInformation_Text__c from task__c where id in :taskIdList and taskType__c = 'OPD' order by createdDate desc]; Boolean manyOpd = false; if(opdList == null || opdList.size() == 0){ mainTask = [select id,mergeTaskMain__c,CreateDate__c,Name,account__c,assignee__c,Assignment_Date__c,taskType__c,RelatedInformation_Text__c from task__c where id in :taskIdList order by createdDate desc limit 1]; }else if(opdList.size() == 1){ mainTask = opdList.get(0); }else{ manyOpd = true; mainTask = opdList.get(0); } List subTaskList = [select id,mergeTaskMain__c,CreateDate__c,Name,account__c,assignee__c,Assignment_Date__c,taskType__c,RelatedInformation_Text__c from task__c where mergeTaskMain__c in :taskIdList ]; List updateList = new List(); List deleteList = new List(); Boolean isSame = false; for(Task__c tsk : taskList){ if(tsk.id != mainTask.id ){ // if(tsk.CreateDate__c != null && tsk.CreateDate__c != mainTask.CreateDate__c && tsk.taskType__c == mainTask.taskType__c &&tsk.Name == mainTask.Name && tsk.RelatedInformation_Text__c == mainTask.RelatedInformation_Text__c ){ // deleteList.add(tsk); // isSame = true; // }else if( tsk.assignee__c == mainTask.assignee__c && tsk.account__c == mainTask.account__c && tsk.taskType__c != mainTask.taskType__c){ // if(isSame){ // return '相同类型的任务合并时,请勿勾选不同类型的任务!'; // } // if(manyOpd){ // return '不同类型的任务合并时,最多可包含一个OPD任务!'; // } // tsk.mergeTaskMain__c = mainTask.Id; // updateList.add(tsk); // }else{ // //return tsk.Name + ' 与 ' + mainTask.Name + ' 不符合合并条件!请选择派发时间不同,任务名称、类型、相关信息相同的任务进行合并,或者选择派发时间和客户相同,其余信息不同的任务进行合并!'; // return '相同客户才可进行任务合并'; // } //只上线相同类型任务合并 if(tsk.CreateDate__c != null && tsk.CreateDate__c != mainTask.CreateDate__c && tsk.taskType__c == mainTask.taskType__c &&tsk.Name == mainTask.Name && tsk.RelatedInformation_Text__c == mainTask.RelatedInformation_Text__c ){ deleteList.add(tsk); }else{ return '相同类型的任务才可进行任务合并(任务名称、类型、相关信息相同)'; } } } if(subTaskList != null && subTaskList.size() > 0){ for(Task__c subTask : subTaskList){ subTask.mergeTaskMain__c = mainTask.Id; } update subTaskList; } if(updateList != null && updateList.size() > 0){ update updateList; } if(deleteList != null && deleteList.size() > 0){ delete deleteList; } return 'Success'; } catch (exception e) { //否则返回错误信息 return e.getMessage(); } } //2021-10-28 yjk 根据任务id获取询价id @AuraEnabled public static string checkEnquiryController(String taskId) { try { List tskList = [select id, OpportunityId__c from task__c where id = :taskId]; if(tskList.size() != 1){ return 'error'; } if(tskList.get(0).OpportunityId__c == null ){ return 'no'; } return tskList.get(0).OpportunityId__c; } catch (exception e) { //否则返回错误信息 return 'error'; } } //重新分配任务 @AuraEnabled public static UserResult resetAssignee(string assigneeID, string taskID) { UserResult result = new UserResult(); Savepoint sp = Database.setSavepoint(); try { Task__c tempTask = new Task__c(); tempTask.id = taskID; tempTask.assignee__c = assigneeID; tempTask.ownerid = assigneeID; tempTask.Assignment_Date__c = Date.today(); update tempTask; //2021-11-12 yjk 任务分配时,子任务也一起分配给用户 start List childTasks = [select id,assignee__c,ownerid,Assignment_Date__c from task__c where mergeTaskMain__c = :taskID]; if(null != childTasks && childTasks.size() > 0 ){ for(Task__c tsk : childTasks){ tsk.assignee__c = assigneeID; tsk.ownerid = assigneeID; tsk.Assignment_Date__c = Date.today(); } } update childTasks; //2021-11-12 yjk 任务分配时,子任务也一起分配给用户 end User tempUser = [select id, alias from user where id = : assigneeID ]; result.assigneeID = assigneeID; result.assigneeName = tempUser.alias; } catch (exception e) { Database.rollback(sp); result.result = e.getMessage(); } return result; } //20210105 CHAN-BWX3YU you start //重新分配任务 @AuraEnabled public static UserResult resetAssignee_Owner(string assigneeID, string taskID) { UserResult result = new UserResult(); Savepoint sp = Database.setSavepoint(); try { // Task__Share tasksha = new Task__Share(UserOrGroupId=assigneeID, AccessLevel='Edit', ParentId = taskID,RowCause = 'Manual'); //insert tasksha; system.debug('==taskID==='+taskID+'==assigneeID=='+assigneeID); Task__c tempTask = new Task__c(); tempTask.id = taskID; tempTask.assignee__c = assigneeID; tempTask.ownerid = assigneeID; tempTask.Assignment_Date__c = Date.today(); update tempTask; //2021-11-12 yjk 任务分配时,子任务也一起分配给用户 start List childTasks = [select id,assignee__c,ownerid,Assignment_Date__c from task__c where mergeTaskMain__c = :taskID]; if(null != childTasks && childTasks.size() > 0 ){ for(Task__c tsk : childTasks){ tsk.assignee__c = assigneeID; tsk.ownerid = assigneeID; tsk.Assignment_Date__c = Date.today(); } } update childTasks; //2021-11-12 yjk 任务分配时,子任务也一起分配给用户 end User tempUser = [select id, alias from user where id = : assigneeID ]; result.assigneeID = assigneeID; result.assigneeName = tempUser.alias; } catch (exception e) { Database.rollback(sp); result.result = e.getMessage(); } return result; } //获取当前登录人的 省份 和 职种 @AuraEnabled public static UserResult UserInfo_Owner() { UserResult result = new UserResult(); ID myUserID = UserInfo.getUserId(); try { User tempUser = [select id,Province__c,Job_Category__c from user where id = : myUserID ]; result.Job_Category = tempUser.Job_Category__c; result.ProvinceName = tempUser.Province__c; } catch (exception e) { result.result = e.getMessage(); } return result; } //20210105 CHAN-BWX3YU you end // 获取当前用户的任务 @AuraEnabled public static Task getMyTask(string myTaskName, string myTaskType, string myTaskStatus, string myAccountID, Date myStartDate, Date myEndDate, //2021-09-28 mzy 任务管理改善 start String myTaskDifferent //2021-09-28 mzy 任务管理改善 end ) { ID myUserID = UserInfo.getUserId(); //2021-09-28 mzy 任务管理改善 update start list myTasks = TasksBuild( new list {myUserID}, myTaskName, myTaskType, '' , myTaskStatus, myAccountID, myStartDate, myEndDate, myTaskDifferent ); //2021-09-28 mzy 任务管理改善 update end Task allTask = new Task(myTasks, null ); return allTask; } //获取当前用户下属的任务 @AuraEnabled public static Task getSubTask(string subTaskName, string subTaskType, string subSFDCPosition , string subTaskStatus, string subAccountID, Date subStartDate, Date subEndDate , //2021-09-28 mzy 任务管理改善 start String subTaskDifferent //2021-09-28 mzy 任务管理改善 end ) { ID myUserID = UserInfo.getUserId(); list subUserIDlist = new list(); for (user tempUser : [select id from user where managerid = : myUserID or JingliApprovalManager__c = : myUserID or SalesManager__c = : myUserID or JingliEquipmentManager__c = : myUserID or BuchangApprovalManagerSales__c = : myUserID or BuchangApprovalManager__c = : myUserID or Buzhang_Equipment_Manager__c = : myUserID or ZongjianApprovalManager__c = : myUserID or TongkuoZongjian__c = : myUserID ]) { subUserIDlist.add(tempUser.id); } //system.debug('subUserIDlist:'+subUserIDlist); //2021-09-28 mzy 任务管理改善 update start list subTasks = TasksBuild( subUserIDlist, subTaskName, subTaskType, subSFDCPosition, subTaskStatus, subAccountID, subStartDate, subEndDate , subTaskDifferent ); //2021-09-28 mzy 任务管理改善 update end Task allTask = new Task(null, subTasks ); return allTask; } // 取消任务 @AuraEnabled public static string cancel(string taskID, string cancelReason, string cancelReasonOther) { //2021-07-30 mzy SWAG-C5DAX8 update start UserResult u = UserInfo_Owner(); //2021-07-30 mzy SWAG-C5DAX8 update end System.debug('取消理由值:'+cancelReason); try { Task__c tempTask = new Task__c(); tempTask.id = taskID; tempTask.cancelReason__c = cancelReason; //2021-11-17 mzy 任务管理改善 if('客户时间变更或冲突'.equals(cancelReason)){ cancelReason = '客户事件变更或冲突'; } //2021-11-17 mzy 任务管理改善 tempTask.cancelReasonOther__c = cancelReasonOther; tempTask.taskStatus__c = '04 取消'; tempTask.cancelDate__c = date.today(); //2021-07-30 mzy SWAG-C5DAX8 update start if(u.Job_Category!=null&&u.Job_Category.equals('销售服务')){ tempTask.cancelReasonSelectFSE__c = cancelReason; }else { tempTask.cancelReasonSelect__c = cancelReason; } //2021-07-30 mzy SWAG-C5DAX8 update end update tempTask; return 'Success'; } catch (exception e) { return e.getMessage(); } } // 构建任务集合 public static list TasksBuild( list userIDList, string TaskName, string taskType, string SFDCPosition , string TaskStatus, string AccountID, Date startDate, Date endDate,String TaskDifferent) {// 2021-09-28 mzy 任务管理改善 start list myTasks = new list(); //2021-11-11 mzy 任务管理改善 start UserResult u = UserInfo_Owner(); //2021-11-11 mzy 任务管理改善 end // 拼出来任务检索条件 String query = 'select id, name, account__c, account__r.name,' + 'CreateDate__c,assignee__c , assignee__r.alias, ' + //2021-03-29 WLIG-BZK59N mzy start 'RelatedInformation_ID__c,RelatedInformation_Text__c,'+ //2021-03-29 WLIG-BZK59N mzy end //2021-09-28 mzy 任务管理改善 start 'TaskDifferent__c,'+ 'completeCondition__c ,distributeReason__c,' + //2021-11-17 yjk 增加完成条件,派发原因 //2021-09-28 mzy 任务管理改善 end //2021-11-11 mzy 任务管理改善 start 'cancelReasonSelect__c,cancelReasonSelectFSE__c,'+ 'delayReasonSelect__c,delayReasonSelectFSE__c,RecordTypeId,'+ //2021-11-11 mzy 任务管理改善 end //2021-11-25 mzy 任务管理改善 start 'HopeCompletionDate__c,'+ //2021-11-25 mzy 任务管理改善 end 'taskStatus__c,taskType__c,Assignment_Date__c from task__c where assignee__c =: userIDList and mergeTaskMain__c = null ' + //2021-1-4 yjk 增加任务区分,只查询被动和上级分配 //' and TaskDifferent__c != \'主动任务\' '; ''; //任务名称 if (string.isNotBlank(TaskName)) { query += ' and Name like \'%' + String.escapeSingleQuotes(TaskName.trim()) + '%\''; } //任务类型 if (string.isNotBlank(taskType)) { query += ' and taskType__c = \'' + String.escapeSingleQuotes(taskType) + '\''; } // SFDC职种 if (string.isNotBlank(SFDCPosition)) { query += ' and assignee__r.SFDCPosition_C__c = \'' + String.escapeSingleQuotes(SFDCPosition) + '\''; } // 所属客户 if (string.isNotBlank(AccountID)) { query += ' and account__c = \'' + String.escapeSingleQuotes(AccountID) + '\''; } //任务状态 if (string.isNotBlank(TaskStatus)) { query += ' and taskStatus__c = \'' + String.escapeSingleQuotes(TaskStatus) + '\''; } //创建日期的起始日期 if (startDate != null) { query += ' and CreateDate__c >= ' + startDate.format().replace('/', '-') ; } //创建日期的结束日期 if (endDate != null) { query += ' and CreateDate__c <= ' + endDate.format().replace('/', '-') ; } //2021-09-28 mzy 任务管理改善 start //任务区分 if(string.isNotBlank(TaskDifferent)){ query += ' and TaskDifferent__c =\''+ String.escapeSingleQuotes(TaskDifferent) +'\''; }else { query += ' and TaskDifferent__c != \'主动任务\' '; } //2021-09-28 mzy 任务管理改善 end //2021-04-19 mzy WLIG-C25DW4 任务一览表显示逻辑 任务管理表请按客户、任务类型和相关信息排序。 start query += ' order by TaskDifferent__c desc,account__c ,taskType__c,RelatedInformation_ID__c'; //2021-04-19 mzy WLIG-C25DW4 任务一览表显示逻辑 任务管理表请按客户、任务类型和相关信息排序。 end // 检索成功后构建任务wrapper for ( Task__c tempTask : Database.query(query) ) { TaskWrapper tempTaskWrapper = new TaskWrapper(); tempTaskWrapper.Id = tempTask.id; tempTaskWrapper.taskId = '/' + tempTask.id; //2021-11-25 mzy 任务管理改善 start //任务名称只显示 名称不显示客户名 if(String.isNotBlank(tempTask.Name)){ String tempTaskName = tempTask.Name; if(tempTaskName.contains(':')){ tempTaskWrapper.taskName = tempTaskName.split(':')[0]; //}else if(tempTaskName.contains('(')){ // tempTaskWrapper.taskName = tempTaskName.split('(')[0]; }else { tempTaskWrapper.taskName = tempTaskName; } } //tempTaskWrapper.taskName = tempTask.Name; //2021-11-25 mzy 任务管理改善 end tempTaskWrapper.taskAccountID = null == tempTask.account__c ? '' : '/' + tempTask.account__c; tempTaskWrapper.taskAccountName = tempTask.account__r.name; tempTaskWrapper.taskType = tempTask.taskType__c; tempTaskWrapper.taskStatus = tempTask.taskStatus__c; tempTaskWrapper.taskCreateddate = tempTask.CreateDate__c; tempTaskWrapper.taskAssigneeName = tempTask.assignee__r.alias; tempTaskWrapper.taskAssigneeUrl = '/' + tempTask.assignee__c; tempTaskWrapper.taskAssigneeID = tempTask.assignee__c; //2021-09-28 mzy 任务管理改善 start tempTaskWrapper.taskDifferent = tempTask.TaskDifferent__c; //2021-09-28 mzy 任务管理改善 end tempTaskWrapper.completeCondition = tempTask.completeCondition__c;//2021-11-17 yjk 完成条件 tempTaskWrapper.distributeReason = tempTask.distributeReason__c; //2021-11-11 mzy 任务管理改善 start //根据任务类型显示不同的理由 tempTaskWrapper.tempTask = tempTask; tempTaskWrapper.isFSE = ('销售服务'.equals(u.Job_Category) ? true :false); //2021-11-11 mzy 任务管理改善 end //2021-11-25 mzy 任务管理改善 start tempTaskWrapper.HopeCompletionDate = tempTask.HopeCompletionDate__c; //2021-11-25 mzy 任务管理改善 end //2021-03-29 WLIG-BZK59N mzy start if(tempTask.RelatedInformation_Text__c != null && tempTask.RelatedInformation_ID__c != null){ //多年保 和 询价 tempTaskWrapper.taskRelatedInformation = tempTask.RelatedInformation_Text__c; tempTaskWrapper.taskRelatedInformationID = '/'+tempTask.RelatedInformation_ID__c; }else if(tempTask.RelatedInformation_Text__c != null&&String.isBlank(String.valueOf(tempTask.RelatedInformation_ID__c))==true){ //OPD任务 || 是其他 tempTaskWrapper.taskRelatedInformation = tempTask.RelatedInformation_Text__c; tempTaskWrapper.taskRelatedInformationID = '/apex/taskManage?id='+String.ValueOf(UserInfo.getUserId()).substring(0,15)+'#'; } //tempTaskWrapper.taskRelatedInformation = tempTask.RelatedInformation_Text__c; //tempTaskWrapper.taskRelatedInformationID = tempTask.RelatedInformation_ID__c==null?'/':'/'+tempTask.RelatedInformation_ID__c; //2021-03-29 WLIG-BZK59N mzy end tempTaskWrapper.cancelButtonisDisabled = false; tempTaskWrapper.confirmButtonisDisabled = false; tempTaskWrapper.delayButtonisDisabled = false; tempTaskWrapper.assignButtonisDisabled = false; //20210111 CHAN-BWX3YU you start tempTaskWrapper.assignButtonisDisabled_Owner = false; Date d2 = date.today().addDays(-2); Date createdate1= date.newinstance(tempTask.CreateDate__c.year(), tempTask.CreateDate__c.month(), tempTask.CreateDate__c.day()); system.debug('分配时间'+tempTask.Assignment_Date__c+'==d2=='+d2); //20210111 CHAN-BWX3YU you end if (tempTask.taskStatus__c != null && !tempTask.taskStatus__c.equals('01 分配')) { tempTaskWrapper.cancelButtonisDisabled = true; tempTaskWrapper.confirmButtonisDisabled = true; tempTaskWrapper.delayButtonisDisabled = true; tempTaskWrapper.assignButtonisDisabled = true; //20210105 CHAN-BWX3YU you start tempTaskWrapper.assignButtonisDisabled_Owner = true; //20210105 CHAN-BWX3YU you end } //20210618 SWAG-C434H9 zh start // if((tempTask.Assignment_Date__c!= null && tempTask.Assignment_Date__c >=d2) || (tempTask.Assignment_Date__c== null && createdate1>=d2 )){ if(tempTask.Assignment_Date__c!= null && tempTask.Assignment_Date__c >=d2){ //20210618 SWAG-C434H9 zh end //20210113 CHAN-BWX3YU you start tempTaskWrapper.assignButtonisDisabled_Owner = true; tempTaskWrapper.assignButtonisDisabled = true; //20210113 CHAN-BWX3YU you end } //2021-10-08 mzy 任务管理改善 start //上级分配的任务只允许 接受 ,不允许 延期/取消 if(tempTask.TaskDifferent__c != null && tempTask.TaskDifferent__c.equals('上级分配任务')){ tempTaskWrapper.cancelButtonisDisabled = true; tempTaskWrapper.delayButtonisDisabled = true; tempTaskWrapper.assignButtonisDisabled_Owner = true; } //2021-10-08 mzy 任务管理改善 end myTasks.add(tempTaskWrapper); } return myTasks; } // 获取各种选项列表的选项值 @AuraEnabled public static map> getpickerField() { map> pickerFields = new map>(); // 任务类型选项值获取 list taskTypeOptions = new list(); Map taskTypeNameMap = Schema.SObjectType.Task__c.getRecordTypeInfosByName(); set taskTypeNameSet = taskTypeNameMap.keySet(); for (string tempStr : taskTypeNameSet) { if (!tempStr.equals('主类型')) { pickerWrapper temppickerWrapper = new pickerWrapper(tempStr, tempStr); taskTypeOptions.add(temppickerWrapper); } } pickerWrapper pickerWrapper = new pickerWrapper('所有', ''); taskTypeOptions.add(pickerWrapper); pickerFields.put('taskTypeOptions', taskTypeOptions); // 任务状态选项值获取 list taskStatusOptions = new list(); Schema.DescribeFieldResult taskStatusfieldResult = Task__c.taskStatus__c.getDescribe(); List taskStatusple = taskStatusfieldResult.getPicklistValues(); for ( Schema.PicklistEntry pickListVal : taskStatusple) { pickerWrapper temppickerWrapper = new pickerWrapper(pickListVal.getLabel(), pickListVal.getValue()); taskStatusOptions.add(temppickerWrapper); } pickerFields.put('taskStatusOptions', taskStatusOptions); // 2021-09-28 mzy 任务管理改善 start // 任务区分选项值获取 list taskDifferentOptions = new list(); Schema.DescribeFieldResult taskDifferentfieldResult = Task__c.taskDifferent__c.getDescribe(); List taskDifferentple = taskDifferentfieldResult.getPicklistValues(); for ( Schema.PicklistEntry pickListVal : taskDifferentple) { pickerWrapper temppickerWrapper = new pickerWrapper(pickListVal.getLabel(), pickListVal.getValue()); taskDifferentOptions.add(temppickerWrapper); } pickerWrapper taskDifferentWrapper = new pickerWrapper('所有', ''); taskDifferentOptions.add(taskDifferentWrapper); pickerFields.put('taskDifferentOptions', taskDifferentOptions); // 2021-09-28 mzy 任务管理改善 end // SFDC 职种选项值获取 list SFDCPositionOptions = new list(); Schema.DescribeFieldResult SFDCPositionfieldResult = user.SFDCPosition_C__c.getDescribe(); List SFDCPositionple = SFDCPositionfieldResult.getPicklistValues(); for ( Schema.PicklistEntry pickListVal : SFDCPositionple) { pickerWrapper temppickerWrapper = new pickerWrapper(pickListVal.getLabel(), pickListVal.getValue()); SFDCPositionOptions.add(temppickerWrapper); } pickerFields.put('SFDCPositionOptions', SFDCPositionOptions); // 当前用户职种获取 User curentUser = [select id , Job_Category__c from User where id = : UserInfo.getUserId()]; // 取消理由选项值获取 list cancelReasonOptions = new list(); Schema.DescribeFieldResult cancelReasonfieldResult; if (curentUser.Job_Category__c != null && curentUser.Job_Category__c.equals('销售服务')) { cancelReasonfieldResult = Task__c.cancelReasonSelectFSE__c.getDescribe(); } else { cancelReasonfieldResult = Task__c.cancelReasonSelect__c.getDescribe(); } List cancelReasonple = cancelReasonfieldResult.getPicklistValues(); for ( Schema.PicklistEntry pickListVal : cancelReasonple) { pickerWrapper temppickerWrapper = new pickerWrapper(pickListVal.getLabel(), pickListVal.getValue()); cancelReasonOptions.add(temppickerWrapper); } pickerFields.put('cancelReasonOptions', cancelReasonOptions); // 延期理由选项值获取 list delayReasonOptions = new list(); Schema.DescribeFieldResult delayReasonfieldResult; if (curentUser.Job_Category__c != null && curentUser.Job_Category__c.equals('销售服务')) { delayReasonfieldResult = Task__c.delayReasonSelectFSE__c.getDescribe(); } else { delayReasonfieldResult = Task__c.delayReasonSelect__c.getDescribe(); } List delayReasonple = delayReasonfieldResult.getPicklistValues(); for ( Schema.PicklistEntry pickListVal : delayReasonple) { pickerWrapper temppickerWrapper = new pickerWrapper(pickListVal.getLabel(), pickListVal.getValue()); delayReasonOptions.add(temppickerWrapper); } pickerFields.put('delayReasonOptions', delayReasonOptions); return pickerFields; } public class Task { @AuraEnabled public list myTasks; @AuraEnabled public list subTasks; public Task(list myTasks, list subTasks) { this.myTasks = myTasks; this.subTasks = subTasks; } } public class TaskWrapper { @AuraEnabled public String id; @AuraEnabled public String taskId; @AuraEnabled public String taskName; @AuraEnabled public String taskAccountID; @AuraEnabled public String taskAccountName; @AuraEnabled public String taskAssigneeID; @AuraEnabled public String taskAssigneeUrl; @AuraEnabled public String taskAssigneeName; @AuraEnabled public String taskType; @AuraEnabled public String taskStatus; @AuraEnabled public Date taskCreateddate; @AuraEnabled public Boolean cancelButtonisDisabled; @AuraEnabled public Boolean confirmButtonisDisabled; @AuraEnabled public Boolean delayButtonisDisabled; @AuraEnabled public Boolean assignButtonisDisabled; //20210104 CHAN-BWX3YU you @AuraEnabled public Boolean assignButtonisDisabled_Owner; //2021-03-29 WLIG-BZK59N mzy @AuraEnabled public String taskRelatedInformation; @AuraEnabled public String taskRelatedInformationID; //2021-09-28 任务管理改善 mzy @AuraEnabled public String taskDifferent; //2021-11-11 任务管理改善 mzy @AuraEnabled public Task__c tempTask; @AuraEnabled public Boolean isFSE; @AuraEnabled public String completeCondition; @AuraEnabled public String distributeReason; //2021-11-25 任务管理改善 mzy @AuraEnabled public Date HopeCompletionDate; //2021-11-25 任务管理改善 mzy } public class pickerWrapper { @AuraEnabled public string label; @AuraEnabled public string value; public pickerWrapper(string label, string value) { this.label = label; this.value = value; } } public class UserResult { @AuraEnabled public string assigneeName; @AuraEnabled public string assigneeID; @AuraEnabled public string result; public UserResult( ) { result = 'Success'; } //20210105 CHAN-BWX3YU you start @AuraEnabled public string Job_Category; @AuraEnabled public string ProvinceName; //20210105 CHAN-BWX3YU you end } }