| | |
| | | export function updateLeave(token: string, data: Leave) { return request<boolean>("/hrm/leave/update", { method: "PUT", data, header: header(token) }); } |
| | | export function deleteLeave(token: string, id: number) { return request<boolean>(`/hrm/leave/delete${query({ id })}`, { method: "DELETE", header: header(token) }); } |
| | | export function submitLeave(token: string, id: number, processDefinitionKey: string) { return request<boolean>(`/hrm/leave/submit${query({ id, processDefinitionKey })}`, { method: "POST", header: header(token) }); } |
| | | export function cancelLeave(token: string, id: number) { return request<boolean>(`/hrm/leave/cancel${query({ id })}`, { method: "POST", header: header(token) }); } |
| | | export function getLeaveProcesses(token: string) { return request<ApproveProcess[]>("/hrm/leave/approve-process-definition-list", { header: header(token) }); } |
| | | |
| | | export function getTransferPage(token: string, params: { pageNo: number; pageSize: number; userId?: number; transferType?: number; status?: number }) { return request<PageResult<Transfer>>(`/hrm/transfer/page${query(params)}`, { header: header(token) }); } |
| | |
| | | }; |
| | | |
| | | /** ★ 打包开关:只改这一行 */ |
| | | export const ACTIVE_COMPANY: CompanyCode = "changhui"; |
| | | export const ACTIVE_COMPANY: CompanyCode = "beifang"; |
| | | |
| | | export const APP_COMPANY: AppCompanyConfig = COMPANY_PROFILES[ACTIVE_COMPANY]; |
| | |
| | | <script setup lang="ts"> |
| | | import { computed, reactive, ref } from "vue"; |
| | | import { onLoad } from "@dcloudio/uni-app"; |
| | | import { createLeave, getAutoApprovalPolicy, getHrmDicts, getLeave, getLeaveProcesses, submitLeave, updateLeave, type ApproveProcess, type HrmAttachment, type Leave } from "../../../api/hrm"; |
| | | import { createLeave, getHrmDicts, getLeave, getLeaveProcesses, submitLeave, updateLeave, type ApproveProcess, type HrmAttachment, type Leave } from "../../../api/hrm"; |
| | | import type { DictData } from "../../../api/crm"; |
| | | import { useAuth } from "../../../stores/auth"; |
| | | import { HRM_DICT, label, options, setDateTime } from "../shared"; |
| | |
| | | draftSaved = true; |
| | | if (!latest.id) throw new Error("未获取到最新申请信息"); |
| | | |
| | | const automaticApproval = await getAutoApprovalPolicy(state.accessToken).catch(() => false); |
| | | let processKey = "hrm_leave"; |
| | | if (!automaticApproval) { |
| | | const processes = await getLeaveProcesses(state.accessToken); |
| | | if (!processes.length) throw new Error("暂无可用审批流程"); |
| | | const process = await chooseProcess(processes); |
| | | if (!process) { |
| | | uni.showToast({ title: "已保存草稿", icon: "success" }); |
| | | return; |
| | | } |
| | | processKey = process.key; |
| | | } |
| | | await submitLeave(state.accessToken, latest.id, processKey); |
| | | const processes = await getLeaveProcesses(state.accessToken); |
| | | if (!processes.length) throw new Error("暂无可用审批流程"); |
| | | const process = await chooseProcess(processes); |
| | | if (!process) { uni.showToast({ title: "已保存草稿", icon: "success" }); return; } |
| | | await submitLeave(state.accessToken, latest.id, process.key); |
| | | uni.showToast({ title: "提交成功", icon: "success" }); |
| | | setTimeout(() => uni.navigateBack(), 500); |
| | | } catch (error) { |
| | |
| | | <script setup lang="ts"> |
| | | import { computed, ref } from "vue"; |
| | | import { onPullDownRefresh, onReachBottom, onShow } from "@dcloudio/uni-app"; |
| | | import { deleteLeave, getAutoApprovalPolicy, getHrmDicts, getLeavePage, getLeaveProcesses, submitLeave, type ApproveProcess, type Leave } from "../../../api/hrm"; |
| | | import { cancelLeave, deleteLeave, getHrmDicts, getLeavePage, getLeaveProcesses, submitLeave, type ApproveProcess, type Leave } from "../../../api/hrm"; |
| | | import type { DictData } from "../../../api/crm"; |
| | | import { useAuth } from "../../../stores/auth"; |
| | | import { auditClass, displayDate, HRM_DICT, label } from "../shared"; |
| | |
| | | async function submit(row: Leave) { |
| | | if (!state.accessToken || !row.id || !canOperate(row)) return; |
| | | try { |
| | | const automaticApproval = await getAutoApprovalPolicy(state.accessToken).catch(() => false); |
| | | let processKey = "hrm_leave"; |
| | | if (!automaticApproval) { |
| | | const processes = await getLeaveProcesses(state.accessToken); |
| | | if (!processes.length) throw new Error("暂无可用审批流程"); |
| | | const process = await chooseProcess(processes); |
| | | if (!process) return; |
| | | processKey = process.key; |
| | | } |
| | | await submitLeave(state.accessToken, row.id, processKey); |
| | | const processes = await getLeaveProcesses(state.accessToken); |
| | | if (!processes.length) throw new Error("暂无可用审批流程"); |
| | | const process = await chooseProcess(processes); |
| | | if (!process) return; |
| | | await submitLeave(state.accessToken, row.id, process.key); |
| | | uni.showToast({ title: "提交成功", icon: "success" }); |
| | | await load(true); |
| | | } catch (cause) { |
| | |
| | | } |
| | | } |
| | | |
| | | function cancel(row: Leave) { |
| | | if (!state.accessToken || !row.id || !canOperate(row)) return; |
| | | uni.showModal({ title: "撤销申请", content: "确定撤销该请假申请吗?", success: async result => { |
| | | if (!result.confirm || !state.accessToken) return; |
| | | try { await cancelLeave(state.accessToken, row.id!); uni.showToast({ title: "撤销成功", icon: "success" }); await load(true); } |
| | | catch (cause) { uni.showToast({ title: cause instanceof Error ? cause.message : "撤销失败", icon: "none" }); } |
| | | }}); |
| | | } |
| | | function remove(row: Leave) { |
| | | if (!state.accessToken || !row.id || !canOperate(row)) return; |
| | | uni.showModal({ |
| | |
| | | <view v-for="row in rows" :key="row.id" class="card"> |
| | | <view class="head"><view><text class="name">{{ row.userName || "--" }}的请假申请</text><text class="sub">申请编号 {{ row.id }} · {{ row.deptName || "未分配部门" }}</text></view><text :class="['tag', auditClass(row.status)]">{{ label(dicts, HRM_DICT.auditStatus, row.status) }}</text></view> |
| | | <view class="grid"><text>类型:{{ label(dicts, HRM_DICT.leaveType, row.leaveType) }}</text><text>时长:{{ row.duration ?? "--" }} 天</text><text>开始:{{ displayDate(row.startTime) }}</text><text>结束:{{ displayDate(row.endTime) }}</text></view> |
| | | <view class="actions"><button @click="go(row.id, 'detail')">详情</button><button v-if="canOperate(row)&&row.status===0&&hasPermission('hrm:leave:update')" @click="go(row.id)">编辑</button><button v-if="canOperate(row)&&row.status===0&&hasPermission('hrm:leave:submit')" @click="submit(row)">提交</button><button v-if="canOperate(row)&&(row.status===0||row.status===40)&&hasPermission('hrm:leave:delete')" class="danger" @click="remove(row)">删除</button></view> |
| | | <view class="actions"><button @click="go(row.id, 'detail')">详情</button><button v-if="canOperate(row)&&row.status===0&&hasPermission('hrm:leave:update')" @click="go(row.id)">编辑</button><button v-if="canOperate(row)&&row.status===0&&hasPermission('hrm:leave:submit')" @click="submit(row)">提交</button><button v-if="canOperate(row)&&row.status===10&&hasPermission('hrm:leave:cancel')" @click="cancel(row)">撤销</button><button v-if="canOperate(row)&&(row.status===0||row.status===40)&&hasPermission('hrm:leave:delete')" class="danger" @click="remove(row)">删除</button></view> |
| | | </view> |
| | | <view v-if="!rows.length&&!loading&&!error" class="state">暂无本人提交的请假申请</view> |
| | | <view v-else-if="rows.length" class="more">{{ hasMore ? (loading ? "加载中..." : "上拉加载更多") : "没有更多了" }}</view> |