Commit e4da02fb by chenwq1

fix: 修改上传的图片格式化

1 parent 3b39c7dc
No preview for this file type
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"dayjs": "^1.10.7", "dayjs": "^1.10.7",
"echarts": "^5.2.2", "echarts": "^5.2.2",
"glsk-oss-jssdk": "^1.0.6", "glsk-oss-jssdk": "^1.0.7",
"image-conversion": "^2.1.1", "image-conversion": "^2.1.1",
"ionicons": "^8.0.9", "ionicons": "^8.0.9",
"lib": "file:../lib", "lib": "file:../lib",
......
...@@ -45,8 +45,8 @@ importers: ...@@ -45,8 +45,8 @@ importers:
specifier: ^5.2.2 specifier: ^5.2.2
version: 5.6.0 version: 5.6.0
glsk-oss-jssdk: glsk-oss-jssdk:
specifier: ^1.0.6 specifier: ^1.0.7
version: 1.0.6 version: 1.0.7
image-conversion: image-conversion:
specifier: ^2.1.1 specifier: ^2.1.1
version: 2.1.1 version: 2.1.1
...@@ -1826,8 +1826,8 @@ packages: ...@@ -1826,8 +1826,8 @@ packages:
resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==}
engines: {node: '>=10'} engines: {node: '>=10'}
glsk-oss-jssdk@1.0.6: glsk-oss-jssdk@1.0.7:
resolution: {integrity: sha512-uifUcPNbb6Roas0Dlx6LRldHPwU1yQqJbQRldUaNB+e6stFvn9XrsewCueNDUty3cZw4NCg3yao2WVCUm3T2Og==} resolution: {integrity: sha512-e5uQWWD+f8UJ/zE7F1qJi09YvSMhX3iAbglJuwOOstMv0aVulX8gA3tdn8zPruS0fxzqrcpE9BNhwnETuHbSpw==}
good-listener@1.2.2: good-listener@1.2.2:
resolution: {integrity: sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==} resolution: {integrity: sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==}
...@@ -5014,7 +5014,7 @@ snapshots: ...@@ -5014,7 +5014,7 @@ snapshots:
merge2: 1.4.1 merge2: 1.4.1
slash: 3.0.0 slash: 3.0.0
glsk-oss-jssdk@1.0.6: glsk-oss-jssdk@1.0.7:
dependencies: dependencies:
ali-oss: 6.23.0 ali-oss: 6.23.0
axios: 1.15.0 axios: 1.15.0
......
...@@ -199,6 +199,23 @@ export class DetectionController { ...@@ -199,6 +199,23 @@ export class DetectionController {
): Promise<AxiosResponse> { ): Promise<AxiosResponse> {
return axios.post("inspectionRecord/completeInspection", params); return axios.post("inspectionRecord/completeInspection", params);
} }
static inspectRecordSaveScore(
axios: AxiosStatic,
params: any,
): Promise<AxiosResponse> {
return axios.post("inspect/record/saveScore", params);
}
static inspectWoOpLogPage(
axios: AxiosStatic,
params: any,
): Promise<AxiosResponse> {
return axios.post("inspect/wo/opLog/" + params.workOrderId + "/page", {
offset: params.offset,
limit: params.limit,
});
}
static PAGE_INSPECTOR_REPORT_INSPECTOR = "inspectionTemplate/page"; static PAGE_INSPECTOR_REPORT_INSPECTOR = "inspectionTemplate/page";
static inspectionTemplatePage( static inspectionTemplatePage(
axios: AxiosStatic, axios: AxiosStatic,
......
...@@ -20,5 +20,8 @@ export class TrackController{ ...@@ -20,5 +20,8 @@ export class TrackController{
static PAGE_VEHICLE_BROWSER_HISTORY = 'track/pageVehicleBrowserHistory'; static PAGE_VEHICLE_BROWSER_HISTORY = 'track/pageVehicleBrowserHistory';
// region 前端扩展代码区 // region 前端扩展代码区
static eventTrackingBatchSave(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('eventTracking/batchSave', params);
}
// endregion // endregion
} }
import { AxiosStatic } from "axios";
import dayjs from "dayjs";
import { TrackController } from "@/api/TrackController";
export interface TrackUser {
id?: number | string;
name?: string;
fullName?: string;
authorities?: string[];
[k: string]: any;
}
export interface TrackBusinessKey {
businessType: string;
businessKey: string | number;
}
export type TrackParamType = "STRING" | "NUMBER" | "BOOLEAN" | "JSON";
export interface TrackParam {
paramKey: string;
paramValue: string;
paramType?: TrackParamType;
}
export interface TrackEventOptions {
eventCode: string;
user?: TrackUser;
duration?: number;
remark?: string;
businessKeys?: TrackBusinessKey[];
params?: TrackParam[];
}
interface EditContext {
reportId?: string | number;
vehicleId?: string | number;
workOrderId?: string | number;
[k: string]: any;
}
export class TrackHelper {
private static editStartTimestamp = 0;
private static editContext: EditContext = {};
static markEditStart() {
TrackHelper.editStartTimestamp = dayjs().unix();
}
static getEditStartTimestamp(): number {
return TrackHelper.editStartTimestamp;
}
static getEditDurationSeconds(): number {
if (!TrackHelper.editStartTimestamp) return 0;
const currentTimestamp = dayjs().unix();
const startTimestamp = TrackHelper.editStartTimestamp;
return Math.max(0, currentTimestamp - startTimestamp);
}
static clearEditStart() {
TrackHelper.editStartTimestamp = 0;
}
static setEditContext(ctx: EditContext) {
TrackHelper.editContext = { ...TrackHelper.editContext, ...ctx };
}
static getEditContext(): EditContext {
return TrackHelper.editContext;
}
static clearEditContext() {
TrackHelper.editContext = {};
}
private static toStringSafe(v: any): string {
if (v === null || v === undefined) return "";
return String(v);
}
private static buildUserParams(user?: TrackUser): TrackParam[] {
const u = user || {};
const roleName = Array.isArray(u.authorities)
? u.authorities.join(",")
: TrackHelper.toStringSafe((u as any).roleName);
return [
{ paramKey: "user_id", paramValue: TrackHelper.toStringSafe(u.id), paramType: "STRING" },
{ paramKey: "role_name", paramValue: roleName, paramType: "STRING" },
];
}
static send(axios: AxiosStatic, options: TrackEventOptions): Promise<any> {
const now = dayjs().format("YYYY-MM-DD HH:mm:ss");
const params = [
...TrackHelper.buildUserParams(options.user),
...(options.params || []),
];
const payload = {
events: [
{
eventCode: options.eventCode,
eventTime: now,
duration: options.duration || 0,
remark: options.remark || "",
businessKeys: options.businessKeys || [],
params,
},
],
};
return TrackController.eventTrackingBatchSave(axios, payload).catch((err) => {
console.warn("[track] event report failed", options.eventCode, err);
});
}
/** 计算两个对象之间值不同的字段名列表(浅比较,按需可扩展) */
static diffFieldNames(
before: Record<string, any> = {},
after: Record<string, any> = {},
): string[] {
const keys = new Set([...Object.keys(before || {}), ...Object.keys(after || {})]);
const changed: string[] = [];
keys.forEach((key) => {
const b = before?.[key];
const a = after?.[key];
if (TrackHelper.normalize(b) !== TrackHelper.normalize(a)) {
changed.push(key);
}
});
return changed;
}
static normalize(v: any): string {
if (v === null || v === undefined) return "";
if (typeof v === "object") return JSON.stringify(v);
return String(v);
}
}
...@@ -27,8 +27,9 @@ export function uploadFile(file, options = {}) { ...@@ -27,8 +27,9 @@ export function uploadFile(file, options = {}) {
const api = getOssApi(); const api = getOssApi();
const bucketName = options.bucketName ?? OSS_CONFIG.BUCKET_NAME; const bucketName = options.bucketName ?? OSS_CONFIG.BUCKET_NAME;
const dir = options.dir ?? OSS_CONFIG.FOLDER; const dir = options.dir ?? OSS_CONFIG.FOLDER;
const custAttrObj = const custAttrObj = options.custAttrObj ?? {
options.custAttrObj ?? { systemSource: OSS_CONFIG.SYSTEM_SOURCE }; systemSource: OSS_CONFIG.SYSTEM_SOURCE,
};
const partSizeKB = options.partSizeKB ?? 500; const partSizeKB = options.partSizeKB ?? 500;
const maxRetries = options.maxRetries ?? 3; const maxRetries = options.maxRetries ?? 3;
...@@ -42,7 +43,7 @@ export function uploadFile(file, options = {}) { ...@@ -42,7 +43,7 @@ export function uploadFile(file, options = {}) {
custAttrObj, custAttrObj,
{}, {},
partSizeKB, partSizeKB,
maxRetries maxRetries,
); );
}); });
} }
...@@ -59,3 +60,15 @@ export function uploadFiles(files, options = {}) { ...@@ -59,3 +60,15 @@ export function uploadFiles(files, options = {}) {
return Promise.all(files.map((f) => uploadFile(f, options))); return Promise.all(files.map((f) => uploadFile(f, options)));
} }
// 将图片进行格式转换。
async function format() {
try {
const result = await ossApi.get("example.jpg", "./example-format.jpg", {
process: "image/format,png",
});
} catch (e) {
console.log(e);
}
}
format();
...@@ -30,6 +30,7 @@ import CustomizeForm from "@/views/detection/order/components/CustomizeForm.vue" ...@@ -30,6 +30,7 @@ import CustomizeForm from "@/views/detection/order/components/CustomizeForm.vue"
import TestingScore from "@/views/detection/order/components/TestingScore.vue"; import TestingScore from "@/views/detection/order/components/TestingScore.vue";
import { DetectionController } from "@/api/DetectionController"; import { DetectionController } from "@/api/DetectionController";
import { CheckCircleFilled } from '@ant-design/icons-vue' import { CheckCircleFilled } from '@ant-design/icons-vue'
import { TrackHelper } from "@/common/TrackHelper";
@Component({ @Component({
...@@ -48,16 +49,33 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> { ...@@ -48,16 +49,33 @@ export default class DetectionOrderEdit extends PaginationComponent<Vehicle> {
inspectionNodeList: any = []; inspectionNodeList: any = [];
created(): void { created(): void {
TrackHelper.markEditStart();
const q = this.$route.query || {};
TrackHelper.setEditContext({
workOrderId: q.id,
reportId: q.id,
});
this.getDetailData(); this.getDetailData();
this.getTemplateData('1'); this.getTemplateData('1');
this.getDefaultTemplate(); this.getDefaultTemplate();
} }
unmounted(): void {
TrackHelper.clearEditStart();
TrackHelper.clearEditContext();
}
getDetailData() { getDetailData() {
const routeData = this.$route.query || {}; const routeData = this.$route.query || {};
let postData = { workOrderId: routeData.id } let postData = { workOrderId: routeData.id }
DetectionController.inspectOrderDetail(this.axios, postData).then(response => { DetectionController.inspectOrderDetail(this.axios, postData).then(response => {
this.pageData = response.data.data || {}; this.pageData = response.data.data || {};
const wo = this.pageData?.inspectionWORespVO || {};
TrackHelper.setEditContext({
workOrderId: routeData.id,
reportId: routeData.id,
vehicleId: wo.vehicleId || wo.vehicle?.id || this.pageData?.vehicle?.id || "",
});
}); });
} }
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<router-link v-if="record.status != 3" <router-link v-if="record.status != 3"
:to="{ path: '/detection/order/edit', query: { id: record.id, page: 'order', action: 'EDIT' } }"> :to="{ path: '/detection/order/edit', query: { id: record.id, page: 'order', action: 'EDIT' } }">
<a-button type="link" size="small">编辑报告</a-button> <a-button type="link" size="small" @click="trackEnterEditMode(record)">编辑报告</a-button>
</router-link> </router-link>
</template> </template>
...@@ -136,6 +136,7 @@ import { ExportUtil } from "@/common/ExportUtil"; ...@@ -136,6 +136,7 @@ import { ExportUtil } from "@/common/ExportUtil";
import { DetectionController } from "@/api/DetectionController"; import { DetectionController } from "@/api/DetectionController";
import OrderAddForm from "@/views/detection/order/components/OrderAddForm.vue"; import OrderAddForm from "@/views/detection/order/components/OrderAddForm.vue";
import cancelDialog from "@/views/detection/order/components/cancelDialog.vue"; import cancelDialog from "@/views/detection/order/components/cancelDialog.vue";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ @Component({
components: { VehicleStateTag, OrderAddForm, cancelDialog } components: { VehicleStateTag, OrderAddForm, cancelDialog }
...@@ -255,6 +256,24 @@ export default class DetectionOrderPage extends PaginationComponent<Vehicle> { ...@@ -255,6 +256,24 @@ export default class DetectionOrderPage extends PaginationComponent<Vehicle> {
this.$refs.orderAddFormRef.init(data); this.$refs.orderAddFormRef.init(data);
} }
// 点击【编辑报告】埋点
trackEnterEditMode(record: any) {
const reportId = record?.inspectionRecord?.reportId || record?.reportId || record?.id;
const vehicleId = record?.vehicle?.id || record?.vehicleId || "";
TrackHelper.send(this.axios, {
eventCode: "click_backend_enter_edit_mode",
user: this.$auth.getAuthentication(),
businessKeys: [
{ businessType: "REPORT", businessKey: String(reportId || "") },
],
params: [
{ paramKey: "report_id", paramValue: String(reportId || ""), paramType: "STRING" },
{ paramKey: "vehicle_id", paramValue: String(vehicleId || ""), paramType: "STRING" },
{ paramKey: "entry_point", paramValue: "work_order_detail", paramType: "STRING" },
],
});
}
// 取消工单 // 取消工单
handleCancelOrder(data) { handleCancelOrder(data) {
this.$refs.cancelDialogRef.init(data); this.$refs.cancelDialogRef.init(data);
......
...@@ -29,23 +29,13 @@ ...@@ -29,23 +29,13 @@
<a-descriptions :column="1" size="small" layout="vertical"> <a-descriptions :column="1" size="small" layout="vertical">
<template #title> <template #title>
<div> <div>
<div>
<title-tip-icon></title-tip-icon> <title-tip-icon></title-tip-icon>
操作日志 操作日志
</div> </div>
<div @click="handleFold(false)" v-if="isShowFold" class="foldBox">收起
<DoubleLeftOutlined color="#666666" font-size="13px;"
style="transform: rotate(90deg);" />
</div>
<div @click="handleFold(true)" v-else class="foldBox">展开
<DoubleLeftOutlined color="#666666" font-size="13px;"
style="transform: rotate(270deg);" />
</div>
</div>
<div class="title-line"></div> <div class="title-line"></div>
</template> </template>
<a-descriptions-item v-if="isShowFold" label=""> <a-descriptions-item label="">
<OperationLog ref="operationLogRef" :operationLogData="pageData" /> <OperationLog ref="operationLogRef" />
</a-descriptions-item> </a-descriptions-item>
</a-descriptions> </a-descriptions>
</div> </div>
...@@ -66,11 +56,10 @@ import OperationLog from "@/views/detection/order/components/OperationLog.vue"; ...@@ -66,11 +56,10 @@ import OperationLog from "@/views/detection/order/components/OperationLog.vue";
import orderReport from "@/views/detection/order/components/orderReport.vue"; import orderReport from "@/views/detection/order/components/orderReport.vue";
import orderDetails from "@/views/detection/order/components/orderDetails.vue"; import orderDetails from "@/views/detection/order/components/orderDetails.vue";
import reviewDialog from "@/views/detection/order/components/reviewDialog.vue"; import reviewDialog from "@/views/detection/order/components/reviewDialog.vue";
import { DoubleLeftOutlined } from '@ant-design/icons-vue';
@Component({ @Component({
components: { TitleDivider, TitleTipIcon, OperationLog, orderReport, orderDetails, reviewDialog, DoubleLeftOutlined } components: { TitleDivider, TitleTipIcon, OperationLog, orderReport, orderDetails, reviewDialog }
}) })
...@@ -87,8 +76,6 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> { ...@@ -87,8 +76,6 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> {
pageData: any = {}; pageData: any = {};
isShowFold: boolean = true;
get tabs() { get tabs() {
let tabs = [ let tabs = [
{ key: "DETAIL", tab: "工单详情" }, { key: "DETAIL", tab: "工单详情" },
...@@ -107,6 +94,10 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> { ...@@ -107,6 +94,10 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> {
this.getDetailData(); this.getDetailData();
} }
mounted(): void {
this.$refs.operationLogRef?.init(this.routeData.id);
}
getDetailData() { getDetailData() {
let postDat = { workOrderId: this.routeData.id } let postDat = { workOrderId: this.routeData.id }
if (this.routeData.page == 'report') { if (this.routeData.page == 'report') {
...@@ -121,10 +112,6 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> { ...@@ -121,10 +112,6 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> {
this.$refs.reviewDialogRef.showVisible({ ...this.pageData, status }); this.$refs.reviewDialogRef.showVisible({ ...this.pageData, status });
} }
handleFold(isFold: boolean) {
this.isShowFold = isFold;
}
handleBack() { handleBack() {
this.$router.back(); this.$router.back();
} }
...@@ -153,13 +140,4 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> { ...@@ -153,13 +140,4 @@ export default class DetectionOrderView extends PaginationComponent<Vehicle> {
margin-top: 16px; margin-top: 16px;
margin-bottom: 16px; margin-bottom: 16px;
} }
.foldBox {
float: right;
color: #666666;
font-size: 13px;
font-weight: 400;
margin-top: -16px;
cursor: pointer;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -112,6 +112,7 @@ import CustomizeFormButtonSelectUploadFile from "@/views/detection/order/compone ...@@ -112,6 +112,7 @@ import CustomizeFormButtonSelectUploadFile from "@/views/detection/order/compone
import { CheckCircleFilled } from "@ant-design/icons-vue"; import { CheckCircleFilled } from "@ant-design/icons-vue";
import { DetectionController } from "@/api/DetectionController"; import { DetectionController } from "@/api/DetectionController";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import { TrackHelper } from "@/common/TrackHelper";
@Component({ components: { TitleDivider, CustomizeFormButtonSelect, CustomizeFormUploadFile, CustomizeFormButtonSelectUploadFile, CheckCircleFilled } }) @Component({ components: { TitleDivider, CustomizeFormButtonSelect, CustomizeFormUploadFile, CustomizeFormButtonSelectUploadFile, CheckCircleFilled } })
...@@ -124,6 +125,9 @@ export default class CustomizeForm extends Vue { ...@@ -124,6 +125,9 @@ export default class CustomizeForm extends Vue {
activeNodeId: string = ''; activeNodeId: string = '';
taskId: number = null; taskId: number = null;
initialLeafValues: Record<string, any> = {};
leafIdToName: Record<string, string> = {};
//初始化数据 //初始化数据
init(data) { init(data) {
//重置表单数据 //重置表单数据
...@@ -134,9 +138,79 @@ export default class CustomizeForm extends Vue { ...@@ -134,9 +138,79 @@ 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.snapshotInitialValues();
console.log('111111111111111111initData', this.columnsList); console.log('111111111111111111initData', this.columnsList);
} }
snapshotInitialValues() {
const leafMap: Record<string, any> = {};
const nameMap: Record<string, string> = {};
const walk = (nodes: any[] = []) => {
(nodes || []).forEach((node) => {
if (node?.childrenNodes && node.childrenNodes.length) {
walk(node.childrenNodes);
} else if (node?.id != null) {
leafMap[node.id] = TrackHelper.normalize(node.value);
nameMap[node.id] = node.nodeName || String(node.id);
}
});
};
walk(this.columnsList || []);
this.initialLeafValues = leafMap;
this.leafIdToName = nameMap;
}
collectModifiedFieldNames(): string[] {
const current: Record<string, any> = {};
const walk = (nodes: any[] = []) => {
(nodes || []).forEach((node) => {
if (node?.childrenNodes && node.childrenNodes.length) {
walk(node.childrenNodes);
} else if (node?.id != null) {
current[node.id] = TrackHelper.normalize(node.value);
}
});
};
walk(this.columnsList || []);
const changedIds = TrackHelper.diffFieldNames(this.initialLeafValues, current);
return changedIds.map((id) => this.leafIdToName[id] || String(id));
}
sendSaveTrack(modifiedFields: string[]) {
const ctx = TrackHelper.getEditContext();
TrackHelper.send(this.axios, {
eventCode: "click_backend_save_report",
user: this.$auth.getAuthentication(),
duration: TrackHelper.getEditDurationSeconds(),
businessKeys: [
{ businessType: "REPORT", businessKey: String(ctx.reportId || ctx.workOrderId || "") },
],
params: [
{ paramKey: "report_id", paramValue: String(ctx.reportId || ""), paramType: "STRING" },
{ paramKey: "vehicle_id", paramValue: String(ctx.vehicleId || ""), paramType: "STRING" },
{ paramKey: "modified_fields", paramValue: JSON.stringify(modifiedFields), paramType: "STRING" },
{ paramKey: "edit_duration", paramValue: String(TrackHelper.getEditDurationSeconds()), paramType: "STRING" },
],
});
}
sendCancelTrack() {
const ctx = TrackHelper.getEditContext();
TrackHelper.send(this.axios, {
eventCode: "click_backend_cancel_edit",
user: this.$auth.getAuthentication(),
duration: TrackHelper.getEditDurationSeconds(),
businessKeys: [
{ businessType: "REPORT", businessKey: String(ctx.reportId || ctx.workOrderId || "") },
],
params: [
{ paramKey: "report_id", paramValue: String(ctx.reportId || ""), paramType: "STRING" },
{ paramKey: "vehicle_id", paramValue: String(ctx.vehicleId || ""), paramType: "STRING" },
{ paramKey: "edit_duration", paramValue: String(TrackHelper.getEditDurationSeconds()), paramType: "STRING" },
],
});
}
getValidationRules(item: any) { getValidationRules(item: any) {
return JSON.parse(item.validationRules || "{}"); return JSON.parse(item.validationRules || "{}");
} }
...@@ -161,11 +235,14 @@ export default class CustomizeForm extends Vue { ...@@ -161,11 +235,14 @@ export default class CustomizeForm extends Vue {
nextFlag: true, nextFlag: true,
modules modules
}; };
const modifiedFields = this.collectModifiedFieldNames();
DetectionController.inspectRecordSave(this.axios, postData).then(response => { DetectionController.inspectRecordSave(this.axios, postData).then(response => {
const res = response?.data || {}; const res = response?.data || {};
if (res.code === "200") { if (res.code === "200") {
this.$emit('submitSuccess', res); this.$emit('submitSuccess', res);
message.success(res.message || '保存成功'); message.success(res.message || '保存成功');
this.sendSaveTrack(modifiedFields);
this.snapshotInitialValues();
} else { } else {
message.error(res.message || '保存失败'); message.error(res.message || '保存失败');
} }
...@@ -283,7 +360,10 @@ export default class CustomizeForm extends Vue { ...@@ -283,7 +360,10 @@ export default class CustomizeForm extends Vue {
returnSpan(item: { interactionType: string }) { returnSpan(item: { interactionType: string }) {
return item.interactionType === 'image_upload_and_button_select' ? 24 : 8; return item.interactionType === 'image_upload_and_button_select' ? 24 : 8;
} }
handleBack() { this.$router.back(); } handleBack() {
this.sendCancelTrack();
this.$router.back();
}
} }
......
<template> <template>
<div class="logBox"> <div ref="scrollBoxRef" class="logBox" @scroll="handleScroll">
<div v-for="(item, index) in logList" :key="index" class="log-list"> <div v-for="(item, index) in logList" :key="item.id || index" class="log-list">
<div class="progressBox"> <div class="progressBox">
<div class="progressBox-point" :class="{ 'bg-1956fe': index > 0 }"></div> <div class="progressBox-point" :class="{ 'bg-1956fe': index > 0 }"></div>
<div v-if="alllist.length !== index + 1" class="progressBox-line"></div> <div v-if="logList.length !== index + 1 || hasMore" class="progressBox-line"></div>
</div> </div>
<div class="log-title"> <div class="log-title">
<div v-if="item.description || item.operationContent" :title="item.description || item.operationContent" class="logBox-content"> <template v-if="item.description">
{{ item.description || item.operationContent }} <a-popover
v-if="isChangeLog(item)"
trigger="hover"
placement="topLeft"
:overlay-class-name="'op-log-detail-popover'"
:overlay-style="{ maxWidth: '820px' }"
>
<template #content>
<a-table
:columns="detailColumns"
:data-source="item.detailItems"
:pagination="false"
:scroll="{ y: 280 }"
:row-key="(row) => row.logItemId"
size="small"
bordered
class="op-log-detail-table"
/>
</template>
<div :title="item.description" class="logBox-content with-detail">
{{ item.description }}
</div> </div>
</a-popover>
<div v-else :title="item.description" class="logBox-content">
{{ item.description }}
</div>
</template>
<div class="logBox-time"> <div class="logBox-time">
<div class="logBox-point" v-if="item.updateNameCnFirst">{{ item.updateNameCnFirst }}</div> <div v-if="getFirstChar(item.operatorName)" class="logBox-point">
{{ getFirstChar(item.operatorName) }}
</div>
<span class="p-l-4">{{ item.operatorName }}</span> <span class="p-l-4">{{ item.operatorName }}</span>
<span class="p-l-8">{{ item.operationTime }}</span> <span class="p-l-8">{{ item.operationTime }}</span>
</div> </div>
</div> </div>
</div> </div>
<div v-if="!isAllData" @click="handleMore()" class="moreBox"> <div v-if="loading" class="statusBox">加载中...</div>
查看更多 <div v-else-if="!hasMore && logList.length > 0" class="statusBox">已加载全部</div>
<DoubleLeftOutlined color="#666666" font-size="16px;" style="transform: rotate(270deg);" /> <div v-else-if="!loading && logList.length === 0" class="statusBox">暂无操作日志</div>
</div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { DoubleLeftOutlined } from '@ant-design/icons-vue'; import { DetectionController } from "@/api/DetectionController";
@Component({ components: { DoubleLeftOutlined } }) @Component({ components: {} })
export default class OperationLog extends Vue { export default class OperationLog extends Vue {
@Prop({ type: Object, required: true }) workOrderId: any = "";
operationLogData: any; logList: any[] = [];
logList = []; offset = 0;
isAllData = false; limit = 20;
alllist = []; totalElements = 0;
@Watch('operationLogData', { deep: true, immediate: true }) loading = false;
watchOperationLogData(newValue: any, oldValue: any): void { hasMore = true;
const list = (newValue.logList || []).map((item: any) => { return { ...item } });
if (list.length > 5) { detailColumns: any[] = [
this.isAllData = false; {
this.alllist = list; title: "变更项",
this.logList = list.slice(0, 5); dataIndex: "fieldLabel",
} else { key: "fieldLabel",
this.isAllData = true; width: 200,
this.logList = list; ellipsis: true,
},
{
title: "变更前的值",
dataIndex: "beforeValue",
key: "beforeValue",
width: 280,
ellipsis: true,
},
{
title: "变更后的值",
dataIndex: "afterValue",
key: "afterValue",
width: 280,
ellipsis: true,
},
];
isChangeLog(item: any) {
const type = Number(item?.operationType);
return (
(type === 11 || type === 12) &&
Array.isArray(item?.detailItems) &&
item.detailItems.length > 0
);
}
init(workOrderId: any) {
this.workOrderId = workOrderId;
this.logList = [];
this.offset = 0;
this.totalElements = 0;
this.hasMore = true;
this.loadNextPage();
} }
loadNextPage() {
if (this.loading || !this.hasMore || !this.workOrderId) return;
this.loading = true;
DetectionController.inspectWoOpLogPage(this.axios, {
workOrderId: this.workOrderId,
offset: this.offset,
limit: this.limit,
})
.then((response) => {
const data = response?.data?.data || {};
const content = data.content || [];
this.logList = [...this.logList, ...content];
this.totalElements = data.totalElements || this.logList.length;
this.offset += this.limit;
this.hasMore =
this.logList.length < this.totalElements &&
content.length > 0;
})
.finally(() => {
this.loading = false;
});
} }
handleMore() { handleScroll(e: Event) {
this.isAllData = true; const target = e.target as HTMLElement;
this.logList = this.alllist if (
target.scrollTop + target.clientHeight >=
target.scrollHeight - 20
) {
this.loadNextPage();
}
} }
getFirstChar(str: string) {
if (!str) return "";
return String(str).charAt(0);
}
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.logBox { .logBox {
width: 100%;
height: auto;
float: left; float: left;
width: 100%;
max-height: 480px;
margin-top: 16px; margin-top: 16px;
overflow-y: auto;
} }
.log-list { .log-list {
float: left;
width: -webkit-calc(100% - 32px); width: -webkit-calc(100% - 32px);
width: -moz-calc(100% - 32px); width: -moz-calc(100% - 32px);
width: calc(100% - 32px); width: calc(100% - 32px);
float: left;
margin-bottom: 16px; margin-bottom: 16px;
margin-left: 32px; margin-left: 32px;
} }
.progressBox { .progressBox {
width: 24px;
float: left; float: left;
width: 24px;
} }
.progressBox-point { .progressBox-point {
...@@ -91,72 +182,75 @@ export default class OperationLog extends Vue { ...@@ -91,72 +182,75 @@ export default class OperationLog extends Vue {
.progressBox-line { .progressBox-line {
width: 2px; width: 2px;
height: 40px; height: 40px;
background: #1956fe;
margin-top: 3px; margin-top: 3px;
margin-left: 2.5px; margin-left: 2.5px;
background: #1956fe;
} }
.log-title { .log-title {
float: left;
width: -webkit-calc(100% - 24px); width: -webkit-calc(100% - 24px);
width: -moz-calc(100% - 24px); width: -moz-calc(100% - 24px);
width: calc(100% - 24px); width: calc(100% - 24px);
float: left;
} }
.logBox-content { .logBox-content {
width: 100%;
line-height: 20px;
float: left; float: left;
color: #2F3133; width: 100%;
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
line-height: 20px;
color: #2f3133;
word-wrap: break-word; word-wrap: break-word;
word-break: break-word; word-break: break-word;
} }
.logBox-content.with-detail {
color: #1956fe;
cursor: help;
text-decoration: underline;
text-decoration-color: rgba(25, 86, 254, 0.4);
text-decoration-style: dashed;
text-underline-offset: 3px;
}
.logBox-content span { .logBox-content span {
color: #2f3133; color: #2f3133;
} }
.logBox-time { .logBox-time {
float: left;
width: 100%; width: 100%;
height: 20px; height: 20px;
line-height: 20px; margin-top: 6px;
float: left;
color: #777c85;
font-size: 12px; font-size: 12px;
font-weight: 400; font-weight: 400;
margin-top: 6px; line-height: 20px;
color: #777c85;
} }
.logBox-point { .logBox-point {
float: left;
width: 14px; width: 14px;
height: 14px; height: 14px;
line-height: 14px;
background: #e6efff;
text-align: center;
float: left;
margin: 3px 0; margin: 3px 0;
color: #1956fe;
font-size: 8px; font-size: 8px;
font-weight: 700; font-weight: 700;
line-height: 14px;
color: #1956fe;
text-align: center;
background: #e6efff;
border-radius: 8px; border-radius: 8px;
} }
.moreBox { .statusBox {
width: -webkit-calc(100% - 32px);
width: -moz-calc(100% - 32px);
width: calc(100% - 32px);
height: 20px;
float: left; float: left;
color: #666666; width: 100%;
font-size: 14px; padding: 8px 0 16px;
font-size: 13px;
font-weight: 400; font-weight: 400;
line-height: 20px; color: #999999;
margin-top: 8px; text-align: center;
margin-bottom: 22px;
margin-left: 32px;
cursor: pointer;
} }
.p-l-4 { .p-l-4 {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!