Преглед изворни кода

refactor(message): 公告数据获取

HMY пре 1 година
родитељ
комит
629da14f87
5 измењених фајлова са 232 додато и 36 уклоњено
  1. 26 0
      api/message.js
  2. 32 10
      api/process.js
  3. 11 4
      components/ygoa/processList.vue
  4. 137 13
      pages/message/index.vue
  5. 26 9
      pages/process/index.vue

+ 26 - 0
api/message.js

@@ -0,0 +1,26 @@
+import request from '@/utils/request.js'
+const preUrl = '/clientServices.do?iscrypt=1'
+
+//获取用户消息列表
+export function GetMessageList(params) {
+	return request({
+		url: preUrl,
+		method: 'post',
+		data: {
+			'serviceId': 'oa_2017V001PHONE_messageList',
+			'params': params
+		}
+	})
+}
+
+//获取用户公告列表
+export function GetNoticeList(params) {
+	return request({
+		url: preUrl,
+		method: 'post',
+		data: {
+			'serviceId': 'eu_notice_2013V0010PHONE001',
+			'params': params
+		}
+	})
+}

+ 32 - 10
api/process.js

@@ -1,13 +1,17 @@
 import request from '@/utils/request.js'
 const preUrl = '/clientServices.do?iscrypt=1'
 //获取用户所有流程
-export function getUserAllProcess(params) {
+export function getUserAllProcess({staffId,page,pageNum}) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
 			'serviceId': 'bpm_2013V0100PHONE009',
-			'params': params
+			'params': {
+				staffId,
+				page,
+				pageNum
+			}
 		}
 	})
 }
@@ -16,10 +20,16 @@ export function getUserAllProcess(params) {
 export function getUserProcessed(params) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
 			'serviceId': 'bpm_2013V0100PHONE003',
-			'params': params
+			'params': {
+				"staffId": params.staffId,
+				"page": params.page,
+				"pageNum": params.pageNum,
+				"modelId": params.modelId, //流程类型
+				"control": params.control //流程控制方式 0 手写 1 引擎
+			}
 		}
 	})
 }
@@ -27,10 +37,16 @@ export function getUserProcessed(params) {
 export function getUserProcess(params) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
 			'serviceId': 'bpm_2013V0010PHONE001',
-			'params': params
+			'params': {
+				"staffId": params.staffId,
+				"page": params.page,
+				"pageNum": params.pageNum,
+				"modelId": params.modelId, //流程类型
+				"control": params.control //流程控制方式 0 手写 1 引擎
+			}
 		}
 	})
 }
@@ -39,10 +55,16 @@ export function getUserProcess(params) {
 export function getUserProcessing(params) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
 			'serviceId': 'bpm_2013V0100PHONE002',
-			'params': params
+			'params': {
+				"staffId": params.staffId,
+				"page": params.page,
+				"pageNum": params.pageNum,
+				"modelId": params.modelId, //流程类型
+				"control": params.control //流程控制方式 0 手写 1 引擎
+			}
 		}
 	})
-}
+}

+ 11 - 4
components/ygoa/processList.vue

@@ -91,15 +91,22 @@
 	const intervalId = ref(null); // 定时器ID
 	
 	// TODO: 根据接口返回的数据动态生成process表单
-	const props = defineProps(['processes'])
+	// const props = defineProps(['processes'])
+	const props = defineProps({
+		processes:{
+			type: Array,
+			required: true,
+			default: []
+		}
+	})
 	function startProcessCheck() {
-		intervalId.value = setInterval(() => {
+		// intervalId.value = setInterval(() => {
 			console.log(111);
 			if (props.processes && props.processes.length > 0) {
 				console.log('props',props.processes);
-				clearInterval(intervalId.value); // 清除定时器    
+				// clearInterval(intervalId.value); // 清除定时器    
 			}
-		}, 100); // 每0.1秒检查一次
+		// }, 100); // 每0.1秒检查一次
 	}
 	
 	

+ 137 - 13
pages/message/index.vue

@@ -37,6 +37,63 @@
 				</view>
 			</uni-collapse-item>
 		</uni-collapse>
