"use strict";
require("../../common/libraries/request.js");
require("../../common/store/useWatermarkStore.js");
const common_store_useWeAppAuthStore = require("../../common/store/useWeAppAuthStore.js");
require("../../common/store/useWorkStore.js");
const WORKORDER_patrol_update_model = require("./model.js");
const gen_Apis = require("../../gen/Apis.js");
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const common_libraries_naviHelper = require("../../common/libraries/naviHelper.js");
common_store_useWeAppAuthStore.useWeAppAuthStore();
const method = {
  init(data) {
    WORKORDER_patrol_update_model.useModel.HouseWorkOrdersStatusItemEnum.value = {
      Processing0: { text: "不合格", value: "0" },
      Processing1: { text: "合格", value: "1" }
    };
    WORKORDER_patrol_update_model.useModel.formData.value = {
      ...data,
      house_work_orders_id: data == null ? void 0 : data.id
    };
  },
  handleSubmit() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
    console.log("handleSubmit", WORKORDER_patrol_update_model.useModel.formData.value);
    if (((_c = (_b = (_a = WORKORDER_patrol_update_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value) == null ? void 0 : _c.type) === "RenovationInspection" && !((_g = (_f = (_e = (_d = WORKORDER_patrol_update_model.useModel) == null ? void 0 : _d.formData) == null ? void 0 : _e.value) == null ? void 0 : _f.attachments) == null ? void 0 : _g.length)) {
      return common_libraries_naviHelper.showToast("请上传巡检图片！");
    }
    if (((_j = (_i = (_h = WORKORDER_patrol_update_model.useModel) == null ? void 0 : _h.formData) == null ? void 0 : _i.value) == null ? void 0 : _j.type) === "RenovationAcceptance") {
      if (!((_m = (_l = (_k = WORKORDER_patrol_update_model.useModel) == null ? void 0 : _k.formData) == null ? void 0 : _l.value) == null ? void 0 : _m.is_passed)) {
        return common_libraries_naviHelper.showToast("请选择验收结果！");
      }
      if (!((_p = (_o = (_n = WORKORDER_patrol_update_model.useModel) == null ? void 0 : _n.formData) == null ? void 0 : _o.value) == null ? void 0 : _p.description)) {
        return common_libraries_naviHelper.showToast("请输入验收说明！");
      }
      if (!((_t = (_s = (_r = (_q = WORKORDER_patrol_update_model.useModel) == null ? void 0 : _q.formData) == null ? void 0 : _r.value) == null ? void 0 : _s.attachments) == null ? void 0 : _t.length)) {
        return common_libraries_naviHelper.showToast("请上传验收图片！");
      }
    }
    console.log("useModel.formData.value", WORKORDER_patrol_update_model.useModel.formData.value);
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkLogs.Store, {
      ...WORKORDER_patrol_update_model.useModel.formData.value,
      status: "Completed"
    }).then((res) => {
      common_libraries_naviHelper.showToastBack("提交成功！", 1, true);
      console.log(res);
    });
  }
};
exports.method = method;
