import { useNamespace as m, useEditViewController as p } from "@ibiz-template/vue-util";
import { defineComponent as u, getCurrentInstance as y, ref as Y } from "vue";
import n from "dayjs";
const M = u({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: a
    } = y(), o = m("byqk-edit-view"), t = p(a, e.modelPath), c = n().subtract(1, "day");
    t.context.selectDay = c.format("YYYY-MM-DD"), t.params.kqrq = t.context.selectDay, t.context.selectMonth = c.format("YYYY-MM");
    const i = Y(c.toDate()), d = (s) => {
      if (s === n(i.value).format("YYYY-MM-DD"))
        return;
      const r = n(s);
      i.value = r.toDate(), t.context.selectDay = r.format("YYYY-MM-DD"), t.params.kqrq = t.context.selectDay, t.context.selectMonth = r.format("YYYY-MM"), t.load();
    }, l = n();
    return {
      ns: o,
      c: t,
      currentDate: i,
      onCurrentDateChange: d,
      options: {
        disabledDate: (s) => {
          const r = n(s);
          return l.isSame(r, "day") || l.isBefore(r, "day");
        }
      }
    };
  },
  render(e) {
    let a = null;
    if (this.c.complete) {
      const {
        form: o
      } = this.c.model;
      this.c.providers[o.name] && (a = e(this.c.providers[o.name].component, {
        props: {
          modelData: o,
          context: this.c.context,
          params: this.c.params
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit(o.name)
        }
      }));
    }
    return e("view-base", {
      attrs: {
        controller: this.c
      },
      class: this.ns.b(),
      scopedSlots: {
        toolbar: () => e("div", {
          class: this.ns.b("calendar-picker-toolbar")
        }, [e("div", {
          class: this.ns.be("calendar-picker-toolbar", "title")
        }, ["\u6309\u65E5\u671F\u67E5\u8BE2"]), e("i-CalendarPicker", {
          class: this.ns.be("calendar-picker-toolbar", "tool"),
          attrs: {
            value: this.currentDate,
            clearable: !1,
            format: "yyyy-MM-dd",
            placeholder: "\u8BF7\u9009\u62E9",
            options: this.options,
            placement: "bottom-end"
          },
          on: {
            "on-change": this.onCurrentDateChange
          }
        })])
      }
    }, [a]);
  }
});
export {
  M as default
};
