ljs-tools 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -299,10 +299,35 @@ function initSearchDate(day = 10, time = false) {
299
299
  end = formatTime(/* @__PURE__ */ new Date(), formatValue);
300
300
  return [start, end];
301
301
  }
302
+ function initSearchDateQj(type = "date", n = 0) {
303
+ const date = /* @__PURE__ */ new Date();
304
+ let start = "";
305
+ let end = "";
306
+ switch (type) {
307
+ case "datetime":
308
+ start = formatTime(date, "{y}-{m}-{d} 00:00:00");
309
+ end = formatTime(date, "{y}-{m}-{d} {h}:{i}:{s}");
310
+ break;
311
+ case "date":
312
+ start = formatTime(date, "{y}-{m}-01");
313
+ end = formatTime(date, "{y}-{m}-{d}");
314
+ break;
315
+ case "month":
316
+ start = formatTime(date, "{y}-01");
317
+ end = formatTime(date, "{y}-{m}");
318
+ break;
319
+ case "year":
320
+ start = date.getFullYear() - (n + 1) * 5;
321
+ end = date.getFullYear();
322
+ break;
323
+ }
324
+ return [start, end];
325
+ }
302
326
  const LJSdate = {
303
327
  formatTime,
304
328
  dateQjChange,
305
- initSearchDate
329
+ initSearchDate,
330
+ initSearchDateQj
306
331
  };
