liujt 3 долоо хоног өмнө
parent
commit
5f036f3818

+ 16 - 0
pages.json

@@ -76,6 +76,22 @@
 				"navigationBarTextStyle": "white"
 			}
 		},
+		{
+			"path": "pages/home/wt/send/send",
+			"style": {
+				"navigationBarTitleText": "已发流程",
+				"navigationStyle": "custom",
+				"navigationBarTextStyle": "white"
+			}
+		},
+		{
+			"path": "pages/home/wt/send/processTask",
+			"style": {
+				"navigationBarTitleText": "详情",
+				"navigationStyle": "custom",
+				"navigationBarTextStyle": "white"
+			}
+		},
 		{
 			"path": "pages/home/wt/done/done",
 			"style": {

+ 11 - 10
pages/home/components/navigation.vue

@@ -36,10 +36,17 @@
 						link_url: '/pages/home/myTicket/myTicket?orderType=2',
 						badge: 0
 					},
+					// {
+					// 	class: 'iconfont icon-dangqiangaojing',
+					// 	title: '我的消息',
+					// 	link_url: '/pages/home/wt/message/message',
+					// 	badge: 0
+					// 	// "num": 1
+					// },
 					{
-						class: 'iconfont icon-dangqiangaojing',
-						title: '我的消息',
-						link_url: '/pages/home/wt/message/message',
+						class: 'iconfont icon-kuneipandian',
+						title: '已发流程',
+						link_url: '/pages/home/wt/send/send',
 						badge: 0
 						// "num": 1
 					},
@@ -74,7 +81,6 @@
 			},
 		},
 		created() {
-			this.getCount()
 			this.gettodoNuber()
 			// this.$nextTick(()=>{
 			// 	this.workList[0].badge = String(this.workOrder.total)
@@ -87,12 +93,7 @@
 				})
 			},
 
