完成 bpm oa 请假的 create 和 detail 前端

This commit is contained in:
YunaiV 2022-01-22 21:49:50 +08:00
parent 991ce2105b
commit 54e7c10a06
10 changed files with 95 additions and 187 deletions

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa; package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveCreateReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert; import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert;
@ -39,7 +39,7 @@ public class BpmOALeaveController {
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("创建请求申请") @ApiOperation("创建请求申请")
public CommonResult<Long> createLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) { public CommonResult<Long> createLeave(@Valid @RequestBody BpmOALeaveCreateReqVO createReqVO) {
return success(leaveService.createLeave(getLoginUserId(), createReqVO)); return success(leaveService.createLeave(getLoginUserId(), createReqVO));
} }

View File

@ -14,5 +14,5 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class OALeaveCreateReqVO extends BpmOALeaveBaseVO { public class BpmOALeaveCreateReqVO extends BpmOALeaveBaseVO {
} }

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.oa; package cn.iocoder.yudao.adminserver.modules.bpm.convert.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveCreateReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -19,7 +19,7 @@ public interface OALeaveConvert {
OALeaveConvert INSTANCE = Mappers.getMapper(OALeaveConvert.class); OALeaveConvert INSTANCE = Mappers.getMapper(OALeaveConvert.class);
OALeaveDO convert(OALeaveCreateReqVO bean); OALeaveDO convert(BpmOALeaveCreateReqVO bean);
OALeaveRespVO convert(OALeaveDO bean); OALeaveRespVO convert(OALeaveDO bean);

View File

@ -6,8 +6,6 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/** /**
* 请假申请 Service 接口 * 请假申请 Service 接口
@ -24,7 +22,7 @@ public interface BpmOALeaveService {
* @param createReqVO 创建信息 * @param createReqVO 创建信息
* @return 编号 * @return 编号
*/ */
Long createLeave(Long userId, @Valid OALeaveCreateReqVO createReqVO); Long createLeave(Long userId, @Valid BpmOALeaveCreateReqVO createReqVO);
/** /**
* 删除请假申请 * 删除请假申请

View File

@ -44,7 +44,7 @@ public class OALeaveServiceImpl implements BpmOALeaveService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createLeave(Long userId, OALeaveCreateReqVO createReqVO) { public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) {
// TODO 芋道源码 // TODO 芋道源码
// 校验是否超过请假天数的上限 // 校验是否超过请假天数的上限
long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false); long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false);

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 创建请假申请 // 创建请假申请
export function createLeave(data) { export function createLeave(data) {
return request({ return request({
url: '/oa/leave/create', url: '/bpm/oa/leave/create',
method: 'post', method: 'post',
data: data data: data
}) })
@ -20,7 +20,7 @@ export function deleteLeave(id) {
// 获得请假申请 // 获得请假申请
export function getLeave(id) { export function getLeave(id) {
return request({ return request({
url: '/oa/leave/get?id=' + id, url: '/bpm/oa/leave/get?id=' + id,
method: 'get' method: 'get'
}) })
} }
@ -33,18 +33,3 @@ export function getLeavePage(query) {
params: query params: query
}) })
} }
export function createFormKeyLeave(data) {
return request({
url: '/oa/leave/form-key/create',
method: 'post',
data: data
})
}
export function getLeaveApplyMembers() {
return request({
url: '/oa/leave/getLeaveApplyMembers',
method: 'get'
})
}

View File

@ -123,16 +123,21 @@ export const constantRoutes = [
] ]
}, },
{ {
path: '/flow', path: '/bpm',
component: Layout, component: Layout,
hidden: true, hidden: true,
redirect: 'noredirect', redirect: 'noredirect',
children: [ children: [
{ {
path: 'leave/apply', path: 'oa/leave/create',
component: (resolve) => require(['@/views/bpm/oa/leave/create'], resolve), component: (resolve) => require(['@/views/bpm/oa/leave/create'], resolve),
name: '请假表单-申请', name: '发起 OA 请假',
meta: { title: '请假表单-申请', icon: 'form' } meta: { title: '发起 OA 请假', icon: 'form' }
}, {
path: 'oa/leave/detail',
component: (resolve) => require(['@/views/bpm/oa/leave/detail'], resolve),
name: '查看 OA 请假',
meta: { title: '查看 OA 请假', icon: 'view' }
} }
] ]
}, },

View File

@ -8,38 +8,26 @@
<el-form-item label="结束时间" prop="endTime"> <el-form-item label="结束时间" prop="endTime">
<el-date-picker clearable size="small" v-model="form.endTime" type="date" value-format="timestamp" placeholder="选择结束时间" /> <el-date-picker clearable size="small" v-model="form.endTime" type="date" value-format="timestamp" placeholder="选择结束时间" />
</el-form-item> </el-form-item>
<el-form-item label="请假类型" prop="leaveType"> <el-form-item label="请假类型" prop="type">
<el-select v-model="form.leaveType" placeholder="请选择"> <el-select v-model="form.type" placeholder="请选择">
<el-option <el-option v-for="dict in typeDictData" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
v-for="dict in leaveTypeDictData"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="原因" prop="reason"> <el-form-item label="原因" prop="reason">
<el-col :span="10"> <el-col :span="10">
<el-input <el-input type="textarea" :rows="3" v-model="form.reason" placeholder="请输入原因" />
type="textarea"
:rows="3"
v-model="form.reason"
placeholder="请输入原因" />
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="申请时间" prop="applyTime">
<el-date-picker clearable size="small" v-model="form.applyTime" type="date" value-format="timestamp" placeholder="选择申请时间" />
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm"></el-button> <el-button type="primary" @click="submitForm"> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { createFormKeyLeave} from "@/api/oa/leave" import { createLeave} from "@/api/oa/leave"
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict' import { getDictDatas, DICT_TYPE } from '@/utils/dict'
export default { export default {
name: "LeaveCreate", name: "LeaveCreate",
components: { components: {
@ -48,31 +36,23 @@ export default {
return { return {
// //
form: { form: {
processKey: 'leave-update', startTime: undefined,
taskVariables:{ endTime: undefined,
hr: "", type: undefined,
pm: "", reason: undefined,
bm: ""
}
}, },
// //
rules: { rules: {
startTime: [{ required: true, message: "开始时间不能为空", trigger: "blur" }], startTime: [{ required: true, message: "开始时间不能为空", trigger: "blur" }],
endTime: [{ required: true, message: "结束时间不能为空", trigger: "blur" }], endTime: [{ required: true, message: "结束时间不能为空", trigger: "blur" }],
applyTime: [{ required: true, message: "申请时间不能为空", trigger: "blur" }], type: [{ required: true, message: "请假类型不能为空", trigger: "change" }],
reason: [{ required: true, message: "请假原因不能为空", trigger: "change" }],
}, },
statusFormat(row, column) { typeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE),
return getDictDataLabel(DICT_TYPE.OA_LEAVE_STATUS, row.status)
},
leaveTypeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE),
leaveStatusData: getDictDatas(DICT_TYPE.OA_LEAVE_STATUS)
}; };
}, },
created() { created() {
this.form.taskVariables.hr = this.$route.query.hr;
this.form.taskVariables.pm = this.$route.query.pm;
this.form.taskVariables.bm = this.$route.query.bm;
}, },
methods: { methods: {
/** 提交按钮 */ /** 提交按钮 */
@ -83,13 +63,10 @@ export default {
} }
// //
createFormKeyLeave(this.form).then(response => { createLeave(this.form).then(response => {
this.msgSuccess("新增成功"); this.msgSuccess("发起成功");
this.$store.dispatch('tagsView/delView', this.$route).then(({ visitedViews }) => { this.$store.dispatch("tagsView/delView", this.$route);
//if (this.isActive(this.$route)) { this.$router.push({ path: "/bpm/oa/leave"});
this.$router.push({path: '/oa/todo'})
//}
})
}); });
}); });
} }