307
332
  function numDxsCheck(opt) {
308
333
  const allOpt = {
@@ -12713,11 +12738,26 @@ const index$1 = {
12713
12738
  dictValue: String,
12714
12739
  // 日期类型字典数据
12715
12740
  datetypeData: Array,
12741
+ // 清除按钮
12742
+ clearable: {
12743
+ type: Boolean,
12744
+ default: false
12745
+ },
12746
+ disabledDate: {
12747
+ type: Function,
12748
+ default: () => {
12749
+ }
12750
+ },
12716
12751
  // 字典key值对应的value值,按照年月日的顺序,默认年为1日为3
12717
12752
  dateTypeKeyValue: {
12718
12753
  type: Array,
12719
12754
  default: ["1", "2", "3"]
12720
12755
  },
12756
+ // 日期区间值切换规则:0跟随传入日期;1每次切换取当月、当年;
12757
+ dateSwitchRule: {
12758
+ type: Number,
12759
+ default: 0
12760
+ },
12721
12761
  // 默认类型,默认值:日。字典value
12722
12762
  formItemLabel: {
12723
12763
  type: String,
@@ -12729,6 +12769,11 @@ const index$1 = {
12729
12769
  default: () => {
12730
12770
  return [];
12731
12771
  }
12772
+ },
12773
+ // 中间符
12774
+ symbol: {
12775
+ type: String,
12776
+ default: "~"
12732
12777
  }
12733
12778
  },
12734
12779
  data() {
@@ -12737,7 +12782,9 @@ const index$1 = {
12737
12782
  date_type: [],
12738
12783
  // 日期参数
12739
12784
  opts: {
12740
- dateType: "daterange",
12785
+ startDate: null,
12786
+ endDate: null,
12787
+ dateType: "date",
12741
12788
  // 日期类型,年year,月month,日date
12742
12789
  dateTypeTag: true,
12743
12790
  // 日期控件是否显示
@@ -12753,14 +12800,6 @@ const index$1 = {
12753
12800
  set(val) {
12754
12801
  this.$emit("update:dictValue", val);
12755
12802
  }
12756
- },
12757
- dateValue: {
12758
- get() {
12759
- return this.date;
12760
- },
12761
- set(val) {
12762
- this.$emit("update:date", val);
12763
- }
12764
12803
  }
12765
12804
  },
12766
12805
  watch: {
@@ -12785,12 +12824,23 @@ const index$1 = {
12785
12824
  this.init();
12786
12825
  },
12787
12826
  methods: {
12788
- yearChange() {
12789
- if (Number(this.dateValue[1]) < Number(this.dateValue[0])) {
12790
- const temp0 = this.dateValue[0];
12791
- const temp1 = this.dateValue[1];
12792
- this.dateValue = [temp1, temp0];
12827
+ // 切换日期
12828
+ dateChange() {
12829
+ if (this.opts.startDate === null || this.opts.endDate === null) {
12830
+ return;
12793
12831
  }
12832
+ let start = this.opts.startDate;
12833
+ let end = this.opts.startDate;
12834
+ if (this.dateType !== "year") {
12835
+ start = new Date(this.opts.startDate).getTime();
12836
+ end = new Date(this.opts.endDate).getTime();
12837
+ }
12838
+ if (Number(start) > Number(end)) {
12839
+ const temp = this.opts.startDate;
12840
+ this.opts.startDate = this.opts.endDate;
12841
+ this.opts.endDate = temp;
12842
+ }
12843
+ this.$emit("update:date", [this.opts.startDate, this.opts.endDate]);
12794
12844
  },
12795
12845
  init() {
12796
12846
  this.initData();
@@ -12811,6 +12861,10 @@ const index$1 = {
12811
12861
  });
12812
12862
  this.date_type = res1;
12813
12863
  }
12864
+ if (!LJSbase.fieldCheck(this.date) && this.date.length === 2) {
12865
+ this.opts.startDate = this.date[0];
12866
+ this.opts.endDate = this.date[1];
12867
+ }
12814
12868
  this.dateTypeF(this.dateType);
12815
12869
  },
12816
12870
  // 日期类型切换
@@ -12818,47 +12872,65 @@ const index$1 = {
12818
12872
  this.opts.dateTypeTag = false;
12819
12873
  this.dateType = val;
12820
12874
  let dateValue = [];
12821
- const date = /* @__PURE__ */ new Date();
12875
+ let date = null;
12822
12876
  switch (val) {
12823
12877
  case this.dateTypeKeyValue[3]:
12824
- this.opts.dateType = "daterange";
12825
- this.opts.valueFormat = "YYYY-MM-DD";
12826
- dateValue = [LJSdate.formatTime(date, "{y}-{m}-{d}"), LJSdate.formatTime(date, "{y}-{m}-{d}")];
12878
+ this.opts.dateType = "datetime";
12879
+ this.opts.valueFormat = "YYYY-MM-DD HH:mm:ss";
12827
12880
  break;
12828
12881
  case this.dateTypeKeyValue[2]:
12829
- this.opts.dateType = "daterange";
12882
+ this.opts.dateType = "date";
12830
12883
  this.opts.valueFormat = "YYYY-MM-DD";
12831
- dateValue = [LJSdate.formatTime(date, "{y}-{m}-01"), LJSdate.formatTime(date, "{y}-{m}-{d}")];
12832
12884
  break;
12833
12885
  case this.dateTypeKeyValue[1]:
12834
- this.opts.dateType = "monthrange";
12886
+ this.opts.dateType = "month";
12835
12887
  this.opts.valueFormat = "YYYY-MM";
12836
- dateValue = [LJSdate.formatTime(date, "{y}-01"), LJSdate.formatTime(date, "{y}-{m}")];
12837
12888
  break;
12838
12889
  case this.dateTypeKeyValue[0]:
12839
12890
  this.opts.dateType = "year";
12840
12891
  this.opts.valueFormat = "YYYY";
12841
- dateValue = [(date.getFullYear() - 4).toString(), date.getFullYear().toString()];
12842
12892
  break;
12843
12893
  }
12844
- this.dateValue = dateValue;
12894
+ if (!LJSbase.fieldCheck(this.date) && this.date.length === 2) {
12895
+ if (this.dateSwitchRule === 0) {
12896
+ date = [this.date[0], this.date[1]];
12897
+ } else if (this.dateSwitchRule === 1) {
12898
+ date = LJSdate.initSearchDateQj(this.opts.dateType);
12899
+ }
12900
+ switch (val) {
12901
+ case this.dateTypeKeyValue[3]:
12902
+ this.opts.startDate = LJSdate.formatTime(date[0], "{y}-{m}-{d} {h}:{i}:{s}");
12903
+ this.opts.endDate = LJSdate.formatTime(date[1], "{y}-{m}-{d} {h}:{i}:{s}");
12904
+ break;
12905
+ case this.dateTypeKeyValue[2]:
12906
+ this.opts.startDate = LJSdate.formatTime(date[0], "{y}-{m}-{d}");
12907
+ this.opts.endDate = LJSdate.formatTime(date[1], "{y}-{m}-{d}");
12908
+ break;
12909
+ case this.dateTypeKeyValue[1]:
12910
+ this.opts.startDate = LJSdate.formatTime(date[0], "{y}-{m}");
12911
+ this.opts.endDate = LJSdate.formatTime(date[1], "{y}-{m}");
12912
+ break;
12913
+ case this.dateTypeKeyValue[0]:
12914
+ this.opts.startDate = date[0].toString();
12915
+ this.opts.endDate = date[1].toString();
12916
+ break;
12917
+ }
12918
+ this.dateValue = dateValue;
12919
+ }
12845
12920
  setTimeout(() => {
12846
12921
  this.opts.dateTypeTag = true;
12847
12922
  }, 0);
12848
12923
  }
12849
12924
  }
12850
12925
  };
12851
- const index_vue_vue_type_style_index_0_scoped_df1ad931_lang = "";
12926
+ const index_vue_vue_type_style_index_0_scoped_43652919_lang = "";
12852
12927
  const _sfc_main$3 = index$1;
12853
12928
  const _hoisted_1$3 = ["onClick"];
12854
12929
  const _hoisted_2$1 = {
12855
12930
  key: 0,
12856
12931
  class: "frequencyDate"
12857
12932
  };
12858
- const _hoisted_3$1 = {
12859
- key: 2,
12860
- class: "zhi"
12861
- };
12933
+ const _hoisted_3$1 = { class: "zhi" };
12862
12934
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
12863
12935
  const _component_el_date_picker = resolveComponent("el-date-picker");
12864
12936
  const _component_el_form_item = resolveComponent("el-form-item");
@@ -12884,45 +12956,35 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
12884
12956
  createVNode(Transition, { name: "frequencyDate" }, {
12885
12957
  default: withCtx(() => [
12886
12958
  _ctx.opts.dateTypeTag ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
12887
- _ctx.opts.dateType !== "year" ? (openBlock(), createBlock(_component_el_date_picker, {
12888
- key: 0,
12889
- modelValue: _ctx.dateValue,
12890
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.dateValue = $event),
12891
- style: { "width": "240px" },
12892
- "value-format": _ctx.opts.valueFormat,
12893
- type: _ctx.opts.dateType,
12894
- placeholder: "请选择",
12895
- editable: false,
12896
- clearable: false,
12897
- "disabled-date": _ctx.LJSfc.pickerOptions()
12898
- }, null, 8, ["modelValue", "value-format", "type", "disabled-date"])) : createCommentVNode("", true),
12899
- _ctx.opts.dateType === "year" ? (openBlock(), createBlock(_component_el_date_picker, {
12900
- key: 1,
12901
- modelValue: _ctx.dateValue[0],
12902
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.dateValue[0] = $event),
12903
- style: { "width": "100px !important" },
12959
+ createVNode(_component_el_date_picker, {
12960
+ modelValue: _ctx.opts.startDate,
12961
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.opts.startDate = $event),
12962
+ style: normalizeStyle({
12963
+ width: `${_ctx.opts.dateType === "year" ? 100 : _ctx.opts.dateType === "month" ? 120 : _ctx.opts.dateType === "date" ? 140 : _ctx.opts.dateType === "datetime" ? 200 : 200}px !important`
12964
+ }),
12904
12965
  "value-format": _ctx.opts.valueFormat,
12905
12966
  type: _ctx.opts.dateType,
12906
12967
  placeholder: "请选择",
12907
12968
  editable: false,
12908
- clearable: false,
12909
- "disabled-date": _ctx.LJSfc.pickerOptions(),
12910
- onChange: _ctx.yearChange
12911
- }, null, 8, ["modelValue", "value-format", "type", "disabled-date", "onChange"])) : createCommentVNode("", true),
12912
- _ctx.opts.dateType === "year" ? (openBlock(), createElementBlock("span", _hoisted_3$1, "~")) : createCommentVNode("", true),
12913
- _ctx.opts.dateType === "year" ? (openBlock(), createBlock(_component_el_date_picker, {
12914
- key: 3,
12915
- modelValue: _ctx.dateValue[1],
12916
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.dateValue[1] = $event),
12917
- style: { "width": "100px !important" },
12969
+ clearable: _ctx.clearable,
12970
+ "disabled-date": _ctx.disabledDate,
12971
+ onChange: _ctx.dateChange
12972
+ }, null, 8, ["modelValue", "style", "value-format", "type", "clearable", "disabled-date", "onChange"]),
12973
+ createElementVNode("span", _hoisted_3$1, toDisplayString(_ctx.symbol), 1),
12974
+ createVNode(_component_el_date_picker, {
12975
+ modelValue: _ctx.opts.endDate,
12976
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.opts.endDate = $event),
12977
+ style: normalizeStyle({
12978
+ width: `${_ctx.opts.dateType === "year" ? 100 : _ctx.opts.dateType === "month" ? 120 : _ctx.opts.dateType === "date" ? 140 : _ctx.opts.dateType === "datetime" ? 200 : 200}px !important`
12979
+ }),
12918
12980
  "value-format": _ctx.opts.valueFormat,
12919
12981
  type: _ctx.opts.dateType,
12920
12982
  placeholder: "请选择",
12921
12983
  editable: false,
12922
- clearable: false,
12923
- "disabled-date": _ctx.LJSfc.pickerOptions(),
12924
- onChange: _ctx.yearChange
12925
- }, null, 8, ["modelValue", "value-format", "type", "disabled-date", "onChange"])) : createCommentVNode("", true)
12984
+ clearable: _ctx.clearable,
12985
+ "disabled-date": _ctx.disabledDate,
12986
+ onChange: _ctx.dateChange
12987
+ }, null, 8, ["modelValue", "style", "value-format", "type", "clearable", "disabled-date", "onChange"])
12926
12988
  ])) : createCommentVNode("", true)
12927
12989
  ]),