+
+
+
+
+
+		<uni-collapse>
+			<uni-collapse-item title-border="show" :border="true" :show-animation="true" :open="false">
+				<template v-slot:title>
+					<uni-section title="公告" type="line" titleFontSize="20px"></uni-section>
+				</template>
+
+				<view class="segmented_control_container">
+					<uni-segmented-control :current="current2" :values="items" @clickItem="onClickItem2"
+						styleType="text" activeColor="#409eff"></uni-segmented-control>
+				</view>
+				<view class="content">
+					<view @click="handleToDetail(message)" v-for="(message, index) in notices" :key="index"
+						:class="message.if_read ? ' ' : 'message_container_unread'" class="message_container">
+						<uni-card :is-full="true">
+							<template v-slot:title>
+								<uni-row>
+									<view class="message_top_container">
+										<uni-col :span="24">
+											<text class="message_user">
+												{{ message.name }}
+											</text>
+										</uni-col>
+									</view>
+								</uni-row>
+								<uni-row>
+									<view class="message_mid_container">
+										<uni-col :span="16">
+											<text class="message_title hidden_over">
+												<text :class="message.icon" class="ygoa-icon"></text>
+												<text class="message_title_text">{{ message.title }}</text>
+											</text>
+										</uni-col>
+										<uni-col :span="8">
+											<text class="message_time">
+												{{ message.sendtime }}
+											</text>
+										</uni-col>
+									</view>
+								</uni-row>
+							</template>
+							<!-- <view class="message_bottom_container">
+								<text class="message_content hidden_over">
+									{{ message.content }}
+								</text>
+							</view> -->
+						</uni-card>
+					</view>
+				</view>
+			</uni-collapse-item>
+		</uni-collapse>
+
+
 		<uni-collapse>
 			<uni-collapse-item title-border="show" :border="true" :show-animation="true" :open="true">
 				<template v-slot:title>
@@ -88,7 +145,8 @@
 			</uni-collapse-item>
 		</uni-collapse>
 		<view class="fab_button">
-			<uni-fab :pattern="{icon:'headphones'}" :popMenu="false" horizontal="right" @fabClick="clickFabButton"></uni-fab>
+			<uni-fab :pattern="{icon:'headphones'}" :popMenu="false" horizontal="right"
+				@fabClick="clickFabButton"></uni-fab>
 		</view>
 		<view class="checkIn_button">
 			<uni-fab :pattern="{icon:'calendar'}" :popMenu="false" horizontal="left" @fabClick="clickCheckIn"></uni-fab>
@@ -97,12 +155,14 @@
 </template>
 
 <script setup lang="ts">
-	import { onMounted, reactive, ref } from 'vue';
+	import { callWithErrorHandling, onMounted, reactive, ref } from 'vue';
 	import $tab from '@/plugins/tab.js';
 	import processList from '@/components/ygoa/processList.vue'
 	import { useUserStore } from '@/store/user.js'
