Skip to content

Commit

Permalink
use /fsm/xxx replace /leave/xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
piupuer committed Nov 7, 2021
1 parent fb86c1c commit d5ba2b0
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 50 deletions.
14 changes: 14 additions & 0 deletions src/api/system/fsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export const findFsmApproving = (params: any) =>
params
})

export const findFsmLogTrack = (params: any) =>
request({
url: '/fsm/log/track',
method: 'get',
params
})

export const getFsmLogDetail = (params: any) =>
request({
url: '/fsm/submitter/detail',
Expand All @@ -35,6 +42,13 @@ export const approveFsm = (data: any) =>
data
})

export const cancelFsm = (data: any) =>
request({
url: '/fsm/cancel',
method: 'patch',
data
})

export const createFsm = (data: any) =>
request({
url: '/fsm/create',
Expand Down
24 changes: 0 additions & 24 deletions src/api/test/leaves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ export const findLeave = (params: any) =>
params
})

export const findLeaveApprovingTrack = (id: number) =>
request({
url: `/leave/approving/track/${id}`,
method: 'get'
})

export const createLeave = (data: any) =>
request({
url: '/leave/create',
Expand All @@ -27,24 +21,6 @@ export const updateLeave = (id: number, data: any) =>
data
})

export const confirmLeave = (id: number) =>
request({
url: `/leave/confirm/${id}`,
method: 'patch'
})

export const resubmitLeave = (id: number) =>
request({
url: `/leave/resubmit/${id}`,
method: 'patch'
})

export const cancelLeave = (id: number) =>
request({
url: `/leave/cancel/${id}`,
method: 'patch'
})

