(component): 新增 date-picker 组件 placeholder 属性

This commit is contained in:
就眠儀式 2022-07-09 20:03:44 +08:00
parent a939c48b79
commit 9ef5a01fbc
4 changed files with 16 additions and 23 deletions

View File

@ -5,6 +5,8 @@
readonly readonly
:name="name" :name="name"
:model-value="dateValue || modelValue" :model-value="dateValue || modelValue"
:placeholder="placeholder"
:allow-clear="true"
prefix-icon="layui-icon-date" prefix-icon="layui-icon-date"
> >
</lay-input> </lay-input>
@ -279,13 +281,14 @@ import { getDayLength, getYears, getMonth, getYear } from "./day";
import { ref, watch, computed, defineProps, defineEmits, onMounted } from "vue"; import { ref, watch, computed, defineProps, defineEmits, onMounted } from "vue";
export interface LayDatePickerProps { export interface LayDatePickerProps {
modelValue?: string;
type?: "date" | "datetime" | "year" | "time" | "month" | "yearmonth"; type?: "date" | "datetime" | "year" | "time" | "month" | "yearmonth";
placeholder?: string;
modelValue?: string;
disabled?: boolean;
simple?: boolean;
name?: string; name?: string;
max?: string; max?: string;
min?: string; min?: string;
disabled?: boolean;
simple?: boolean;
} }
const props = withDefaults(defineProps<LayDatePickerProps>(), { const props = withDefaults(defineProps<LayDatePickerProps>(), {
@ -299,20 +302,7 @@ const dropdownRef = ref(null);
const $emits = defineEmits(["update:modelValue"]); const $emits = defineEmits(["update:modelValue"]);
const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"]; const WEEK_NAME = ["日", "一", "二", "三", "四", "五", "六"];
const MONTH_NAME = [ const MONTH_NAME = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"];
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
];
const hms = ref({ const hms = ref({
hh: dayjs(props.modelValue).hour(), hh: dayjs(props.modelValue).hour(),

View File

@ -45,13 +45,17 @@ const emit = defineEmits<InputEmits>();
const { t } = useI18n(); const { t } = useI18n();
const slots = useSlots(); const slots = useSlots();
const currentValue = ref<string>(String(props.modelValue == null ? '' : props.modelValue)); const currentValue = ref<string>(
String(props.modelValue == null ? "" : props.modelValue)
);
const hasContent = computed(() => (props.modelValue as string)?.length > 0); const hasContent = computed(() => (props.modelValue as string)?.length > 0);
watch( watch(
() => props.modelValue, () => props.modelValue,
() => { () => {
currentValue.value = String(props.modelValue == null ? '' : props.modelValue); currentValue.value = String(
props.modelValue == null ? "" : props.modelValue
);
} }
); );
@ -126,7 +130,7 @@ const classes = computed(() => {
></lay-icon> ></lay-icon>
</span> </span>
<span class="layui-input-clear" v-if="allowClear && hasContent"> <span class="layui-input-clear" v-if="allowClear && hasContent">
<lay-icon type="layui-icon-close-fill" @click="onClear"></lay-icon> <lay-icon type="layui-icon-close-fill" @click.stop="onClear"></lay-icon>
</span> </span>
</div> </div>
</template> </template>

View File

@ -18,8 +18,6 @@ export type MaybeRef<T> = Ref<T> | T;
export type Recordable = Record<string, any>; export type Recordable = Record<string, any>;
/************************/
export type Number = number; export type Number = number;
export type String = string; export type String = string;

View File

@ -16,8 +16,9 @@
<li> <li>
<h3>1.2.8 <span class="layui-badge-rim">2022-07-08</span></h3> <h3>1.2.8 <span class="layui-badge-rim">2022-07-08</span></h3>
<ul> <ul>
<li>[修复] layer 组件 Notifiy 缺失关闭图标。 by @SmallWai</li> <li>[修复] layer 组件 notifiy 缺失关闭图标。 by @SmallWai</li>
<li>[修复] input 组件 modelValue 设置为 zero 不显示的问题。by @Jmysy</li> <li>[修复] input 组件 modelValue 设置为 zero 不显示的问题。by @Jmysy</li>
<li>[新增] date-picker 组件 placeholder 属性, 设置提示信息。by @Jmysy</li>
<li>[新增] textarea 组件 allow-clear 属性, 允许清空。by @Jmysy</li> <li>[新增] textarea 组件 allow-clear 属性, 允许清空。by @Jmysy</li>
<li>[新增] textarea 组件 change 回调函数。by @Jmysy</li> <li>[新增] textarea 组件 change 回调函数。by @Jmysy</li>
<li>[新增] textarea 组件 clear 回调函数。by @Jmysy</li> <li>[新增] textarea 组件 clear 回调函数。by @Jmysy</li>