+	import { GetMessageList, GetNoticeList } from '@/api/message.js';
 	onMounted(() => {
 		onClickItem({ currentIndex: 0 })
+		onClickItem2({ currentIndex: 0 })
 	})
 	const userStore = useUserStore()
 	function clickCheckIn() {
@@ -114,8 +174,11 @@
 	const items = reactive(['全部', '已读', '未读'])
 	// 分段器选项
 	const current = ref(-1)
+	const current2 = ref(0)
 	// 消息列表
-	let messages = reactive([])
+	let messages = ref([])
+	//公告列表
+	let notices = ref([]);
 	// 待办列表
 	let processes = reactive([
 		{
@@ -155,31 +218,70 @@
 			step: 0
 		},
 	])
+	// const msg = reactive({
+	// 	msgId: '1',
+	// 	title: '账户2 的加班申请',
+	// 	userName: '账户2',
+	// 	createTime: '2024/10/10',
+	// 	icon: 'icon-announce',
+	// 	is_read: '1',
+	// 	msgType: '0',//0消息或1公告
+	// })
 
 	// 点击消息分段器
 	function onClickItem({ currentIndex }) {
 		current.value = currentIndex
+		console.log("onClickItem", currentIndex);
 		switch (currentIndex) {
 			case 0:
-				messages = [
+				messages.value = [
 					{
-						id: 1,
-						user: "账户1",
-						title: "已读公告1",
+						id: 3,
+						user: "账户3",
+						title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
 						content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
 						time: "2024/10/10",
 						icon: 'icon-announce',
-						is_read: 1
+						is_read: 0
 					},
 					{
-						id: 2,
-						user: "账户2",
-						title: "已读通知2",
+						id: 4,
+						user: "账户4",
+						title: "未读通知4",
 						content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
 						time: "2024/10/10",
 						icon: 'icon-notify',
+						is_read: 0
+					}
+				]
+				break;
+			case 1:
+				console.log("case1")
+				messages.value = [
+					{
+						id: 1,
+						user: "账户1",
+						title: "已读公告1",
+						content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
+						time: "2024/10/10",
+						icon: 'icon-announce',
 						is_read: 1
 					},
+					// {
+					// 	id: 2,
+					// 	user: "账户2",
+					// 	title: "已读通知2",
+					// 	content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
+					// 	time: "2024/10/10",
+					// 	icon: 'icon-notify',
+					// 	is_read: 1
+					// }
+				];
+				console.log(messages.value);
+
+				break;
+			case 2:
+				messages.value = [
 					{
 						id: 3,
 						user: "账户3",
@@ -200,8 +302,30 @@
 					}
 				]
 				break;
+		}
+	}
+
+	// 点击公告分段器
+	function onClickItem2({ currentIndex }) {
+		current2.value = currentIndex;
+		console.log(currentIndex);
+		switch (currentIndex) {
+			case 0:
+				// console.log('userStore', JSON.parse(JSON.stringify(userStore.user)))
+				const params1 = {
+					"notice_title": "",
+					"p": "1",
+					"pSize": "5",
+					"userId": userStore.user.useId,
+					"unitId": userStore.user.unitId,
+				}
+				GetNoticeList(params1).then(res => {
+					// console.log(res);
+					notices.value=res.returnParams.noticelist.list;
+				})
+				break;
 			case 1:
-				messages = [
+				notices.value = [
 					{
 						id: 1,
 						user: "账户1",
@@ -223,7 +347,7 @@
 				]
 				break;
 			case 2:
-				messages = [
+				notices.value = [
 					{
 						id: 3,
 						user: "账户3",

+ 26 - 9
pages/process/index.vue

@@ -82,22 +82,27 @@
 		console.log('searchOnBlur', e);
 	}
 
-	const params = ref({});
 	function onClickItem({ currentIndex }) { // 点击分段器选项
 		current.value = currentIndex
+		let params = {}
 		switch (currentIndex) {
 			case 0: // 我的
-				params.value = {
-					"staffId": userStore.user.useId,
-					"page": 1,
-					"pageNum": 5
+				params = {
+					staffId: userStore.user.useId,
+					page: 1,
+					pageNum: 5
 				}
 				getUserAllProcess(params).then(res => {
-					processes.value = res.returnParams.list;
+					// console.log(res.returnParams);
+					if(res.returnParams==undefined){
+						processes.value=[]
+						return
+					}
+					processes.value = res.returnParams.list
 				});
 				break;
 			case 1: // 待办
-				params.value = {
+				params = {
 					"staffId": userStore.user.useId,
 					"page": 1,
 					"pageNum": 5,
@@ -105,11 +110,15 @@
 					"control": 1
 				}
 				getUserProcess(params).then(res => {
+					if(res.returnParams==undefined){
+						processes.value=[]
+						return
+					}
 					processes.value = res.returnParams.list;
 				});
 				break;
 			case 2: // 在办
-				params.value = {
+				params = {
 					"staffId": userStore.user.useId,
 					"page": 1,
 					"pageNum": 5,
@@ -117,11 +126,15 @@
 					"control": 1
 				}
 				getUserProcessing(params).then(res => {
+					if(res.returnParams==undefined){
+						processes.value=[]
+						return
+					}
 					processes.value = res.returnParams.list;
 				});
 				break;
 			case 3: // 办结
-				params.value = {
+				params = {
 					"staffId": userStore.user.useId,
 					"page": 1,
 					"pageNum": 5,
@@ -129,6 +142,10 @@
 					"control": 1
 				}
 				getUserProcessed(params).then(res => {
+					if(res.returnParams==undefined){
+						processes.value=[]
+						return
+					}
 					processes.value = res.returnParams.list;
 				});
 				break;