"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 common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const common_libraries_naviHelper = require("../../common/libraries/naviHelper.js");
const gen_Apis = require("../../gen/Apis.js");
const WORKORDER_update_model = require("./model.js");
common_store_useWeAppAuthStore.useWeAppAuthStore();
const method = {
  init(data) {
    WORKORDER_update_model.useModel.HouseWorkOrdersStatusItemEnum.value = {
      Processing: { text: "仍在处理", value: "Processing" },
      Completed: { text: "我已完工", value: "Completed" }
    };
    WORKORDER_update_model.useModel.HouseWorkOrdersCostEnum.value = {
      Processing2: { text: "是", value: "1" },
      Processing1: { text: "否", value: "0" }
    };
    WORKORDER_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;
    console.log("handleSubmit", WORKORDER_update_model.useModel.formData.value);
    if (!WORKORDER_update_model.useModel.formData.value.status) {
      return common_libraries_naviHelper.showToast("请先选择状态！");
    }
    if (!WORKORDER_update_model.useModel.formData.value.description) {
      return common_libraries_naviHelper.showToast("请输入备注说明/进度说明！");
    }
    if (WORKORDER_update_model.useModel.formData.value.status === "Completed" && !((_a = WORKORDER_update_model.useModel.formData.value.attachments) == null ? void 0 : _a.length)) {
      return common_libraries_naviHelper.showToast("请上传完工图片！");
    }
    if (((_d = (_c = (_b = WORKORDER_update_model.useModel) == null ? void 0 : _b.formData) == null ? void 0 : _c.value) == null ? void 0 : _d.status) === "Completed" && ((_g = (_f = (_e = WORKORDER_update_model.useModel) == null ? void 0 : _e.formData) == null ? void 0 : _f.value) == null ? void 0 : _g.location) === "MyHome" && !((_j = (_i = (_h = WORKORDER_update_model.useModel) == null ? void 0 : _h.formData) == null ? void 0 : _i.value) == null ? void 0 : _j.is_fee)) {
      return common_libraries_naviHelper.showToast("请上选择是否产生费用！");
    }
    if (WORKORDER_update_model.useModel.formData.value.is_fee === "1" && !((_m = (_l = (_k = WORKORDER_update_model.useModel) == null ? void 0 : _k.formData) == null ? void 0 : _l.value) == null ? void 0 : _m.amount)) {
      return common_libraries_naviHelper.showToast("请输入费用金额！");
    }
    if (WORKORDER_update_model.useModel.formData.value.is_fee === "1" && !((_p = (_o = (_n = WORKORDER_update_model.useModel) == null ? void 0 : _n.formData) == null ? void 0 : _o.value) == null ? void 0 : _p.company_project_receipt_accounts_id)) {
      return common_libraries_naviHelper.showToast("请选择收款账号！");
    }
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkLogs.Store, {
      ...WORKORDER_update_model.useModel.formData.value
      // is_fee: useModel.formData.value.is_fee === '1' ? true : false
    }).then((res) => {
      common_libraries_naviHelper.showToastBack("提交成功！", 1, true);
      console.log(res);
    });
  }
};
exports.method = method;