View File

@ -0,0 +1,54 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="开始时间:" prop="startTime"> {{parseTime(form.startTime, '{y}-{m}-{d}')}} </el-form-item>
<el-form-item label="结束时间:" prop="endTime"> {{parseTime(form.endTime, '{y}-{m}-{d}')}} </el-form-item>
<el-form-item label="请假类型:" prop="type">{{ typeFormat(form) }}</el-form-item>
<el-form-item label="原因:" prop="reason"> {{ form.reason }}</el-form-item>
</el-form>
</div>
</template>
<script>
import { getLeave} from "@/api/oa/leave"
import {getDictDatas, DICT_TYPE, getDictDataLabel} from '@/utils/dict'
export default {
name: "LeaveDetail",
components: {
},
data() {
return {
id: undefined, //
//
form: {
startTime: undefined,
endTime: undefined,
type: undefined,
reason: undefined,
},
typeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE),
};
},
created() {
this.id = this.$route.query.id;
if (!this.id) {
this.$message.error('未传递 id 参数,无法查看 OA 请假信息');
return;
}
this.getDetail();
},
methods: {
/** 获得请假信息 */
getDetail() {
getLeave(this.id).then(response => {
this.form = response.data;
});
},
typeFormat(row) {
return getDictDataLabel(DICT_TYPE.BPM_OA_LEAVE_TYPE, row.type)
}
}
};
</script>

