From 2becc703471741dfdf1d7158cf3ccda845aa247c Mon Sep 17 00:00:00 2001 From: 964269669 <964269669@qq.com> Date: Tue, 6 Mar 2018 15:41:55 +0800 Subject: [PATCH] form --- .../haomo/components/forms/HmComplexForm.md | 835 +++++++++--------- .../haomo/components/forms/HmComplexForm.vue | 92 +- src/views/haomo/components/forms/index.vue | 6 +- 3 files changed, 464 insertions(+), 469 deletions(-) diff --git a/src/views/haomo/components/forms/HmComplexForm.md b/src/views/haomo/components/forms/HmComplexForm.md index d7db680..5e1b4bc 100644 --- a/src/views/haomo/components/forms/HmComplexForm.md +++ b/src/views/haomo/components/forms/HmComplexForm.md @@ -1,236 +1,222 @@ ### 基本使用 ```jsx - <hm-complex-form - :schema="{ + <hm-complex-form :columns="[ + { name: 'username', widgetType: 1 }, + { name: 'securityLevel', widgetType: 5 }, + { name: 'type', widgetType: 2, options: ['ä¼ä¸š', '代ç†å•†'] }, + { name: 'avatar', widgetType: 3 }, + { name: 'departmentId', widgetType: 4 }, + { name: 'createTime', widgetType: 6 } + ]" + :schema="{ 'model': 'HmUser', - 'modelPlural': 'HmUserS', - 'modelCamel': 'hmUser', - 'modelCamelPlural': 'hmUserS', - 'modelUnderscore': 'hm_user', - 'modelUnderscorePlural': 'hm_userS', - 'columns': [ - { - 'id': 'o50', - 'objectId': '170A4473-36CC-47E1-96C3-F238F8132AA4', - 'name': '用户åå—', - 'code': 'USERNAME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1517859502', - 'modifier': 'hm20160509', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'codeCamel': 'username', - 'codeCamelPlural': 'usernames', - 'codeUnderscore': 'username', - 'codeUnderscorePlural': 'usernames', - 'type': 'string' - }, - { - 'id': 'o51', - 'objectId': '70EC38C6-4AE4-4E79-BA72-29DA2FE50782', - 'name': '登录ID', - 'code': 'LOGINID', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'columnMandatory': '1', - 'codeCamel': 'loginid', - 'codeCamelPlural': 'loginids', - 'codeUnderscore': 'loginid', - 'codeUnderscorePlural': 'loginids', - 'type': 'string' - }, - { - 'id': 'o52', - 'objectId': '4FCE7185-D489-4DED-AA5F-093A4DBC1112', - 'name': '密ç ', - 'code': 'PASSWORD', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'codeCamel': 'password', - 'codeCamelPlural': 'passwords', - 'codeUnderscore': 'password', - 'codeUnderscorePlural': 'passwords', - 'type': 'string' - }, - { - 'id': 'o53', - 'objectId': '3A897125-CB02-40F5-9BB1-62A9B06553E0', - 'name': 'è”系电è¯', - 'code': 'MOBILE', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(16CHAR)', - 'length': '16', - 'codeCamel': 'mobile', - 'codeCamelPlural': 'mobiles', - 'codeUnderscore': 'mobile', - 'codeUnderscorePlural': 'mobiles', - 'type': 'string' - }, - { - 'id': 'o54', - 'objectId': '48B9C079-3CCA-4886-9543-3AE764998E9A', - 'name': '邮箱', - 'code': 'EMAIL', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'codeCamel': 'email', - 'codeCamelPlural': 'emails', - 'codeUnderscore': 'email', - 'codeUnderscorePlural': 'emails', - 'type': 'string' - }, - { - 'id': 'o55', - 'objectId': '533AB6E8-A3D0-473D-9DE6-0D0CABA6731C', - 'name': '头åƒ', - 'code': 'AVATAR', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(1024CHAR)', - 'length': '1024', - 'codeCamel': 'avatar', - 'codeCamelPlural': 'avatars', - 'codeUnderscore': 'avatar', - 'codeUnderscorePlural': 'avatars', - 'type': 'string', - 'widgetType': 'checkbox' - }, - { - 'id': 'o56', - 'objectId': 'EF44AF1F-F6B9-412F-9FF7-AAECD6B5521A', - 'name': '创建时间', - 'code': 'CREATE_TIME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'DATE', - 'codeCamel': 'createTime', - 'codeCamelPlural': 'createTimes', - 'codeUnderscore': 'create_time', - 'codeUnderscorePlural': 'create_times', - 'type': 'datetime' - }, - { - 'id': 'o57', - 'objectId': 'CD1BC772-356B-4D14-A40E-28F115F95EEC', - 'name': 'æ›´æ–°æ—¶é—´', - 'code': 'LAST_UPDATE_TIME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'DATE', - 'codeCamel': 'lastUpdateTime', - 'codeCamelPlural': 'lastUpdateTimes', - 'codeUnderscore': 'last_update_time', - 'codeUnderscorePlural': 'last_update_times', - 'type': 'datetime' - }, - { - 'id': 'o58', - 'objectId': '297D03AE-459D-4991-A459-3449FE893EEB', - 'name': '最åŽç™»å½•æ—¶é—´', - 'code': 'LAST_LOGIN_TIME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'DATE', - 'codeCamel': 'lastLoginTime', - 'codeCamelPlural': 'lastLoginTimes', - 'codeUnderscore': 'last_login_time', - 'codeUnderscorePlural': 'last_login_times', - 'type': 'datetime' - }, - { - 'id': 'o59', - 'objectId': '6767F0FE-6C49-46F3-919E-D854C21FCA52', - 'name': '安全级别', - 'code': 'SECURITY_LEVEL', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'NUMBER(11,0)', - 'length': '11', - 'codeCamel': 'securityLevel', - 'codeCamelPlural': 'securityLevels', - 'codeUnderscore': 'security_level', - 'codeUnderscorePlural': 'security_levels', - 'type': 'number', - 'widgetType': 'richText' - }, - { - 'id': 'o60', - 'objectId': 'C4BF570D-C8FC-4B72-919C-78DB3D790171', - 'name': '类型', - 'code': 'TYPE', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'comment': '1:ä¼ä¸šï¼Œ2:代ç†å•†', - 'dataType': 'NUMBER(11,0)', - 'length': '11', - 'codeCamel': 'type', - 'codeCamelPlural': 'types', - 'codeUnderscore': 'type', - 'codeUnderscorePlural': 'types', - 'type': 'number', - 'widgetType': 'selectType' - }, - { - 'id': 'o340', - 'objectId': 'B5BCB5C5-192F-4BD0-8215-BB65A8288168', - 'name': '部门id', - 'code': 'department_id', - 'creationDate': '1503476586', - 'creator': 'yide', - 'modificationDate': '1517186153', - 'modifier': 'yide', - 'dataType': 'varchar(128)', - 'length': '128', - 'codeCamel': 'departmentId', - 'codeCamelPlural': 'departmentIds', - 'codeUnderscore': 'department_id', - 'codeUnderscorePlural': 'department_ids', - 'type': 'string', - 'widgetType': 'textarea' - } - ] -}"></hm-complex-form> + 'modelPlural': 'HmUsers', + 'modelCamel': 'hmUser', + 'modelCamelPlural': 'hmUsers', + 'modelUnderscore': 'hm_user', + 'modelUnderscorePlural': 'hm_users', + 'columns': [ + { + 'id': 'o50', + 'objectId': '170A4473-36CC-47E1-96C3-F238F8132AA4', + 'name': '用户åå—', + 'code': 'USERNAME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1517859502', + 'modifier': 'hm20160509', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'codeCamel': 'username', + 'codeCamelPlural': 'usernames', + 'codeUnderscore': 'username', + 'codeUnderscorePlural': 'usernames', + 'type': 'string' + }, + { + 'id': 'o51', + 'objectId': '70EC38C6-4AE4-4E79-BA72-29DA2FE50782', + 'name': '登录ID', + 'code': 'LOGINID', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'columnMandatory': '1', + 'codeCamel': 'loginid', + 'codeCamelPlural': 'loginids', + 'codeUnderscore': 'loginid', + 'codeUnderscorePlural': 'loginids', + 'type': 'string' + }, + { + 'id': 'o52', + 'objectId': '4FCE7185-D489-4DED-AA5F-093A4DBC1112', + 'name': '密ç ', + 'code': 'PASSWORD', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'codeCamel': 'password', + 'codeCamelPlural': 'passwords', + 'codeUnderscore': 'password', + 'codeUnderscorePlural': 'passwords', + 'type': 'string' + }, + { + 'id': 'o53', + 'objectId': '3A897125-CB02-40F5-9BB1-62A9B06553E0', + 'name': 'è”系电è¯', + 'code': 'MOBILE', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(16CHAR)', + 'length': '16', + 'codeCamel': 'mobile', + 'codeCamelPlural': 'mobiles', + 'codeUnderscore': 'mobile', + 'codeUnderscorePlural': 'mobiles', + 'type': 'string' + }, + { + 'id': 'o54', + 'objectId': '48B9C079-3CCA-4886-9543-3AE764998E9A', + 'name': '邮箱', + 'code': 'EMAIL', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'codeCamel': 'email', + 'codeCamelPlural': 'emails', + 'codeUnderscore': 'email', + 'codeUnderscorePlural': 'emails', + 'type': 'string' + }, + { + 'id': 'o55', + 'objectId': '533AB6E8-A3D0-473D-9DE6-0D0CABA6731C', + 'name': '头åƒ', + 'code': 'AVATAR', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(1024CHAR)', + 'length': '1024', + 'codeCamel': 'avatar', + 'codeCamelPlural': 'avatars', + 'codeUnderscore': 'avatar', + 'codeUnderscorePlural': 'avatars', + 'type': 'string' + }, + { + 'id': 'o56', + 'objectId': 'EF44AF1F-F6B9-412F-9FF7-AAECD6B5521A', + 'name': '创建时间', + 'code': 'CREATE_TIME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'DATE', + 'codeCamel': 'createTime', + 'codeCamelPlural': 'createTimes', + 'codeUnderscore': 'create_time', + 'codeUnderscorePlural': 'create_times', + 'type': 'datetime' + }, + { + 'id': 'o57', + 'objectId': 'CD1BC772-356B-4D14-A40E-28F115F95EEC', + 'name': 'æ›´æ–°æ—¶é—´', + 'code': 'LAST_UPDATE_TIME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'DATE', + 'codeCamel': 'lastUpdateTime', + 'codeCamelPlural': 'lastUpdateTimes', + 'codeUnderscore': 'last_update_time', + 'codeUnderscorePlural': 'last_update_times', + 'type': 'datetime' + }, + { + 'id': 'o58', + 'objectId': '297D03AE-459D-4991-A459-3449FE893EEB', + 'name': '最åŽç™»å½•æ—¶é—´', + 'code': 'LAST_LOGIN_TIME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'DATE', + 'codeCamel': 'lastLoginTime', + 'codeCamelPlural': 'lastLoginTimes', + 'codeUnderscore': 'last_login_time', + 'codeUnderscorePlural': 'last_login_times', + 'type': 'datetime' + }, + { + 'id': 'o59', + 'objectId': '6767F0FE-6C49-46F3-919E-D854C21FCA52', + 'name': '安全级别', + 'code': 'SECURITY_LEVEL', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'NUMBER(11,0)', + 'length': '11', + 'codeCamel': 'securityLevel', + 'codeCamelPlural': 'securityLevels', + 'codeUnderscore': 'security_level', + 'codeUnderscorePlural': 'security_levels', + 'type': 'number' + }, + { + 'id': 'o60', + 'objectId': 'C4BF570D-C8FC-4B72-919C-78DB3D790171', + 'name': '类型', + 'code': 'TYPE', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'comment': '1:ä¼ä¸šï¼Œ2:代ç†å•†', + 'dataType': 'NUMBER(11,0)', + 'length': '11', + 'codeCamel': 'type', + 'codeCamelPlural': 'types', + 'codeUnderscore': 'type', + 'codeUnderscorePlural': 'types', + 'type': 'number' + } + ] + }"></hm-complex-form> ``` -### 指定显示的表å•类型 + +### 指定显示的表å•ç±»åž‹åŠæŒ‰é’® ```vue <template> - <div> - <hm-complex-form + <hm-complex-form :schema="schema['HmUser']" + :columns="showUserColumns" :tableId="tableId" - :schema="schema['HmUser']" - :columns="showUserColumns"> + :buttons="showUserButtons"> + </hm-complex-form> - </div> </template> <script> @@ -239,207 +225,206 @@ data() { return { schema: { - 'HmUser': { - 'model': 'HmUser', - 'modelPlural': 'HmUsers', - 'modelCamel': 'hmUser', - 'modelCamelPlural': 'hmUsers', - 'modelUnderscore': 'hm_user', - 'modelUnderscorePlural': 'hm_users', - 'columns': [ - { - 'id': 'o50', - 'objectId': '170A4473-36CC-47E1-96C3-F238F8132AA4', - 'name': '用户åå—', - 'code': 'USERNAME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1517859502', - 'modifier': 'hm20160509', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'codeCamel': 'username', - 'codeCamelPlural': 'usernames', - 'codeUnderscore': 'username', - 'codeUnderscorePlural': 'usernames', - 'type': 'string' - }, - { - 'id': 'o51', - 'objectId': '70EC38C6-4AE4-4E79-BA72-29DA2FE50782', - 'name': '登录ID', - 'code': 'LOGINID', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'columnMandatory': '1', - 'codeCamel': 'loginid', - 'codeCamelPlural': 'loginids', - 'codeUnderscore': 'loginid', - 'codeUnderscorePlural': 'loginids', - 'type': 'string' - }, - { - 'id': 'o52', - 'objectId': '4FCE7185-D489-4DED-AA5F-093A4DBC1112', - 'name': '密ç ', - 'code': 'PASSWORD', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'codeCamel': 'password', - 'codeCamelPlural': 'passwords', - 'codeUnderscore': 'password', - 'codeUnderscorePlural': 'passwords', - 'type': 'string' - }, - { - 'id': 'o53', - 'objectId': '3A897125-CB02-40F5-9BB1-62A9B06553E0', - 'name': 'è”系电è¯', - 'code': 'MOBILE', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(16CHAR)', - 'length': '16', - 'codeCamel': 'mobile', - 'codeCamelPlural': 'mobiles', - 'codeUnderscore': 'mobile', - 'codeUnderscorePlural': 'mobiles', - 'type': 'string' - }, - { - 'id': 'o54', - 'objectId': '48B9C079-3CCA-4886-9543-3AE764998E9A', - 'name': '邮箱', - 'code': 'EMAIL', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(256CHAR)', - 'length': '256', - 'codeCamel': 'email', - 'codeCamelPlural': 'emails', - 'codeUnderscore': 'email', - 'codeUnderscorePlural': 'emails', - 'type': 'string' - }, - { - 'id': 'o55', - 'objectId': '533AB6E8-A3D0-473D-9DE6-0D0CABA6731C', - 'name': '头åƒ', - 'code': 'AVATAR', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'VARCHAR2(1024CHAR)', - 'length': '1024', - 'codeCamel': 'avatar', - 'codeCamelPlural': 'avatars', - 'codeUnderscore': 'avatar', - 'codeUnderscorePlural': 'avatars', - 'type': 'string', - 'widgetType': 'checkbox' - }, - { - 'id': 'o56', - 'objectId': 'EF44AF1F-F6B9-412F-9FF7-AAECD6B5521A', - 'name': '创建时间', - 'code': 'CREATE_TIME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'DATE', - 'codeCamel': 'createTime', - 'codeCamelPlural': 'createTimes', - 'codeUnderscore': 'create_time', - 'codeUnderscorePlural': 'create_times', - 'type': 'datetime' - }, - { - 'id': 'o57', - 'objectId': 'CD1BC772-356B-4D14-A40E-28F115F95EEC', - 'name': 'æ›´æ–°æ—¶é—´', - 'code': 'LAST_UPDATE_TIME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'DATE', - 'codeCamel': 'lastUpdateTime', - 'codeCamelPlural': 'lastUpdateTimes', - 'codeUnderscore': 'last_update_time', - 'codeUnderscorePlural': 'last_update_times', - 'type': 'datetime' - }, - { - 'id': 'o58', - 'objectId': '297D03AE-459D-4991-A459-3449FE893EEB', - 'name': '最åŽç™»å½•æ—¶é—´', - 'code': 'LAST_LOGIN_TIME', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'DATE', - 'codeCamel': 'lastLoginTime', - 'codeCamelPlural': 'lastLoginTimes', - 'codeUnderscore': 'last_login_time', - 'codeUnderscorePlural': 'last_login_times', - 'type': 'datetime' - }, - { - 'id': 'o59', - 'objectId': '6767F0FE-6C49-46F3-919E-D854C21FCA52', - 'name': '安全级别', - 'code': 'SECURITY_LEVEL', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'dataType': 'NUMBER(11,0)', - 'length': '11', - 'codeCamel': 'securityLevel', - 'codeCamelPlural': 'securityLevels', - 'codeUnderscore': 'security_level', - 'codeUnderscorePlural': 'security_levels', - 'type': 'number', - 'widgetType': 'richText' - }, - { - 'id': 'o60', - 'objectId': 'C4BF570D-C8FC-4B72-919C-78DB3D790171', - 'name': '类型', - 'code': 'TYPE', - 'creationDate': '1498990741', - 'creator': 'hm20160509', - 'modificationDate': '1498995491', - 'modifier': 'xjq', - 'comment': '1:ä¼ä¸šï¼Œ2:代ç†å•†', - 'dataType': 'NUMBER(11,0)', - 'length': '11', - 'codeCamel': 'type', - 'codeCamelPlural': 'types', - 'codeUnderscore': 'type', - 'codeUnderscorePlural': 'types', - 'type': 'number', - 'widgetType': 'selectType' - } - ] - } - }, - showUserColumns: ['username', 'loginid', 'password', 'mobile', 'email'] + 'HmUser': { + 'model': 'HmUser', + 'modelPlural': 'HmUsers', + 'modelCamel': 'hmUser', + 'modelCamelPlural': 'hmUsers', + 'modelUnderscore': 'hm_user', + 'modelUnderscorePlural': 'hm_users', + 'columns': [ + { + 'id': 'o50', + 'objectId': '170A4473-36CC-47E1-96C3-F238F8132AA4', + 'name': '用户åå—', + 'code': 'USERNAME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1517859502', + 'modifier': 'hm20160509', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'codeCamel': 'username', + 'codeCamelPlural': 'usernames', + 'codeUnderscore': 'username', + 'codeUnderscorePlural': 'usernames', + 'type': 'string' + }, + { + 'id': 'o51', + 'objectId': '70EC38C6-4AE4-4E79-BA72-29DA2FE50782', + 'name': '登录ID', + 'code': 'LOGINID', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'columnMandatory': '1', + 'codeCamel': 'loginid', + 'codeCamelPlural': 'loginids', + 'codeUnderscore': 'loginid', + 'codeUnderscorePlural': 'loginids', + 'type': 'string' + }, + { + 'id': 'o52', + 'objectId': '4FCE7185-D489-4DED-AA5F-093A4DBC1112', + 'name': '密ç ', + 'code': 'PASSWORD', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'codeCamel': 'password', + 'codeCamelPlural': 'passwords', + 'codeUnderscore': 'password', + 'codeUnderscorePlural': 'passwords', + 'type': 'string' + }, + { + 'id': 'o53', + 'objectId': '3A897125-CB02-40F5-9BB1-62A9B06553E0', + 'name': 'è”系电è¯', + 'code': 'MOBILE', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(16CHAR)', + 'length': '16', + 'codeCamel': 'mobile', + 'codeCamelPlural': 'mobiles', + 'codeUnderscore': 'mobile', + 'codeUnderscorePlural': 'mobiles', + 'type': 'string' + }, + { + 'id': 'o54', + 'objectId': '48B9C079-3CCA-4886-9543-3AE764998E9A', + 'name': '邮箱', + 'code': 'EMAIL', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(256CHAR)', + 'length': '256', + 'codeCamel': 'email', + 'codeCamelPlural': 'emails', + 'codeUnderscore': 'email', + 'codeUnderscorePlural': 'emails', + 'type': 'string' + }, + { + 'id': 'o55', + 'objectId': '533AB6E8-A3D0-473D-9DE6-0D0CABA6731C', + 'name': '头åƒ', + 'code': 'AVATAR', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'VARCHAR2(1024CHAR)', + 'length': '1024', + 'codeCamel': 'avatar', + 'codeCamelPlural': 'avatars', + 'codeUnderscore': 'avatar', + 'codeUnderscorePlural': 'avatars', + 'type': 'string' + }, + { + 'id': 'o56', + 'objectId': 'EF44AF1F-F6B9-412F-9FF7-AAECD6B5521A', + 'name': '创建时间', + 'code': 'CREATE_TIME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'DATE', + 'codeCamel': 'createTime', + 'codeCamelPlural': 'createTimes', + 'codeUnderscore': 'create_time', + 'codeUnderscorePlural': 'create_times', + 'type': 'datetime' + }, + { + 'id': 'o57', + 'objectId': 'CD1BC772-356B-4D14-A40E-28F115F95EEC', + 'name': 'æ›´æ–°æ—¶é—´', + 'code': 'LAST_UPDATE_TIME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'DATE', + 'codeCamel': 'lastUpdateTime', + 'codeCamelPlural': 'lastUpdateTimes', + 'codeUnderscore': 'last_update_time', + 'codeUnderscorePlural': 'last_update_times', + 'type': 'datetime' + }, + { + 'id': 'o58', + 'objectId': '297D03AE-459D-4991-A459-3449FE893EEB', + 'name': '最åŽç™»å½•æ—¶é—´', + 'code': 'LAST_LOGIN_TIME', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'DATE', + 'codeCamel': 'lastLoginTime', + 'codeCamelPlural': 'lastLoginTimes', + 'codeUnderscore': 'last_login_time', + 'codeUnderscorePlural': 'last_login_times', + 'type': 'datetime' + }, + { + 'id': 'o59', + 'objectId': '6767F0FE-6C49-46F3-919E-D854C21FCA52', + 'name': '安全级别', + 'code': 'SECURITY_LEVEL', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'dataType': 'NUMBER(11,0)', + 'length': '11', + 'codeCamel': 'securityLevel', + 'codeCamelPlural': 'securityLevels', + 'codeUnderscore': 'security_level', + 'codeUnderscorePlural': 'security_levels', + 'type': 'number' + }, + { + 'id': 'o60', + 'objectId': 'C4BF570D-C8FC-4B72-919C-78DB3D790171', + 'name': '类型', + 'code': 'TYPE', + 'creationDate': '1498990741', + 'creator': 'hm20160509', + 'modificationDate': '1498995491', + 'modifier': 'xjq', + 'comment': '1:ä¼ä¸šï¼Œ2:代ç†å•†', + 'dataType': 'NUMBER(11,0)', + 'length': '11', + 'codeCamel': 'type', + 'codeCamelPlural': 'types', + 'codeUnderscore': 'type', + 'codeUnderscorePlural': 'types', + 'type': 'number' + } + ] + } + }, + showUserColumns: [{ name: 'username', widgetType: 1 }, { name: 'securityLevel', widgetType: 5 }, { name: 'type', widgetType: 2, options: ['ä¼ä¸š', '代ç†å•†'] }, { name: 'avatar', widgetType: 3 }, { name: 'departmentId', widgetType: 4 }, { name: 'createTime', widgetType: 6 }], + // è¦æ˜¾ç¤ºæŒ‰é’® æš‚åªæ”¯æŒç¡®å®šã€ä¿å˜ã€å–æ¶ˆã€æäº¤ã€é‡ç½® + showUserButtons: ['确定', 'å–æ¶ˆ'] } }, created() { @@ -448,4 +433,6 @@ } } </script> + + ``` \ No newline at end of file diff --git a/src/views/haomo/components/forms/HmComplexForm.vue b/src/views/haomo/components/forms/HmComplexForm.vue index a5b3c2f..ef59c32 100644 --- a/src/views/haomo/components/forms/HmComplexForm.vue +++ b/src/views/haomo/components/forms/HmComplexForm.vue @@ -8,21 +8,14 @@ <!--表å•部分--> <el-form ref="form" :model="formModel" :rules="rules" label-width="110px" style="width:80%;margin:0 auto"> - <el-form-item v-for="(column,index) in showUserColumns" :key="index" :label="column.name" :prop="column.codeCamel"> + <el-form-item v-for="(column,index) in showUserColumns" :key="column.id" :label="column.name" :prop="column.codeCamel"> <!--el-input<el-input v-if="column.codeCamel==='password'" type="password" v-model="formModel[column.codeCamel]"></el-input>--> - <!-- 富文本 --> - <quill-editor v-if="column.widgetType === 5" - ref="textEditor" - v-model="formModel[column.codeCamel]" - :options="editorOption" - @blur="onEditorBlur($event)" - @focus="onEditorFocus($event)" - @ready="onEditorReady($event)"> - </quill-editor> - <!-- 日期选择 --> - <el-date-picker v-else-if="column.type === 'datetime' || column.type === 'date'" + <!-- 1 普通input --> + <el-input v-if="column.widgetType === 1" v-model="formModel[column.codeCamel]"></el-input> + <!-- 2 日期选择 --> + <el-date-picker v-else-if="column.widgetType === 6 || column.type === 'datetime' || column.type === 'date'" v-model="formModel[column.codeCamel]" type="datetime" align="right" @@ -30,31 +23,36 @@ value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions"> </el-date-picker> - <!-- 下拉框 --> - <el-select v-else-if="column.widgetType === 2" v-model="formModel[column.codeCamel]"> - <el-option v-for="item in selectOptions" - :key="item.value" - :label="item.label" - :value="item.value"> + <!-- 3 下拉框 --> + <el-select v-else-if="column.widgetType === 2" v-model="formModel[column.codeCamel]" @change="selectChange(formModel[column.codeCamel])"> + <el-option v-for="(item,key) in column.options" + :key="key" + :label="item" + :value="key"> </el-option> </el-select> - <!-- 文本域 --> + <!-- 4 文本域 --> <el-input v-else-if="column.widgetType === 4" v-model="formModel[column.codeCamel]" type="textarea" :autosize="{ minRows: 2, maxRows: 5}" :rows="2"> </el-input> - <!-- å¤é€‰æ¡† --> + <!-- 5 å¤é€‰æ¡† --> <el-checkbox v-else-if="column.widgetType === 3" v-model="formModel[column.codeCamel]"></el-checkbox> - <!-- 普通input --> - <el-input v-else v-model="formModel[column.codeCamel]"></el-input> + <!-- 6 富文本 --> + <quill-editor v-else-if="column.widgetType === 5" + ref="textEditor" + v-model="formModel[column.codeCamel]" + :options="editorOption" + @blur="onEditorBlur($event)" + @focus="onEditorFocus($event)" + @ready="onEditorReady($event)"> + </quill-editor> </el-form-item> - <el-form-item> - <el-col :span="12"> - <el-button type="primary" @click="onSubmit()">确定</el-button> - </el-col> - <el-col :span="12"> - <el-button @click="resetForm()">é‡ç½®</el-button> + <el-form-item v-if="buttons.length"> + <el-col :span="12" v-for="(btn,key) in buttons" :key="key"> + <el-button v-if="btn === '确定' || btn === 'æäº¤'" type="primary" @click="onSubmit()">{{btn}}</el-button> + <el-button v-if="btn === 'å–æ¶ˆ' || btn === 'é‡ç½®'" type="primary" @click="resetForm()">{{btn}}</el-button> </el-col> </el-form-item> </el-form> @@ -69,7 +67,6 @@ <script> import _ from 'lodash' import request from '@/utils/request' - // import { parseTime } from '@/utils/index' /** * 毫末科技的表å•组件. @@ -82,7 +79,8 @@ // 集æˆå…¶ä»–组件 extends: {}, // 使用其它组件 - components: {}, + components: { + }, // 混入公共对象 mixins: [], props: { @@ -95,11 +93,18 @@ required: true }, /** - * æŒ‡å®šè¦æ˜¾ç¤ºçš„表å•å—æ®µåŠç±»åž‹ã€‚é»˜è®¤ä¸ºæ ¹æ®schemaå¾—åˆ°çš„æ‰€æœ‰å—æ®µã€‚ + * æŒ‡å®šè¦æ˜¾ç¤ºçš„表å•å—æ®µåŠç±»åž‹ï¼Œå¿…ä¼ ã€‚æ•°ç»„çš„æ¯ä¸ªå…ƒç´ 须有nameå’ŒwidgetTypeä¸¤ä¸ªå—æ®µï¼Œnameè¡¨ç¤ºè¦æ˜¾ç¤ºçš„表å•å—æ®µï¼ŒwidgetTypeè¡¨ç¤ºè¯¥å—æ®µè¦æ˜¾ç¤ºçš„表å•类型(æ™®é€šè¾“å…¥æ¡†ã€æ–‡æœ¬åŸŸã€å¯Œæ–‡æœ¬ã€ä¸‹æ‹‰æ¡†...),å–值1-6(1表示普通输入框,2表示下拉框,3表示å¤é€‰æ¡†,4表示文本域,5表示富文本,6è¡¨ç¤ºæ—¥æœŸæ ¼å¼),若表å•ç±»åž‹ä¸ºä¸‹æ‹‰æ¡†ï¼Œè¿˜éœ€ä¼ å…¥optionså—æ®µï¼Œå€¼ä¸ºæ•°ç»„(æ•°ç»„å…ƒç´ æ˜¯ä¸‹æ‹‰æ¡†çš„é€‰é¡¹) + * 示例:[ + * { name: 'username', widgetType: 1 }, + * { name: 'securityLevel', widgetType: 5 }, + * { name: 'type', widgetType: 2, options: ['ä¼ä¸š', '代ç†å•†'] }, + * { name: 'avatar', widgetType: 3 }, { name: 'departmentId', widgetType: 4 }, + * { name: 'createTime', widgetType: 6 } + * ] */ columns: { type: Array, - required: false, + required: true, validator: function(value) { if (typeof value !== 'object') { console.warn(`ä¼ å…¥çš„columnsä¸ç¬¦åˆè¦æ±‚,必须是数组`) @@ -109,6 +114,13 @@ return true } }, + /** + * æŒ‡å®šè¦æ˜¾ç¤ºçš„æŒ‰é’®(确定ã€å–消ã€é‡ç½®)ã€‚é»˜è®¤ä¸æ˜¾ç¤ºã€‚ + */ + buttons: { + type: Array, + required: false + }, /** * ä¼ å…¥ç”¨æˆ·çš„id用æ¥ä¿®æ”¹ç”¨æˆ·ä¿¡æ¯ */ @@ -152,7 +164,6 @@ // } // } return { - requestUrl: '', form: null, formModel: {}, // åŒå‘绑定的数æ®å˜é‡ showUserColumns: [], // è¦æ˜¾ç¤ºçš„å—æ®µ @@ -213,24 +224,19 @@ picker.$emit('pick', date) } }] - }, - selectOptions: [{ - value: '1', - label: 'ä¼ä¸š' - }, { - value: '2', - label: '代ç†å•†' - }] + } } }, created() { // this.validate() this.init() - // console.log(this.schema) + console.log(this.buttons) }, methods: { + selectChange(v) { + console.log(v) + }, logTimeChange(value) { - // value = parseTime(value) console.log(value) }, validate() { diff --git a/src/views/haomo/components/forms/index.vue b/src/views/haomo/components/forms/index.vue index 963372a..a0427e3 100644 --- a/src/views/haomo/components/forms/index.vue +++ b/src/views/haomo/components/forms/index.vue @@ -1,6 +1,6 @@ <template> <div> - <hm-complex-form :schema="schema['HmUser2']" :columns="showUserColumns" :tableId="tableId"> + <hm-complex-form :schema="schema['HmUser2']" :columns="showUserColumns" :buttons="showUserButtons" :tableId="tableId"> </hm-complex-form> </div> </template> @@ -21,7 +21,9 @@ return { // showUserColumns: ['username', 'loginid', 'password', 'mobile', 'email', 'createTime'] // widgetType值 1:普通input 2:下拉框 (如果是下拉框 å†ä¼ 一个options表示下拉框选项)3:å¤é€‰æ¡† 4:文本域 5:富文本 6:日期 - showUserColumns: [{ name: 'username', widgetType: 1 }, { name: 'securityLevel', widgetType: 5 }, { name: 'type', widgetType: 2, options: ['ä¼ä¸š', '代ç†å•†'] }, { name: 'avatar', widgetType: 3 }, { name: 'departmentId', widgetType: 4 }, { name: 'createTime', widgetType: 6 }] + showUserColumns: [{ name: 'username', widgetType: 1 }, { name: 'securityLevel', widgetType: 5 }, { name: 'type', widgetType: 2, options: ['ä¼ä¸š', '代ç†å•†'] }, { name: 'avatar', widgetType: 3 }, { name: 'departmentId', widgetType: 4 }, { name: 'createTime', widgetType: 6 }], + // è¦æ˜¾ç¤ºæŒ‰é’® æš‚åªæ”¯æŒç¡®å®šã€ä¿å˜ã€å–æ¶ˆã€æäº¤ã€é‡ç½® + showUserButtons: ['确定', 'å–æ¶ˆ'] } }, computed: { -- 2.21.0