"use strict";
const common_vendor = require("../../../common/vendor.js");
const ME_emergency_show_model = require("./model.js");
const common_libraries_apiLoading = require("../../../common/libraries/apiLoading.js");
const gen_Apis = require("../../../gen/Apis.js");
const getShow = () => {
  var _a, _b;
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Emergency.EmergencyEvents.Show, (_b = (_a = ME_emergency_show_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value).then((res) => {
    var _a2;
    ME_emergency_show_model.useModel.showData.value = res == null ? void 0 : res.data;
    ME_emergency_show_model.useModel.formDataLogs.value = { emergency_events_id: (_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.id, page: 1 };
    getLogs();
  });
};
const getLogs = () => {
  var _a, _b;
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Emergency.EmergencyEventFollows.List, (_b = (_a = ME_emergency_show_model.useModel) == null ? void 0 : _a.formDataLogs) == null ? void 0 : _b.value).then(
    (res) => {
      var _a2, _b2;
      ME_emergency_show_model.useModel.logsData.value = [...(_b2 = (_a2 = ME_emergency_show_model.useModel) == null ? void 0 : _a2.logsData) == null ? void 0 : _b2.value, ...res == null ? void 0 : res.data];
      ME_emergency_show_model.useModel.metaData.value = res == null ? void 0 : res.meta;
    }
  );
};
const method = {
  getShow,
  handlePreview(index) {
    var _a, _b, _c, _d;
    common_vendor.index.previewImage({
      urls: (_d = (_c = (_b = (_a = ME_emergency_show_model.useModel) == null ? void 0 : _a.showData) == null ? void 0 : _b.value) == null ? void 0 : _c.emergency_images) == null ? void 0 : _d.map((i) => (i == null ? void 0 : i.url) || ""),
      current: index
    });
  },
  handleLoad(page) {
    console.log(page);
    ME_emergency_show_model.useModel.formDataLogs.value.page = page;
    getLogs();
  },
  handleClose() {
    var _a, _b, _c;
    common_vendor.index.navigateTo({
      url: `/ME/emergency/update/index?id=${(_c = (_b = (_a = ME_emergency_show_model.useModel) == null ? void 0 : _a.showData) == null ? void 0 : _b.value) == null ? void 0 : _c.id}&type=申请关闭`
    });
  },
  handleUpdate() {
    var _a, _b, _c;
    common_vendor.index.navigateTo({
      url: `/ME/emergency/update/index?id=${(_c = (_b = (_a = ME_emergency_show_model.useModel) == null ? void 0 : _a.showData) == null ? void 0 : _b.value) == null ? void 0 : _c.id}&type=更新进度`
    });
  },
  handleUpdateFollow() {
    var _a, _b, _c;
    common_vendor.index.navigateTo({
      url: `/ME/emergency/change/index?id=${(_c = (_b = (_a = ME_emergency_show_model.useModel) == null ? void 0 : _a.showData) == null ? void 0 : _b.value) == null ? void 0 : _c.id}`
    });
  }
};
exports.method = method;
