fix: update

bak
elseif 1 year ago
parent 8979379156
commit d87761a1b5

@ -1,14 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getAllfieldList, getfieldList } from '@/api/home/filter' import { chunk, clone } from 'lodash-es'
import { audit } from '@/api/task/task'
import { getTaskDetailInfo, getTaskDetailPictureList } from '@/api/work/work'
import { useTask } from '@/store/modules/task'
import { useUser } from '@/store/modules/user'
import { isEmpty } from '@/utils'
import { hideDownload } from '@/utils/image'
import emitter from '@/utils/mitt'
import _ from 'lodash'
import { clone } from 'lodash-es'
import { useDialog, useMessage } from 'naive-ui' import { useDialog, useMessage } from 'naive-ui'
import { computed, onUnmounted, reactive, ref, unref, watch } from 'vue' import { computed, onUnmounted, reactive, ref, unref, watch } from 'vue'
import BatchModal from '../modal/BatchModal.vue' import BatchModal from '../modal/BatchModal.vue'
@ -16,18 +7,18 @@ import ConfrimModal from '../modal/ConfrimModal.vue'
import CustomSettingModal from '../modal/CustomSettingModal.vue' import CustomSettingModal from '../modal/CustomSettingModal.vue'
import PictureTable from './PictureTable.vue' import PictureTable from './PictureTable.vue'
import TaskTable from './TaskTable.vue' import TaskTable from './TaskTable.vue'
import { getAllfieldList } from '@/api/home/filter'
import { audit } from '@/api/task/task'
import { getTaskDetailInfo, getTaskDetailPictureList } from '@/api/work/work'
import { useTask } from '@/store/modules/task'
import { useUser } from '@/store/modules/user'
import { isEmpty } from '@/utils'
import { hideDownload } from '@/utils/image'
import emitter from '@/utils/mitt' import emitter from '@/utils/mitt'
import { hideDownload } from '@/utils/image'
import { isEmpty } from '@/utils'
import { useUser } from '@/store/modules/user'
import { useTask } from '@/store/modules/task'
import { getTaskDetailInfo, getTaskDetailPictureList } from '@/api/work/work'
import { audit } from '@/api/task/task'
import { getAllfieldList, getfieldList } from '@/api/home/filter'
import type { ApprovalParam, PictureSortParam } from '/#/api' import type { ApprovalParam, PictureSortParam } from '/#/api'
import { formatToDateHMS } from '@/utils/dateUtil' import { formatToDateHMS } from '@/utils/dateUtil'
const batch = ref(false) const batch = ref(false)
const selectItems = ref<any[]>([]) const selectItems = ref<any[]>([])
const message = useMessage() const message = useMessage()
@ -39,47 +30,54 @@ const CustomSettingModalRef = ref(null)
const taskTableData = ref<any[]>([]) const taskTableData = ref<any[]>([])
const sortBy: PictureSortParam = { const sortBy: PictureSortParam = {
orderbyname: "asc", orderbyname: 'desc',
orderbyvalue: "fromuptime", orderbyvalue: 'pictureResult',
}; }
function setBatch(value: boolean) { function setBatch(value: boolean) {
if (totalCount.value === 0) return; if (totalCount.value === 0)
return
batch.value = value
batch.value = value;
if (value === false) { if (value === false) {
selectItems.value.forEach((item) => (item.checked = false)); selectItems.value.forEach(item => (item.checked = false))
selectItems.value.length = 0; selectItems.value.length = 0
selectItems.value.length = 0
} }
} }
function onCheckChange(checked: any, item: any) { function onCheckChange(checked: any, item: any) {
const index = selectItems.value.indexOf(item); const index = selectItems.value.indexOf(item)
item.checked = checked; item.checked = checked
if (index === -1 && checked) selectItems.value.push(item); if (index === -1 && checked)
else selectItems.value.splice(index, 1); selectItems.value.push(item)
else selectItems.value.splice(index, 1)
console.log(selectItems.value.map(item => item.id))
} }
const showActions = computed(() => { const showActions = computed(() => {
return selectItems.value.length > 0 && batch; return selectItems.value.length > 0 && batch
}); })
const taskpagination = reactive({ const taskpagination = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
}); })
const taskStore = useTask(); const taskStore = useTask()
const overTask = ref<any>(null); const overTask = ref<any>(null)
const taskDetailInfo = ref<any>({}); const taskDetailInfo = ref<any>({})
const taskDetailPictureList = ref<any[]>([]); const taskDetailPictureList = ref<any[]>([])
const userStore = useUser(); const userStore = useUser()
const imageRef = ref<ComponentElRef | null>(); const imageRef = ref<ComponentElRef | null>()
let processItems: any[] = []; let processItems: any[] = []
// states:1234 // states:1234
function validate(items: any[]) { function validate(items: any[]) {
if (items.length === 0) return "至少选中一个任务"; if (items.length === 0)
return '至少选中一个任务'
// const useInfo = userStore.getUserInfo // const useInfo = userStore.getUserInfo
// const username = useInfo.loginname // const username = useInfo.loginname
@ -96,115 +94,118 @@ function validate(items: any[]) {
// return '' // return ''
// } // }
return null; return null
} }
function approvalHandler(items?: any) { function approvalHandler(items?: any) {
let cloneItem: any; let cloneItem: any
if (batch.value) { if (batch.value) {
processItems = selectItems.value; processItems = selectItems.value
} else if (overTask.value) { }
cloneItem = clone(overTask.value); else if (overTask.value) {
processItems = [cloneItem]; cloneItem = clone(overTask.value)
processItems = [cloneItem]
} }
if (items !== undefined && !(items instanceof PointerEvent)) if (items !== undefined && !(items instanceof PointerEvent))
processItems = items; processItems = items
const msg = validate(processItems); const msg = validate(processItems)
if (msg !== null) { if (msg !== null) {
message.error(msg); message.error(msg)
return; return
} }
dialog.info({ dialog.info({
title: "确认提示", title: '确认提示',
content: "确认给该任务审批为【通过】吗?", content: '确认给该任务审批为【通过】吗?',
positiveText: "确定", positiveText: '确定',
negativeText: "取消", negativeText: '取消',
onPositiveClick: () => { onPositiveClick: () => {
approval(); approval()
}, },
onNegativeClick: () => {}, onNegativeClick: () => {},
}); })
} }
function rejectHandler(items?: any) { function rejectHandler(items?: any) {
let cloneItem: any; let cloneItem: any
if (batch.value) { if (batch.value) {
processItems = selectItems.value; processItems = selectItems.value
} else if (overTask.value) { }
cloneItem = clone(overTask.value); else if (overTask.value) {
processItems = [cloneItem]; cloneItem = clone(overTask.value)
processItems = [cloneItem]
} }
if (items !== undefined && !(items instanceof PointerEvent)) if (items !== undefined && !(items instanceof PointerEvent))
processItems = items; processItems = items
const msg = validate(processItems); const msg = validate(processItems)
if (msg !== null) { if (msg !== null) {
message.error(msg); message.error(msg)
return; return
} }
const modal = unref(confrimModalRef)! as any; const modal = unref(confrimModalRef)! as any
modal.showModal(); modal.showModal()
} }
function approval() { function approval() {
const formIds: string[] = processItems.map((item) => item.id); const formIds: string[] = processItems.map(item => item.id)
const taskIds: string[] = processItems.map((item) => item.taskId); const taskIds: string[] = processItems.map(item => item.taskId)
const tasknames: string[] = processItems.map((item) => item.taskname); const tasknames: string[] = processItems.map(item => item.taskname)
const param: ApprovalParam = { const param: ApprovalParam = {
formid: formIds, formid: formIds,
taskId: taskIds, taskId: taskIds,
approvd: true, approvd: true,
taskComment: "approval", taskComment: 'approval',
taskname: tasknames, taskname: tasknames,
}; }
doAudit(param); doAudit(param)
} }
function doAudit(param: any) { function doAudit(param: any) {
audit(param).then((res) => { audit(param).then((res) => {
const { code } = res; const { code } = res
processItems.length = 0; setBatch(false)
if (code === "OK") emitter.emit("refresh"); if (code === 'OK')
else message.error(res.message); emitter.emit('refresh')
}); else message.error(res.message)
})
} }
function reject(idOrDesc: string, backId: string, isOther: boolean) { function reject(idOrDesc: string, backId: string, isOther: boolean) {
const formIds: string[] = processItems.map((item) => item.id); const formIds: string[] = processItems.map(item => item.id)
const taskIds: string[] = processItems.map((item) => item.taskId); const taskIds: string[] = processItems.map(item => item.taskId)
const tasknames: string[] = processItems.map((item) => item.taskname); const tasknames: string[] = processItems.map(item => item.taskname)
const param: ApprovalParam = { const param: ApprovalParam = {
formid: formIds, formid: formIds,
taskId: taskIds, taskId: taskIds,
approvd: false, approvd: false,
taskComment: idOrDesc, taskComment: idOrDesc,
taskname: isOther ? tasknames : ["其他"], taskname: isOther ? tasknames : ['其他'],
}; }
doAudit(param); doAudit(param)
} }
function showModal(modalRef: any) { function showModal(modalRef: any) {
const modal = unref(modalRef)! as any; const modal = unref(modalRef)! as any
modal.showModal(); modal.showModal()
} }
function forwardHandler() { function forwardHandler() {
taskStore.forward(); taskStore.forward()
} }
function backHandler() { function backHandler() {
taskStore.back(); taskStore.back()
} }
watch( watch(
@ -213,27 +214,28 @@ watch(
const packageid = taskStore.getPackageid const packageid = taskStore.getPackageid
const taskId = taskStore.getActiveId const taskId = taskStore.getActiveId
if (isEmpty(taskId)) return; if (isEmpty(taskId))
const useInfo = userStore.getUserInfo; return
const useInfo = userStore.getUserInfo
let listData = [];
taskDetailInfo.value = await getTaskDetailInfo(taskId, packageid); const listData = []
const reviewType = 3; // taskDetailInfo.value = await getTaskDetailInfo(taskId, packageid)
let res = await getAllfieldList(reviewType); const reviewType = 3 //
let fieldList = (res as any)?.data; let res = await getAllfieldList(reviewType)
res = await getfieldList(reviewType, useInfo.id); const fieldList = (res as any)?.data
let userFieldList = (res as any)?.data.userFieldFixed; res = await getfieldList(reviewType, useInfo.id)
console.log(userFieldList,'userFieldList') const userFieldList = (res as any)?.data.userFieldFixed
console.log(userFieldList, 'userFieldList')
fieldList.map((v) => { fieldList.map((v) => {
if (userFieldList.indexOf(v.name) > -1) { if (userFieldList.includes(v.name)) {
let item = { const item = {
label: v.fieldDesc, label: v.fieldDesc,
value: taskDetailInfo.value.ocrPicture[v.name], value: taskDetailInfo.value.ocrPicture[v.name],
key: v.name, key: v.name,
}; }
listData.push(item); listData.push(item)
} }
}); })
// TODO mock // TODO mock
// let showFieldData = taskDetailInfo.value.ocrPicture; // let showFieldData = taskDetailInfo.value.ocrPicture;
// let showFieldKeys = Object.keys(showFieldData); // let showFieldKeys = Object.keys(showFieldData);
@ -254,7 +256,7 @@ watch(
// } // }
// } // }
// } // }
taskTableData.value = _.chunk(listData, 2); taskTableData.value = chunk(listData, 2)
if (!isEmpty(packageid)) { if (!isEmpty(packageid)) {
const { data, total } = await getTaskDetailPictureList( const { data, total } = await getTaskDetailPictureList(
packageid, packageid,
@ -264,56 +266,57 @@ watch(
taskDetailPictureList.value = data taskDetailPictureList.value = data
totalCount.value = total totalCount.value = total
} }
} },
); )
const currentTaskId = computed(() => { const currentTaskId = computed(() => {
const index = taskStore.getCurrentIndex; const index = taskStore.getCurrentIndex
return taskStore.getApprovalList[index]?.formid || ""; return taskStore.getApprovalList[index]?.formid || ''
}); })
function overTaskHandle() { function overTaskHandle() {
const item = taskDetailInfo.value; const item = taskDetailInfo.value
if (validate([item]) == null && batch.value === false) overTask.value = item; if (validate([item]) == null && batch.value === false)
overTask.value = item
} }
function leaveTaskHandler() { function leaveTaskHandler() {
overTask.value = null; overTask.value = null
} }
function showActionsModal() { function showActionsModal() {
const modal = unref(CustomSettingModalRef)! as any; const modal = unref(CustomSettingModalRef)! as any
modal.showModal(); modal.showModal()
} }
onUnmounted(() => { onUnmounted(() => {
taskStore.reset(); taskStore.reset()
}); })
const mark = computed(() => { const mark = computed(() => {
return taskDetailInfo.value.iztrueorfalse === null ? "未标记" : "已标记"; return taskDetailInfo.value.iztrueorfalse === null ? '未标记' : '已标记'
}); })
function immersionHandler() { function immersionHandler() {
taskStore.updateImmersion(); taskStore.updateImmersion()
} }
function previewHandler(event: MouseEvent) { function previewHandler(event: MouseEvent) {
event.stopImmediatePropagation(); event.stopImmediatePropagation()
event.stopPropagation(); event.stopPropagation()
if (imageRef.value && (imageRef.value as any).src) if (imageRef.value && (imageRef.value as any).src)
(imageRef.value as any).mergedOnClick() (imageRef.value as any).mergedOnClick()
} }
function getPercent(pictureid: string) { function getPercent(pictureid: string) {
const { ocpictureid, pictureresult } = taskDetailInfo.value; const { ocpictureid, pictureresult } = taskDetailInfo.value
const index = ocpictureid.split(",").indexOf(String(pictureid)); const index = ocpictureid.split(',').indexOf(String(pictureid))
const results = pictureresult.split(","); const results = pictureresult.split(',')
const percent = results[index] || "0"; const percent = results[index] || '0'
const val = Number.parseFloat(percent); const val = Number.parseFloat(percent)
return `${val}%`; return `${val}%`
} }
</script> </script>
@ -501,7 +504,9 @@ function getPercent(pictureid: string) {
<div class="info-header"> <div class="info-header">
<div class="left_box"> <div class="left_box">
<div class="title">填报信息</div> <div class="title">
填报信息
</div>
<SvgIcon size="12" name="collapse" /> <SvgIcon size="12" name="collapse" />
</div> </div>
<div class="right_box" @click="showActionsModal"> <div class="right_box" @click="showActionsModal">
@ -511,7 +516,7 @@ function getPercent(pictureid: string) {
</div> </div>
<n-tabs type="line" animated> <n-tabs type="line" animated>
<n-tab-pane name="task-info" tab="任务信息"> <n-tab-pane name="task-info" tab="任务信息">
<TaskTable :data="taskDetailInfo" :taskTableData="taskTableData" /> <TaskTable :data="taskDetailInfo" :task-table-data="taskTableData" />
</n-tab-pane> </n-tab-pane>
<n-tab-pane name="picture-info" tab="图片信息"> <n-tab-pane name="picture-info" tab="图片信息">
<PictureTable :data="taskDetailInfo" /> <PictureTable :data="taskDetailInfo" />

@ -248,7 +248,7 @@ const layout = debounce(() => {
_imagesload.on('done', (instance) => { _imagesload.on('done', (instance) => {
if (!el.value) if (!el.value)
return return
loading.value = false loading.value = false
}) })
_imagesload.on('fail', (instance) => { _imagesload.on('fail', (instance) => {

Loading…
Cancel
Save