添加 cl-date

This commit is contained in:
icssoa 2021-12-06 23:59:41 +08:00
parent 92c55b1882
commit 0fc2f2eb1a
6 changed files with 75 additions and 17 deletions

View File

@ -72,6 +72,12 @@ export default [
},
{
test: ["date"],
table: {
name: "cl-date",
props: {
format: "YYYY-MM-DD"
}
},
form: {
name: "el-date-picker",
props: {
@ -82,6 +88,12 @@ export default [
},
{
test: ["dates", "dateRange", "dateScope"],
table: {
name: "cl-date",
props: {
format: "YYYY-MM-DD"
}
},
form: {
component: {
name: "el-date-picker",
@ -109,7 +121,8 @@ export default [
name: "el-date-picker",
props: {
type: "datetimerange",
valueFormat: "YYYY-MM-DD HH:mm:ss"
valueFormat: "YYYY-MM-DD HH:mm:ss",
defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]
}
}
}

View File

@ -34,9 +34,6 @@ const colors = [
// 组件处理器
const handler = {
// 临时变量
d: {},
// 单选
dict({ comment }) {
const [label, ...arr] = comment.split(" ");
@ -207,7 +204,8 @@ function datetimeMerge({ columns, item }: any) {
name: "el-date-picker",
props: {
type: key == "time" ? "datetimerange" : "daterange",
valueFormat: "time" ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"
valueFormat: "time" ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00",
defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]
}
};
}

View File

@ -0,0 +1,30 @@
<template>
<span class="cl-date">{{ value }}</span>
</template>
<script lang="ts">
import { defineComponent, computed } from "vue";
import dayjs from "dayjs";
export default defineComponent({
name: "cl-date",
props: {
modelValue: [String, Number],
format: {
type: String,
default: "YYYY-MM-DD HH:mm:ss"
}
},
setup(props) {
const value = computed(() => {
return props.modelValue ? dayjs(props.modelValue).format(props.format) : "";
});
return {
value
};
}
});
</script>

View File

@ -63,7 +63,13 @@ export default defineComponent({
{
label: "创建时间",
prop: "createTime",
minWidth: 150
minWidth: 150,
component: {
name: "cl-date",
props: {
format: "YYYY-MM-DD"
}
}
},
{
label: "操作",

View File

@ -48,6 +48,22 @@ export default defineComponent({
component: {
name: "el-switch"
}
},
{
label: "时间",
prop: "time",
hook: "datetimeRange",
component: {
name: "el-date-picker",
props: {
type: "datetimerange",
valueFormat: "YYYY-MM-DD HH:mm:ss",
defaultTime: [
new Date(2000, 1, 1, 0, 0, 0),
new Date(2000, 1, 1, 23, 59, 59)
]
}
}
}
]);

View File

@ -6,41 +6,36 @@ export const UserList = [
{
id: 1,
name: "刘一",
createTime: "2019年09月02日",
createTime: "2019-09-02 12:00:00",
price: 75.99,
status: 1,
urls: "https://images.quanjing.com/ojo003/thu/pe0082640.jpg,https://images.quanjing.com/rad005/thu/rad600-02347621.jpg",
hook: "1,2"
},
{
id: 2,
name: "陈二",
createTime: "2019年09月05日",
createTime: "2019-09-05",
price: 242.1,
urls: [
"https://images.quanjing.com/rad005/thu/rad600-02347621.jpg",
"https://images.quanjing.com/ojo003/thu/pe0082640.jpg"
],
status: 2
},
{
id: 3,
name: "张三",
createTime: "2019年09月12日",
createTime: "2019-09-12",
price: 74.11,
status: 3
},
{
id: 4,
name: "李四",
createTime: "2019年09月13日",
createTime: "2019-09-13",
price: 276.64,
status: 4
},
{
id: 5,
name: "王五",
createTime: "2019年09月18日",
createTime: "2019-09-18",
price: 160.23,
status: 5
}
@ -92,7 +87,7 @@ export const TestService = {
UserList.push({
...d,
id: id++,
createTime: dayjs().format("YYYY年MM月DD日")
createTime: dayjs().format("YYYY-MM-DD日")
});
return Promise.resolve();
},