Commit 43fcb0e0 authored by gaochao's avatar gaochao

Merge branch 'master' of 115.28.80.125:softwarefactory/vueelementtemplate

parents 6c4d4262 501d8e99
<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')
} }
} }
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<el-button class="filter-item" type="primary" v-waves icon="el-icon-refresh" v-if="isShowRefresh" @click="refreshList">刷新</el-button> <el-button class="filter-item" type="primary" v-waves icon="el-icon-refresh" v-if="isShowRefresh" @click="refreshList">刷新</el-button>
<el-button class="filter-item" type="primary" v-waves icon="el-icon-close" v-if="multipleSelection.length" @click="BatchRemove">批量删除</el-button> <el-button class="filter-item" type="primary" v-waves icon="el-icon-close" v-if="multipleSelection.length" @click="BatchRemove">批量删除</el-button>
</span> </span>
<hm-full-calendar style="display: inline;margin-left: 10px;" :schema="HmFullCalendar.calendarSchema" :demoEvents="HmFullCalendar.demoEvents" v-if="HmFullCalendar.calendarSchema"></hm-full-calendar>
</el-form> </el-form>
</div> </div>
...@@ -136,14 +137,13 @@ ...@@ -136,14 +137,13 @@
<!-- @TODO 补充详情弹窗 --> <!-- @TODO 补充详情弹窗 -->
<el-dialog :title="dialogName" :visible.sync="dialogFormVisible" :close-on-click-modal="closeOnClickModal" width="dialogWidth" v-if="dialogFormVisible"> <el-dialog :title="dialogName" :visible.sync="dialogFormVisible" :close-on-click-modal="closeOnClickModal" width="dialogWidth" v-if="dialogFormVisible">
<hm-complex-form :schema="formSchema" <hm-complex-form :schema="HmComplexForm.formSchema"
:columns="showUserColumns" :columns="HmComplexForm.showUserColumns"
:buttons="showUserButtons" :buttons="HmComplexForm.showUserButtons"
:layout="layout" :layout="HmComplexForm.layout"
:tableId="tableId" :tableId="HmComplexForm.tableId"
:tips="formTips" :tips="HmComplexForm.formTips"
:formStyle="formStyle" :formStyle="HmComplexForm.formStyle">
ref="selectfood">
</hm-complex-form> </hm-complex-form>
</el-dialog> </el-dialog>
...@@ -160,6 +160,7 @@ ...@@ -160,6 +160,7 @@
import * as excel from '@/vendor/Export2Excel' import * as excel from '@/vendor/Export2Excel'
import { Button, Table, TableColumn, Pagination, Loading } from 'element-ui' import { Button, Table, TableColumn, Pagination, Loading } from 'element-ui'
import HmComplexForm from '../forms/HmComplexForm.vue' import HmComplexForm from '../forms/HmComplexForm.vue'
import HmFullCalendar from '../calendar/HmFullCalendar.vue'
/** /**
* 毫末科技的表格组件. * 毫末科技的表格组件.
...@@ -178,7 +179,8 @@ ...@@ -178,7 +179,8 @@
'el-table': Table, 'el-table': Table,
'el-table-column': TableColumn, 'el-table-column': TableColumn,
'el-pagination': Pagination, 'el-pagination': Pagination,
'hm-complex-form': HmComplexForm 'hm-complex-form': HmComplexForm,
'hm-full-calendar': HmFullCalendar
}, },
// 混入公共对象 // 混入公共对象
mixins: [], mixins: [],
...@@ -361,14 +363,17 @@ ...@@ -361,14 +363,17 @@
isShowEditDataButton: false, // 是否显示编辑 isShowEditDataButton: false, // 是否显示编辑
isShowDeleteButton: false, // 是否显示删除 isShowDeleteButton: false, // 是否显示删除
isShowExport: false, // 是否显示导出按钮 isShowExport: false, // 是否显示导出按钮
formSchema: {}, // form弹窗的Schema定义 HmComplexForm: { // 设置form组件
showUserColumns: [], // form弹窗的Columns定义 formSchema: {}, // form弹窗的Schema定义
showUserButtons: [], // from弹窗显示按钮, showUserColumns: [], // form弹窗的Columns定义
layout: { left: 0, middle: 24, right: 0 }, // form弹窗的布局方式 showUserButtons: [], // from弹窗显示按钮,
tableId: '', layout: { left: 0, middle: 24, right: 0 }, // form弹窗的布局方式
formTips: '', tableId: '',
formStyle: '', formTips: '',
showOverflowTooltip: false, formStyle: ''
},
showOverflowTooltip: false, // 设置当内容过长被隐藏时显示 tooltip
HmFullCalendar: {}, //
isShowRefresh: false, isShowRefresh: false,
buttonGroup: false, buttonGroup: false,
...@@ -611,29 +616,29 @@ ...@@ -611,29 +616,29 @@
self.userDefined.definedDetail(true, data) self.userDefined.definedDetail(true, data)
return false return false
} }
self.tableId = '' self.HmComplexForm.tableId = ''
if (type === 'editData') { if (type === 'editData') {
self.dialogName = '编辑' self.dialogName = '编辑'
if (self.options.editData.showUserButtons) { if (self.options.editData.showUserButtons) {
self.showUserButtons = self.options.editData.showUserButtons self.showUserButtons = self.options.editData.showUserButtons
} }
self.tableId = data.id self.HmComplexForm.tableId = data.id
self.showUserColumns = self.options.editData.showUserColumns self.HmComplexForm.showUserColumns = self.options.editData.showUserColumns
self.formSchema = self.options.editData.formSchema self.HmComplexForm.formSchema = self.options.editData.formSchema
self.layout = self.options.editData.layout self.HmComplexForm.layout = self.options.editData.layout
self.formTips = self.options.editData.tips self.HmComplexForm.formTips = self.options.editData.tips
self.formStyle = self.options.editData.formStyle self.HmComplexForm.formStyle = self.options.editData.formStyle
} }
if (type === 'newData') { if (type === 'newData') {
self.dialogName = '新建' self.dialogName = '新建'
if (self.options.newData.showUserButtons) { if (self.options.newData.showUserButtons) {
self.showUserButtons = self.options.newData.showUserButtons self.showUserButtons = self.options.newData.showUserButtons
} }
self.showUserColumns = self.options.newData.showUserColumns self.HmComplexForm.showUserColumns = self.options.newData.showUserColumns
self.formSchema = self.options.newData.formSchema self.HmComplexForm.formSchema = self.options.newData.formSchema
self.layout = self.options.newData.layout self.HmComplexForm.layout = self.options.newData.layout
self.formTips = self.options.newData.tips self.HmComplexForm.formTips = self.options.newData.tips
self.formStyle = self.options.newData.formStyle self.HmComplexForm.formStyle = self.options.newData.formStyle
} }
if (type === 'detail') { if (type === 'detail') {
self.dialogName = '详情' self.dialogName = '详情'
...@@ -641,12 +646,12 @@ ...@@ -641,12 +646,12 @@
if (self.options.detailData.showUserButtons) { if (self.options.detailData.showUserButtons) {
self.showUserButtons = self.options.detailData.showUserButtons self.showUserButtons = self.options.detailData.showUserButtons
} }
self.showUserColumns = self.options.showDetail.showUserColumns self.HmComplexForm.showUserColumns = self.options.showDetail.showUserColumns
self.formSchema = self.options.showDetail.formSchema self.HmComplexForm.formSchema = self.options.showDetail.formSchema
self.layout = self.options.showDetail.layout self.HmComplexForm.layout = self.options.showDetail.layout
self.formTips = self.options.showDetail.tips self.HmComplexForm.formTips = self.options.showDetail.tips
self.formStyle = self.options.showDetail.formStyle self.HmComplexForm.formStyle = self.options.showDetail.formStyle
self.tableId = data.id self.HmComplexForm.tableId = data.id
} }
self.dialogFormVisible = true self.dialogFormVisible = true
...@@ -676,29 +681,9 @@ ...@@ -676,29 +681,9 @@
// 删除一条数据 // 删除一条数据
deleteData(data) { deleteData(data) {
const self = this const self = this
self.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { const params = { ids: [data.id] }
confirmButtonText: '确定', params.ids = JSON.stringify(params.ids)
cancelButtonText: '取消', self.deleteDataRequest(params)
type: 'warning'
}).then(() => {
request(self.schema.modelUnderscorePlural + '/' + data.id + '/delete', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
}).then(data => {
if (data.data.message === 'delete success') {
self.$message({
message: data.data.message,
type: 'success'
})
self.getList()
}
})
}).catch(() => {
self.$message({
message: '已取消删除',
type: 'success'
})
})
}, },
refreshList() { refreshList() {
this.listQuery = { this.listQuery = {
...@@ -715,15 +700,17 @@ ...@@ -715,15 +700,17 @@
// 批量删除 // 批量删除
BatchRemove() { BatchRemove() {
const self = this const self = this
const datas = { const datas = { ids: [] }
ids: []
}
if (!self.multipleSelection) return false if (!self.multipleSelection) return false
_.each(self.multipleSelection, function(item, index) { _.each(self.multipleSelection, function(item, index) {
datas.ids.push(item.id) datas.ids.push(item.id)
}) })
datas.ids = JSON.stringify(datas.ids) datas.ids = JSON.stringify(datas.ids)
self.$confirm('此操作将永久删除该数据, 是否继续?', '提示', { self.deleteDataRequest(datas)
},
deleteDataRequest(data) {
const self = this
self.$confirm('此操作将永久删除数据, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
...@@ -731,12 +718,12 @@ ...@@ -731,12 +718,12 @@
request(self.schema.modelUnderscorePlural + '/delete/batch', { request(self.schema.modelUnderscorePlural + '/delete/batch', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
data: datas, data: data,
transformRequest: param transformRequest: param
}).then(data => { }).then(resp => {
if (data.data.message === 'delete success') { if (resp.data.message === 'delete success') {
self.$message({ self.$message({
message: data.data.message, message: resp.data.message,
type: 'success' type: 'success'
}) })
self.getList() self.getList()
...@@ -784,6 +771,9 @@ ...@@ -784,6 +771,9 @@
if (self.options.showOverflowTooltip) { // 当内容过长被隐藏时显示 tooltip if (self.options.showOverflowTooltip) { // 当内容过长被隐藏时显示 tooltip
self.showOverflowTooltip = self.options.showOverflowTooltip self.showOverflowTooltip = self.options.showOverflowTooltip
} }
if (self.options.HmFullCalendar) { // 当内容过长被隐藏时显示 tooltip
self.HmFullCalendar = self.options.HmFullCalendar
}
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val this.multipleSelection = val
......
...@@ -82,11 +82,19 @@ ...@@ -82,11 +82,19 @@
showDetail: { showDetail: {
isShow: true isShow: true
}, },
HmFullCalendar: {
calendarSchema: schema['HmUser'],
demoEvents: {
title: 'username',
start: 'createTime',
end: 'lastUpdateTime'
}
},
showRefresh: true, showRefresh: true,
showExport: true, showExport: true,
showDeleteButton: true, showDeleteButton: true,
buttonGroup: false, buttonGroup: false,
showSelection: false, showSelection: true,
showOverflowTooltip: true, showOverflowTooltip: true,
tableCurrentChange(value) {} tableCurrentChange(value) {}
// dataProcessing(value, params, definedOperate) {}, // 处理返回后的数据,必须return 处理后的数据 // dataProcessing(value, params, definedOperate) {}, // 处理返回后的数据,必须return 处理后的数据
......
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