"use strict";
const common_vendor = require("../../../common/vendor.js");
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 INDEX_task_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");
const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
const method = {
  init(data) {
    var _a;
    common_vendor.index.setNavigationBarTitle({
      title: data == null ? void 0 : data.type
    });
    console.log("init", auth == null ? void 0 : auth.data);
    INDEX_task_update_model.useModel.formData.value = {
      ...data,
      pageType: data == null ? void 0 : data.type,
      assign_employees: (_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.user,
      house_work_orders_id: data == null ? void 0 : data.id
    };
  },
  handleSubmit() {
    var _a, _b;
    console.log("handleSubmit", INDEX_task_update_model.useModel.formData.value);
    let data = (_b = (_a = INDEX_task_update_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value;
    if (!(data == null ? void 0 : data.level)) {
      return common_libraries_naviHelper.showToast("请先选择优先级！");
    }
    if ((data == null ? void 0 : data.pageType) === "指派工单" && !(data == null ? void 0 : data.assign_employees_id)) {
      return common_libraries_naviHelper.showToast("请先选择处理人！");
    }
    common_libraries_apiLoading.getApiLoading(
      (data == null ? void 0 : data.pageType) === "指派工单" ? gen_Apis.Apis.WorkOrder.HouseWorkOrders.Assign : gen_Apis.Apis.WorkOrder.HouseWorkOrders.Receive,
      data
    ).then((res) => {
      common_libraries_naviHelper.showToastBack((data == null ? void 0 : data.pageType) === "指派工单" ? "提交成功！" : "领取成功！", 1, true);
      console.log(res);
    });
  }
};
exports.method = method;
