From 24acfc8a10ddc339efeeedd51b6720dbdcd59d53 Mon Sep 17 00:00:00 2001
From: buaixuexideshitongxue <2936013465@qq.com>
Date: Fri, 5 Dec 2025 15:03:52 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=89=B9=E4=BA=BA=E8=AE=B0=E5=BF=86?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/reportAudit/finish.vue | 69 ++++++++++++++++++++++++--
src/components/reportAudit/start.vue | 45 ++++++++++++++++-
src/utils/lastChoice.ts | 46 +++++++++++++++++
src/views/entryWindow/index.vue | 2 +-
src/views/report/edit/controlPrice.vue | 4 +-
src/views/work/work.vue | 2 +-
6 files changed, 158 insertions(+), 10 deletions(-)
create mode 100644 src/utils/lastChoice.ts
diff --git a/src/components/reportAudit/finish.vue b/src/components/reportAudit/finish.vue
index f9741bd..bea6fae 100644
--- a/src/components/reportAudit/finish.vue
+++ b/src/components/reportAudit/finish.vue
@@ -6,13 +6,13 @@ import {listPolice} from "@/api/system/police";
import {getList,save,delCommon} from '@/api/commonOpinions';
import useCatchStore from "@/stores/modules/catch";
import useUserStore from "@/stores/modules/user";
+import { saveLastChoice, loadLastChoice } from '@/utils/lastChoice';
+
const userStore = useUserStore();
const props = defineProps(['dialog','reportId','node','isAudit'])
const emits = defineEmits(['submitFeedback',"closeFun"])
const loading =ref(false)
-
const catchSotre = useCatchStore();
-
const departs = catchSotre.getDeparts() ;
const formData = ref({
isInform:'1'
@@ -45,6 +45,7 @@ const flowNodes = ref([
value:'audit'
}
])
+const silentUnitChange = ref(false);
const getNodesFun = (val)=>{
let data = [];
@@ -141,7 +142,7 @@ function getPoliceList() {
});
loading.value=false
}
-getPoliceList()
+// getPoliceList()
// 获取常用意见
const commonList =ref([])
@@ -206,12 +207,72 @@ const submitFun = async ()=>{
//nextNode
const res = await auditReport(formData.value);
+ // === 写回“当前节点桶”的最近一次选择 ===
+ try {
+ const curUserId = userStore?.user?.userName || userStore?.user?.id || '';
+ const nodeKey = formData.value.nextNode || 'default';
+ saveLastChoice(curUserId, nodeKey, {
+ approverUnitId: formData.value.approverUnitId,
+ approverUnit: formData.value.approverUnit,
+ approverId: formData.value.approverId,
+ approver: formData.value.approver,
+ });
+ } catch (e) {}
+
feedback.msgSuccess("操作成功");
emits('submitFeedback',true)
closeAdd()
}
+// 计算“记忆桶”的节点 key(优先使用当前选择的 nextNode)
+const nodeKeyOf = (nodeOverride) => nodeOverride || formData.value.nextNode || 'default';
+
+// 事件:当选择“办理流程”节点时,从缓存拿数据回显
+const handleFlowChange = async (node) => {
+ debugger
+ // 确保模型已是最新节点
+ formData.value.nextNode = node;
+ // 2) 读取上次选择(按 用户ID + 节点 分桶)
+ const uid = userStore?.user?.userName || userStore?.user?.id || '';
+ const hint = loadLastChoice(uid, nodeKeyOf(node));
+ if (!hint){
+ // formData.value.approverUnitId = null;
+ // formData.value.approverUnit = null;
+ // formData.value.approverId = null;
+ // formData.value.approver = null;
+ return;
+ }
+
+ // —— 开始静默:避免 watcher 再拉一次 ——
+ silentUnitChange.value = true;
+ // 3) 直接覆盖“办理单位”
+ formData.value.approverUnitId = hint.approverUnitId ?? null;
+ formData.value.approverUnit = hint.approverUnit ?? null;
+
+ // 4) 为了让“审核人”下拉是该单位的人,按单位拉一次人员列表(不做任何判断,强制拉)
+ if (hint.approverUnitId) {
+ query.value.departId = hint.approverUnitId;
+ loading.value = true;
+ try {
+ const data = await listPolice(query.value);
+ polices.value = data?.records || [];
+ } finally {
+ loading.value = false;
+ delete query.value.departId;
+ }
+ }
+
+ // 5) 直接覆盖“审核人”
+ formData.value.approverId = hint.approverId ?? null;
+ formData.value.approver = hint.approver ?? null;
+ // —— 结束静默 ——
+ silentUnitChange.value = false;
+};
+
+
+
+
watch(()=>props.dialog,(val)=>{
debugger
if(val){
@@ -268,7 +329,7 @@ watch(()=>formData.value.approverId,(val)=>{
-
+
diff --git a/src/components/reportAudit/start.vue b/src/components/reportAudit/start.vue
index cbcf746..fd3746b 100644
--- a/src/components/reportAudit/start.vue
+++ b/src/components/reportAudit/start.vue
@@ -7,9 +7,11 @@
import useCatchStore from "@/stores/modules/catch";
import useUserStore from "@/stores/modules/user";
const userStore = useUserStore();
- const props = defineProps(['dialog','reportId','nextNode','message',"isWarning","isCityAudit","reportProject"])
+ const props = defineProps(['dialog','reportId','nextNode','message',"isWarning","isCityAudit","reportProject", 'currentNode'])
const emits = defineEmits(['submitFeedback',"closeFun"])
import { getDictValue } from "@/utils/util";
+ import { saveLastChoice, loadLastChoice } from '@/utils/lastChoice';
+
const catchSotre = useCatchStore();
const dict = catchSotre.getDicts(["AuditUnitPresetting","ReviewePresetSetting"]);
@@ -111,6 +113,18 @@
const res = await auditReport(formData.value);
}
+ // === 追加:保存缓存 ===
+ try {
+ const curUserId = userStore?.user?.userName || userStore?.user?.id || '';
+ const nodeKey = props.currentNode || props.nextNode || 'default';
+ saveLastChoice(curUserId, nodeKey, {
+ approverUnitId: formData.value.approverUnitId,
+ approverUnit: formData.value.approverUnit,
+ approverId: formData.value.approverId,
+ approver: formData.value.approver,
+ });
+ } catch (e) {}
+
feedback.msgSuccess("操作成功");
emits('submitFeedback',true)
closeAdd()
@@ -200,9 +214,36 @@
}
}
+ }
+ // === 回显“上次选择”:仅当当前字段为空时才回填 ===
+ try {
+ const curUserId = userStore?.user?.userName || userStore?.user?.id || '';
+ const nodeKey = props.currentNode || props.nextNode || 'default';
+
+ const hint = loadLastChoice(curUserId, nodeKey);
+ if (hint) {
+ // 单位
+ if (hint.approverUnitId) {
+ formData.value.approverUnitId = hint.approverUnitId;
+ formData.value.approverUnit = hint.approverUnit;
+
+ // 如果按单位筛人,触发一次人员加载
+ if (props.isWarning !== 'inform') {
+ query.value.departId = hint.approverUnitId;
+ getPoliceList();
+ delete query.value.departId;
+ }
+ }
+
+ // 审核人
+ if ( hint.approverId) {
+ formData.value.approverId = hint.approverId;
+ formData.value.approver = hint.approver;
+ }
+ }
+ } catch (e) {}
- }
})
watch(
diff --git a/src/utils/lastChoice.ts b/src/utils/lastChoice.ts
new file mode 100644
index 0000000..2e66cfe
--- /dev/null
+++ b/src/utils/lastChoice.ts
@@ -0,0 +1,46 @@
+// 记忆“上次选择的单位和人员”——按 用户ID + 节点 分桶
+export type WfNode =
+ | 'initial' | 'review' | 'first' | 'second' | 'third'
+ | 'original' | 'audit' | 'end' | string;
+
+const LS_KEY = 'wf_last_choice_v1';
+
+function keyOf(userId: string | number, node: WfNode) {
+ return `${userId ?? ''}__${node ?? ''}`;
+}
+
+function loadAll(): Record {
+ try {
+ return JSON.parse(localStorage.getItem(LS_KEY) || '{}');
+ } catch {
+ return {};
+ }
+}
+
+function saveAll(map: Record) {
+ localStorage.setItem(LS_KEY, JSON.stringify(map));
+}
+
+export function saveLastChoice(
+ userId: string | number,
+ node: WfNode,
+ payload: {
+ approverUnitId?: string | number;
+ approverUnit?: string;
+ approverId?: string | number;
+ approver?: string;
+ }
+) {
+ const map = loadAll();
+ map[keyOf(userId, node)] = { ...payload, updatedAt: Date.now() };
+ saveAll(map);
+}
+
+export function loadLastChoice(userId: string | number, node: WfNode) {
+ const map = loadAll();
+ return map[keyOf(userId, node)];
+}
+
+export function clearAllLastChoice() {
+ localStorage.removeItem(LS_KEY);
+}
diff --git a/src/views/entryWindow/index.vue b/src/views/entryWindow/index.vue
index 7a65892..519df81 100644
--- a/src/views/entryWindow/index.vue
+++ b/src/views/entryWindow/index.vue
@@ -449,7 +449,7 @@ const isAdminShow = ()=>{
{{timeFormat(row.projectApprovalTime)}}
-
+
编辑
diff --git a/src/views/report/edit/controlPrice.vue b/src/views/report/edit/controlPrice.vue
index 9bbac1c..3ef9459 100644
--- a/src/views/report/edit/controlPrice.vue
+++ b/src/views/report/edit/controlPrice.vue
@@ -834,7 +834,7 @@ watch(()=>formData.value.review.thirdlyMoney,(val)=>{
-
+
@@ -1384,7 +1384,7 @@ watch(()=>formData.value.review.thirdlyMoney,(val)=>{
+ :dialog="dialog" :currentNode="formData.project.node"/>
{
}
//我的待办点击
const rowWorkClick = (row) => {
- console.log('initial',row.flowCode)
+ console.log('当前待办项目节点',row.flowCode)
let isEnd = row.reportType === "结算项目";
if(row.isWarning){