Commit 3ab02e71 by chenwq1

fix: gengxin

1 parent c89c9543
No preview for this file type
/**
* 复制文本到剪贴板。优先 Clipboard API,非 HTTPS 等场景回退 execCommand。
*/
export async function copyText(text: unknown): Promise<void> {
const value = String(text ?? "").trim();
if (!value) {
throw new Error("empty");
}
if (navigator.clipboard?.writeText) {
try {
await navigator.clipboard.writeText(value);
return;
} catch {
// 非安全上下文或权限被拒时回退
}
}
const textarea = document.createElement("textarea");
textarea.value = value;
textarea.setAttribute("readonly", "");
textarea.style.position = "fixed";
textarea.style.left = "-9999px";
textarea.style.top = "0";
textarea.style.opacity = "0";
document.body.appendChild(textarea);
textarea.focus();
textarea.select();
textarea.setSelectionRange(0, value.length);
const ok = document.execCommand("copy");
document.body.removeChild(textarea);
if (!ok) {
throw new Error("copy failed");
}
}
......@@ -27,15 +27,15 @@
</div>
</div>
</div>
<div class="customizeFormBox" v-if="activeNodeId != -1">
<div ref="customizeFormBoxRef" class="customizeFormBox">
<CustomizeForm
v-if="activeNodeId != -1"
ref="customizeFormRef"
:readonly="readonly"
@submitSuccess="onFormSubmitSuccess"
/>
</div>
<div class="customizeFormBox" v-if="activeNodeId == -1">
<TestingScore
v-if="activeNodeId == -1"
ref="testingScoreRef"
:readonly="readonly"
@submitSuccess="onFormSubmitSuccess"
......@@ -203,6 +203,16 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
activeNodeId: this.activeNodeId,
taskId: routeData.id,
});
this.scrollCustomizeFormToTop();
});
}
scrollCustomizeFormToTop() {
this.$nextTick(() => {
const el = this.$refs.customizeFormBoxRef as HTMLElement | undefined;
if (el) {
el.scrollTop = 0;
}
});
}
......@@ -290,6 +300,7 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
switchNode(item: any) {
this.activeNodeId = item.id;
this.scrollCustomizeFormToTop();
if (Number(item.id) > 0) {
this.getInspectionNodeData(this.activeNodeId);
}
......
......@@ -355,7 +355,25 @@ export default class CustomizeForm extends Vue {
this.carTypeList = data.carTypeList || [];
this.activeNodeId = data.activeNodeId || "";
this.taskId = data.taskId || "";
this.snapshotInitialValues();
this.scheduleSnapshotInitialValues();
}
getLeafSnapshotValue(node: any): string {
if (node?.interactionType === "image_upload_and_button_select") {
return TrackHelper.normalize({
value: node.value,
uploadValue: node.uploadValue,
});
}
return TrackHelper.normalize(node.value);
}
scheduleSnapshotInitialValues() {
this.$nextTick(() => {
this.$nextTick(() => {
this.snapshotInitialValues();
});
});
}
snapshotInitialValues() {
......@@ -366,7 +384,7 @@ export default class CustomizeForm extends Vue {
if (node?.childrenNodes && node.childrenNodes.length) {
walk(node.childrenNodes);
} else if (node?.id != null) {
leafMap[node.id] = TrackHelper.normalize(node.value);
leafMap[node.id] = this.getLeafSnapshotValue(node);
nameMap[node.id] = node.nodeName || String(node.id);
}
});
......@@ -387,7 +405,7 @@ export default class CustomizeForm extends Vue {
if (node?.childrenNodes && node.childrenNodes.length) {
walk(node.childrenNodes);
} else if (node?.id != null) {
current[node.id] = TrackHelper.normalize(node.value);
current[node.id] = this.getLeafSnapshotValue(node);
}
});
};
......@@ -563,7 +581,7 @@ export default class CustomizeForm extends Vue {
this.$emit("submitSuccess", res);
message.success(res.message || "保存成功");
this.sendSaveTrack(modifiedFields);
this.snapshotInitialValues();
this.scheduleSnapshotInitialValues();
} else {
message.error(res.message || "保存失败");
}
......
......@@ -11,6 +11,7 @@
</template>
<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-facing-decorator";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ components: {} })
......@@ -25,8 +26,8 @@ export default class CustomizeFormButtonSelect extends Vue {
pickerValue = []
// item.resultStatus 变化时,清空选择项
@Watch('item.resultStatus', { deep: true, immediate: true })
watchItem(newValue: any, oldValue: any): void {
@Watch("item.resultStatus")
watchItem(newValue: boolean): void {
if (newValue) {
this.pickerValue = [];
this.setupdate();
......@@ -39,7 +40,18 @@ export default class CustomizeFormButtonSelect extends Vue {
// 初始化数据
initData() {
this.pickerValue = this.item?.inspectionResultVO?.inspectionValueList?.filter(item => item.valueKey && item.interactionType == "button_select")?.map(item => item.valueKey) || [];
if (this.item?.resultStatus) {
this.pickerValue = [];
return;
}
this.pickerValue =
this.item?.inspectionResultVO?.inspectionValueList
?.filter(
(entry) =>
entry.valueKey &&
entry.interactionType == "button_select",
)
?.map((entry) => entry.valueKey) || [];
this.setupdate();
}
......@@ -59,15 +71,22 @@ export default class CustomizeFormButtonSelect extends Vue {
}
setupdate() {
const valueList = (this.pickerValue || []).map(item => {
const object = (this.columnsList || []).find(finditem => finditem.value == item) || {};
const valueList = (this.pickerValue || []).map((item) => {
const object =
(this.columnsList || []).find(
(finditem) => finditem.value == item,
) || {};
return { valueText: object.text || "", valueKey: item || "" };
});
if (valueList.length > 0) {
this.$emit("update", JSON.stringify(valueList || []));
} else {
this.$emit("update", "");
const nextValue =
valueList.length > 0 ? JSON.stringify(valueList) : "";
if (
TrackHelper.normalize(this.item?.value) ===
TrackHelper.normalize(nextValue)
) {
return;
}
this.$emit("update", nextValue);
}
}
......
<template>
<div>
<div class="abnormal-image-upload">
<div class="abnormal-image-upload__title">
异常图片<span class="abnormal-image-upload__required">*</span>
</div>
<div class="abnormal-image-upload__subtitle">
有损伤请拍摄图片,无损伤请忽略
</div>
<div class="hidden-input">
<input
ref="fileInputRef"
......@@ -43,6 +49,7 @@ import { Component, Prop, Vue, Watch } from "vue-facing-decorator";
import { uploadFile, isLikelyImageFile } from "@/utils/upload.js";
import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ components: { PlusOutlined, CloseCircleOutlined } })
export default class CustomizeFormButtonSelectUploadFile extends Vue {
......@@ -54,8 +61,8 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue {
pickerValue: any = [];
// item.resultStatus 变化时,清空选择项
@Watch("item.resultStatus", { deep: true, immediate: true })
watchItem(newValue: any, oldValue: any): void {
@Watch("item.resultStatus")
watchItem(newValue: boolean): void {
if (newValue) {
this.pickerValue = [];
this.updateData();
......@@ -140,16 +147,49 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue {
}
updateData() {
if (this.pickerValue.length > 0) {
this.$emit("update", JSON.stringify(this.pickerValue));
} else {
this.$emit("update", "");
const nextValue =
this.pickerValue.length > 0
? JSON.stringify(this.pickerValue)
: "";
if (
TrackHelper.normalize(this.item?.uploadValue) ===
TrackHelper.normalize(nextValue)
) {
return;
}
this.$emit("update", nextValue);
}
}
</script>
<style scoped lang="less">
.abnormal-image-upload {
width: 100%;
float: left;
margin-top: 8px;
}
.abnormal-image-upload__title {
font-size: 14px;
font-weight: 500;
line-height: 22px;
color: #2f3133;
}
.abnormal-image-upload__required {
margin-left: 4px;
color: #eb4e4e;
}
.abnormal-image-upload__subtitle {
margin-top: 4px;
margin-bottom: 12px;
font-size: 12px;
font-weight: 400;
line-height: 20px;
color: #777c85;
}
.hidden-input {
position: absolute;
width: 0;
......
......@@ -86,6 +86,7 @@ import { Component, Prop, Vue } from "vue-facing-decorator";
import { uploadFile, isLikelyImageFile, isLikelyVideoFile } from "@/utils/upload.js";
import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ components: { PlusOutlined, CloseCircleOutlined } })
export default class CustomizeFormUploadFile extends Vue {
......@@ -178,11 +179,17 @@ export default class CustomizeFormUploadFile extends Vue {
}
updateData() {
if (this.pickerValue.length > 0) {
this.$emit("update", JSON.stringify(this.pickerValue));
} else {
this.$emit("update", "");
const nextValue =
this.pickerValue.length > 0
? JSON.stringify(this.pickerValue)
: "";
if (
TrackHelper.normalize(this.item?.value) ===
TrackHelper.normalize(nextValue)
) {
return;
}
this.$emit("update", nextValue);
}
previewVideo(url: string) {
......
......@@ -53,6 +53,7 @@
import { Component, Vue } from "vue-facing-decorator";
import { DetectionController } from "@/api/DetectionController";
import { CopyOutlined } from "@ant-design/icons-vue";
import { copyText } from "@/utils/copyText";
import { message } from "ant-design-vue";
import { h, type VNode } from "vue";
......@@ -191,7 +192,7 @@ export default class OperationLog extends Vue {
return;
}
try {
await navigator.clipboard.writeText(text);
await copyText(text);
message.success("复制成功");
} catch {
message.error("复制失败");
......
......@@ -161,6 +161,7 @@ import TitleTipIcon from "@/components/icons/TitleTipIcon.vue";
import VehicleStateTag from "@/views/vehicle/inventory/VehicleStateTag.vue";
import { CopyOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue";
import { copyText } from "@/utils/copyText";
@Component({
components: { TitleDivider, TitleTipIcon, VehicleStateTag, CopyOutlined }
......@@ -174,12 +175,12 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> {
@Prop({ type: Object, required: true })
inspectionReportResp: any;
async copyCustomText(text) {
async copyCustomText(text: unknown) {
try {
await navigator.clipboard.writeText(text);
message.success('复制成功');
} catch (err) {
message.error('复制失败');
await copyText(text);
message.success("复制成功");
} catch {
message.error("复制失败");
}
}
......
......@@ -199,12 +199,33 @@ export function syncLeafNodeFormValue(
return;
}
if (interactionType === "button_select") {
const entries = list.map((entry) => ({
valueKey: String(entry.valueKey ?? ""),
valueText: String(entry.valueText ?? ""),
}));
if (
interactionType === "button_select" ||
interactionType === "image_upload_and_button_select"
) {
const entries = list
.filter((entry) => entry.interactionType === "button_select")
.map((entry) => ({
valueKey: String(entry.valueKey ?? ""),
valueText: String(entry.valueText ?? ""),
}));
node.value = entries.length > 0 ? JSON.stringify(entries) : "";
if (interactionType === "image_upload_and_button_select") {
const uploadUrls = list
.filter((entry) => entry.interactionType === "image_upload")
.map((entry) => String(entry.valueText ?? ""))
.filter((text) => text !== "");
node.uploadValue =
uploadUrls.length > 0 ? JSON.stringify(uploadUrls) : "";
}
return;
}
if (interactionType === "image_upload" || interactionType === "video_upload") {
const urls = list
.map((entry) => String(entry.valueText ?? ""))
.filter((text) => text !== "");
node.value = urls.length > 0 ? JSON.stringify(urls) : "";
return;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!