添加时间合并

This commit is contained in:
icssoa 2021-12-06 15:00:06 +08:00
parent 6620e99d4a
commit 4b9a43b55f
2 changed files with 46 additions and 13 deletions

View File

@ -75,16 +75,20 @@ export default [
form: { form: {
name: "el-date-picker", name: "el-date-picker",
props: { props: {
type: "date" type: "date",
valueFormat: "YYYY-MM-DD"
} }
} }
}, },
{ {
test: ["dates", "dateRange", "dateScope"], test: ["dates", "dateRange", "dateScope"],
form: { form: {
name: "el-date-picker", component: {
props: { name: "el-date-picker",
type: "daterange" props: {
type: "daterange",
valueFormat: "YYYY-MM-DD"
}
} }
} }
}, },
@ -93,16 +97,20 @@ export default [
form: { form: {
name: "el-date-picker", name: "el-date-picker",
props: { props: {
type: "datetime" type: "datetime",
valueFormat: "YYYY-MM-DD HH:mm:ss"
} }
} }
}, },
{ {
test: ["times", "timeRange", "timeScope"], test: ["times", "timeRange", "timeScope"],
form: { form: {
name: "el-date-picker", component: {
props: { name: "el-date-picker",
type: "datetimerange" props: {
type: "datetimerange",
valueFormat: "YYYY-MM-DD HH:mm:ss"
}
} }
} }
}, },
@ -157,7 +165,7 @@ export default [
{ {
test: ["rich", "text", "html", "content"], test: ["rich", "text", "html", "content"],
form: { form: {
name: "el-editor-quill", name: "cl-editor-quill",
props: { props: {
height: 400 height: 400
} }
@ -166,7 +174,7 @@ export default [
{ {
test: ["code", "codes"], test: ["code", "codes"],
form: { form: {
name: "el-codemirror", name: "cl-codemirror",
props: { props: {
height: 400 height: 400
} }

View File

@ -20,7 +20,6 @@ function format(data: any) {
// 颜色 // 颜色
const colors = [ const colors = [
"",
"#409EFF", "#409EFF",
"#67C23A", "#67C23A",
"#E6A23C", "#E6A23C",
@ -35,6 +34,9 @@ const colors = [
// 组件处理器 // 组件处理器
const handler = { const handler = {
// 临时变量
d: {},
// 单选 // 单选
dict({ comment }) { dict({ comment }) {
const [label, ...arr] = comment.split(" "); const [label, ...arr] = comment.split(" ");
@ -47,7 +49,7 @@ const handler = {
value: isNaN(Number(value)) ? value : Number(value) value: isNaN(Number(value)) ? value : Number(value)
}; };
if (colors[i]) { if (i > 0 && colors[i]) {
d.color = colors[i]; d.color = colors[i];
} }
@ -192,6 +194,26 @@ function getPageName(router: string) {
return router ? `name: "${router.replace("/", "-")}",` : ""; return router ? `name: "${router.replace("/", "-")}",` : "";
} }
// 时间合并
function datetimeMerge({ columns, item }: any) {
if (["startTime", "startDate"].includes(item.prop)) {
const key = item.prop.replace("start", "");
if (columns.find((e: any) => e.propertyName == "end" + key)) {
item.label = key == "time" ? "时间范围" : "日期访问";
item.prop = key.toLocaleLowerCase();
item.hook = "datetimeRange";
item.component = {
name: "el-date-picker",
props: {
type: key == "time" ? "datetimerange" : "daterange",
valueFormat: "YYYY-MM-DD HH:mm:ss"
}
};
}
}
}
// 创建文件 // 创建文件
function createVue({ router, columns, prefix, api, module, filename }: any): void { function createVue({ router, columns, prefix, api, module, filename }: any): void {
const upsert: any = { const upsert: any = {
@ -212,7 +234,10 @@ function createVue({ router, columns, prefix, api, module, filename }: any): voi
item.required = true; item.required = true;
} }
if (!["createTime", "updateTime", "id"].includes(item.prop)) { // 忽略部分字段
if (!["createTime", "updateTime", "id", "endTime", "endDate"].includes(item.prop)) {
datetimeMerge({ columns, item });
if (!item.component) { if (!item.component) {
item.component = { item.component = {
name: "el-input" name: "el-input"