添加我的审核,我的申请提前结束
This commit is contained in:
@@ -66,15 +66,25 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" min-width="110">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="statusType(scope.row.status)" size="small">{{ statusText(scope.row.status) }}</el-tag>
|
||||
<el-tag :type="statusType(scope.row)" size="small">{{ statusText(scope.row) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发起时间" prop="createTime" min-width="160">
|
||||
<template slot-scope="scope">{{ formatDate(scope.row.createTime) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="120" fixed="right">
|
||||
<el-table-column label="操作" min-width="180" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="goDetail(scope.row)">详情</el-button>
|
||||
<el-button
|
||||
v-if="showEarlyEndButton(scope.row)"
|
||||
type="text"
|
||||
size="mini"
|
||||
style="color: #e6a23c"
|
||||
:loading="earlyEndLoadingId === scope.row.bizId"
|
||||
@click.stop="handleEarlyEnd(scope.row)"
|
||||
>
|
||||
提前结束
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -97,6 +107,7 @@
|
||||
|
||||
<script>
|
||||
import { listMyApply } from '@/api/hrm/myApply'
|
||||
import { earlyEndTravel } from '@/api/hrm/travel'
|
||||
import applyTypeMinix from '@/views/hrm/minix/applyTypeMinix.js'
|
||||
|
||||
export default {
|
||||
@@ -105,6 +116,7 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
loading: false,
|
||||
earlyEndLoadingId: null,
|
||||
list: [],
|
||||
total: 0,
|
||||
summary: {
|
||||
@@ -128,11 +140,31 @@ export default {
|
||||
getRowTitle (row) {
|
||||
return row.title || row.remark || '-'
|
||||
},
|
||||
statusText (status) {
|
||||
isTravelCompleted (row) {
|
||||
if (!row || row.bizType !== 'travel') return false
|
||||
const endTime = row.endTime ? new Date(row.endTime).getTime() : 0
|
||||
const now = Date.now()
|
||||
return Boolean(row.actualEndTime) || (endTime && endTime <= now)
|
||||
},
|
||||
showEarlyEndButton (row) {
|
||||
if (!row || row.bizType !== 'travel') return false
|
||||
if (row.actualEndTime) return false
|
||||
const endTime = row.endTime ? new Date(row.endTime).getTime() : 0
|
||||
return row.status === 'approved' && endTime > Date.now()
|
||||
},
|
||||
statusText (row) {
|
||||
const status = row?.status
|
||||
if (row?.bizType === 'travel' && status === 'approved') {
|
||||
return this.isTravelCompleted(row) ? '已完成' : '进行中'
|
||||
}
|
||||
const map = { draft: '草稿', running: '审批中', pending: '审批中', approved: '已通过', rejected: '已驳回', revoked: '已撤销', finished: '已完成' }
|
||||
return map[status] || status || '-'
|
||||
},
|
||||
statusType (status) {
|
||||
statusType (row) {
|
||||
const status = row?.status
|
||||
if (row?.bizType === 'travel' && status === 'approved') {
|
||||
return this.isTravelCompleted(row) ? 'success' : 'warning'
|
||||
}
|
||||
const map = { draft: 'info', running: 'warning', pending: 'warning', approved: 'success', rejected: 'danger', revoked: 'danger', finished: 'success' }
|
||||
return map[status] || 'info'
|
||||
},
|
||||
@@ -163,8 +195,8 @@ export default {
|
||||
this.list = res.rows || []
|
||||
this.total = res.total || 0
|
||||
this.summary.total = res.total || 0
|
||||
this.summary.running = (res.rows || []).filter(i => ['running', 'pending'].includes(i.status)).length
|
||||
this.summary.approved = (res.rows || []).filter(i => i.status === 'approved').length
|
||||
this.summary.running = (res.rows || []).filter(i => ['running', 'pending'].includes(i.status) || (i.bizType === 'travel' && i.status === 'approved' && !this.isTravelCompleted(i))).length
|
||||
this.summary.approved = (res.rows || []).filter(i => i.status === 'approved' && !(i.bizType === 'travel' && !this.isTravelCompleted(i))).length
|
||||
} catch (err) {
|
||||
console.error('加载我的申请失败:', err)
|
||||
this.$message.error('加载我的申请失败')
|
||||
@@ -183,6 +215,24 @@ export default {
|
||||
this.query.pageNum = val
|
||||
this.loadList()
|
||||
},
|
||||
async handleEarlyEnd (row) {
|
||||
this.$confirm('确认提前结束本次出差吗?结束后的实际时间将记录为当前时间。', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
this.earlyEndLoadingId = row.bizId
|
||||
try {
|
||||
await earlyEndTravel(row.bizId)
|
||||
this.$message.success('提前结束成功')
|
||||
await this.loadList()
|
||||
} catch (error) {
|
||||
this.$message.error(error.message || '提前结束失败')
|
||||
} finally {
|
||||
this.earlyEndLoadingId = null
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
goDetail (row) {
|
||||
if (!row) return
|
||||
const routeMap = {
|
||||
|
||||
Reference in New Issue
Block a user