diff --git a/.vscode/settings.json b/.vscode/settings.json index 29677da..cc87c93 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,7 +42,7 @@ "vue3snippets.enable-compile-vue-file-on-did-save-code": true, "editor.defaultFormatter": "rvest.vs-code-prettier-eslint", "[vue]": { - "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" + "editor.defaultFormatter": "Wscats.vue" }, "editor.formatOnSaveMode": "modifications" } diff --git a/components.d.ts b/components.d.ts index 298dbe9..6458938 100644 --- a/components.d.ts +++ b/components.d.ts @@ -11,6 +11,7 @@ declare module 'vue' { BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default'] DataHeader: typeof import('./src/components/DataHeader/index.vue')['default'] NAvatar: typeof import('naive-ui')['NAvatar'] + NBackTop: typeof import('naive-ui')['NBackTop'] NButton: typeof import('naive-ui')['NButton'] NCard: typeof import('naive-ui')['NCard'] NCheckbox: typeof import('naive-ui')['NCheckbox'] @@ -21,8 +22,11 @@ declare module 'vue' { NDialogProvider: typeof import('naive-ui')['NDialogProvider'] NDivider: typeof import('naive-ui')['NDivider'] NDropdown: typeof import('naive-ui')['NDropdown'] + NEllipsis: typeof import('naive-ui')['NEllipsis'] + NEmpty: typeof import('naive-ui')['NEmpty'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] + NGi: typeof import('naive-ui')['NGi'] NGrid: typeof import('naive-ui')['NGrid'] NGridItem: typeof import('naive-ui')['NGridItem'] NImage: typeof import('naive-ui')['NImage'] @@ -31,6 +35,7 @@ declare module 'vue' { NModal: typeof import('naive-ui')['NModal'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] NotPassed: typeof import('./src/components/NotPassed.vue')['default'] + NPopconfirm: typeof import('naive-ui')['NPopconfirm'] NPopover: typeof import('naive-ui')['NPopover'] NPopselect: typeof import('naive-ui')['NPopselect'] NProgress: typeof import('naive-ui')['NProgress'] @@ -40,7 +45,11 @@ declare module 'vue' { NSpace: typeof import('naive-ui')['NSpace'] NSpin: typeof import('naive-ui')['NSpin'] NSwitch: typeof import('naive-ui')['NSwitch'] + NTabPane: typeof import('naive-ui')['NTabPane'] + NTabs: typeof import('naive-ui')['NTabs'] NTag: typeof import('naive-ui')['NTag'] + NTimeline: typeof import('naive-ui')['NTimeline'] + NTimelineItem: typeof import('naive-ui')['NTimelineItem'] NTooltip: typeof import('naive-ui')['NTooltip'] NUpload: typeof import('naive-ui')['NUpload'] NUploadDragger: typeof import('naive-ui')['NUploadDragger'] diff --git a/src/components/RichEditor/Quill.vue b/src/components/RichEditor/Quill.vue index cfda6a9..c87d0ef 100644 --- a/src/components/RichEditor/Quill.vue +++ b/src/components/RichEditor/Quill.vue @@ -53,7 +53,8 @@ const saveHandler = debounce(() => { 备注信息 { extraCustomConfig.push(key) }) -function showModal() { - show.value = true +function showModal(type: boolean = true) { + show.value = type // 重置左右列表数据 const config = finalStore.getSystemConfig const customConfig = finalStore.getCustomConfig if (config == null || customConfig == null) return + // 在现有基础上添加 关闭弹窗时重置数据 + if (!type) { + const { showList, hideList } = generatList(config, customConfig) + onList.value = showList + offList.value = hideList + // 重置全选状态 + checkAll.value = hideList.every(item => item.checked) + // 重置输入框查询条件 + offKeyword.value = '' + onKeyword.value = '' + return + } if (tempList.value.length > 0 && isEqual(tempList.value, finalStore.getFilterConfig)) return const { showList, hideList } = generatList(config, customConfig) @@ -221,6 +233,19 @@ async function handleSumbit(e: MouseEvent) { function onCheckAllChange(value) { const ids: string[] = [] + if (value) { + offList.value.forEach((v) => { + if (!v.checked) + onList.value.push(v) + }) + } + else { + onList.value = offList.value.filter(v => v.fix) + offList.value.map(v => ({ + ...v, + checked: v.fix, + })) + } for (const item of offList.value) { if (!item.fix) { @@ -228,7 +253,6 @@ function onCheckAllChange(value) { ids.push(item.id) } } - selectIds.value = value ? ids : [] } @@ -478,7 +502,7 @@ onMounted(() => { 取消 diff --git a/src/views/final/comp/CustomTabelModal.vue b/src/views/final/comp/CustomTabelModal.vue index 8361da7..b2580ee 100644 --- a/src/views/final/comp/CustomTabelModal.vue +++ b/src/views/final/comp/CustomTabelModal.vue @@ -3,7 +3,6 @@ import { difference } from 'lodash-es' import { computed, onMounted, ref, watch } from 'vue' import { VueDraggable } from 'vue-draggable-plus' import { getAllfieldList, getfieldList, savefield } from '@/api/home/filter' -import { ColumnsMap } from '@/config/final' import { useUser } from '@/store/modules/user' const props = defineProps({ @@ -39,8 +38,8 @@ onMounted(async () => { */ const userFieldFixed = useList.userFieldFixed?.split(',') const userFieldUnFixed = useList.userFieldUnFixed?.split(',') - const mustList = [] - allList?.map((v) => { + const mustList: any[] = [] + allList?.forEach((v) => { const item = { name: v.fieldDesc, id: v.name, @@ -73,67 +72,6 @@ const selectCount = computed(() => { return `显示字段(共${onList.value.length}个)` }) -function generatList() { - const keys = Object.keys(ColumnsMap) - // const showStr = 'name' - // const showKeys = showStr.split(',').map((key: string) => key.toLowerCase()) - - for (const key of keys) { - const { title, fixed, fixLeft, width } = ColumnsMap[key] - const item = { - id: key, - title, - fix: fixed, - checked: ColumnsMap[key].fixed, - width, - } - - if (!fixed) - offList.value.push(item) - - if (fixLeft) - fixLeftList.value.push(item) - } - - // showList = showKeys.reduce((acc, key) => { - // const config = { - // id: key, - // title: ColumnsMap[key].name || '未配置', - // fix: ColumnsMap[key].fixed, - // } - // return [...acc, config] - // }, []) - - const fixedList = generateDefaultList() - const filterList = fixedList.filter((item) => { - return !item.fixLeft - }) - - onList.value.unshift(...filterList) - offList.value.unshift(...fixedList) -} - -function generateDefaultList() { - return Object.keys(ColumnsMap).reduce((acc, key) => { - const { title, fixed, fixLeft, width } = ColumnsMap[key] - - if (fixed) { - const config = { - id: key, - title, - fix: true, - checked: true, - fixLeft, - width, - } - return [...acc, config] - } - else { - return acc - } - }, []) -} - const show = ref(false) const checkAll = ref(false) @@ -152,10 +90,10 @@ async function handleSumbit(e: MouseEvent) { const userInfo = userStore.getUserInfo let userFieldFixed = '' let userFieldUnFixed = '' - fixLeftList.value.map((v) => { + fixLeftList.value.forEach((v) => { userFieldFixed += `${v.id},` }) - onList.value.map((v) => { + onList.value.forEach((v) => { userFieldUnFixed += `${v.id},` }) userFieldFixed = userFieldFixed.slice(0, userFieldFixed.length - 1) @@ -207,7 +145,7 @@ function onCheckAllChange(value) { } } if (value) { - offList.value.map((v) => { + offList.value.forEach((v) => { if (!v.checked) onList.value.push(v) }) @@ -215,7 +153,7 @@ function onCheckAllChange(value) { else { onList.value = [] fixLeftList.value = [] - offList.value.map((v) => { + offList.value.forEach((v) => { if (v.fix) fixLeftList.value.push(v) }) @@ -330,21 +268,21 @@ function removeHandler(id: string, type: 'fix' | 'unfix') { offList.value[index].checked = false } else { - index == fixLeftList.value.findIndex(v => v.id == id) + index = fixLeftList.value.findIndex(v => v.id == id) fixLeftList.value[index].checked = false } } const indeterminate = computed(() => { - let baseNum = 0 - offList.value.map((v) => { - if (v.fix) - baseNum += 1 - }) return ( - onList.value.length + fixLeftList.value.length - baseNum > 0 - && offList.value.length - baseNum - > onList.value.length + fixLeftList.value.length - baseNum + onList.value.length + + fixLeftList.value.length + - offList.value.filter(v => v.fix).length + > 0 + && offList.value.length - offList.value.filter(v => v.fix).length + > onList.value.length + + fixLeftList.value.length + - offList.value.filter(v => v.fix).length ) }) @@ -553,8 +491,7 @@ const indeterminate = computed(() => { .textbtnStyle { cursor: pointer; - color: #507AFD; - + color: #507afd; } .drag-wrapper { @@ -615,7 +552,7 @@ const indeterminate = computed(() => { ::v-deep(.n-button--info-type) { background: #507afd !important; } -::v-deep(.n-button--default-type){ +::v-deep(.n-button--default-type) { border: 1px solid #cad2dd !important; } // ::v-deep(.n-card__content){ diff --git a/src/views/final/comp/FilterModal.vue b/src/views/final/comp/FilterModal.vue index 0ee4b3a..a66639b 100644 --- a/src/views/final/comp/FilterModal.vue +++ b/src/views/final/comp/FilterModal.vue @@ -166,20 +166,20 @@ function handleCheck(rowKeys: DataTableRowKey[]) { } function select(key: number, id: string) { - if (key == 1) { + if (key == 1) editSelection(id) - } - else { - const modalInst = modal.create({ - title: '确认提示', - content: '确认删除该条过滤条件吗?', - positiveText: '确定', - negativeText: '取消', - preset: 'dialog', - onPositiveClick: () => deleteSelection(id), - onNegativeClick: () => modalInst.destroy(), - }) - } + + else + deleteSelection(id) + // const modalInst = modal.create({ + // title: "确认提示", + // content: "确认删除该条过滤条件吗?", + // positiveText: "确定", + // negativeText: "取消", + // preset: "dialog", + // onPositiveClick: () => deleteSelection(id), + // onNegativeClick: () => modalInst.destroy(), + // }); } function editSelection(id = '') { diff --git a/src/views/final/comp/NewFilterModal.vue b/src/views/final/comp/NewFilterModal.vue index 0700ec1..2d30431 100644 --- a/src/views/final/comp/NewFilterModal.vue +++ b/src/views/final/comp/NewFilterModal.vue @@ -302,6 +302,7 @@ defineExpose({ v-model:value="formValue.name" :style="{ width: '780px' }" placeholder="请输入过滤名称" + maxlength="15" @keydown.enter.prevent /> diff --git a/src/views/final/content/Content.vue b/src/views/final/content/Content.vue index 0dd543c..e1b055a 100644 --- a/src/views/final/content/Content.vue +++ b/src/views/final/content/Content.vue @@ -3,8 +3,8 @@ import type { DataTableColumns, DataTableRowKey, PaginationProps, -} from "naive-ui"; -import { NButton, NDataTable, useDialog, useMessage } from "naive-ui"; +} from 'naive-ui' +import { NButton, NDataTable, useDialog, useMessage } from 'naive-ui' import { computed, defineEmits, @@ -17,11 +17,11 @@ import { ref, unref, watch, -} from "vue"; -import { rowPropKeys } from "naive-ui/es/legacy-grid/src/Row"; -import { useRoute, useRouter } from "vue-router"; -import dayjs from "dayjs"; -import { cloneDeep } from "lodash-es"; +} from 'vue' +import { rowPropKeys } from 'naive-ui/es/legacy-grid/src/Row' +import { useRoute, useRouter } from 'vue-router' +import dayjs from 'dayjs' +import { cloneDeep } from 'lodash-es' import { CustomTabelModal, ImportExcelModal, @@ -29,55 +29,55 @@ import { RepeatModal, RepeatTaskTableModal, StatusItem, -} 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 NotPassed from "@/components/Approval/NotPassed.vue"; -import type { ApprovalParam } from "/#/api"; -import emitter from "@/utils/mitt"; -import { formatToDateHMS } from "@/utils/dateUtil"; -import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter"; -import DataHeader from "@/components/DataHeader/index.vue"; - -const emit = defineEmits(["changeShow"]); +} 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 NotPassed from '@/components/Approval/NotPassed.vue' +import type { ApprovalParam } from '/#/api' +import emitter from '@/utils/mitt' +import { formatToDateHMS } from '@/utils/dateUtil' +import { getAllfieldList, getfieldList, savefield } from '@/api/home/filter' +import DataHeader from '@/components/DataHeader/index.vue' + +const emit = defineEmits(['changeShow']) function changeContent() { - emit("changeShow"); + emit('changeShow') } -const checkedRowKeys = ref([]); -const dicStore = useDictionary(); -const izstatusList = ref([]); -const router = useRouter(); -const route = useRoute(); -const reviewType = 0; -const sortorder = ref("asc"); -const sortname = ref("states"); -const searchContent = route.query.searchContent as string; +const checkedRowKeys = ref([]) +const dicStore = useDictionary() +const izstatusList = ref([]) +const router = useRouter() +const route = useRoute() +const reviewType = 0 +const sortorder = ref('asc') +const sortname = ref('states') +const searchContent = route.query.searchContent as string const actionsColumns = { - title: "操作", - key: "actions", + title: '操作', + key: 'actions', minWidth: 200, width: 200, - fixed: "right", + fixed: 'right', render(row) { return h(ListAction, { id: row.id, status: row.states, trigger: (action) => { - actionHandler(action, row); + actionHandler(action, row) }, - }); + }) }, -}; -const columnsRef = ref>([]); +} +const columnsRef = ref>([]) // const columns: DataTableColumns = [ // { // type: "selection", @@ -177,56 +177,57 @@ const columnsRef = ref>([]); async function getColumns() { columnsRef.value = [ { - type: "selection", - fixed: "left", + type: 'selection', + fixed: 'left', width: 50, disabled(row: any) { - return row.states !== 2; + return row.states !== 2 }, }, - ]; - - 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(","); + ] + + 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(',') if (!userFieldFixed?.length && !userFieldUnFixed?.length) { allList?.map((v) => { if (v.isrequired == 2) { columnsRef.value.push({ title: v.fieldDesc, - fixed: "left", + fixed: 'left', key: v.name, width: 120, - }); + }) } - return v; - }); - } else { + return v + }) + } + else { userFieldFixed.map((v) => { - const item = allList.find((v2) => v2.name == v); + const item = allList.find(v2 => v2.name == v) columnsRef.value.push({ title: item.fieldDesc, key: item.name, - fixed: "left", + fixed: 'left', width: 120, - }); - return v; - }); + }) + return v + }) userFieldUnFixed.map((v) => { - const item = allList.find((v2) => v2.name == v); + const item = allList.find(v2 => v2.name == v) columnsRef.value.push({ title: item.fieldDesc, key: item.name, width: 120, - }); - return v; - }); + }) + return v + }) } // TODO: 会导致排序问题 废弃 // #region @@ -260,185 +261,194 @@ async function getColumns() { // }); // #endregion - columnsRef.value.push(actionsColumns as any); - formatColumns(); + columnsRef.value.push(actionsColumns as any) + formatColumns() } async function formatColumns() { // TODO处理特殊字段 - let index; - index = columnsRef.value.findIndex((v) => v.title == "任务ID"); + let index + index = columnsRef.value.findIndex(v => v.title == '任务ID') if (index > -1) { columnsRef.value[index] = { - title: "任务ID", + title: '任务ID', key: columnsRef.value[index].key, // "id" fixed: columnsRef.value[index].fixed || undefined, width: 200, render(row) { const item: any = izstatusList.value.find( - (item: any) => item.value == row.states - ); + (item: any) => item.value == row.states, + ) return h( NButton, { - strong: true, + 'strong': true, // 'tertiary': true, - text: true, - size: "small", - "text-color": "#507AFD", - onClick: () => goDetail(row), + 'text': true, + 'size': 'small', + 'text-color': '#507AFD', + 'onClick': () => goDetail(row), }, - { default: () => row.fromtaskid } - ); + { default: () => row.fromtaskid }, + ) }, - }; + } } - index = columnsRef.value.findIndex((v) => v.title == "所属项目"); + index = columnsRef.value.findIndex(v => v.title == '所属项目') if (index > -1) { columnsRef.value[index] = { - title: "所属项目", + 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: "任务名称", + 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: "审批状态", + title: '审批状态', key: columnsRef.value[index].key, fixed: columnsRef.value[index].fixed || undefined, width: 120, - 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) { const item: any = izstatusList.value.find( - (item: any) => item.value == row.states - ); + (item: any) => item.value == row.states, + ) return h(StatusItem, { id: row.id, status: row.states, - label: item ? item.label : "", - }); + label: item ? item.label : '', + }) }, - }; + } } - index = columnsRef.value.findIndex((v) => v.title == "图片相似度"); + index = columnsRef.value.findIndex(v => v.title == '图片相似度') if (index > -1) { columnsRef.value[index] = { - title: "图片相似度", + 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 h( - "div", + 'div', { id: row.id, - style: { color: row.similarityscore === 100 ? "#FF4E4F" : "" }, + style: { color: row.similarityscore === 100 ? '#FF4E4F' : '' }, }, { default: () => - row.similarityscore ? `${row.similarityscore}%` : "", - } - ); + 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: "提报时间", + 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.fromuptime || 0); + return formatToDateHMS(row.fromuptime || 0) }, - }; + } } - index = columnsRef.value.findIndex((v) => v.title == "提报人"); + index = columnsRef.value.findIndex(v => v.title == '提报人') if (index > -1) { columnsRef.value[index] = { - title: "提报人", + title: '提报人', key: columnsRef.value[index].key, fixed: columnsRef.value[index].fixed || undefined, width: 200, render(row: any) { - return row.fromusername; + return row.fromusername }, - }; + } } - index = columnsRef.value.findIndex((v) => v.title == "更新时间"); + index = columnsRef.value.findIndex(v => v.title == '更新时间') if (index > -1) { columnsRef.value[index] = { - title: "更新时间", + 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) 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>(); -const rowKey = (row: RowData) => row.id; -const loading = ref(true); -const total = ref(0); +const tableRef = ref>() +const rowKey = (row: RowData) => row.id +const loading = ref(true) +const total = ref(0) const pagination = reactive({ page: 1, pageCount: 10, @@ -446,62 +456,62 @@ const pagination = reactive({ showSizePicker: true, pageSizes: [ { - label: "10 每页", + label: '10 每页', value: 10, }, { - label: "15 每页", + label: '15 每页', value: 15, }, { - label: "30 每页", + label: '30 每页', value: 30, }, { - label: "50 每页", + label: '50 每页', value: 50, }, ], showQuickJumper: true, prefix: () => `共 ${total.value} 条数据`, -}); -const tableData = ref>([]); -const selectionIds = ref([]); -const dialog = useDialog(); -const message = useMessage(); -const finalStore = useFinal(); +}) +const tableData = ref>([]) +const selectionIds = ref([]) +const dialog = useDialog() +const message = useMessage() +const finalStore = useFinal() async function query( page: number, pageSize: number, filterId?: any, - taskName?: string + taskName?: string, ) { - console.log("query", taskName); - const asideParmas = cloneDeep(unref(finalStore.getAsideValue)); - // console.log(asideParmas); + console.log('query', taskName) + const asideParmas = cloneDeep(unref(finalStore.getAsideValue)) + // console.log(asideParmas); if (asideParmas.izyear) { - asideParmas.izuptime = cloneDeep(asideParmas.izyear); - if (typeof asideParmas.izuptime == "object") { + asideParmas.izuptime = cloneDeep(asideParmas.izyear) + if (typeof asideParmas.izuptime == 'object') { asideParmas.izuptime[0] = dayjs(asideParmas.izuptime[0]).format( - "YYYY/MM/DD" - ); + 'YYYY/MM/DD', + ) asideParmas.izuptime[1] = dayjs(asideParmas.izuptime[1]).format( - "YYYY/MM/DD" - ); - asideParmas.izuptime = asideParmas.izuptime.join("-"); - delete asideParmas.izyear; + 'YYYY/MM/DD', + ) + asideParmas.izuptime = asideParmas.izuptime.join('-') + delete asideParmas.izyear } } // 有过滤配置的时候优先使用过滤配置,不要使用左侧参数 // let params = filterId ? { userSearchId: filterId } : asideParmas - let params = asideParmas; - if(params?.izshowall==false){ - params.isFail=false - } - params = params?.izshowall ? {isFail:true} : params; + let params = asideParmas + if (params?.izshowall == false) + params.isFail = false + + params = params?.izshowall ? { isFail: true } : params const result = await getFinalList({ sortorder: sortorder.value, @@ -510,232 +520,241 @@ async function query( sortname: sortname.value, taskName, ...params, - }); - const { data, pageCount, totalCount } = result; - tableData.value = data; - total.value = totalCount; - pagination.page = page; - pagination.pageCount = Math.ceil(totalCount / pageSize); - loading.value = false; + }) + const { data, pageCount, totalCount } = result + tableData.value = data + total.value = totalCount + pagination.page = page + pagination.pageCount = Math.ceil(totalCount / pageSize) + loading.value = false } async function handleSorterChange(value) { - let name = value.columnKey; - if (name === "fromuptime") name = "submit_date_timestamp"; - else if (name === "similarityscore") name = "similarity_score"; - else if (name === "fromusername") name = "fromuserid"; - - sortname.value = name; - sortorder.value = value.order === "ascend" ? "asc" : "desc"; - refreshHandler(); + let name = value.columnKey + if (name === 'fromuptime') + name = 'submit_date_timestamp' + else if (name === 'similarityscore') + name = 'similarity_score' + else if (name === 'fromusername') + name = 'fromuserid' + + sortname.value = name + sortorder.value = value.order === 'ascend' ? 'asc' : 'desc' + refreshHandler() } async function handlePageChange(currentPage) { - if (loading.value) return; - const { pageSize } = pagination; - pagination.page = currentPage; - await query(currentPage, pageSize); + if (loading.value) + return + const { pageSize } = pagination + pagination.page = currentPage + await query(currentPage, pageSize) } async function handlePageSizeChange(currentPageSize) { - if (loading.value) return; + if (loading.value) + return - const { page } = pagination; - pagination.pageSize = currentPageSize; + const { page } = pagination + pagination.pageSize = currentPageSize - await query(page, currentPageSize); + await query(page, currentPageSize) } 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' +}) const scrollX = computed(() => { - const table = unref(tableRef); - if (!table) return; - const tableEl: any = table?.$el; - const wrapper = tableEl.querySelector(".n-data-table-wrapper"); + const table = unref(tableRef) + if (!table) + return + const tableEl: any = table?.$el + const wrapper = tableEl.querySelector('.n-data-table-wrapper') // const arr = columnsRef.value.filter(item => !item.fixed) - let width = 0; + let width = 0 columnsRef.value.forEach((item) => { - width += Number(item.width) || 200; - }); + width += Number(item.width) || 200 + }) - return width; -}); -const customTabelRef = ref(null); -const importExcelRef = ref(null); -const notPassModalRef = ref(null); // 不通过弹窗 -const repeatModalRef = ref(null); -const repeatTaskTableModalRef = ref(null); + return width +}) +const customTabelRef = ref(null) +const importExcelRef = ref(null) +const notPassModalRef = 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(null); +const popover = ref(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 = [ - "pictureid", - "name", - "approvalnode", - "approvalstatus", - "similarity", - "uptime", - "updatetime", - ]; - const list = tableData.value; - const data = formatJson(filterVal, list); + 'pictureid', + '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(); + columnsRef.value = [...columns, actionsColumns] + formatColumns() } function actionHandler(action: any, row: any) { - const { key } = action; + const { key } = action switch (key) { - case "view": - goDetail(row); - break; - case "reset": - resetHandler(); - break; - case "approval": - singleApproval(row); - break; - case "reject": - rejectHandler([row]); - break; + case 'view': + goDetail(row) + break + case 'reset': + resetHandler() + break + case 'approval': + singleApproval(row) + break + case 'reject': + rejectHandler([row]) + break default: - break; + break } } // states:1未提交,2待审批,3通过,4不通过 function validate(items: any[]) { - if (items.length === 0) return "至少选中一个任务"; - return null; + if (items.length === 0) + return '至少选中一个任务' + return null } function goDetail(row) { router.push({ - name: "final-detail", + name: 'final-detail', query: { id: row.id, packageid: row.packageid }, - }); + }) } 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)) } const showActions = computed(() => { - return selectionIds.value.length; -}); + return selectionIds.value.length +}) // 单个审批通过 function singleApproval(row) { const param = { result: true, - comment: "", - disposeType: "", - disposeTypeId: "", - failCauseId: "", - failCauseName: "", + comment: '', + disposeType: '', + disposeTypeId: '', + failCauseId: '', + failCauseName: '', flowTaskInfoList: [ { formId: row.id, @@ -743,139 +762,142 @@ function singleApproval(row) { taskName: row.fromTaskName, }, ], - }; - doAudit(param); + } + doAudit(param) } // 批量通过 function batchApproval() { - const items: any = getSelectItems(); - const msg = validate(items); + const items: any = getSelectItems() + const msg = validate(items) if (msg !== null) { - message.error(msg); - return; + message.error(msg) + return } - console.log(items); - const list: any = []; + console.log(items) + const list: any = [] items.forEach((item) => { list.push({ formId: item.id, taskId: item.taskId, taskName: item.fromtaskname, - }); - }); + }) + }) const param = { result: true, - comment: "", - disposeType: "", - disposeTypeId: "", - failCauseId: "", - failCauseName: "", + comment: '', + disposeType: '', + disposeTypeId: '', + failCauseId: '', + failCauseName: '', flowTaskInfoList: list, - }; + } - doAudit(param); + doAudit(param) } // 小结批量不通过 function repeatBatchReject(items) { - console.log(items); - rejectHandler(items); + console.log(items) + rejectHandler(items) } // 批量不通过 function batchReject() { - const items: any = getSelectItems(); - rejectHandler(items); + const items: any = getSelectItems() + rejectHandler(items) } // 审核不通过 function rejectHandler(list) { - const msg = validate(list); + const msg = validate(list) if (msg !== null) { - message.error(msg); - return; + message.error(msg) + return } - const modal = unref(notPassModalRef)! as any; - modal.showModal(list); + const modal = unref(notPassModalRef)! as any + modal.showModal(list) } // 审核通过 function doAudit(param: any) { dialog.info({ - title: "确认提示", - content: "确认给该任务审批为【通过】吗?", - positiveText: "确定", - negativeText: "取消", + title: '确认提示', + content: '确认给该任务审批为【通过】吗?', + positiveText: '确定', + negativeText: '取消', onPositiveClick: () => { audit(param).then((res) => { - const { code } = res; - if (code === "OK") { - message.success(res.message); - reload(); - } else { - message.error(res.message); + const { code } = res + if (code === 'OK') { + message.success(res.message) + reload() + } + else { + message.error(res.message) } - }); + }) }, onNegativeClick: () => {}, - }); + }) } function switchBatch() { - selectionIds.value = []; - checkedRowKeys.value = []; + selectionIds.value = [] + checkedRowKeys.value = [] } function reload() { - selectionIds.value = []; - checkedRowKeys.value = []; + selectionIds.value = [] + checkedRowKeys.value = [] const { page, pageSize } = unref( - tableRef.value?.pagination - ) as PaginationProps; - query(page!, pageSize!); + tableRef.value?.pagination, + ) as PaginationProps + query(page!, pageSize!) } watch( () => finalStore.asideValue, (newVal, oldVal) => { - refreshHandler(); + refreshHandler() }, - { deep: true } -); + { deep: true }, +) watch( () => finalStore.listKey, (newVal, oldVal) => { - refreshHandler(); - } -); + refreshHandler() + }, +) function reset() { - pagination.page = 1; - pagination.pageCount = 1; + pagination.page = 1 + pagination.pageCount = 1 } async function refreshHandler(searchId?: any) { - reset(); - let searchKeyword = ""; + reset() + let searchKeyword = '' if (searchContent) { - const id_param = searchContent.match(/-\d+-/); - if (id_param) searchKeyword = id_param[0].slice(1, -1); + const id_param = searchContent.match(/-\d+-/) + if (id_param) + searchKeyword = id_param[0].slice(1, -1) } - console.log("refreshHandler", searchKeyword); - query(pagination.page, pagination.pageSize, searchId, searchKeyword); + console.log('refreshHandler', searchKeyword) + query(pagination.page, pagination.pageSize, searchId, searchKeyword) } function filterTableData(keyword) { - pagination.page = 1; - pagination.pageSize = 10; - if (keyword) query(pagination.page, pagination.pageSize, "", keyword); - else query(pagination.page, pagination.pageSize); + pagination.page = 1 + pagination.pageSize = 10 + if (keyword) + query(pagination.page, pagination.pageSize, '', keyword) + else query(pagination.page, pagination.pageSize) } async function initData(pageSize, page) { const result = await getFinalList({ @@ -883,34 +905,35 @@ async function initData(pageSize, page) { pageSize, currPage: page, sortname: sortname.value, - }); - const { data, pageCount, totalCount } = result; - tableData.value = data; - total.value = totalCount; - pagination.page = page; - pagination.pageCount = Math.ceil(totalCount / pageSize); - loading.value = false; + }) + const { data, pageCount, totalCount } = result + tableData.value = data + total.value = totalCount + pagination.page = page + pagination.pageCount = Math.ceil(totalCount / pageSize) + loading.value = false } onMounted(() => { // query(pagination.page, pagination.pageSize); - const asideParmas = cloneDeep(unref(finalStore.getAsideValue)); - console.log(asideParmas); - emitter.on("filter-final", refreshHandler); - getColumns(); + const asideParmas = cloneDeep(unref(finalStore.getAsideValue)) + console.log(asideParmas) + emitter.on('filter-final', refreshHandler) + getColumns() if (asideParmas == null) { - initData(10, 1); - } else { - reset(); + initData(10, 1) + } + else { + reset() filterTableData() } - //alert(1) + // alert(1) nextTick(() => { - computeListHeight(); - }); -}); + computeListHeight() + }) +}) defineExpose({ filterTableData, -}); +})