-			async getCount() {
-				// const res = await getTodoList({}, false)
-				// this.workList[0].badge = res.count
-				const messageCount = await getUnreadNotifyMessageCountAPI()
-				this.workList[2].badge = Number(messageCount)
-			},
+			
 			gettodoNuber() {
 				todoNuber().then(res => {
 					this.workList[3].badge = res.count

+ 25 - 3
pages/home/home.vue

@@ -1,8 +1,14 @@
 <template>
 	<view class="ss">
 		<!-- 头 -->
-		<uni-nav-bar fixed="true" statusBar="true" right-icon="scan" title="首页" @clickLeft="back"
-			@clickRight="HandlScanCode"></uni-nav-bar>
+		<uni-nav-bar fixed="true" statusBar="true" right-icon="scan" title="首页"
+			@clickRight="HandlScanCode">
+			<template v-slot:left>
+				<uni-badge size="small" :text="messageCount" absolute="righttop" type="error">
+					<uni-icons type="notification" size="24" @click="handleMessage"></uni-icons>
+				</uni-badge>
+			</template>
+		</uni-nav-bar>
 		<!-- <uni-nav-bar fixed="true" statusBar="true" title="工作台"></uni-nav-bar> -->
 
 		<view class="container">
@@ -161,6 +167,9 @@
 	import sparePart from './pages/sparePart/sparePart.vue'
 	import ScanCode from '@/components/ScanCode.vue'
 	import homeNew from './homeNew.vue'
+	import {
+		getUnreadNotifyMessageCountAPI
+	} from '@/api/wt/index.js'
 
 	import {
 		getDateNew
@@ -228,6 +237,7 @@
 				equipmentInfo: '',
 				qrContent: '',
 				barType: '',
+				messageCount: 0,
 				workOrder: {
 					maintenanceNum: 0,
 					patrolInspection: 0,
@@ -260,6 +270,7 @@
 			}
 		},
 		created() {
+			this.getCount()
 			uni.getStorage({
 				key: 'userInfo',
 				success: res => {
@@ -277,9 +288,20 @@
 
 
 		methods: {
+			handleMessage() {
+				uni.navigateTo({
+					url: '/pages/home/wt/message/message'
+				})
+			},
+			async getCount() {
+				// const res = await getTodoList({}, false)
+				// this.workList[0].badge = res.count
+				const messageCount = await getUnreadNotifyMessageCountAPI()
+				this.messageCount = Number(messageCount)
+			},
 			init() {
 				this.getStatistics()
-				this.$refs.navigationRef && this.$refs.navigationRef.getCount()
+				// this.$refs.navigationRef && this.$refs.navigationRef.getCount()
 				this.$refs.equipmentRef && this.$refs.equipmentRef.getData()
 				this.$refs.mochaRef && this.$refs.mochaRef.getData()
 				this.$refs.mouldRef &&

+ 211 - 0
pages/home/wt/send/processTask.vue

@@ -0,0 +1,211 @@
+<template>
+	<view class="havedone-container">
+		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="uniNavBarTitle"
+		 background-color="#157A2C" color="#fff"
+			@clickLeft="back"></uni-nav-bar>
+			<!-- <iframe src="http://aiot.zoomwin.com.cn:51001/test/a.html" style="width: 200px;height: 600px" frameborder="0"></iframe> -->
+		<view v-if="processInstance.processDefinition && taskFormComp">
+			<component :is="taskFormComp" id='async-biz-form-component' :taskId="listData.taskId" :businessId="listData.businessId" :id="listData.id"
+				:taskDefinitionKey="listData.taskDefinitionKey"
+				 ref="bziRef"></component>
+				 
+		</view>
+		<!-- <view v-for="(item, index) in runningTasks" :key="index">
+			<div v-if="processInstance.processDefinition">
+				<taskSubmit id='async-sub-form-component' :taskId="listData.taskId" :businessId="listData.businessId" :id="listData.id"
+					:taskDefinitionKey="listData.taskDefinitionKey" @handleAudit="handleAudit"
+					@getTableValue="getTableValue" @handleUpdateAssignee="handleUpdateAssignee(item)"
+					@handleBackList="handleBackList(item)" ref="subForm">
+				</taskSubmit>
+			</div>
+		</view> -->
+		<u-toast ref="uToast"></u-toast>
+	</view>
+</template>
+
+<script>
+	import {
+		getProcessInstance,
+		getTaskListByProcessInstanceId
+	} from '@/api/wt/index.js'
+import Vue from 'vue'
+// import taskForm from './taskForm.vue'
+// import taskSubmit from './taskSubmit.vue'
+
+	export default {
+		name: 'processTask',
+		// components:{ taskForm,taskSubmit },
+		data() {
+			return {
+				uniNavBarTitle: '',
+				processInstanceLoading: false,
+				listData: {},
+				processInstance: {},
+				runningTasks: [],
+				auditForms: [],
+				activeComp: null,
+				taskFormComp: null, // 动态加载的 taskForm 组件
+			}
+		},
+
+		onLoad(option) {
+			this.listData = option
+			this.getDetail()
+			this.activeComp = 'tab1'
+			// 动态加载 miniHandleRouter 对应的 taskForm 组件
+			if (option.miniHandleRouter) {
+				this.loadTaskFormComponent(option.miniHandleRouter)
+			}
+		},
+		methods: {
+			/** 动态加载 miniHandleRouter 对应的 taskForm 组件 */
+		loadTaskFormComponent(router) {
+			try {
+				// router 格式: /wt/components/purchaseOrder/taskForm
+				// require.context 在编译期解析所有 taskForm.vue,运行时按 key 取值
+				const context = require.context('@/pages/home', true, /taskForm\.vue$/)
+				const key = '.' + router + '.vue' // -> ./wt/components/purchaseOrder/taskForm.vue
+				const module = context(key)
+				if (module) {
+					this.taskFormComp = module.default || module
+				}
+			} catch (e) {
+				console.error('动态加载 taskForm 组件失败:', router, e)
+				uni.showModal({
+					title: '组件加载失败',
+					content: `无法加载: ${router}`,
+					showCancel: false
+				})
+			}
+		},
+			/** 获得流程实例 */
+		async	getDetail() {
+				// 获得流程实例相关
+				this.processInstanceLoading = true;
+				getProcessInstance({
+					id: this.listData.id
+				}).then(async (response) => {
+					if (!response) {
+						this.$message.error('查询不到流程信息!');
+						return;
+					}
+					// 设置流程信息 
+						this.processInstance = response;
+					this.uniNavBarTitle =`${ response.name } 【${ response.startUser?.nickname}】`
+						
+			
+					// //将业务表单,注册为动态组件
+					// Vue.component('async-biz-form-component', (resolve) => {
+					// 	require(['pages/home' + this.listData.miniHandleRouter], resolve);
+					// });
+					// Vue.component('async-sub-form-component', (resolve) => {
+					// 	require(['pages/home' + this.listData.miniViewRouter], resolve);
+					// });
+					
+				
+					this.processInstanceLoading = false;
+				});
+
+				this.runningTasks = [];
+				this.auditForms = [];
+				getTaskListByProcessInstanceId({
+					processInstanceId: this.listData.id
+				}).then((response) => {
+					console.log(response, 'response');
+					// 审批记录
+					this.tasks = [];
+					// 移除已取消的审批
+					response.forEach((task) => {
+						if (task.result !== 4) {
+							this.tasks.push(task);
+						}
+					});
+					// 排序,将未完成的排在前面,已完成的排在后面;
+					this.tasks.sort((a, b) => {
+						// 有已完成的情况,按照完成时间倒序
+						if (a.endTime && b.endTime) {
+							return b.endTime - a.endTime;
+						} else if (a.endTime) {
+							return 1;
+						} else if (b.endTime) {
+							return -1;
+							// 都是未完成,按照创建时间倒序
+						} else {
+							return b.createTime - a.createTime;
+						}
+					});
+
+					// 需要审核的记录
+					let userInfo = wx.getStorageSync("userInfo");
+					this.tasks.forEach((task) => {
+						if (task.result !== 1 && task.result !== 6) {
+							// 只有待处理才需要
+							return;
+						}
+						if (!task.assigneeUser || task.assigneeUser.id !== userInfo.userId) {
+							// 自己不是处理人
+							return;
+						}
+						if (task.taskDefinitionKey !== this.listData.taskDefinitionKey) {
+							// 不是当前流程的
+							return;
+						}
+						this.runningTasks.push({
+							...task
+						});
+						console.log(this.runningTasks, ' this.runningTasks');
+						this.auditForms.push({
+							reason: ''
+						});
+					});
+				});
+			},
+
+
+			/** 处理审批通过和不通过的操作 */
+			handleAudit(data) {
+				let text = data.status === 1 ? '通过' : '不通过';
+				this.$refs.uToast.show({
+					type: 'success',
+					message: `审批${data.title || text}成功!`,
+					iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
+				})
+				// 获得最新详情
+				setTimeout(() => {
+				
+					uni.navigateBack()
+				}, 1000)
+
+
+				// const index = this.runningTasks.indexOf(task);
+				// this.$refs['form' + index][0].validate((valid) => {
+				//   if (!valid) {
+				//     return;
+				//   }
+				//   const data = {
+				//     id: task.id,
+				//     reason: this.auditForms[index].reason
+				//   };
+				//   if (pass) {
+				//     approveTask(data).then((response) => {
+				//       this.$message.success('审批通过成功!');
+				//       this.handleClose(); // 获得最新详情
+				//     });
+				//   } else {
+				//     rejectTask(data).then((response) => {
+				//       this.$message.success('审批不通过成功!');
+				//       this.handleClose(); // 获得最新详情
+				//     });
+				//   }
+				// });
+			},
+			getTableValue(fn) {
+				fn(this.$refs.bziRef.getTableValue());
+			}
+		}
+
+	}
+</script>
+
+<style>
+</style>

+ 288 - 0
pages/home/wt/send/send.vue

@@ -0,0 +1,288 @@
+<template>
+  <view class="blacklog-container">
+    <uni-nav-bar
+      fixed="true"
+      statusBar="true"
+      left-icon="back"
+      title="已发流程"
+      @clickLeft="back"
+      background-color="#157A2C"
+      color="#fff"
+    ></uni-nav-bar>
+
+    <view class="list-container">
+      <u-list @scrolltolower="scrolltolower">
+        <u-list-item v-for="(item, index) in list" :key="index">
+          <view class="kd-card">
+            <view class="card-title">
+              <text>{{ item.processInstance.name }}</text>
+              <text class="card-time">{{ item.createTime }}</text>
+            </view>
+            <view>
+              <view class="card-body">
+                <view class="card-col" v-for="itm in colOptions">
+                  <text class="label">{{ itm.label }}</text>
+                  <text class="content">{{ item[itm.key] }}</text>
+                </view>
+              </view>
+
+              <view class="card-footer">
+                <u-button
+                  type="success"
+                  @click="handleDetail(item, 'view')"
+                  v-if="
+                    ['0', '2'].includes(
+                      item.extensionProperty.taskHandlePlatform,
+                    )
+                  "
+                  >查看</u-button
+                >
+                <u-button v-else type="error">请在PC端处理</u-button>
+                <u-button type="info" @click="handleDetail(item, 'detail')"
+                  >流程详情</u-button
+                >
+              </view>
+            </view>
+          </view>
+        </u-list-item>
+      </u-list>
+    </view>
+    <view v-show="list.length === 0" class="no_data">
+      <u-empty mode="data" textSize="30"></u-empty>
+    </view>
+  </view>
+</template>
+
+<script>
+import { getTodoTaskPage } from "@/api/wt/index.js";
+let [page, size, isEnd] = [1, 10, true];
+
+export default {
+  computed: {
+    colOptions() {
+      return [
+        {
+          label: "流程节点",
+          key: "name",
+        },
+        {
+          label: "流程发起人",
+          key: `startUserNickname`,
+        },
+      ];
+    },
+  },
+  data() {
+    return {
+      list: [],
+      params: {
+        status: "",
+        name: "",
+      },
+    };
+  },
+  onShow() {
+    page = 1;
+    this.list = [];
+    this.getList();
+  },
+
+  methods: {
+    scrolltolower() {
+      if (isEnd) return;
+      page++;
+      this.getList();
+    },
+    //miniHandleRouter
+    handleDetail(item, type) {
+      console.log("111~~~", item);
+      //'pages/home' + this.listData.miniHandleRouter
+      ///wt/components/feeApplication/taskSubmit
+      if (type == "handle") {
+        console.log(Object.keys(item.formJson).length);
+        if (Object.keys(item.formJson).length) {
+          let params = JSON.stringify({
+            id: item.id,
+            processInstanceId: item.processInstance.id || "",
+            type: type,
+          });
+          let queryParams = `params=${params}`;
+          let url = "/pages/home/wt/components/formParser/routerView";
+          uni.navigateTo({
+            url: `${url}?${queryParams}`,
+          });
+        } else {
+          let queryParams = `id=${item.processInstance.id}&businessId=${item.businessId}&taskId=${item.id}&taskDefinitionKey=${item.taskDefinitionKey}&miniHandleRouter=${item.miniHandleRouter}&miniViewRouter=${item.miniViewRouter}`;
+          let url =
+            "/pages/home" +
+            item.miniHandleRouter.replace("taskForm", "processTask");
+
+          console.log("url~~~", `${url}?${queryParams}`);
+          uni.navigateTo({
+            url: `${url}?${queryParams}`,
+          });
+        }
+
+        //
+      } else if (type == "view") {
+        console.log(Object.keys(item.formJson).length);
+        if (Object.keys(item.formJson).length) {
+          let params = JSON.stringify({
+            id: item.id,
+            processInstanceId: item.processInstance.id || "",
+            type: type,
+          });
+          let queryParams = `params=${params}`;
+          let url = "/pages/home/wt/components/formParser/routerView";
+          uni.navigateTo({
+            url: `${url}?${queryParams}`,
+          });
+        } else {
+          let queryParams = `id=${item.processInstance.id}&businessId=${item.businessId}&taskId=${item.id}&taskDefinitionKey=${item.taskDefinitionKey}&miniHandleRouter=${item.miniHandleRouter}&miniViewRouter=${item.miniViewRouter}`;
+        //   let url =
+        //     "/pages/home" +
+        //     item.miniHandleRouter.replace("taskForm", "processTask");
+         let url =
+            "/pages/home/wt/send/processTask"
+
+          console.log("url~~~", `${url}?${queryParams}`);
+          uni.navigateTo({
+            url: `${url}?${queryParams}`,
+          });
+        }
+      } else {
+        uni.navigateTo({
+          url: `/pages/home/wt/components/detail?processInstanceId=${item.processInstance.id}`,
+        });
+      }
+    },
+    async getList() {
+      let paging = {
+        pageNo: page,
+        pageSize: size,
+        processType: 0,
+      };
+      let par = Object.assign(paging, this.params);
+      isEnd = false;
+      const data = await getTodoTaskPage(par);
+      this.list.push(...data.list);
+      this.list.forEach((item) => {
+        item.startUserNickname = item.processInstance.startUserNickname;
+      });
+      isEnd = this.list.length >= data.count;
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.blacklog-container {
+  height: 100vh;
+  display: flex;
+  flex-direction: column;
+}
+
+.list-container {
+  flex: 1;
+  padding: 24rpx;
+  background: $page-bg;
+  flex: 1;
+  overflow: hidden;
+  // position: absolute;
+  // top: 88rpx;
+  // bottom: 0;
+  // left: 0;
+  // right: 0;
+
+  /deep/ .u-list {
+    height: 100% !important;
+  }
+}
+
+.no_data {
+  position: fixed;
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  color: #999;
+  font-size: 50rpx;
+}
+
+.kd-card {
+  font-size: 34rpx;
+  color: #333;
+  background-color: #fff;
+  border-radius: 10rpx;
+  word-break: break-all;
+  margin-bottom: 24rpx;
+
+  .status {
+    font-weight: normal;
+  }
+
+  .card-title {
+    font-size: 1rem;
+    font-weight: bold;
+
+    .card-time {
+      font-weight: normal;
+      color: #bfbfbf;
+      font-size: 0.9rem;
+      align-self: center;
+    }
+  }
+
+  .card-footer,
+  .card-title {
+    display: flex;
+    justify-content: space-between;
+    padding: 30rpx 30rpx;
+  }
+
+  .card-footer {
+    padding: 10rpx 30rpx 18rpx 30rpx;
+    font-size: 0.8rem;
+
+    /deep/ .u-button {
+      width: 48%;
+    }
+  }
+
+  .card-body {
+    padding: 0 28rpx;
+    position: relative;
+    min-height: 150rpx;
+  }
+
+  .card-body:after {
+    content: "";
+    position: absolute;
+    left: auto;
+    top: auto;
+    bottom: 10rpx;
+    right: auto;
+    height: 1rpx;
+    width: 91%;
+    background-color: #f1f1f1;
+  }
+
+  .card-col {
+    padding: 8rpx 0;
+    display: flex;
+
+    // line-height: ;
+
+    .content {
+      flex: 1;
+      overflow: hidden;
+      font-size: 0.9rem;
+    }
+
+    .label {
+      font-size: 0.9rem;
+      color: #999;
+      width: 25%;
+    }
+  }
+}
+</style>