266 lines
12 KiB
JavaScript
266 lines
12 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const request_request = require("../../request/request.js");
|
|
const components_hazardDetail_hazardDetail = require("./hazardDetail.js");
|
|
const components_hazardDetail_useHazardDetailScroll = require("./useHazardDetailScroll.js");
|
|
const _sfc_main = {
|
|
__name: "HazardDetailPanelV2",
|
|
props: {
|
|
detail: {
|
|
type: Object,
|
|
default: () => ({})
|
|
},
|
|
loading: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
bodyHeight: {
|
|
type: Number,
|
|
default: 0
|
|
}
|
|
},
|
|
setup(__props) {
|
|
const props = __props;
|
|
const { detail, loading } = common_vendor.toRefs(props);
|
|
const {
|
|
historyList,
|
|
activeIndex,
|
|
contentScrollIntoView,
|
|
stepScrollIntoView,
|
|
scrollWithAnimation,
|
|
onContentScroll,
|
|
onScrollToLower,
|
|
scrollToNode,
|
|
scheduleMeasureLayout
|
|
} = components_hazardDetail_useHazardDetailScroll.useHazardDetailScroll(detail, loading);
|
|
const scrollAreaStyle = common_vendor.computed(() => {
|
|
const height = props.bodyHeight > 0 ? props.bodyHeight : 400;
|
|
return { height: `${height}px` };
|
|
});
|
|
const detailBodyStyle = common_vendor.computed(() => {
|
|
const height = props.bodyHeight > 0 ? props.bodyHeight : 400;
|
|
return { height: `${height}px` };
|
|
});
|
|
common_vendor.watch(
|
|
() => props.bodyHeight,
|
|
(height) => {
|
|
if (height > 0) {
|
|
scheduleMeasureLayout();
|
|
setTimeout(scheduleMeasureLayout, 100);
|
|
}
|
|
}
|
|
);
|
|
const LEVEL_CLASS_MAP = {
|
|
2: "level-normal",
|
|
3: "level-major"
|
|
};
|
|
const LEVEL_NAME_CLASS_MAP = {
|
|
一般: "level-normal",
|
|
一般隐患: "level-normal",
|
|
重大: "level-major",
|
|
重大隐患: "level-major"
|
|
};
|
|
const getLevelTagClass = (content) => {
|
|
const level = content == null ? void 0 : content.level;
|
|
const levelName = content == null ? void 0 : content.levelName;
|
|
if (level != null && LEVEL_CLASS_MAP[level]) {
|
|
return LEVEL_CLASS_MAP[level];
|
|
}
|
|
if (levelName && LEVEL_NAME_CLASS_MAP[levelName]) {
|
|
return LEVEL_NAME_CLASS_MAP[levelName];
|
|
}
|
|
return "";
|
|
};
|
|
const resolveFileUrl = (path) => request_request.toImageUrl(path);
|
|
const formatCost = (cost) => {
|
|
if (cost == null || cost === "")
|
|
return "-";
|
|
const num = Number(cost);
|
|
return Number.isNaN(num) ? "-" : `${num} 元`;
|
|
};
|
|
const previewSingle = (path) => {
|
|
const url = resolveFileUrl(path);
|
|
if (!url)
|
|
return;
|
|
common_vendor.index.previewImage({ current: url, urls: [url] });
|
|
};
|
|
const previewImages = (attachments, index) => {
|
|
const urls = (attachments || []).filter((f) => f.fileType === "image" || !f.fileType).map((f) => resolveFileUrl(f.filePath)).filter(Boolean);
|
|
if (!urls.length)
|
|
return;
|
|
common_vendor.index.previewImage({ current: urls[index] || urls[0], urls });
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.unref(loading)
|
|
}, common_vendor.unref(loading) ? {} : common_vendor.unref(historyList).length === 0 ? {} : {
|
|
c: common_vendor.f(common_vendor.unref(historyList), (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.unref(components_hazardDetail_hazardDetail.getStepIconPath)(item.type, common_vendor.unref(activeIndex) === index),
|
|
b: common_vendor.unref(activeIndex) === index ? 1 : "",
|
|
c: common_vendor.t(item.nodeName),
|
|
d: common_vendor.unref(activeIndex) === index ? 1 : "",
|
|
e: index < common_vendor.unref(historyList).length - 1
|
|
}, index < common_vendor.unref(historyList).length - 1 ? {} : {}, {
|
|
f: "step-" + index,
|
|
g: "hazard-step-" + index,
|
|
h: common_vendor.unref(activeIndex) === index ? 1 : "",
|
|
i: common_vendor.o(($event) => common_vendor.unref(scrollToNode)(index), "step-" + index)
|
|
});
|
|
}),
|
|
d: common_vendor.s(scrollAreaStyle.value),
|
|
e: common_vendor.unref(stepScrollIntoView),
|
|
f: common_vendor.f(common_vendor.unref(historyList), (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.t(item.titlePrefix),
|
|
b: common_vendor.t(item.operator),
|
|
c: common_vendor.t(item.time),
|
|
d: item.type === "submit" && item.content.levelName
|
|
}, item.type === "submit" && item.content.levelName ? {
|
|
e: common_vendor.t(item.content.levelName),
|
|
f: common_vendor.n(getLevelTagClass(item.content))
|
|
} : {}, {
|
|
g: item.type === "submit"
|
|
}, item.type === "submit" ? common_vendor.e({
|
|
h: common_vendor.t(item.content.title),
|
|
i: common_vendor.t(item.content.source),
|
|
j: item.content.areaColor
|
|
}, item.content.areaColor ? {
|
|
k: item.content.areaColor
|
|
} : {}, {
|
|
l: common_vendor.t(item.content.areaName),
|
|
m: common_vendor.t(item.content.address),
|
|
n: common_vendor.t(item.content.levelName || "-"),
|
|
o: common_vendor.n(getLevelTagClass(item.content)),
|
|
p: common_vendor.t(item.content.tagName),
|
|
q: common_vendor.t(item.content.description),
|
|
r: item.content.attachments && item.content.attachments.length
|
|
}, item.content.attachments && item.content.attachments.length ? {
|
|
s: common_vendor.f(item.content.attachments, (file, idx, i1) => {
|
|
return {
|
|
a: idx,
|
|
b: resolveFileUrl(file.filePath),
|
|
c: common_vendor.o(($event) => previewImages(item.content.attachments, idx), idx),
|
|
d: common_vendor.o((...args) => common_vendor.unref(scheduleMeasureLayout) && common_vendor.unref(scheduleMeasureLayout)(...args), idx)
|
|
};
|
|
})
|
|
} : {}, {
|
|
t: common_vendor.t(item.content.legalBasis)
|
|
}) : item.type === "assign" ? {
|
|
w: common_vendor.t(item.content.assigneeName),
|
|
x: common_vendor.t(item.content.deadline)
|
|
} : item.type === "rectify" ? common_vendor.e({
|
|
z: common_vendor.t(item.content.rectifyStatusName),
|
|
A: common_vendor.t(item.content.rectifyPlan),
|
|
B: common_vendor.t(item.content.rectifyResult),
|
|
C: common_vendor.t(item.content.rectificationMeasures),
|
|
D: common_vendor.t(item.content.controlMeasures),
|
|
E: common_vendor.t(item.content.deadline),
|
|
F: common_vendor.t(item.content.rectifierNames),
|
|
G: common_vendor.t(item.content.managerNames),
|
|
H: common_vendor.t(formatCost(item.content.planCost)),
|
|
I: common_vendor.t(formatCost(item.content.actualCost)),
|
|
J: item.content.attachments && item.content.attachments.length
|
|
}, item.content.attachments && item.content.attachments.length ? {
|
|
K: common_vendor.f(item.content.attachments, (file, idx, i1) => {
|
|
return common_vendor.e({
|
|
a: file.fileType === "image"
|
|
}, file.fileType === "image" ? {
|
|
b: resolveFileUrl(file.filePath),
|
|
c: common_vendor.o(($event) => previewImages(item.content.attachments, idx), idx),
|
|
d: common_vendor.o((...args) => common_vendor.unref(scheduleMeasureLayout) && common_vendor.unref(scheduleMeasureLayout)(...args), idx)
|
|
} : {
|
|
e: common_vendor.t(file.fileName || "附件")
|
|
}, {
|
|
f: idx
|
|
});
|
|
})
|
|
} : {}, {
|
|
L: item.content.signPath
|
|
}, item.content.signPath ? {
|
|
M: resolveFileUrl(item.content.signPath),
|
|
N: common_vendor.o(($event) => previewSingle(item.content.signPath), "node-" + index),
|
|
O: common_vendor.o((...args) => common_vendor.unref(scheduleMeasureLayout) && common_vendor.unref(scheduleMeasureLayout)(...args), "node-" + index)
|
|
} : {}) : item.type === "verify" ? common_vendor.e({
|
|
Q: common_vendor.t(item.content.resultName),
|
|
R: common_vendor.n(item.content.resultName === "通过" ? "result-tag--pass" : "result-tag--fail"),
|
|
S: item.content.remark
|
|
}, item.content.remark ? {
|
|
T: common_vendor.t(item.content.remark)
|
|
} : {}, {
|
|
U: item.content.attachments && item.content.attachments.length
|
|
}, item.content.attachments && item.content.attachments.length ? {
|
|
V: common_vendor.f(item.content.attachments, (file, idx, i1) => {
|
|
return common_vendor.e({
|
|
a: file.fileType === "image"
|
|
}, file.fileType === "image" ? {
|
|
b: resolveFileUrl(file.filePath),
|
|
c: common_vendor.o(($event) => previewImages(item.content.attachments, idx), idx),
|
|
d: common_vendor.o((...args) => common_vendor.unref(scheduleMeasureLayout) && common_vendor.unref(scheduleMeasureLayout)(...args), idx)
|
|
} : {
|
|
e: common_vendor.t(file.fileName || "附件")
|
|
}, {
|
|
f: idx
|
|
});
|
|
})
|
|
} : {}, {
|
|
W: item.content.signPath
|
|
}, item.content.signPath ? {
|
|
X: resolveFileUrl(item.content.signPath),
|
|
Y: common_vendor.o(($event) => previewSingle(item.content.signPath), "node-" + index),
|
|
Z: common_vendor.o((...args) => common_vendor.unref(scheduleMeasureLayout) && common_vendor.unref(scheduleMeasureLayout)(...args), "node-" + index)
|
|
} : {}) : item.type === "writeoff" ? common_vendor.e({
|
|
ab: common_vendor.t(item.content.resultName),
|
|
ac: common_vendor.n(item.content.resultName === "通过" ? "result-tag--pass" : "result-tag--fail"),
|
|
ad: item.content.remark
|
|
}, item.content.remark ? {
|
|
ae: common_vendor.t(item.content.remark)
|
|
} : {}, {
|
|
af: item.content.attachments && item.content.attachments.length
|
|
}, item.content.attachments && item.content.attachments.length ? {
|
|
ag: common_vendor.f(item.content.attachments, (file, idx, i1) => {
|
|
return common_vendor.e({
|
|
a: file.fileType === "image"
|
|
}, file.fileType === "image" ? {
|
|
b: resolveFileUrl(file.filePath),
|
|
c: common_vendor.o(($event) => previewImages(item.content.attachments, idx), idx),
|
|
d: common_vendor.o((...args) => common_vendor.unref(scheduleMeasureLayout) && common_vendor.unref(scheduleMeasureLayout)(...args), idx)
|
|
} : {
|
|
e: common_vendor.t(file.fileName || "附件")
|
|
}, {
|
|
f: idx
|
|
});
|
|
})
|
|
} : {}, {
|
|
ah: item.content.signPath
|
|
}, item.content.signPath ? {
|
|
ai: resolveFileUrl(item.content.signPath),
|
|
aj: common_vendor.o(($event) => previewSingle(item.content.signPath), "node-" + index),
|
|
ak: common_vendor.o((...args) => common_vendor.unref(scheduleMeasureLayout) && common_vendor.unref(scheduleMeasureLayout)(...args), "node-" + index)
|
|
} : {}) : {}, {
|
|
v: item.type === "assign",
|
|
y: item.type === "rectify",
|
|
P: item.type === "verify",
|
|
aa: item.type === "writeoff",
|
|
al: "node-" + index,
|
|
am: "hazard-node-" + index,
|
|
an: index === common_vendor.unref(historyList).length - 1 ? 1 : ""
|
|
});
|
|
}),
|
|
g: common_vendor.s(scrollAreaStyle.value),
|
|
h: common_vendor.unref(contentScrollIntoView),
|
|
i: common_vendor.unref(scrollWithAnimation),
|
|
j: common_vendor.o((...args) => common_vendor.unref(onContentScroll) && common_vendor.unref(onContentScroll)(...args)),
|
|
k: common_vendor.o((...args) => common_vendor.unref(onScrollToLower) && common_vendor.unref(onScrollToLower)(...args)),
|
|
l: common_vendor.s(detailBodyStyle.value)
|
|
}, {
|
|
b: common_vendor.unref(historyList).length === 0,
|
|
m: common_vendor.gei(_ctx, "")
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-361ef447"]]);
|
|
wx.createComponent(Component);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/hazardDetail/HazardDetailPanelV2.js.map
|