"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_libraries_apiLoading = require("../../../common/libraries/apiLoading.js");
const common_libraries_day = require("../../../common/libraries/day.js");
const common_libraries_naviHelper = require("../../../common/libraries/naviHelper.js");
const gen_Apis = require("../../../gen/Apis.js");
const ME_instrument_add_model = require("./model.js");
const method = {
  init(e) {
    ME_instrument_add_model.useModel.formData.value = { house_meters_id: e == null ? void 0 : e.id };
  },
  handleSubmit() {
    var _a, _b, _c;
    console.log("handleSubmit", ME_instrument_add_model.useModel.formData.value);
    if (!((_c = (_b = (_a = ME_instrument_add_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value) == null ? void 0 : _c.current_reading)) {
      return common_libraries_naviHelper.showToast("请设置本次读数！");
    }
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Meter.HouseMeterReadings.Store, {
      ...ME_instrument_add_model.useModel.formData.value,
      reading_time: common_libraries_day.getTime()
    }).then((res) => {
      common_libraries_naviHelper.showToastBack("提交成功！", 1, true);
      console.log(res);
    });
  },
  handleToSelectHouse() {
    common_vendor.index.navigateTo({
      url: "/pages/public/asset_houses/index?type=work_add"
    });
  },
  handleSwitchChange(e) {
    var _a;
    ME_instrument_add_model.useModel.formData.value.is_anonymous = (_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.value;
    console.log(e, "e");
  },
  getShow(e) {
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Meter.HouseMeters.Show, e).then((res) => {
      ME_instrument_add_model.useModel.showData.value = res == null ? void 0 : res.data;
      console.log(res);
    });
  }
};
exports.method = method;