export const batchDeleteLeave = (ids: string) =>
request({
url: '/leave/delete/batch',
Expand Down
2 changes: 1 addition & 1 deletion src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default class extends Vue {
private checkCapslock(e: KeyboardEvent) {
const { key } = e
this.capsTooltip = key !== null && key.length === 1 && (key >= 'A' && key <= 'Z')
this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z')
}
private showPwd() {
Expand Down
3 changes: 2 additions & 1 deletion src/views/system/fsm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ export default class extends Vue {
const oldRow = JSON.parse(JSON.stringify(row))
// 弹窗表单赋值
this.updateDialog.form.id = row.id
this.updateDialog.form.category = row.category
this.updateDialog.form.name = row.name
this.updateDialog.form.submitterName = row.submitterName
this.updateDialog.form.submitterEditFields = []
Expand Down Expand Up @@ -844,7 +845,7 @@ export default class extends Vue {
this.updateDialog.form.levels = levels
// 记录旧数据
this.updateDialog.oldData = JSON.parse(JSON.stringify(await this.encodeData(oldRow)))
this.updateDialog.oldData = JSON.parse(JSON.stringify(this.encodeData(oldRow)))
// 修改类型
this.updateDialog.type = 1
// 修改标题
Expand Down
10 changes: 5 additions & 5 deletions src/views/system/role.vue
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@
import { Component, Vue } from 'vue-property-decorator'
import Pagination from '@/components/Pagination/index.vue'
import { Form, Tree } from 'element-ui'
import { batchDeleteRole, createRole, findRole, updateRole, updateRoleApis, updateRoleMenus } from '@/api/system/roles'
import { findApiGroupByCategoryByRoleId } from '@/api/system/apis'
import { findMenuByRoleId } from '@/api/system/menus'
import { batchDeleteRole, createRole, findRole, updateRole } from '@/api/system/roles'
import { findApiGroupByCategoryByRoleId, updateApiByRoleId } from '@/api/system/apis'
import { findMenuByRoleId, updateMenuByRoleId } from '@/api/system/menus'
import { diffArrUpdate, diffObjUpdate } from '@/utils/diff'
import { UserModule } from '@/store/modules/user'
import { IdempotenceModule } from '@/store/modules/idempotence'
Expand Down Expand Up @@ -537,7 +537,7 @@ export default class extends Vue {
}
try {
this.roleDialog.loading = true
await updateRoleMenus(this.roleDialog.roleId, diff)
await updateMenuByRoleId(this.roleDialog.roleId, diff)
} finally {
this.roleDialog.loading = false
}
Expand Down Expand Up @@ -567,7 +567,7 @@ export default class extends Vue {
}
try {
this.roleDialog.loading = true
await updateRoleApis(this.roleDialog.roleId, diff)
await updateApiByRoleId(this.roleDialog.roleId, diff)
} finally {
this.roleDialog.loading = false
}
Expand Down
29 changes: 29 additions & 0 deletions src/views/test/approving.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,28 @@
>
<template slot-scope="scope">
<el-button
v-if="scope.row.resubmit === 1"
type="success"
@click="handleApproval(scope.row, 2)"
>
重新提交
</el-button>
<el-button
v-if="scope.row.confirm === 1"
type="success"
@click="handleApproval(scope.row, 3)"
>
确认
</el-button>
<el-button
v-if="scope.row.resubmit === 0 && scope.row.confirm === 0"
type="primary"
@click="handleApproval(scope.row, 0)"
>
通过
</el-button>
<el-button
v-if="scope.row.resubmit === 0 && scope.row.confirm === 0 && scope.row.refuse === 1"
type="danger"
@click="handleApproval(scope.row, 1)"
>
Expand Down Expand Up @@ -281,6 +297,9 @@ export default class extends Vue {
category: '',
submitterUser: {},
submitterRole: {},
resubmit: 0,
confirm: 0,
refuse: 0,
logDetail: []
}
}
Expand Down Expand Up @@ -355,6 +374,16 @@ export default class extends Vue {
// 弹窗表单赋值
this.approvalDialog.form.uuid = row.uuid
this.approvalDialog.form.category = row.category
if (type === 2 || type === 3) {
// 重新提交/确认
await approveFsm({
uuid: row.uuid,
category: row.category,
approved: 1
})
this.getData()
return
}
// 修改分类
this.approvalDialog.type = type
// 修改标题
Expand Down
61 changes: 42 additions & 19 deletions src/views/test/leave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<el-button
type="primary"
:loading="table.approvalLoading"
@click="handleApproval(scope.row)"
@click="handleLogTrack(scope.row)"
>
审批日志
</el-button>
Expand Down Expand Up @@ -273,16 +273,10 @@
import { Component, Vue } from 'vue-property-decorator'
import Pagination from '@/components/Pagination/index.vue'
import { Form } from 'element-ui'
import {
batchDeleteLeave,
cancelLeave,
createLeave,
findLeaveApprovingTrack,
findLeave,
updateLeave, confirmLeave, resubmitLeave
} from '@/api/test/leaves'
import { batchDeleteLeave, createLeave, findLeave, updateLeave } from '@/api/test/leaves'
import { diffObjUpdate } from '@/utils/diff'
import { IdempotenceModule } from '@/store/modules/idempotence'
import { approveFsm, cancelFsm, findFsmLogTrack } from '@/api/system/fsm'
@Component({
// 组件名称首字母需大写, 否则会报警告
Expand All @@ -295,6 +289,8 @@ export default class extends Vue {
private readonly defaultConfig: any = {
pageNum: 1,
pageSize: 5,
// 默认状态机分类, 需要和后端保持一致, 也可以动态从数据字典查询
category: 1,
status: [{
name: 0,
label: '已提交',
Expand Down Expand Up @@ -502,11 +498,17 @@ export default class extends Vue {
this.updateDialog.visible = true
}
private async handleApproval(row: any) {
private async handleLogTrack(row: any) {
this.table.approvalLoading = true
this.approvalDialog.title = ''
try {
const { data } = await findLeaveApprovingTrack(row.id)
console.log({
category: this.defaultConfig.category,
uuid: row.fsmUuid
})
const { data } = await findFsmLogTrack({
category: this.defaultConfig.category,
uuid: row.fsmUuid
})
this.approvalDialog.stepsActive = data.length - 1
const logs: any [] = []
for (let i = 0, len = data.length; i < len; i++) {
Expand All @@ -520,6 +522,14 @@ export default class extends Vue {
} else if (i < len - 1 || item.status > 0) {
let status = 'success'
let description = item.updatedAt
let opinion = item.opinion
if (item.opinion === '' && item.status !== 3 && item.end === 0 && item.confirm === 0) {
opinion = '通过'
}
let title = item.name
if (opinion !== '') {
title = item.name + '[审批意见: ' + opinion + ']'
}
if (item.status === 2) {
status = 'error'
if (item.opinion !== '') {
Expand All @@ -531,18 +541,18 @@ export default class extends Vue {
status = 'finish'
}
logs.push({
title: item.name,
title,
description,
status
})
} else {
if (item.resubmit) {
if (item.resubmit === 1) {
logs.push({
title: '待重新提交',
description: '请编辑后重新提交~',
status: 'wait'
})
} else if (item.confirm) {
} else if (item.confirm === 1) {
logs.push({
title: '待确认',
description: '请点击确认~',
Expand Down Expand Up @@ -599,13 +609,23 @@ export default class extends Vue {
type: 'warning'
})
.then(async() => {
await confirmLeave(row.id)
await approveFsm({
category: this.defaultConfig.category,
uuid: row.fsmUuid,
// 确认相当于一次审批通过
approved: 1
})
this.getData()
})
}
private async handleResubmit(row: any) {
await resubmitLeave(row.id)
await approveFsm({
category: this.defaultConfig.category,
uuid: row.fsmUuid,
// 重新提交相当于一次审批通过
approved: 1
})
this.getData()
}
Expand All @@ -617,7 +637,10 @@ export default class extends Vue {
type: 'warning'
})
.then(async() => {
await cancelLeave(row.id)
await cancelFsm({
category: this.defaultConfig.category,
uuids: [row.fsmUuid]
})
this.getData()
})
}
Expand Down Expand Up @@ -721,7 +744,7 @@ export default class extends Vue {
margin-bottom: 15px;
}
.el-steps {
width: 50%;
width: 70%;
margin: 0 auto;
}
}
Expand Down

0 comments on commit d5ba2b0

Please sign in to comment.