Commit 501d8e99 authored by 王康's avatar 王康

form

parent ddd166b4
<template> <template>
<!--:refers="judgeRefers"-->
<div> <div>
<hm-complex-form :schema="schema['HmUser']" <hm-complex-form :schema="schema['HmUser']"
:columns="showUserColumns" :columns="showUserColumns"
:buttons="showUserButtons" :buttons="showUserButtons"
:layout="layout" :layout="layout"
:tips="tips" :tips="tips"
:refers="userRefers"> :refers="userRefers"
:foreignFormFields="foreignFormFields"
:relates="userRelates">
</hm-complex-form> </hm-complex-form>
</div> </div>
</template> </template>
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
change: this.inputChange change: this.inputChange
// rule: { required: true, message: '用户名不能为空', trigger: 'blur' } // rule: { required: true, message: '用户名不能为空', trigger: 'blur' }
// hide: true // hide: true
// default: '默认值', // default: '默认值',
}, },
// 5富文本 // 5富文本
{ name: '电子邮件', codeCamel: 'email', widgetType: 5, disabled: false, { name: '电子邮件', codeCamel: 'email', widgetType: 5, disabled: false,
...@@ -60,7 +61,7 @@ ...@@ -60,7 +61,7 @@
// 6日期 // 6日期
{ name: '新建时间', codeCamel: 'createTime', widgetType: 6, dateType: 'datetime', { name: '新建时间', codeCamel: 'createTime', widgetType: 6, dateType: 'datetime',
dateFormate: 'yyyy-MM-dd HH:mm:ss', change: this.inputChange dateFormate: 'yyyy-MM-dd HH:mm:ss', change: this.inputChange
// default: '2018-01-01 00:07:08' // default: '2018-01-01 00:07:08'
}, },
// 7单选 // 7单选
{ name: '登陆id', codeCamel: 'loginid', widgetType: 7, { name: '登陆id', codeCamel: 'loginid', widgetType: 7,
...@@ -72,38 +73,51 @@ ...@@ -72,38 +73,51 @@
// 8文件 // 8文件
{ name: '选择头像', codeCamel: 'avatar', widgetType: 8, url: '/api/upload' } // url是后台接口地址 { name: '选择头像', codeCamel: 'avatar', widgetType: 8, url: '/api/upload' } // url是后台接口地址
], ],
// CcSubject示例
showUserColumns2: [ showUserColumns2: [
// 1普通input { name: '题目', codeCamel: 'subject' },
{ name: '用户名称', codeCamel: 'username', widgetType: 1 }, { name: '题目类型', codeCamel: 'subjectType', default: 3 },
{ name: '部门ID', codeCamel: 'departmentId', widgetType: 1 }, { name: 'A选项', codeCamel: 'description0', code: 'description', serialNumber: 'A', widgetType: 1, isForeign: true },
{ name: '部门名称', codeCamel: 'departmentName', widgetType: 1 }, { name: 'B选项', codeCamel: 'description1', code: 'description', serialNumber: 'B', widgetType: 1, isForeign: true },
{ name: '密码', codeCamel: 'password', widgetType: 1 }, { name: '正确选项', codeCamel: 'correct', widgetType: 1, isForeign: true, partProp: true },
{ name: '电话', codeCamel: 'mobile', widgetType: 1 }, { name: '试题详解', codeCamel: 'commentary', widgetType: 1 }
{ name: '电子邮件', codeCamel: 'email', widgetType: 1 },
{ name: '新建时间', codeCamel: 'createTime', widgetType: 1 },
{ name: '登陆id', codeCamel: 'loginid', widgetType: 1 }
], ],
userIncludes: { // schema['CcMenuResource'] + userRelates + showUserColumns3 理论学习示例
'hm_user': { showUserColumns3: [
includes: ['user_id'] { name: '标题', codeCamel: 'title', widgetType: 1 },
} { name: '封面图片', codeCamel: 'thumbnail', widgetType: 8 },
}, { name: '视频', codeCamel: 'videoName', widgetType: 8 },
// 主查外 { name: '简介', codeCamel: 'lntroduction', widgetType: 1 },
{ name: '内容', codeCamel: 'content', widgetType: 4 },
{ name: '发布人', codeCamel: 'publisher', widgetType: 1 }
],
// schema['CcSubject']+foreignFormFields+userRefers+showUserColumns2 判断题示例
// 第一个值为外键字段(codeCamel)
foreignFormFields: ['ccSubjectId', 'description', 'correct', 'serialNumber'],
// 主查外表 外键字段
userRefers: { userRefers: {
'cc_shift': { 'cc_option': {
includes: ['applicant_id'] includes: ['ccSubjectId']
} }
}, },
// userIncludes: {
// 'hm_user': {
// includes: ['user_id']
// }
// },
// 要显示按钮 // 要显示按钮
showUserButtons: [ showUserButtons: [
{ text: '确定', type: 1, method: this.method1, beforeSubmit: this.processData }, { text: '确定', type: 1, method: this.method1, beforeSubmit: this.processData },
{ text: '重置', type: 2, method: this.method2 }, { text: '重置', type: 2, method: this.method2 },
{ text: '生成', method: this.method4 }, { text: '生成', method: this.method4 },
// { text: '预览', method: this.method5 },
// { text: '预览2', method: this.method5 },
{ text: '取消', type: 3, method: this.method3 } { text: '取消', type: 3, method: this.method3 }
], ],
// showUserButtons: [] // showUserButtons: []
// 布局方式 // 布局方式
layout: { left: 4, middle: 16, right: 4 }, layout: { left: 2, middle: 20, right: 2 },
// 自定义提示消息 // 自定义提示消息
tips: { tips: {
hidde: false, // 是否显示提示,默认false显示 hidde: false, // 是否显示提示,默认false显示
...@@ -128,16 +142,22 @@ ...@@ -128,16 +142,22 @@
autosize: { minRows: 3, maxRows: 5 }, autosize: { minRows: 3, maxRows: 5 },
rows: 3 rows: 3
}, },
quillEdito: { style: { width: '65%' }} quillEditor: { style: { width: '65%' }}
}, },
// 'cc_option': {
// includes: ['ccSubjectId'] // 关联表 本表即页面显示的要创建的表'CcMenuResource' 中间表'cc_menu_resource_associations'
// } // 间接关联表'cc_secondary_menu_dictionaries'
judgeRefers: { // 主查外 userRelates: [
'cc_hm_user': { // 间接关联表
includes: ['applicantId'] { indirectTable: 'cc_secondary_menu_dictionaries', // 下划线复数
// 过滤查询的条件
filters: { 'cc_secondary_menu_dictionary': { 'name': { equalTo: '理论学习' }}}
},
// 中间表
{ relateTable: 'cc_menu_resource_associations',
relateKeys: ['resourceId', 'menuId'] // 中间表与主表(本表)字段 与间接关联表对应字段
} }
} ]
} }
}, },
computed: { computed: {
...@@ -169,7 +189,12 @@ ...@@ -169,7 +189,12 @@
method3() { method3() {
console.log('method3') console.log('method3')
}, },
method4() { method4(formModel) {
console.log(formModel)
console.log('method4')
},
method5(formModel) {
console.log(formModel)
console.log('method4') console.log('method4')
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment