浏览代码

Merge branch 'master' of gitee.com:xiaopubao/aizuda-web-vue3

xlsea 1 年之前
父节点
当前提交
5a620549e4

+ 3 - 1
src/store/index.ts

@@ -4,6 +4,7 @@ import usePermissionStore from './modules/permission'
 import useSettingStore from './modules/settings'
 import useTagsViewStore from './modules/tagsView'
 import useFlowStore from './modules/flow'
+import useTaskProcessStore from './modules/taskProcess'
 
 const useStore = () => ({
 	app: useAppStore(),
@@ -11,7 +12,8 @@ const useStore = () => ({
 	permission: usePermissionStore(),
 	setting: useSettingStore(),
 	tagsView: useTagsViewStore(),
-	flow: useFlowStore()
+	flow: useFlowStore(),
+	taskProcess: useTaskProcessStore()
 })
 
 export default useStore

+ 25 - 0
src/store/modules/taskProcess.ts

@@ -0,0 +1,25 @@
+import { defineStore } from 'pinia'
+
+// 审核条目
+export const useTaskProcessStore = defineStore({
+	id: 'taskProcess',
+	state: () => {
+		return {
+			storeInfoName: '',
+			currentTaskRow: {},
+			refresh: false // 刷新 false=>不刷新 true=>刷新
+		}
+	},
+	getters: {},
+	actions: {
+		initState(title: string) {
+			this.storeInfoName = title || '审批流程'
+		},
+		setCurrentTaskRow(row: any) {
+			this.currentTaskRow = row
+		}
+	},
+	persist: true
+})
+
+export default useTaskProcessStore

+ 4 - 3
src/views/approve/components/addSignDialog.vue

@@ -4,13 +4,13 @@
 		<el-form ref="formRef" v-loading="uploadLoading" label-position="top" element-loading-text="图片上传中..." :model="form" label-width="80px">
 			<el-form-item label="加签方式" prop="type">
 				<el-radio-group v-model="form.type">
-					<el-radio value="9"
+					<el-radio label="9"
 						>前加签
 						<el-tooltip effect="dark" content="在当前节点之前增加一个审批节点,当新增的节点同意后,再流转至当前节点。" placement="top">
 							<el-button text :icon="QuestionFilled" style="padding: 0"></el-button>
 						</el-tooltip>
 					</el-radio>
-					<el-radio value="11"
+					<el-radio label="11"
 						>后加签
 						<el-tooltip effect="dark" content="在当前节点之后增加一个审批节点,当前节点会默认同意,并流转至新增的节点。" placement="top">
 							<el-button text :icon="QuestionFilled" style="padding: 0"></el-button>
@@ -75,7 +75,7 @@ const formRef = ref(null)
 const uploadLoading = ref(false)
 const userOptList = ref([])
 
-const $myEmit = defineEmits(['update:modelValue', 'confirm'])
+const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 // 获取用户
 const getUserList = async () => {
@@ -121,6 +121,7 @@ const submitForm = () => {
 }
 
 const closeDialog = () => {
+	$myEmit('successCb')
 	$myEmit('update:modelValue', false)
 }
 

+ 73 - 62
src/views/approve/components/approvedContent.vue

@@ -2,12 +2,12 @@
 	<div class="flow-detail-content">
 		<div class="flow-detail-container">
 			<!-- 值为空 -->
-			<div v-if="!visibleDialog" class="flow-empty-detail-box">
+			<div v-if="!currentTaskRow.taskId" class="flow-empty-detail-box">
 				<el-empty description="暂无数据" />
 			</div>
 
 			<!-- 值不为空 -->
-			<template v-if="visibleDialog">
+			<template v-if="currentTaskRow.taskId">
 				<!-- 1、头部信息 -->
 				<div class="flow-status-stamp">
 					<div class="flow-stamp-container">
@@ -16,7 +16,7 @@
 				</div>
 
 				<div class="flow-header-box">
-					<div class="flow-no">编号:1759387444983226369</div>
+					<div class="flow-no">编号:{{ currentTaskRow.taskId }}</div>
 					<div class="action-area">
 						<div class="action-item"></div>
 					</div>
@@ -26,12 +26,12 @@
 					<!--头部-->
 					<div class="header-box">
 						<div class="summary-info">
-							<div class="title">{{ taskObj.processName }}</div>
+							<div class="title">{{ currentTaskRow.processName }}</div>
 							<FlowStatusTag :status="0" />
 						</div>
 						<div class="initiator-info">
 							<FlowNodeAvatar id="1" />
-							<div class="begin-time">{{ taskObj.createTime }} 提交</div>
+							<div class="begin-time">{{ currentTaskRow.createTime }} 提交</div>
 						</div>
 					</div>
 					<div class="area-divider"></div>
@@ -83,7 +83,7 @@
 									<el-icon><Switch /></el-icon>
 									回退
 								</el-dropdown-item>
-								<el-dropdown-item>
+								<el-dropdown-item @click.native="openComment('addSignVisible')">
 									<el-icon><Plus /></el-icon>
 									加签
 								</el-dropdown-item>
@@ -99,10 +99,10 @@
 		</div>
 
 		<!-- 评论弹窗-->
-		<review-dialog v-if="reviewVisible" v-model="reviewVisible" :task-id="taskId"></review-dialog>
+		<review-dialog v-if="reviewVisible" v-model="reviewVisible" :task-id="taskId" @success-cb="closeDetailEv"></review-dialog>
 
 		<!-- 加签弹窗 -->
-		<add-sign-dialog v-if="addSignVisible" v-model="addSignVisible" :task-id="taskId"></add-sign-dialog>
+		<add-sign-dialog v-if="addSignVisible" v-model="addSignVisible" :task-id="taskId" @success-cb="closeDetailEv"></add-sign-dialog>
 
 		<!-- 同意或拒绝弹窗 -->
 		<consent-or-refuse-dialog
@@ -110,21 +110,28 @@
 			v-model="consentOrRefuseVisible"
 			:task-id="taskId"
 			:current-type="currentDialog"
+			@success-cb="closeDetailEv"
 		></consent-or-refuse-dialog>
 
 		<!-- 转交审批弹窗 -->
-		<deliver-to-review-dialog v-if="deliverToReviewVisible" v-model="deliverToReviewVisible" :task-id="taskId"></deliver-to-review-dialog>
+		<deliver-to-review-dialog
+			v-if="deliverToReviewVisible"
+			v-model="deliverToReviewVisible"
+			:task-id="taskId"
+			@success-cb="closeDetailEv"
+		></deliver-to-review-dialog>
 
 		<!-- 减签弹窗 -->
-		<lose-sign-dialog v-if="loseSignVisible" v-model="loseSignVisible" :task-id="taskId"></lose-sign-dialog>
+		<lose-sign-dialog v-if="loseSignVisible" v-model="loseSignVisible" :task-id="taskId" @success-cb="closeDetailEv"></lose-sign-dialog>
 
 		<!-- 回退弹窗 -->
-		<rollback-dialog v-if="rollbackVisible" v-model="rollbackVisible" :task-id="taskId"></rollback-dialog>
+		<rollback-dialog v-if="rollbackVisible" v-model="rollbackVisible" :task-id="taskId" @success-cb="closeDetailEv"></rollback-dialog>
 	</div>
 </template>
 
 <script setup>
-import { computed, ref, onMounted, nextTick } from 'vue'
+import useTaskProcessStore from '@/store/modules/taskProcess'
+import { computed, ref, onMounted, nextTick, watch } from 'vue'
 import FlowStatusStamp from '@/components/Flow/FlowStatusStamp.vue'
 import FlowStatusTag from '@/components/Flow/FlowStatusTag.vue'
 import FlowNodeAvatar from '@/components/Flow/FlowNodeAvatar.vue'
@@ -139,18 +146,11 @@ import DeliverToReviewDialog from './deliverToReviewDialog'
 import LoseSignDialog from './loseSignDialog'
 import RollbackDialog from './rollbackDialog'
 import viewForm from '@/utils/form'
+import { storeToRefs } from 'pinia'
 
-const props = defineProps({
-	modelValue: {
-		type: Boolean,
-		default: false
-	},
-	taskObj: {
-		type: Object,
-		default: () => ({})
-	}
-})
-const emit = defineEmits(['update:modelValue', 'successFn'])
+// store值
+const taskProcessInfo = useTaskProcessStore()
+const { currentTaskRow } = storeToRefs(taskProcessInfo)
 
 // 各种操作弹窗显示隐藏 start
 const reviewVisible = ref(false)
@@ -163,18 +163,10 @@ const rollbackVisible = ref(false)
 const activeData = ref([])
 const currentDialog = ref(null)
 
-const visibleDialog = computed({
-	get() {
-		return props.modelValue
-	},
-	set(val) {
-		emit('update:modelValue', val)
-	}
-})
-
 const taskId = computed(() => {
-	return props.taskObj.taskId || ''
+	return currentTaskRow.value.taskId || ''
 })
+
 const FormCreate = viewForm.$form()
 const validateForm = ref({
 	api: {},
@@ -185,18 +177,36 @@ const validateForm = ref({
 	loading: false
 })
 
-// 关闭按钮
-const closeDrawer = () => {
-	emit('successFn')
-	emit('update:modelValue', false)
-}
-
-const handleCancel = () => {
-	closeDrawer()
+/**
+ * 拿到当前关闭详情弹窗
+ */
+const closeDetailEv = () => {
+	// 存储表单 todo.....
+	// 如果这里有表单,是否要把所有表单的内容进行存储,存储完毕后,才能关闭这个详情,刷新左侧的列表 todo
+	// return todo
+	debugger
+	taskProcessInfo.refresh = true
+	taskProcessInfo.setCurrentTaskRow({})
 }
 
-// 操作按钮
+/**
+ * 详情按钮各个操作弹窗
+ * @param type 评论 拒绝 同意等
+ */
 const openComment = (type, item) => {
+	// 验证表单 todo...
+	const api = validateForm.value.api
+	api.validate((valid, fail) => {
+		if (valid) {
+			const values = api.formData()
+			console.warn(values, 'values')
+			//todo 表单验证通过
+		} else {
+			//todo 表单验证未通过
+		}
+	})
+	// return
+
 	switch (type) {
 		case 'reviewVisible':
 			reviewVisible.value = !reviewVisible.value
@@ -205,22 +215,6 @@ const openComment = (type, item) => {
 			addSignVisible.value = !addSignVisible.value
 			break
 		case 'consentOrRefuseVisible':
-			// 点击同意
-			if (item === 'agree') {
-				debugger
-				// 验证表单 todo...
-				const api = validateForm.value.api
-				api.validate((valid, fail) => {
-					if (valid) {
-						const values = api.formData()
-						console.warn(values, 'values')
-						//todo 表单验证通过
-					} else {
-						//todo 表单验证未通过
-					}
-				})
-				// return
-			}
 			currentDialog.value = item
 			consentOrRefuseVisible.value = !consentOrRefuseVisible.value
 			break
@@ -236,9 +230,11 @@ const openComment = (type, item) => {
 	}
 }
 
-nextTick(() => {
-	if(!visibleDialog.value) return
-	const cur = props.taskObj || {}
+/**
+ * 获取taskId对应的详情
+ */
+const getTaskDetail = () => {
+	const cur = currentTaskRow.value || {}
 	processApprovalInfoApi(cur.taskId).then(data => {
 		// console.log(JSON.stringify(data))
 		activeData.value = data
@@ -294,7 +290,22 @@ nextTick(() => {
 		.finally(() => {
 			validateForm.value.loading = false
 		})
-})
+}
+
+/**
+ * 监听同级子组件的taskId的值变化
+ * 1、监听taskId的值变化,如果值有变化,则重新获取审批详情
+ * 2、如果taskId没有值,则不请求接口,暂时暂无数据img
+ */
+watch(
+	() => currentTaskRow.value.taskId,
+	(nValue, oValue) => {
+		if (!nValue) return
+		nextTick(() => {
+			getTaskDetail()
+		})
+	}
+)
 </script>
 
 <style scoped lang="scss">

+ 47 - 10
src/views/approve/components/approvedItem.vue

@@ -21,7 +21,13 @@
 		</div>
 		<!-- 内容值 -->
 		<div v-infinite-scroll="load" :infinite-scroll-disabled="disabledInfinite" class="flow-list-box">
-			<div v-for="i in satelliteList" :key="i.taskId" class="item-box" :class="[i === 2 ? 'item-box-choosed' : '']">
+			<div
+				v-for="i in satelliteList"
+				:key="i.taskId"
+				class="item-box"
+				:class="[i.taskId === taskProcessInfo.currentTaskRow.taskId ? 'item-box-choosed' : '']"
+				@click="getTaskDetail(i)"
+			>
 				<div class="flow-card-box flow-card-box-hoverable">
 					<!--头部-->
 					<div class="header">
@@ -48,20 +54,27 @@
 </template>
 
 <script setup>
+import useTaskProcessStore from '@/store/modules/taskProcess'
 import FlowNodeAvatar from '@/components/Flow/FlowNodeAvatar.vue'
 import { Search, Filter, Refresh } from '@element-plus/icons-vue'
-import { computed, onMounted, reactive, ref } from 'vue'
+import { computed, onMounted, reactive, ref, watch } from 'vue'
 import { processTaskPagePendingApprovalApi } from '@/api/flow/processTask'
 
-const satelliteList = ref([])
+// store值
+const taskProcessInfo = useTaskProcessStore()
+
 const input3 = ref('')
-const loading = ref(false)
-const totalNumber = ref(0)
-const totalPages = ref(0)
+// 下拉滚动属性值 start
+const loading = ref(false) // loading
+const totalNumber = ref(0) // 总条数
+const totalPages = ref(0) // 总页数
+// 当前页码数和每页条数
 const condition = reactive({
 	page: 1,
 	pageSize: 10
 })
+const satelliteList = ref([]) // 列表数据
+// 下拉滚动属性值 end
 
 // 初始化
 const init = () => {
@@ -70,6 +83,8 @@ const init = () => {
 	satelliteList.value = []
 	totalNumber.value = 0
 	totalPages.value = 0
+	taskProcessInfo.refresh = false
+	taskProcessInfo.setCurrentTaskRow({})
 }
 
 // 分页获取数据
@@ -81,12 +96,15 @@ const load = () => {
 // 获取分页数据
 const getPagedSatellites = async () => {
 	try {
-		const { records, total, current } = await processTaskPagePendingApprovalApi(condition)
-		satelliteList.value = satelliteList.value.concat(records)
+		const { records, total, pages } = await processTaskPagePendingApprovalApi(condition)
+		records.forEach(item => {
+			satelliteList.value.push(item)
+		})
 		totalNumber.value = total
-		totalPages.value = current
+		totalPages.value = pages
 		loading.value = false
 		if (condition.page > totalPages.value) {
+			console.log('没有更多数据了')
 			return
 		}
 		condition.page++
@@ -95,13 +113,32 @@ const getPagedSatellites = async () => {
 	}
 }
 
+// 点击当前实例的具体
+const getTaskDetail = item => {
+	taskProcessInfo.setCurrentTaskRow(item)
+}
+
 onMounted(() => {
 	init()
 })
 
+/**
+ * 监听同级子组件通知
+ * 1、监听refresh的值变化,进行刷新
+ */
+watch(
+	() => taskProcessInfo.refresh,
+	(nValue, oValue) => {
+		if (nValue) {
+			init()
+		}
+	},
+	{ immediate: true }
+)
+
 const noMore = computed(() => satelliteList.value.length > totalNumber.value)
 
-const disabledInfinite = computed(() => loading.value || noMore.value)
+const disabledInfinite = computed(() => noMore.value)
 </script>
 
 <style scoped lang="scss">

+ 2 - 10
src/views/approve/components/consentOrRefuseDialog.vue

@@ -47,15 +47,6 @@ const props = defineProps({
 	currentType: {
 		type: String,
 		default: 'agree'
-	},
-	showOrderDesc: {
-		type: Boolean,
-		default: true
-	},
-	// 1-审核 2-复审 3-审核,复审 ,第一版默认审核
-	linkType: {
-		type: String,
-		default: '1'
 	}
 })
 const btnDisabled = ref(false)
@@ -66,7 +57,7 @@ const form = reactive({
 const formRef = ref(null)
 const uploadLoading = ref(false)
 
-const $myEmit = defineEmits(['update:modelValue'])
+const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 const submitForm = () => {
 	btnDisabled.value = true
@@ -90,6 +81,7 @@ const submitForm = () => {
 }
 
 const closeDialog = () => {
+	$myEmit('successCb')
 	$myEmit('update:modelValue', false)
 }
 

+ 2 - 1
src/views/approve/components/deliverToReviewDialog.vue

@@ -74,7 +74,7 @@ const form = reactive({
 const formRef = ref(null)
 const uploadLoading = ref(false)
 const userOptList = ref([])
-const $myEmit = defineEmits(['update:modelValue', 'confirm'])
+const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 // 获取用户
 const getUserList = async () => {
@@ -120,6 +120,7 @@ const submitForm = () => {
 }
 
 const closeDialog = () => {
+	$myEmit('successCb')
 	$myEmit('update:modelValue', false)
 }
 

+ 3 - 11
src/views/approve/components/loseSignDialog.vue

@@ -41,15 +41,6 @@ const props = defineProps({
 		type: Boolean,
 		default: false
 	},
-	showOrderDesc: {
-		type: Boolean,
-		default: true
-	},
-	// 1-审核 2-复审 3-审核,复审 ,第一版默认审核
-	linkType: {
-		type: String,
-		default: '1'
-	},
 	taskId: {
 		type: String,
 		default: undefined
@@ -86,7 +77,7 @@ const options = [
 	}
 ]
 
-const $myEmit = defineEmits(['update:modelValue', 'confirm'])
+const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 const submitForm = () => {
 	btnDisabled.value = true
@@ -95,7 +86,7 @@ const submitForm = () => {
 		.validate()
 		.then(valid => {
 			if (valid) {
-				emit('confirm', formData)
+				emit('successCb', formData)
 				btnDisabled.value = false
 			}
 		})
@@ -106,6 +97,7 @@ const submitForm = () => {
 }
 
 const closeDialog = () => {
+	$myEmit('successCb')
 	$myEmit('update:modelValue', false)
 }
 

+ 2 - 10
src/views/approve/components/reviewDialog.vue

@@ -37,15 +37,6 @@ const props = defineProps({
 		type: Boolean,
 		default: false
 	},
-	showOrderDesc: {
-		type: Boolean,
-		default: true
-	},
-	// 1-审核 2-复审 3-审核,复审 ,第一版默认审核
-	linkType: {
-		type: String,
-		default: '1'
-	},
 	taskId: {
 		type: String,
 		default: undefined
@@ -59,7 +50,7 @@ const form = reactive({
 const formRef = ref(null)
 const uploadLoading = ref(false)
 
-const $myEmit = defineEmits(['update:modelValue'])
+const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 // 提交
 const submitForm = () => {
@@ -80,6 +71,7 @@ const submitForm = () => {
 }
 
 const closeDialog = () => {
+	$myEmit('successCb')
 	$myEmit('update:modelValue', false)
 }
 

+ 2 - 11
src/views/approve/components/rollbackDialog.vue

@@ -41,15 +41,6 @@ const props = defineProps({
 		type: Boolean,
 		default: false
 	},
-	showOrderDesc: {
-		type: Boolean,
-		default: true
-	},
-	// 1-审核 2-复审 3-审核,复审 ,第一版默认审核
-	linkType: {
-		type: String,
-		default: '1'
-	},
 	taskId: {
 		type: String,
 		default: undefined
@@ -86,7 +77,7 @@ const options = [
 	}
 ]
 
-const $myEmit = defineEmits(['update:modelValue', 'confirm'])
+const $myEmit = defineEmits(['update:modelValue', 'successCb'])
 
 const submitForm = () => {
 	btnDisabled.value = true
@@ -95,7 +86,6 @@ const submitForm = () => {
 		.validate()
 		.then(valid => {
 			if (valid) {
-				emit('confirm', formData)
 				btnDisabled.value = false
 			}
 		})
@@ -106,6 +96,7 @@ const submitForm = () => {
 }
 
 const closeDialog = () => {
+	$myEmit('successCb')
 	$myEmit('update:modelValue', false)
 }