From bbb43faaa3057b4b83ed43eb15f458926f0bbd9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=94=BF?= <3443290081@qq.com> Date: Fri, 3 Apr 2026 14:23:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 233 ++++++++++-------- src/api/TableInfoController.ts | 14 ++ src/api/types/index.ts | 5 + .../table-vue/StandardDataGrid.vue | 144 +++++++++++ .../custom-components/table-vue/type/index.ts | 75 ++++++ .../table-vue/utils/tableUtils.ts | 118 +++++++++ .../table-vue/utils/useTableSpan.ts | 52 ++++ .../layout/base-panel/imageModel.vue | 7 - .../right-aside/select-item-props-setting.vue | 12 +- src/components/mt-edit/store/types.ts | 1 + .../vue-components/vue-characters.vue | 73 ++++-- .../vue-components/vue-generate-table.vue | 160 ++++++++++++ src/utils/axios.ts | 7 + src/utils/config.ts | 168 +++++++------ src/utils/electricConfig.ts | 99 ++++---- src/views/edit/index.vue | 3 +- 16 files changed, 907 insertions(+), 264 deletions(-) create mode 100644 src/api/TableInfoController.ts create mode 100644 src/api/types/index.ts create mode 100644 src/components/custom-components/table-vue/StandardDataGrid.vue create mode 100644 src/components/custom-components/table-vue/type/index.ts create mode 100644 src/components/custom-components/table-vue/utils/tableUtils.ts create mode 100644 src/components/custom-components/table-vue/utils/useTableSpan.ts create mode 100644 src/components/vue-components/vue-generate-table.vue create mode 100644 src/utils/axios.ts diff --git a/src/App.vue b/src/App.vue index 26211d7..5c936e6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,15 @@ diff --git a/src/api/TableInfoController.ts b/src/api/TableInfoController.ts new file mode 100644 index 0000000..08389dd --- /dev/null +++ b/src/api/TableInfoController.ts @@ -0,0 +1,14 @@ +import axios from '@/utils/axios'; +import type { ApiResponse } from '@/api/types'; +export async function getTableOptionsVOList(options?: { [key: string]: any }) { + return axios>('/tableInfo/get/list', { + method: 'GET', + ...(options || {}) + }); +} +export async function getTableInfoVO(options?: { [key: string]: any }) { + return axios>('/tableInfo/get/vo', { + method: 'GET', + ...(options || {}) + }); +} diff --git a/src/api/types/index.ts b/src/api/types/index.ts new file mode 100644 index 0000000..5ac0686 --- /dev/null +++ b/src/api/types/index.ts @@ -0,0 +1,5 @@ +export interface ApiResponse { + code: number; + message: string; + data: T; +} diff --git a/src/components/custom-components/table-vue/StandardDataGrid.vue b/src/components/custom-components/table-vue/StandardDataGrid.vue new file mode 100644 index 0000000..5773a80 --- /dev/null +++ b/src/components/custom-components/table-vue/StandardDataGrid.vue @@ -0,0 +1,144 @@ + + + + + diff --git a/src/components/custom-components/table-vue/type/index.ts b/src/components/custom-components/table-vue/type/index.ts new file mode 100644 index 0000000..8a6f87f --- /dev/null +++ b/src/components/custom-components/table-vue/type/index.ts @@ -0,0 +1,75 @@ +/** + * 表格列的基本规范 + */ +interface BaseColumn { + // 表头的标题 + title: string; + // 数据源对应的字段名 + key: string; + // 列的宽度 + width?: number | string; + // 单元格的显示位置 + align?: 'left' | 'center' | 'right'; + // 固定列 + fixed?: 'left' | 'right'; + // 最小宽度,适应不同大小的屏幕 + minWidth?: number | string; + // 标记这个列是否需要纵向合并 + mergeRow?: boolean; + // 标记这个列是否需要横向合并 + horizontalMergeRule?: { + matchCondition: { key: string; value: string | boolean }; + mergeKeys: string[]; + renderConfig?: { + type: string; + actions?: ActionButton[]; + }; + }; + // 多级表头 + children?: TableColumnSchema[]; + // 标记合并行时的参考列 + mergeBy?: string; +} +// 纯文本列 +export interface TextColumn extends BaseColumn { + type: 'text'; +} +// 状态列 +export interface StatusColumn extends BaseColumn { + type: 'status'; + dictCode?: string; +} +// 数值列 +export interface NumberColumn extends BaseColumn { + type: 'number'; + // 单位后缀 + unit?: string; +} +// 操作列 +export interface ActionColumn extends BaseColumn { + type: 'action'; + // 操作列包含按钮列表 + actions: ActionButton[]; +} +// 按钮定义的schema +export interface ActionButton { + // 按钮的文字 + label: string; + //抛出给外层的事件名 + actionKey: string; + // 按钮的视觉类型 + btnType?: 'primary' | 'default' | 'dashed' | 'danger' | 'link' | 'text'; + // 根据状态值控制显示 + showOn?: { + key: string; // 依赖哪一列数据 + values: any[]; // 当值等于数组中的哪些项时,才显示按钮 + }; + // 根据状态来控制禁用 + disabledOn?: { + key: string; + values: any[]; + }; + isRound?: boolean; +} +export type TableColumnSchema = TextColumn | StatusColumn | NumberColumn | ActionColumn; +export type DataGridSchema = TableColumnSchema[]; diff --git a/src/components/custom-components/table-vue/utils/tableUtils.ts b/src/components/custom-components/table-vue/utils/tableUtils.ts new file mode 100644 index 0000000..e637910 --- /dev/null +++ b/src/components/custom-components/table-vue/utils/tableUtils.ts @@ -0,0 +1,118 @@ +// 提取叶子节点列,解决多级表头索引对齐问题 +const getLeafColumns = (columns: any[]) => { + let leaves: any[] = []; + columns.forEach((col) => { + if (col.children && col.children.length > 0) { + leaves.push(...getLeafColumns(col.children)); + } else { + leaves.push(col); + } + }); + return leaves; +}; +/** + * + * @param data 表格的数据源 + * @param rowMergeConfigs 纵向合并配置 [{ key: 'xxx', mergeBy: 'yyy' }] + * @param rawColumns 表格列配置 + */ +export const createRowSpanMethod = ( + data: any[], + rawColumns: any[], + rowMergeConfigs: { key: string; mergeBy: string }[] +) => { + // 1. 拍平获取物理叶子列 + const columns = getLeafColumns(rawColumns); + const rowSpanInfos: Record = {}; + rowMergeConfigs.forEach((config) => { + const { key, mergeBy } = config; + rowSpanInfos[key] = []; + let position = 0; + data.forEach((item, index) => { + if (index === 0) { + rowSpanInfos[key].push(1); + position = 0; + } else { + // 如果当前行数据和上一行数据相等,则当前行不显示 + if ( + item[mergeBy] === data[index - 1][mergeBy] && + !item.colMergeConfig && + !data[index - 1].colMergeConfig + ) { + rowSpanInfos[key][position] += 1; + rowSpanInfos[key].push(0); + } else { + rowSpanInfos[key].push(1); + position = index; + } + } + }); + }); + return ({ row, column, rowIndex, columnIndex }: any) => { + // 优先处理横向合并 + const ruleColumn = columns.find( + (col) => + col.horizontalMergeRule && + row[col.horizontalMergeRule.matchCondition.key] === + col.horizontalMergeRule.matchCondition.value + ); + if (ruleColumn) { + const rule = ruleColumn.horizontalMergeRule; + const targetKeys = rule.mergeKeys; + const validIndices = targetKeys + .map((key) => columns.findIndex((item) => item.key === key)) + .filter((index) => index != -1); + + if (validIndices.length > 0) { + const minIndex = Math.min(...validIndices); + const maxIndex = Math.max(...validIndices); + const actualColSpan = maxIndex - minIndex + 1; + if (columnIndex == minIndex) { + return { + rowspan: 1, + colspan: actualColSpan + }; + } + if (columnIndex > minIndex && columnIndex <= maxIndex) { + return { + rowspan: 0, + colspan: 0 + }; + } + } + } + // 再处理纵向合并 + const mergeTarget = rowMergeConfigs.find((c) => c.key === column.property); + if (mergeTarget) { + const rowspan = rowSpanInfos[column.property][rowIndex]; + const colspan = rowspan > 0 ? 1 : 0; + return { rowspan, colspan }; + } + return { rowspan: 1, colspan: 1 }; + }; +}; + +/** + * 通用数组聚合标记函数 + * @param {Array} list - 原始数组 + * @param {String} groupKey - 按照哪个字段进行分组统计 (例如 'deviceName') + * @param {String} flagName - 生成的布尔值标记名称 (例如 'isMultiNode') + */ +export const injectMultiNodeFlag = (list: any[], groupKey: string, flagName: string) => { + const countMap = {} as Record; + // 统计 + list.forEach((item) => { + const val = item[groupKey]; + if (val) countMap[val] = (countMap[val] || 0) + 1; + }); + + // 映射 + return list.map((item) => { + const val = item[groupKey]; + if (!val) return item; // 非目标数据,直接返回 + return { + ...item, + [flagName]: countMap[val] > 1 // 动态注入标记 + }; + }); +}; diff --git a/src/components/custom-components/table-vue/utils/useTableSpan.ts b/src/components/custom-components/table-vue/utils/useTableSpan.ts new file mode 100644 index 0000000..418edef --- /dev/null +++ b/src/components/custom-components/table-vue/utils/useTableSpan.ts @@ -0,0 +1,52 @@ +import { computed, type Ref, unref } from 'vue'; +import { createRowSpanMethod } from '@/components/custom-components/table-vue/utils/tableUtils'; +/** + * 只能表格合并 hook + * @param tableData 表格数据源 + * @param tableColumns 表格列配置 + */ +export function useTableSpan(tableData: Ref, tableColumns: any[] | Ref) { + const flatColumns = computed(() => { + const columns = unref(tableColumns); // 兼容普通对象和ref对象 + const flatten = (cols: any[]): any[] => { + let result: any[] = []; + cols.forEach((col) => { + result.push(col); + if (col.children && col.children.length > 0) { + result.push(...flatten(col.children)); + } + }); + return result; + }; + return flatten(columns); + }); + //自动提取需要纵向合并的列配置 + const rowMergeConfigs = computed(() => { + return flatColumns.value + .filter((col) => col.mergeRow) + .map((col) => { + return { + key: col.key, + mergeBy: col.mergeBy || col.key + }; + }); + }); + // 判断表格需不需要开启合并引擎 + const needSpan = computed(() => { + // 有任何列配置了纵向合并 + const hasRowMerge = rowMergeConfigs.value.length; + // 有任何列配置了横向合并 + const hasColMerge = flatColumns.value.some((col) => !!col.horizontalMergeRule); + return hasRowMerge || hasColMerge; + }); + // 动态返回合并函数 + const spanMethod = computed(() => { + if (!needSpan.value) { + return undefined; + } + return createRowSpanMethod(unref(tableData), unref(tableColumns), rowMergeConfigs.value); + }); + return { + spanMethod + }; +} diff --git a/src/components/mt-edit/components/layout/base-panel/imageModel.vue b/src/components/mt-edit/components/layout/base-panel/imageModel.vue index bda78aa..818bd98 100644 --- a/src/components/mt-edit/components/layout/base-panel/imageModel.vue +++ b/src/components/mt-edit/components/layout/base-panel/imageModel.vue @@ -42,10 +42,6 @@ - - { @@ -287,7 +281,6 @@ async function loadFileList() { startTime: form.fileDate ? new Date(form.fileDate[0]).getTime() : null, endTime: form.fileDate ? new Date(form.fileDate[1]).getTime() : null }; - console.log('endJson:', endJson); const response = await modelApi.fileStorage_file_list_post(endJson); tableData.value = []; if (!response.data) { diff --git a/src/components/mt-edit/components/layout/right-aside/select-item-props-setting.vue b/src/components/mt-edit/components/layout/right-aside/select-item-props-setting.vue index 1b99113..60ac584 100644 --- a/src/components/mt-edit/components/layout/right-aside/select-item-props-setting.vue +++ b/src/components/mt-edit/components/layout/right-aside/select-item-props-setting.vue @@ -15,6 +15,7 @@ :value="item.value" /> + - - {{ attr_item.val }} @@ -275,9 +267,7 @@ function bindingImg(obj: any) { let modelIds = ref([]); function handleEdit(obj: any) { - console.log('绑定', modelIds.value); dialogTableVisible.value = false; - modelIds.value = [obj.modeId]; attrItem.val = obj.modeId; emits('selectById', obj.modeId); } diff --git a/src/components/mt-edit/store/types.ts b/src/components/mt-edit/store/types.ts index 45868ed..90a48c3 100644 --- a/src/components/mt-edit/store/types.ts +++ b/src/components/mt-edit/store/types.ts @@ -11,6 +11,7 @@ export type ILeftAsideConfigItemPublicPropsType = | 'inputSelectId' | 'inputTypeTag' //inputTypeTag 必须和 inputSelectId 一起使用 | 'inputSelectImgId' + | 'tableSelect' | 'map'; //使用这个类型 disabled必须为true(必须隐藏) // 开放注册配置 export type ILeftAsideConfigItemPublicProps = Record< diff --git a/src/components/vue-components/vue-characters.vue b/src/components/vue-components/vue-characters.vue index f2cea8d..635a4e4 100644 --- a/src/components/vue-components/vue-characters.vue +++ b/src/components/vue-components/vue-characters.vue @@ -1,14 +1,26 @@ + + diff --git a/src/utils/axios.ts b/src/utils/axios.ts new file mode 100644 index 0000000..636a7bc --- /dev/null +++ b/src/utils/axios.ts @@ -0,0 +1,7 @@ +import axios from 'axios'; +const myAxios = axios.create({ + baseURL: 'http://localhost:8080', + timeout: 60000, + withCredentials: true +}); +export default myAxios; diff --git a/src/utils/config.ts b/src/utils/config.ts index 010dc07..10d54fe 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -1,58 +1,58 @@ import { dayjs } from 'element-plus'; -interface RecIn{ - Node: { - InTypeIn: [number, string][], - TypeBase: [number, string][], - }, +interface RecIn { + Node: { + InTypeIn: [number, string][]; + TypeBase: [number, string][]; + }; CONST: { STR: { - EnumType: [number, string][] - }, + EnumType: [number, string][]; + }; YX: { - EnumType: [number, string][] - }, - UserPage:[string, string][] - }, - EnumTypeVal: [number, string][][], - EnumTypeValFun: Function[], - regex: any, - trans: (val: any, enumArr: [number, string][])=> string + EnumType: [number, string][]; + }; + UserPage: [string, string][]; + }; + EnumTypeVal: [number, string][][]; + EnumTypeValFun: Function[]; + regex: any; + trans: (val: any, enumArr: [number, string][]) => string; } - -const Rec: Partial={}; -Rec.Node={} as RecIn['Node']; -Rec.CONST={} as RecIn['CONST']; -Rec.trans = (index, type)=> { +export const Rec: Partial = {}; +Rec.Node = {} as RecIn['Node']; +Rec.CONST = {} as RecIn['CONST']; +Rec.CONST.STR = {} as RecIn['CONST']['STR']; +Rec.CONST.YX = {} as RecIn['CONST']['YX']; +Rec.trans = (index, type) => { for (let i = 0; i < type.length; i++) { if (type[i][0] == index) { return type[i][1]; } } - return "*未知*"; + return '*未知*'; }; // 所有输入类型 Rec.Node.InTypeIn = [ [1, '遥信'], [2, '遥测'] ]; -const getIndex=(num:number)=>{ - switch (num) - { - case 1 : - return 100 - case 2 : - return 0 - default: - return -1 - } -} +export const getIndex = (num: number) => { + switch (num) { + case 1: + return 100; + case 2: + return 0; + default: + return -1; + } +}; // 四遥基本类型 Rec.Node.TypeBase = [ [1, '遥信'], [2, '遥测'], [3, '遥控'], - [4, '遥调'], + [4, '遥调'] ]; // 定值转化的 类型 @@ -67,26 +67,35 @@ Rec.CONST.STR.EnumType = [ [14, '国网空调模式'], [21, 'KTC空调'] ]; -Rec.CONST.YX.EnumType=[ +Rec.CONST.YX.EnumType = [ [0, '颜色'], [1, '文字'], - [2, '颜色+文字'], -] - - -Rec.EnumTypeVal = []; // 定值类型,用于编辑时的选择 -Rec.EnumTypeValFun = []; // 转换函数,用于显示与控制 + [2, '颜色+文字'] +]; +Rec.EnumTypeVal = []; // 定值类型,用于编辑时的选择 +Rec.EnumTypeValFun = []; // 转换函数,用于显示与控制 Rec.EnumTypeVal[100] = [ - [0, '绿色'], - [1, '黄色'], - [2, '红色'], + [0, 'green'], + [1, 'yellow'], + [2, 'red'] ]; Rec.EnumTypeVal[101] = [ - [0, '开启'], - [1, '关闭'], - [2, ''], + [0, '正常'], + [1, '异常'], + [2, '故障'], + [3, '报警'], + [4, '运行'], + [5, '关闭'] +]; +Rec.EnumTypeVal[102] = [ + [0, '正常,green'], + [1, '异常,saddlebrown'], + [2, '故障,yellow'], + [3, '报警,red'], + [4, '运行,blue'], + [5, '关闭,purple'] ]; // 缺省 Rec.EnumTypeVal[0] = [ @@ -94,10 +103,10 @@ Rec.EnumTypeVal[0] = [ [1, '开启'] ]; -Rec.EnumTypeValFun[0] = function (val:any,index:number) { - return Rec.trans!(val, Rec.EnumTypeVal![index+0]) -} -//Rec.EnumTypeValFun[0](val,getIndex(btype)); +Rec.EnumTypeValFun[0] = function (val: any, index: number) { + return Rec.trans!(val, Rec.EnumTypeVal![index + 0]); +}; +//Rec.EnumTypeValFun[etype](val,getIndex(btype)); // 遥控 Rec.EnumTypeVal[1] = [ @@ -105,21 +114,21 @@ Rec.EnumTypeVal[1] = [ [1, '开启'] ]; -Rec.EnumTypeValFun[1] = function (val:any,index:number) { - return Rec.trans!(val, Rec.EnumTypeVal![index+1]) -} +Rec.EnumTypeValFun[1] = function (val: any, index: number) { + return Rec.trans!(val, Rec.EnumTypeVal![index + 1]); +}; // 数值 Rec.EnumTypeVal[2] = []; -Rec.EnumTypeValFun[2] = function (val:any,index:number) { - return Rec.trans!(val, Rec.EnumTypeVal![index+2]); -} +Rec.EnumTypeValFun[2] = function (val: any, index: number) { + return Rec.trans!(val, Rec.EnumTypeVal![index + 2]); +}; // timestamp 转换成时间 -Rec.EnumTypeValFun[3] = function (val:any) { +Rec.EnumTypeValFun[3] = function (val: any) { // Ext.Date.format(val * 1000, 'Y-m-d H:i:s') - dayjs.unix(val).format('YYYY-MM-DD HH:mm:ss') -} + dayjs.unix(val).format('YYYY-MM-DD HH:mm:ss'); +}; // 国网空调模式 Rec.EnumTypeVal[14] = [ @@ -130,9 +139,9 @@ Rec.EnumTypeVal[14] = [ [2, '送风'] ]; -Rec.EnumTypeValFun[14] = function (val:any) { - return Rec.trans!(val, Rec.EnumTypeVal![14]) -} +Rec.EnumTypeValFun[14] = function (val: any) { + return Rec.trans!(val, Rec.EnumTypeVal![14]); +}; // RY空调模式 Rec.EnumTypeVal[11] = [ @@ -143,9 +152,9 @@ Rec.EnumTypeVal[11] = [ [4, '送风'] ]; -Rec.EnumTypeValFun[11] = function (val:any) { - return Rec.trans!(val, Rec.EnumTypeVal![11]) -} +Rec.EnumTypeValFun[11] = function (val: any) { + return Rec.trans!(val, Rec.EnumTypeVal![11]); +}; // 空调温度 Rec.EnumTypeVal[12] = [ @@ -166,9 +175,9 @@ Rec.EnumTypeVal[12] = [ [30, '30℃'] ]; -Rec.EnumTypeValFun[12] = function (val:any) { - return Rec.trans!(val, Rec.EnumTypeVal![12]) -} +Rec.EnumTypeValFun[12] = function (val: any) { + return Rec.trans!(val, Rec.EnumTypeVal![12]); +}; // 空调风速 Rec.EnumTypeVal[13] = [ @@ -178,9 +187,9 @@ Rec.EnumTypeVal[13] = [ [3, '高'] ]; -Rec.EnumTypeValFun[13] = function (val:any) { - return Rec.trans!(val, Rec.EnumTypeVal![13]) -} +Rec.EnumTypeValFun[13] = function (val: any) { + return Rec.trans!(val, Rec.EnumTypeVal![13]); +}; // KTC 空调 Rec.EnumTypeVal[21] = [ @@ -189,20 +198,21 @@ Rec.EnumTypeVal[21] = [ [2, '制热'] ]; -Rec.EnumTypeValFun[21] = function (val:any) { - return Rec.trans!(val, Rec.EnumTypeVal![21]) -} +Rec.EnumTypeValFun[21] = function (val: any) { + return Rec.trans!(val, Rec.EnumTypeVal![21]); +}; // -Rec.EnumTypeValFun[21]() +Rec.EnumTypeValFun[21](); // 用户的缺省界面 Rec.CONST.UserPage = [ ['Admin', 'Admin'], - ['User', 'User'], -] + ['User', 'User'] +]; // 正则表达式 Rec.regex = { // Modbus 配置的正则表达式 - modbusCfg: /^(?:25[0-4]|2[0-4]\d|1\d{2}|[1-9]\d|[1-9]):(?:[1-6]|10):(?:6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)(?::[2-9])?$/, + modbusCfg: + /^(?:25[0-4]|2[0-4]\d|1\d{2}|[1-9]\d|[1-9]):(?:[1-6]|10):(?:6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)(?::[2-9])?$/, modbusParm: /^(?:\d+(?::\d+){0,2})?$/ -} \ No newline at end of file +}; diff --git a/src/utils/electricConfig.ts b/src/utils/electricConfig.ts index 655a504..45bf06a 100644 --- a/src/utils/electricConfig.ts +++ b/src/utils/electricConfig.ts @@ -8,83 +8,80 @@ const EnumTypeValFun: ((val: number) => string)[] = []; * @returns {string|*} */ const trans = function (index: number, type: any[]) { - for (let i = 0; i < type.length; i++) { - if (type[i][0] == index) { - return type[i][1]; - } + for (let i = 0; i < type.length; i++) { + if (type[i][0] == index) { + return type[i][1]; } - return "*未知*"; + } + return '*未知*'; }; const EnumType = [ - [0, '缺省'], - [1, '普通开关'], - [2, '数值'], - [3, '时间秒'], - [11, 'RY空调模式'], - [12, '空调温度'], - [13, '空调风速'], - [14, '国网空调模式'], - [21, 'KTC空调'] + [0, '缺省'], + [1, '普通开关'], + [2, '数值'], + [3, '时间秒'], + [11, 'RY空调模式'], + [12, '空调温度'], + [13, '空调风速'], + [14, '国网空调模式'], + [21, 'KTC空调'] ]; // 缺省 EnumTypeVal[0] = [ - [0, '关闭'], - [1, '开启'] + [0, '关闭'], + [1, '开启'] ]; EnumTypeValFun[0] = function (val: number) { - return trans(val, EnumTypeVal[0]) -} + return trans(val, EnumTypeVal[0]); +}; // 遥控 EnumTypeVal[1] = [ - [0, '关闭'], - [1, '开启'] + [0, '关闭'], + [1, '开启'] ]; EnumTypeValFun[1] = function (val) { - return trans(val, EnumTypeVal[1]) -} - + return trans(val, EnumTypeVal[1]); +}; // 数值 EnumTypeVal[2] = []; EnumTypeValFun[2] = function (val) { - return val.toString(); -} + return val.toString(); +}; // timestamp 转换成时间 EnumTypeValFun[3] = function (val) { - return format(val * 1000, 'Y-m-d H:i:s') -} - - + return format(val * 1000, 'Y-m-d H:i:s'); +}; -export {EnumTypeVal,EnumTypeValFun} +export { EnumTypeVal, EnumTypeValFun }; -const format = function(date: Date, format: string) { - var formatFunctions = formatFunctions; +const format = function (date: Date, format: string) { + var formatFunctions = formatFunctions; - if (!Ext.isDate(date)) { - return ''; - } + if (!Ext.isDate(date)) { + return ''; + } - if (formatFunctions[format] == null) { - utilDate.createFormat(format); - } + if (formatFunctions[format] == null) { + utilDate.createFormat(format); + } - return formatFunctions[format].call(date) + ''; - } + return formatFunctions[format].call(date) + ''; +}; const formatFunctions: { [key: string]: () => string } = { - "MS": function() { - // UTC milliseconds since Unix epoch (MS-AJAX serialized date format (MRSF)) - return '\\/Date(' + this.getTime() + ')\\/'; - }, - "time": function() { - return this.getTime().toString(); - }, - "timestamp": function() { - return format(this.getTime(), 'U'); - } - } \ No newline at end of file + MS: function () { + // UTC milliseconds since Unix epoch (MS-AJAX serialized date format (MRSF)) + return '\\/Date(' + this.getTime() + ')\\/'; + }, + time: function () { + return this.getTime().toString(); + }, + timestamp: function () { + return format(this.getTime(), 'U'); + } +}; diff --git a/src/views/edit/index.vue b/src/views/edit/index.vue index 6b10ce9..c7343d7 100644 --- a/src/views/edit/index.vue +++ b/src/views/edit/index.vue @@ -7,7 +7,8 @@ @on-return-click="onReturnClick" @on-save-click="onSaveClick" @on-thumbnail-click="onThumbnailClick" - > + > +