74 lines
2.2 KiB
JavaScript
74 lines
2.2 KiB
JavaScript
"use strict";
|
|
const utils_upload = require("../../utils/upload.js");
|
|
const LEVEL_OPTIONS = [
|
|
{ id: 2, title: "一般隐患" },
|
|
{ id: 3, title: "重大隐患" }
|
|
];
|
|
const SOURCE_OPTIONS = [
|
|
{ id: 1, title: "部门检查" },
|
|
{ id: 2, title: "督导检查" },
|
|
{ id: 3, title: "企业自查" },
|
|
{ id: 4, title: "行业互查" }
|
|
];
|
|
const AI_LEVEL_MAP = {
|
|
轻微: 0,
|
|
轻微隐患: 0,
|
|
一般: 0,
|
|
一般隐患: 0,
|
|
重大: 1,
|
|
重大隐患: 1
|
|
};
|
|
function createEmptyHazardPayload() {
|
|
return {
|
|
formData: {
|
|
title: "",
|
|
level: 0,
|
|
source: 0,
|
|
description: "",
|
|
tagIndex: 0,
|
|
tagId: null,
|
|
regulationId: null,
|
|
regulationName: ""
|
|
},
|
|
address: "",
|
|
lng: 0,
|
|
lat: 0,
|
|
areaId: "",
|
|
areaName: "",
|
|
fileList: []
|
|
};
|
|
}
|
|
function buildHiddenDangerParams(payload, extra = {}) {
|
|
var _a, _b, _c;
|
|
const { formData, address, lng, lat, areaId, fileList } = payload;
|
|
const selectedTag = (_a = payload.tagOptions) == null ? void 0 : _a[formData.tagIndex];
|
|
const tagId = formData.tagId ?? (selectedTag ? selectedTag.id : null);
|
|
return {
|
|
title: formData.title,
|
|
level: ((_b = LEVEL_OPTIONS[formData.level]) == null ? void 0 : _b.id) || 2,
|
|
lng: lng || 0,
|
|
lat: lat || 0,
|
|
address: address || "",
|
|
areaId: areaId || null,
|
|
description: formData.description || "",
|
|
source: ((_c = SOURCE_OPTIONS[formData.source]) == null ? void 0 : _c.title) || "",
|
|
tagId,
|
|
attachments: (fileList || []).filter((f) => f.status === "success").map((file) => utils_upload.buildAttachmentItem(file)),
|
|
regulationId: formData.regulationId || null,
|
|
...extra
|
|
};
|
|
}
|
|
function hasValidHazardPayload(payload) {
|
|
if (!payload)
|
|
return false;
|
|
const { formData, fileList } = payload;
|
|
return !!((formData == null ? void 0 : formData.title) && (fileList == null ? void 0 : fileList.length) > 0);
|
|
}
|
|
exports.AI_LEVEL_MAP = AI_LEVEL_MAP;
|
|
exports.LEVEL_OPTIONS = LEVEL_OPTIONS;
|
|
exports.SOURCE_OPTIONS = SOURCE_OPTIONS;
|
|
exports.buildHiddenDangerParams = buildHiddenDangerParams;
|
|
exports.createEmptyHazardPayload = createEmptyHazardPayload;
|
|
exports.hasValidHazardPayload = hasValidHazardPayload;
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/hazard/hazardForm.js.map
|