80 lines
4.3 KiB
JavaScript
80 lines
4.3 KiB
JavaScript
|
|
"use strict";
|
|||
|
|
const ME_emergency_change_model = require("./model.js");
|
|||
|
|
require("../../../common/libraries/request.js");
|
|||
|
|
require("../../../common/store/useWatermarkStore.js");
|
|||
|
|
require("../../../common/store/useWeAppAuthStore.js");
|
|||
|
|
const common_store_useWorkStore = require("../../../common/store/useWorkStore.js");
|
|||
|
|
const common_libraries_day = require("../../../common/libraries/day.js");
|
|||
|
|
const common_libraries_apiLoading = require("../../../common/libraries/apiLoading.js");
|
|||
|
|
const gen_Apis = require("../../../gen/Apis.js");
|
|||
|
|
const common_libraries_naviHelper = require("../../../common/libraries/naviHelper.js");
|
|||
|
|
const work = common_store_useWorkStore.useWorkStore();
|
|||
|
|
const getShow = () => {
|
|||
|
|
var _a, _b;
|
|||
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Emergency.EmergencyEvents.Show, (_b = (_a = ME_emergency_change_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value).then((res) => {
|
|||
|
|
var _a2, _b2, _c;
|
|||
|
|
ME_emergency_change_model.useModel.formData.value = {
|
|||
|
|
...res == null ? void 0 : res.data,
|
|||
|
|
project_name: (_b2 = (_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.asset_project) == null ? void 0 : _b2.name,
|
|||
|
|
emergency_time: common_libraries_day.showDay((_c = res == null ? void 0 : res.data) == null ? void 0 : _c.emergency_time)
|
|||
|
|
};
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
const method = {
|
|||
|
|
getShow,
|
|||
|
|
init() {
|
|||
|
|
var _a, _b, _c, _d, _e;
|
|||
|
|
console.log("init", work == null ? void 0 : work.selectWorkProject);
|
|||
|
|
if ((_a = work == null ? void 0 : work.selectWorkProject) == null ? void 0 : _a.id) {
|
|||
|
|
ME_emergency_change_model.useModel.formData.value = {
|
|||
|
|
...(_c = (_b = ME_emergency_change_model.useModel) == null ? void 0 : _b.formData) == null ? void 0 : _c.value,
|
|||
|
|
project_name: (_d = work == null ? void 0 : work.selectWorkProject) == null ? void 0 : _d.name,
|
|||
|
|
asset_projects_id: (_e = work == null ? void 0 : work.selectWorkProject) == null ? void 0 : _e.id
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
handleSubmit() {
|
|||
|
|
var _a, _b, _c, _d, _e;
|
|||
|
|
let data = (_b = (_a = ME_emergency_change_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value;
|
|||
|
|
if (!(data == null ? void 0 : data.asset_projects_id)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请选择项目!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.name)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请输入事件名称!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.two_emergency_categories_id)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请选择分类!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.two_emergency_categories_id) || ((_c = data == null ? void 0 : data.two_emergency_categories_id) == null ? void 0 : _c.length) === 1) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请选择2级分类!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.emergency_event_levels_id)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请选择等级!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.emergency_event_levels_id)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请选择等级!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.emergency_time)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请选择发生时间!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.emergency_location)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请输入事发地点!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.emergency_description)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请输入事件描述!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.emergency_cause)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请输入原因!");
|
|||
|
|
}
|
|||
|
|
if (!(data == null ? void 0 : data.cause_result)) {
|
|||
|
|
return common_libraries_naviHelper.showToast("请设置结果!");
|
|||
|
|
}
|
|||
|
|
data.two_emergency_categories_id = ((_d = data == null ? void 0 : data.two_emergency_categories_id) == null ? void 0 : _d.length) ? (_e = data == null ? void 0 : data.two_emergency_categories_id) == null ? void 0 : _e[1] : data == null ? void 0 : data.two_emergency_categories_id;
|
|||
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Emergency.EmergencyEvents.Update, data).then((res) => {
|
|||
|
|
common_libraries_naviHelper.showToastBack("提交成功!", 1, true);
|
|||
|
|
console.log(res);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
exports.method = method;
|