12928
12990
  _: 1
@@ -12931,7 +12993,7 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
12931
12993
  _: 1
12932
12994
  }, 8, ["label"]);
12933
12995
  }
12934
- const DatetypeChooseDateRange = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-df1ad931"]]);
12996
+ const DatetypeChooseDateRange = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-43652919"]]);
12935
12997
  const index = {
12936
12998
  name: "DatetypeChooseDateRange",
12937
12999
  props: {
@@ -12945,7 +13007,7 @@ const index = {
12945
13007
  // 默认类型,默认值:日。字典value
12946
13008
  formItemLabel: {
12947
13009
  type: String,
12948
- default: "日期区间"
13010
+ default: "日期"
12949
13011
  },
12950
13012
  // 清除按钮
12951
13013
  clearable: {
@@ -12960,8 +13022,6 @@ const index = {
12960
13022
  },
12961
13023
  data() {
12962
13024
  return {
12963
- LJSfc,
12964
- date_type: [],
12965
13025
  // 日期参数
12966
13026
  opts: {
12967
13027
  startDate: null,
@@ -13026,9 +13086,9 @@ const index = {
13026
13086
  }
13027
13087
  }
13028
13088
  };
13029
- const index_vue_vue_type_style_index_0_scoped_9216c7d9_lang = "";
13089
+ const index_vue_vue_type_style_index_0_scoped_bb586ec7_lang = "";
13030
13090
  const _sfc_main$2 = index;
13031
- const _withScopeId$1 = (n) => (pushScopeId("data-v-9216c7d9"), n = n(), popScopeId(), n);
13091
+ const _withScopeId$1 = (n) => (pushScopeId("data-v-bb586ec7"), n = n(), popScopeId(), n);
13032
13092
  const _hoisted_1$2 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createElementVNode("span", { class: "and" }, "~", -1));
13033
13093
  function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
13034
13094
  const _component_el_date_picker = resolveComponent("el-date-picker");
@@ -13071,7 +13131,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
13071
13131
  _: 1
13072
13132
  }, 8, ["label"]);
13073
13133
  }
13074
- const DateRange = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-9216c7d9"]]);
13134
+ const DateRange = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-bb586ec7"]]);
13075
13135
  const index_vue_vue_type_style_index_0_scoped_f2de2f23_lang = "";
13076
13136
  const _sfc_main$1 = {
13077
13137
  name: "DictTag",