View File

@ -30,7 +30,7 @@
<!-- 操作工具栏 --> <!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button> <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">发起请假</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -58,7 +58,7 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleDetail(scope.row)">详情</el-button> <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)">详情</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleProcessDetail(scope.row)">审批进度</el-button> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleProcessDetail(scope.row)">审批进度</el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -67,58 +67,6 @@
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/> @pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="开始时间" prop="startTime">
<el-date-picker clearable size="small" v-model="form.startTime" type="date" value-format="timestamp" placeholder="选择开始时间" />
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
<el-date-picker clearable size="small" v-model="form.endTime" type="date" value-format="timestamp" placeholder="选择结束时间" />
</el-form-item>
<el-form-item label="请假类型" prop="leaveType">
<el-select v-model="form.leaveType" placeholder="请选择">
<el-option
v-for="dict in leaveTypeDictData"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="原因" prop="reason">
<el-input v-model="form.reason" placeholder="请输入原因" />
</el-form-item>
<el-form-item label="申请时间" prop="applyTime">
<el-date-picker clearable size="small" v-model="form.applyTime" type="date" value-format="timestamp" placeholder="选择申请时间" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog :title="title" :visible.sync="dialogDetailVisible" width="500px" append-to-body>
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="状态" >
{{ getDictDataLabel(DICT_TYPE.OA_LEAVE_STATUS, form.status) }}
</el-form-item>
<el-form-item label="申请人id" >{{form.userId}}</el-form-item>
<el-form-item label="开始时间" >{{ parseTime(form.startTime) }}</el-form-item>
<el-form-item label="结束时间" prop="endTime">{{ parseTime(form.endTime) }}</el-form-item>
<el-form-item label="请假类型" prop="leaveType">
{{ getDictDataLabel(DICT_TYPE.BPM_OA_LEAVE_TYPE, form.leaveType) }}
</el-form-item>
<el-form-item label="原因" prop="reason">{{form.reason}}</el-form-item>
<el-form-item label="申请时间" prop="applyTime">{{ parseTime(form.applyTime) }}</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="dialogDetailVisible = false"> </el-button>
<el-button @click="dialogDetailVisible = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -156,17 +104,9 @@ export default {
leaveType: null, leaveType: null,
reason: null, reason: null,
}, },
//
form: {},
//
rules: {
startTime: [{ required: true, message: "开始时间不能为空", trigger: "blur" }],
endTime: [{ required: true, message: "结束时间不能为空", trigger: "blur" }],
},
leaveTypeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE), leaveTypeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE),
leaveResultData: getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT), leaveResultData: getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT),
dialogDetailVisible: false, // TODO
}; };
}, },
created() { created() {
@ -186,25 +126,6 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
status: undefined,
userId: undefined,
startTime: undefined,
endTime: undefined,
leaveType: undefined,
reason: undefined,
applyTime: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
@ -212,54 +133,22 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.dateRangeStartTime = [];
this.dateRangeEndTime = [];
this.dateRangeCreateTime = []; this.dateRangeCreateTime = [];
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
getLeaveApplyMembers().then(response => { this.$router.push({ path: "/bpm/oa/leave/create"});
const route = {
path: '/flow/leave/apply',
query: {
hr: response.data.hr,
pm: response.data.pm,
bm : response.data.bm
}
}
this.$router.replace(route);
});
}, },
/** 详情按钮操作 */ /** 详情按钮操作 */
handleDetail(row) { handleDetail(row) {
this.reset(); this.$router.push({ path: "/bpm/oa/leave/detail", query: { id: row.id}});
const id = row.id;
getLeave(id).then(response => {
this.form = response.data;
this.dialogDetailVisible = true
this.title = "请假详情";
});
}, },
/** 查看审批进度的操作 */ /** 查看审批进度的操作 */
handleProcessDetail(row) { handleProcessDetail(row) {
this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstanceId}}); this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstanceId}});
}, },
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (!valid) {
return;
}
//
createLeave(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
});
},
resultFormat(row, column) { resultFormat(row, column) {
return getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, row.result) return getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, row.result)
}, },