✨: 发布 1.2.8 版本
This commit is contained in:
		
							parent
							
								
									c09f4766b8
								
							
						
					
					
						commit
						3902453b7c
					
				@ -1,24 +1,51 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <lay-dropdown class="layui-cascader" ref="dropdownRef" :autoFitMinWidth="false" :updateAtScroll="true"
 | 
			
		||||
    :disabled="dropDownDisabled">
 | 
			
		||||
    <lay-input v-model="displayValue" readonly suffix-icon="layui-icon-down" :placeholder="placeholder"
 | 
			
		||||
      v-if="!slots.default" :allow-clear="allowClear" @clear="onClear"></lay-input>
 | 
			
		||||
  <lay-dropdown
 | 
			
		||||
    class="layui-cascader"
 | 
			
		||||
    ref="dropdownRef"
 | 
			
		||||
    :autoFitMinWidth="false"
 | 
			
		||||
    :updateAtScroll="true"
 | 
			
		||||
    :disabled="dropDownDisabled"
 | 
			
		||||
  >
 | 
			
		||||
    <lay-input
 | 
			
		||||
      v-model="displayValue"
 | 
			
		||||
      readonly
 | 
			
		||||
      suffix-icon="layui-icon-down"
 | 
			
		||||
      :placeholder="placeholder"
 | 
			
		||||
      v-if="!slots.default"
 | 
			
		||||
      :allow-clear="allowClear"
 | 
			
		||||
      @clear="onClear"
 | 
			
		||||
    ></lay-input>
 | 
			
		||||
    <slot v-else></slot>
 | 
			
		||||
 | 
			
		||||
    <template #content>
 | 
			
		||||
      <div class="layui-cascader-panel">
 | 
			
		||||
        <template v-for="(itemCol, index) in treeData">
 | 
			
		||||
          <lay-scroll height="180px" class="layui-cascader-menu" :key="'cascader-menu' + index"
 | 
			
		||||
            v-if="itemCol.data.length">
 | 
			
		||||
            <div class="layui-cascader-menu-item" v-for="(item, i) in itemCol.data" :key="index + i"
 | 
			
		||||
              @click="selectBar(item, i, index)" :class="[
 | 
			
		||||
          <lay-scroll
 | 
			
		||||
            height="180px"
 | 
			
		||||
            class="layui-cascader-menu"
 | 
			
		||||
            :key="'cascader-menu' + index"
 | 
			
		||||
            v-if="itemCol.data.length"
 | 
			
		||||
          >
 | 
			
		||||
            <div
 | 
			
		||||
              class="layui-cascader-menu-item"
 | 
			
		||||
              v-for="(item, i) in itemCol.data"
 | 
			
		||||
              :key="index + i"
 | 
			
		||||
              @click="selectBar(item, i, index)"
 | 
			
		||||
              :class="[
 | 
			
		||||
                {
 | 
			
		||||
                  'layui-cascader-selected': itemCol.selectIndex === i,
 | 
			
		||||
                },
 | 
			
		||||
              ]">
 | 
			
		||||
              <slot :name="item.slot" v-if="item.slot && slots[item.slot]"></slot>
 | 
			
		||||
              ]"
 | 
			
		||||
            >
 | 
			
		||||
              <slot
 | 
			
		||||
                :name="item.slot"
 | 
			
		||||
                v-if="item.slot && slots[item.slot]"
 | 
			
		||||
              ></slot>
 | 
			
		||||
              <template v-else>{{ item.label }}</template>
 | 
			
		||||
              <i class="layui-icon layui-icon-right" v-if="item.children && item.children.length"></i>
 | 
			
		||||
              <i
 | 
			
		||||
                class="layui-icon layui-icon-right"
 | 
			
		||||
                v-if="item.children && item.children.length"
 | 
			
		||||
              ></i>
 | 
			
		||||
            </div>
 | 
			
		||||
          </lay-scroll>
 | 
			
		||||
        </template>
 | 
			
		||||
@ -46,7 +73,7 @@ export interface LayCascaderProps {
 | 
			
		||||
  placeholder?: string;
 | 
			
		||||
  onlyLastLevel?: boolean;
 | 
			
		||||
  replaceFields?: { label: string; value: string; children: string };
 | 
			
		||||
  allowClear?: boolean
 | 
			
		||||
  allowClear?: boolean;
 | 
			
		||||
}
 | 
			
		||||
