|
|
|
@ -1,14 +1,16 @@
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { computed, h, nextTick, onMounted, reactive, ref, unref } from 'vue'
|
|
|
|
|
import { NDataTable, useDialog } from 'naive-ui'
|
|
|
|
|
import type { DataTableColumns, DataTableRowKey } from 'naive-ui'
|
|
|
|
|
import { Action, CustomTabelModal, ImportExcelModal, RejectModal, RepeatModal, RepeatTaskTableModal } from '../comp'
|
|
|
|
|
import { NDataTable, useDialog, useMessage } from 'naive-ui'
|
|
|
|
|
import type { DataTableColumns, DataTableRowKey, PaginationProps } from 'naive-ui'
|
|
|
|
|
import { Action, CustomTabelModal, ImportExcelModal, RepeatModal, RepeatTaskTableModal } from '../comp'
|
|
|
|
|
import ConfrimModal from '@/views/task/modal/ConfrimModal.vue'
|
|
|
|
|
import { useWindowSizeFn } from '@/hooks/event/useWindowSizeFn'
|
|
|
|
|
import { getViewportOffset } from '@/utils/domUtils'
|
|
|
|
|
import type { RowData } from '@/config/final'
|
|
|
|
|
import { findKey, headRules } from '@/config/final'
|
|
|
|
|
import { getFinalList } from '@/api/final'
|
|
|
|
|
import { isBoolean } from '@/utils/is'
|
|
|
|
|
import { useUser } from '@/store/modules/user'
|
|
|
|
|
import type { ApprovalParam } from '/#/api'
|
|
|
|
|
import { audit } from '@/api/task/task'
|
|
|
|
|
|
|
|
|
@ -92,9 +94,12 @@ const pagination = reactive({
|
|
|
|
|
})
|
|
|
|
|
const tableData = ref<Array<RowData>>([])
|
|
|
|
|
const selectionIds = ref<DataTableRowKey[]>([])
|
|
|
|
|
const userStore = useUser()
|
|
|
|
|
const dialog = useDialog()
|
|
|
|
|
const message = useMessage()
|
|
|
|
|
|
|
|
|
|
async function query(page: number, pageSize: number) {
|
|
|
|
|
const result = await getFinalList({ sortorder: 'asc', pageSize: 10, currPage: 1, sortname: '' })
|
|
|
|
|
const result = await getFinalList({ sortorder: 'asc', pageSize, currPage: page, sortname: '' })
|
|
|
|
|
const { data, pageCount } = result
|
|
|
|
|
tableData.value = data
|
|
|
|
|
pagination.page = page
|
|
|
|
@ -212,7 +217,6 @@ function actionHandler(action: any) {
|
|
|
|
|
const { key } = action
|
|
|
|
|
switch (key) {
|
|
|
|
|
case 'view':
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
case 'reset':
|
|
|
|
|
resetHandler()
|
|
|
|
@ -221,14 +225,35 @@ function actionHandler(action: any) {
|
|
|
|
|
approvalHandler()
|
|
|
|
|
break
|
|
|
|
|
case 'reject':
|
|
|
|
|
showModal(rejectModalRef)
|
|
|
|
|
rejectHandler()
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const dialog = useDialog()
|
|
|
|
|
// states:1未提交,2待审批,3通过,4不通过
|
|
|
|
|
function validate(items: any[]) {
|
|
|
|
|
if (items.length === 0)
|
|
|
|
|
return '至少选中一个任务'
|
|
|
|
|
|
|
|
|
|
const useInfo = userStore.getUserInfo
|
|
|
|
|
const username = useInfo.loginname
|
|
|
|
|
|
|
|
|
|
for (const item of items) {
|
|
|
|
|
const { iztrueorfalse, states, assignee } = item
|
|
|
|
|
if (iztrueorfalse === null)
|
|
|
|
|
return '未判别真假'
|
|
|
|
|
|
|
|
|
|
else if (states !== 2)
|
|
|
|
|
return '审批状态不合法'
|
|
|
|
|
|
|
|
|
|
else if (assignee !== username)
|
|
|
|
|
return '审批人不一致'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resetHandler() {
|
|
|
|
|
dialog.info({
|
|
|
|
@ -244,34 +269,89 @@ function resetHandler() {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSelectItems() {
|
|
|
|
|
return tableData.value.filter(item => selectionIds.value.includes(item.id))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function approvalHandler() {
|
|
|
|
|
const items = getSelectItems()
|
|
|
|
|
const msg = validate(items)
|
|
|
|
|
|
|
|
|
|
if (msg !== null) {
|
|
|
|
|
message.error(msg)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dialog.info({
|
|
|
|
|
title: '确认提示',
|
|
|
|
|
content: '确认给该任务审批为【通过】吗?',
|
|
|
|
|
positiveText: '确定',
|
|
|
|
|
negativeText: '取消',
|
|
|
|
|
onPositiveClick: () => {
|
|
|
|
|
// TODO:调用批量审批接口
|
|
|
|
|
approval(items)
|
|
|
|
|
},
|
|
|
|
|
onNegativeClick: () => { },
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rejectHandler(idOrDesc: string, isOther: boolean) {
|
|
|
|
|
// TODO:实现批量拒绝
|
|
|
|
|
// const param: ApprovalParam = {
|
|
|
|
|
// formid: '',
|
|
|
|
|
// taskId: '',
|
|
|
|
|
// approvd: false,
|
|
|
|
|
// taskComment: '',
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (isOther)
|
|
|
|
|
// param.taskComment = idOrDesc
|
|
|
|
|
// else
|
|
|
|
|
// param.taskComment = idOrDesc
|
|
|
|
|
|
|
|
|
|
// audit(param)
|
|
|
|
|
function approval(items) {
|
|
|
|
|
const formIds: string[] = items.map(item => item.id)
|
|
|
|
|
const taskIds: string[] = items.map(item => item.taskId)
|
|
|
|
|
const tasknames: string[] = items.map(item => item.taskname)
|
|
|
|
|
|
|
|
|
|
const param: ApprovalParam = {
|
|
|
|
|
formid: formIds,
|
|
|
|
|
taskId: taskIds,
|
|
|
|
|
approvd: true,
|
|
|
|
|
taskComment: 'approval',
|
|
|
|
|
taskname: tasknames,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doAudit(param)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rejectHandler() {
|
|
|
|
|
const items = getSelectItems()
|
|
|
|
|
const msg = validate(items)
|
|
|
|
|
|
|
|
|
|
if (msg !== null) {
|
|
|
|
|
message.error(msg)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const modal = unref(rejectModalRef)! as any
|
|
|
|
|
modal.showModal()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reject(idOrDesc: string, backId: string, isOther: boolean) {
|
|
|
|
|
const items = getSelectItems()
|
|
|
|
|
const formIds: string[] = items.map(item => item.id)
|
|
|
|
|
const taskIds: string[] = items.map(item => item.fromtaskid)
|
|
|
|
|
const tasknames: string[] = items.map(item => item.fromtaskname)
|
|
|
|
|
|
|
|
|
|
const param: ApprovalParam = {
|
|
|
|
|
formid: formIds,
|
|
|
|
|
taskId: taskIds,
|
|
|
|
|
approvd: false,
|
|
|
|
|
taskComment: idOrDesc,
|
|
|
|
|
taskname: isOther ? tasknames : ['其他'],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doAudit(param)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function doAudit(param: any) {
|
|
|
|
|
audit(param).then((res) => {
|
|
|
|
|
const { code } = res
|
|
|
|
|
if (code === 'OK')
|
|
|
|
|
reload()
|
|
|
|
|
else message.error(res.message)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload() {
|
|
|
|
|
const { page, pageSize } = unref(tableRef.value?.pagination) as PaginationProps
|
|
|
|
|
query(page!, pageSize!)
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
@ -337,7 +417,7 @@ function rejectHandler(idOrDesc: string, isOther: boolean) {
|
|
|
|
|
|
|
|
|
|
<CustomTabelModal ref="customTabelRef" @commit="commitHandler" />
|
|
|
|
|
<ImportExcelModal ref="importExcelRef" :on-success="sucessHandler" :header-config="headRules" />
|
|
|
|
|
<RejectModal ref="rejectModalRef" @commit="rejectHandler" />
|
|
|
|
|
<ConfrimModal ref="rejectModalRef" @commit="reject" />
|
|
|
|
|
<RepeatModal ref="repeatModalRef" @reject="showModal(rejectModalRef)" @viewrepeat="showModal(repeatTaskTableModalRef)" />
|
|
|
|
|
<RepeatTaskTableModal ref="repeatTaskTableModalRef" />
|
|
|
|
|
</div>
|
|
|
|
|