批量审批

bak
Dragon 1 year ago
parent d7c5950b6a
commit 31412e035f

@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { DataTableColumns, DataTableRowKey, PaginationProps } from "naive-ui";
import { NDataTable, useDialog, useMessage } from "naive-ui";
import type { DataTableColumns, DataTableRowKey, PaginationProps } from 'naive-ui'
import { NDataTable, useDialog, useMessage } from 'naive-ui'
import {
computed,
h,
@ -12,51 +12,51 @@ import {
ref,
unref,
watch,
} from "vue";
import { rowPropKeys } from "naive-ui/es/legacy-grid/src/Row";
} from 'vue'
import { rowPropKeys } from 'naive-ui/es/legacy-grid/src/Row'
import {
Action,
CustomTabelModal,
ImportExcelModal,
RepeatModal,
RepeatTaskTableModal,
} from "../comp";
import { getFinalList } from "@/api/final";
import { audit } from "@/api/task/task";
import SvgIcon from "@/components/Icon/SvgIcon.vue";
import type { RowData } from "@/config/final";
import { findKey, headRules } from "@/config/final";
import { useWindowSizeFn } from "@/hooks/event/useWindowSizeFn";
import { useUser } from "@/store/modules/user";
import { useFinal } from "@/store/modules/final";
import { getViewportOffset } from "@/utils/domUtils";
import { isBoolean } from "@/utils/is";
import { useDictionary } from "@/store/modules/dictonary";
import ConfrimModal from "@/views/task/modal/ConfrimModal.vue";
import type { ApprovalParam } from "/#/api";
import emitter from "@/utils/mitt";
import { formatToDateHMS } from "@/utils/dateUtil";
import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter";
const dicStore = useDictionary();
const izstatusList = ref([]);
const reviewType = 0;
} from '../comp'
import { getFinalList } from '@/api/final'
import { audit } from '@/api/task/task'
import SvgIcon from '@/components/Icon/SvgIcon.vue'
import type { RowData } from '@/config/final'
import { findKey, headRules } from '@/config/final'
import { useWindowSizeFn } from '@/hooks/event/useWindowSizeFn'
import { useUser } from '@/store/modules/user'
import { useFinal } from '@/store/modules/final'
import { getViewportOffset } from '@/utils/domUtils'
import { isBoolean } from '@/utils/is'
import { useDictionary } from '@/store/modules/dictonary'
import ConfrimModal from '@/views/task/modal/ConfrimModal.vue'
import type { ApprovalParam } from '/#/api'
import emitter from '@/utils/mitt'
import { formatToDateHMS } from '@/utils/dateUtil'
import { getAllfieldList, getfieldList, savefield } from '@/api/home/filter'
const dicStore = useDictionary()
const izstatusList = ref([])
const reviewType = 0
const actionsColumns = {
title: "操作",
key: "actions",
title: '操作',
key: 'actions',
minWidth: 200,
fixed: "right",
fixed: 'right',
render(row) {
return h(Action, {
id: row.id,
status: row.states,
trigger: (action) => {
actionHandler(action, row);
actionHandler(action, row)
},
});
})
},
};
const columnsRef = ref<DataTableColumns<RowData>>([]);
}
const columnsRef = ref<DataTableColumns<RowData>>([])
// const columns: DataTableColumns<RowData> = [
// {
// type: "selection",
@ -156,350 +156,363 @@ const columnsRef = ref<DataTableColumns<RowData>>([]);
async function getColumns() {
columnsRef.value = [
{
type: "selection",
fixed: "left",
type: 'selection',
fixed: 'left',
width: 50,
},
];
const userStore = useUser();
const userInfo = userStore.getUserInfo;
let res;
res = await getAllfieldList(reviewType); //
const allList = res.data;
res = await getfieldList(reviewType, userInfo.id); //
const useList = res.data;
const userFieldFixed = useList.userFieldFixed?.split(",");
const userFieldUnFixed = useList.userFieldUnFixed?.split(",");
console.log(userFieldFixed, userFieldUnFixed, "userFieldUnFixed");
console.log(allList, "allList");
]
const userStore = useUser()
const userInfo = userStore.getUserInfo
let res
res = await getAllfieldList(reviewType) //
const allList = res.data
res = await getfieldList(reviewType, userInfo.id) //
const useList = res.data
const userFieldFixed = useList.userFieldFixed?.split(',')
const userFieldUnFixed = useList.userFieldUnFixed?.split(',')
console.log(userFieldFixed, userFieldUnFixed, 'userFieldUnFixed')
console.log(allList, 'allList')
allList?.map((v) => {
if (!userFieldFixed?.length && !userFieldUnFixed?.length) {
if (v.isrequired == 2) {
columnsRef.value.push({
title: v.fieldDesc,
fixed: "left",
fixed: 'left',
key: v.name,
width: 120,
});
})
}
}
if (userFieldFixed?.find((v2) => v2 == v.name)) {
if (userFieldFixed?.find(v2 => v2 == v.name)) {
columnsRef.value.push({
title: v.fieldDesc,
key: v.name,
fixed: "left",
fixed: 'left',
width: 120,
});
})
}
if (userFieldUnFixed?.find((v2) => v2 == v.name)) {
if (userFieldUnFixed?.find(v2 => v2 == v.name)) {
columnsRef.value.push({
title: v.fieldDesc,
key: v.name,
width: 120,
});
})
}
});
})
columnsRef.value.push(actionsColumns as any)
formatColumns();
console.log(columnsRef.value, "columnsRef");
formatColumns()
console.log(columnsRef.value, 'columnsRef')
}
async function formatColumns() {
// TODO
let index;
index = columnsRef.value.findIndex((v) => v.title == "任务名称");
let index
index = columnsRef.value.findIndex(v => v.title == '任务名称')
if (index > -1) {
columnsRef.value[index] = {
title: "任务名称",
key: columnsRef.value[index]["key"], //"fromtaskname"
fixed: columnsRef.value[index]["fixed"] || undefined,
title: '任务名称',
key: columnsRef.value[index].key, // "fromtaskname"
fixed: columnsRef.value[index].fixed || undefined,
width: 200,
ellipsis: {
tooltip: true,
},
};
}
}
index = columnsRef.value.findIndex((v) => v.title == "审批状态");
index = columnsRef.value.findIndex(v => v.title == '审批状态')
if (index > -1) {
columnsRef.value[index] = {
title: "审批状态",
key: columnsRef.value[index]["key"],
fixed: columnsRef.value[index]["fixed"] || undefined,
title: '审批状态',
key: columnsRef.value[index].key,
fixed: columnsRef.value[index].fixed || undefined,
width: 100,
sorter: "default",
sorter: 'default',
renderSorterIcon: ({ order }) => {
if (order === false) return h(SvgIcon, { name: "sort-2" });
if (order === "ascend") return h(SvgIcon, { name: "sort-1" });
if (order === "descend") return h(SvgIcon, { name: "sort-3" });
if (order === false)
return h(SvgIcon, { name: 'sort-2' })
if (order === 'ascend')
return h(SvgIcon, { name: 'sort-1' })
if (order === 'descend')
return h(SvgIcon, { name: 'sort-3' })
},
render(row: any) {
const item: any = izstatusList.value.find(
(item: any) => item.value == row.states
);
return item ? item.label : "";
(item: any) => item.value == row.states,
)
return item ? item.label : ''
},
};
}
}
index = columnsRef.value.findIndex((v) => v.title == "图片相似度");
index = columnsRef.value.findIndex(v => v.title == '图片相似度')
if (index > -1) {
columnsRef.value[index] = {
title: "图片相似度",
key: columnsRef.value[index]["key"],
fixed: columnsRef.value[index]["fixed"] || undefined,
title: '图片相似度',
key: columnsRef.value[index].key,
fixed: columnsRef.value[index].fixed || undefined,
width: 150,
sorter: "default",
sorter: 'default',
renderSorterIcon: ({ order }) => {
if (order === false) return h(SvgIcon, { name: "sort-2" });
if (order === "ascend") return h(SvgIcon, { name: "sort-1" });
if (order === "descend") return h(SvgIcon, { name: "sort-3" });
if (order === false)
return h(SvgIcon, { name: 'sort-2' })
if (order === 'ascend')
return h(SvgIcon, { name: 'sort-1' })
if (order === 'descend')
return h(SvgIcon, { name: 'sort-3' })
},
render(row: any) {
return row.similarityscore ? `${row.similarityscore}%` : "";
return row.similarityscore ? `${row.similarityscore}%` : ''
},
};
}
}
index = columnsRef.value.findIndex((v) => v.title == "提报时间");
index = columnsRef.value.findIndex(v => v.title == '提报时间')
if (index > -1) {
columnsRef.value[index] = {
title: "提报时间",
key: columnsRef.value[index]["key"],
fixed: columnsRef.value[index]["fixed"] || undefined,
title: '提报时间',
key: columnsRef.value[index].key,
fixed: columnsRef.value[index].fixed || undefined,
width: 200,
sorter: "default",
sorter: 'default',
renderSorterIcon: ({ order }) => {
if (order === false) return h(SvgIcon, { name: "sort-2" });
if (order === "ascend") return h(SvgIcon, { name: "sort-1" });
if (order === "descend") return h(SvgIcon, { name: "sort-3" });
if (order === false)
return h(SvgIcon, { name: 'sort-2' })
if (order === 'ascend')
return h(SvgIcon, { name: 'sort-1' })
if (order === 'descend')
return h(SvgIcon, { name: 'sort-3' })
},
render(row: any) {
return formatToDateHMS(row.createdate || 0);
return formatToDateHMS(row.createdate || 0)
},
};
}
}
index = columnsRef.value.findIndex((v) => v.title == "更新时间");
index = columnsRef.value.findIndex(v => v.title == '更新时间')
if (index > -1) {
columnsRef.value[index] = {
title: "更新时间",
key: columnsRef.value[index]["key"],
fixed: columnsRef.value[index]["fixed"] || undefined,
title: '更新时间',
key: columnsRef.value[index].key,
fixed: columnsRef.value[index].fixed || undefined,
width: 200,
render(row: any) {
return row.updatetime ? formatToDateHMS(row.updatetime) : "";
return row.updatetime ? formatToDateHMS(row.updatetime) : ''
},
};
}
}
}
const deviceHeight = ref(600);
const deviceHeight = ref(600)
onMounted(() => {
emitter.on("filter-final", refreshHandler);
getColumns();
emitter.on('filter-final', refreshHandler)
getColumns()
nextTick(() => {
computeListHeight();
});
});
computeListHeight()
})
})
onBeforeMount(() => {
dicStore.fetchizstatusListt();
});
dicStore.fetchizstatusListt()
})
watch(
() => dicStore.izstatusList,
(newval) => {
izstatusList.value = newval;
}
);
izstatusList.value = newval
},
)
onUnmounted(() => {
emitter.off("filter-final", refreshHandler);
});
emitter.off('filter-final', refreshHandler)
})
const tableRef = ref<InstanceType<typeof NDataTable>>();
const rowKey = (row: RowData) => row.id;
const loading = ref(true);
const tableRef = ref<InstanceType<typeof NDataTable>>()
const rowKey = (row: RowData) => row.id
const loading = ref(true)
const pagination = reactive({
page: 1,
pageCount: 1,
pageSize: 10,
});
const tableData = ref<Array<RowData>>([]);
const selectionIds = ref<DataTableRowKey[]>([]);
const dialog = useDialog();
const message = useMessage();
const finalStore = useFinal();
})
const tableData = ref<Array<RowData>>([])
const selectionIds = ref<DataTableRowKey[]>([])
const dialog = useDialog()
const message = useMessage()
const finalStore = useFinal()
async function query(page: number, pageSize: number, filterId?: any) {
const asideParmas = unref(finalStore.getAsideValue);
const asideParmas = unref(finalStore.getAsideValue)
// 使使
const params = filterId ? { userSearchId: filterId } : asideParmas;
const params = filterId ? { userSearchId: filterId } : asideParmas
const result = await getFinalList({
sortorder: "asc",
sortorder: 'asc',
pageSize,
currPage: page,
sortname: "",
sortname: '',
...params,
});
const { data, pageCount } = result;
tableData.value = data;
console.log(data, "tableData");
pagination.page = page;
pagination.pageCount = pageCount;
loading.value = false;
})
const { data, pageCount } = result
tableData.value = data
console.log(data, 'tableData')
pagination.page = page
pagination.pageCount = pageCount
loading.value = false
}
async function handlePageChange(currentPage) {
if (loading.value) return;
if (loading.value)
return
const { pageSize } = pagination;
await query(currentPage, pageSize);
const { pageSize } = pagination
await query(currentPage, pageSize)
}
function handleCheck(rowKeys: DataTableRowKey[]) {
selectionIds.value = rowKeys;
selectionIds.value = rowKeys
}
async function computeListHeight() {
const table = unref(tableRef);
if (!table) return;
const tableEl: any = table?.$el;
const headEl = tableEl.querySelector(".n-data-table-thead ");
const { bottomIncludeBody } = getViewportOffset(headEl);
const headerH = 64;
let paginationH = 2;
const marginH = 60;
const table = unref(tableRef)
if (!table)
return
const tableEl: any = table?.$el
const headEl = tableEl.querySelector('.n-data-table-thead ')
const { bottomIncludeBody } = getViewportOffset(headEl)
const headerH = 64
let paginationH = 2
const marginH = 60
if (!isBoolean(unref(pagination))) {
const paginationEl = tableEl.querySelector(
".n-data-table__pagination"
) as HTMLElement;
'.n-data-table__pagination',
) as HTMLElement
if (paginationEl) {
const offsetHeight = paginationEl.offsetHeight;
paginationH += offsetHeight || 0;
} else {
paginationH += 28;
const offsetHeight = paginationEl.offsetHeight
paginationH += offsetHeight || 0
}
else {
paginationH += 28
}
}
let height = bottomIncludeBody - (headerH + paginationH + marginH);
const maxHeight = 800;
height = maxHeight && maxHeight < height ? maxHeight : height;
deviceHeight.value = height;
let height = bottomIncludeBody - (headerH + paginationH + marginH)
const maxHeight = 800
height = maxHeight && maxHeight < height ? maxHeight : height
deviceHeight.value = height
}
useWindowSizeFn(computeListHeight);
useWindowSizeFn(computeListHeight)
const maxHeight = computed(() => {
return tableData.value.length ? `${unref(deviceHeight)}px` : "auto";
});
return tableData.value.length ? `${unref(deviceHeight)}px` : 'auto'
})
query(pagination.page, pagination.pageSize);
query(pagination.page, pagination.pageSize)
const customTabelRef = ref(null);
const importExcelRef = ref(null);
const rejectModalRef = ref(null);
const repeatModalRef = ref(null);
const repeatTaskTableModalRef = ref(null);
const customTabelRef = ref(null)
const importExcelRef = ref(null)
const rejectModalRef = ref(null)
const repeatModalRef = ref(null)
const repeatTaskTableModalRef = ref(null)
function showModal(modalRef: any) {
const modal = unref(modalRef)! as any;
modal.showModal();
const modal = unref(modalRef)! as any
modal.showModal()
}
const popover = ref<ComponentRef | null>(null);
const popover = ref<ComponentRef | null>(null)
function importHandler() {
(popover.value as any).setShow(false);
showModal(importExcelRef);
(popover.value as any).setShow(false)
showModal(importExcelRef)
}
function exportHandler() {
loading.value = true;
import("@/utils/exportExcel").then((excel) => {
loading.value = true
import('@/utils/exportExcel').then((excel) => {
const tHeader = [
"任务Id",
"任务名称",
"审批节点",
"审批状态",
"图片相似度",
"提报时间",
"更新时间",
];
'任务Id',
'任务名称',
'审批节点',
'审批状态',
'图片相似度',
'提报时间',
'更新时间',
]
const filterVal = [
"id",
"name",
"approvalnode",
"approvalstatus",
"similarity",
"uptime",
"updatetime",
];
const list = tableData.value;
const data = formatJson(filterVal, list);
'id',
'name',
'approvalnode',
'approvalstatus',
'similarity',
'uptime',
'updatetime',
]
const list = tableData.value
const data = formatJson(filterVal, list)
excel.export_json_to_excel({
header: tHeader,
data,
filename: "data",
filename: 'data',
autoWidth: true,
bookType: "xlsx",
});
loading.value = false;
});
bookType: 'xlsx',
})
loading.value = false
})
}
function formatJson(filterVal, jsonDataList) {
return jsonDataList.map((v) =>
return jsonDataList.map(v =>
filterVal.map((j) => {
return v[j];
})
);
return v[j]
}),
)
}
function sucessHandler(excelData) {
const data = excelData.content.map((item) => {
const obj = {};
const obj = {}
Object.keys(item).forEach((key) => {
const k = findKey(columns, key);
obj[k] = item[key];
});
return obj;
});
const k = findKey(columns, key)
obj[k] = item[key]
})
return obj
})
tableData.value = data;
tableData.value = data
}
function commitHandler(columns) {
columnsRef.value = [
...columns,
actionsColumns
];
formatColumns();
actionsColumns,
]
formatColumns()
}
function actionHandler(action: any, row: any) {
const { key } = action;
const { key } = action
switch (key) {
case "view":
break;
case "reset":
resetHandler();
break;
case "approval":
approvalHandler(row);
break;
case "reject":
rejectHandler(row);
break;
case 'view':
break
case 'reset':
resetHandler()
break
case 'approval':
approvalHandler(row)
break
case 'reject':
rejectHandler(row)
break
default:
break;
break
}
}
// states:1234
function validate(items: any[]) {
if (items.length === 0) return "至少选中一个任务";
if (items.length === 0)
return '至少选中一个任务'
// const useInfo = userStore.getUserInfo
// const username = useInfo.loginname
@ -516,126 +529,148 @@ function validate(items: any[]) {
// return ''
// }
return null;
return null
}
function resetHandler() {
dialog.info({
title: "确认提示",
content: "确认重置当前选中的任务的审批吗?",
positiveText: "确定",
negativeText: "取消",
title: '确认提示',
content: '确认重置当前选中的任务的审批吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
// TODO
// const result = await resetApproval()
},
onNegativeClick: () => {},
});
})
}
function getSelectItems() {
return tableData.value.filter((item) => selectionIds.value.includes(item.id));
return tableData.value.filter(item => selectionIds.value.includes(item.id))
}
function approvalHandler(row) {
// const items = getSelectItems()
const items = [row];
const msg = validate(items);
const items = [row]
const msg = validate(items)
if (msg !== null) {
message.error(msg);
return;
message.error(msg)
return
}
dialog.info({
title: "确认提示",
content: "确认给该任务审批为【通过】吗?",
positiveText: "确定",
negativeText: "取消",
title: '确认提示',
content: '确认给该任务审批为【通过】吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: () => {
approval(items);
approval(items)
},
onNegativeClick: () => {},
});
})
}
function batchApproval() {
const items = getSelectItems()
const msg = validate(items)
if (msg !== null) {
message.error(msg)
return
}
dialog.info({
title: '确认提示',
content: '确认给该任务审批为【通过】吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: () => {
approval(items)
},
onNegativeClick: () => {},
})
}
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 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",
taskComment: 'approval',
taskname: tasknames,
};
}
doAudit(param);
doAudit(param)
}
function rejectHandler(row) {
// const items = getSelectItems()
const items = [row];
const msg = validate(items);
const items = [row]
const msg = validate(items)
if (msg !== null) {
message.error(msg);
return;
message.error(msg)
return
}
const modal = unref(rejectModalRef)! as any;
modal.showModal();
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 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 : ["其他"],
};
taskname: isOther ? tasknames : ['其他'],
}
doAudit(param);
doAudit(param)
}
function doAudit(param: any) {
audit(param).then((res) => {
const { code } = res;
if (code === "OK") reload();
else message.error(res.message);
});
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!);
const { page, pageSize } = unref(tableRef.value?.pagination) as PaginationProps
query(page!, pageSize!)
}
watch(
() => finalStore.asideValue,
(newVal, oldVal) => {
refreshHandler();
refreshHandler()
},
{ deep: true }
);
{ deep: true },
)
function reset() {
pagination.page = 1;
pagination.pageCount = 1;
pagination.pageSize = 1;
pagination.page = 1
pagination.pageCount = 1
pagination.pageSize = 1
}
async function refreshHandler(searchId?: any) {
reset();
query(pagination.page, pagination.pageSize, searchId);
reset()
query(pagination.page, pagination.pageSize, searchId)
}
</script>
@ -650,7 +685,7 @@ async function refreshHandler(searchId?: any) {
<n-button class="xjcc" text @click="showModal(repeatModalRef)">
小结查重
</n-button>
<div class="btn">
<div class="btn" @click="batchApproval">
<SvgIcon style="margin-right: 6px" size="14" name="tf" />
批量审批
</div>
@ -667,19 +702,13 @@ async function refreshHandler(searchId?: any) {
</template>
<ul class="wrapper-header-action">
<li @click="importHandler">
<SvgIcon size="20" name="download" /><span style="margin-left: 5px"
>批量导入数据</span
>
<SvgIcon size="20" name="download" /><span style="margin-left: 5px">批量导入数据</span>
</li>
<li @click="exportHandler">
<SvgIcon size="20" name="download" /><span style="margin-left: 5px"
>导出待审数据</span
>
<SvgIcon size="20" name="download" /><span style="margin-left: 5px">导出待审数据</span>
</li>
<li>
<SvgIcon size="20" name="download" /><span style="margin-left: 5px"
>导出全部数据</span
>
<SvgIcon size="20" name="download" /><span style="margin-left: 5px">导出全部数据</span>
</li>
</ul>
</n-popover>

Loading…
Cancel
Save