byqk-edit-view.fea98c06.js 2.4 KB
Newer Older
lxm1993's avatar
lxm1993 committed
1 2 3
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";
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
const M = u({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
lxm1993's avatar
lxm1993 committed
20 21 22 23 24 25 26
      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);
27
      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();
lxm1993's avatar
lxm1993 committed
28
    }, l = n();
29 30 31 32 33 34
    return {
      ns: o,
      c: t,
      currentDate: i,
      onCurrentDateChange: d,
      options: {
lxm1993's avatar
lxm1993 committed
35 36
        disabledDate: (s) => {
          const r = n(s);
37 38 39 40 41 42
          return l.isSame(r, "day") || l.isBefore(r, "day");
        }
      }
    };
  },
  render(e) {
lxm1993's avatar
lxm1993 committed
43
    let a = null;
44 45 46 47
    if (this.c.complete) {
      const {
        form: o
      } = this.c.model;
lxm1993's avatar
lxm1993 committed
48
      this.c.providers[o.name] && (a = e(this.c.providers[o.name].component, {
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        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",
lxm1993's avatar
lxm1993 committed
76 77
            options: this.options,
            placement: "bottom-end"
78 79 80 81 82 83
          },
          on: {
            "on-change": this.onCurrentDateChange
          }
        })])
      }
lxm1993's avatar
lxm1993 committed
84
    }, [a]);
85 86 87 88 89
  }
});
export {
  M as default
};