const props = withDefaults(defineProps<LayCascaderProps>(), {
 | 
			
		||||
  options: null,
 | 
			
		||||
@ -230,7 +257,7 @@ const dropDownDisabled = ref(false);
 | 
			
		||||
 | 
			
		||||
//清除事件
 | 
			
		||||
const onClear = () => {
 | 
			
		||||
  dropDownDisabled.value=true;
 | 
			
		||||
  dropDownDisabled.value = true;
 | 
			
		||||
  let arr = JSON.parse(JSON.stringify(treeData.value));
 | 
			
		||||
  for (let index = 0; index < arr.length; index++) {
 | 
			
		||||
    arr[index].selectIndex = null;
 | 
			
		||||
@ -242,7 +269,7 @@ const onClear = () => {
 | 
			
		||||
  treeData.value = arr;
 | 
			
		||||
  emit("update:modelValue", null);
 | 
			
		||||
  setTimeout(() => {
 | 
			
		||||
    dropDownDisabled.value=false;
 | 
			
		||||
    dropDownDisabled.value = false;
 | 
			
		||||
  }, 0);
 | 
			
		||||
}
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
@ -302,7 +302,20 @@ const dropdownRef = ref(null);
 | 
			
		||||
const $emits = defineEmits(["update:modelValue"]);
 | 
			
		||||
 | 
			
		||||
const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"];
 | 
			
		||||
const MONTH_NAME = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"];
 | 
			
		||||
const MONTH_NAME = [
 | 
			
		||||
  "1月",
 | 
			
		||||
  "2月",
 | 
			
		||||
  "3月",
 | 
			
		||||
  "4月",
 | 
			
		||||
  "5月",
 | 
			
		||||
  "6月",
 | 
			
		||||
  "7月",
 | 
			
		||||
  "8月",
 | 
			
		||||
  "9月",
 | 
			
		||||
  "10月",
 | 
			
		||||
  "11月",
 | 
			
		||||
  "12月",
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const hms = ref({
 | 
			
		||||
  hh: dayjs(props.modelValue).hour(),
 | 
			
		||||
 | 
			
		||||
@ -371,7 +371,8 @@ export function removeNotifiyFromQueen(layerId: string) {
 | 
			
		||||
  // 间隙
 | 
			
		||||
  let transOffsetTop = 15;
 | 
			
		||||
  // 删除项的高度
 | 
			
		||||
  let notifiyDom = document.getElementById(layerId)?.firstElementChild?.firstElementChild as HTMLElement;
 | 
			
		||||
  let notifiyDom = document.getElementById(layerId)?.firstElementChild
 | 
			
		||||
    ?.firstElementChild as HTMLElement;
 | 
			
		||||
  let offsetHeight = notifiyDom.offsetHeight;
 | 
			
		||||
  (window as any).NotifiyQueen = (window as any).NotifiyQueen || [];
 | 
			
		||||
  let notifiyQueen = (window as any).NotifiyQueen;
 | 
			
		||||
@ -386,11 +387,17 @@ export function removeNotifiyFromQueen(layerId: string) {
 | 
			
		||||
  // //得到需要修改的定位的Notifiy集合
 | 
			
		||||
  let needCalculatelist = list.slice(findIndex + 1);
 | 
			
		||||
  needCalculatelist.forEach((e: { id: string }) => {
 | 
			
		||||
    let dom = document.getElementById(e.id)?.firstElementChild?.firstElementChild as HTMLElement;
 | 
			
		||||
    let dom = document.getElementById(e.id)?.firstElementChild
 | 
			
		||||
      ?.firstElementChild as HTMLElement;
 | 
			
		||||
    if (offsetType === "rt" || offsetType === "lt") {
 | 
			
		||||
      dom.style["top"] = parseFloat(dom.style["top"]) - transOffsetTop - offsetHeight + "px";
 | 
			
		||||
      dom.style["top"] =
 | 
			
		||||
        parseFloat(dom.style["top"]) - transOffsetTop - offsetHeight + "px";
 | 
			
		||||
    } else {
 | 
			
		||||
      let bottom = parseFloat(dom.style["top"].split(" - ")[1]) - transOffsetTop - offsetHeight; dom.style["top"] = "calc(100vh - " + bottom + "px)";
 | 
			
		||||
      let bottom =
 | 
			
		||||
        parseFloat(dom.style["top"].split(" - ")[1]) -
 | 
			
		||||
        transOffsetTop -
 | 
			
		||||
        offsetHeight;
 | 
			
		||||
      dom.style["top"] = "calc(100vh - " + bottom + "px)";
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
  notifiyQueen.splice(index, 1); //删除
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user