From 4b9a43b55f196b5bf9b902e08ab710f33972eb0e Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Mon, 6 Dec 2021 15:00:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4=E5=90=88?= =?UTF-8?q?=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/config/rules.ts | 28 ++++++++++++++++++---------- build/plugins/cool.ts | 31 ++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/build/config/rules.ts b/build/config/rules.ts index 2b67341..b65df7a 100644 --- a/build/config/rules.ts +++ b/build/config/rules.ts @@ -75,16 +75,20 @@ export default [ form: { name: "el-date-picker", props: { - type: "date" + type: "date", + valueFormat: "YYYY-MM-DD" } } }, { test: ["dates", "dateRange", "dateScope"], form: { - name: "el-date-picker", - props: { - type: "daterange" + component: { + name: "el-date-picker", + props: { + type: "daterange", + valueFormat: "YYYY-MM-DD" + } } } }, @@ -93,16 +97,20 @@ export default [ form: { name: "el-date-picker", props: { - type: "datetime" + type: "datetime", + valueFormat: "YYYY-MM-DD HH:mm:ss" } } }, { test: ["times", "timeRange", "timeScope"], form: { - name: "el-date-picker", - props: { - type: "datetimerange" + component: { + name: "el-date-picker", + props: { + type: "datetimerange", + valueFormat: "YYYY-MM-DD HH:mm:ss" + } } } }, @@ -157,7 +165,7 @@ export default [ { test: ["rich", "text", "html", "content"], form: { - name: "el-editor-quill", + name: "cl-editor-quill", props: { height: 400 } @@ -166,7 +174,7 @@ export default [ { test: ["code", "codes"], form: { - name: "el-codemirror", + name: "cl-codemirror", props: { height: 400 } diff --git a/build/plugins/cool.ts b/build/plugins/cool.ts index 0ca439c..c3c0acf 100644 --- a/build/plugins/cool.ts +++ b/build/plugins/cool.ts @@ -20,7 +20,6 @@ function format(data: any) { // 颜色 const colors = [ - "", "#409EFF", "#67C23A", "#E6A23C", @@ -35,6 +34,9 @@ const colors = [ // 组件处理器 const handler = { + // 临时变量 + d: {}, + // 单选 dict({ comment }) { const [label, ...arr] = comment.split(" "); @@ -47,7 +49,7 @@ const handler = { value: isNaN(Number(value)) ? value : Number(value) }; - if (colors[i]) { + if (i > 0 && colors[i]) { d.color = colors[i]; } @@ -192,6 +194,26 @@ function getPageName(router: string) { 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 { const upsert: any = { @@ -212,7 +234,10 @@ function createVue({ router, columns, prefix, api, module, filename }: any): voi 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) { item.component = { name: "el-input"