这一版本优化了很多
This commit is contained in:
@@ -41,14 +41,14 @@ const _sfc_main = {
|
||||
});
|
||||
userList.value = users;
|
||||
userColumns.value = [users.map((u) => u.name)];
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:83", "整改人员列表:", users);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:91", "整改人员列表:", users);
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/assignment.vue:86", "获取部门人员失败:", error);
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/assignment.vue:94", "获取部门人员失败:", error);
|
||||
}
|
||||
};
|
||||
const onUserConfirm = (e) => {
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:92", "选择的人员:", e);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:100", "选择的人员:", e);
|
||||
if (e.value && e.value.length > 0) {
|
||||
selectedUser.value = e.value[0];
|
||||
const user = userList.value.find((u) => u.name === e.value[0]);
|
||||
@@ -59,7 +59,7 @@ const _sfc_main = {
|
||||
showUserPicker.value = false;
|
||||
};
|
||||
const onDateConfirm = (e) => {
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:106", "选择的日期时间:", e);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:114", "选择的日期时间:", e);
|
||||
const date = new Date(e.value);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
@@ -92,10 +92,11 @@ const _sfc_main = {
|
||||
assignRemark: ""
|
||||
// 交办备注(可选)
|
||||
};
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:142", "提交数据:", params);
|
||||
common_vendor.index.__f__("log", "at pages/hiddendanger/assignment.vue:150", "提交数据:", params);
|
||||
try {
|
||||
const res = await request_api.assignHiddenDanger(params);
|
||||
if (res.code === 0) {
|
||||
clearDraft(false);
|
||||
common_vendor.index.showToast({ title: "交办成功", icon: "success" });
|
||||
setTimeout(() => {
|
||||
common_vendor.index.navigateBack();
|
||||
@@ -104,45 +105,122 @@ const _sfc_main = {
|
||||
common_vendor.index.showToast({ title: res.msg || "交办失败", icon: "none" });
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/assignment.vue:155", "交办失败:", error);
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/assignment.vue:164", "交办失败:", error);
|
||||
common_vendor.index.showToast({ title: "请求失败", icon: "none" });
|
||||
}
|
||||
};
|
||||
const hasDraft = common_vendor.ref(false);
|
||||
const showRestoreBanner = common_vendor.ref(false);
|
||||
const isRestoring = common_vendor.ref(false);
|
||||
const getDraftKey = () => `draft_assign_${hazardId.value || ""}`;
|
||||
const saveDraft = () => {
|
||||
if (isRestoring.value)
|
||||
return;
|
||||
const key = getDraftKey();
|
||||
const hasContent = selectedDate.value;
|
||||
if (!hasContent) {
|
||||
common_vendor.index.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
selectedDate: selectedDate.value,
|
||||
dateValue: dateValue.value
|
||||
};
|
||||
common_vendor.index.setStorageSync(key, JSON.stringify(data));
|
||||
hasDraft.value = true;
|
||||
};
|
||||
const clearDraft = (showToast = true) => {
|
||||
const key = getDraftKey();
|
||||
common_vendor.index.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
showRestoreBanner.value = false;
|
||||
isRestoring.value = true;
|
||||
selectedDate.value = "";
|
||||
dateValue.value = Date.now();
|
||||
common_vendor.nextTick$1(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
if (showToast) {
|
||||
common_vendor.index.showToast({ title: "草稿已清空", icon: "none" });
|
||||
}
|
||||
};
|
||||
const restoreDraft = () => {
|
||||
const key = getDraftKey();
|
||||
const cached = common_vendor.index.getStorageSync(key);
|
||||
if (cached) {
|
||||
try {
|
||||
const data = JSON.parse(cached);
|
||||
const hasContent = data.selectedDate;
|
||||
if (!hasContent)
|
||||
return;
|
||||
isRestoring.value = true;
|
||||
selectedDate.value = data.selectedDate || "";
|
||||
dateValue.value = data.dateValue || Date.now();
|
||||
hasDraft.value = true;
|
||||
showRestoreBanner.value = true;
|
||||
common_vendor.nextTick$1(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
common_vendor.index.showToast({
|
||||
title: "已自动恢复您上次未提交的内容",
|
||||
icon: "none",
|
||||
duration: 2500
|
||||
});
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/hiddendanger/assignment.vue:239", "解析草稿失败:", e);
|
||||
isRestoring.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
common_vendor.watch(
|
||||
() => [selectedDate.value],
|
||||
() => {
|
||||
if (hazardId.value) {
|
||||
saveDraft();
|
||||
}
|
||||
}
|
||||
);
|
||||
common_vendor.onLoad((options) => {
|
||||
if (options.hazardId)
|
||||
hazardId.value = options.hazardId;
|
||||
if (options.assignId)
|
||||
assignId.value = options.assignId;
|
||||
fetchDeptUsers();
|
||||
restoreDraft();
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.t(selectedUser.value || "请选择整改人员"),
|
||||
b: common_vendor.n(selectedUser.value ? "" : "text-gray"),
|
||||
c: common_vendor.o(($event) => showUserPicker.value = true),
|
||||
d: common_vendor.o(onUserConfirm),
|
||||
e: common_vendor.o(($event) => showUserPicker.value = false),
|
||||
f: common_vendor.o(($event) => showUserPicker.value = false),
|
||||
g: common_vendor.p({
|
||||
return common_vendor.e({
|
||||
a: showRestoreBanner.value
|
||||
}, showRestoreBanner.value ? {
|
||||
b: common_vendor.o(($event) => clearDraft(true))
|
||||
} : {}, {
|
||||
c: common_vendor.t(selectedUser.value || "请选择整改人员"),
|
||||
d: common_vendor.n(selectedUser.value ? "" : "text-gray"),
|
||||
e: common_vendor.o(($event) => showUserPicker.value = true),
|
||||
f: common_vendor.o(onUserConfirm),
|
||||
g: common_vendor.o(($event) => showUserPicker.value = false),
|
||||
h: common_vendor.o(($event) => showUserPicker.value = false),
|
||||
i: common_vendor.p({
|
||||
show: showUserPicker.value,
|
||||
columns: userColumns.value
|
||||
}),
|
||||
h: common_vendor.t(selectedDate.value || "请选择整改期限"),
|
||||
i: common_vendor.n(selectedDate.value ? "" : "text-gray"),
|
||||
j: common_vendor.o(($event) => showDatePicker.value = true),
|
||||
k: common_vendor.o(onDateConfirm),
|
||||
l: common_vendor.o(($event) => showDatePicker.value = false),
|
||||
m: common_vendor.o(($event) => showDatePicker.value = false),
|
||||
n: common_vendor.o(($event) => dateValue.value = $event),
|
||||
o: common_vendor.p({
|
||||
j: common_vendor.t(selectedDate.value || "请选择整改期限"),
|
||||
k: common_vendor.n(selectedDate.value ? "" : "text-gray"),
|
||||
l: common_vendor.o(($event) => showDatePicker.value = true),
|
||||
m: common_vendor.o(onDateConfirm),
|
||||
n: common_vendor.o(($event) => showDatePicker.value = false),
|
||||
o: common_vendor.o(($event) => showDatePicker.value = false),
|
||||
p: common_vendor.o(($event) => dateValue.value = $event),
|
||||
q: common_vendor.p({
|
||||
show: showDatePicker.value,
|
||||
mode: "datetime",
|
||||
modelValue: dateValue.value
|
||||
}),
|
||||
p: common_vendor.o(handleCancel),
|
||||
q: common_vendor.o(handleSubmit),
|
||||
r: common_vendor.gei(_ctx, "")
|
||||
};
|
||||
r: common_vendor.o(handleCancel),
|
||||
s: common_vendor.o(handleSubmit),
|
||||
t: common_vendor.gei(_ctx, "")
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user