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 @@ ...@@ -27,15 +27,15 @@
</div> </div>
</div> </div>
</div> </div>
<div class="customizeFormBox" v-if="activeNodeId != -1"> <div ref="customizeFormBoxRef" class="customizeFormBox">
<CustomizeForm <CustomizeForm
v-if="activeNodeId != -1"
ref="customizeFormRef" ref="customizeFormRef"
:readonly="readonly" :readonly="readonly"
@submitSuccess="onFormSubmitSuccess" @submitSuccess="onFormSubmitSuccess"
/> />
</div>
<div class="customizeFormBox" v-if="activeNodeId == -1">
<TestingScore <TestingScore
v-if="activeNodeId == -1"
ref="testingScoreRef" ref="testingScoreRef"
:readonly="readonly" :readonly="readonly"
@submitSuccess="onFormSubmitSuccess" @submitSuccess="onFormSubmitSuccess"
...@@ -203,6 +203,16 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> { ...@@ -203,6 +203,16 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
activeNodeId: this.activeNodeId, activeNodeId: this.activeNodeId,
taskId: routeData.id, 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> { ...@@ -290,6 +300,7 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
switchNode(item: any) { switchNode(item: any) {
this.activeNodeId = item.id; this.activeNodeId = item.id;
this.scrollCustomizeFormToTop();
if (Number(item.id) > 0) { if (Number(item.id) > 0) {
this.getInspectionNodeData(this.activeNodeId); this.getInspectionNodeData(this.activeNodeId);
} }
......
...@@ -355,7 +355,25 @@ export default class CustomizeForm extends Vue { ...@@ -355,7 +355,25 @@ export default class CustomizeForm extends Vue {
this.carTypeList = data.carTypeList || []; this.carTypeList = data.carTypeList || [];
this.activeNodeId = data.activeNodeId || ""; this.activeNodeId = data.activeNodeId || "";
this.taskId = data.taskId || ""; this.taskId = data.taskId || "";
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(); this.snapshotInitialValues();
});
});
} }
snapshotInitialValues() { snapshotInitialValues() {
...@@ -366,7 +384,7 @@ export default class CustomizeForm extends Vue { ...@@ -366,7 +384,7 @@ export default class CustomizeForm extends Vue {
if (node?.childrenNodes && node.childrenNodes.length) { if (node?.childrenNodes && node.childrenNodes.length) {
walk(node.childrenNodes); walk(node.childrenNodes);
} else if (node?.id != null) { } 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); nameMap[node.id] = node.nodeName || String(node.id);
} }
}); });
...@@ -387,7 +405,7 @@ export default class CustomizeForm extends Vue { ...@@ -387,7 +405,7 @@ export default class CustomizeForm extends Vue {
if (node?.childrenNodes && node.childrenNodes.length) { if (node?.childrenNodes && node.childrenNodes.length) {
walk(node.childrenNodes); walk(node.childrenNodes);
} else if (node?.id != null) { } 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 { ...@@ -563,7 +581,7 @@ export default class CustomizeForm extends Vue {
this.$emit("submitSuccess", res); this.$emit("submitSuccess", res);
message.success(res.message || "保存成功"); message.success(res.message || "保存成功");
this.sendSaveTrack(modifiedFields); this.sendSaveTrack(modifiedFields);
this.snapshotInitialValues(); this.scheduleSnapshotInitialValues();
} else { } else {
message.error(res.message || "保存失败"); message.error(res.message || "保存失败");
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-facing-decorator"; import { Component, Prop, Vue, Watch } from "vue-facing-decorator";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ components: {} }) @Component({ components: {} })
...@@ -25,8 +26,8 @@ export default class CustomizeFormButtonSelect extends Vue { ...@@ -25,8 +26,8 @@ export default class CustomizeFormButtonSelect extends Vue {
pickerValue = [] pickerValue = []
// item.resultStatus 变化时,清空选择项 // item.resultStatus 变化时,清空选择项
@Watch('item.resultStatus', { deep: true, immediate: true }) @Watch("item.resultStatus")
watchItem(newValue: any, oldValue: any): void { watchItem(newValue: boolean): void {
if (newValue) { if (newValue) {
this.pickerValue = []; this.pickerValue = [];
this.setupdate(); this.setupdate();
...@@ -39,7 +40,18 @@ export default class CustomizeFormButtonSelect extends Vue { ...@@ -39,7 +40,18 @@ export default class CustomizeFormButtonSelect extends Vue {
// 初始化数据 // 初始化数据
initData() { 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(); this.setupdate();
} }
...@@ -59,15 +71,22 @@ export default class CustomizeFormButtonSelect extends Vue { ...@@ -59,15 +71,22 @@ export default class CustomizeFormButtonSelect extends Vue {
} }
setupdate() { setupdate() {
const valueList = (this.pickerValue || []).map(item => { const valueList = (this.pickerValue || []).map((item) => {
const object = (this.columnsList || []).find(finditem => finditem.value == item) || {}; const object =
(this.columnsList || []).find(
(finditem) => finditem.value == item,
) || {};
return { valueText: object.text || "", valueKey: item || "" }; return { valueText: object.text || "", valueKey: item || "" };
}); });
if (valueList.length > 0) { const nextValue =
this.$emit("update", JSON.stringify(valueList || [])); valueList.length > 0 ? JSON.stringify(valueList) : "";
} else { if (
this.$emit("update", ""); TrackHelper.normalize(this.item?.value) ===
TrackHelper.normalize(nextValue)
) {
return;
} }
this.$emit("update", nextValue);
} }
} }
......
<template> <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"> <div class="hidden-input">
<input <input
ref="fileInputRef" ref="fileInputRef"
...@@ -43,6 +49,7 @@ import { Component, Prop, Vue, Watch } from "vue-facing-decorator"; ...@@ -43,6 +49,7 @@ import { Component, Prop, Vue, Watch } from "vue-facing-decorator";
import { uploadFile, isLikelyImageFile } from "@/utils/upload.js"; import { uploadFile, isLikelyImageFile } from "@/utils/upload.js";
import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue"; import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ components: { PlusOutlined, CloseCircleOutlined } }) @Component({ components: { PlusOutlined, CloseCircleOutlined } })
export default class CustomizeFormButtonSelectUploadFile extends Vue { export default class CustomizeFormButtonSelectUploadFile extends Vue {
...@@ -54,8 +61,8 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue { ...@@ -54,8 +61,8 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue {
pickerValue: any = []; pickerValue: any = [];
// item.resultStatus 变化时,清空选择项 // item.resultStatus 变化时,清空选择项
@Watch("item.resultStatus", { deep: true, immediate: true }) @Watch("item.resultStatus")
watchItem(newValue: any, oldValue: any): void { watchItem(newValue: boolean): void {
if (newValue) { if (newValue) {
this.pickerValue = []; this.pickerValue = [];
this.updateData(); this.updateData();
...@@ -140,16 +147,49 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue { ...@@ -140,16 +147,49 @@ export default class CustomizeFormButtonSelectUploadFile extends Vue {
} }
updateData() { updateData() {
if (this.pickerValue.length > 0) { const nextValue =
this.$emit("update", JSON.stringify(this.pickerValue)); this.pickerValue.length > 0
} else { ? JSON.stringify(this.pickerValue)
this.$emit("update", ""); : "";
if (
TrackHelper.normalize(this.item?.uploadValue) ===
TrackHelper.normalize(nextValue)
) {
return;
} }
this.$emit("update", nextValue);
} }
} }
</script> </script>
<style scoped lang="less"> <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 { .hidden-input {
position: absolute; position: absolute;
width: 0; width: 0;
......
...@@ -86,6 +86,7 @@ import { Component, Prop, Vue } from "vue-facing-decorator"; ...@@ -86,6 +86,7 @@ import { Component, Prop, Vue } from "vue-facing-decorator";
import { uploadFile, isLikelyImageFile, isLikelyVideoFile } from "@/utils/upload.js"; import { uploadFile, isLikelyImageFile, isLikelyVideoFile } from "@/utils/upload.js";
import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue"; import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ components: { PlusOutlined, CloseCircleOutlined } }) @Component({ components: { PlusOutlined, CloseCircleOutlined } })
export default class CustomizeFormUploadFile extends Vue { export default class CustomizeFormUploadFile extends Vue {
...@@ -178,11 +179,17 @@ export default class CustomizeFormUploadFile extends Vue { ...@@ -178,11 +179,17 @@ export default class CustomizeFormUploadFile extends Vue {
} }
updateData() { updateData() {
if (this.pickerValue.length > 0) { const nextValue =
this.$emit("update", JSON.stringify(this.pickerValue)); this.pickerValue.length > 0
} else { ? JSON.stringify(this.pickerValue)
this.$emit("update", ""); : "";
if (
TrackHelper.normalize(this.item?.value) ===
TrackHelper.normalize(nextValue)
) {
return;
} }
this.$emit("update", nextValue);
} }
previewVideo(url: string) { previewVideo(url: string) {
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { DetectionController } from "@/api/DetectionController"; import { DetectionController } from "@/api/DetectionController";
import { CopyOutlined } from "@ant-design/icons-vue"; import { CopyOutlined } from "@ant-design/icons-vue";
import { copyText } from "@/utils/copyText";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import { h, type VNode } from "vue"; import { h, type VNode } from "vue";
...@@ -191,7 +192,7 @@ export default class OperationLog extends Vue { ...@@ -191,7 +192,7 @@ export default class OperationLog extends Vue {
return; return;
} }
try { try {
await navigator.clipboard.writeText(text); await copyText(text);
message.success("复制成功"); message.success("复制成功");
} catch { } catch {
message.error("复制失败"); message.error("复制失败");
......
...@@ -161,6 +161,7 @@ import TitleTipIcon from "@/components/icons/TitleTipIcon.vue"; ...@@ -161,6 +161,7 @@ import TitleTipIcon from "@/components/icons/TitleTipIcon.vue";
import VehicleStateTag from "@/views/vehicle/inventory/VehicleStateTag.vue"; import VehicleStateTag from "@/views/vehicle/inventory/VehicleStateTag.vue";
import { CopyOutlined } from "@ant-design/icons-vue"; import { CopyOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import { copyText } from "@/utils/copyText";
@Component({ @Component({
components: { TitleDivider, TitleTipIcon, VehicleStateTag, CopyOutlined } components: { TitleDivider, TitleTipIcon, VehicleStateTag, CopyOutlined }
...@@ -174,12 +175,12 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> { ...@@ -174,12 +175,12 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> {
@Prop({ type: Object, required: true }) @Prop({ type: Object, required: true })
inspectionReportResp: any; inspectionReportResp: any;
async copyCustomText(text) { async copyCustomText(text: unknown) {
try { try {
await navigator.clipboard.writeText(text); await copyText(text);
message.success('复制成功'); message.success("复制成功");
} catch (err) { } catch {
message.error('复制失败'); message.error("复制失败");
} }
} }
......
...@@ -199,12 +199,33 @@ export function syncLeafNodeFormValue( ...@@ -199,12 +199,33 @@ export function syncLeafNodeFormValue(
return; return;
} }
if (interactionType === "button_select") { if (
const entries = list.map((entry) => ({ interactionType === "button_select" ||
interactionType === "image_upload_and_button_select"
) {
const entries = list
.filter((entry) => entry.interactionType === "button_select")
.map((entry) => ({
valueKey: String(entry.valueKey ?? ""), valueKey: String(entry.valueKey ?? ""),
valueText: String(entry.valueText ?? ""), valueText: String(entry.valueText ?? ""),
})); }));
node.value = entries.length > 0 ? JSON.stringify(entries) : ""; 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; return;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!