Sfoglia il codice sorgente

集成详情页的处理

kagg886 2 mesi fa
parent
commit
f54f23c90b

+ 90 - 4
src/api/system/report/complaint-resolve-history.ts

@@ -1,8 +1,94 @@
-import { ComplaintResolveHistory, ComplaintResolveHistoryInsertRequest } from '/@/api/system/report/type'
-import { get, post } from '/@/utils/request'
+import { Complaint, ComplaintResolveHistory, ComplaintResolveHistoryInsertRequest, ComplaintStatus } from '/@/api/system/report/type'
+import { post } from '/@/utils/request'
+import { checkLog } from '/@/api/flow/flowModel'
 
 export default {
-	list: (id: number): Promise<ComplaintResolveHistory[]> => get('/system/complaint/records',{ticketNo: id}).then((res: {data: ComplaintResolveHistory[]}) => res.data),
+	// list: (id: number): Promise<ComplaintResolveHistory[]> => get('/system/complaint/records',{ticketNo: id}).then((res: {data: ComplaintResolveHistory[]}) => res.data),
+	list: async (resolve: Complaint['actionBtn']): Promise<ComplaintResolveHistory[]> => {
+		// formId 19
+		// formTable sys_complaints
+		// pageNum 1
+		// pageSize 10
+		const data = await checkLog({
+			formId: resolve.wfFid,
+			formTable: resolve.wfType,
+			pageNum: 1,
+			pageSize: 500,
+			//@ts-ignore
+		})
+			.then((resp) => {
+				return (resp as unknown as { list: Array<WorkflowLog> }).list
+			})
+			.catch(() => undefined)
 
-	update:(params: ComplaintResolveHistoryInsertRequest) => post('/system/complaint/records/add', params)
+		if (data === undefined) {
+			return [] as ComplaintResolveHistory[]
+		}
+
+		const rtn = data.map((data) => {
+			let status: ComplaintStatus | undefined = undefined
+			switch (data.btn) {
+				case '发起流程':
+					status = ComplaintStatus.PENDING
+					break
+				case '流程审核':
+					status = ComplaintStatus.PROCESSING
+					break
+				case '强制终止':
+					status = ComplaintStatus.COMPLETED
+					break
+			}
+			const history: ComplaintResolveHistory = {
+				id: data.id,
+				ticketNo: data.id,
+				status: status,
+				operator: data.approvalUser.userNickname,
+				description: data.content ?? '',
+				createdAt: data.createdAt,
+				updatedAt: data.createdAt,
+				// id: number;
+				// ticketNo: number;
+				// status: ComplaintStatus;
+				// operator: string;
+				// description: string
+				// createdAt: string;
+				// updatedAt: string
+			}
+
+			return history
+		})
+
+		const last = rtn.at(-1)
+
+		//最后一个流程审核标记为已完成。
+		if (resolve.title === '' && last?.status === ComplaintStatus.PROCESSING) {
+			last.status = ComplaintStatus.COMPLETED
+		}
+
+		return rtn
+	},
+
+	update: (params: ComplaintResolveHistoryInsertRequest) => post('/system/complaint/records/add', params),
+}
+
+//"id": 63,
+//                 "uid": 1,
+//                 "nodeName": "流程开始",
+//                 "content": "1",
+//                 "createdAt": "2025-08-01 11:58:31",
+//                 "approvalUser": {
+//                     "id": 1,
+//                     "userNickname": "超级管理员"
+//                 },
+//                 "btn": "发起流程"
+type WorkflowLog = {
+	id: number
+	uid: number
+	btn: '发起流程' | '流程审核' | '强制终止'
+	content?: string
+	createdAt: string
+	approvalUser: {
+		id: number
+		userNickname: string
+	}
 }

+ 13 - 1
src/api/system/report/type.ts

@@ -26,7 +26,19 @@ export interface Complaint {
   updatedAt: string;
 
 	//FIXME: 流程控制需要
-	actionBtn: any;
+	actionBtn: {
+		//"title": "",
+		//                     "type": "disabled",
+		//                     "wfFid": 17,
+		//                     "wfModelType": 2,
+		//                     "wfStatusField": "status",
+		//                     "wfTitle": "title",
+		//                     "wfType": "sys_complaints"
+		wfFid: number
+		wfType: string
+		type: string
+		title: string
+	};
 }
 
 export type CreateComplaintRequest = Pick<Complaint, 'title' | 'category' | 'source' | 'area' | 'complainantName' | 'contact' | 'level' | 'content'> & {

+ 12 - 4
src/views/system/report/componments/report-detail-dialog.vue

@@ -63,11 +63,16 @@ const formatReportSource = computed<(value: string) => string>(() => {
 	}
 })
 
-const props = defineProps<{
-	id: number | undefined
 
+type Prop = {
+	id: number | undefined
+	wfProp: Complaint['actionBtn'] | undefined
 	visible: boolean
-}>()
+}
+
+const props = withDefaults(defineProps<Prop>(), {
+	wfProp: undefined,      // 保持 undefined 作为默认值
+})
 
 const emit = defineEmits<{
 	// eslint-disable-next-line no-unused-vars
@@ -98,7 +103,10 @@ const {
 	if (props.id === undefined) {
 		return []
 	}
-	return complaint_resolve_history.list(props.id)
+	if (props.wfProp === undefined) {
+		return []
+	}
+	return  complaint_resolve_history.list(props.wfProp)
 }, [])
 
 watch(

+ 3 - 1
src/views/system/report/list/index.vue

@@ -448,9 +448,11 @@ const { loading: createFeedbackLoading, doLoading: createFeedback } = useLoading
 })
 
 const complaintDetailId = ref<number | undefined>(undefined)
+const complaintDetailProps = ref<Complaint['actionBtn'] | undefined>(undefined)
 const showDetail = ref(false)
 const handleDetail = (row: Complaint) => {
 	complaintDetailId.value = row.id
+	complaintDetailProps.value = row.actionBtn
 	showDetail.value = true
 }
 
@@ -840,7 +842,7 @@ const handleStartFlow = (row: FlowDemoTableColumns | null) => {
 			</template>
 		</el-dialog>
 
-		<report-detail-dialog :id="complaintDetailId" v-model:visible="showDetail" />
+		<report-detail-dialog :id="complaintDetailId" v-model:visible="showDetail" :wf-prop="complaintDetailProps"/>
 
 		<checkFlow ref="ckFlowRef" @getList="getComplaintList"></checkFlow>
 	</div>