diff --git a/src/main/java/cn/palmte/work/controller/backend/ProcessController.java b/src/main/java/cn/palmte/work/controller/backend/ProcessController.java index 4fa18fb..75d69df 100644 --- a/src/main/java/cn/palmte/work/controller/backend/ProcessController.java +++ b/src/main/java/cn/palmte/work/controller/backend/ProcessController.java @@ -123,6 +123,7 @@ public class ProcessController { model.addAttribute("sealTypes", SealType.values()); model.addAttribute("procurementMode", ProcurementMode.values()); model.addAttribute("taxRate", Arrays.asList(0, 1, 3, 4, 5, 6, 9, 10, 13)); + model.addAttribute("applyDeptSectorOptions", JSON.toJSONString(processService.filterDept())); return "/admin/business/process-new"; } @@ -131,10 +132,11 @@ public class ProcessController { */ @GetMapping("/edit/{id}") public String editProcess(Model model, @PathVariable int id) { + model.addAttribute("processId", id); model.addAttribute("sealTypes", SealType.values()); model.addAttribute("procurementMode", ProcurementMode.values()); model.addAttribute("taxRate", Arrays.asList(0, 1, 3, 4, 5, 6, 9, 10, 13)); - model.addAttribute("processId", id); + model.addAttribute("applyDeptSectorOptions", JSON.toJSONString(processService.filterDept())); return "/admin/business/process-edit"; } diff --git a/src/main/java/cn/palmte/work/model/process/ProjectProcess.java b/src/main/java/cn/palmte/work/model/process/ProjectProcess.java index 0b07e1f..853e1b7 100644 --- a/src/main/java/cn/palmte/work/model/process/ProjectProcess.java +++ b/src/main/java/cn/palmte/work/model/process/ProjectProcess.java @@ -60,9 +60,15 @@ public class ProjectProcess implements Serializable { // 申请人 ID private Integer applyPersonId; - // 申请部门 + // 申请部门 部门1,部门2,部门3 private String applyDept; + // 申请部门ID + private Integer applyDeptId; + + // 申请部门领导ID + private Integer applyDeptLeaderId; + // 申请部门领导 private String applyDeptLeaderName; diff --git a/src/main/java/cn/palmte/work/model/process/form/ProcessCreationForm.java b/src/main/java/cn/palmte/work/model/process/form/ProcessCreationForm.java index 9c371b3..cab7600 100644 --- a/src/main/java/cn/palmte/work/model/process/form/ProcessCreationForm.java +++ b/src/main/java/cn/palmte/work/model/process/form/ProcessCreationForm.java @@ -42,8 +42,13 @@ public class ProcessCreationForm { private String[] applyDept; - // 申请部门领导 + // 申请部门ID + private Integer applyDeptId; + // 申请部门领导ID + private Integer applyDeptLeaderId; + + // 申请部门领导 private String applyDeptLeaderName; // 申请人电话 diff --git a/src/main/java/cn/palmte/work/service/ProjectProcessService.java b/src/main/java/cn/palmte/work/service/ProjectProcessService.java index c0be917..411573b 100644 --- a/src/main/java/cn/palmte/work/service/ProjectProcessService.java +++ b/src/main/java/cn/palmte/work/service/ProjectProcessService.java @@ -8,9 +8,11 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import javax.persistence.EntityManager; @@ -18,6 +20,9 @@ import javax.persistence.TypedQuery; import cn.palmte.work.config.activiti.ActProjectTypeEnum; import cn.palmte.work.model.Admin; +import cn.palmte.work.model.AdminRepository; +import cn.palmte.work.model.Dept; +import cn.palmte.work.model.DeptRepository; import cn.palmte.work.model.Project; import cn.palmte.work.model.ProjectRepository; import cn.palmte.work.model.enums.ProcessStatus; @@ -25,6 +30,7 @@ import cn.palmte.work.model.process.ProcurementContract; import cn.palmte.work.model.process.ProjectProcess; import cn.palmte.work.model.process.SaleContract; import cn.palmte.work.model.process.form.SaleContractDetailForm; +import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -41,6 +47,78 @@ public class ProjectProcessService { private final ProjectInstanceService projectInstanceService; private final ProjectRepository projectRepository; + private final DeptRepository deptRepository; + private final AdminRepository userRepository; + + @Data + static class DeptReturnValue { + + private int id; + private int leaderId; + + private String leaderName; + + private String name; + + private List children; + + public void addChildren(DeptReturnValue child) { + if (children == null) { + children = new ArrayList<>(); + } + children.add(child); + } + } + + public List filterDept() { + List deptList = deptRepository.findEnable(); + List level1 = filterByLevel(deptList, 1); + List level2 = filterByLevel(deptList, 2); + List level3 = filterByLevel(deptList, 3); + + List returnValues = new ArrayList<>(); + for (Dept dept : level1) { + DeptReturnValue returnValue = createReturnValue(dept); + for (Dept dept2 : level2) { + + if (Objects.equals(dept2.getParentId(), dept.getId())) { + DeptReturnValue returnValue2 = createReturnValue(dept2); + returnValue.addChildren(returnValue2); + + for (Dept dept3 : level3) { + if (Objects.equals(dept3.getParentId(), dept2.getId())) { + returnValue2.addChildren(createReturnValue(dept3)); + } + } + } + } + returnValues.add(returnValue); + } + return returnValues; + } + + private static List filterByLevel(List deptList, int level) { + ArrayList ret = new ArrayList<>(); + for (Dept dept : deptList) { + if (Objects.equals(dept.getLevel(), level)) { + ret.add(dept); + } + } + return ret; + } + + private DeptReturnValue createReturnValue(Dept dept) { + DeptReturnValue returnValue = new DeptReturnValue(); + + returnValue.setId(dept.getId()); + returnValue.setName(dept.getName()); + returnValue.setLeaderId(dept.getManagerId()); + + Admin user = userRepository.getAdminById(dept.getManagerId()); + returnValue.setLeaderName(user.getRealName()); + return returnValue; + } + /** * 更新流程 审批人,和状态 * @@ -153,6 +231,8 @@ public class ProjectProcessService { variables.put("projectType", project.getType()); // 合作类型 variables.put("cooperationType", project.getCooperateType() == null ? 0 : project.getCooperateType()); + // 部门领导ID + variables.put("deptLeaderId", entity.getApplyDeptLeaderId()); startAuditProgress(entity, variables); } diff --git a/src/main/resources/templates/admin/business/process-edit.ftl b/src/main/resources/templates/admin/business/process-edit.ftl index eef0adc..0a5e003 100644 --- a/src/main/resources/templates/admin/business/process-edit.ftl +++ b/src/main/resources/templates/admin/business/process-edit.ftl @@ -90,8 +90,9 @@
- - + + @@ -359,205 +360,7 @@ }, processType: '', projectSelected: false, - applySectorOptions: [ - { - value: 'zhinan', - label: '指南', - children: [{ - value: 'shejiyuanze', - label: '设计原则', - children: [{ - value: 'yizhi', - label: '一致' - }, { - value: 'fankui', - label: '反馈' - }, { - value: 'xiaolv', - label: '效率' - }, { - value: 'kekong', - label: '可控' - }] - }, { - value: 'daohang', - label: '导航', - children: [{ - value: 'cexiangdaohang', - label: '侧向导航' - }, { - value: 'dingbudaohang', - label: '顶部导航' - }] - }] - }, - { - value: 'zujian', - label: '组件', - children: [{ - value: 'basic', - label: 'Basic', - children: [{ - value: 'layout', - label: 'Layout 布局' - }, { - value: 'color', - label: 'Color 色彩' - }, { - value: 'typography', - label: 'Typography 字体' - }, { - value: 'icon', - label: 'Icon 图标' - }, { - value: 'button', - label: 'Button 按钮' - }] - }, { - value: 'form', - label: 'Form', - children: [{ - value: 'radio', - label: 'Radio 单选框' - }, { - value: 'checkbox', - label: 'Checkbox 多选框' - }, { - value: 'input', - label: 'Input 输入框' - }, { - value: 'input-number', - label: 'InputNumber 计数器' - }, { - value: 'select', - label: 'Select 选择器' - }, { - value: 'cascader', - label: 'Cascader 级联选择器' - }, { - value: 'switch', - label: 'Switch 开关' - }, { - value: 'slider', - label: 'Slider 滑块' - }, { - value: 'time-picker', - label: 'TimePicker 时间选择器' - }, { - value: 'date-picker', - label: 'DatePicker 日期选择器' - }, { - value: 'datetime-picker', - label: 'DateTimePicker 日期时间选择器' - }, { - value: 'upload', - label: 'Upload 上传' - }, { - value: 'rate', - label: 'Rate 评分' - }, { - value: 'form', - label: 'Form 表单' - }] - }, { - value: 'data', - label: 'Data', - children: [{ - value: 'table', - label: 'Table 表格' - }, { - value: 'tag', - label: 'Tag 标签' - }, { - value: 'progress', - label: 'Progress 进度条' - }, { - value: 'tree', - label: 'Tree 树形控件' - }, { - value: 'pagination', - label: 'Pagination 分页' - }, { - value: 'badge', - label: 'Badge 标记' - }] - }, { - value: 'notice', - label: 'Notice', - children: [{ - value: 'alert', - label: 'Alert 警告' - }, { - value: 'loading', - label: 'Loading 加载' - }, { - value: 'message', - label: 'Message 消息提示' - }, { - value: 'message-box', - label: 'MessageBox 弹框' - }, { - value: 'notification', - label: 'Notification 通知' - }] - }, { - value: 'navigation', - label: 'Navigation', - children: [{ - value: 'menu', - label: 'NavMenu 导航菜单' - }, { - value: 'tabs', - label: 'Tabs 标签页' - }, { - value: 'breadcrumb', - label: 'Breadcrumb 面包屑' - }, { - value: 'dropdown', - label: 'Dropdown 下拉菜单' - }, { - value: 'steps', - label: 'Steps 步骤条' - }] - }, { - value: 'others', - label: 'Others', - children: [{ - value: 'dialog', - label: 'Dialog 对话框' - }, { - value: 'tooltip', - label: 'Tooltip 文字提示' - }, { - value: 'popover', - label: 'Popover 弹出框' - }, { - value: 'card', - label: 'Card 卡片' - }, { - value: 'carousel', - label: 'Carousel 走马灯' - }, { - value: 'collapse', - label: 'Collapse 折叠面板' - }] - }] - }, - { - value: 'ziyuan', - label: '资源', - children: [{ - value: 'axure', - label: 'Axure Components' - }, { - value: 'sketch', - label: 'Sketch Templates' - }, { - value: 'jiaohu', - label: '组件交互文档' - }] - } - ], + applyDeptSectorOptions: [], fileList: [], // 销售合同收入明细 incomeDetails: [], @@ -672,6 +475,47 @@ this.$message.error("未上传附件"); return false } + + const processType = this.processType + const processForm = this.processForm + if (processType === 'procurement_contract') { + const { procurementMode } = processForm + + // specify_purchase("指定采购"), + // simple_price_comparison("简单比价"), + // price_comparison("比价"), + // competitive_evaluation("竞争性评估"); + // 当“采购模式”为“指定采购”“简单比价”时,本模块为非必填模块,当为“比价”“竞争性评估”时,本模块为必填项(“备注”除外) + if (procurementMode === 'price_comparison' + || procurementMode === 'competitive_evaluation') { + + for (const item in this.supplierMaterialsForm) { + for (const [key, value] of Object.entries(item)) { + if (value) { + if (typeof value === 'string') { + if (isBlank(value)) { + this.$message.error("有未填写的表单,请检查表单"); + return false + } + } + } + else { + // 没有值 + if (key !== 'remark') { + this.$message.error("有未填写的表单,请检查表单"); + } + } + } + + } + } + } + + if (!processForm.applyDeptLeaderId) { + this.$message.error("申请部门还未选择"); + return false + } + const loading = this.$loading({ lock: true, text: '正在提交', @@ -753,7 +597,12 @@ indexMethod(index) { return index * 1; - } + }, + + applyDeptSelected(value) { + console.log(value) + }, + } new Vue({ @@ -798,6 +647,7 @@ mounted() { const processId = ${processId} this.loadProject(processId) + this.applyDeptSectorOptions = JSON.parse('${applyDeptSectorOptions}') }, }) diff --git a/src/main/resources/templates/admin/business/process-new.ftl b/src/main/resources/templates/admin/business/process-new.ftl index 16218a2..8187ecb 100644 --- a/src/main/resources/templates/admin/business/process-new.ftl +++ b/src/main/resources/templates/admin/business/process-new.ftl @@ -52,13 +52,17 @@ .el-input-number i { line-height: unset; } + + [v-cloak] { + display: none; + }
业务应用 / - {{subTitle}}
+ {{subTitle}}
@@ -90,7 +94,7 @@ <#-- 新增销售合同流程 --> -
+
@@ -138,8 +142,9 @@
- - + + @@ -350,7 +355,7 @@ style="float: right;margin-top: 10px;">
- + 返回上一级 保存草稿 提交 @@ -360,7 +365,7 @@ <#-- 销售合同清单明细 --> -
+
@@ -395,7 +400,7 @@ <#-- 选择 业务采购清单明细 --> -
+
@@ -468,205 +473,7 @@ }, supplierMaterialsForm: [], projectSelected: false, - applySectorOptions: [ - { - value: 'zhinan', - label: '指南', - children: [{ - value: 'shejiyuanze', - label: '设计原则', - children: [{ - value: 'yizhi', - label: '一致' - }, { - value: 'fankui', - label: '反馈' - }, { - value: 'xiaolv', - label: '效率' - }, { - value: 'kekong', - label: '可控' - }] - }, { - value: 'daohang', - label: '导航', - children: [{ - value: 'cexiangdaohang', - label: '侧向导航' - }, { - value: 'dingbudaohang', - label: '顶部导航' - }] - }] - }, - { - value: 'zujian', - label: '组件', - children: [{ - value: 'basic', - label: 'Basic', - children: [{ - value: 'layout', - label: 'Layout 布局' - }, { - value: 'color', - label: 'Color 色彩' - }, { - value: 'typography', - label: 'Typography 字体' - }, { - value: 'icon', - label: 'Icon 图标' - }, { - value: 'button', - label: 'Button 按钮' - }] - }, { - value: 'form', - label: 'Form', - children: [{ - value: 'radio', - label: 'Radio 单选框' - }, { - value: 'checkbox', - label: 'Checkbox 多选框' - }, { - value: 'input', - label: 'Input 输入框' - }, { - value: 'input-number', - label: 'InputNumber 计数器' - }, { - value: 'select', - label: 'Select 选择器' - }, { - value: 'cascader', - label: 'Cascader 级联选择器' - }, { - value: 'switch', - label: 'Switch 开关' - }, { - value: 'slider', - label: 'Slider 滑块' - }, { - value: 'time-picker', - label: 'TimePicker 时间选择器' - }, { - value: 'date-picker', - label: 'DatePicker 日期选择器' - }, { - value: 'datetime-picker', - label: 'DateTimePicker 日期时间选择器' - }, { - value: 'upload', - label: 'Upload 上传' - }, { - value: 'rate', - label: 'Rate 评分' - }, { - value: 'form', - label: 'Form 表单' - }] - }, { - value: 'data', - label: 'Data', - children: [{ - value: 'table', - label: 'Table 表格' - }, { - value: 'tag', - label: 'Tag 标签' - }, { - value: 'progress', - label: 'Progress 进度条' - }, { - value: 'tree', - label: 'Tree 树形控件' - }, { - value: 'pagination', - label: 'Pagination 分页' - }, { - value: 'badge', - label: 'Badge 标记' - }] - }, { - value: 'notice', - label: 'Notice', - children: [{ - value: 'alert', - label: 'Alert 警告' - }, { - value: 'loading', - label: 'Loading 加载' - }, { - value: 'message', - label: 'Message 消息提示' - }, { - value: 'message-box', - label: 'MessageBox 弹框' - }, { - value: 'notification', - label: 'Notification 通知' - }] - }, { - value: 'navigation', - label: 'Navigation', - children: [{ - value: 'menu', - label: 'NavMenu 导航菜单' - }, { - value: 'tabs', - label: 'Tabs 标签页' - }, { - value: 'breadcrumb', - label: 'Breadcrumb 面包屑' - }, { - value: 'dropdown', - label: 'Dropdown 下拉菜单' - }, { - value: 'steps', - label: 'Steps 步骤条' - }] - }, { - value: 'others', - label: 'Others', - children: [{ - value: 'dialog', - label: 'Dialog 对话框' - }, { - value: 'tooltip', - label: 'Tooltip 文字提示' - }, { - value: 'popover', - label: 'Popover 弹出框' - }, { - value: 'card', - label: 'Card 卡片' - }, { - value: 'carousel', - label: 'Carousel 走马灯' - }, { - value: 'collapse', - label: 'Collapse 折叠面板' - }] - }] - }, - { - value: 'ziyuan', - label: '资源', - children: [{ - value: 'axure', - label: 'Axure Components' - }, { - value: 'sketch', - label: 'Sketch Templates' - }, { - value: 'jiaohu', - label: '组件交互文档' - }] - } - ], + applyDeptSectorOptions: [], fileList: [], // 销售合同收入明细 incomeDetails: [], @@ -833,6 +640,12 @@ } } + if (!processForm.applyDeptLeaderId) { + this.$message.error("申请部门还未选择"); + return false + } + + // 提交 const loading = this.$loading({ lock: true, text: '正在提交', @@ -915,6 +728,51 @@ this.supplierMaterialsForm.push({}) }, + applyDeptSelected(value) { + console.log(value) + const sectorOptions = this.applyDeptSectorOptions + const level1Value = value[0] + const level2Value = value.length >= 2 && value[1] + const level3Value = value.length === 3 && value[2] + let opt; + + const find = (options, value) => { + for (let option in options) { + if (option.id === value) { + return option + } + } + } + + const leveled = [] + for (let options in sectorOptions) { + let op = find(options, level1Value) + leveled.push(op) + if (op && level2Value) { + op = find(op.children, level1Value) + leveled.push(op) + if (op && level3Value) { + op = find(op.children, level1Value) + leveled.push(op) + if (op) { + opt = op + } + } + else { + opt = op + } + } + else { + opt = op + } + } + + this.processForm['applyDept'] = 2 + this.processForm['applyDeptId'] = opt.id + this.processForm['applyDeptLeaderId'] = opt.leaderId + this.processForm['applyDeptLeaderName'] = opt.leaderName + }, + } new Vue({ @@ -962,6 +820,7 @@ mounted() { // this.newProcurementContractClick(); this.handleSelectProject({ id: 135, name: '' }) + this.applyDeptSectorOptions = JSON.parse('${applyDeptSectorOptions}') }, })