部门选择

master
Harry Yang 2022-12-27 14:14:05 +08:00
parent c73239604d
commit 82d31b4029
6 changed files with 213 additions and 411 deletions

View File

@ -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";
}

View File

@ -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;

View File

@ -42,8 +42,13 @@ public class ProcessCreationForm {
private String[] applyDept;
// 申请部门领导
// 申请部门ID
private Integer applyDeptId;
// 申请部门领导ID
private Integer applyDeptLeaderId;
// 申请部门领导
private String applyDeptLeaderName;
// 申请人电话

View File

@ -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<DeptReturnValue> children;
public void addChildren(DeptReturnValue child) {
if (children == null) {
children = new ArrayList<>();
}
children.add(child);
}
}
public List<DeptReturnValue> filterDept() {
List<Dept> deptList = deptRepository.findEnable();
List<Dept> level1 = filterByLevel(deptList, 1);
List<Dept> level2 = filterByLevel(deptList, 2);
List<Dept> level3 = filterByLevel(deptList, 3);
List<DeptReturnValue> 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<Dept> filterByLevel(List<Dept> deptList, int level) {
ArrayList<Dept> 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);
}

View File

@ -90,8 +90,9 @@
<div>
<el-form-item label="申请部门" :rules="[{ required: true, message: '申请部门电话不能为空'}]" prop="applyDept">
<el-cascader :options="applySectorOptions" clearable v-model="processForm.applyDept"></el-cascader>
<el-form-item label="申请部门" :rules="[{ required: true, message: '申请部门不能为空'}]" prop="applyDept">
<el-cascader :options="applyDeptSectorOptions" clearable v-model="processForm.applyDept"
:props="{ expandTrigger: 'hover', label:'name', value: 'id'}"></el-cascader>
</el-form-item>
<el-form-item label="申请人">
@ -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}')
},
})

View File

@ -52,13 +52,17 @@
.el-input-number i {
line-height: unset;
}
[v-cloak] {
display: none;
}
</style>
<div class="admin-content" id="app">
<div class="admin-content-body">
<div class="am-cf am-padding">
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">业务应用</strong> /
<small>{{subTitle}}</small></div>
<small v-cloak>{{subTitle}}</small></div>
</div>
<div class="am-g">
@ -90,7 +94,7 @@
<#-- 新增销售合同流程 -->
<div class="am-u-sm-12 am-u-md-12" v-if="isSalesContractMode || isProcurementContractMode">
<div class="am-u-sm-12 am-u-md-12" v-cloak v-if="isSalesContractMode || isProcurementContractMode">
<el-form :inline="true" ref="saleContractProcessForm" :model="processForm" label-position="right" label-width="110px">
<div class="am-form-inline">
@ -138,8 +142,9 @@
<div>
<el-form-item label="申请部门" :rules="[{ required: true, message: '申请部门电话不能为空'}]" prop="applyDept">
<el-cascader :options="applySectorOptions" clearable v-model="processForm.applyDept"></el-cascader>
<el-form-item label="申请部门" :rules="[{ required: true, message: '申请部门不能为空'}]" prop="applyDept">
<el-cascader :options="applyDeptSectorOptions" clearable
:props="{ expandTrigger: 'click', label:'name', value: 'id'}" @change="applyDeptSelected"></el-cascader>
</el-form-item>
<el-form-item label="申请人">
@ -350,7 +355,7 @@
style="float: right;margin-top: 10px;"></el-button>
</div>
<el-row class="am-u-sm-12 am-u-md-12">
<el-row class="am-u-sm-12 am-u-md-12" v-cloak>
<el-button type="info" @click="goToHome">返回上一级</el-button>
<el-button type="primary" @click="saveDraft">保存草稿</el-button>
<el-button type="success" @click="submitForm">提交</el-button>
@ -360,7 +365,7 @@
<#-- 销售合同清单明细 -->
<div class="am-u-sm-12 am-u-md-12" v-if="isSaleContractDetailMode">
<div v-cloak class="am-u-sm-12 am-u-md-12" v-if="isSaleContractDetailMode">
<el-table border :data="incomeDetails">
<el-table-column type="index" :index="1" label="序号" fixed></el-table-column>
<el-table-column prop="name" label="名称" fixed width="120"></el-table-column>
@ -395,7 +400,7 @@
<#-- 选择 业务采购清单明细 -->
<div class="am-u-sm-12 am-u-md-12" v-if="isProcurementContractDetailMode">
<div v-cloak class="am-u-sm-12 am-u-md-12" v-if="isProcurementContractDetailMode">
<el-table style="width: 100%" border>
<el-table-column prop="fee" label="费用项目" width="180"></el-table-column>
@ -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}')
},
})