72 changed files with 9832 additions and 0 deletions
@ -0,0 +1,224 @@ |
|||
<template> |
|||
<div> |
|||
<w-form |
|||
ref="formRef" |
|||
:fields="[ |
|||
{ |
|||
name: 'test1', |
|||
label: '文本框', |
|||
type: 'w-text', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test2', |
|||
label: '下拉框', |
|||
type: 'w-select', |
|||
requiredIf: true, |
|||
multiple: true, |
|||
options: [ |
|||
{ label: '男', value: 1 }, |
|||
{ label: '女', value: 0 }, |
|||
], |
|||
}, |
|||
{ |
|||
name: 'test2.5', |
|||
label: '可输入可选择下拉框', |
|||
type: 'w-input-select', |
|||
requiredIf: true, |
|||
defaultValue: 'wowowo', |
|||
options: [ |
|||
{ label: 'java', value: '1' }, |
|||
{ label: 'python', value: '2' }, |
|||
], |
|||
}, |
|||
{ |
|||
name: 'test3', |
|||
label: '复选框', |
|||
type: 'w-checkbox', |
|||
}, |
|||
{ |
|||
name: 'test4', |
|||
label: '日期', |
|||
type: 'w-date', |
|||
clearable: true, |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test4.5', |
|||
label: '日期范围', |
|||
type: 'w-date-range', |
|||
clearable: true, |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test5', |
|||
label: '文件', |
|||
type: 'w-file', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test6', |
|||
label: '数字', |
|||
type: 'w-number', |
|||
precision: 2, |
|||
requiredIf: (args) => { |
|||
return true; |
|||
}, |
|||
}, |
|||
{ |
|||
name: 'test7', |
|||
label: '密码', |
|||
type: 'w-password', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test8', |
|||
label: '头像', |
|||
type: 'w-icon', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test9', |
|||
label: '页面位置', |
|||
type: 'w-position', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test10', |
|||
label: '颜色', |
|||
type: 'w-color-input', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test11', |
|||
label: '颜色2', |
|||
type: 'w-color-input-palette', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test12', |
|||
label: '复选框组', |
|||
requiredIf: true, |
|||
type: 'w-checkbox-group', |
|||
simple: false, |
|||
options: [ |
|||
{ label: '唱歌', value: '1' }, |
|||
{ label: '跳舞', value: '2' }, |
|||
{ label: '运动', value: '3' }, |
|||
{ label: '看书', value: '4' }, |
|||
], |
|||
}, |
|||
{ |
|||
name: 'test12.5', |
|||
label: '单选按钮', |
|||
type: 'w-radio', |
|||
requiredIf: true, |
|||
options: [ |
|||
{ label: '已婚', value: 1 }, |
|||
{ label: '单身', value: 2 }, |
|||
{ label: '离异', value: 3 }, |
|||
], |
|||
}, |
|||
{ |
|||
name: 'test13', |
|||
label: '自定义下拉表格', |
|||
type: 'w-grid-select', |
|||
requiredIf: true, |
|||
multiple: true, |
|||
displayValue: 'name', |
|||
grid: { |
|||
title: '应用列表', |
|||
dataUrl: Environment.apiContextPath('/api/system/application'), |
|||
sortBy: ['order'], |
|||
queryFormColsNum: 3, |
|||
queryFormFields: [ |
|||
{ name: 'code', label: $t('code') }, |
|||
{ name: 'name', label: $t('name') }, |
|||
{ name: 'enable', label: $t('isEnable') }, |
|||
], |
|||
toolbarActions: ['query', 'separator', 'reset'], |
|||
columns: [ |
|||
{ name: 'order', label: $t('order') }, |
|||
{ name: 'code', label: $t('code') }, |
|||
{ |
|||
name: 'name', |
|||
label: $t('name'), |
|||
format: (val, row) => { |
|||
return val; |
|||
}, |
|||
}, |
|||
{ name: 'enable', label: $t('status'), format: Formater.enableTag() }, |
|||
{ name: 'lastModifier', label: $t('lastModifier') }, |
|||
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.dateOnly() }, |
|||
], |
|||
}, |
|||
}, |
|||
{ |
|||
name: 'test14', |
|||
label: '用户选择', |
|||
type: 'w-user-select', |
|||
multiple: true, |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test15', |
|||
label: '机构选择', |
|||
type: 'w-org-select', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test16', |
|||
label: 'cron表达式', |
|||
type: 'w-cron', |
|||
requiredIf: true, |
|||
}, |
|||
{ |
|||
name: 'test98', |
|||
label: '代码编辑器', |
|||
type: 'w-code-mirror', |
|||
requiredIf: true, |
|||
colsFirst: true, |
|||
colSpan: '2', |
|||
rows: 3, |
|||
}, |
|||
{ |
|||
name: 'test99', |
|||
label: '文本域', |
|||
type: 'w-textarea', |
|||
requiredIf: true, |
|||
colSpan: '2', |
|||
rows: 7, |
|||
}, |
|||
{ |
|||
name: 'test100', |
|||
label: '富文本编辑器', |
|||
type: 'w-text-editor', |
|||
required: true, |
|||
colsFirst: true, |
|||
colSpan: 'full', |
|||
}, |
|||
]" |
|||
:cols-x-gap="8" |
|||
> |
|||
</w-form> |
|||
<q-btn label="提交" @click="submit"></q-btn> <q-btn label="重置" @click="reset"></q-btn> |
|||
<q-btn label="初始化值" @click="setValue"></q-btn> |
|||
</div> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { ref } from 'vue'; |
|||
import { Environment, Formater } from 'platform-core'; |
|||
|
|||
const formRef = ref(); |
|||
|
|||
const submit = async () => { |
|||
console.info('表单数据:', formRef.value.getData()); |
|||
const validateResult = await formRef.value.validate(); |
|||
console.info('表单验证结果:', validateResult); |
|||
}; |
|||
const reset = () => { |
|||
formRef.value.reset(); |
|||
}; |
|||
const setValue = () => { |
|||
}; |
|||
</script> |
@ -0,0 +1,400 @@ |
|||
<template> |
|||
<q-card ref="cardRef" class="p-0" flat bordered :style="cardHeightComponent"> |
|||
<q-card-section class="p-2"> |
|||
<div class="flex justify-end gap-4"> |
|||
<q-btn label="导出报表" icon="download" @click="downloadExcel"></q-btn> |
|||
</div> |
|||
</q-card-section> |
|||
<div id="luckysheet2" :class="luckySheetClassComputed"></div> |
|||
</q-card> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, onMounted, computed, reactive } from 'vue'; |
|||
import { useRoute } from 'vue-router'; |
|||
import { exportExcel } from './luckysheet/export'; |
|||
import { useQuasar } from 'quasar'; |
|||
import { axios, Environment, Tools } from 'platform-core'; |
|||
|
|||
import { getExcelCellFormatObject } from './template.ts'; |
|||
|
|||
const gc = Environment.getConfigure(); |
|||
const $q = useQuasar(); |
|||
const route = useRoute(); |
|||
const cardRef = ref(); |
|||
const props = defineProps({ |
|||
templateId: { type: String, default: '' }, |
|||
}); |
|||
|
|||
const state = reactive({ |
|||
cardY: 0, |
|||
}); |
|||
|
|||
const luckySheetClassComputed = computed(() => { |
|||
return !Tools.isEmpty(props.templateId) ? 'repoortView' : 'templateView'; |
|||
}); |
|||
|
|||
const cardHeightComponent = computed(() => { |
|||
// 浏览器可视区域高度 |
|||
const screenHeight = $q.screen.height; |
|||
// 系统底部高度(一般用来显示XX版权所有那一层) |
|||
const footerHeight = gc.theme.footer.enable ? gc.theme.footer.height : 0; |
|||
const cardHeight = screenHeight - footerHeight - state.cardY - 10; |
|||
return { |
|||
height: cardHeight + 'px', |
|||
}; |
|||
}); |
|||
|
|||
const downloadExcel = () => { |
|||
// eslint-disable-next-line |
|||
exportExcel(window['luckysheet'].getAllSheets(), '下载'); |
|||
}; |
|||
|
|||
const luckysheetData = [ |
|||
{ |
|||
name: 'Cell', // 工作表名称 |
|||
color: '', // 工作表颜色 |
|||
index: 0, // 工作表索引 |
|||
status: 1, // 激活状态 |
|||
order: 0, // 工作表的下标 |
|||
hide: 0, // 是否隐藏 |
|||
defaultRowHeight: 19, // 自定义行高 |
|||
defaultColWidth: 73, // 自定义列宽 |
|||
column: 26, |
|||
row: 33, |
|||
celldata: [], // 初始化使用的单元格数据 |
|||
config: { |
|||
merge: {}, // 合并单元格 |
|||
rowlen: {}, // 表格行高 |
|||
columnlen: {}, // 表格列宽 |
|||
rowhidden: {}, // 隐藏行 |
|||
colhidden: {}, // 隐藏列 |
|||
borderInfo: [], // 边框 |
|||
authority: {}, // 工作表保护 |
|||
}, |
|||
scrollLeft: 0, // 左右滚动条位置 |
|||
scrollTop: 0, // 上下滚动条位置 |
|||
luckysheet_select_save: [], // 选中的区域 |
|||
calcChain: [], // 公式链 |
|||
isPivotTable: false, // 是否数据透视表 |
|||
pivotTable: {}, // 数据透视表设置 |
|||
filter_select: {}, // 筛选范围 |
|||
filter: null, // 筛选配置 |
|||
luckysheet_alternateformat_save: [], // 交替颜色 |
|||
luckysheet_alternateformat_save_modelCustom: [], // 自定义交替颜色 |
|||
luckysheet_conditionformat_save: {}, // 条件格式 |
|||
frozen: {}, // 冻结行列配置 |
|||
chart: [], // 图表配置 |
|||
zoomRatio: 1, // 缩放比例 |
|||
image: [], // 图片 |
|||
showGridLines: 0, // 是否显示网格线 |
|||
dataVerification: {}, // 数据验证配置 |
|||
}, |
|||
]; |
|||
const luckysheetOptions = { |
|||
container: 'luckysheet2', // 设定DOM容器的id |
|||
lang: 'zh', // 设定表格语言 |
|||
title: '测试', // 设定表格名称 |
|||
allowEdit: false, // 是否允许编辑 |
|||
rowHeaderWidth: 0, // 行标题区域的宽度,如果设置为0,则表示隐藏行标题,也就是表格第一行,A,B,C这行,默认值46 |
|||
columnHeaderHeight: 0, // 列标题区域的高度,如果设置为0,则表示隐藏列标题,也就是序号这一行,默认值20 |
|||
showtoolbar: false, // 是否显示工具栏,设置字体,边框,插入这些工具按钮。 |
|||
showinfobar: false, // 是否显示顶部信息栏,luckysheet的logo,表格名称这一栏。 |
|||
userInfo: 'likunming', // 右上角用户信息,若需要展示,必须配合showinfobar使用 |
|||
sheetFormulaBar: false, // 是否显示公式栏 |
|||
defaultFontSize: 11, // 初始化默认字体大小,默认11 |
|||
showsheetbar: false, // 是否显示底部sheet页按钮 |
|||
enableAddRow: false, |
|||
enableAddBackTop: false, |
|||
data: luckysheetData, // 表格数据 |
|||
}; |
|||
|
|||
let columnParamsArr = <any>[]; |
|||
// eslint-disable-next-line |
|||
const psReg = /\@\{(?!\@\{)(.*?)\}\@/; |
|||
const columnParamsHandle = (json) => { |
|||
columnParamsArr = []; |
|||
// 提取所有批注中 @{}@ 包裹的非首列配置(批注中配置了循环列表属性的列定义为首列,除去首列外,其他列也可配置如千分位显示、百分比格式等属性) |
|||
for (let r = 0; r < json.data.length; r++) { |
|||
let row = json.data[r]; |
|||
for (let c = 0; c < row.length; c++) { |
|||
let col = row[c]; |
|||
if (col && col.ps && col.ps.value.startsWith('@{') && col.ps.value.endsWith('}@')) { |
|||
const jsonObject = JSON.parse(psReg.exec(col.ps.value.replaceAll('\n', ''))[1]); |
|||
if (jsonObject && !Tools.hasOwnProperty(jsonObject, 'listName')) { |
|||
columnParamsArr.push({ row: r, col: c, ps: jsonObject }); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
|
|||
const initExcel = async (templateId) => { |
|||
const resp = await axios.get(Environment.apiContextPath('api/excel/template/') + templateId); |
|||
if (resp.data?.templateConfig) { |
|||
let config = resp.data.templateConfig; |
|||
const dataResp = await axios.get(Environment.apiContextPath('api/excel/template/getReportData/') + templateId); |
|||
// 替换所有 ${} 包裹的占位符变量 |
|||
Object.keys(dataResp.data).forEach((item) => { |
|||
if (!Array.isArray(dataResp.data[item])) { |
|||
config = config.replaceAll('${' + item + '}', dataResp.data[item]); |
|||
} |
|||
}); |
|||
|
|||
const json = eval('(' + config + ')'); |
|||
luckysheetOptions.data = [json]; |
|||
json.showGridLines = 0; // 不显示网格线 |
|||
json.scrollLeft = 0; |
|||
json.scrollTop = 0; |
|||
if (json.frozen && json.frozen.type === 'rangeBoth') { |
|||
json.frozen.range.row_focus = json.frozen.range.row_focus - 1; |
|||
json.frozen.range.column_focus = json.frozen.range.column_focus - 1; |
|||
} |
|||
// eslint-disable-next-line |
|||
luckysheet.create(luckysheetOptions); |
|||
|
|||
if (json.data) { |
|||
columnParamsHandle(json); |
|||
|
|||
// 根据配置找出所有批注中 @{}@ 包裹的循环列表变量及所在行信息 |
|||
for (let r = 0; r < json.data.length; r++) { |
|||
let row = json.data[r]; |
|||
for (let c = 0; c < row.length; c++) { |
|||
let col = row[c]; |
|||
if (col && col.ps && col.ps.value.startsWith('@{') && col.ps.value.endsWith('}@')) { |
|||
const jsonObject = JSON.parse(psReg.exec(col.ps.value.replaceAll('\n', ''))[1]); |
|||
/** |
|||
* row: 批注存在 @{XXX}@ 的行数 |
|||
* col: 批注存在 @{XXX}@ 的列数 |
|||
* ps: 提取 @{XXX}@ 中的内容并去除换行符后转换的 JSON 对象,为模板配置中属性配置中的内容。 |
|||
* rowData: 批注存在 @{XXX}@ 的行原始数据 |
|||
* templateMerge: 模板合并单元格配置 |
|||
*/ |
|||
listHandler({ row: r, col: c, ps: jsonObject, rowData: row, templateMerge: json.config?.merge }, dataResp, json); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} else { |
|||
// eslint-disable-next-line |
|||
luckysheet.create(luckysheetOptions); |
|||
} |
|||
}; |
|||
|
|||
/** |
|||
* 处理合并单元格(luckysheet.insertRow插入的表格行与列不具备合并功能,与微软Excel一样的。 |
|||
* 所以需要找出配置的模板中列表类型是否包含合并单元格,并在插入后进行处理) |
|||
*/ |
|||
const mergeCellHandler = (json, item, num) => { |
|||
if (item.templateMerge) { |
|||
let mergeColumn; |
|||
Object.keys(item.templateMerge).forEach((mergeKey) => { |
|||
mergeColumn = mergeKey.split('_')[1]; |
|||
if (mergeKey.startsWith(String(item.row))) { |
|||
for (let i = 0; i < num; i++) { |
|||
json.config.merge[item.row + i + '_' + mergeColumn] = { |
|||
r: item.row + i, |
|||
c: mergeColumn, |
|||
rs: item.templateMerge[mergeKey].rs, |
|||
cs: item.templateMerge[mergeKey].cs, |
|||
}; |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
// eslint-disable-next-line |
|||
const colReg = /\#\{([^}]*)\}/; |
|||
const listHandler = (item, dataResp, json) => { |
|||
if (item.ps && Tools.hasOwnProperty(item.ps, 'listName')) { |
|||
if (Tools.isEmpty(item.ps.dataRowNum)) { |
|||
item.ps.dataRowNum = 1; |
|||
} |
|||
// 根据返回数据重新设置报表行数 |
|||
const num = dataResp.data[item.ps.listName].length * item.ps.dataRowNum; |
|||
if (num > 0 && num <= 100) { |
|||
// eslint-disable-next-line |
|||
luckysheet.insertRow(item.row, { number: num }); |
|||
mergeCellHandler(json, item, num); |
|||
} else if (num > 0) { |
|||
const page = Math.floor(num / 100); |
|||
const count = num % 100; |
|||
for (let i = 0; i < page; i++) { |
|||
// eslint-disable-next-line |
|||
luckysheet.insertRow(item.row, { number: 100 }); |
|||
mergeCellHandler(json, item, 100); |
|||
} |
|||
if (count > 0) { |
|||
// eslint-disable-next-line |
|||
luckysheet.insertRow(item.row, { number: count }); |
|||
mergeCellHandler(json, item, count); |
|||
} |
|||
} |
|||
// eslint-disable-next-line |
|||
luckysheet.deleteRow(item.row + num, item.row + num); |
|||
|
|||
// 字体加粗 |
|||
let fontWeightArr = []; |
|||
if (item.ps.fontWeight) { |
|||
fontWeightArr = item.ps.fontWeight.indexOf(',') > -1 ? item.ps.fontWeight.split(',') : [item.ps.fontWeight]; |
|||
} |
|||
// 单元格背景色 |
|||
let cellBgColorArr = <any>[]; |
|||
if (item.ps.cellBgColor) { |
|||
const tmpArr = item.ps.cellBgColor.split('='); |
|||
const valueArr = tmpArr[0].indexOf(',') > -1 ? tmpArr[0].split(',') : [tmpArr[0]]; |
|||
const colorArr = tmpArr[1].indexOf(',') > -1 ? tmpArr[1].split(',') : [tmpArr[1]]; |
|||
for (let i = 0; i < valueArr.length; i++) { |
|||
cellBgColorArr.push([valueArr[i], colorArr[i]]); |
|||
} |
|||
} |
|||
// 单元格值转换 |
|||
let transformedArr = <any>[]; |
|||
if (item.ps.cellValueTransformed) { |
|||
const tmpArr = item.ps.cellValueTransformed.split('='); |
|||
const valueArr = tmpArr[0].indexOf(',') > -1 ? tmpArr[0].split(',') : [tmpArr[0]]; |
|||
const tfArr = tmpArr[1].indexOf(',') > -1 ? tmpArr[1].split(',') : [tmpArr[1]]; |
|||
for (let i = 0; i < valueArr.length; i++) { |
|||
transformedArr.push([valueArr[i], tfArr[i] === 'NULL' ? '' : tfArr[i]]); |
|||
} |
|||
} |
|||
|
|||
dataResp.data[item.ps.listName].forEach((rowData, i) => { |
|||
let columnBgColor = false; |
|||
let columnFontWeight = false; |
|||
item.rowData.forEach((c, colIndex) => { |
|||
if (c && c.v) { |
|||
const code = colReg.exec(c.v); |
|||
if (code && code.length > 1 && Tools.hasOwnProperty(rowData, code[1])) { |
|||
let cellValue = { ...c }; |
|||
// 处理单元格格式 |
|||
if (columnParamsArr.length > 0) { |
|||
columnParamsArr.forEach((columnParams) => { |
|||
if (columnParams.row === item.row && colIndex === columnParams.col && columnParams.ps.cellFormat) { |
|||
cellValue = { ...cellValue, ...{ ct: getExcelCellFormatObject(columnParams.ps.cellFormat) } }; |
|||
} |
|||
}); |
|||
} |
|||
cellValue = { ...cellValue, ...{ v: rowData[code[1]] } }; |
|||
if (fontWeightArr.length > 0 && (fontWeightArr.indexOf(rowData[code[1]]) > -1 || columnFontWeight)) { |
|||
columnFontWeight = item.ps.fontWeightRow === 'true' ? true : false; |
|||
cellValue = { ...cellValue, ...{ bl: 1 } }; |
|||
} |
|||
cellBgColorArr.forEach((cellBgColor) => { |
|||
if (cellBgColor[0] === String(rowData[code[1]]) || columnBgColor) { |
|||
columnBgColor = item.ps.cellBgColorRow === 'true' ? true : false; |
|||
cellValue = { ...cellValue, ...{ bg: cellBgColor[1] } }; |
|||
} |
|||
}); |
|||
if (item.ps.cellComment && colIndex === item.col) { |
|||
cellValue = { ...cellValue, ...{ ps: { value: item.ps.cellComment } } }; |
|||
} else if (Tools.hasOwnProperty(cellValue, 'ps') && cellValue.ps.value.startsWith('@{') && cellValue.ps.value.endsWith('}@')) { |
|||
delete cellValue.ps; |
|||
} |
|||
// 字体加粗、背景色等无API,故先通过上面处理好单元格基础数据及格式,设置到单元格中。 |
|||
// eslint-disable-next-line |
|||
luckysheet.setCellValue(item.row + i * item.ps.dataRowNum, colIndex, cellValue, { isRefresh: false }); |
|||
|
|||
let cellValueResult = rowData[code[1]]; |
|||
transformedArr.forEach((cellValueTransformed) => { |
|||
if (cellValueTransformed[0] === String(rowData[code[1]])) { |
|||
cellValueResult = cellValueTransformed[1]; |
|||
} |
|||
}); |
|||
// 设置好格式后再设置具体值,格式才会生效。 |
|||
if (i === dataResp.data[item.ps.listName].length - 1 && colIndex === item.rowData.length - 1) { |
|||
columnParamsHandle(json); |
|||
// eslint-disable-next-line |
|||
luckysheet.setCellValue(item.row + i * item.ps.dataRowNum, colIndex, cellValueResult, { isRefresh: true }); |
|||
} else { |
|||
// eslint-disable-next-line |
|||
luckysheet.setCellValue(item.row + i * item.ps.dataRowNum, colIndex, cellValueResult, { isRefresh: false }); |
|||
} |
|||
} else { |
|||
let cellValue = { ...c }; |
|||
delete cellValue.mc; |
|||
if (i === dataResp.data[item.ps.listName].length - 1 && colIndex === item.rowData.length - 1) { |
|||
columnParamsHandle(json); |
|||
// eslint-disable-next-line |
|||
luckysheet.setCellValue(item.row + i * item.ps.dataRowNum, colIndex, cellValue, { isRefresh: true }); |
|||
} else { |
|||
// eslint-disable-next-line |
|||
luckysheet.setCellValue(item.row + i * item.ps.dataRowNum, colIndex, cellValue, { isRefresh: false }); |
|||
} |
|||
} |
|||
} else { |
|||
let cellValue = { ...c }; |
|||
delete cellValue.mc; |
|||
if (i === dataResp.data[item.ps.listName].length - 1 && colIndex === item.rowData.length - 1) { |
|||
columnParamsHandle(json); |
|||
// eslint-disable-next-line |
|||
luckysheet.setCellValue(item.row + i * item.ps.dataRowNum, colIndex, cellValue, { isRefresh: true }); |
|||
} else { |
|||
// eslint-disable-next-line |
|||
luckysheet.setCellValue(item.row + i * item.ps.dataRowNum, colIndex, cellValue, { isRefresh: false }); |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
const showLoading = () => { |
|||
$q.loading.show({ |
|||
message: '正在初始化表格,请稍等...', |
|||
boxClass: 'bg-grey-2 text-grey-9', |
|||
spinnerColor: 'primary', |
|||
}); |
|||
}; |
|||
const hideLoading = () => { |
|||
$q.loading.hide(); |
|||
}; |
|||
|
|||
onMounted(async () => { |
|||
state.cardY = cardRef.value.$el.getBoundingClientRect()?.y; |
|||
|
|||
// eslint-disable-next-line |
|||
if (window.luckysheet) { |
|||
// eslint-disable-next-line |
|||
window.luckysheet.destroy(); |
|||
} |
|||
showLoading(); |
|||
await initExcel(!Tools.isEmpty(props.templateId) ? props.templateId : route.query.templateId); |
|||
// eslint-disable-next-line |
|||
luckysheet.setRangeShow('A1:A1', { show: true }); |
|||
hideLoading(); |
|||
}); |
|||
|
|||
defineExpose({ |
|||
initExcel, |
|||
}); |
|||
</script> |
|||
|
|||
<style scoped> |
|||
/** |
|||
* 模板查看报表 |
|||
*/ |
|||
.templateView { |
|||
margin: 0px; |
|||
padding: 0px; |
|||
position: absolute; |
|||
width: 100%; |
|||
left: 0px; |
|||
top: 60px; |
|||
bottom: 0px; |
|||
} |
|||
|
|||
/** |
|||
* 报表查看 |
|||
*/ |
|||
.repoortView { |
|||
margin: 0px; |
|||
padding: 0px; |
|||
position: absolute; |
|||
width: 100%; |
|||
left: 0px; |
|||
top: 50px; |
|||
bottom: 0px; |
|||
} |
|||
</style> |
@ -0,0 +1,11 @@ |
|||
<template> |
|||
<div> |
|||
<LuckySheet></LuckySheet> |
|||
</div> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import LuckySheet from './luckysheet/LuckySheet.vue'; |
|||
</script> |
|||
|
|||
<style scoped></style> |
@ -0,0 +1,358 @@ |
|||
<template> |
|||
<w-dialog ref="dialogRef" :title="state.dialogTitle" :maximized="true" :buttons="dialog.buttons" body-padding="0px 0px 0px 0px"> |
|||
<div class="flex justify-end gap-2 p-1.5"> |
|||
<q-file v-model="impFile" label="导入Excel文件" input-class="w-[400px]" filled dense accept=".xlsx,.xls" @update:model-value="loadExcel($event)"> |
|||
<template #append> |
|||
<q-icon name="attachment" /> |
|||
</template> |
|||
</q-file> |
|||
<div class="flex flex-none"> |
|||
<q-btn label="选取变量" :icon="PlatformIconEnum.选取变量" @click="selectParams"></q-btn> |
|||
</div> |
|||
<div class="flex flex-none"> |
|||
<q-btn-dropdown :icon="PlatformIconEnum.设置" label="循环属性配置" unelevated outline> |
|||
<q-list> |
|||
<q-item v-close-popup clickable> |
|||
<q-item-section> |
|||
<q-item-label @click="openConfigDialog('main')"><q-icon :name="PlatformIconEnum.更多查询"></q-icon> 整体配置(首列)</q-item-label> |
|||
</q-item-section> |
|||
</q-item> |
|||
<q-item v-close-popup clickable> |
|||
<q-item-section> |
|||
<q-item-label @click="openConfigDialog('column')"><q-icon :name="PlatformIconEnum.更多查询"></q-icon> 列配置(非首列)</q-item-label> |
|||
</q-item-section> |
|||
</q-item> |
|||
</q-list> |
|||
</q-btn-dropdown> |
|||
</div> |
|||
<TemplateParamsSelectDialog ref="paramsSelectDialogRef" @set-params="setParams"></TemplateParamsSelectDialog> |
|||
<TemplateSetForeachPropsDialog ref="setForeachPropsDialogRef" @set-for-each-params="setForEachParams"></TemplateSetForeachPropsDialog> |
|||
<TemplateSetColumnParamsDialog ref="setColumnParamsDialogRef" @set-for-each-params="setForEachParams"></TemplateSetColumnParamsDialog> |
|||
</div> |
|||
<div id="luckysheet"></div> |
|||
</w-dialog> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, reactive, nextTick, onBeforeMount } from 'vue'; |
|||
import LuckyExcel from 'luckyexcel'; |
|||
import { exportExcel } from './luckysheet/export'; |
|||
import { useQuasar } from 'quasar'; |
|||
import { axios, Environment, NotifyManager, PlatformIconEnum, Tools } from 'platform-core'; |
|||
|
|||
import TemplateParamsSelectDialog from './TemplateParamsSelectDialog.vue'; |
|||
import TemplateSetForeachPropsDialog from './TemplateSetForeachPropsDialog.vue'; |
|||
import TemplateSetColumnParamsDialog from './TemplateSetColumnParamsDialog.vue'; |
|||
|
|||
const $q = useQuasar(); |
|||
|
|||
const dialogRef = ref(); |
|||
const state = reactive({ |
|||
dialogTitle: '模板制定', |
|||
dataId: '', |
|||
}); |
|||
const dialog = { |
|||
buttons: [ |
|||
{ |
|||
icon: PlatformIconEnum.保存, |
|||
label: '保存', |
|||
click: () => { |
|||
save(); |
|||
}, |
|||
}, |
|||
], |
|||
}; |
|||
|
|||
const show = async (tableSelectedRow: any) => { |
|||
state.dialogTitle = '模板制定——' + tableSelectedRow.templateName + '(' + tableSelectedRow.templateCode + ')'; |
|||
state.dataId = tableSelectedRow.id; |
|||
dialogRef.value.show(); |
|||
nextTick(async () => { |
|||
if (window.luckysheet) { |
|||
window.luckysheet.destroy(); |
|||
} |
|||
const resp = await axios.get(Environment.apiContextPath('api/excel/template/') + state.dataId); |
|||
if (resp?.data?.templateConfig) { |
|||
luckysheetOptions.data = [eval('(' + resp.data.templateConfig + ')')]; |
|||
} |
|||
// eslint-disable-next-line |
|||
luckysheet.create(luckysheetOptions); |
|||
}); |
|||
}; |
|||
const hide = () => { |
|||
dialogRef.value.hide(); |
|||
}; |
|||
|
|||
const impFile = ref(null); |
|||
const paramsSelectDialogRef = ref(); |
|||
const setForeachPropsDialogRef = ref(); |
|||
const setColumnParamsDialogRef = ref(); |
|||
|
|||
const loadExcel = (value) => { |
|||
const { name } = value; |
|||
const suffixArr = name.split('.'); |
|||
const suffix = suffixArr[suffixArr.length - 1]; |
|||
if (suffix !== 'xlsx') { |
|||
NotifyManager.warn('只能导入 .xlsx 格式的Excel文件'); |
|||
return; |
|||
} |
|||
LuckyExcel.transformExcelToLucky(value, (exportJson) => { |
|||
if (exportJson.sheets === null || exportJson.sheets.length === 0) { |
|||
NotifyManager.warn('导入的Excel为空文件'); |
|||
return; |
|||
} |
|||
|
|||
window.luckysheet.destroy(); |
|||
|
|||
const data = [ |
|||
{ |
|||
...exportJson.sheets[0], |
|||
...{ |
|||
column: 26, |
|||
row: 30, |
|||
}, |
|||
}, |
|||
]; |
|||
luckysheetOptions.data = data; |
|||
window.luckysheet.create({ |
|||
lang: 'zh', |
|||
container: 'luckysheet', |
|||
showinfobar: false, |
|||
showtoolbar: true, // 是否显示工具栏,设置字体,边框,插入这些工具按钮。 |
|||
sheetFormulaBar: true, // 是否显示公式栏 |
|||
showsheetbar: false, // 是否显示底部sheet页按钮 |
|||
data: data, |
|||
title: exportJson.info.name, |
|||
userInfo: exportJson.info.name.creator, |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
const downloadExcel = () => { |
|||
// eslint-disable-next-line |
|||
exportExcel(luckysheet.getAllSheets(), '下载'); |
|||
}; |
|||
|
|||
const luckysheetData = [ |
|||
{ |
|||
name: 'Cell', // 工作表名称 |
|||
color: '', // 工作表颜色 |
|||
index: 0, // 工作表索引 |
|||
status: 1, // 激活状态 |
|||
order: 0, // 工作表的下标 |
|||
hide: 0, // 是否隐藏 |
|||
defaultRowHeight: 19, // 自定义行高 |
|||
defaultColWidth: 73, // 自定义列宽 |
|||
column: 26, |
|||
row: 30, |
|||
celldata: [], // 初始化使用的单元格数据 |
|||
config: { |
|||
merge: {}, // 合并单元格 |
|||
rowlen: {}, // 表格行高 |
|||
columnlen: {}, // 表格列宽 |
|||
rowhidden: {}, // 隐藏行 |
|||
colhidden: {}, // 隐藏列 |
|||
borderInfo: [], // 边框 |
|||
authority: {}, // 工作表保护 |
|||
}, |
|||
scrollLeft: 0, // 左右滚动条位置 |
|||
scrollTop: 0, // 上下滚动条位置 |
|||
luckysheet_select_save: [], // 选中的区域 |
|||
calcChain: [], // 公式链 |
|||
isPivotTable: false, // 是否数据透视表 |
|||
pivotTable: {}, // 数据透视表设置 |
|||
filter_select: {}, // 筛选范围 |
|||
filter: null, // 筛选配置 |
|||
luckysheet_alternateformat_save: [], // 交替颜色 |
|||
luckysheet_alternateformat_save_modelCustom: [], // 自定义交替颜色 |
|||
luckysheet_conditionformat_save: {}, // 条件格式 |
|||
frozen: {}, // 冻结行列配置 |
|||
chart: [], // 图表配置 |
|||
zoomRatio: 1, // 缩放比例 |
|||
image: [], // 图片 |
|||
showGridLines: 1, // 是否显示网格线 |
|||
dataVerification: {}, // 数据验证配置 |
|||
}, |
|||
]; |
|||
const luckysheetOptions = { |
|||
container: 'luckysheet', // 设定DOM容器的id |
|||
lang: 'zh', // 设定表格语言 |
|||
title: '测试', // 设定表格名称 |
|||
allowEdit: true, // 是否允许编辑 |
|||
rowHeaderWidth: 46, // 行标题区域的宽度,如果设置为0,则表示隐藏行标题,也就是表格第一行,A,B,C这行,默认值46 |
|||
columnHeaderHeight: 20, // 列标题区域的高度,如果设置为0,则表示隐藏列标题,也就是序号这一行,默认值20 |
|||
showtoolbar: true, // 是否显示工具栏,设置字体,边框,插入这些工具按钮。 |
|||
showinfobar: false, // 是否显示顶部信息栏,luckysheet的logo,表格名称这一栏。 |
|||
userInfo: 'likunming', // 右上角用户信息,若需要展示,必须配合showinfobar使用 |
|||
sheetFormulaBar: true, // 是否显示公式栏 |
|||
defaultFontSize: 11, // 初始化默认字体大小,默认11 |
|||
showsheetbar: false, // 是否显示底部sheet页按钮 |
|||
data: luckysheetData, // 表格数据 |
|||
}; |
|||
const selectParams = () => { |
|||
// eslint-disable-next-line |
|||
const selectRange = luckysheet.getRange(); |
|||
if (!selectRange || selectRange.length === 0) { |
|||
NotifyManager.warn('请选择要插入变量的Excel单元格'); |
|||
return; |
|||
} else if (selectRange && selectRange.length > 1) { |
|||
NotifyManager.warn('只支持单个选区选取变量'); |
|||
return; |
|||
} |
|||
paramsSelectDialogRef.value.show(state.dataId); |
|||
}; |
|||
const setParams = (paramsCode: string | Array<string>) => { |
|||
if (typeof paramsCode === 'string') { |
|||
// eslint-disable-next-line |
|||
let rangeValue = luckysheet.getRangeValue(); |
|||
rangeValue[0][0] = { ...rangeValue[0][0], ...{ m: paramsCode, v: paramsCode } }; |
|||
// eslint-disable-next-line |
|||
luckysheet.setRangeValue(rangeValue); |
|||
} else { |
|||
// eslint-disable-next-line |
|||
const currRange = luckysheet.getRange(); |
|||
paramsCode.forEach((item, index) => { |
|||
const tmpRangeValue = [[{ m: item, v: item }]]; |
|||
const tmp = { |
|||
row: [currRange[0].row[0], currRange[0].row[1]], |
|||
column: [currRange[0].column[0] + index, currRange[0].column[1] + index], |
|||
}; |
|||
// eslint-disable-next-line |
|||
luckysheet.setRangeValue(tmpRangeValue, { range: tmp }); |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
// eslint-disable-next-line |
|||
const psReg = /\@\{(.*)\}\@/; |
|||
const openConfigDialog = (configType) => { |
|||
// eslint-disable-next-line |
|||
const range = luckysheet.getRange(); |
|||
// eslint-disable-next-line |
|||
const rangeValue = luckysheet.getRangeValue(); |
|||
if (!range) { |
|||
NotifyManager.info('请选择要配置属性的单元格'); |
|||
return; |
|||
} else if (range && range.length > 1) { |
|||
NotifyManager.warn('多个选区无法配置属性,选择单元格既可'); |
|||
return; |
|||
} |
|||
let data = {}; |
|||
if (rangeValue[0] && rangeValue[0][0] && rangeValue[0][0].ps && rangeValue[0][0].ps.value) { |
|||
let tmp = rangeValue[0][0].ps.value.replaceAll('\n', ''); |
|||
data = JSON.parse(psReg.exec(tmp)[1]); |
|||
} |
|||
if (configType === 'main') { |
|||
setForeachPropsDialogRef.value.show(state.dataId, data); |
|||
} else { |
|||
setColumnParamsDialogRef.value.show(data); |
|||
} |
|||
}; |
|||
|
|||
const setForEachParams = (formData) => { |
|||
// eslint-disable-next-line |
|||
const range = luckysheet.getRange(); |
|||
let tmp = '@{{\n'; |
|||
Object.keys(formData).forEach((item) => { |
|||
if (!Tools.isEmpty(formData[item])) { |
|||
tmp += '"' + item + '"' + ':' + '"' + formData[item] + '"' + ',' + '\n'; |
|||
} |
|||
}); |
|||
tmp = tmp.substring(0, tmp.length - 2); |
|||
tmp += '\n}}@'; |
|||
// eslint-disable-next-line |
|||
luckysheet.insertComment(range[0].row[0], range[0].column[0], tmp); |
|||
// 插入批注后调整批注框大小 |
|||
luckysheetOptions.data[0].data[range[0].row[0]][range[0].column[0]].ps.width = 300; |
|||
luckysheetOptions.data[0].data[range[0].row[0]][range[0].column[0]].ps.height = 150; |
|||
luckysheetOptions.data[0].data[range[0].row[0]][range[0].column[0]].ps.isShow = false; |
|||
// eslint-disable-next-line |
|||
luckysheet.refresh(); |
|||
}; |
|||
const save = async () => { |
|||
// eslint-disable-next-line |
|||
if (!luckysheet.getAllSheets() || luckysheet.getAllSheets().length === 0) { |
|||
NotifyManager.warn('系统异常,未获取到需要保存的Sheet数据'); |
|||
return; |
|||
} |
|||
// 覆盖celldata数据缩减传给后端的数据量,该数据仅用以初始化表格,无需保存,初始化时可使用data属性。 |
|||
// eslint-disable-next-line |
|||
const saveData = { ...luckysheet.getAllSheets()[0], ...{ celldata: [] } }; |
|||
// 保存 |
|||
let requestParams = { |
|||
method: 'POST', |
|||
headers: { 'content-type': 'application/json;charset=utf-8;' }, |
|||
data: { templateConfig: JSON.stringify(saveData) }, |
|||
url: Environment.apiContextPath('api/excel/template/updateConfig/') + state.dataId, |
|||
}; |
|||
const resp = await axios(requestParams).catch((error) => { |
|||
console.info('error====', error); |
|||
NotifyManager.error('保存失败'); |
|||
}); |
|||
NotifyManager.info('保存成功'); |
|||
// dialogRef.value.dialogHide(); |
|||
}; |
|||
|
|||
const buttons = ref([ |
|||
{ |
|||
name: 'selectParams', |
|||
icon: 'find_in_page', |
|||
label: '选取变量', |
|||
click: selectParams, |
|||
}, |
|||
[ |
|||
{ |
|||
name: 'foreachPropsConfig', |
|||
icon: 'settings', |
|||
label: '循环属性配置', |
|||
}, |
|||
{ |
|||
name: 'mainConfig', |
|||
icon: 'build_circle', |
|||
label: '整体配置(首列)', |
|||
click: () => { |
|||
openConfigDialog('main'); |
|||
}, |
|||
}, |
|||
{ |
|||
name: 'columnConfig', |
|||
icon: 'build_circle', |
|||
label: '列配置(非首列)', |
|||
click: () => { |
|||
openConfigDialog('column'); |
|||
}, |
|||
}, |
|||
], |
|||
{ |
|||
name: 'download', |
|||
icon: 'download', |
|||
label: '导出文件', |
|||
click: downloadExcel, |
|||
}, |
|||
]); |
|||
|
|||
onBeforeMount(() => { |
|||
window.setInputZIndex = () => { |
|||
return true; |
|||
}; |
|||
window.setRightClickMenuZIndex = () => { |
|||
return true; |
|||
}; |
|||
}); |
|||
defineExpose({ |
|||
show, |
|||
hide, |
|||
}); |
|||
</script> |
|||
|
|||
<style scoped> |
|||
#luckysheet { |
|||
margin: 0px; |
|||
padding: 0px; |
|||
position: absolute; |
|||
width: 100%; |
|||
left: 0px; |
|||
top: 50px; |
|||
bottom: 0px; |
|||
} |
|||
</style> |
@ -0,0 +1,131 @@ |
|||
<template> |
|||
<div style="height: 100%"> |
|||
<w-grid |
|||
ref="templateGridRef" |
|||
title="Excel模板列表" |
|||
sort-no |
|||
:data-url="Environment.apiContextPath('api/excel/template')" |
|||
:query-form-cols-num="2" |
|||
:query-form-fields="templateGrid.queryFormFields" |
|||
:toolbar-actions="templateGrid.toolbarActions" |
|||
:columns="templateGrid.columns" |
|||
:editor="templateGrid.editor" |
|||
:viewer="templateGrid.viewer" |
|||
:sort-by="['-lastModifyDate']" |
|||
></w-grid> |
|||
<TemplateParamsDialog ref="templateParamsDialogRef"></TemplateParamsDialog> |
|||
<TemplateConfigDialog ref="templateConfigDialogRef"></TemplateConfigDialog> |
|||
<TemplateReportDialog ref="templateReportDialogRef"></TemplateReportDialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref } from 'vue'; |
|||
import { Environment } from 'platform-core'; |
|||
|
|||
import TemplateParamsDialog from './TemplateParamsDialog.vue'; |
|||
import TemplateConfigDialog from './TemplateConfigDialog.vue'; |
|||
import TemplateReportDialog from './TemplateReportDialog.vue'; |
|||
|
|||
const templateGridRef = ref(); |
|||
const templateParamsDialogRef = ref(); |
|||
const templateConfigDialogRef = ref(); |
|||
const templateReportDialogRef = ref(); |
|||
|
|||
const templateGrid = { |
|||
queryFormFields: [ |
|||
{ label: '模板编码', name: 'templateCode', type: 'w-text' }, |
|||
{ label: '模板名称', name: 'templateName', type: 'w-text' }, |
|||
], |
|||
toolbarActions: [ |
|||
'query', |
|||
'reset', |
|||
'separator', |
|||
[ |
|||
{ |
|||
name: 'operate', |
|||
icon: 'difference', |
|||
label: '操作', |
|||
}, |
|||
'add', |
|||
{ |
|||
extend: 'edit', |
|||
afterClick: (args) => { |
|||
args.grid.setEditDataUrl(Environment.apiContextPath('api/excel/template/updateField')); |
|||
}, |
|||
}, |
|||
'remove', |
|||
], |
|||
{ |
|||
name: 'params', |
|||
icon: 'settings', |
|||
label: '变量维护', |
|||
click: (args) => { |
|||
templateParamsDialogRef.value.show(args.selecteds); |
|||
}, |
|||
}, |
|||
{ |
|||
name: 'templateConfig', |
|||
icon: 'build_circle', |
|||
label: '模板制定', |
|||
enableIf: (args) => { |
|||
if (args.selected) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
}, |
|||
click: (args) => { |
|||
templateConfigDialogRef.value.show(args.selected); |
|||
}, |
|||
}, |
|||
'separator', |
|||
{ |
|||
name: 'reportView', |
|||
icon: 'visibility', |
|||
label: '报表查看', |
|||
enableIf: (args) => { |
|||
if (args.selected) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
}, |
|||
click: (args) => { |
|||
templateReportDialogRef.value.show(args.selected); |
|||
}, |
|||
}, |
|||
'separator', |
|||
], |
|||
columns: [ |
|||
{ name: 'templateCode', label: '模板编码' }, |
|||
{ name: 'templateName', label: '模板名称' }, |
|||
{ name: 'lastModifier', label: '最后修改人' }, |
|||
{ name: 'lastModifyDate', label: '最后修改时间' }, |
|||
], |
|||
editor: { |
|||
dialog: { |
|||
width: '50%', |
|||
height: '30%', |
|||
}, |
|||
form: { |
|||
colsNum: 1, |
|||
fields: [ |
|||
{ label: '模板编码', name: 'templateCode', type: 'w-text', requiredIf: true }, |
|||
{ label: '模板名称', name: 'templateName', type: 'w-text', requiredIf: true }, |
|||
], |
|||
}, |
|||
}, |
|||
viewer: { |
|||
panel: { |
|||
fields: [ |
|||
{ name: 'id', label: '模板ID' }, |
|||
{ name: 'templateCode', label: '模板编码' }, |
|||
{ name: 'templateName', label: '模板名称' }, |
|||
{ name: 'lastModifier', label: '最后修改人' }, |
|||
{ name: 'lastModifyDate', label: '最后修改时间' }, |
|||
], |
|||
}, |
|||
}, |
|||
}; |
|||
</script> |
@ -0,0 +1,464 @@ |
|||
<template> |
|||
<w-dialog ref="dialogRef" title="变量维护" :maximized="true"> |
|||
<w-grid |
|||
ref="templateParamsGridRef" |
|||
title="模板变量列表" |
|||
:auto-fetch-data="false" |
|||
:data-url="Environment.apiContextPath('api/excel/template/params')" |
|||
:sort-no="true" |
|||
:columns="templateParamsGrid.columns" |
|||
:toolbar-actions="templateParamsGrid.toolbarActions" |
|||
:query-form-cols-num="4" |
|||
:query-form-fields="templateParamsGrid.queryFormFields" |
|||
:pagination="{ |
|||
sortBy: 'lastModifyDate', |
|||
descending: true, |
|||
}" |
|||
></w-grid> |
|||
<w-dialog ref="templateParamsDialogRef" :title="state.templateParamsDialogTitle" width="80%" height="80%" :buttons="templateParamsDialog.buttons"> |
|||
<w-form ref="templateParamsAddEditFormRef" :cols-num="3" :fields="templateParamsDialog.formFields" class="p-1.5"> </w-form> |
|||
<w-grid |
|||
v-show="state.paramsType && state.paramsType === 'LIST'" |
|||
ref="templateParamsListFieldGridRef" |
|||
title="字段列表" |
|||
dense |
|||
:draggable="true" |
|||
:pageable="false" |
|||
:config-button="false" |
|||
:auto-fetch-data="false" |
|||
:fetch-data-url="Environment.apiContextPath('api/excel/template/params/list?sortBy=sortNo')" |
|||
:toolbar-actions="templateParamsListFieldGrid.toolbarActions" |
|||
:columns="templateParamsListFieldGrid.columns" |
|||
></w-grid> |
|||
<w-dialog |
|||
ref="templateParamsListFieldDialogRef" |
|||
:title="state.templateParamsListFieldDialogTitle" |
|||
width="60%" |
|||
height="50%" |
|||
:buttons="templateParamsListFieldDialog.buttons" |
|||
> |
|||
<w-form ref="templateParamsListFieldAddEditFormRef" :cols-num="1" :fields="templateParamsListFieldDialog.formFields" class="p-1.5"> </w-form> |
|||
</w-dialog> |
|||
</w-dialog> |
|||
</w-dialog> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, reactive, nextTick } from 'vue'; |
|||
import { axios, Environment, NotifyManager } from 'platform-core'; |
|||
|
|||
const dialogRef = ref(); |
|||
const templateParamsGridRef = ref(); |
|||
const templateParamsDialogRef = ref(); |
|||
const templateParamsAddEditFormRef = ref(); |
|||
const templateParamsListFieldGridRef = ref(); |
|||
const templateParamsListFieldDialogRef = ref(); |
|||
const templateParamsListFieldAddEditFormRef = ref(); |
|||
|
|||
const state = reactive({ |
|||
templateArray: [], |
|||
tableSelectedTemplateId: null, |
|||
paramsType: null, |
|||
templateParamsDialogTitle: '新增变量', |
|||
templateParamsListFieldDialogTitle: '新增字段', |
|||
}); |
|||
|
|||
const templateParamsGrid = { |
|||
queryFormFields: [ |
|||
{ label: '变量编码', name: 'paramsCode', type: 'w-text' }, |
|||
{ label: '变量名称', name: 'paramsName', type: 'w-text' }, |
|||
{ |
|||
label: '变量类型', |
|||
name: 'paramsType', |
|||
type: 'w-select', |
|||
queryOperator: 'equals', |
|||
options: [ |
|||
{ label: '单值', value: 'SING' }, |
|||
{ label: '列表', value: 'LIST' }, |
|||
], |
|||
}, |
|||
{ |
|||
label: '所属模板', |
|||
name: 'reportExcelTemplate', |
|||
queryOperator: 'equals', |
|||
type: 'w-select', |
|||
clearable: true, |
|||
colspan: 2, |
|||
options: [], |
|||
}, |
|||
], |
|||
toolbarActions: [ |
|||
'query', |
|||
'reset', |
|||
'separator', |
|||
{ |
|||
extend: 'add', |
|||
click: () => { |
|||
templateParamsDialogRef.value.show(); |
|||
}, |
|||
afterClick: () => { |
|||
templateParamsAddEditFormRef.value.setStatus('add'); |
|||
state.templateParamsDialogTitle = '新增变量'; |
|||
templateParamsAddEditFormRef.value.getFields()['reportExcelTemplate'].options = state.templateArray; |
|||
state.paramsType = null; |
|||
if (state.tableSelectedTemplateId) { |
|||
templateParamsAddEditFormRef.value.setFieldValue('paramsIsCommon', false); |
|||
templateParamsAddEditFormRef.value.setFieldValue('reportExcelTemplate', state.tableSelectedTemplateId); |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
extend: 'edit', |
|||
click: () => { |
|||
templateParamsDialogRef.value.show(); |
|||
}, |
|||
afterClick: (args) => { |
|||
templateParamsAddEditFormRef.value.setStatus('edit'); |
|||
state.templateParamsDialogTitle = '编辑变量'; |
|||
templateParamsAddEditFormRef.value.getFields()['reportExcelTemplate'].options = state.templateArray; |
|||
templateParamsAddEditFormRef.value.setData(args.selected); |
|||
state.paramsType = args.selected.paramsType; |
|||
if (args.selected['paramsIsCommon']) { |
|||
templateParamsAddEditFormRef.value.setFieldValue('reportExcelTemplate', null); |
|||
} else if (args.selected['reportExcelTemplate']) { |
|||
templateParamsAddEditFormRef.value.setFieldValue('reportExcelTemplate', args.selected['reportExcelTemplate']); |
|||
} |
|||
if (state.paramsType === 'LIST') { |
|||
const urlSearchParams = new URLSearchParams(); |
|||
urlSearchParams.append('criteria', JSON.stringify({ fieldName: 'reportExcelTemplateParams', operator: 'equals', value: args.selected.id })); |
|||
axios |
|||
.get(Environment.apiContextPath('api/excel/template/params/list?pageable=false&sortBy=sortNo'), { params: urlSearchParams }) |
|||
.then((resp) => { |
|||
if (resp.data.content) { |
|||
templateParamsListFieldGridRef.value.setLocalData(resp.data.content); |
|||
} |
|||
}) |
|||
.catch((error) => { |
|||
console.info('error====', error); |
|||
}); |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
extend: 'clone', |
|||
click: () => { |
|||
templateParamsDialogRef.value.show(); |
|||
}, |
|||
afterClick: (args) => { |
|||
templateParamsAddEditFormRef.value.setStatus('clone'); |
|||
state.templateParamsDialogTitle = '复制变量'; |
|||
templateParamsAddEditFormRef.value.getFields()['reportExcelTemplate'].options = state.templateArray; |
|||
templateParamsAddEditFormRef.value.setData(args.selected); |
|||
state.paramsType = args.selected.paramsType; |
|||
if (args.selected['paramsIsCommon']) { |
|||
templateParamsAddEditFormRef.value.setFieldValue('reportExcelTemplate', null); |
|||
} else if (args.selected['reportExcelTemplate']) { |
|||
templateParamsAddEditFormRef.value.setFieldValue('reportExcelTemplate', args.selected['reportExcelTemplate']); |
|||
} |
|||
if (state.paramsType === 'LIST') { |
|||
const urlSearchParams = new URLSearchParams(); |
|||
urlSearchParams.append('criteria', JSON.stringify({ fieldName: 'reportExcelTemplateParams', operator: 'equals', value: args.selected.id })); |
|||
axios |
|||
.get(Environment.apiContextPath('api/excel/template/params/list?pageable=false&sortBy=sortNo'), { params: urlSearchParams }) |
|||
.then((resp) => { |
|||
if (resp.data.content) { |
|||
templateParamsListFieldGridRef.value.setLocalData(resp.data.content); |
|||
} |
|||
}) |
|||
.catch((error) => { |
|||
console.info('error====', error); |
|||
}); |
|||
} |
|||
}, |
|||
}, |
|||
'remove', |
|||
'separator', |
|||
], |
|||
columns: [ |
|||
{ name: 'paramsCode', label: '变量编码' }, |
|||
{ name: 'paramsName', label: '变量名称' }, |
|||
{ |
|||
name: 'paramsType', |
|||
label: '变量类型', |
|||
format: (val, row) => { |
|||
if (val === 'SING') { |
|||
return '单值'; |
|||
} else if (val === 'LIST') { |
|||
return '列表'; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
name: 'paramsIsCommon', |
|||
label: '变量是否通用', |
|||
format: (val, row) => { |
|||
if (val === true) { |
|||
return '所有模板均可使用'; |
|||
} else if (val === false) { |
|||
return '指定模板可使用'; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
{ name: 'reportExcelTemplateName', label: '所属模板名称' }, |
|||
{ name: 'lastModifier', label: '最后修改人' }, |
|||
{ name: 'lastModifyDate', label: '最后修改时间' }, |
|||
], |
|||
}; |
|||
|
|||
const templateParamsDialog = { |
|||
buttons: [ |
|||
{ |
|||
icon: 'beenhere', |
|||
label: '提交', |
|||
click: async () => { |
|||
const validate = await templateParamsAddEditFormRef.value.validate(); |
|||
if (validate) { |
|||
const formStatus = templateParamsAddEditFormRef.value.getStatus(); |
|||
const formData = templateParamsAddEditFormRef.value.getData(); |
|||
if (formData.reportExcelTemplate) { |
|||
formData.reportExcelTemplate = { id: formData.reportExcelTemplate }; |
|||
} else { |
|||
formData.reportExcelTemplate = null; |
|||
} |
|||
const fieldRows = templateParamsListFieldGridRef.value.getRows(); |
|||
let url = Environment.apiContextPath('api/excel/template/params'); |
|||
if (formStatus === 'edit') { |
|||
url += '/edit'; |
|||
formData.id = templateParamsGridRef.value.getSelectedRows()[0].id; |
|||
fieldRows.forEach((item) => { |
|||
delete item.reportExcelTemplateParams; |
|||
}); |
|||
} else { |
|||
url += '/add'; |
|||
} |
|||
const resp = await axios |
|||
.post(url, { |
|||
params: formData, |
|||
list: formData.paramsType === 'LIST' ? fieldRows : [], |
|||
}) |
|||
.catch((error) => { |
|||
console.info('error====', error); |
|||
NotifyManager.error('操作失败'); |
|||
}); |
|||
NotifyManager.info('保存成功'); |
|||
templateParamsDialogRef.value.hide(); |
|||
templateParamsGridRef.value.refresh(); |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
icon: 'published_with_changes', |
|||
label: 'SQL校验', |
|||
click: async () => { |
|||
const paramsSqlValue = templateParamsAddEditFormRef.value.getFieldValue('paramsSql'); |
|||
if (!paramsSqlValue) { |
|||
NotifyManager.warn('取值SQL为空'); |
|||
return; |
|||
} |
|||
const requestParams = { |
|||
method: 'POST', |
|||
headers: { 'content-type': 'text/plain;charset=utf-8;' }, |
|||
data: paramsSqlValue, |
|||
url: Environment.apiContextPath('api/jdbc/fetchMetaDataBySql'), |
|||
}; |
|||
const resp = await axios(requestParams); |
|||
if (resp && resp.data) { |
|||
NotifyManager.info('校验通过'); |
|||
} else { |
|||
NotifyManager.error('校验失败'); |
|||
} |
|||
}, |
|||
}, |
|||
], |
|||
formFields: [ |
|||
{ label: '变量编码', name: 'paramsCode', type: 'w-text', requiredIf: true }, |
|||
{ label: '变量名称', name: 'paramsName', type: 'w-text', requiredIf: true }, |
|||
{ |
|||
label: '变量类型', |
|||
name: 'paramsType', |
|||
type: 'w-select', |
|||
requiredIf: true, |
|||
options: [ |
|||
{ label: '单值', value: 'SING' }, |
|||
{ label: '列表', value: 'LIST' }, |
|||
], |
|||
'onUpdate:modelValue': (value) => { |
|||
state.paramsType = value; |
|||
}, |
|||
}, |
|||
{ |
|||
label: '变量是否通用', |
|||
name: 'paramsIsCommon', |
|||
type: 'w-select', |
|||
requiredIf: true, |
|||
options: [ |
|||
{ label: '所有模板均可使用', value: true }, |
|||
{ label: '指定模板可使用', value: false }, |
|||
], |
|||
'onUpdate:modelValue': (value) => { |
|||
if (typeof value === 'boolean' && value === false) { |
|||
templateParamsAddEditFormRef.value.setFieldValue('reportExcelTemplate', state.tableSelectedTemplateId); |
|||
} else { |
|||
templateParamsAddEditFormRef.value.setFieldValue('reportExcelTemplate', null); |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
label: '所属模板', |
|||
name: 'reportExcelTemplate', |
|||
type: 'w-select', |
|||
colspan: 2, |
|||
requiredIf: true, |
|||
options: [], |
|||
showIf: (args) => { |
|||
const value = args.form?.getFieldValue('paramsIsCommon'); |
|||
if (typeof value === 'boolean' && value === false) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
label: '取值SQL', |
|||
name: 'paramsSql', |
|||
type: 'w-textarea', |
|||
requiredIf: true, |
|||
colspan: 'full', |
|||
}, |
|||
], |
|||
}; |
|||
|
|||
const templateParamsListFieldGrid = { |
|||
toolbarActions: [ |
|||
{ |
|||
name: 'generateFieldsBySql', |
|||
icon: 'playlist_add_circle', |
|||
label: '根据取值SQL生成', |
|||
click: async () => { |
|||
const paramsSqlValue = templateParamsAddEditFormRef.value.getFieldValue('paramsSql'); |
|||
if (!paramsSqlValue) { |
|||
NotifyManager.warn('取值SQL为空,无法生成'); |
|||
return; |
|||
} |
|||
const requestParams = { |
|||
method: 'POST', |
|||
headers: { 'content-type': 'text/plain;charset=utf-8;' }, |
|||
data: paramsSqlValue, |
|||
url: Environment.apiContextPath('api/jdbc/fetchMetaDataBySql'), |
|||
}; |
|||
const resp: any = await axios(requestParams).catch((error) => { |
|||
console.info('error====', error); |
|||
NotifyManager.error('操作失败'); |
|||
}); |
|||
const listFieldsRow = { name: '', desc: '' }; |
|||
const listFields = <any>[]; |
|||
if (resp.data) { |
|||
resp.data.forEach((item, index) => { |
|||
listFields.push({ ...listFieldsRow, ...{ sortNo: index + 1, name: item.columnName, type: item.columnTypeName } }); |
|||
}); |
|||
templateParamsListFieldGridRef.value.setLocalData(listFields); |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
extend: 'edit', |
|||
click: () => { |
|||
state.templateParamsListFieldDialogTitle = '编辑字段'; |
|||
templateParamsListFieldDialogRef.value.show(); |
|||
}, |
|||
afterClick: (args) => { |
|||
templateParamsListFieldAddEditFormRef.value.setStatus('edit'); |
|||
templateParamsListFieldAddEditFormRef.value.setData(args.selected); |
|||
}, |
|||
}, |
|||
{ |
|||
extend: 'remove', |
|||
click: (args) => { |
|||
if (args.tickeds) { |
|||
templateParamsListFieldGridRef.value.removeLocalData(args.tickeds); |
|||
} else { |
|||
templateParamsListFieldGridRef.value.removeLocalData(args.selecteds); |
|||
} |
|||
}, |
|||
}, |
|||
], |
|||
columns: [ |
|||
{ name: 'sortNo', label: '排序号' }, |
|||
{ name: 'name', label: '字段名' }, |
|||
{ name: 'desc', label: '字段描述' }, |
|||
], |
|||
}; |
|||
|
|||
const templateParamsListFieldDialog = { |
|||
buttons: [ |
|||
{ |
|||
icon: 'save', |
|||
label: '确定', |
|||
click: async () => { |
|||
const validateResult = await templateParamsListFieldAddEditFormRef.value.validate(); |
|||
if (validateResult) { |
|||
const formData = templateParamsListFieldAddEditFormRef.value.getData(); |
|||
const formStatus = templateParamsListFieldAddEditFormRef.value.getStatus(); |
|||
if (formStatus === 'add') { |
|||
templateParamsListFieldGridRef.value.addRow(formData, null); |
|||
} else { |
|||
templateParamsListFieldGridRef.value.replaceRow({ |
|||
...formData, |
|||
_rowKey_: templateParamsListFieldGridRef.value.getSelectedRows()[0]['_rowKey_'], |
|||
}); |
|||
} |
|||
templateParamsListFieldDialogRef.value.hide(); |
|||
} |
|||
}, |
|||
}, |
|||
], |
|||
formFields: [ |
|||
{ label: '字段名', name: 'name', type: 'w-text', requiredIf: true }, |
|||
{ label: '字段描述', name: 'desc', type: 'w-text' }, |
|||
], |
|||
}; |
|||
|
|||
const getTemplateListFun = async () => { |
|||
const resp = await axios.get(Environment.apiContextPath('api/excel/template?pageable=false')); |
|||
if (resp && resp.data?.content) { |
|||
const options = <any>[]; |
|||
resp.data.content.forEach((item) => { |
|||
options.push({ label: item.templateName, value: item.id }); |
|||
}); |
|||
state.templateArray = options; |
|||
templateParamsGridRef.value.getQueryForm().getFields()['reportExcelTemplate'].options = options; |
|||
|
|||
setTimeout(() => { |
|||
if (state.tableSelectedTemplateId) { |
|||
templateParamsGridRef.value.getQueryForm().setFieldValue('reportExcelTemplate', state.tableSelectedTemplateId); |
|||
} |
|||
// 设置完所属模板后加载变量列表的数据 |
|||
templateParamsGridRef.value.refresh(); |
|||
}, 100); |
|||
} |
|||
}; |
|||
const show = (tableSelected) => { |
|||
dialogRef.value.show(); |
|||
if (tableSelected && tableSelected.length > 0) { |
|||
state.tableSelectedTemplateId = tableSelected[0].id; |
|||
} else { |
|||
state.tableSelectedTemplateId = null; |
|||
} |
|||
nextTick(() => { |
|||
getTemplateListFun(); |
|||
}); |
|||
}; |
|||
const hide = () => { |
|||
dialogRef.value.hide(); |
|||
}; |
|||
|
|||
defineExpose({ |
|||
show, |
|||
hide, |
|||
}); |
|||
</script> |
@ -0,0 +1,234 @@ |
|||
<template> |
|||
<w-dialog ref="dialogRef" title="选取变量" width="80%" height="80%" :buttons="dialog.buttons"> |
|||
<div class="h-full"> |
|||
<div class="h-[300px]"> |
|||
<w-grid |
|||
ref="templateParamsGridRef" |
|||
dense |
|||
sort-no |
|||
title="模板变量列表" |
|||
:auto-fetch-data="false" |
|||
:data-url="Environment.apiContextPath('api/excel/template/params')" |
|||
:columns="templateParamsGrid.columns" |
|||
:toolbar-actions="templateParamsGrid.toolbarActions" |
|||
:config-button="false" |
|||
:query-form-cols-num="3" |
|||
:query-form-fields="templateParamsGrid.queryFormFields" |
|||
:sort-by="['-lastModifyDate']" |
|||
@row-click="templateParamsGridClick" |
|||
></w-grid> |
|||
</div> |
|||
<div style="height: calc(100% - 300px)"> |
|||
<w-grid |
|||
v-show="state.showListFieldGrid" |
|||
ref="templateParamsListFieldGridRef" |
|||
dense |
|||
sort-no |
|||
:config-button="false" |
|||
:hide-bottom="false" |
|||
:pageable="false" |
|||
title="字段列表" |
|||
:auto-fetch-data="false" |
|||
:fetch-data-url="Environment.apiContextPath('api/excel/template/params/list')" |
|||
:columns="templateParamsListFieldGrid.columns" |
|||
></w-grid> |
|||
</div> |
|||
</div> |
|||
</w-dialog> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, reactive, nextTick } from 'vue'; |
|||
import { useQuasar } from 'quasar'; |
|||
import { axios, Environment, NotifyManager, OperatorTypeEnum } from 'platform-core'; |
|||
|
|||
const $q = useQuasar(); |
|||
const emit = defineEmits<{ |
|||
( |
|||
e: 'setParams', // 设置模板变量 |
|||
paramsCode: string | Array<string>, // 变量编码(列表类型返回数组) |
|||
): void; |
|||
}>(); |
|||
|
|||
const dialogRef = ref(); |
|||
const templateParamsGridRef = ref(); |
|||
const templateParamsListFieldGridRef = ref(); |
|||
|
|||
const state = reactive({ |
|||
templateArray: [], |
|||
tableSelectedTemplateId: null, |
|||
showListFieldGrid: false, |
|||
}); |
|||
|
|||
const dialog = { |
|||
buttons: [ |
|||
{ |
|||
icon: 'save', |
|||
label: '确定', |
|||
click: async () => { |
|||
const paramsSelected = templateParamsGridRef.value.getSelectedRows(); |
|||
const listFieldSelected = templateParamsListFieldGridRef.value.getSelectedRows(); |
|||
if (paramsSelected && paramsSelected.length > 0) { |
|||
if (paramsSelected[0].paramsType === 'LIST' && (!listFieldSelected || listFieldSelected.length === 0)) { |
|||
const listFieldRows = templateParamsListFieldGridRef.value.getRows(); |
|||
const arr = <string[]>[]; |
|||
listFieldRows.forEach((item) => { |
|||
arr.push('#{' + item.name + '}'); |
|||
}); |
|||
emit('setParams', arr); |
|||
hide(); |
|||
return; |
|||
} else if (paramsSelected[0].paramsType === 'LIST' && listFieldSelected && listFieldSelected.length > 0) { |
|||
emit('setParams', '#{' + listFieldSelected[0].name + '}'); |
|||
hide(); |
|||
return; |
|||
} |
|||
} else { |
|||
NotifyManager.warn('请选择要插入的变量'); |
|||
return; |
|||
} |
|||
}, |
|||
}, |
|||
], |
|||
}; |
|||
|
|||
const templateParamsGrid = reactive({ |
|||
queryFormFields: [ |
|||
{ label: '变量名称', name: 'paramsName', type: 'w-text' }, |
|||
{ |
|||
label: '变量类型', |
|||
name: 'paramsType', |
|||
type: 'w-select', |
|||
queryOperator: 'equals', |
|||
options: [ |
|||
{ label: '单值', value: 'SING' }, |
|||
{ label: '列表', value: 'LIST' }, |
|||
], |
|||
}, |
|||
{ |
|||
label: '所属模板', |
|||
name: 'reportExcelTemplate', |
|||
type: 'w-select', |
|||
queryOperator: 'equals', |
|||
clearable: true, |
|||
colspan: 2, |
|||
options: [], |
|||
}, |
|||
], |
|||
toolbarActions: ['query', 'reset'], |
|||
columns: [ |
|||
{ name: 'paramsCode', label: '变量编码' }, |
|||
{ name: 'paramsName', label: '变量名称' }, |
|||
{ |
|||
name: 'paramsType', |
|||
label: '变量类型', |
|||
format: (val) => { |
|||
if (val === 'SING') { |
|||
return '单值'; |
|||
} else if (val === 'LIST') { |
|||
return '列表'; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
name: 'paramsIsCommon', |
|||
label: '变量是否通用', |
|||
format: (val) => { |
|||
if (val === true) { |
|||
return '所有模板均可使用'; |
|||
} else if (val === false) { |
|||
return '指定模板可使用'; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
{ name: 'reportExcelTemplateName', label: '所属模板名称' }, |
|||
{ name: 'lastModifier', label: '最后修改人' }, |
|||
{ name: 'lastModifyDate', label: '最后修改时间' }, |
|||
], |
|||
}); |
|||
|
|||
const templateParamsListFieldGrid = reactive({ |
|||
columns: [ |
|||
{ name: 'name', label: '字段名' }, |
|||
{ name: 'desc', label: '字段描述' }, |
|||
{ |
|||
name: 'formatType', |
|||
label: '格式化类型', |
|||
format: (val) => { |
|||
if (val && OperatorTypeEnum[val]) { |
|||
return OperatorTypeEnum[val]; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
{ name: 'formatValue', label: '格式化值' }, |
|||
], |
|||
}); |
|||
|
|||
const templateParamsGridClick = (args) => { |
|||
const { evt, row, index } = args; |
|||
if (row.paramsType === 'LIST') { |
|||
state.showListFieldGrid = true; |
|||
const urlSearchParams = new URLSearchParams(); |
|||
urlSearchParams.append('criteria', JSON.stringify({ fieldName: 'reportExcelTemplateParams', operator: 'equals', value: row.id })); |
|||
axios |
|||
.get(Environment.apiContextPath('api/excel/template/params/list?pageable=false&sortBy=sortNo'), { params: urlSearchParams }) |
|||
.then((resp) => { |
|||
if (resp.data.content) { |
|||
templateParamsListFieldGridRef.value.setLocalData(resp.data.content); |
|||
} |
|||
}) |
|||
.catch((error) => { |
|||
console.info('error====', error); |
|||
}); |
|||
} else { |
|||
// 清空字段列表 |
|||
templateParamsListFieldGridRef.value.setLocalData([]); |
|||
// 隐藏字段列表 |
|||
state.showListFieldGrid = false; |
|||
} |
|||
}; |
|||
const getTemplateListFun = async () => { |
|||
const resp = await axios.get(Environment.apiContextPath('api/excel/template?pageable=false')); |
|||
if (resp && resp.data?.content) { |
|||
const options = <any>[]; |
|||
resp.data.content.forEach((item) => { |
|||
options.push({ label: item.templateName, value: item.id }); |
|||
}); |
|||
state.templateArray = options; |
|||
templateParamsGridRef.value.getQueryForm().getFields()['reportExcelTemplate'].options = options; |
|||
|
|||
setTimeout(() => { |
|||
if (state.tableSelectedTemplateId) { |
|||
templateParamsGridRef.value.getQueryForm().setFieldValue('reportExcelTemplate', state.tableSelectedTemplateId); |
|||
} |
|||
// 设置完所属模板后加载变量列表的数据 |
|||
templateParamsGridRef.value.refresh(); |
|||
}, 100); |
|||
} |
|||
}; |
|||
const show = (templateId) => { |
|||
dialogRef.value.show(); |
|||
if (templateId) { |
|||
state.tableSelectedTemplateId = templateId; |
|||
} else { |
|||
state.tableSelectedTemplateId = null; |
|||
} |
|||
nextTick(() => { |
|||
getTemplateListFun(); |
|||
}); |
|||
}; |
|||
const hide = () => { |
|||
dialogRef.value.hide(); |
|||
}; |
|||
|
|||
defineExpose({ |
|||
show, |
|||
hide, |
|||
}); |
|||
</script> |
@ -0,0 +1,34 @@ |
|||
<template> |
|||
<w-dialog ref="dialogRef" :title="state.dialogTitle" width="100%" height="100%" :maximized="true" :can-maximize="false" body-padding="0px 0px 0px 0px"> |
|||
<ExcelReport v-if="state.dataId" ref="excelReportRef" :template-id="state.dataId" style="height: 100%"></ExcelReport> |
|||
</w-dialog> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, reactive } from 'vue'; |
|||
|
|||
import ExcelReport from './ExcelReport.vue'; |
|||
|
|||
const dialogRef = ref(); |
|||
const excelReportRef = ref(); |
|||
const state = reactive({ |
|||
dialogTitle: '模板制定', |
|||
dataId: '', |
|||
}); |
|||
|
|||
const show = (tableSelectedRow: any) => { |
|||
state.dataId = tableSelectedRow.id; |
|||
state.dialogTitle = '模板报表查看——' + tableSelectedRow.templateName + '(' + tableSelectedRow.templateCode + ')'; |
|||
dialogRef.value.show(); |
|||
}; |
|||
const hide = () => { |
|||
dialogRef.value.hide(); |
|||
}; |
|||
|
|||
defineExpose({ |
|||
show, |
|||
hide, |
|||
}); |
|||
</script> |
|||
|
|||
<style scoped></style> |
@ -0,0 +1,91 @@ |
|||
<template> |
|||
<w-dialog ref="dialogRef" title="属性配置" width="80%" height="80%" :buttons="dialog.buttons"> |
|||
<w-form ref="formRef" :cols-num="1" :fields="form.fields" class="p-1.5"> </w-form> |
|||
</w-dialog> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, nextTick } from 'vue'; |
|||
import { NotifyManager, Tools } from 'platform-core'; |
|||
|
|||
const emit = defineEmits<{ |
|||
( |
|||
e: 'setForEachParams', // 设置循环属性 |
|||
formData: any, // 循环属性对象 |
|||
): void; |
|||
}>(); |
|||
|
|||
const dialogRef = ref(); |
|||
const formRef = ref(); |
|||
|
|||
const dialog = { |
|||
buttons: [ |
|||
{ |
|||
icon: 'save', |
|||
label: '确定', |
|||
click: async () => { |
|||
const validate = await formRef.value.validate(); |
|||
if (validate) { |
|||
const formData = formRef.value.getData(); |
|||
let flag = false; |
|||
Object.keys(formData).forEach((item) => { |
|||
if (!Tools.isEmpty(formData[item])) { |
|||
flag = true; |
|||
} |
|||
}); |
|||
if (flag) { |
|||
emit('setForEachParams', formData); |
|||
dialogRef.value.hide(); |
|||
} else { |
|||
NotifyManager.warn('未配置任何属性'); |
|||
} |
|||
} |
|||
}, |
|||
}, |
|||
], |
|||
}; |
|||
const form = { |
|||
fields: [ |
|||
{ |
|||
label: '单元格格式', |
|||
name: 'cellFormat', |
|||
type: 'w-select', |
|||
options: [ |
|||
{ label: '纯文本', value: '1' }, |
|||
{ label: '数字格式-整数', value: '2' }, |
|||
{ label: '数字格式-两位小数', value: '3' }, |
|||
{ label: '数字格式-四位小数', value: '4' }, |
|||
{ label: '百分比整数', value: '5' }, |
|||
{ label: '百分比两位小数', value: '6' }, |
|||
{ label: '万元两位小数(示例:12万3456.00)', value: '7' }, |
|||
{ label: '千位符整数(示例:1,235)', value: '8' }, |
|||
{ label: '千位符两位小数(示例:1,234.56)', value: '9' }, |
|||
], |
|||
}, |
|||
{ |
|||
label: '单元格码值转换', |
|||
name: 'cellValueTransformed', |
|||
type: 'w-text', |
|||
hint: `当值匹配上时显示转换后的值,等号左边为原始值,右边为转换值,位置需对应,英文逗号分隔。示例:1,2=年,月 转换为空示例:-999=NULL`, |
|||
}, |
|||
{ label: '单元格批注', name: 'cellComment', type: 'w-textarea' }, |
|||
], |
|||
}; |
|||
|
|||
const show = (data) => { |
|||
dialogRef.value.show(); |
|||
nextTick(() => { |
|||
if (data) { |
|||
formRef.value.setData(data); |
|||
} |
|||
}); |
|||
}; |
|||
const hide = () => { |
|||
dialogRef.value.hide(); |
|||
}; |
|||
|
|||
defineExpose({ |
|||
show, |
|||
hide, |
|||
}); |
|||
</script> |
@ -0,0 +1,250 @@ |
|||
<template> |
|||
<w-dialog ref="dialogRef" title="属性配置" width="80%" height="80%" :buttons="dialog.buttons"> |
|||
<w-form ref="formRef" :cols-num="1" :fields="form.fields" class="p-1.5"></w-form> |
|||
<w-dialog ref="listParamsDialogRef" dialog-title="选择循环的列表名" width="70%" height="70%" :buttons="listParamsDialog.buttons"> |
|||
<w-grid |
|||
ref="templateParamsGridRef" |
|||
title="模板变量列表" |
|||
sort-no |
|||
dense |
|||
:checkbox-selection="false" |
|||
:auto-fetch-data="false" |
|||
:data-url="Environment.apiContextPath('api/excel/template/params')" |
|||
:columns="templateParamsGrid.columns" |
|||
:toolbar-actions="templateParamsGrid.toolbarActions" |
|||
:query-form-cols-num="2" |
|||
:query-form-row-num="2" |
|||
:query-form-fields="templateParamsGrid.queryFormFields" |
|||
:sort-by="['-lastModifyDate']" |
|||
></w-grid> |
|||
</w-dialog> |
|||
</w-dialog> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, reactive, nextTick } from 'vue'; |
|||
import { axios, Environment, NotifyManager, Tools } from 'platform-core'; |
|||
|
|||
const emit = defineEmits<{ |
|||
( |
|||
e: 'setForEachParams', // 设置循环属性 |
|||
formData: any, // 循环属性对象 |
|||
): void; |
|||
}>(); |
|||
|
|||
const dialogRef = ref(); |
|||
const formRef = ref(); |
|||
const listParamsDialogRef = ref(); |
|||
const templateParamsGridRef = ref(); |
|||
|
|||
const state = reactive({ |
|||
templateArray: [], |
|||
tableSelectedTemplateId: null, |
|||
}); |
|||
|
|||
const dialog = { |
|||
buttons: [ |
|||
{ |
|||
icon: 'save', |
|||
label: '确定', |
|||
click: async () => { |
|||
const validate = await formRef.value.validate(); |
|||
if (validate) { |
|||
const formData = formRef.value.getData(); |
|||
let flag = false; |
|||
Object.keys(formData).forEach((item) => { |
|||
if (!Tools.isEmpty(formData[item])) { |
|||
flag = true; |
|||
} |
|||
}); |
|||
if (flag) { |
|||
emit('setForEachParams', formData); |
|||
dialogRef.value.hide(); |
|||
} else { |
|||
NotifyManager.warn('未配置任何属性'); |
|||
} |
|||
} |
|||
}, |
|||
}, |
|||
], |
|||
}; |
|||
const templateParamsGrid = { |
|||
queryFormFields: [ |
|||
{ label: '变量编码', name: 'paramsCode', type: 'w-text' }, |
|||
{ label: '变量名称', name: 'paramsName', type: 'w-text' }, |
|||
{ |
|||
label: '所属模板', |
|||
name: 'reportExcelTemplate', |
|||
type: 'w-select', |
|||
clearable: true, |
|||
queryOperator: 'equals', |
|||
options: [], |
|||
}, |
|||
{ |
|||
label: '变量类型', |
|||
name: 'paramsType', |
|||
type: 'w-select', |
|||
queryOperator: 'equals', |
|||
options: [ |
|||
{ label: '单值', value: 'SING' }, |
|||
{ label: '列表', value: 'LIST' }, |
|||
], |
|||
}, |
|||
], |
|||
toolbarActions: ['query', 'reset', 'separator'], |
|||
columns: [ |
|||
{ name: 'paramsCode', label: '变量编码' }, |
|||
{ name: 'paramsName', label: '变量名称' }, |
|||
{ |
|||
name: 'paramsType', |
|||
label: '变量类型', |
|||
format: (val) => { |
|||
if (val === 'SING') { |
|||
return '单值'; |
|||
} else if (val === 'LIST') { |
|||
return '列表'; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
{ |
|||
name: 'paramsIsCommon', |
|||
label: '变量是否通用', |
|||
format: (val) => { |
|||
if (val === true) { |
|||
return '所有模板均可使用'; |
|||
} else if (val === false) { |
|||
return '指定模板可使用'; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
{ name: 'reportExcelTemplateName', label: '所属模板名称' }, |
|||
{ name: 'lastModifier', label: '最后修改人' }, |
|||
{ name: 'lastModifyDate', label: '最后修改时间' }, |
|||
], |
|||
}; |
|||
const form = { |
|||
fields: [ |
|||
{ |
|||
label: '循环的列表名', |
|||
name: 'listName', |
|||
type: 'w-grid-select', |
|||
requiredIf: true, |
|||
displayValue: 'paramsName', |
|||
grid: { |
|||
title: '模板变量列表', |
|||
primaryKey: 'paramsCode', |
|||
sortNo: true, |
|||
dense: true, |
|||
dataUrl: Environment.apiContextPath('api/excel/template/params'), |
|||
columns: templateParamsGrid.columns, |
|||
queryFormFields: templateParamsGrid.queryFormFields, |
|||
queryFormColsNum: 2, |
|||
queryFormRowNum: 2, |
|||
sortBy: ['-lastModifyDate'], |
|||
}, |
|||
}, |
|||
{ label: '循环列表中一行数据占几行', name: 'dataRowNum', type: 'w-number' }, |
|||
{ |
|||
label: '单元格值相等时字体加粗', |
|||
name: 'fontWeight', |
|||
type: 'w-text', |
|||
hint: `当值匹配上任意值字体加粗,英文逗号分隔。示例:合计,不适用`, |
|||
}, |
|||
{ |
|||
label: '单元格值相等时字体加粗-该行后续列都加粗', |
|||
name: 'fontWeightRow', |
|||
type: 'w-select', |
|||
options: [ |
|||
{ label: '是', value: 'true' }, |
|||
{ label: '否', value: 'false' }, |
|||
], |
|||
}, |
|||
{ |
|||
label: '单元格根据值设置背景色', |
|||
name: 'cellBgColor', |
|||
type: 'w-text', |
|||
hint: `当值匹配上时设置对应的背景色,等号左边为单元格值,右边为设置的背景色,位置需对应,英文逗号分隔。示例:不达标,达标,其他=#f44336,#2196f3,#bdbdbd`, |
|||
}, |
|||
{ |
|||
label: '单元格根据值设置背景色-该行后续列都设置相同背景色', |
|||
name: 'cellBgColorRow', |
|||
type: 'w-select', |
|||
options: [ |
|||
{ label: '是', value: 'true' }, |
|||
{ label: '否', value: 'false' }, |
|||
], |
|||
}, |
|||
{ |
|||
label: '单元格码值转换', |
|||
name: 'cellValueTransformed', |
|||
type: 'w-text', |
|||
hint: `当值匹配上时显示转换后的值,等号左边为原始值,右边为转换值,位置需对应,英文逗号分隔。示例:1,2=年,月 转换为空示例:-999=NULL`, |
|||
}, |
|||
{ label: '单元格批注', name: 'cellComment', type: 'w-textarea', rows: 2 }, |
|||
], |
|||
}; |
|||
|
|||
const listParamsDialog = { |
|||
buttons: [ |
|||
{ |
|||
icon: 'save', |
|||
label: '确定', |
|||
click: () => { |
|||
const tableSelected = templateParamsGridRef.value.getSelectedRows(); |
|||
if (!tableSelected || tableSelected.length === 0) { |
|||
NotifyManager.info('请选择模板变量'); |
|||
return; |
|||
} |
|||
formRef.value.setFieldValue('listName', tableSelected[0].paramsCode); |
|||
listParamsDialogRef.value.hide(); |
|||
}, |
|||
}, |
|||
], |
|||
}; |
|||
|
|||
const getTemplateListFun = async () => { |
|||
const resp = await axios.get(Environment.apiContextPath('api/excel/template?pageable=false')); |
|||
if (resp.data?.content) { |
|||
const options = <any>[]; |
|||
resp.data.content.forEach((item) => { |
|||
options.push({ label: item.templateName, value: item.id }); |
|||
}); |
|||
state.templateArray = options; |
|||
templateParamsGridRef.value.getQueryForm().getFields()['reportExcelTemplate'].options = options; |
|||
|
|||
setTimeout(() => { |
|||
if (state.tableSelectedTemplateId) { |
|||
templateParamsGridRef.value.getQueryForm().setFieldValue('reportExcelTemplate', state.tableSelectedTemplateId); |
|||
templateParamsGridRef.value.getQueryForm().setFieldValue('paramsType', 'LIST'); |
|||
} |
|||
templateParamsGridRef.value.refresh(); |
|||
}, 100); |
|||
} |
|||
}; |
|||
|
|||
const show = (templateId, data) => { |
|||
dialogRef.value.show(); |
|||
if (templateId) { |
|||
state.tableSelectedTemplateId = templateId; |
|||
} else { |
|||
state.tableSelectedTemplateId = null; |
|||
} |
|||
nextTick(() => { |
|||
if (data) { |
|||
formRef.value.setData(data); |
|||
} |
|||
}); |
|||
}; |
|||
const hide = () => { |
|||
dialogRef.value.hide(); |
|||
}; |
|||
|
|||
defineExpose({ |
|||
show, |
|||
hide, |
|||
}); |
|||
</script> |
@ -0,0 +1,339 @@ |
|||
<template> |
|||
<q-card ref="cardRef" flat bordered :style="cardHeightComponent"> |
|||
<q-card-section class="p-2.5"> |
|||
<div class="flex gap-2"> |
|||
<div class="grow"> |
|||
<q-file v-model="impFile" label="导入Excel文件" outlined dense accept=".xlsx,.xls" @update:model-value="loadExcel($event)"> |
|||
<template #append> |
|||
<q-icon name="attachment" /> |
|||
</template> |
|||
</q-file> |
|||
</div> |
|||
<div class="flex flex-none"> |
|||
<q-btn label="选取变量" :icon="PlatformIconEnum.选取变量" @click="selectParams"></q-btn> |
|||
</div> |
|||
<div class="flex flex-none"> |
|||
<q-btn-dropdown :icon="PlatformIconEnum.设置" label="循环属性配置" unelevated outline> |
|||
<q-list> |
|||
<q-item v-close-popup clickable> |
|||
<q-item-section> |
|||
<q-item-label @click="openConfigDialog('main')"><q-icon :name="PlatformIconEnum.更多查询"></q-icon> 整体配置(首列)</q-item-label> |
|||
</q-item-section> |
|||
</q-item> |
|||
<q-item v-close-popup clickable> |
|||
<q-item-section> |
|||
<q-item-label @click="openConfigDialog('column')"><q-icon :name="PlatformIconEnum.更多查询"></q-icon> 列配置(非首列)</q-item-label> |
|||
</q-item-section> |
|||
</q-item> |
|||
</q-list> |
|||
</q-btn-dropdown> |
|||
</div> |
|||
<div class="flex flex-none"> |
|||
<q-btn label="保存并关闭" :icon="PlatformIconEnum.保存" @click="save"></q-btn> |
|||
</div> |
|||
<div class="flex flex-none"> |
|||
<q-btn label="导出文件" :icon="PlatformIconEnum.下载" @click="downloadExcel"></q-btn> |
|||
</div> |
|||
</div> |
|||
</q-card-section> |
|||
<TemplateParamsSelectDialog ref="paramsSelectDialogRef" @set-params="setParams"></TemplateParamsSelectDialog> |
|||
<TemplateSetForEachParamsDialog ref="setForEachParamsDialogRef" @set-for-each-params="setForEachParams"></TemplateSetForEachParamsDialog> |
|||
<TemplateSetColumnParamsDialog ref="setColumnParamsDialogRef" @set-for-each-params="setForEachParams"></TemplateSetColumnParamsDialog> |
|||
<div id="luckysheet"></div> |
|||
</q-card> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref, onMounted, computed, reactive } from 'vue'; |
|||
import { useRoute, onBeforeRouteUpdate } from 'vue-router'; |
|||
import LuckyExcel from 'luckyexcel'; |
|||
import { exportExcel } from './export'; |
|||
import { useQuasar } from 'quasar'; |
|||
import { axios, TagViewManager, Environment, PlatformIconEnum, Tools, NotifyManager } from 'platform-core'; |
|||
|
|||
import TemplateParamsSelectDialog from '@/views/excel_template/TemplateParamsSelectDialog.vue'; |
|||
import TemplateSetForEachParamsDialog from '@/views/excel_template/TemplateSetForeachPropsDialog.vue'; |
|||
import TemplateSetColumnParamsDialog from '@/views/excel_template/TemplateSetColumnParamsDialog.vue'; |
|||
|
|||
const gc = Environment.getConfigure(); |
|||
const $q = useQuasar(); |
|||
const impFile = ref(null); |
|||
const paramsSelectDialogRef = ref(); |
|||
const setForEachParamsDialogRef = ref(); |
|||
const setColumnParamsDialogRef = ref(); |
|||
const route = useRoute(); |
|||
const cardRef = ref(); |
|||
console.info('route------------', route); |
|||
|
|||
// 路由变更时 |
|||
onBeforeRouteUpdate((to, from, next) => { |
|||
console.info('to------------', to); |
|||
initExcel(to.query.templateId); |
|||
next(); |
|||
}); |
|||
|
|||
const state = reactive({ |
|||
cardY: 0, |
|||
}); |
|||
|
|||
const cardHeightComponent = computed(() => { |
|||
// 浏览器可视区域高度 |
|||
const screenHeight = $q.screen.height; |
|||
// 系统底部高度(一般用来显示XX版权所有那一层) |
|||
const footerHeight = gc.theme.footer.enable ? gc.theme.footer.height : 0; |
|||
const cardHeight = screenHeight - footerHeight - state.cardY - 10; |
|||
return { |
|||
height: cardHeight + 'px', |
|||
}; |
|||
}); |
|||
|
|||
const loadExcel = (value) => { |
|||
const { name } = value; |
|||
const suffixArr = name.split('.'); |
|||
const suffix = suffixArr[suffixArr.length - 1]; |
|||
if (suffix !== 'xlsx') { |
|||
NotifyManager.info('只能导入xlsx格式的Excel文件'); |
|||
return; |
|||
} |
|||
LuckyExcel.transformExcelToLucky(value, (exportJson) => { |
|||
if (exportJson.sheets === null || exportJson.sheets.length === 0) { |
|||
NotifyManager.info(`只能导入'xlsx'格式的Excel文件`); |
|||
return; |
|||
} |
|||
|
|||
window.luckysheet.destroy(); |
|||
|
|||
const data = [ |
|||
{ |
|||
...exportJson.sheets[0], |
|||
...{ |
|||
column: 26, |
|||
row: 30, |
|||
}, |
|||
}, |
|||
]; |
|||
luckysheetOptions.data = data; |
|||
window.luckysheet.create({ |
|||
lang: 'zh', |
|||
container: 'luckysheet', |
|||
showinfobar: false, |
|||
showtoolbar: true, // 是否显示工具栏,设置字体,边框,插入这些工具按钮。 |
|||
sheetFormulaBar: true, // 是否显示公式栏 |
|||
showsheetbar: false, // 是否显示底部sheet页按钮 |
|||
data: data, |
|||
title: exportJson.info.name, |
|||
userInfo: exportJson.info.name.creator, |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
const downloadExcel = () => { |
|||
// eslint-disable-next-line |
|||
exportExcel(luckysheet.getAllSheets(), '下载'); |
|||
}; |
|||
|
|||
const luckysheetData = [ |
|||
{ |
|||
name: 'Cell', // 工作表名称 |
|||
color: '', // 工作表颜色 |
|||
index: 0, // 工作表索引 |
|||
status: 1, // 激活状态 |
|||
order: 0, // 工作表的下标 |
|||
hide: 0, // 是否隐藏 |
|||
defaultRowHeight: 19, // 自定义行高 |
|||
defaultColWidth: 73, // 自定义列宽 |
|||
column: 26, |
|||
row: 30, |
|||
celldata: [], // 初始化使用的单元格数据 |
|||
config: { |
|||
merge: {}, // 合并单元格 |
|||
rowlen: {}, // 表格行高 |
|||
columnlen: {}, // 表格列宽 |
|||
rowhidden: {}, // 隐藏行 |
|||
colhidden: {}, // 隐藏列 |
|||
borderInfo: [], // 边框 |
|||
authority: {}, // 工作表保护 |
|||
}, |
|||
scrollLeft: 0, // 左右滚动条位置 |
|||
scrollTop: 0, // 上下滚动条位置 |
|||
luckysheet_select_save: [], // 选中的区域 |
|||
calcChain: [], // 公式链 |
|||
isPivotTable: false, // 是否数据透视表 |
|||
pivotTable: {}, // 数据透视表设置 |
|||
filter_select: {}, // 筛选范围 |
|||
filter: null, // 筛选配置 |
|||
luckysheet_alternateformat_save: [], // 交替颜色 |
|||
luckysheet_alternateformat_save_modelCustom: [], // 自定义交替颜色 |
|||
luckysheet_conditionformat_save: {}, // 条件格式 |
|||
frozen: {}, // 冻结行列配置 |
|||
chart: [], // 图表配置 |
|||
zoomRatio: 1, // 缩放比例 |
|||
image: [], // 图片 |
|||
showGridLines: 1, // 是否显示网格线 |
|||
dataVerification: {}, // 数据验证配置 |
|||
}, |
|||
]; |
|||
const luckysheetOptions = { |
|||
container: 'luckysheet', // 设定DOM容器的id |
|||
lang: 'zh', // 设定表格语言 |
|||
title: '测试', // 设定表格名称 |
|||
allowEdit: true, // 是否允许编辑 |
|||
rowHeaderWidth: 46, // 行标题区域的宽度,如果设置为0,则表示隐藏行标题,也就是表格第一行,A,B,C这行,默认值46 |
|||
columnHeaderHeight: 20, // 列标题区域的高度,如果设置为0,则表示隐藏列标题,也就是序号这一行,默认值20 |
|||
showtoolbar: true, // 是否显示工具栏,设置字体,边框,插入这些工具按钮。 |
|||
showinfobar: false, // 是否显示顶部信息栏,luckysheet的logo,表格名称这一栏。 |
|||
userInfo: 'likunming', // 右上角用户信息,若需要展示,必须配合showinfobar使用 |
|||
sheetFormulaBar: true, // 是否显示公式栏 |
|||
defaultFontSize: 11, // 初始化默认字体大小,默认11 |
|||
showsheetbar: false, // 是否显示底部sheet页按钮 |
|||
data: luckysheetData, // 表格数据 |
|||
}; |
|||
const luckySheetEdit = () => { |
|||
luckysheetOptions.allowEdit = true; |
|||
luckysheetOptions.showtoolbar = true; |
|||
luckysheetOptions.sheetFormulaBar = true; |
|||
// eslint-disable-next-line |
|||
luckysheet.create(luckysheetOptions); |
|||
}; |
|||
const luckySheetSave = () => { |
|||
luckysheetOptions.allowEdit = false; |
|||
luckysheetOptions.showtoolbar = false; |
|||
luckysheetOptions.sheetFormulaBar = false; |
|||
// eslint-disable-next-line |
|||
luckysheet.create(luckysheetOptions); |
|||
}; |
|||
const selectParams = () => { |
|||
// eslint-disable-next-line |
|||
const selectRange = luckysheet.getRange(); |
|||
if (!selectRange || selectRange.length === 0) { |
|||
platformNotify($q, '请选择要插入变量的Excel单元格'); |
|||
return; |
|||
} else if (selectRange && selectRange.length > 1) { |
|||
platformNotify($q, '只支持单个选区选取变量'); |
|||
return; |
|||
} |
|||
paramsSelectDialogRef.value.dialogShow(route.query?.templateId); |
|||
}; |
|||
const setParams = (paramsCode: string | Array<string>) => { |
|||
if (typeof paramsCode === 'string') { |
|||
// eslint-disable-next-line |
|||
let rangeValue = luckysheet.getRangeValue(); |
|||
rangeValue[0][0] = { ...rangeValue[0][0], ...{ m: paramsCode, v: paramsCode } }; |
|||
// eslint-disable-next-line |
|||
luckysheet.setRangeValue(rangeValue); |
|||
} else { |
|||
// eslint-disable-next-line |
|||
const currRange = luckysheet.getRange(); |
|||
paramsCode.forEach((item, index) => { |
|||
const tmpRangeValue = [[{ m: item, v: item }]]; |
|||
const tmp = { |
|||
row: [currRange[0].row[0], currRange[0].row[1]], |
|||
column: [currRange[0].column[0] + index, currRange[0].column[1] + index], |
|||
}; |
|||
// eslint-disable-next-line |
|||
luckysheet.setRangeValue(tmpRangeValue, { range: tmp }); |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
// eslint-disable-next-line |
|||
const psReg = /\@\{(.*)\}\@/; |
|||
const openConfigDialog = (configType) => { |
|||
// eslint-disable-next-line |
|||
const range = luckysheet.getRange(); |
|||
// eslint-disable-next-line |
|||
const rangeValue = luckysheet.getRangeValue(); |
|||
if (!range) { |
|||
NotifyManager.info('请选择要配置属性的单元格'); |
|||
return; |
|||
} else if (range && range.length > 1) { |
|||
NotifyManager.info('多个选区无法配置属性,选择单元格既可'); |
|||
return; |
|||
} |
|||
let data = {}; |
|||
if (rangeValue[0] && rangeValue[0][0] && rangeValue[0][0].ps && rangeValue[0][0].ps.value) { |
|||
let tmp = rangeValue[0][0].ps.value.replaceAll('\n', ''); |
|||
data = JSON.parse(psReg.exec(tmp)[1]); |
|||
} |
|||
if (configType === 'main') { |
|||
setForEachParamsDialogRef.value.dialogShow(route.query?.templateId, data); |
|||
} else { |
|||
setColumnParamsDialogRef.value.dialogShow(data); |
|||
} |
|||
}; |
|||
|
|||
const setForEachParams = (formData) => { |
|||
// eslint-disable-next-line |
|||
const range = luckysheet.getRange(); |
|||
let tmp = '@{{\n'; |
|||
Object.keys(formData).forEach((item) => { |
|||
if (!Tools.isEmpty(formData[item])) { |
|||
tmp += '"' + item + '"' + ':' + '"' + formData[item] + '"' + ',' + '\n'; |
|||
} |
|||
}); |
|||
tmp = tmp.substring(0, tmp.length - 2); |
|||
tmp += '\n}}@'; |
|||
// eslint-disable-next-line |
|||
luckysheet.insertComment(range[0].row[0], range[0].column[0], tmp); |
|||
// 插入批注后调整批注框大小 |
|||
luckysheetOptions.data[0].data[range[0].row[0]][range[0].column[0]].ps.width = 300; |
|||
luckysheetOptions.data[0].data[range[0].row[0]][range[0].column[0]].ps.height = 150; |
|||
luckysheetOptions.data[0].data[range[0].row[0]][range[0].column[0]].ps.isShow = false; |
|||
// eslint-disable-next-line |
|||
luckysheet.refresh(); |
|||
}; |
|||
const save = async () => { |
|||
// eslint-disable-next-line |
|||
if (!luckysheet.getAllSheets() || luckysheet.getAllSheets().length === 0) { |
|||
NotifyManager.info('系统异常,未获取到需要保存的Sheet数据') |
|||
return; |
|||
} |
|||
// 覆盖celldata数据缩减传给后端的数据量,该数据仅用以初始化表格,无需保存,初始化时可使用data属性。 |
|||
// eslint-disable-next-line |
|||
const saveData = { ...luckysheet.getAllSheets()[0], ...{ celldata: [] } }; |
|||
// 保存 |
|||
let requestParams = { |
|||
method: 'POST', |
|||
headers: { 'content-type': 'application/json;charset=utf-8;' }, |
|||
data: { templateConfig: JSON.stringify(saveData) }, |
|||
url: Environment.apiContextPath('api/excel/template/updateConfig/') + route.query.templateId, |
|||
}; |
|||
const resp = await axios(requestParams).catch((error) => { |
|||
console.info('error====', error); |
|||
NotifyManager.error('保存失败'); |
|||
}); |
|||
NotifyManager.error('保存成功') |
|||
// 关闭当前页 |
|||
// const index = TagViewManager.getTagViews().findIndex((item) => item.fullPath.indexOf(route.query.templateId) > -1); |
|||
TagViewManager.removeTagView({ mode: 'current' }); |
|||
}; |
|||
|
|||
const initExcel = async (templateId?: any) => { |
|||
if (window.luckysheet) { |
|||
window.luckysheet.destroy(); |
|||
} |
|||
const resp = await axios.get(Environment.apiContextPath('api/excel/template/') + (templateId ?? route.query.templateId)); |
|||
if (resp?.data?.templateConfig) { |
|||
luckysheetOptions.data = [eval('(' + resp.data.templateConfig + ')')]; |
|||
} |
|||
// eslint-disable-next-line |
|||
luckysheet.create(luckysheetOptions); |
|||
}; |
|||
|
|||
onMounted(async () => { |
|||
state.cardY = cardRef.value.$el.getBoundingClientRect()?.y; |
|||
initExcel(); |
|||
}); |
|||
</script> |
|||
|
|||
<style scoped> |
|||
#luckysheet { |
|||
margin: 0px; |
|||
padding: 0px; |
|||
position: absolute; |
|||
width: 100%; |
|||
left: 0px; |
|||
top: 70px; |
|||
bottom: 0px; |
|||
} |
|||
</style> |
@ -0,0 +1,319 @@ |
|||
import Excel from 'exceljs'; |
|||
import FileSaver from 'file-saver'; |
|||
|
|||
const exportExcel = function (luckysheet, value) { |
|||
// 参数为luckysheet.getluckysheetfile()获取的对象
|
|||
// 1.创建工作簿,可以为工作簿添加属性
|
|||
const workbook = new Excel.Workbook(); |
|||
// 2.创建表格,第二个参数可以配置创建什么样的工作表
|
|||
if (Object.prototype.toString.call(luckysheet) === '[object Object]') { |
|||
luckysheet = [luckysheet]; |
|||
} |
|||
luckysheet.forEach(function (table) { |
|||
if (table.data.length === 0) return true; |
|||
// ws.getCell('B2').fill = fills.
|
|||
const worksheet = workbook.addWorksheet(table.name); |
|||
const merge = (table.config && table.config.merge) || {}; |
|||
const borderInfo = (table.config && table.config.borderInfo) || {}; |
|||
// 3.设置单元格合并,设置单元格边框,设置单元格样式,设置值
|
|||
setStyleAndValue(table.data, worksheet); |
|||
setMerge(merge, worksheet); |
|||
setBorder(borderInfo, worksheet); |
|||
return true; |
|||
}); |
|||
|
|||
// return
|
|||
// 4.写入 buffer
|
|||
const buffer = workbook.xlsx.writeBuffer().then((data) => { |
|||
// console.log('data', data)
|
|||
const blob = new Blob([data], { |
|||
type: 'application/vnd.ms-excel;charset=utf-8', |
|||
}); |
|||
console.log('导出成功!'); |
|||
FileSaver.saveAs(blob, `${value}.xlsx`); |
|||
}); |
|||
return buffer; |
|||
}; |
|||
|
|||
var setMerge = function (luckyMerge = {}, worksheet) { |
|||
const mergearr = Object.values(luckyMerge); |
|||
mergearr.forEach(function (elem) { |
|||
// elem格式:{r: 0, c: 0, rs: 1, cs: 2}
|
|||
// 按开始行,开始列,结束行,结束列合并(相当于 K10:M12)
|
|||
worksheet.mergeCells(elem.r + 1, elem.c + 1, elem.r + elem.rs, elem.c + elem.cs); |
|||
}); |
|||
}; |
|||
|
|||
var setBorder = function (luckyBorderInfo, worksheet) { |
|||
if (!Array.isArray(luckyBorderInfo)) return; |
|||
// console.log('luckyBorderInfo', luckyBorderInfo)
|
|||
luckyBorderInfo.forEach(function (elem) { |
|||
// 现在只兼容到borderType 为range的情况
|
|||
// console.log('ele', elem)
|
|||
if (elem.rangeType === 'range') { |
|||
let border = borderConvert(elem.borderType, elem.style, elem.color); |
|||
let rang = elem.range[0]; |
|||
// console.log('range', rang)
|
|||
let row = rang.row; |
|||
let column = rang.column; |
|||
for (let i = row[0] + 1; i < row[1] + 2; i++) { |
|||
for (let y = column[0] + 1; y < column[1] + 2; y++) { |
|||
worksheet.getCell(i, y).border = border; |
|||
} |
|||
} |
|||
} |
|||
if (elem.rangeType === 'cell') { |
|||
// col_index: 2
|
|||
// row_index: 1
|
|||
// b: {
|
|||
// color: '#d0d4e3'
|
|||
// style: 1
|
|||
// }
|
|||
const { col_index, row_index } = elem.value; |
|||
const borderData = Object.assign({}, elem.value); |
|||
delete borderData.col_index; |
|||
delete borderData.row_index; |
|||
let border = addborderToCell(borderData, row_index, col_index); |
|||
// console.log('bordre', border, borderData)
|
|||
worksheet.getCell(row_index + 1, col_index + 1).border = border; |
|||
} |
|||
// console.log(rang.column_focus + 1, rang.row_focus + 1)
|
|||
// worksheet.getCell(rang.row_focus + 1, rang.column_focus + 1).border = border
|
|||
}); |
|||
}; |
|||
var setStyleAndValue = function (cellArr, worksheet) { |
|||
if (!Array.isArray(cellArr)) return; |
|||
cellArr.forEach(function (row, rowid) { |
|||
row.every(function (cell, columnid) { |
|||
if (!cell) return true; |
|||
let fill = fillConvert(cell.bg); |
|||
|
|||
let font = fontConvert(cell.ff, cell.fc, cell.bl, cell.it, cell.fs, cell.cl, cell.ul); |
|||
let alignment = alignmentConvert(cell.vt, cell.ht, cell.tb, cell.tr); |
|||
let value = ''; |
|||
|
|||
if (cell.f) { |
|||
value = { formula: cell.f, result: cell.v }; |
|||
} else if (!cell.v && cell.ct && cell.ct.s) { |
|||
// xls转为xlsx之后,内部存在不同的格式,都会进到富文本里,即值不存在与cell.v,而是存在于cell.ct.s之后
|
|||
// value = cell.ct.s[0].v
|
|||
cell.ct.s.forEach((arr) => { |
|||
value += arr.v; |
|||
}); |
|||
} else { |
|||
value = cell.v; |
|||
} |
|||
// style 填入到_value中可以实现填充色
|
|||
let letter = createCellPos(columnid); |
|||
let target = worksheet.getCell(letter + (rowid + 1)); |
|||
// console.log('1233', letter + (rowid + 1))
|
|||
for (const key in fill) { |
|||
target.fill = fill; |
|||
break; |
|||
} |
|||
target.font = font; |
|||
target.alignment = alignment; |
|||
target.value = value; |
|||
|
|||
return true; |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
var fillConvert = function (bg) { |
|||
if (!bg) { |
|||
return {}; |
|||
} |
|||
// const bgc = bg.replace('#', '')
|
|||
let fill = { |
|||
type: 'pattern', |
|||
pattern: 'solid', |
|||
fgColor: { argb: bg.replace('#', '') }, |
|||
}; |
|||
return fill; |
|||
}; |
|||
|
|||
var fontConvert = function (ff = 0, fc = '#000000', bl = 0, it = 0, fs = 10, cl = 0, ul = 0) { |
|||
// luckysheet:ff(样式), fc(颜色), bl(粗体), it(斜体), fs(大小), cl(删除线), ul(下划线)
|
|||
const luckyToExcel = { |
|||
0: '微软雅黑', |
|||
1: '宋体(Song)', |
|||
2: '黑体(ST Heiti)', |
|||
3: '楷体(ST Kaiti)', |
|||
4: '仿宋(ST FangSong)', |
|||
5: '新宋体(ST Song)', |
|||
6: '华文新魏', |
|||
7: '华文行楷', |
|||
8: '华文隶书', |
|||
9: 'Arial', |
|||
10: 'Times New Roman ', |
|||
11: 'Tahoma ', |
|||
12: 'Verdana', |
|||
num2bl: function (num) { |
|||
return num === 0 ? false : true; |
|||
}, |
|||
}; |
|||
// 出现Bug,导入的时候ff为luckyToExcel的val
|
|||
|
|||
let font = { |
|||
name: typeof ff === 'number' ? luckyToExcel[ff] : ff, |
|||
family: 1, |
|||
size: fs, |
|||
color: { argb: fc.replace('#', '') }, |
|||
bold: luckyToExcel.num2bl(bl), |
|||
italic: luckyToExcel.num2bl(it), |
|||
underline: luckyToExcel.num2bl(ul), |
|||
strike: luckyToExcel.num2bl(cl), |
|||
}; |
|||
|
|||
return font; |
|||
}; |
|||
|
|||
var alignmentConvert = function (vt = 'default', ht = 'default', tb = 'default', tr = 'default') { |
|||
// luckysheet:vt(垂直), ht(水平), tb(换行), tr(旋转)
|
|||
const luckyToExcel = { |
|||
vertical: { |
|||
0: 'middle', |
|||
1: 'top', |
|||
2: 'bottom', |
|||
default: 'top', |
|||
}, |
|||
horizontal: { |
|||
0: 'center', |
|||
1: 'left', |
|||
2: 'right', |
|||
default: 'left', |
|||
}, |
|||
wrapText: { |
|||
0: false, |
|||
1: false, |
|||
2: true, |
|||
default: false, |
|||
}, |
|||
textRotation: { |
|||
0: 0, |
|||
1: 45, |
|||
2: -45, |
|||
3: 'vertical', |
|||
4: 90, |
|||
5: -90, |
|||
default: 0, |
|||
}, |
|||
}; |
|||
|
|||
let alignment = { |
|||
vertical: luckyToExcel.vertical[vt], |
|||
horizontal: luckyToExcel.horizontal[ht], |
|||
wrapText: luckyToExcel.wrapText[tb], |
|||
textRotation: luckyToExcel.textRotation[tr], |
|||
}; |
|||
return alignment; |
|||
}; |
|||
|
|||
var borderConvert = function (borderType, style = 1, color = '#000') { |
|||
// 对应luckysheet的config中borderinfo的的参数
|
|||
if (!borderType) { |
|||
return {}; |
|||
} |
|||
const luckyToExcel = { |
|||
type: { |
|||
'border-all': 'all', |
|||
'border-top': 'top', |
|||
'border-right': 'right', |
|||
'border-bottom': 'bottom', |
|||
'border-left': 'left', |
|||
}, |
|||
style: { |
|||
0: 'none', |
|||
1: 'thin', |
|||
2: 'hair', |
|||
3: 'dotted', |
|||
4: 'dashDot', // 'Dashed',
|
|||
5: 'dashDot', |
|||
6: 'dashDotDot', |
|||
7: 'double', |
|||
8: 'medium', |
|||
9: 'mediumDashed', |
|||
10: 'mediumDashDot', |
|||
11: 'mediumDashDotDot', |
|||
12: 'slantDashDot', |
|||
13: 'thick', |
|||
}, |
|||
}; |
|||
let template = { |
|||
style: luckyToExcel.style[style], |
|||
color: { argb: color.replace('#', '') }, |
|||
}; |
|||
let border = {}; |
|||
if (luckyToExcel.type[borderType] === 'all') { |
|||
border['top'] = template; |
|||
border['right'] = template; |
|||
border['bottom'] = template; |
|||
border['left'] = template; |
|||
} else { |
|||
border[luckyToExcel.type[borderType]] = template; |
|||
} |
|||
// console.log('border', border)
|
|||
return border; |
|||
}; |
|||
|
|||
function addborderToCell(borders, row_index, col_index) { |
|||
let border = {}; |
|||
const luckyExcel = { |
|||
type: { |
|||
l: 'left', |
|||
r: 'right', |
|||
b: 'bottom', |
|||
t: 'top', |
|||
}, |
|||
style: { |
|||
0: 'none', |
|||
1: 'thin', |
|||
2: 'hair', |
|||
3: 'dotted', |
|||
4: 'dashDot', // 'Dashed',
|
|||
5: 'dashDot', |
|||
6: 'dashDotDot', |
|||
7: 'double', |
|||
8: 'medium', |
|||
9: 'mediumDashed', |
|||
10: 'mediumDashDot', |
|||
11: 'mediumDashDotDot', |
|||
12: 'slantDashDot', |
|||
13: 'thick', |
|||
}, |
|||
}; |
|||
// console.log('borders', borders)
|
|||
for (const bor in borders) { |
|||
// console.log(bor)
|
|||
if (borders[bor].color.indexOf('rgb') === -1) { |
|||
border[luckyExcel.type[bor]] = { |
|||
style: luckyExcel.style[borders[bor].style], |
|||
color: { argb: borders[bor].color.replace('#', '') }, |
|||
}; |
|||
} else { |
|||
border[luckyExcel.type[bor]] = { |
|||
style: luckyExcel.style[borders[bor].style], |
|||
color: { argb: borders[bor].color }, |
|||
}; |
|||
} |
|||
} |
|||
|
|||
return border; |
|||
} |
|||
|
|||
function createCellPos(n) { |
|||
let ordA = 'A'.charCodeAt(0); |
|||
|
|||
let ordZ = 'Z'.charCodeAt(0); |
|||
let len = ordZ - ordA + 1; |
|||
let s = ''; |
|||
while (n >= 0) { |
|||
s = String.fromCharCode((n % len) + ordA) + s; |
|||
|
|||
n = Math.floor(n / len) - 1; |
|||
} |
|||
return s; |
|||
} |
|||
|
|||
export { exportExcel }; |
@ -0,0 +1,27 @@ |
|||
const cellFormatMap = new Map(); |
|||
// 纯文本
|
|||
cellFormatMap.set('1', { fa: '@', t: 's' }); |
|||
// 数字格式-整数
|
|||
cellFormatMap.set('2', { fa: '0', t: 'n' }); |
|||
// 数字格式-两位小数
|
|||
cellFormatMap.set('3', { fa: '0.00', t: 'n' }); |
|||
// 数字格式-四位小数
|
|||
cellFormatMap.set('4', { fa: '0.0000', t: 'n' }); |
|||
// 百分比整数
|
|||
cellFormatMap.set('5', { fa: '0%', t: 'n' }); |
|||
// 百分比两位小数
|
|||
cellFormatMap.set('6', { fa: '0.00%', t: 'n' }); |
|||
// 万元两位小数(示例:12万3456.00)
|
|||
cellFormatMap.set('7', { fa: 'w0.00', t: 'n' }); |
|||
// 千位符整数(示例:1,235)
|
|||
cellFormatMap.set('8', { fa: '#,##0', t: 'n' }); |
|||
// 千位符两位小数(示例:1,234.56)
|
|||
cellFormatMap.set('9', { fa: '#,##0.00', t: 'n' }); |
|||
|
|||
/** |
|||
* 根据下拉框所选值获取单元格格式化对象 |
|||
* @param index |
|||
*/ |
|||
export function getExcelCellFormatObject(index: string) { |
|||
return cellFormatMap.get(index); |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,362 @@ |
|||
<template> |
|||
<div v-if="state.isReload && state.pageType === PageTemplateType.GRID" :class="props.configId ? 'pt-2.5' : ''" style="height: 100%"> |
|||
<GridPage |
|||
ref="gridPageRef" |
|||
:platform-grid-config="state.pageConfig" |
|||
:grid-before-request-data="gridBeforeRequestData" |
|||
:grid-before-editor-data-submit="gridBeforeEditorDataSubmit" |
|||
></GridPage> |
|||
</div> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { reactive, ref, onMounted, nextTick, watch } from 'vue'; |
|||
import { useRoute, onBeforeRouteUpdate } from 'vue-router'; |
|||
import { axios, Environment, OptionComeFromEnum, FormTypeEnum, Tools } from 'platform-core'; |
|||
|
|||
import { getPageConfig, PageTemplateType } from './page.ts'; |
|||
import GridPage from './grid/GridPage.vue'; |
|||
|
|||
const gridPageRef = ref(); |
|||
const props = defineProps({ |
|||
configId: { type: String, default: '' }, |
|||
gridBeforeRequestData: { type: Function, default: () => {} }, |
|||
gridBeforeEditorDataSubmit: { type: Function, default: () => {} }, |
|||
gridInitLoadData: { type: Boolean, default: false }, |
|||
}); |
|||
|
|||
const route = useRoute(); |
|||
const state = reactive({ |
|||
isReload: true, |
|||
pageType: '', |
|||
pageConfig: {}, |
|||
}); |
|||
|
|||
watch( |
|||
() => props.configId, |
|||
(newVal, oldVal) => { |
|||
reload(); |
|||
}, |
|||
); |
|||
|
|||
// onBeforeRouteUpdate((to, from, next) => { |
|||
// // if (!Tools.isEmpty(to.query?.id) && !Tools.isEmpty(from.query?.id) && to.query.id !== from.query.id) { |
|||
// // reload(); |
|||
// // } |
|||
// next(); |
|||
// }); |
|||
|
|||
const reload = () => { |
|||
state.isReload = false; |
|||
nextTick(() => { |
|||
state.isReload = true; |
|||
getConfig(); |
|||
}); |
|||
}; |
|||
|
|||
const getJsonStr = async () => { |
|||
// 两种接收参数的方式,一种是页面嵌套该组件为子组件,将configId传进来,另一种是通过路由将参数传进来。 |
|||
const result = await getPageConfig((props.configId ? props.configId : route.query.id) as string); |
|||
if (result) { |
|||
state.pageConfig = eval('(' + result.config + ')'); |
|||
state.pageType = result.type; |
|||
} |
|||
}; |
|||
const getSelectOptions = async (configItem) => { |
|||
let options = []; |
|||
if (configItem.fieldIsSelect && configItem.optionComeFrom === OptionComeFromEnum.数据字典) { |
|||
// 数据字典选项值 |
|||
} else if (configItem.fieldIsSelect && configItem.optionComeFrom === OptionComeFromEnum.Java接口) { |
|||
// java返回的选项值 |
|||
} else if (configItem.fieldIsSelect && configItem.optionComeFrom === OptionComeFromEnum.自定义数组) { |
|||
// 自定义数组 |
|||
options = eval('(' + configItem.otherOptionValue + ')'); |
|||
} else if (configItem.fieldIsSelect && configItem.optionComeFrom === 'sql') { |
|||
const requestParams = { |
|||
method: 'POST', |
|||
headers: { 'content-type': 'text/plain;charset=utf-8;' }, |
|||
data: configItem.otherOptionValue, |
|||
url: Environment.apiContextPath('api/jdbc/fetchDataBySql'), |
|||
}; |
|||
const resp = await axios(requestParams); |
|||
options = resp.data; |
|||
} |
|||
return options; |
|||
}; |
|||
const getConfig = async () => { |
|||
const resp = await axios.get(Environment.apiContextPath('api/template/config/fetch/') + (props.configId ? props.configId : route.query.id)); |
|||
if (resp && resp.data && resp.data.templateConfig?.templatePageLoadType === 'JSON') { |
|||
getJsonStr(); |
|||
} else if (resp && resp.data) { |
|||
const templateConfig = resp.data.templateConfig; |
|||
const templateGrid = resp.data.templateGrid; |
|||
const templateGridFields = resp.data.templateGridFields; |
|||
|
|||
// 处理分页排序 |
|||
const tablePagination = { |
|||
// sortBy: '', |
|||
// descending: true, |
|||
reqPageStart: 0, |
|||
rowsPerPage: 10, |
|||
}; |
|||
let defaultSortBy = undefined; |
|||
if (templateGrid.defaultSortBy) { |
|||
try { |
|||
defaultSortBy = eval('(' + templateGrid.defaultSortBy + ')'); |
|||
} catch (error) { |
|||
console.error('sortBy eval error!'); |
|||
} |
|||
// tablePagination.sortBy = templateGrid.defaultSortBy; |
|||
// tablePagination.descending = templateGrid.descending; |
|||
} |
|||
if (templateGrid.reqPageStart) { |
|||
tablePagination.reqPageStart = templateGrid.reqPageStart; |
|||
} |
|||
if (templateGrid.rowsPerPage) { |
|||
tablePagination.rowsPerPage = templateGrid.rowsPerPage; |
|||
} |
|||
|
|||
// 处理按钮 |
|||
const tableButtons = <any>[]; |
|||
let configButton = false; |
|||
if (templateGrid.buttons && templateGrid.buttons.length > 0) { |
|||
templateGrid.buttons.forEach((item) => { |
|||
if (item !== 'config') { |
|||
tableButtons.push(item); |
|||
} else { |
|||
configButton = true; |
|||
} |
|||
}); |
|||
} |
|||
|
|||
// 处理紧凑模式 |
|||
const dense = { |
|||
dense: false, |
|||
denseToolbar: false, |
|||
denseHeader: false, |
|||
denseBody: false, |
|||
denseBottom: false, |
|||
}; |
|||
if (templateGrid.dense && templateGrid.dense.length > 0) { |
|||
if ( |
|||
templateGrid.dense.findIndex((item) => { |
|||
return item === 'dense'; |
|||
}) > -1 |
|||
) { |
|||
dense.dense = true; |
|||
} |
|||
if ( |
|||
templateGrid.dense.findIndex((item) => { |
|||
return item === 'denseToolbar'; |
|||
}) > -1 |
|||
) { |
|||
dense.denseToolbar = true; |
|||
} |
|||
if ( |
|||
templateGrid.dense.findIndex((item) => { |
|||
return item === 'denseHeader'; |
|||
}) > -1 |
|||
) { |
|||
dense.denseHeader = true; |
|||
} |
|||
if ( |
|||
templateGrid.dense.findIndex((item) => { |
|||
return item === 'denseBody'; |
|||
}) > -1 |
|||
) { |
|||
dense.denseBody = true; |
|||
} |
|||
if ( |
|||
templateGrid.dense.findIndex((item) => { |
|||
return item === 'denseBottom'; |
|||
}) > -1 |
|||
) { |
|||
dense.denseBottom = true; |
|||
} |
|||
} |
|||
|
|||
// 处理字段 |
|||
const addFormFields = <any>[]; |
|||
const queryFormFields = <any>[]; |
|||
const tableColumns = <any>[]; |
|||
let addFormField = {}; |
|||
let queryFormField = {}; |
|||
let tableColumn = {}; |
|||
|
|||
for (let i = 0; i < templateGridFields.length; i++) { |
|||
let item = templateGridFields[i]; |
|||
addFormField = {}; |
|||
queryFormField = {}; |
|||
tableColumn = {}; |
|||
const options = await getSelectOptions(item); |
|||
if (item.editorShow) { |
|||
addFormField = { ...addFormField, ...{ label: item.fieldLabel, name: item.fieldName } }; |
|||
if (item.editorFormType) { |
|||
if (item.editorFormType === FormTypeEnum.下拉框) { |
|||
addFormField = { ...addFormField, ...{ type: 'w-select' } }; |
|||
addFormField = { ...addFormField, ...{ options: options } }; |
|||
} else if (item.editorFormType === FormTypeEnum.多选下拉框) { |
|||
addFormField = { ...addFormField, ...{ type: 'w-select' } }; |
|||
addFormField = { ...addFormField, ...{ options: options } }; |
|||
} else if (item.editorFormType === FormTypeEnum.数字框) { |
|||
if (item.fieldPrecision) { |
|||
addFormField = { ...addFormField, ...{ type: 'w-number', precision: item.fieldPrecision } }; |
|||
} else { |
|||
addFormField = { ...addFormField, ...{ type: 'w-number' } }; |
|||
} |
|||
} else if (item.editorFormType === FormTypeEnum.日期) { |
|||
addFormField = { ...addFormField, ...{ type: 'w-date' } }; |
|||
} else if (item.editorFormType === FormTypeEnum.日期范围) { |
|||
addFormField = { ...addFormField, ...{ type: 'dateRange' } }; |
|||
} else { |
|||
addFormField = { ...addFormField, ...{ type: 'w-text' } }; |
|||
} |
|||
} else { |
|||
addFormField = { ...addFormField, ...{ type: 'w-text' } }; |
|||
} |
|||
|
|||
if (item.editorDefaultValue) { |
|||
addFormField = { ...addFormField, ...{ defaultValue: item.editorDefaultValue } }; |
|||
} |
|||
if (item.editorIsRequired) { |
|||
addFormField = { ...addFormField, ...{ requiredIf: item.editorIsRequired } }; |
|||
} |
|||
addFormFields.push(addFormField); |
|||
} |
|||
if (item.queryShow) { |
|||
queryFormField = { ...queryFormField, ...{ label: item.fieldLabel, name: item.fieldName } }; |
|||
if (item.queryFormType) { |
|||
if (item.queryFormType === FormTypeEnum.下拉框) { |
|||
queryFormField = { ...queryFormField, ...{ type: 'w-select' } }; |
|||
queryFormField = { ...queryFormField, ...{ options: options } }; |
|||
} else if (item.queryFormType === FormTypeEnum.多选下拉框) { |
|||
queryFormField = { ...queryFormField, ...{ type: 'w-select' } }; |
|||
queryFormField = { ...queryFormField, ...{ options: options } }; |
|||
} else if (item.queryFormType === FormTypeEnum.数字框) { |
|||
if (item.fieldPrecision) { |
|||
queryFormField = { ...queryFormField, ...{ type: 'w-number', precision: item.fieldPrecision } }; |
|||
} else { |
|||
queryFormField = { ...queryFormField, ...{ type: 'w-number' } }; |
|||
} |
|||
} else if (item.queryFormType === FormTypeEnum.日期) { |
|||
queryFormField = { ...queryFormField, ...{ type: 'w-date' } }; |
|||
} else if (item.queryFormType === FormTypeEnum.日期范围) { |
|||
queryFormField = { ...queryFormField, ...{ type: 'dateRange' } }; |
|||
} else { |
|||
queryFormField = { ...queryFormField, ...{ type: 'w-text' } }; |
|||
} |
|||
} else { |
|||
queryFormField = { ...queryFormField, ...{ type: 'w-text' } }; |
|||
} |
|||
if (item.queryDefaultValue) { |
|||
queryFormField = { ...queryFormField, ...{ defaultValue: item.queryDefaultValue } }; |
|||
} |
|||
if (item.queryIsRequired) { |
|||
queryFormField = { ...queryFormField, ...{ requiredIf: item.queryIsRequired } }; |
|||
} |
|||
if (item.queryOperator) { |
|||
queryFormField = { ...queryFormField, ...{ queryOperator: item.queryOperator } }; |
|||
} |
|||
queryFormFields.push(queryFormField); |
|||
} |
|||
if (item.tableShow) { |
|||
tableColumn = { ...tableColumn, ...{ label: item.fieldLabel, name: item.fieldName } }; |
|||
if (item.tableSort) { |
|||
tableColumn = { ...tableColumn, ...{ sortable: item.tableSort } }; |
|||
} |
|||
if (item.tableColumnAlign) { |
|||
tableColumn = { ...tableColumn, ...{ align: item.tableColumnAlign } }; |
|||
} |
|||
if (item.tableColumnWidth) { |
|||
tableColumn = { ...tableColumn, ...{ width: item.tableColumnWidth } }; |
|||
} |
|||
if (item.fieldIsSelect) { |
|||
tableColumn = { |
|||
...tableColumn, |
|||
...{ |
|||
format: (val, row) => { |
|||
if (Array.isArray(options) && options.length > 0) { |
|||
let formatResult = val; |
|||
options.forEach((option: any) => { |
|||
if (option.value === val) { |
|||
formatResult = option.label; |
|||
} |
|||
}); |
|||
return formatResult; |
|||
} else { |
|||
return val; |
|||
} |
|||
}, |
|||
}, |
|||
}; |
|||
} |
|||
tableColumns.push(tableColumn); |
|||
} |
|||
} |
|||
|
|||
// 根据配置组装数据对象 |
|||
state.pageType = templateConfig.templateType; |
|||
state.pageConfig = { |
|||
// templateGridId: templateGrid.id, |
|||
title: templateGrid.title, |
|||
toolbarActions: tableButtons, |
|||
configButton: configButton, |
|||
selection: templateGrid.selection, |
|||
primaryKey: templateGrid.primaryKey, |
|||
foreignKey: templateGrid.foreignKey, |
|||
dataUrl: Environment.apiContextPath(templateGrid.dataUrl), |
|||
fetchDataUrl: Environment.apiContextPath(templateGrid.fetchDataUrl + '?templateGridId=' + templateGrid.id), |
|||
addDataUrl: Environment.apiContextPath(templateGrid.addDataUrl) + '/' + templateGrid.id, |
|||
editDataUrl: Environment.apiContextPath(templateGrid.editDataUrl) + '/' + templateGrid.id + '/' + templateGrid.primaryKey, |
|||
removeDataUrl: Environment.apiContextPath(templateGrid.removeDataUrl) + '/' + templateGrid.id + '/' + templateGrid.primaryKey, |
|||
sortNo: templateGrid.sortNo, |
|||
checkboxSelection: templateGrid.checkboxSelection, |
|||
draggable: templateGrid.draggable, |
|||
autoFetchData: templateGrid.autoFetchData, |
|||
dense: dense.dense, |
|||
denseToolbar: dense.denseToolbar, |
|||
denseHeader: dense.denseHeader, |
|||
denseBody: dense.denseBody, |
|||
denseBottom: dense.denseBottom, |
|||
stickyNum: templateGrid.stickyNum, |
|||
tree: templateGrid.tree, |
|||
treeRelationship: templateGrid.treeRelationship, |
|||
// treeIcon: |
|||
treeDefaultExpandAll: templateGrid.treeDefaultExpandAll, |
|||
treeTickStrategy: templateGrid.treeTickStrategy, |
|||
tickedField: templateGrid.tickedField, |
|||
selectedField: templateGrid.selectedField, |
|||
pageable: templateGrid.pageable, |
|||
pagination: tablePagination, |
|||
queryFormColsNum: templateGrid.queryFormColsNum, |
|||
queryFormRowNum: templateGrid.queryFormRowNum, |
|||
editor: { |
|||
dialog: { |
|||
width: '60%', |
|||
}, |
|||
form: { |
|||
colsNum: templateGrid.editorFormColsNum, |
|||
fields: addFormFields, |
|||
}, |
|||
}, |
|||
queryFormFields: queryFormFields, |
|||
columns: tableColumns, |
|||
sortBy: defaultSortBy, |
|||
}; |
|||
} |
|||
}; |
|||
|
|||
const refresh = () => { |
|||
gridPageRef.value.refresh(); |
|||
}; |
|||
|
|||
onMounted(async () => { |
|||
await getConfig(); |
|||
if (props.gridInitLoadData) { |
|||
gridPageRef.value.refresh(); |
|||
} |
|||
}); |
|||
|
|||
defineExpose({ |
|||
refresh, |
|||
}); |
|||
</script> |
@ -0,0 +1,287 @@ |
|||
<template> |
|||
<div style="height: 100%"> |
|||
<w-grid |
|||
ref="platformGridRef" |
|||
sort-no |
|||
hide-bottom |
|||
:config-button="false" |
|||
dense-body |
|||
tree |
|||
:checkbox-selection="false" |
|||
selection="multiple" |
|||
title="字段列表(拖拽可对字段进行排序)" |
|||
:auto-fetch-data="false" |
|||
draggable="local" |
|||
:pageable="false" |
|||
:columns="columnsComputed" |
|||
:toolbar-actions="platformGrid.toolbarActions" |
|||
@row-click="platformGrid.rowClickFun" |
|||
></w-grid> |
|||
</div> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { ref, computed, watch } from 'vue'; |
|||
import { Tools } from 'platform-core'; |
|||
|
|||
import type { FieldRowType } from './fieldGrid'; |
|||
import { newFieldRowFun } from './fieldGrid'; |
|||
|
|||
const props = defineProps({ |
|||
fieldComeFrom: { type: String, default: 'table' }, |
|||
}); |
|||
const emit = defineEmits(['set-field-config-value-fun', 'add-table-field-fun']); |
|||
const fieldComeFromValue = ref(props.fieldComeFrom); |
|||
watch( |
|||
() => props.fieldComeFrom, |
|||
(newVal, oldVal) => { |
|||
fieldComeFromValue.value = newVal; |
|||
}, |
|||
); |
|||
|
|||
const fieldName = { label: '字段名称', name: 'fieldName', sortable: false }; |
|||
const fieldLabel = { label: '页面显示名称', name: 'fieldLabel', sortable: false }; |
|||
const queryShow = { |
|||
label: '查询', |
|||
name: 'queryShow', |
|||
width: 50, |
|||
sortable: false, |
|||
align: 'center', |
|||
format: (val, row) => { |
|||
return { |
|||
componentType: 'q-checkbox', |
|||
bindModelValue: true, |
|||
attrs: { |
|||
dense: true, |
|||
disable: row.id === 'query_field' || row.id === 'where_field' || row.parent === 'query_field' || false, |
|||
}, |
|||
}; |
|||
}, |
|||
}; |
|||
const tableShow = { |
|||
label: '列表', |
|||
name: 'tableShow', |
|||
width: 50, |
|||
align: 'center', |
|||
sortable: false, |
|||
format: (val, row) => { |
|||
return { |
|||
componentType: 'q-checkbox', |
|||
bindModelValue: true, |
|||
attrs: { |
|||
dense: true, |
|||
disable: row.id === 'query_field' || row.id === 'where_field' || row.parent === 'where_field' || false, |
|||
}, |
|||
}; |
|||
}, |
|||
}; |
|||
const editorShow = { |
|||
label: '编辑', |
|||
name: 'editorShow', |
|||
width: 50, |
|||
sortable: false, |
|||
align: 'center', |
|||
format: (val, row) => { |
|||
return { |
|||
componentType: 'q-checkbox', |
|||
bindModelValue: true, |
|||
attrs: { |
|||
dense: true, |
|||
}, |
|||
}; |
|||
}, |
|||
}; |
|||
const columnsComputed = computed(() => { |
|||
if (fieldComeFromValue.value === 'sql') { |
|||
return [fieldName, fieldLabel, queryShow, tableShow]; |
|||
} |
|||
return [fieldName, fieldLabel, queryShow, tableShow, editorShow]; |
|||
}); |
|||
|
|||
const platformGridRef = ref(); |
|||
const platformGrid = { |
|||
toolbarActions: [ |
|||
// { |
|||
// extend: 'add', |
|||
// icon: 'add_box', |
|||
// label: '增加不在列表中的字段', |
|||
// click: () => { |
|||
// emit('add-table-field-fun', getRows()); |
|||
// }, |
|||
// }, |
|||
{ |
|||
extend: 'remove', |
|||
enableIf: (args) => { |
|||
if (args.firstTicked && fieldComeFromValue.value !== 'sql') { |
|||
return true; |
|||
} else if (args.selected && fieldComeFromValue.value !== 'sql') { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
}, |
|||
click: (args) => { |
|||
if (args.tickeds) { |
|||
platformGridRef.value.removeLocalData(args.tickeds); |
|||
} else if (args.selecteds) { |
|||
platformGridRef.value.removeLocalData(args.selecteds); |
|||
} |
|||
}, |
|||
}, |
|||
], |
|||
rowClickFun: (args) => { |
|||
emit('set-field-config-value-fun', args.row); |
|||
}, |
|||
columns: [ |
|||
// { |
|||
// label: '字段类型', |
|||
// name: 'fieldType', |
|||
// width: 50, |
|||
// format: (val) => { |
|||
// if (val && DataTypeEnum[val]) { |
|||
// return DataTypeEnum[val]; |
|||
// } else { |
|||
// return val; |
|||
// } |
|||
// }, |
|||
// }, |
|||
], |
|||
}; |
|||
|
|||
const setLocalData = (rows: FieldRowType[], tableName: string) => { |
|||
const result = <FieldRowType[]>[]; |
|||
if (!Tools.isEmpty(tableName)) { |
|||
rows.forEach((row) => { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...row, |
|||
...{ tableName }, |
|||
}); |
|||
}); |
|||
} else { |
|||
rows.forEach((row: any) => { |
|||
if (row.name.toUpperCase() === 'ID' || row.name.toUpperCase() === 'ID_') { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...{ |
|||
...row, |
|||
fieldName: row.name, |
|||
fieldLabel: row.remarks, |
|||
tableName: row.tableName, |
|||
columnType: row.javaType, |
|||
addValueType: 'UUID', |
|||
editOverride: false, |
|||
}, |
|||
}); |
|||
} else if (row.name.toUpperCase() === 'DATA_COME_FROM' || row.name.toUpperCase() === 'DATA_COME_FROM_') { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...{ |
|||
...row, |
|||
fieldName: row.name, |
|||
fieldLabel: row.remarks, |
|||
tableName: row.tableName, |
|||
columnType: row.javaType, |
|||
addValueType: 'DCF_INPUT', |
|||
editOverride: false, |
|||
}, |
|||
}); |
|||
} else if (row.name.toUpperCase() === 'CREATOR' || row.name.toUpperCase() === 'CREATOR_') { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...{ |
|||
...row, |
|||
fieldName: row.name, |
|||
fieldLabel: row.remarks, |
|||
tableName: row.tableName, |
|||
columnType: row.javaType, |
|||
addValueType: 'CURR_USER', |
|||
editOverride: false, |
|||
}, |
|||
}); |
|||
} else if (row.name.toUpperCase() === 'CREATE_DATE' || row.name.toUpperCase() === 'CREATE_DATE_') { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...{ |
|||
...row, |
|||
fieldName: row.name, |
|||
fieldLabel: row.remarks, |
|||
tableName: row.tableName, |
|||
columnType: row.javaType, |
|||
addValueType: 'CURR_DATE', |
|||
editOverride: false, |
|||
fieldtype: 'w-date', |
|||
}, |
|||
}); |
|||
} else if (row.name.toUpperCase() === 'LAST_MODIFIER' || row.name.toUpperCase() === 'LAST_MODIFIER_') { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...{ |
|||
...row, |
|||
fieldName: row.name, |
|||
fieldLabel: row.remarks, |
|||
tableName: row.tableName, |
|||
columnType: row.javaType, |
|||
addValueType: 'CURR_USER', |
|||
editOverride: true, |
|||
}, |
|||
}); |
|||
} else if (row.name.toUpperCase() === 'LAST_MODIFYDATE' || row.name.toUpperCase() === 'LAST_MODIFYDATE_') { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...{ |
|||
...row, |
|||
fieldName: row.name, |
|||
fieldLabel: row.remarks, |
|||
tableName: row.tableName, |
|||
columnType: row.javaType, |
|||
addValueType: 'CURR_DATE', |
|||
editOverride: true, |
|||
fieldtype: 'w-date', |
|||
}, |
|||
}); |
|||
} else if (row.name.toUpperCase() === 'CORP_CODE' || row.name.toUpperCase() === 'CORP_CODE_') { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
...{ |
|||
...row, |
|||
fieldName: row.name, |
|||
fieldLabel: row.remarks, |
|||
tableName: row.tableName, |
|||
columnType: row.javaType, |
|||
addValueType: 'CURR_CORP', |
|||
editOverride: true, |
|||
}, |
|||
}); |
|||
} else { |
|||
result.push({ |
|||
...newFieldRowFun(), |
|||
// tableShow = true 默认设置在表格中显示 |
|||
...{ ...row, fieldName: row.name, fieldLabel: row.remarks, tableName: row.tableName, columnType: row.javaType, tableShow: true }, |
|||
}); |
|||
} |
|||
}); |
|||
} |
|||
platformGridRef.value.setLocalData(result); |
|||
}; |
|||
const updateLocalData = (row: FieldRowType) => { |
|||
platformGridRef.value.updateLocalData({ ...row, _rowKey_: platformGridRef.value.getSelectedRows()[0]['_rowKey_'] }); |
|||
}; |
|||
const addLocalData = (row, index) => { |
|||
platformGridRef.value.addLocalData(row, index); |
|||
}; |
|||
const getRows = () => { |
|||
return platformGridRef.value.getRows(); |
|||
}; |
|||
const getSelectedRows = () => { |
|||
return platformGridRef.value.getSelectedRows(); |
|||
}; |
|||
|
|||
defineExpose({ |
|||
setLocalData, |
|||
updateLocalData, |
|||
getRows, |
|||
addLocalData, |
|||
getSelectedRows, |
|||
}); |
|||
</script> |
|||
./fieldGrid |
@ -0,0 +1,36 @@ |
|||
<template> |
|||
<div style="height: 100%"> |
|||
<w-grid |
|||
ref="platformGridRef" |
|||
v-bind="platformGrid" |
|||
@before-request-data="gridBeforeRequestData" |
|||
@before-editor-data-submit="gridBeforeEditorDataSubmit" |
|||
></w-grid> |
|||
</div> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { ref } from 'vue'; |
|||
|
|||
const props = defineProps({ |
|||
platformGridConfig: { |
|||
type: Object, |
|||
default: () => { |
|||
return {}; |
|||
}, |
|||
}, |
|||
gridBeforeRequestData: { type: Function, default: () => {} }, |
|||
gridBeforeEditorDataSubmit: { type: Function, default: () => {} }, |
|||
}); |
|||
|
|||
const platformGridRef = ref(); |
|||
const platformGrid = { ...props.platformGridConfig }; |
|||
|
|||
// 刷新平台表格组件 |
|||
const refresh = () => { |
|||
platformGridRef.value.refresh(); |
|||
}; |
|||
|
|||
defineExpose({ |
|||
refresh, |
|||
}); |
|||
</script> |
@ -0,0 +1,66 @@ |
|||
export type FieldRowType = { |
|||
// 字段定义
|
|||
tableName?: string; // 字段所属表
|
|||
fieldName: string; // 字段名称
|
|||
fieldLabel: string; // 字段中文名
|
|||
fieldType: string; // 字段类型
|
|||
fieldLength?: number; // 字段长度
|
|||
fieldPrecision?: number; // 字段精度
|
|||
fieldIsSelect?: boolean; // 字段为选项值
|
|||
optionComeFrom: string; // 选项值来源
|
|||
dictionaryOptionValue: string; // 数据字典选项值
|
|||
otherOptionValue: string; // 其他类型选项值
|
|||
addValueType: string; // 新增时系统自动填充类型
|
|||
editOverride?: boolean; // 修改时覆盖系统自动填充值
|
|||
// 查询面板
|
|||
queryShow?: boolean; // 查询面板中显示
|
|||
queryFormType: string; // 使用的表单类型
|
|||
queryDefaultValue: string; // 默认值
|
|||
queryIsRequired?: boolean; // 必填项
|
|||
queryOperator: string; // 匹配模式
|
|||
// 列表
|
|||
tableShow?: boolean; // 列表中显示
|
|||
tableSort?: boolean; // 支持排序
|
|||
tableColumnAlign: string; // 列对齐方式
|
|||
tableColumnWidth?: number; // 列宽
|
|||
// 新增页面
|
|||
editorShow?: boolean; // 新增编辑页面中显示
|
|||
editorFormType: string; // 使用的表单类型
|
|||
editorDefaultValue: string; // 默认值
|
|||
editorIsRequired?: boolean; // 必填项
|
|||
}; |
|||
|
|||
export function newFieldRowFun() { |
|||
const fieldRow = { |
|||
// 字段定义
|
|||
tableName: undefined, // 字段所属表
|
|||
fieldName: '', // 字段名称
|
|||
fieldLabel: '', // 字段中文名
|
|||
fieldType: 'String', // 字段类型
|
|||
fieldLength: undefined, // 字段长度
|
|||
fieldPrecision: undefined, // 字段精度
|
|||
fieldIsSelect: false, // 字段为选项值
|
|||
optionComeFrom: '', // 选项值来源
|
|||
dictionaryOptionValue: '', // 数据字典选项值
|
|||
otherOptionValue: '', // 其他类型选项值
|
|||
addValueType: 'NONE', // 新增时系统自动填充类型
|
|||
editOverride: undefined, // 修改时覆盖系统自动填充值
|
|||
// 查询面板
|
|||
queryShow: false, // 查询面板中显示
|
|||
queryFormtype: 'w-text', // 使用的表单类型
|
|||
queryDefaultValue: '', // 默认值
|
|||
queryIsrequiredIf: false, // 必填项
|
|||
queryOperator: '', // 匹配模式
|
|||
// 列表
|
|||
tableShow: false, // 列表中显示
|
|||
tableSort: false, // 支持排序
|
|||
tableColumnAlign: '', // 列对齐方式
|
|||
tableColumnWidth: undefined, // 列宽
|
|||
// 新增页面
|
|||
editorShow: false, // 新增编辑页面中显示
|
|||
editorFormtype: 'w-text', // 使用的表单类型
|
|||
editorDefaultValue: '', // 默认值
|
|||
editorIsrequiredIf: false, // 必填项
|
|||
}; |
|||
return fieldRow; |
|||
} |
@ -0,0 +1,18 @@ |
|||
import { axios, Environment } from 'platform-core'; |
|||
|
|||
/** |
|||
* 页面模板类型枚举 |
|||
*/ |
|||
export enum PageTemplateType { |
|||
GRID = 'GRID', // 表格页面
|
|||
} |
|||
|
|||
export async function getPageConfig(configId: string) { |
|||
const result = await axios.get(Environment.apiContextPath('api/page/config'), { |
|||
params: { id: configId }, |
|||
}); |
|||
if (result && result.data) { |
|||
return result.data[0]; |
|||
} |
|||
return null; |
|||
} |
@ -0,0 +1,15 @@ |
|||
package io.sc.platform.lcdp.excel.template.controller; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelListDetail; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelListDetailRepository; |
|||
import io.sc.platform.lcdp.excel.template.service.ExcelListDetailService; |
|||
import io.sc.platform.lcdp.excel.template.vo.ExcelListDetailVo; |
|||
import io.sc.platform.mvc.controller.support.RestCrudController; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/excel/template/params/list") |
|||
public class ExcelListDetailController extends RestCrudController<ExcelListDetailVo, ExcelListDetail,String, ExcelListDetailRepository, ExcelListDetailService> { |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package io.sc.platform.lcdp.excel.template.controller; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelParams; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelParamsRepository; |
|||
import io.sc.platform.lcdp.excel.template.service.ExcelParamsService; |
|||
import io.sc.platform.lcdp.excel.template.support.ExcelParamsWrapper; |
|||
import io.sc.platform.lcdp.excel.template.vo.ExcelParamsVo; |
|||
import io.sc.platform.mvc.controller.support.RestCrudController; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/excel/template/params") |
|||
public class ExcelParamsController extends RestCrudController<ExcelParamsVo, ExcelParams,String, ExcelParamsRepository, ExcelParamsService> { |
|||
|
|||
@RequestMapping(value="add",method= RequestMethod.POST) |
|||
public ExcelParamsWrapper add(@RequestBody ExcelParamsWrapper wrapper) throws Exception { |
|||
return service.add(wrapper); |
|||
} |
|||
|
|||
@RequestMapping(value="edit",method= RequestMethod.POST) |
|||
public ExcelParamsWrapper edit(@RequestBody ExcelParamsWrapper wrapper) throws Exception { |
|||
return service.edit(wrapper); |
|||
} |
|||
} |
@ -0,0 +1,34 @@ |
|||
package io.sc.platform.lcdp.excel.template.controller; |
|||
|
|||
import io.sc.platform.core.response.ResponseWrapper; |
|||
import io.sc.platform.core.response.SuccessResponseWrapper; |
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelTemplate; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelTemplateRepository; |
|||
import io.sc.platform.lcdp.excel.template.service.ExcelTemplateService; |
|||
import io.sc.platform.lcdp.excel.template.vo.ExcelTemplateVo; |
|||
import io.sc.platform.mvc.controller.support.RestCrudController; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/excel/template") |
|||
public class ExcelTemplateController extends RestCrudController<ExcelTemplateVo, ExcelTemplate,String, ExcelTemplateRepository, ExcelTemplateService> { |
|||
|
|||
@RequestMapping(value="updateConfig/{templateId}",method= RequestMethod.POST) |
|||
public ResponseWrapper updateConfig(@PathVariable(name="templateId") String templateId, @RequestBody ExcelTemplate template) throws Exception { |
|||
service.updateConfig(templateId, template); |
|||
return new SuccessResponseWrapper(); |
|||
} |
|||
|
|||
@RequestMapping(value="updateField/{templateId}",method= RequestMethod.PUT) |
|||
public ResponseWrapper updateField(@PathVariable(name="templateId") String templateId, @RequestBody ExcelTemplate template) throws Exception { |
|||
service.updateField(templateId, template); |
|||
return new SuccessResponseWrapper(); |
|||
} |
|||
|
|||
@RequestMapping(value="getReportData/{templateId}",method= RequestMethod.GET) |
|||
public Map<String, Object> getReportData(@PathVariable(name="templateId") String templateId) throws Exception { |
|||
return service.getReportData(templateId); |
|||
} |
|||
} |
@ -0,0 +1,142 @@ |
|||
package io.sc.platform.lcdp.excel.template.entity; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.vo.ExcelListDetailVo; |
|||
import io.sc.platform.orm.entity.CorporationAuditorEntity; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import javax.validation.constraints.Size; |
|||
|
|||
/** |
|||
* Excel列表类型的变量明细 |
|||
* @author likunming |
|||
* |
|||
*/ |
|||
@Entity |
|||
@Table(name="LCDP_EXCEL_LIST_DETAIL") |
|||
public class ExcelListDetail extends CorporationAuditorEntity<ExcelListDetailVo> { |
|||
|
|||
//主键
|
|||
@Id |
|||
@GeneratedValue(generator = "system-uuid") |
|||
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
|||
@Column(name="ID_") |
|||
@Size(max=50) |
|||
protected String id; |
|||
|
|||
// 所属变量
|
|||
@ManyToOne(fetch=FetchType.LAZY) |
|||
@JoinColumn(name="PARAMS_ID_") |
|||
protected ExcelParams reportExcelTemplateParams; |
|||
|
|||
// 字段名称
|
|||
@Column(name="SORT_NO_") |
|||
protected Integer sortNo; |
|||
|
|||
// 字段名称
|
|||
@Column(name="FIELD_NAME_") |
|||
@Size(max=200) |
|||
protected String name; |
|||
|
|||
// 字段描述
|
|||
@Column(name="FIELD_DESC_") |
|||
@Size(max=500) |
|||
protected String desc; |
|||
|
|||
// 字段格式化类型(dictionary: 数据字典, javaApi: java接口, array: 自定义数组)
|
|||
@Column(name="FORMAT_TYPE_") |
|||
@Size(max=100) |
|||
protected String formatType; |
|||
|
|||
// 数据字典格式化值
|
|||
@Column(name="DICT_FORMAT_VALUE_") |
|||
@Size(max=100) |
|||
protected String dictFormatValue; |
|||
|
|||
// 其他格式化值
|
|||
@Column(name="OTHER_FORMAT_VALUE_") |
|||
@Size(max=1000) |
|||
protected String otherFormatValue; |
|||
|
|||
@Override |
|||
public ExcelListDetailVo toVo() { |
|||
ExcelListDetailVo vo = new ExcelListDetailVo(); |
|||
super.toVo(vo); |
|||
|
|||
vo.setId(this.getId()); |
|||
if (null!=this.getReportExcelTemplateParams()) { |
|||
vo.setReportExcelTemplateParams(this.getReportExcelTemplateParams().getId()); |
|||
} |
|||
vo.setSortNo(this.getSortNo()); |
|||
vo.setName(this.getName()); |
|||
vo.setDesc(this.getDesc()); |
|||
vo.setFormatType(this.getFormatType()); |
|||
vo.setDictFormatValue(this.getDictFormatValue()); |
|||
vo.setOtherFormatValue(this.getOtherFormatValue()); |
|||
return vo; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public ExcelParams getReportExcelTemplateParams() { |
|||
return reportExcelTemplateParams; |
|||
} |
|||
|
|||
public void setReportExcelTemplateParams(ExcelParams reportExcelTemplateParams) { |
|||
this.reportExcelTemplateParams = reportExcelTemplateParams; |
|||
} |
|||
|
|||
public Integer getSortNo() { |
|||
return sortNo; |
|||
} |
|||
|
|||
public void setSortNo(Integer sortNo) { |
|||
this.sortNo = sortNo; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public String getFormatType() { |
|||
return formatType; |
|||
} |
|||
|
|||
public void setFormatType(String formatType) { |
|||
this.formatType = formatType; |
|||
} |
|||
|
|||
public String getDictFormatValue() { |
|||
return dictFormatValue; |
|||
} |
|||
|
|||
public void setDictFormatValue(String dictFormatValue) { |
|||
this.dictFormatValue = dictFormatValue; |
|||
} |
|||
|
|||
public String getOtherFormatValue() { |
|||
return otherFormatValue; |
|||
} |
|||
|
|||
public void setOtherFormatValue(String otherFormatValue) { |
|||
this.otherFormatValue = otherFormatValue; |
|||
} |
|||
} |
@ -0,0 +1,146 @@ |
|||
package io.sc.platform.lcdp.excel.template.entity; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.enums.ExcelParamsType; |
|||
import io.sc.platform.lcdp.excel.template.vo.ExcelParamsVo; |
|||
import io.sc.platform.orm.converter.NumericBooleanConverter; |
|||
import io.sc.platform.orm.entity.CorporationAuditorEntity; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import javax.validation.constraints.Size; |
|||
|
|||
/** |
|||
* Excel模板变量表 |
|||
* @author likunming |
|||
* |
|||
*/ |
|||
@Entity |
|||
@Table(name="LCDP_EXCEL_PARAMS") |
|||
public class ExcelParams extends CorporationAuditorEntity<ExcelParamsVo> { |
|||
|
|||
private static final long serialVersionUID = 1402132856965803346L; |
|||
|
|||
//主键
|
|||
@Id |
|||
@GeneratedValue(generator = "system-uuid") |
|||
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
|||
@Column(name="ID_") |
|||
@Size(max=50) |
|||
protected String id; |
|||
|
|||
// 变量编码
|
|||
@Column(name="CODE_") |
|||
@Size(max=100) |
|||
protected String paramsCode; |
|||
|
|||
// 变量名称
|
|||
@Column(name="NAME_") |
|||
@Size(max=200) |
|||
protected String paramsName; |
|||
|
|||
// 所属模板
|
|||
@ManyToOne(fetch=FetchType.LAZY) |
|||
@JoinColumn(name="TPL_ID_") |
|||
protected ExcelTemplate reportExcelTemplate; |
|||
|
|||
@Transient |
|||
protected String reportExcelTemplateName; |
|||
|
|||
// 变量是否通用(0:模板ID对应的模板可使用,1:所有模板均可使用)
|
|||
@Column(name="IS_COMMON_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean paramsIsCommon; |
|||
|
|||
// 变量类型(SING:单值,LIST:列表)
|
|||
@Column(name="TYPE_") |
|||
@Enumerated(EnumType.STRING) |
|||
protected ExcelParamsType paramsType; |
|||
|
|||
// 取值SQL
|
|||
@Column(name="SQL_") |
|||
protected String paramsSql; |
|||
|
|||
@Override |
|||
public ExcelParamsVo toVo() { |
|||
ExcelParamsVo vo = new ExcelParamsVo(); |
|||
super.toVo(vo); |
|||
|
|||
vo.setId(this.getId()); |
|||
vo.setParamsCode(this.getParamsCode()); |
|||
vo.setParamsName(this.getParamsName()); |
|||
if (null!=this.getReportExcelTemplate()) { |
|||
vo.setReportExcelTemplate(this.getReportExcelTemplate().getId()); |
|||
vo.setReportExcelTemplateName(this.getReportExcelTemplate().getTemplateName()); |
|||
} |
|||
vo.setParamsIsCommon(this.getParamsIsCommon()); |
|||
if (null!=this.getParamsType()) { |
|||
vo.setParamsType(this.getParamsType().name()); |
|||
} |
|||
vo.setParamsSql(this.getParamsSql()); |
|||
return vo; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getParamsCode() { |
|||
return paramsCode; |
|||
} |
|||
|
|||
public void setParamsCode(String paramsCode) { |
|||
this.paramsCode = paramsCode; |
|||
} |
|||
|
|||
public String getParamsName() { |
|||
return paramsName; |
|||
} |
|||
|
|||
public void setParamsName(String paramsName) { |
|||
this.paramsName = paramsName; |
|||
} |
|||
|
|||
public ExcelTemplate getReportExcelTemplate() { |
|||
return reportExcelTemplate; |
|||
} |
|||
|
|||
public void setReportExcelTemplate(ExcelTemplate reportExcelTemplate) { |
|||
this.reportExcelTemplate = reportExcelTemplate; |
|||
} |
|||
|
|||
public String getReportExcelTemplateName() { |
|||
return reportExcelTemplateName; |
|||
} |
|||
|
|||
public void setReportExcelTemplateName(String reportExcelTemplateName) { |
|||
this.reportExcelTemplateName = reportExcelTemplateName; |
|||
} |
|||
|
|||
public Boolean getParamsIsCommon() { |
|||
return paramsIsCommon; |
|||
} |
|||
|
|||
public void setParamsIsCommon(Boolean paramsIsCommon) { |
|||
this.paramsIsCommon = paramsIsCommon; |
|||
} |
|||
|
|||
public ExcelParamsType getParamsType() { |
|||
return paramsType; |
|||
} |
|||
|
|||
public void setParamsType(ExcelParamsType paramsType) { |
|||
this.paramsType = paramsType; |
|||
} |
|||
|
|||
public String getParamsSql() { |
|||
return paramsSql; |
|||
} |
|||
|
|||
public void setParamsSql(String paramsSql) { |
|||
this.paramsSql = paramsSql; |
|||
} |
|||
} |
@ -0,0 +1,84 @@ |
|||
package io.sc.platform.lcdp.excel.template.entity; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.vo.ExcelTemplateVo; |
|||
import io.sc.platform.orm.entity.CorporationAuditorEntity; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import javax.validation.constraints.Size; |
|||
|
|||
/** |
|||
* Excel模板 |
|||
* @author likunming |
|||
* |
|||
*/ |
|||
@Entity |
|||
@Table(name="LCDP_EXCEL_TEMPLATE") |
|||
public class ExcelTemplate extends CorporationAuditorEntity<ExcelTemplateVo> { |
|||
|
|||
//主键
|
|||
@Id |
|||
@GeneratedValue(generator = "system-uuid") |
|||
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
|||
@Column(name="ID_") |
|||
@Size(max=50) |
|||
protected String id; |
|||
|
|||
// 模板编码
|
|||
@Column(name="CODE_") |
|||
@Size(max=100) |
|||
protected String templateCode; |
|||
|
|||
// 模板名称
|
|||
@Column(name="NAME_") |
|||
@Size(max=500) |
|||
protected String templateName; |
|||
|
|||
// 模板配置的内容
|
|||
@Column(name="CONFIG_") |
|||
protected String templateConfig; |
|||
|
|||
@Override |
|||
public ExcelTemplateVo toVo() { |
|||
ExcelTemplateVo vo = new ExcelTemplateVo(); |
|||
super.toVo(vo); |
|||
|
|||
vo.setId(this.getId()); |
|||
vo.setTemplateCode(this.getTemplateCode()); |
|||
vo.setTemplateName(this.getTemplateName()); |
|||
vo.setTemplateConfig(this.getTemplateConfig()); |
|||
return vo; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTemplateCode() { |
|||
return templateCode; |
|||
} |
|||
|
|||
public void setTemplateCode(String templateCode) { |
|||
this.templateCode = templateCode; |
|||
} |
|||
|
|||
public String getTemplateName() { |
|||
return templateName; |
|||
} |
|||
|
|||
public void setTemplateName(String templateName) { |
|||
this.templateName = templateName; |
|||
} |
|||
|
|||
public String getTemplateConfig() { |
|||
return templateConfig; |
|||
} |
|||
|
|||
public void setTemplateConfig(String templateConfig) { |
|||
this.templateConfig = templateConfig; |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
package io.sc.platform.lcdp.excel.template.enums; |
|||
|
|||
/** |
|||
* Excel模板变量类型 |
|||
*/ |
|||
public enum ExcelParamsType { |
|||
SING, // 单值
|
|||
LIST // 列表
|
|||
} |
@ -0,0 +1,11 @@ |
|||
package io.sc.platform.lcdp.excel.template.repository; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelListDetail; |
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelParams; |
|||
import io.sc.platform.orm.repository.DaoRepository; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface ExcelListDetailRepository extends DaoRepository<ExcelListDetail, String> { |
|||
List<ExcelListDetail> findByReportExcelTemplateParams(ExcelParams reportExcelTemplateParams) throws Exception; |
|||
} |
@ -0,0 +1,13 @@ |
|||
package io.sc.platform.lcdp.excel.template.repository; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelParams; |
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelTemplate; |
|||
import io.sc.platform.orm.repository.DaoRepository; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface ExcelParamsRepository extends DaoRepository<ExcelParams, String> { |
|||
|
|||
List<ExcelParams> findByReportExcelTemplate(ExcelTemplate template); |
|||
ExcelParams findByParamsCode(String paramsCode); |
|||
} |
@ -0,0 +1,8 @@ |
|||
package io.sc.platform.lcdp.excel.template.repository; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelTemplate; |
|||
import io.sc.platform.orm.repository.DaoRepository; |
|||
|
|||
public interface ExcelTemplateRepository extends DaoRepository<ExcelTemplate, String> { |
|||
ExcelTemplate findByTemplateCode(String templateCode); |
|||
} |
@ -0,0 +1,9 @@ |
|||
package io.sc.platform.lcdp.excel.template.service; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelListDetail; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelListDetailRepository; |
|||
import io.sc.platform.orm.service.DaoService; |
|||
|
|||
public interface ExcelListDetailService extends DaoService<ExcelListDetail, String, ExcelListDetailRepository> { |
|||
|
|||
} |
@ -0,0 +1,12 @@ |
|||
package io.sc.platform.lcdp.excel.template.service; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelParams; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelParamsRepository; |
|||
import io.sc.platform.lcdp.excel.template.support.ExcelParamsWrapper; |
|||
import io.sc.platform.orm.service.DaoService; |
|||
|
|||
public interface ExcelParamsService extends DaoService<ExcelParams, String, ExcelParamsRepository> { |
|||
|
|||
public ExcelParamsWrapper add(ExcelParamsWrapper wrapper) throws Exception; |
|||
public ExcelParamsWrapper edit(ExcelParamsWrapper wrapper) throws Exception; |
|||
} |
@ -0,0 +1,16 @@ |
|||
package io.sc.platform.lcdp.excel.template.service; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelTemplate; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelTemplateRepository; |
|||
import io.sc.platform.orm.service.DaoService; |
|||
|
|||
import java.util.Map; |
|||
|
|||
public interface ExcelTemplateService extends DaoService<ExcelTemplate, String, ExcelTemplateRepository> { |
|||
|
|||
public void updateConfig(String templateId, ExcelTemplate template) throws Exception; |
|||
|
|||
public void updateField(String templateId, ExcelTemplate template) throws Exception; |
|||
|
|||
public Map<String, Object> getReportData(String templateId) throws Exception; |
|||
} |
@ -0,0 +1,12 @@ |
|||
package io.sc.platform.lcdp.excel.template.service.impl; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelListDetail; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelListDetailRepository; |
|||
import io.sc.platform.lcdp.excel.template.service.ExcelListDetailService; |
|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service("lcdpExcelListDetailService") |
|||
public class ExcelListDetailServiceImpl extends DaoServiceImpl<ExcelListDetail, String, ExcelListDetailRepository> implements ExcelListDetailService { |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package io.sc.platform.lcdp.excel.template.service.impl; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelListDetail; |
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelParams; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelParamsRepository; |
|||
import io.sc.platform.lcdp.excel.template.service.ExcelListDetailService; |
|||
import io.sc.platform.lcdp.excel.template.service.ExcelParamsService; |
|||
import io.sc.platform.lcdp.excel.template.support.ExcelParamsWrapper; |
|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Service("lcdpExcelParamsService") |
|||
public class ExcelParamsServiceImpl extends DaoServiceImpl<ExcelParams, String, ExcelParamsRepository> implements ExcelParamsService { |
|||
|
|||
@Autowired |
|||
private ExcelListDetailService excelListDetailService; |
|||
|
|||
@Override |
|||
public ExcelParams findByUniqueKey(ExcelParams entity) { |
|||
return repository.findByParamsCode(entity.getParamsCode()); |
|||
} |
|||
|
|||
@Override |
|||
public ExcelParamsWrapper add(ExcelParamsWrapper wrapper) throws Exception { |
|||
ExcelParams params = wrapper.getParams(); |
|||
List<ExcelListDetail> list = wrapper.getList(); |
|||
repository.save(params); |
|||
|
|||
if (null != list && list.size() > 0){ |
|||
for (int i=0; i<list.size(); i++) { |
|||
list.get(i).setReportExcelTemplateParams(params); |
|||
} |
|||
excelListDetailService.getRepository().saveAll(list); |
|||
} |
|||
return new ExcelParamsWrapper(params, list); |
|||
} |
|||
|
|||
@Override |
|||
public ExcelParamsWrapper edit(ExcelParamsWrapper wrapper) throws Exception { |
|||
ExcelParams params = wrapper.getParams(); |
|||
List<ExcelListDetail> list = wrapper.getList(); |
|||
|
|||
this.update(params.getId(), params); |
|||
|
|||
// 删除所有列表配置记录
|
|||
List<ExcelListDetail> listArrays = excelListDetailService.getRepository().findByReportExcelTemplateParams(params); |
|||
List<String> removeIds = new ArrayList<>(); |
|||
if (null != listArrays && listArrays.size() > 0) { |
|||
for(ExcelListDetail retpl : listArrays) { |
|||
removeIds.add(retpl.getId()); |
|||
} |
|||
} |
|||
excelListDetailService.remove(removeIds); |
|||
if (null != list && list.size() > 0){ |
|||
// 保存最新记录
|
|||
for (int i=0; i<list.size(); i++) { |
|||
list.get(i).setReportExcelTemplateParams(params); |
|||
} |
|||
excelListDetailService.getRepository().saveAll(list); |
|||
} |
|||
return new ExcelParamsWrapper(params, list); |
|||
} |
|||
} |
@ -0,0 +1,105 @@ |
|||
package io.sc.platform.lcdp.excel.template.service.impl; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelParams; |
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelTemplate; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelParamsRepository; |
|||
import io.sc.platform.lcdp.excel.template.repository.ExcelTemplateRepository; |
|||
import io.sc.platform.lcdp.excel.template.service.ExcelTemplateService; |
|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
@Service("lcdpExcelTemplateService") |
|||
public class ExcelTemplateServiceImpl extends DaoServiceImpl<ExcelTemplate, String, ExcelTemplateRepository> implements ExcelTemplateService { |
|||
|
|||
public static Pattern codePattern = Pattern.compile("\\$\\{([^}]*)\\}"); |
|||
public static Pattern commentPattern = Pattern.compile("\\@\\{(?!\\@\\{)(.*?)\\}\\@"); |
|||
|
|||
@Autowired |
|||
private ExcelParamsRepository reportExcelTemplateParamsRepository; |
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
@Autowired |
|||
private ObjectMapper objectMapper; |
|||
|
|||
@Override |
|||
public ExcelTemplate findByUniqueKey(ExcelTemplate entity) { |
|||
return repository.findByTemplateCode(entity.getTemplateCode()); |
|||
} |
|||
|
|||
@Override |
|||
public void updateConfig(String templateId, ExcelTemplate template) { |
|||
ExcelTemplate oldTemplate = this.findById(templateId); |
|||
oldTemplate.setTemplateConfig(template.getTemplateConfig()); |
|||
|
|||
repository.save(oldTemplate); |
|||
} |
|||
|
|||
@Override |
|||
public void updateField(String templateId, ExcelTemplate template) throws Exception { |
|||
ExcelTemplate oldTemplate = this.findById(templateId); |
|||
oldTemplate.setTemplateCode(template.getTemplateCode()); |
|||
oldTemplate.setTemplateName(template.getTemplateName()); |
|||
|
|||
repository.save(oldTemplate); |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, Object> getReportData(String templateId) throws Exception { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
ExcelTemplate template = this.findById(templateId); |
|||
List<String> paramsCodeList = getCodeListByContent(template.getTemplateConfig()); |
|||
List<String> paramsCommentList = getCommentListByContent(template.getTemplateConfig()); |
|||
for (int i=0; i<paramsCodeList.size(); i++) { |
|||
String paramsCode = paramsCodeList.get(i); |
|||
ExcelParams params = reportExcelTemplateParamsRepository.findByParamsCode(paramsCode); |
|||
Map<String, Object> queryMap = jdbcTemplate.queryForMap(params.getParamsSql()); |
|||
Collection<Object> values = queryMap.values(); |
|||
for (Object o : values) { |
|||
map.put(paramsCode, o); |
|||
} |
|||
} |
|||
for (int i=0; i< paramsCommentList.size(); i++) { |
|||
String jsonStr = paramsCommentList.get(i); |
|||
jsonStr = jsonStr.replaceAll("\\\\n", ""); |
|||
jsonStr = jsonStr.replaceAll("\\\\", ""); |
|||
Map<String, Object> comment = objectMapper.readValue(jsonStr, Map.class); |
|||
if (comment.containsKey("listName")) { |
|||
ExcelParams params = reportExcelTemplateParamsRepository.findByParamsCode(comment.get("listName").toString()); |
|||
List<Map<String, Object>> list = jdbcTemplate.queryForList(params.getParamsSql()); |
|||
map.put(comment.get("listName").toString(), list); |
|||
} |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
/** |
|||
* 按照动态内容的参数出现顺序,将参数放到List中 |
|||
* |
|||
* @param content |
|||
* @return |
|||
*/ |
|||
public static List<String> getCodeListByContent(String content) { |
|||
Set<String> paramSet = new LinkedHashSet<>(); |
|||
Matcher m = codePattern.matcher(content); |
|||
while (m.find()) { |
|||
paramSet.add(m.group(1)); |
|||
} |
|||
return new ArrayList<>(paramSet); |
|||
} |
|||
|
|||
public static List<String> getCommentListByContent(String content) { |
|||
Set<String> paramSet = new LinkedHashSet<>(); |
|||
Matcher m = commentPattern.matcher(content); |
|||
while (m.find()) { |
|||
paramSet.add(m.group(1)); |
|||
} |
|||
return new ArrayList<>(paramSet); |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
package io.sc.platform.lcdp.excel.template.support; |
|||
|
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelListDetail; |
|||
import io.sc.platform.lcdp.excel.template.entity.ExcelParams; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class ExcelParamsWrapper { |
|||
public ExcelParams params; |
|||
public List<ExcelListDetail> list; |
|||
|
|||
public ExcelParamsWrapper() {}; |
|||
|
|||
public ExcelParamsWrapper(ExcelParams p, List<ExcelListDetail> l){ |
|||
this.params = p; |
|||
this.list = l; |
|||
} |
|||
public ExcelParams getParams() { |
|||
return params; |
|||
} |
|||
|
|||
public void setParams(ExcelParams params) { |
|||
this.params = params; |
|||
} |
|||
|
|||
public List<ExcelListDetail> getList() { |
|||
return list; |
|||
} |
|||
|
|||
public void setList(List<ExcelListDetail> list) { |
|||
this.list = list; |
|||
} |
|||
} |
@ -0,0 +1,94 @@ |
|||
package io.sc.platform.lcdp.excel.template.vo; |
|||
|
|||
import io.sc.platform.orm.api.vo.CorporationAuditorVo; |
|||
|
|||
public class ExcelListDetailVo extends CorporationAuditorVo { |
|||
|
|||
//主键
|
|||
private String id; |
|||
|
|||
// 所属变量
|
|||
private String reportExcelTemplateParams; |
|||
|
|||
// 字段名称
|
|||
private Integer sortNo; |
|||
|
|||
// 字段名称
|
|||
private String name; |
|||
|
|||
// 字段描述
|
|||
private String desc; |
|||
|
|||
// 字段格式化类型(dictionary: 数据字典, javaApi: java接口, array: 自定义数组)
|
|||
private String formatType; |
|||
|
|||
// 数据字典格式化值
|
|||
private String dictFormatValue; |
|||
|
|||
// 其他格式化值
|
|||
private String otherFormatValue; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getReportExcelTemplateParams() { |
|||
return reportExcelTemplateParams; |
|||
} |
|||
|
|||
public void setReportExcelTemplateParams(String reportExcelTemplateParams) { |
|||
this.reportExcelTemplateParams = reportExcelTemplateParams; |
|||
} |
|||
|
|||
public Integer getSortNo() { |
|||
return sortNo; |
|||
} |
|||
|
|||
public void setSortNo(Integer sortNo) { |
|||
this.sortNo = sortNo; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public String getFormatType() { |
|||
return formatType; |
|||
} |
|||
|
|||
public void setFormatType(String formatType) { |
|||
this.formatType = formatType; |
|||
} |
|||
|
|||
public String getDictFormatValue() { |
|||
return dictFormatValue; |
|||
} |
|||
|
|||
public void setDictFormatValue(String dictFormatValue) { |
|||
this.dictFormatValue = dictFormatValue; |
|||
} |
|||
|
|||
public String getOtherFormatValue() { |
|||
return otherFormatValue; |
|||
} |
|||
|
|||
public void setOtherFormatValue(String otherFormatValue) { |
|||
this.otherFormatValue = otherFormatValue; |
|||
} |
|||
} |
@ -0,0 +1,94 @@ |
|||
package io.sc.platform.lcdp.excel.template.vo; |
|||
|
|||
import io.sc.platform.orm.api.vo.CorporationAuditorVo; |
|||
|
|||
public class ExcelParamsVo extends CorporationAuditorVo { |
|||
|
|||
//主键
|
|||
private String id; |
|||
|
|||
// 变量编码
|
|||
private String paramsCode; |
|||
|
|||
// 变量名称
|
|||
private String paramsName; |
|||
|
|||
// 所属模板
|
|||
private String reportExcelTemplate; |
|||
|
|||
// 所属模板名称
|
|||
private String reportExcelTemplateName; |
|||
|
|||
// 变量是否通用(0:模板ID对应的模板可使用,1:所有模板均可使用)
|
|||
private Boolean paramsIsCommon; |
|||
|
|||
// 变量类型(SING:单值,LIST:列表)
|
|||
private String paramsType; |
|||
|
|||
// 取值SQL
|
|||
private String paramsSql; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getParamsCode() { |
|||
return paramsCode; |
|||
} |
|||
|
|||
public void setParamsCode(String paramsCode) { |
|||
this.paramsCode = paramsCode; |
|||
} |
|||
|
|||
public String getParamsName() { |
|||
return paramsName; |
|||
} |
|||
|
|||
public void setParamsName(String paramsName) { |
|||
this.paramsName = paramsName; |
|||
} |
|||
|
|||
public String getReportExcelTemplate() { |
|||
return reportExcelTemplate; |
|||
} |
|||
|
|||
public void setReportExcelTemplate(String reportExcelTemplate) { |
|||
this.reportExcelTemplate = reportExcelTemplate; |
|||
} |
|||
|
|||
public String getReportExcelTemplateName() { |
|||
return reportExcelTemplateName; |
|||
} |
|||
|
|||
public void setReportExcelTemplateName(String reportExcelTemplateName) { |
|||
this.reportExcelTemplateName = reportExcelTemplateName; |
|||
} |
|||
|
|||
public Boolean getParamsIsCommon() { |
|||
return paramsIsCommon; |
|||
} |
|||
|
|||
public void setParamsIsCommon(Boolean paramsIsCommon) { |
|||
this.paramsIsCommon = paramsIsCommon; |
|||
} |
|||
|
|||
public String getParamsType() { |
|||
return paramsType; |
|||
} |
|||
|
|||
public void setParamsType(String paramsType) { |
|||
this.paramsType = paramsType; |
|||
} |
|||
|
|||
public String getParamsSql() { |
|||
return paramsSql; |
|||
} |
|||
|
|||
public void setParamsSql(String paramsSql) { |
|||
this.paramsSql = paramsSql; |
|||
} |
|||
} |
@ -0,0 +1,50 @@ |
|||
package io.sc.platform.lcdp.excel.template.vo; |
|||
|
|||
import io.sc.platform.orm.api.vo.CorporationAuditorVo; |
|||
|
|||
public class ExcelTemplateVo extends CorporationAuditorVo { |
|||
|
|||
//主键
|
|||
private String id; |
|||
|
|||
// 模板编码
|
|||
private String templateCode; |
|||
|
|||
// 模板名称
|
|||
private String templateName; |
|||
|
|||
// 模板配置的内容
|
|||
private String templateConfig; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTemplateCode() { |
|||
return templateCode; |
|||
} |
|||
|
|||
public void setTemplateCode(String templateCode) { |
|||
this.templateCode = templateCode; |
|||
} |
|||
|
|||
public String getTemplateName() { |
|||
return templateName; |
|||
} |
|||
|
|||
public void setTemplateName(String templateName) { |
|||
this.templateName = templateName; |
|||
} |
|||
|
|||
public String getTemplateConfig() { |
|||
return templateConfig; |
|||
} |
|||
|
|||
public void setTemplateConfig(String templateConfig) { |
|||
this.templateConfig = templateConfig; |
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
package io.sc.platform.lcdp.form.controller; |
|||
|
|||
import io.sc.platform.jdbc.meta.support.Column; |
|||
import io.sc.platform.jdbc.meta.support.Schema; |
|||
import io.sc.platform.jdbc.meta.support.TableSummary; |
|||
import io.sc.platform.lcdp.form.entity.FormEntity; |
|||
import io.sc.platform.lcdp.form.repository.FormRepository; |
|||
import io.sc.platform.lcdp.form.service.FormService; |
|||
import io.sc.platform.lcdp.form.support.GridPageWrapper; |
|||
import io.sc.platform.lcdp.form.vo.FormVo; |
|||
import io.sc.platform.mvc.controller.support.RestCrudController; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/template/config") |
|||
public class FormController extends RestCrudController<FormVo, FormEntity,String, FormRepository, FormService> { |
|||
|
|||
@RequestMapping(value="schemas",method= RequestMethod.GET) |
|||
public List<Schema> schemas() throws Exception { |
|||
return service.schemas(); |
|||
} |
|||
|
|||
@RequestMapping(value = {"tables/{schema}", "tables"},method= RequestMethod.POST) |
|||
public List<TableSummary> tables(@PathVariable(name = "schema", required = false) String schema, @RequestBody String[] excludeTableTypes) throws Exception { |
|||
return service.tables(schema, excludeTableTypes); |
|||
} |
|||
|
|||
@RequestMapping(value = {"columns/{schema}/{table}", "columns/{table}"},method= RequestMethod.GET) |
|||
public List<Column> columns(@PathVariable(name="schema", required = false) String schema, @PathVariable(name="table") String table) throws Exception { |
|||
return service.columns(schema, table); |
|||
} |
|||
|
|||
@RequestMapping(value="add",method= RequestMethod.POST) |
|||
public FormEntity add(@RequestBody GridPageWrapper tcrw) throws Exception { |
|||
return service.add(tcrw); |
|||
} |
|||
|
|||
@RequestMapping(value="edit",method= RequestMethod.POST) |
|||
public FormEntity edit(@RequestBody GridPageWrapper tcrw) throws Exception { |
|||
return service.edit(tcrw); |
|||
} |
|||
|
|||
@RequestMapping(value="delete",method= RequestMethod.POST) |
|||
public void delete(@RequestBody String[] templateConfigIds) throws Exception { |
|||
service.delete(templateConfigIds); |
|||
} |
|||
|
|||
@RequestMapping(value="fetch/{templateConfigId}",method= RequestMethod.GET) |
|||
public GridPageWrapper fetch(@PathVariable(name="templateConfigId") String templateConfigId) throws Exception { |
|||
return service.fetch(templateConfigId); |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
package io.sc.platform.lcdp.form.controller; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.GridFieldEntity; |
|||
import io.sc.platform.lcdp.form.repository.GridFieldRepository; |
|||
import io.sc.platform.lcdp.form.service.GridFieldService; |
|||
import io.sc.platform.lcdp.form.vo.GridFieldVo; |
|||
import io.sc.platform.mvc.controller.support.RestCrudController; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/template/grid/field") |
|||
public class GridFieldController extends RestCrudController<GridFieldVo, GridFieldEntity,String, GridFieldRepository, GridFieldService> { |
|||
} |
@ -0,0 +1,14 @@ |
|||
package io.sc.platform.lcdp.form.controller; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
import io.sc.platform.lcdp.form.repository.GridPageRepository; |
|||
import io.sc.platform.lcdp.form.service.GridPageService; |
|||
import io.sc.platform.lcdp.form.vo.GridPageVo; |
|||
import io.sc.platform.mvc.controller.support.RestCrudController; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/template/grid") |
|||
public class GridPageController extends RestCrudController<GridPageVo, GridPageEntity,String, GridPageRepository, GridPageService> { |
|||
} |
@ -0,0 +1,59 @@ |
|||
package io.sc.platform.lcdp.form.controller; |
|||
|
|||
import io.sc.platform.lcdp.form.service.JdbcTemplateService; |
|||
import io.sc.platform.orm.service.support.QueryParameter; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/jdbc") |
|||
public class JdbcTemplateController { |
|||
|
|||
@Autowired |
|||
private JdbcTemplateService service; |
|||
|
|||
@RequestMapping(value="list",method= RequestMethod.GET) |
|||
@ResponseBody |
|||
public Map<String, Object> list(String templateGridId, QueryParameter parameter) throws Exception { |
|||
return service.list(templateGridId, parameter); |
|||
} |
|||
|
|||
@RequestMapping(value="add/{templateGridId}",method= RequestMethod.POST) |
|||
@ResponseBody |
|||
public void add(@PathVariable(name="templateGridId") String templateGridId, @RequestBody Map<String, Object> data) throws Exception { |
|||
service.add(templateGridId, data); |
|||
} |
|||
|
|||
@RequestMapping(value="edit/{templateGridId}/{tableRowKey}/{tableRowKeyValue}",method= RequestMethod.PUT) |
|||
@ResponseBody |
|||
public void edit(@PathVariable(name="templateGridId") String templateGridId, @PathVariable(name="tableRowKey") String tableRowKey, @PathVariable(name="tableRowKeyValue") String tableRowKeyValue, @RequestBody Map<String, Object> data) throws Exception { |
|||
service.edit(templateGridId, tableRowKey, tableRowKeyValue, data); |
|||
} |
|||
|
|||
@RequestMapping(value="delete/{templateGridId}/{tableRowKey}",method= RequestMethod.DELETE) |
|||
@ResponseBody |
|||
public void delete(@PathVariable(name="templateGridId") String templateGridId, @PathVariable(name="tableRowKey") String tableRowKey, @RequestBody String[] tableRowKeyValues) throws Exception { |
|||
service.delete(templateGridId, tableRowKey, tableRowKeyValues); |
|||
} |
|||
|
|||
/** |
|||
* 根据SQL查询字段、类型等元信息 |
|||
* @param sql |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
@RequestMapping(value="fetchMetaDataBySql",method= RequestMethod.POST) |
|||
@ResponseBody |
|||
public List<Map<String, Object>> fetchMetaDataBySql(@RequestBody String sql) throws Exception { |
|||
return service.fetchMetaDataBySql(sql); |
|||
} |
|||
|
|||
@RequestMapping(value="fetchDataBySql",method= RequestMethod.POST) |
|||
@ResponseBody |
|||
public List<Map<String, Object>> fetchDataBySql(@RequestBody String sql) throws Exception { |
|||
return service.fetchDataBySql(sql); |
|||
} |
|||
} |
@ -0,0 +1,100 @@ |
|||
package io.sc.platform.lcdp.form.entity; |
|||
|
|||
import io.sc.platform.lcdp.form.enums.PageLoadType; |
|||
import io.sc.platform.lcdp.form.enums.PageType; |
|||
import io.sc.platform.lcdp.form.vo.FormVo; |
|||
import io.sc.platform.orm.entity.CorporationAuditorEntity; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import javax.validation.constraints.Size; |
|||
|
|||
/** |
|||
* 低代码表单配置主表 |
|||
* @author likunming |
|||
* |
|||
*/ |
|||
@Entity |
|||
@Table(name="LCDP_FORM") |
|||
public class FormEntity extends CorporationAuditorEntity<FormVo> { |
|||
|
|||
//主键
|
|||
@Id |
|||
@GeneratedValue(generator = "system-uuid") |
|||
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
|||
@Column(name="ID_") |
|||
@Size(max=50) |
|||
protected String id; |
|||
|
|||
// 配置名称
|
|||
@Column(name="NAME_") |
|||
@Size(max=200) |
|||
protected String templateName; |
|||
|
|||
// 配置类型(grid:表格页面)
|
|||
@Column(name="TYPE_") |
|||
@Enumerated(EnumType.STRING) |
|||
protected PageType templateType; |
|||
|
|||
// 页面配置项
|
|||
@Column(name="CONFIG_") |
|||
protected String config; |
|||
|
|||
// 页面加载类型(JSON:通过本表的_config字段存储的json字符串加载;CONFIG:通过系统配置加载)
|
|||
@Column(name="PAGE_LOAD_TYPE_") |
|||
@Enumerated(EnumType.STRING) |
|||
protected PageLoadType pageLoadType; |
|||
|
|||
@Override |
|||
public FormVo toVo() { |
|||
FormVo vo = new FormVo(); |
|||
super.toVo(vo); |
|||
|
|||
vo.setId(this.getId()); |
|||
vo.setTemplateName(this.getTemplateName()); |
|||
vo.setTemplateType(this.getTemplateType()); |
|||
vo.setConfig(this.getConfig()); |
|||
vo.setPageLoadType(this.getPageLoadType()); |
|||
return vo; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTemplateName() { |
|||
return templateName; |
|||
} |
|||
|
|||
public void setTemplateName(String templateName) { |
|||
this.templateName = templateName; |
|||
} |
|||
|
|||
public PageType getTemplateType() { |
|||
return templateType; |
|||
} |
|||
|
|||
public void setTemplateType(PageType templateType) { |
|||
this.templateType = templateType; |
|||
} |
|||
|
|||
public String getConfig() { |
|||
return config; |
|||
} |
|||
|
|||
public void setConfig(String config) { |
|||
this.config = config; |
|||
} |
|||
|
|||
public PageLoadType getPageLoadType() { |
|||
return pageLoadType; |
|||
} |
|||
|
|||
public void setPageLoadType(PageLoadType pageLoadType) { |
|||
this.pageLoadType = pageLoadType; |
|||
} |
|||
} |
@ -0,0 +1,419 @@ |
|||
package io.sc.platform.lcdp.form.entity; |
|||
|
|||
import io.sc.platform.lcdp.form.enums.AddValueType; |
|||
import io.sc.platform.lcdp.form.vo.GridFieldVo; |
|||
import io.sc.platform.orm.converter.NumericBooleanConverter; |
|||
import io.sc.platform.orm.entity.CorporationAuditorEntity; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import javax.validation.constraints.Size; |
|||
|
|||
/** |
|||
* 低代码表单配置-表格页面字段配置表 |
|||
* @author likunming |
|||
* |
|||
*/ |
|||
@Entity |
|||
@Table(name="LCDP_FORM_GRID_FIELD") |
|||
public class GridFieldEntity extends CorporationAuditorEntity<GridFieldVo> { |
|||
|
|||
//主键
|
|||
@Id |
|||
@GeneratedValue(generator = "system-uuid") |
|||
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
|||
@Column(name="ID_") |
|||
@Size(max=50) |
|||
protected String id; |
|||
|
|||
// 所属表格模板ID
|
|||
@ManyToOne(fetch=FetchType.LAZY) |
|||
@JoinColumn(name="GRID_ID_") |
|||
protected GridPageEntity templateGrid; |
|||
|
|||
// 字段所属的父类型(query_field: 查询字段;where_field: 条件字段)
|
|||
@Column(name="PARENT_") |
|||
@Size(max=50) |
|||
protected String parent; |
|||
|
|||
// 字段名称
|
|||
@Column(name="FIELD_NAME_") |
|||
@Size(max=100) |
|||
protected String fieldName; |
|||
|
|||
// 页面显示名称
|
|||
@Column(name="FIELD_LABEL_") |
|||
@Size(max=500) |
|||
protected String fieldLabel; |
|||
|
|||
// 字段类型
|
|||
@Column(name="FIELD_TYPE_") |
|||
// @Enumerated(EnumType.STRING)
|
|||
protected String fieldType; |
|||
|
|||
// 字段序号
|
|||
@Column(name="SORT_NO_") |
|||
protected Integer sortNo; |
|||
|
|||
// 字段长度
|
|||
@Column(name="FIELD_LENGTH_") |
|||
protected Integer fieldLength; |
|||
|
|||
// 字段精度
|
|||
@Column(name="FIELD_PRECISION_") |
|||
protected Integer fieldPrecision; |
|||
|
|||
// 字段是否为选项值
|
|||
@Column(name="FIELD_IS_SELECT_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean fieldIsSelect; |
|||
|
|||
// 选项值来源(dictionary: 数据字典, javaApi: java接口, array: 自定义数组)
|
|||
@Column(name="OPTION_COME_FROM_") |
|||
@Size(max=100) |
|||
protected String optionComeFrom; |
|||
|
|||
// 数据字典选项值
|
|||
@Column(name="DICT_OPTION_VALUE_") |
|||
@Size(max=100) |
|||
protected String dictionaryOptionValue; |
|||
|
|||
// 其他选项值
|
|||
@Column(name="OTHER_OPTION_VALUE_") |
|||
@Size(max=1000) |
|||
protected String otherOptionValue; |
|||
|
|||
// 新增时系统自动填充类型
|
|||
@Column(name="ADD_SYS_VALUE_TYPE_") |
|||
@Enumerated(EnumType.STRING) |
|||
protected AddValueType addValueType; |
|||
|
|||
// 修改时覆盖系统自动填充值
|
|||
@Column(name="EDIT_OVERRIDE_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean editOverride; |
|||
|
|||
// 查询面板中显示
|
|||
@Column(name="QUERY_SHOW_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean queryShow; |
|||
|
|||
// 使用的表单类型
|
|||
@Column(name="QUERY_FORM_TYPE_") |
|||
@Size(max=100) |
|||
protected String queryFormType; |
|||
|
|||
// 默认值
|
|||
@Column(name="QUERY_DEFA_VALUE_") |
|||
@Size(max=500) |
|||
protected String queryDefaultValue; |
|||
|
|||
// 是否必填项
|
|||
@Column(name="QUERY_IS_REQUIRED_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean queryIsRequired; |
|||
|
|||
// 匹配模式(like:模糊匹配, equals:完全匹配)
|
|||
@Column(name="QUERY_OPERATOR_") |
|||
@Size(max=100) |
|||
protected String queryOperator; |
|||
|
|||
// 列表中显示
|
|||
@Column(name="TABLE_SHOW_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean tableShow; |
|||
|
|||
// 是否支持排序
|
|||
@Column(name="TABLE_SORT_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean tableSort; |
|||
|
|||
// 列对齐方式
|
|||
@Column(name="TABLE_COLUMN_ALIGN_") |
|||
@Size(max=100) |
|||
protected String tableColumnAlign; |
|||
|
|||
// 列宽
|
|||
@Column(name="TABLE_COLUMN_WIDTH_") |
|||
protected Integer tableColumnWidth; |
|||
|
|||
// 新增编辑页面是否显示
|
|||
@Column(name="EDITOR_SHOW_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean editorShow; |
|||
|
|||
// 使用的表单类型
|
|||
@Column(name="EDITOR_FORM_TYPE_") |
|||
@Size(max=100) |
|||
protected String editorFormType; |
|||
|
|||
// 默认值
|
|||
@Column(name="EDITOR_DEFA_VALUE_") |
|||
@Size(max=500) |
|||
protected String editorDefaultValue; |
|||
|
|||
// 是否必填项
|
|||
@Column(name="EDITOR_IS_REQUIRED_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean editorIsRequired; |
|||
|
|||
@Override |
|||
public GridFieldVo toVo() { |
|||
GridFieldVo vo = new GridFieldVo(); |
|||
super.toVo(vo); |
|||
|
|||
vo.setId(this.getId()); |
|||
vo.setTemplateGrid(this.getTemplateGrid().getId()); |
|||
vo.setParent(this.getParent()); |
|||
vo.setFieldName(this.getFieldName()); |
|||
vo.setFieldLabel(this.getFieldLabel()); |
|||
vo.setFieldType(this.getFieldType()); |
|||
vo.setSortNo(this.getSortNo()); |
|||
vo.setFieldLength(this.getFieldLength()); |
|||
vo.setFieldPrecision(this.getFieldPrecision()); |
|||
vo.setFieldIsSelect(this.getFieldIsSelect()); |
|||
vo.setOptionComeFrom(this.getOptionComeFrom()); |
|||
vo.setDictionaryOptionValue(this.getDictionaryOptionValue()); |
|||
vo.setOtherOptionValue(this.getOtherOptionValue()); |
|||
vo.setAddValueType(this.getAddValueType()); |
|||
vo.setEditOverride(this.getEditOverride()); |
|||
vo.setQueryShow(this.getQueryShow()); |
|||
vo.setQueryFormType(this.getQueryFormType()); |
|||
vo.setQueryDefaultValue(this.getQueryDefaultValue()); |
|||
vo.setQueryIsRequired(this.getQueryIsRequired()); |
|||
vo.setQueryOperator(this.getQueryOperator()); |
|||
vo.setTableShow(this.getTableShow()); |
|||
vo.setTableSort(this.getTableSort()); |
|||
vo.setTableColumnAlign(this.getTableColumnAlign()); |
|||
vo.setTableColumnWidth(this.getTableColumnWidth()); |
|||
vo.setEditorShow(this.getEditorShow()); |
|||
vo.setEditorFormType(this.getEditorFormType()); |
|||
vo.setEditorDefaultValue(this.getEditorDefaultValue()); |
|||
vo.setEditorIsRequired(this.getEditorIsRequired()); |
|||
return vo; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public GridPageEntity getTemplateGrid() { |
|||
return templateGrid; |
|||
} |
|||
|
|||
public void setTemplateGrid(GridPageEntity templateGrid) { |
|||
this.templateGrid = templateGrid; |
|||
} |
|||
|
|||
public String getParent() { |
|||
return parent; |
|||
} |
|||
|
|||
public void setParent(String parent) { |
|||
this.parent = parent; |
|||
} |
|||
|
|||
public String getFieldName() { |
|||
return fieldName; |
|||
} |
|||
|
|||
public void setFieldName(String fieldName) { |
|||
this.fieldName = fieldName; |
|||
} |
|||
|
|||
public String getFieldLabel() { |
|||
return fieldLabel; |
|||
} |
|||
|
|||
public void setFieldLabel(String fieldLabel) { |
|||
this.fieldLabel = fieldLabel; |
|||
} |
|||
|
|||
public String getFieldType() { |
|||
return fieldType; |
|||
} |
|||
|
|||
public void setFieldType(String fieldType) { |
|||
this.fieldType = fieldType; |
|||
} |
|||
|
|||
public Integer getSortNo() { |
|||
return sortNo; |
|||
} |
|||
|
|||
public void setSortNo(Integer sortNo) { |
|||
this.sortNo = sortNo; |
|||
} |
|||
|
|||
public Integer getFieldLength() { |
|||
return fieldLength; |
|||
} |
|||
|
|||
public void setFieldLength(Integer fieldLength) { |
|||
this.fieldLength = fieldLength; |
|||
} |
|||
|
|||
public Integer getFieldPrecision() { |
|||
return fieldPrecision; |
|||
} |
|||
|
|||
public void setFieldPrecision(Integer fieldPrecision) { |
|||
this.fieldPrecision = fieldPrecision; |
|||
} |
|||
|
|||
public Boolean getFieldIsSelect() { |
|||
return fieldIsSelect; |
|||
} |
|||
|
|||
public void setFieldIsSelect(Boolean fieldIsSelect) { |
|||
this.fieldIsSelect = fieldIsSelect; |
|||
} |
|||
|
|||
public String getOptionComeFrom() { |
|||
return optionComeFrom; |
|||
} |
|||
|
|||
public void setOptionComeFrom(String optionComeFrom) { |
|||
this.optionComeFrom = optionComeFrom; |
|||
} |
|||
|
|||
public String getDictionaryOptionValue() { |
|||
return dictionaryOptionValue; |
|||
} |
|||
|
|||
public void setDictionaryOptionValue(String dictionaryOptionValue) { |
|||
this.dictionaryOptionValue = dictionaryOptionValue; |
|||
} |
|||
|
|||
public String getOtherOptionValue() { |
|||
return otherOptionValue; |
|||
} |
|||
|
|||
public void setOtherOptionValue(String otherOptionValue) { |
|||
this.otherOptionValue = otherOptionValue; |
|||
} |
|||
|
|||
public AddValueType getAddValueType() { |
|||
return addValueType; |
|||
} |
|||
|
|||
public void setAddValueType(AddValueType addValueType) { |
|||
this.addValueType = addValueType; |
|||
} |
|||
|
|||
public Boolean getEditOverride() { |
|||
return editOverride; |
|||
} |
|||
|
|||
public void setEditOverride(Boolean editOverride) { |
|||
this.editOverride = editOverride; |
|||
} |
|||
|
|||
public Boolean getQueryShow() { |
|||
return queryShow; |
|||
} |
|||
|
|||
public void setQueryShow(Boolean queryShow) { |
|||
this.queryShow = queryShow; |
|||
} |
|||
|
|||
public String getQueryFormType() { |
|||
return queryFormType; |
|||
} |
|||
|
|||
public void setQueryFormType(String queryFormType) { |
|||
this.queryFormType = queryFormType; |
|||
} |
|||
|
|||
public String getQueryDefaultValue() { |
|||
return queryDefaultValue; |
|||
} |
|||
|
|||
public void setQueryDefaultValue(String queryDefaultValue) { |
|||
this.queryDefaultValue = queryDefaultValue; |
|||
} |
|||
|
|||
public Boolean getQueryIsRequired() { |
|||
return queryIsRequired; |
|||
} |
|||
|
|||
public void setQueryIsRequired(Boolean queryIsRequired) { |
|||
this.queryIsRequired = queryIsRequired; |
|||
} |
|||
|
|||
public String getQueryOperator() { |
|||
return queryOperator; |
|||
} |
|||
|
|||
public void setQueryOperator(String queryOperator) { |
|||
this.queryOperator = queryOperator; |
|||
} |
|||
|
|||
public Boolean getTableShow() { |
|||
return tableShow; |
|||
} |
|||
|
|||
public void setTableShow(Boolean tableShow) { |
|||
this.tableShow = tableShow; |
|||
} |
|||
|
|||
public Boolean getTableSort() { |
|||
return tableSort; |
|||
} |
|||
|
|||
public void setTableSort(Boolean tableSort) { |
|||
this.tableSort = tableSort; |
|||
} |
|||
|
|||
public String getTableColumnAlign() { |
|||
return tableColumnAlign; |
|||
} |
|||
|
|||
public void setTableColumnAlign(String tableColumnAlign) { |
|||
this.tableColumnAlign = tableColumnAlign; |
|||
} |
|||
|
|||
public Integer getTableColumnWidth() { |
|||
return tableColumnWidth; |
|||
} |
|||
|
|||
public void setTableColumnWidth(Integer tableColumnWidth) { |
|||
this.tableColumnWidth = tableColumnWidth; |
|||
} |
|||
|
|||
public Boolean getEditorShow() { |
|||
return editorShow; |
|||
} |
|||
|
|||
public void setEditorShow(Boolean editorShow) { |
|||
this.editorShow = editorShow; |
|||
} |
|||
|
|||
public String getEditorFormType() { |
|||
return editorFormType; |
|||
} |
|||
|
|||
public void setEditorFormType(String editorFormType) { |
|||
this.editorFormType = editorFormType; |
|||
} |
|||
|
|||
public String getEditorDefaultValue() { |
|||
return editorDefaultValue; |
|||
} |
|||
|
|||
public void setEditorDefaultValue(String editorDefaultValue) { |
|||
this.editorDefaultValue = editorDefaultValue; |
|||
} |
|||
|
|||
public Boolean getEditorIsRequired() { |
|||
return editorIsRequired; |
|||
} |
|||
|
|||
public void setEditorIsRequired(Boolean editorIsRequired) { |
|||
this.editorIsRequired = editorIsRequired; |
|||
} |
|||
} |
@ -0,0 +1,545 @@ |
|||
package io.sc.platform.lcdp.form.entity; |
|||
|
|||
import io.sc.platform.lcdp.form.enums.FieldComeFrom; |
|||
import io.sc.platform.lcdp.form.vo.GridPageVo; |
|||
import io.sc.platform.orm.converter.ArrayStringConverter; |
|||
import io.sc.platform.orm.converter.NumericBooleanConverter; |
|||
import io.sc.platform.orm.entity.CorporationAuditorEntity; |
|||
import org.hibernate.annotations.GenericGenerator; |
|||
|
|||
import javax.persistence.*; |
|||
import javax.validation.constraints.Size; |
|||
|
|||
/** |
|||
* 低代码表单配置-表格页面主要配置表 |
|||
* @author likunming |
|||
* |
|||
*/ |
|||
@Entity |
|||
@Table(name="LCDP_FORM_GRID") |
|||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) |
|||
public class GridPageEntity extends CorporationAuditorEntity<GridPageVo> { |
|||
|
|||
|
|||
//主键
|
|||
@Id |
|||
@GeneratedValue(generator = "system-uuid") |
|||
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
|||
@Column(name="ID_") |
|||
@Size(max=50) |
|||
protected String id; |
|||
|
|||
// 所属模板
|
|||
@ManyToOne(fetch=FetchType.LAZY) |
|||
@JoinColumn(name="TEMPLATE_ID_") |
|||
protected FormEntity templateConfig; |
|||
|
|||
// 字段来源
|
|||
@Column(name="FIELD_COME_FROM") |
|||
@Enumerated(EnumType.STRING) |
|||
protected FieldComeFrom fieldComeFrom; |
|||
|
|||
// schema
|
|||
@Column(name="SCHEMA_") |
|||
@Size(max=100) |
|||
protected String schema; |
|||
|
|||
// 数据表名
|
|||
@Column(name="DATABASE_TABLE_") |
|||
@Size(max=100) |
|||
protected String databaseTable; |
|||
|
|||
// SQL
|
|||
@Column(name="SQL_") |
|||
protected String sql; |
|||
|
|||
// 表格名称
|
|||
@Column(name="TITLE_") |
|||
@Size(max=100) |
|||
protected String title; |
|||
|
|||
// 表格按钮
|
|||
@Column(name="BUTTONS_") |
|||
@Convert(converter = ArrayStringConverter.class) |
|||
protected String[] buttons; |
|||
|
|||
// 选择模式(none:不允许选中;cell:单元格选择;row:行选择)
|
|||
@Column(name="SELECTION_") |
|||
@Size(max=100) |
|||
protected String selection; |
|||
|
|||
// 数据主键
|
|||
@Column(name="PRIMARY_KEY_") |
|||
@Size(max=100) |
|||
protected String primaryKey; |
|||
|
|||
// 数据外键
|
|||
@Column(name="FOREIGN_KEY_") |
|||
@Size(max=100) |
|||
protected String foreignKey; |
|||
|
|||
// 数据操作URL前缀
|
|||
@Column(name="DATA_URL_") |
|||
@Size(max=1000) |
|||
protected String dataUrl; |
|||
|
|||
// 加载数据URL
|
|||
@Column(name="FETCH_DATA_URL_") |
|||
@Size(max=1000) |
|||
protected String fetchDataUrl; |
|||
|
|||
// 新增URL
|
|||
@Column(name="ADD_DATA_URL_") |
|||
@Size(max=1000) |
|||
protected String addDataUrl; |
|||
|
|||
// 编辑URL
|
|||
@Column(name="EDIT_DATA_URL_") |
|||
@Size(max=1000) |
|||
protected String editDataUrl; |
|||
|
|||
// 删除URL
|
|||
@Column(name="REMOVE_DATA_URL_") |
|||
@Size(max=1000) |
|||
protected String removeDataUrl; |
|||
|
|||
// 是否显示序号列
|
|||
@Column(name="SORT_NO_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean sortNo; |
|||
|
|||
// 是否显示复选框列
|
|||
@Column(name="CHECKBOX_SELECTION_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean checkboxSelection; |
|||
|
|||
// 行是否允许拖拽
|
|||
@Column(name="DRAGGABLE_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean draggable; |
|||
|
|||
// 是否自动加载数据
|
|||
@Column(name="AUTO_FETCH_DATA_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean autoFetchData; |
|||
|
|||
// 紧凑模式
|
|||
@Column(name="DENSE_") |
|||
@Convert(converter = ArrayStringConverter.class) |
|||
protected String[] dense; |
|||
|
|||
// 列冻结数
|
|||
@Column(name="STICKY_NUM_") |
|||
protected Integer stickyNum; |
|||
|
|||
// 是否为树形表格
|
|||
@Column(name="TREE_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean tree; |
|||
|
|||
// 树形表格数据关系
|
|||
@Column(name="TREE_RELATIONSHIP_") |
|||
@Size(max=100) |
|||
protected String treeRelationship; |
|||
|
|||
// 树形表格图标函数
|
|||
@Column(name="TREE_ICON_") |
|||
@Size(max=1000) |
|||
protected String treeIcon; |
|||
|
|||
// 树形表格默认全部展开
|
|||
@Column(name="TREE_DEFAULT_EXPAND_ALL_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean treeDefaultExpandAll; |
|||
|
|||
// 树形表格勾选策略
|
|||
@Column(name="TREE_TICK_STRATEGY_") |
|||
@Size(max=100) |
|||
protected String treeTickStrategy; |
|||
|
|||
// checkbox勾选映射字段名
|
|||
@Column(name="TICKED_FIELD_") |
|||
@Size(max=100) |
|||
protected String tickedField; |
|||
|
|||
// 行点击选中映射字段名
|
|||
@Column(name="SELECTED_FIELD_") |
|||
@Size(max=100) |
|||
protected String selectedField; |
|||
|
|||
// 默认排序字段
|
|||
@Column(name="DEFAULT_SORT_BY_") |
|||
@Size(max=100) |
|||
protected String defaultSortBy; |
|||
|
|||
// 排序方式是否为倒序
|
|||
@Column(name="DESCENDING_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean descending; |
|||
|
|||
// 是否分页
|
|||
@Column(name="PAGEABLE_") |
|||
@Convert(converter= NumericBooleanConverter.class) |
|||
protected Boolean pageable; |
|||
|
|||
// 每页显示行数
|
|||
@Column(name="ROWS_PER_PAGE_") |
|||
protected Integer rowsPerPage; |
|||
|
|||
// 后端查询使用的初始页码
|
|||
@Column(name="REQ_PAGE_START_") |
|||
protected Integer reqPageStart; |
|||
|
|||
// 查询面板一行显示个数(0为自适应)
|
|||
@Column(name="QUERY_FORM_COLS_NUM_") |
|||
protected Integer queryFormColsNum; |
|||
|
|||
// 查询面板显示行数
|
|||
@Column(name="QUERY_FORM_ROW_NUM_") |
|||
protected Integer queryFormRowNum; |
|||
|
|||
// 编辑面板一行显示元素个数
|
|||
@Column(name="EDITOR_FORM_COLS_NUM_") |
|||
protected Integer editorFormColsNum; |
|||
|
|||
@Override |
|||
public GridPageVo toVo() { |
|||
GridPageVo vo = new GridPageVo(); |
|||
super.toVo(vo); |
|||
|
|||
vo.setId(this.getId()); |
|||
vo.setTemplateConfig(this.getTemplateConfig().getId()); |
|||
vo.setFieldComeFrom(this.getFieldComeFrom()); |
|||
vo.setSchema(this.getSchema()); |
|||
vo.setDatabaseTable(this.getDatabaseTable()); |
|||
vo.setSql(this.getSql()); |
|||
vo.setTitle(this.getTitle()); |
|||
vo.setButtons(this.getButtons()); |
|||
vo.setSelection(this.getSelection()); |
|||
vo.setPrimaryKey(this.getPrimaryKey()); |
|||
vo.setForeignKey(this.getForeignKey()); |
|||
vo.setDataUrl(this.getDataUrl()); |
|||
vo.setFetchDataUrl(this.getFetchDataUrl()); |
|||
vo.setAddDataUrl(this.getAddDataUrl()); |
|||
vo.setEditDataUrl(this.getEditDataUrl()); |
|||
vo.setRemoveDataUrl(this.getRemoveDataUrl()); |
|||
vo.setSortNo(this.getSortNo()); |
|||
vo.setCheckboxSelection(this.getCheckboxSelection()); |
|||
vo.setDraggable(this.getDraggable()); |
|||
vo.setAutoFetchData(this.getAutoFetchData()); |
|||
vo.setDense(this.getDense()); |
|||
vo.setStickyNum(this.getStickyNum()); |
|||
vo.setTree(this.getTree()); |
|||
vo.setTreeRelationship(this.getTreeRelationship()); |
|||
vo.setTreeIcon(this.getTreeIcon()); |
|||
vo.setTreeDefaultExpandAll(this.getTreeDefaultExpandAll()); |
|||
vo.setTreeTickStrategy(this.getTreeTickStrategy()); |
|||
vo.setTickedField(this.getTickedField()); |
|||
vo.setSelectedField(this.getSelectedField()); |
|||
vo.setDefaultSortBy(this.getDefaultSortBy()); |
|||
vo.setDescending(this.getDescending()); |
|||
vo.setPageable(this.getPageable()); |
|||
vo.setRowsPerPage(this.getRowsPerPage()); |
|||
vo.setReqPageStart(this.getReqPageStart()); |
|||
vo.setQueryFormColsNum(this.getQueryFormColsNum()); |
|||
vo.setQueryFormRowNum(this.getQueryFormRowNum()); |
|||
vo.setEditorFormColsNum(this.getEditorFormColsNum()); |
|||
return vo; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public FormEntity getTemplateConfig() { |
|||
return templateConfig; |
|||
} |
|||
|
|||
public void setTemplateConfig(FormEntity templateConfig) { |
|||
this.templateConfig = templateConfig; |
|||
} |
|||
|
|||
public FieldComeFrom getFieldComeFrom() { |
|||
return fieldComeFrom; |
|||
} |
|||
|
|||
public void setFieldComeFrom(FieldComeFrom fieldComeFrom) { |
|||
this.fieldComeFrom = fieldComeFrom; |
|||
} |
|||
|
|||
public String getSql() { |
|||
return sql; |
|||
} |
|||
|
|||
public void setSql(String sql) { |
|||
this.sql = sql; |
|||
} |
|||
|
|||
public String getSchema() { |
|||
return schema; |
|||
} |
|||
|
|||
public void setSchema(String schema) { |
|||
this.schema = schema; |
|||
} |
|||
|
|||
public String getDatabaseTable() { |
|||
return databaseTable; |
|||
} |
|||
|
|||
public void setDatabaseTable(String databaseTable) { |
|||
this.databaseTable = databaseTable; |
|||
} |
|||
|
|||
public String getTitle() { |
|||
return title; |
|||
} |
|||
|
|||
public void setTitle(String title) { |
|||
this.title = title; |
|||
} |
|||
|
|||
public String[] getButtons() { |
|||
return buttons; |
|||
} |
|||
|
|||
public void setButtons(String[] buttons) { |
|||
this.buttons = buttons; |
|||
} |
|||
|
|||
public String getSelection() { |
|||
return selection; |
|||
} |
|||
|
|||
public void setSelection(String selection) { |
|||
this.selection = selection; |
|||
} |
|||
|
|||
public String getPrimaryKey() { |
|||
return primaryKey; |
|||
} |
|||
|
|||
public void setPrimaryKey(String primaryKey) { |
|||
this.primaryKey = primaryKey; |
|||
} |
|||
|
|||
public String getForeignKey() { |
|||
return foreignKey; |
|||
} |
|||
|
|||
public void setForeignKey(String foreignKey) { |
|||
this.foreignKey = foreignKey; |
|||
} |
|||
|
|||
public String getDataUrl() { |
|||
return dataUrl; |
|||
} |
|||
|
|||
public void setDataUrl(String dataUrl) { |
|||
this.dataUrl = dataUrl; |
|||
} |
|||
|
|||
public String getFetchDataUrl() { |
|||
return fetchDataUrl; |
|||
} |
|||
|
|||
public void setFetchDataUrl(String fetchDataUrl) { |
|||
this.fetchDataUrl = fetchDataUrl; |
|||
} |
|||
|
|||
public String getAddDataUrl() { |
|||
return addDataUrl; |
|||
} |
|||
|
|||
public void setAddDataUrl(String addDataUrl) { |
|||
this.addDataUrl = addDataUrl; |
|||
} |
|||
|
|||
public String getEditDataUrl() { |
|||
return editDataUrl; |
|||
} |
|||
|
|||
public void setEditDataUrl(String editDataUrl) { |
|||
this.editDataUrl = editDataUrl; |
|||
} |
|||
|
|||
public String getRemoveDataUrl() { |
|||
return removeDataUrl; |
|||
} |
|||
|
|||
public void setRemoveDataUrl(String removeDataUrl) { |
|||
this.removeDataUrl = removeDataUrl; |
|||
} |
|||
|
|||
public Boolean getSortNo() { |
|||
return sortNo; |
|||
} |
|||
|
|||
public void setSortNo(Boolean sortNo) { |
|||
this.sortNo = sortNo; |
|||
} |
|||
|
|||
public Boolean getCheckboxSelection() { |
|||
return checkboxSelection; |
|||
} |
|||
|
|||
public void setCheckboxSelection(Boolean checkboxSelection) { |
|||
this.checkboxSelection = checkboxSelection; |
|||
} |
|||
|
|||
public Boolean getDraggable() { |
|||
return draggable; |
|||
} |
|||
|
|||
public void setDraggable(Boolean draggable) { |
|||
this.draggable = draggable; |
|||
} |
|||
|
|||
public Boolean getAutoFetchData() { |
|||
return autoFetchData; |
|||
} |
|||
|
|||
public void setAutoFetchData(Boolean autoFetchData) { |
|||
this.autoFetchData = autoFetchData; |
|||
} |
|||
|
|||
public String[] getDense() { |
|||
return dense; |
|||
} |
|||
|
|||
public void setDense(String[] dense) { |
|||
this.dense = dense; |
|||
} |
|||
|
|||
public Integer getStickyNum() { |
|||
return stickyNum; |
|||
} |
|||
|
|||
public void setStickyNum(Integer stickyNum) { |
|||
this.stickyNum = stickyNum; |
|||
} |
|||
|
|||
public Boolean getTree() { |
|||
return tree; |
|||
} |
|||
|
|||
public void setTree(Boolean tree) { |
|||
this.tree = tree; |
|||
} |
|||
|
|||
public String getTreeRelationship() { |
|||
return treeRelationship; |
|||
} |
|||
|
|||
public void setTreeRelationship(String treeRelationship) { |
|||
this.treeRelationship = treeRelationship; |
|||
} |
|||
|
|||
public String getTreeIcon() { |
|||
return treeIcon; |
|||
} |
|||
|
|||
public void setTreeIcon(String treeIcon) { |
|||
this.treeIcon = treeIcon; |
|||
} |
|||
|
|||
public Boolean getTreeDefaultExpandAll() { |
|||
return treeDefaultExpandAll; |
|||
} |
|||
|
|||
public void setTreeDefaultExpandAll(Boolean treeDefaultExpandAll) { |
|||
this.treeDefaultExpandAll = treeDefaultExpandAll; |
|||
} |
|||
|
|||
public String getTreeTickStrategy() { |
|||
return treeTickStrategy; |
|||
} |
|||
|
|||
public void setTreeTickStrategy(String treeTickStrategy) { |
|||
this.treeTickStrategy = treeTickStrategy; |
|||
} |
|||
|
|||
public String getTickedField() { |
|||
return tickedField; |
|||
} |
|||
|
|||
public void setTickedField(String tickedField) { |
|||
this.tickedField = tickedField; |
|||
} |
|||
|
|||
public String getSelectedField() { |
|||
return selectedField; |
|||
} |
|||
|
|||
public void setSelectedField(String selectedField) { |
|||
this.selectedField = selectedField; |
|||
} |
|||
|
|||
public String getDefaultSortBy() { |
|||
return defaultSortBy; |
|||
} |
|||
|
|||
public void setDefaultSortBy(String defaultSortBy) { |
|||
this.defaultSortBy = defaultSortBy; |
|||
} |
|||
|
|||
public Boolean getDescending() { |
|||
return descending; |
|||
} |
|||
|
|||
public void setDescending(Boolean descending) { |
|||
this.descending = descending; |
|||
} |
|||
|
|||
public Boolean getPageable() { |
|||
return pageable; |
|||
} |
|||
|
|||
public void setPageable(Boolean pageable) { |
|||
this.pageable = pageable; |
|||
} |
|||
|
|||
public Integer getRowsPerPage() { |
|||
return rowsPerPage; |
|||
} |
|||
|
|||
public void setRowsPerPage(Integer rowsPerPage) { |
|||
this.rowsPerPage = rowsPerPage; |
|||
} |
|||
|
|||
public Integer getReqPageStart() { |
|||
return reqPageStart; |
|||
} |
|||
|
|||
public void setReqPageStart(Integer reqPageStart) { |
|||
this.reqPageStart = reqPageStart; |
|||
} |
|||
|
|||
public Integer getQueryFormColsNum() { |
|||
return queryFormColsNum; |
|||
} |
|||
|
|||
public void setQueryFormColsNum(Integer queryFormColsNum) { |
|||
this.queryFormColsNum = queryFormColsNum; |
|||
} |
|||
|
|||
public Integer getQueryFormRowNum() { |
|||
return queryFormRowNum; |
|||
} |
|||
|
|||
public void setQueryFormRowNum(Integer queryFormRowNum) { |
|||
this.queryFormRowNum = queryFormRowNum; |
|||
} |
|||
|
|||
public Integer getEditorFormColsNum() { |
|||
return editorFormColsNum; |
|||
} |
|||
|
|||
public void setEditorFormColsNum(Integer editorFormColsNum) { |
|||
this.editorFormColsNum = editorFormColsNum; |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
package io.sc.platform.lcdp.form.enums; |
|||
|
|||
/** |
|||
* 新增时系统自动填充值类型 |
|||
*/ |
|||
public enum AddValueType { |
|||
NONE, // 无填充类型,接收用户输入内容
|
|||
UUID, // 数据库UUID
|
|||
DCF_INPUT, // 数据来源-手工录入
|
|||
DCF_IMPORT, // 数据来源-系统自动导入
|
|||
CURR_USER, // 当前登录用户
|
|||
CURR_DATE, // 当前时间
|
|||
CURR_CORP // 当前所属法人
|
|||
} |
@ -0,0 +1,9 @@ |
|||
package io.sc.platform.lcdp.form.enums; |
|||
|
|||
/** |
|||
* 字段来源 |
|||
*/ |
|||
public enum FieldComeFrom { |
|||
table, // 数据库单表
|
|||
sql, // sql
|
|||
} |
@ -0,0 +1,23 @@ |
|||
package io.sc.platform.lcdp.form.enums; |
|||
|
|||
/** |
|||
* 字段类型 |
|||
*/ |
|||
public enum FieldType { |
|||
|
|||
String(java.lang.String.class), |
|||
Integer(java.lang.Integer.class), |
|||
BigDecimal(java.math.BigDecimal.class), |
|||
Date(java.util.Date.class), |
|||
Boolean(java.lang.Boolean.class); |
|||
|
|||
private final Class fieldTypeClass; |
|||
|
|||
private FieldType(Class fieldTypeClass) { |
|||
this.fieldTypeClass = fieldTypeClass; |
|||
} |
|||
|
|||
public Class getFieldTypeClass() { |
|||
return fieldTypeClass; |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
package io.sc.platform.lcdp.form.enums; |
|||
|
|||
/** |
|||
* 页面加载类型 |
|||
*/ |
|||
public enum PageLoadType { |
|||
JSON, // 通过表中配置的JSON字符串字段加载页面
|
|||
CONFIG // 通过配置表加载页面
|
|||
} |
@ -0,0 +1,8 @@ |
|||
package io.sc.platform.lcdp.form.enums; |
|||
|
|||
/** |
|||
* 页面类型 |
|||
*/ |
|||
public enum PageType { |
|||
GRID // 表格页面
|
|||
} |
@ -0,0 +1,7 @@ |
|||
package io.sc.platform.lcdp.form.repository; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.FormEntity; |
|||
import io.sc.platform.orm.repository.DaoRepository; |
|||
|
|||
public interface FormRepository extends DaoRepository<FormEntity, String> { |
|||
} |
@ -0,0 +1,11 @@ |
|||
package io.sc.platform.lcdp.form.repository; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.GridFieldEntity; |
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
import io.sc.platform.orm.repository.DaoRepository; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface GridFieldRepository extends DaoRepository<GridFieldEntity, String> { |
|||
List<GridFieldEntity> findByTemplateGridOrderBySortNoAsc(GridPageEntity templateGrid ); |
|||
} |
@ -0,0 +1,9 @@ |
|||
package io.sc.platform.lcdp.form.repository; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.FormEntity; |
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
import io.sc.platform.orm.repository.DaoRepository; |
|||
|
|||
public interface GridPageRepository extends DaoRepository<GridPageEntity, String> { |
|||
GridPageEntity findByTemplateConfig(FormEntity templateConfig); |
|||
} |
@ -0,0 +1,21 @@ |
|||
package io.sc.platform.lcdp.form.service; |
|||
|
|||
import io.sc.platform.jdbc.meta.support.Column; |
|||
import io.sc.platform.jdbc.meta.support.Schema; |
|||
import io.sc.platform.jdbc.meta.support.TableSummary; |
|||
import io.sc.platform.lcdp.form.entity.FormEntity; |
|||
import io.sc.platform.lcdp.form.repository.FormRepository; |
|||
import io.sc.platform.lcdp.form.support.GridPageWrapper; |
|||
import io.sc.platform.orm.service.DaoService; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface FormService extends DaoService<FormEntity, String, FormRepository> { |
|||
public List<Schema> schemas() throws Exception; |
|||
public List<TableSummary> tables(String schema, String[] excludeTableTypes) throws Exception; |
|||
public List<Column> columns(String schema, String table) throws Exception; |
|||
public FormEntity add(GridPageWrapper gpw) throws Exception; |
|||
public FormEntity edit(GridPageWrapper tcrw) throws Exception; |
|||
public void delete(String[] templateConfigIds) throws Exception; |
|||
public GridPageWrapper fetch(String templateConfigId) throws Exception; |
|||
} |
@ -0,0 +1,8 @@ |
|||
package io.sc.platform.lcdp.form.service; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.GridFieldEntity; |
|||
import io.sc.platform.lcdp.form.repository.GridFieldRepository; |
|||
import io.sc.platform.orm.service.DaoService; |
|||
|
|||
public interface GridFieldService extends DaoService<GridFieldEntity, String, GridFieldRepository> { |
|||
} |
@ -0,0 +1,8 @@ |
|||
package io.sc.platform.lcdp.form.service; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
import io.sc.platform.lcdp.form.repository.GridPageRepository; |
|||
import io.sc.platform.orm.service.DaoService; |
|||
|
|||
public interface GridPageService extends DaoService<GridPageEntity, String, GridPageRepository> { |
|||
} |
@ -0,0 +1,35 @@ |
|||
package io.sc.platform.lcdp.form.service; |
|||
|
|||
import io.sc.platform.jdbc.sql.condition.Condition; |
|||
import io.sc.platform.orm.service.support.QueryParameter; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface JdbcTemplateService { |
|||
public Map<String, Object> list(String templateGridId, QueryParameter parameter)throws Exception; |
|||
|
|||
/** |
|||
* 根据 QueryParameter 与 SQL 查询数据 |
|||
* @param parameter |
|||
* @param sql |
|||
* @param fieldTypeMap 前端查询面板的字段映射的 java 类型 |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, Object> listBySql(QueryParameter parameter, String sql, Map<String, Class<?>> fieldTypeMap)throws Exception; |
|||
/** |
|||
* 根据 QueryParameter 与 与自己组装的带where条件的SQL 查询数据 |
|||
* @param parameter |
|||
* @param sql |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, Object> listByConditionSql(QueryParameter parameter, String sql, Map<String, Object> conditionParamsMap)throws Exception; |
|||
public void add(String templateGridId, Map<String, Object> data)throws Exception; |
|||
public void edit(String templateGridId, String tableRowKey, String tableRowKeyValue, Map<String, Object> data)throws Exception; |
|||
public void delete(String templateGridId, String tableRowKey, String[] tableRowKeyValues) throws Exception; |
|||
public List<Map<String, Object>> fetchMetaDataBySql(String sql)throws Exception; |
|||
public List<Map<String, Object>> fetchDataBySql(String sql)throws Exception; |
|||
public Condition buildCondition(Map<String,Class<?>> mapping, QueryParameter queryParameter) throws Exception; |
|||
} |
@ -0,0 +1,237 @@ |
|||
package io.sc.platform.lcdp.form.service.impl; |
|||
|
|||
import io.sc.platform.jdbc.DatabaseType; |
|||
import io.sc.platform.jdbc.meta.MetaDataLoader; |
|||
import io.sc.platform.jdbc.meta.support.Column; |
|||
import io.sc.platform.jdbc.meta.support.Schema; |
|||
import io.sc.platform.jdbc.meta.support.TableSummary; |
|||
import io.sc.platform.lcdp.form.entity.FormEntity; |
|||
import io.sc.platform.lcdp.form.entity.GridFieldEntity; |
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
import io.sc.platform.lcdp.form.enums.FieldComeFrom; |
|||
import io.sc.platform.lcdp.form.repository.FormRepository; |
|||
import io.sc.platform.lcdp.form.service.FormService; |
|||
import io.sc.platform.lcdp.form.service.GridFieldService; |
|||
import io.sc.platform.lcdp.form.service.GridPageService; |
|||
import io.sc.platform.lcdp.form.support.*; |
|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.RowMapper; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.sql.Connection; |
|||
import java.sql.DatabaseMetaData; |
|||
import java.util.*; |
|||
|
|||
@Service("lcdpFormService") |
|||
public class FormServiceImpl extends DaoServiceImpl<FormEntity, String, FormRepository> implements FormService { |
|||
|
|||
public static final RowMapper<TableWrapper> TableWrapperRowMapper = TableWrapper.getRowMapper(); |
|||
public static final RowMapper<ColumnWrapper> ColumnWrapperRowMapper = ColumnWrapper.getRowMapper(); |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
@Autowired |
|||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate; |
|||
@Autowired |
|||
private GridPageService templateGridService; |
|||
@Autowired |
|||
private GridFieldService templateGridFieldService; |
|||
@Autowired |
|||
private DataSource dataSource; |
|||
|
|||
@Override |
|||
public List<Schema> schemas() throws Exception { |
|||
return MetaDataLoader.newInstance().getSchemas(dataSource); |
|||
} |
|||
|
|||
@Override |
|||
public List<TableSummary> tables(String schema, String[] excludeTableTypes) throws Exception { |
|||
List<TableWrapper> tables = getDatabaseTables(excludeTableTypes); |
|||
List<TableSummary> list = new ArrayList<>(); |
|||
for (TableWrapper wrapper: tables) { |
|||
TableSummary table = new TableSummary(); |
|||
table.setName(wrapper.getName()); |
|||
table.setRemarks(wrapper.getComment()); |
|||
list.add(table); |
|||
} |
|||
// List<TableSummary> list = MetaDataLoader.newInstance().getTableSummary(dataSource, schema, false);
|
|||
// // 排除不加载的表
|
|||
// List<String> excludeTables = getExcludeTables(excludeTableTypes);
|
|||
// if (null != excludeTables && excludeTables.size() > 0) {
|
|||
// list.removeIf((tableSummary) -> excludeTables.contains(tableSummary.getName()));
|
|||
// }
|
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public List<Column> columns(String schema, String table) throws Exception { |
|||
List<ColumnWrapper> columns = getTableColumns(table); |
|||
List<Column> columnList = new ArrayList<Column>(); |
|||
for(ColumnWrapper wrapper: columns) { |
|||
Column column = new Column(); |
|||
column.setName(wrapper.getName()); |
|||
column.setRemarks(wrapper.getComment()); |
|||
columnList.add(column); |
|||
} |
|||
// List<Table> list = MetaDataLoader.newInstance().getTables(dataSource, schema, table);
|
|||
// List<Column> columnList = new ArrayList<Column>();
|
|||
// if (null != list && list.size() > 0) {
|
|||
// columnList = list.get(0).getColumns();
|
|||
// }
|
|||
return columnList; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public FormEntity add(GridPageWrapper tcrw) throws Exception { |
|||
FormEntity templateConfig = tcrw.getTemplateConfig(); |
|||
GridPageEntity templateGrid = tcrw.getTemplateGrid(); |
|||
|
|||
List<GridFieldEntity> templateGridFields = tcrw.getTemplateGridFields(); |
|||
repository.save(templateConfig); |
|||
|
|||
templateGrid.setTemplateConfig(templateConfig); |
|||
buildTemplateGrid(templateGrid); |
|||
templateGridService.getRepository().save(templateGrid); |
|||
|
|||
for (int i = 0; i < templateGridFields.size(); i++) { |
|||
templateGridFields.get(i).setTemplateGrid(templateGrid); |
|||
templateGridFields.get(i).setId(null); |
|||
} |
|||
templateGridFieldService.getRepository().saveAll(templateGridFields); |
|||
|
|||
return templateConfig; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public FormEntity edit(GridPageWrapper tcrw) throws Exception { |
|||
FormEntity templateConfig = tcrw.getTemplateConfig(); |
|||
GridPageEntity templateGrid = tcrw.getTemplateGrid(); |
|||
List<GridFieldEntity> templateGridFields = tcrw.getTemplateGridFields(); |
|||
if (null == templateConfig.getId() || "".equals(templateConfig.getId())) { |
|||
throw new RuntimeException("模板ID为空,保存失败"); |
|||
} |
|||
Optional<FormEntity> templateConfigOptional = repository.findById(templateConfig.getId()); |
|||
if (null == templateConfigOptional || null == templateConfigOptional.get()) { |
|||
throw new RuntimeException("根据模板ID未查找到数据,保存失败"); |
|||
} |
|||
|
|||
// 查询当前数据库中存储的数据
|
|||
FormEntity oldTemplateConfig = templateConfigOptional.get(); |
|||
GridPageEntity oldTemplateGrid = templateGridService.getRepository().findByTemplateConfig(oldTemplateConfig); |
|||
List<GridFieldEntity> oldTemplateGridFields = templateGridFieldService.getRepository().findByTemplateGridOrderBySortNoAsc(oldTemplateGrid); |
|||
List<String> oldTemplateGridFieldIds = new ArrayList<String>(); |
|||
for (int i=0; i < oldTemplateGridFields.size(); i++) { |
|||
oldTemplateGridFieldIds.add(oldTemplateGridFields.get(i).getId()); |
|||
} |
|||
|
|||
// 修改主配置及表格页面配置项
|
|||
templateConfig = super.update(oldTemplateConfig.getId(), templateConfig); |
|||
templateGrid.setTemplateConfig(templateConfig); |
|||
templateGrid.setId(oldTemplateGrid.getId()); |
|||
buildTemplateGrid(templateGrid); |
|||
templateGridService.update(oldTemplateGrid.getId(), templateGrid); |
|||
|
|||
// 删除老的字段配置
|
|||
templateGridFieldService.remove(oldTemplateGridFieldIds); |
|||
// 重新保存新的记录,将页面传递过来的对象设置 TemplateGrid ,同时将 ID 置为空。
|
|||
for (int i = 0; i < templateGridFields.size(); i++) { |
|||
templateGridFields.get(i).setTemplateGrid(templateGrid); |
|||
templateGridFields.get(i).setId(null); |
|||
} |
|||
templateGridFieldService.getRepository().saveAll(templateGridFields); |
|||
|
|||
return templateConfig; |
|||
} |
|||
|
|||
private void buildTemplateGrid(GridPageEntity templateGrid) { |
|||
if (templateGrid.getFieldComeFrom().equals(FieldComeFrom.sql)) { |
|||
templateGrid.setSchema(null); |
|||
templateGrid.setDatabaseTable(null); |
|||
templateGrid.setDataUrl(null); |
|||
templateGrid.setAddDataUrl(null); |
|||
templateGrid.setEditDataUrl(null); |
|||
templateGrid.setRemoveDataUrl(null); |
|||
templateGrid.setDraggable(false); |
|||
templateGrid.setAutoFetchData(true); |
|||
} else if (templateGrid.getFieldComeFrom().equals(FieldComeFrom.table)) { |
|||
templateGrid.setSql(null); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void delete(String[] templateConfigIds) throws Exception { |
|||
super.remove(Arrays.asList(templateConfigIds)); |
|||
} |
|||
|
|||
@Override |
|||
public GridPageWrapper fetch(String templateConfigId) throws Exception { |
|||
FormEntity templateConfig = repository.findById(templateConfigId).get(); |
|||
GridPageEntity templateGrid = templateGridService.getRepository().findByTemplateConfig(templateConfig); |
|||
List<GridFieldEntity> templateGridFields = templateGridFieldService.getRepository().findByTemplateGridOrderBySortNoAsc(templateGrid); |
|||
GridPageWrapper wrapper = new GridPageWrapper(); |
|||
wrapper.setTemplateConfig(templateConfig); |
|||
wrapper.setTemplateGrid(templateGrid); |
|||
wrapper.setTemplateGridFields(templateGridFields); |
|||
return wrapper; |
|||
} |
|||
|
|||
/** |
|||
* 获取所有排除的数据表 |
|||
* @param excludeTableTypes |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
private List<String> getExcludeTables(String[] excludeTableTypes) throws Exception { |
|||
Map<String, Object> tablesParamsMap = new HashMap<String, Object>(); |
|||
tablesParamsMap.put("excludeTableTypes", Arrays.asList(excludeTableTypes)); |
|||
String sql = "SELECT TABLE_ FROM LCDP_EXCLUDE_TABLE WHERE EXCLUDE_TYPE_ IN (:excludeTableTypes)"; |
|||
List<String> list = namedParameterJdbcTemplate.queryForList(sql, tablesParamsMap, String.class); |
|||
return list; |
|||
} |
|||
|
|||
/** |
|||
* 根据数据库类型获取所有表 |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
private List<TableWrapper> getDatabaseTables(String[] excludeTableTypes) throws Exception { |
|||
Connection conn = jdbcTemplate.getDataSource().getConnection(); |
|||
DatabaseMetaData dmd = conn.getMetaData(); |
|||
conn.close(); |
|||
String tablesSql = ""; |
|||
Map<String, Object> tablesParamsMap = new HashMap<String, Object>(); |
|||
if (DatabaseType.MYSQL.getProductName().equals(dmd.getDatabaseProductName())) { |
|||
tablesParamsMap.put("excludeTableTypes", Arrays.asList(excludeTableTypes)); |
|||
tablesParamsMap.put("tableType", "BASE TABLE"); |
|||
tablesSql = MySqlBuilder.sqlTables(); |
|||
} else { |
|||
tablesParamsMap.put("excludeTableTypes", Arrays.asList(excludeTableTypes)); |
|||
tablesParamsMap.put("tableType", "TABLE"); |
|||
tablesSql = OracleBuilder.sqlTables(); |
|||
} |
|||
return namedParameterJdbcTemplate.query(tablesSql, tablesParamsMap, TableWrapperRowMapper); |
|||
} |
|||
|
|||
private List<ColumnWrapper> getTableColumns(String table) throws Exception { |
|||
Connection conn = jdbcTemplate.getDataSource().getConnection(); |
|||
DatabaseMetaData dmd = conn.getMetaData(); |
|||
conn.close(); |
|||
String columnsSql = ""; |
|||
Map<String, Object> columnsParamsMap = new HashMap<String, Object>(); |
|||
columnsParamsMap.put("tableName", table); |
|||
if (DatabaseType.MYSQL.getProductName().equals(dmd.getDatabaseProductName())) { |
|||
columnsSql = MySqlBuilder.sqlColumns(); |
|||
} else { |
|||
columnsSql = OracleBuilder.sqlColumns(); |
|||
} |
|||
return namedParameterJdbcTemplate.query(columnsSql, columnsParamsMap, ColumnWrapperRowMapper); |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
package io.sc.platform.lcdp.form.service.impl; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.GridFieldEntity; |
|||
import io.sc.platform.lcdp.form.repository.GridFieldRepository; |
|||
import io.sc.platform.lcdp.form.service.GridFieldService; |
|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service("lcdpGridFieldService") |
|||
public class GridFieldServiceImpl extends DaoServiceImpl<GridFieldEntity, String, GridFieldRepository> implements GridFieldService { |
|||
|
|||
} |
@ -0,0 +1,12 @@ |
|||
package io.sc.platform.lcdp.form.service.impl; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
import io.sc.platform.lcdp.form.repository.GridPageRepository; |
|||
import io.sc.platform.lcdp.form.service.GridPageService; |
|||
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service("lcdpGridPageService") |
|||
public class GridPageServiceImpl extends DaoServiceImpl<GridPageEntity, String, GridPageRepository> implements GridPageService { |
|||
|
|||
} |
@ -0,0 +1,583 @@ |
|||
package io.sc.platform.lcdp.form.service.impl; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import io.sc.platform.jdbc.DatabaseType; |
|||
import io.sc.platform.jdbc.sql.builder.SqlBuilder; |
|||
import io.sc.platform.jdbc.sql.condition.Condition; |
|||
import io.sc.platform.lcdp.form.entity.GridFieldEntity; |
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
import io.sc.platform.lcdp.form.enums.AddValueType; |
|||
import io.sc.platform.lcdp.form.enums.FieldComeFrom; |
|||
import io.sc.platform.lcdp.form.enums.FieldType; |
|||
import io.sc.platform.lcdp.form.repository.GridFieldRepository; |
|||
import io.sc.platform.lcdp.form.repository.GridPageRepository; |
|||
import io.sc.platform.lcdp.form.service.JdbcTemplateService; |
|||
import io.sc.platform.lcdp.form.support.MySqlBuilder; |
|||
import io.sc.platform.lcdp.form.support.OracleBuilder; |
|||
import io.sc.platform.orm.api.enums.DataComeFrom; |
|||
import io.sc.platform.orm.service.support.OperatorType; |
|||
import io.sc.platform.orm.service.support.QueryParameter; |
|||
import io.sc.platform.orm.service.support.criteria.Criteria; |
|||
import io.sc.platform.security.util.SecurityUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.convert.ConversionService; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.jdbc.support.rowset.SqlRowSet; |
|||
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.DatabaseMetaData; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.*; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service("jdbcTemplateService") |
|||
public class JdbcTemplateServiceImpl implements JdbcTemplateService { |
|||
|
|||
@Autowired |
|||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate; |
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
@Autowired |
|||
private ObjectMapper objectMapper; |
|||
@Autowired |
|||
protected ConversionService conversionService; |
|||
@Autowired |
|||
private GridPageRepository templateGridRepository; |
|||
@Autowired |
|||
private GridFieldRepository templateGridFieldRepository; |
|||
|
|||
/** |
|||
* betweenAnd 正则表达式 |
|||
*/ |
|||
public static Pattern betweenAndPattern = Pattern.compile("(where|and|or)[\\s\\S]*\\bbetween\\b((?!and|or)[\\s\\S])*\\#\\{([^}]*)\\}((?!and|or)[\\s\\S])*\\band\\b((?!and|or)[\\s\\S])*\\#\\{([^}]*)\\}((?!and|or)[\\s\\S])*", Pattern.CASE_INSENSITIVE); |
|||
/** |
|||
* = <> > >= < <= 正则表达式 |
|||
*/ |
|||
public static Pattern equalsPattern = Pattern.compile("(where|and|or)((?!and|or)[\\s\\S])*[=|>|<]((?!and|or)[\\s\\S])*\\#\\{([^}]*)\\}((?!and|or)[\\s\\S])*((?!and|or)[\\s\\S])*", Pattern.CASE_INSENSITIVE); |
|||
/** |
|||
* like与 not like 正则表达式 |
|||
*/ |
|||
public static Pattern likePattern = Pattern.compile("(where|and|or)((?!and|or)[\\s\\S])*\\blike\\b((?!and|or)[\\s\\S])*\\#\\{([^}]*)\\}((?!and|or)[\\s\\S])*((?!and|or)[\\s\\S])*", Pattern.CASE_INSENSITIVE); |
|||
/** |
|||
* in与 not in 正则表达式 |
|||
*/ |
|||
public static Pattern inPattern = Pattern.compile("(where|and|or)((?!and|or)[\\s\\S])*\\bin\\b((?!and|or)[\\s\\S])*\\#\\{([^}]*)\\}((?!and|or)[\\s\\S])*((?!and|or)[\\s\\S])*", Pattern.CASE_INSENSITIVE); |
|||
/** |
|||
* 占位符变量 正则表达式 |
|||
*/ |
|||
public static Pattern paramsPattern = Pattern.compile("\\#\\{([^}]*)\\}"); |
|||
|
|||
@Override |
|||
public Condition buildCondition(Map<String,Class<?>> mapping, QueryParameter queryParameter) throws Exception { |
|||
if(queryParameter==null){ |
|||
return new Condition(); |
|||
} |
|||
List<Criteria> criterias = queryParameter.getCriterias(); |
|||
if(criterias==null || criterias.isEmpty()){ |
|||
return new Condition(); |
|||
} |
|||
if(OperatorType.and.equals(queryParameter.getOperator())){ |
|||
List<Condition> conditions =new ArrayList<>(); |
|||
for(Criteria criteria : criterias){ |
|||
criteria.setConversionService(conversionService); |
|||
Condition condition =criteria.getCondition(mapping); |
|||
conditions.add(condition); |
|||
} |
|||
if(!conditions.isEmpty()) { |
|||
return SqlBuilder.getSqlWhereBuilder().and(conditions); |
|||
} |
|||
}else if(OperatorType.or.equals(queryParameter.getOperator())){ |
|||
List<Condition> conditions =new ArrayList<>(); |
|||
for(Criteria criteria : criterias){ |
|||
criteria.setConversionService(conversionService); |
|||
Condition condition =criteria.getCondition(mapping); |
|||
conditions.add(condition); |
|||
} |
|||
if(!conditions.isEmpty()) { |
|||
return SqlBuilder.getSqlWhereBuilder().or(conditions); |
|||
} |
|||
}else if(OperatorType.not.equals(queryParameter.getOperator())){ |
|||
List<Condition> conditions =new ArrayList<>(); |
|||
for(Criteria criteria : criterias){ |
|||
criteria.setConversionService(conversionService); |
|||
Condition condition =criteria.getCondition(mapping); |
|||
conditions.add(condition); |
|||
} |
|||
if(!conditions.isEmpty()) { |
|||
return SqlBuilder.getSqlWhereBuilder().not(conditions); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, Object> list(String templateGridId, QueryParameter parameter) throws Exception { |
|||
return query(templateGridId, parameter); |
|||
} |
|||
|
|||
@Override |
|||
public void add(String templateGridId, Map<String, Object> dataMap) throws Exception { |
|||
GridPageEntity templateGrid = templateGridRepository.findById(templateGridId).get(); |
|||
List<GridFieldEntity> fields = getTemplateGridField(templateGrid); |
|||
String sql = "INSERT INTO " + templateGrid.getDatabaseTable() + "("; |
|||
String valuesSql = "VALUES("; |
|||
List<Object> args = new ArrayList<Object>(); |
|||
GridFieldEntity templateGridField = null; |
|||
for (int i=0; i<fields.size(); i++) { |
|||
templateGridField = fields.get(i); |
|||
sql += templateGridField.getFieldName() + ","; |
|||
if (null!=templateGridField.getAddValueType() |
|||
&& !"".equals(templateGridField.getAddValueType()) |
|||
&& !AddValueType.NONE.equals(templateGridField.getAddValueType())) { |
|||
// 根据配置系统生成值
|
|||
valuesSql += "?,"; |
|||
args.add(getSysGenerateValuesStr(templateGridField.getAddValueType())); |
|||
} else if(dataMap.containsKey(templateGridField.getFieldName())){ |
|||
// 页面传递过来的值
|
|||
valuesSql += "?,"; |
|||
args.add(fieldValueTypeHandler(templateGridField.getFieldType(), dataMap.get(templateGridField.getFieldName()))); |
|||
} else { |
|||
// 设置为 null
|
|||
valuesSql += "null,"; |
|||
} |
|||
} |
|||
sql = sql.substring(0, sql.length()-1) + ")"; |
|||
valuesSql = valuesSql.substring(0, valuesSql.length()-1) + ")"; |
|||
jdbcTemplate.update(sql + valuesSql, args.toArray()); |
|||
} |
|||
|
|||
@Override |
|||
public void edit(String templateGridId, String tableRowKey, String tableRowKeyValue, Map<String, Object> dataMap) throws Exception { |
|||
GridPageEntity templateGrid = templateGridRepository.findById(templateGridId).get(); |
|||
List<GridFieldEntity> fields = getTemplateGridField(templateGrid); |
|||
String queryOldSql = "SELECT * FROM " + templateGrid.getDatabaseTable() + " WHERE " + tableRowKey + "=:tableRowKey"; |
|||
Map<String, Object> oldSqlParams = new HashMap<String, Object>(); |
|||
oldSqlParams.put("tableRowKey", tableRowKeyValue); |
|||
List<Map<String, Object>> oldList = namedParameterJdbcTemplate.queryForList(queryOldSql, oldSqlParams); |
|||
if (null == oldList || oldList.size() == 0) { |
|||
throw new RuntimeException("根据【"+tableRowKey+"】字段未找到记录,无法保存!"); |
|||
} else if (null != oldList && oldList.size() > 1) { |
|||
throw new RuntimeException("根据【"+tableRowKey+"】字段找到多条记录,无法保存!"); |
|||
} |
|||
|
|||
// 剔除主键,不修改该字段
|
|||
fields.removeIf((pt) -> pt.getFieldName().equals(tableRowKey)); |
|||
|
|||
String updateSql = "UPDATE "+ templateGrid.getDatabaseTable(); |
|||
String setSql = " SET "; |
|||
String whereSql = " WHERE " + tableRowKey + " =? "; |
|||
List<Object> args = new ArrayList<Object>(); |
|||
GridFieldEntity templateGridField = null; |
|||
for (int i=0; i<fields.size(); i++) { |
|||
templateGridField = fields.get(i); |
|||
if (null!=templateGridField.getAddValueType() |
|||
&& !"".equals(templateGridField.getAddValueType()) |
|||
&& !AddValueType.NONE.equals(templateGridField.getAddValueType()) |
|||
&& templateGridField.getEditOverride()) { |
|||
// 使用系统生成值覆盖原值
|
|||
setSql += templateGridField.getFieldName() + "=?,"; |
|||
args.add(getSysGenerateValuesStr(templateGridField.getAddValueType())); |
|||
} else if(dataMap.containsKey(templateGridField.getFieldName())){ |
|||
// 页面传递过来的值
|
|||
setSql += templateGridField.getFieldName() + "=?,"; |
|||
args.add(fieldValueTypeHandler(templateGridField.getFieldType(), dataMap.get(templateGridField.getFieldName()))); |
|||
} else if (null!=templateGridField.getAddValueType() |
|||
&& !"".equals(templateGridField.getAddValueType().name()) |
|||
&& !AddValueType.NONE.equals(templateGridField.getAddValueType().name()) |
|||
&& !dataMap.containsKey(templateGridField.getFieldName()) |
|||
&& null!=oldList.get(0).get(templateGridField.getFieldName())) { |
|||
// 系统生成值且修改时不覆盖的值,同时当前存储的值不为空,设置为当前存储的值
|
|||
setSql += templateGridField.getFieldName() + "=?,"; |
|||
args.add(oldList.get(0).get(templateGridField.getFieldName())); |
|||
} else { |
|||
// 设置为 null
|
|||
setSql += templateGridField.getFieldName() + "=null,"; |
|||
} |
|||
} |
|||
args.add(tableRowKeyValue); |
|||
setSql = setSql.substring(0, setSql.length()-1); |
|||
jdbcTemplate.update(updateSql + setSql + whereSql, args.toArray()); |
|||
} |
|||
|
|||
@Override |
|||
public void delete(String templateGridId, String tableRowKey, String[] tableRowKeyValues) throws Exception { |
|||
GridPageEntity templateGrid = templateGridRepository.findById(templateGridId).get(); |
|||
List<GridFieldEntity> fields = getTemplateGridField(templateGrid); |
|||
String sql = "DELETE FROM " + templateGrid.getDatabaseTable() + " WHERE " + tableRowKey + "=?"; |
|||
List<Object[]> paramsList = new ArrayList<Object[]>(); |
|||
for(int i=0; i<tableRowKeyValues.length; i++) { |
|||
paramsList.add(new Object[]{tableRowKeyValues[i]}); |
|||
} |
|||
jdbcTemplate.batchUpdate(sql, paramsList); |
|||
} |
|||
|
|||
public String sqlHandler(String sql) throws Exception { |
|||
String newSql = sql; |
|||
Set<String> set = new LinkedHashSet<>(); |
|||
Matcher betweenAndMatcher = betweenAndPattern.matcher(sql); |
|||
while (betweenAndMatcher.find()) { |
|||
set.add(betweenAndMatcher.group(0)); |
|||
} |
|||
Matcher equalsMatcher = equalsPattern.matcher(sql); |
|||
while (equalsMatcher.find()) { |
|||
set.add(equalsMatcher.group(0)); |
|||
} |
|||
Matcher likeMatcher = likePattern.matcher(sql); |
|||
while (likeMatcher.find()) { |
|||
set.add(likeMatcher.group(0)); |
|||
} |
|||
Matcher inMatcher = inPattern.matcher(sql); |
|||
while (inMatcher.find()) { |
|||
set.add(inMatcher.group(0)); |
|||
} |
|||
if (set.size() > 0) { |
|||
for (String str : set) { |
|||
if (str.toLowerCase().startsWith("where")) { |
|||
newSql = newSql.replace(str, " where 1=1 "); |
|||
} else if (str.toLowerCase().startsWith("and")) { |
|||
newSql = newSql.replace(str, " and 1=1 "); |
|||
} else if (str.toLowerCase().startsWith("or")) { |
|||
newSql = newSql.replace(str, " or 1=1 "); |
|||
} |
|||
} |
|||
} |
|||
return newSql; |
|||
}; |
|||
|
|||
public static List<String> getParamsList(String sql) { |
|||
Set<String> paramSet = new LinkedHashSet<>(); |
|||
Matcher m = paramsPattern.matcher(sql); |
|||
while (m.find()) { |
|||
paramSet.add(m.group(1)); |
|||
} |
|||
return new ArrayList<>(paramSet); |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> fetchMetaDataBySql(String sql) throws Exception { |
|||
List<Map<String, Object>> list = new ArrayList<>(); |
|||
Map<String, Object> map = null; |
|||
// 匹配SQL中是否存在占位符,存在查询字段元信息时全部替换成 1=1
|
|||
String newSql = sqlHandler(sql); |
|||
SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet(newSql); |
|||
SqlRowSetMetaData sqlRowSetMetaData = sqlRowSet.getMetaData(); |
|||
|
|||
List<String> paramsList = getParamsList(sql); |
|||
if (null!=paramsList && paramsList.size()> 0) { |
|||
Map<String, Object> queryField = new HashMap<>(); |
|||
queryField.put("id", "query_field"); |
|||
queryField.put("columnName", "查询字段"); |
|||
list.add(queryField); |
|||
Map<String, Object> whereField = new HashMap<>(); |
|||
whereField.put("id", "where_field"); |
|||
whereField.put("columnName", "条件字段"); |
|||
list.add(whereField); |
|||
for (String param:paramsList) { |
|||
map = new HashMap<>(); |
|||
map.put("id", UUID.randomUUID().toString().trim().replaceAll("-", "")); |
|||
map.put("parent", "where_field"); |
|||
map.put("columnName", param); |
|||
list.add(map); |
|||
} |
|||
} |
|||
for (int i=1;i<=sqlRowSetMetaData.getColumnCount();i++) { |
|||
map = new HashMap<>(); |
|||
map.put("id", UUID.randomUUID().toString().trim().replaceAll("-", "")); |
|||
map.put("parent", "query_field"); |
|||
map.put("columnName", sqlRowSetMetaData.getColumnLabel(i)); |
|||
map.put("columnTypeName", sqlRowSetMetaData.getColumnTypeName(i)); |
|||
list.add(map); |
|||
} |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> fetchDataBySql(String sql) throws Exception { |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public List<GridFieldEntity> getTemplateGridField(GridPageEntity templateGrid) { |
|||
List<GridFieldEntity> tgfList = templateGridFieldRepository.findByTemplateGridOrderBySortNoAsc(templateGrid); |
|||
if (null == tgfList || tgfList.size() == 0 ) { |
|||
throw new RuntimeException("数据表字段未定义,操作失败!"); |
|||
} |
|||
return tgfList; |
|||
} |
|||
|
|||
public Object fieldValueTypeHandler (String type, Object value) throws Exception { |
|||
return conversionService.convert(value, FieldType.valueOf(type).getFieldTypeClass()); |
|||
} |
|||
|
|||
/** |
|||
* 获取新增时需要系统自动填充的值 |
|||
* @param addValueType |
|||
* @return |
|||
*/ |
|||
public Object getSysGenerateValuesStr(AddValueType addValueType) throws Exception { |
|||
if (AddValueType.CURR_USER.equals(addValueType)) { |
|||
return SecurityUtil.getLoginName(); |
|||
} else if(AddValueType.CURR_CORP.equals(addValueType)) { |
|||
return SecurityUtil.getCorporationCode(); |
|||
} else if(AddValueType.CURR_DATE.equals(addValueType)) { |
|||
return new Date(); |
|||
} else if(AddValueType.UUID.equals(addValueType)) { |
|||
return UUID.randomUUID().toString(); |
|||
} else if (AddValueType.DCF_INPUT.equals(addValueType)) { |
|||
return DataComeFrom.INPUT.name(); |
|||
} else if (AddValueType.DCF_IMPORT.equals(addValueType)) { |
|||
return DataComeFrom.IMPORT.name(); |
|||
} |
|||
return ""; |
|||
} |
|||
|
|||
public String getDatabaseProductName()throws Exception { |
|||
Connection conn = jdbcTemplate.getDataSource().getConnection(); |
|||
DatabaseMetaData dmd = conn.getMetaData(); |
|||
String productName = dmd.getDatabaseProductName(); |
|||
conn.close(); |
|||
return productName; |
|||
} |
|||
|
|||
public Map<String, Object> query(String templateGridId, QueryParameter parameter) throws Exception { |
|||
Map<String, Object> paramsMap = new HashMap<String, Object>(); |
|||
|
|||
GridPageEntity tg = new GridPageEntity(); |
|||
tg.setId(templateGridId); |
|||
List<GridFieldEntity> fields = templateGridFieldRepository.findByTemplateGridOrderBySortNoAsc(tg); |
|||
|
|||
Map<String, Class<?>> fieldTypeMap = new HashMap<String, Class<?>>(); |
|||
for(GridFieldEntity field: fields) { |
|||
if (null!=field.getFieldType() && !"".equals(field.getFieldType())) { |
|||
fieldTypeMap.put(field.getFieldName(), FieldType.valueOf(field.getFieldType()).getFieldTypeClass()); |
|||
} else { |
|||
fieldTypeMap.put(field.getFieldName(), FieldType.String.getFieldTypeClass()); |
|||
} |
|||
} |
|||
|
|||
Condition condition = buildCondition(fieldTypeMap, parameter); |
|||
// String conditionSql = builderQueryParams(paramsMap, fields);
|
|||
String conditionSql = " where 1=1 "; |
|||
if (null!=condition.getWhere() && !"".equals(condition.getWhere())) { |
|||
conditionSql += " and " + condition.getWhere(); |
|||
} |
|||
paramsMap = condition.getParameters(); |
|||
String orderBySql = builderOrderBy(parameter); |
|||
String sql = buildQuerySql(fields.get(0).getTemplateGrid(), conditionSql, condition, orderBySql); |
|||
|
|||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); |
|||
if (!parameter.getPageable()) { |
|||
list = namedParameterJdbcTemplate.queryForList(sql, paramsMap); |
|||
} else if (DatabaseType.MYSQL.getProductName().equals(getDatabaseProductName())) { |
|||
list = namedParameterJdbcTemplate.queryForList(MySqlBuilder.sqlPage(sql, parameter.getPage(), parameter.getSize()), paramsMap); |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), namedParameterJdbcTemplate.queryForObject(MySqlBuilder.sqlCount(sql.toString()), paramsMap, Integer.class)); |
|||
} else { |
|||
// 默认使用 Oracle 分页
|
|||
list = namedParameterJdbcTemplate.queryForList(OracleBuilder.sqlPage(sql, parameter.getPage(), parameter.getSize()), paramsMap); |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), namedParameterJdbcTemplate.queryForObject(OracleBuilder.sqlCount(sql.toString()), paramsMap, Integer.class)); |
|||
} |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), list.size()); |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, Object> listBySql(QueryParameter parameter, String querySql, Map<String, Class<?>> fieldTypeMap) throws Exception { |
|||
Map<String, Object> paramsMap = new HashMap<String, Object>(); |
|||
Condition condition = buildCondition(fieldTypeMap, parameter); |
|||
String conditionSql = " where 1=1 "; |
|||
if (null!=condition.getWhere() && !"".equals(condition.getWhere())) { |
|||
conditionSql += " and " + condition.getWhere(); |
|||
} |
|||
paramsMap = condition.getParameters(); |
|||
String orderBySql = builderOrderBy(parameter); |
|||
|
|||
StringBuffer sql = new StringBuffer(); |
|||
sql.append(querySql); |
|||
sql.append(conditionSql); |
|||
sql.append(orderBySql); |
|||
|
|||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); |
|||
if (!parameter.getPageable()) { |
|||
list = namedParameterJdbcTemplate.queryForList(sql.toString(), paramsMap); |
|||
} else if (DatabaseType.MYSQL.getProductName().equals(getDatabaseProductName())) { |
|||
list = namedParameterJdbcTemplate.queryForList(MySqlBuilder.sqlPage(sql.toString(), parameter.getPage(), parameter.getSize()), paramsMap); |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), namedParameterJdbcTemplate.queryForObject(MySqlBuilder.sqlCount(sql.toString()), paramsMap, Integer.class)); |
|||
} else { |
|||
// 默认使用 Oracle 分页
|
|||
list = namedParameterJdbcTemplate.queryForList(OracleBuilder.sqlPage(sql.toString(), parameter.getPage(), parameter.getSize()), paramsMap); |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), namedParameterJdbcTemplate.queryForObject(OracleBuilder.sqlCount(sql.toString()), paramsMap, Integer.class)); |
|||
} |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), list.size()); |
|||
} |
|||
|
|||
@Override |
|||
public Map<String, Object> listByConditionSql(QueryParameter parameter, String querySql, Map<String, Object> conditionParamsMap) throws Exception { |
|||
String orderBySql = builderOrderBy(parameter); |
|||
StringBuffer sql = new StringBuffer(); |
|||
sql.append(querySql); |
|||
sql.append(orderBySql); |
|||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); |
|||
if (!parameter.getPageable()) { |
|||
list = namedParameterJdbcTemplate.queryForList(sql.toString(), conditionParamsMap); |
|||
} else if (DatabaseType.MYSQL.getProductName().equals(getDatabaseProductName())) { |
|||
list = namedParameterJdbcTemplate.queryForList(MySqlBuilder.sqlPage(sql.toString(), parameter.getPage(), parameter.getSize()), conditionParamsMap); |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), namedParameterJdbcTemplate.queryForObject(MySqlBuilder.sqlCount(sql.toString()), conditionParamsMap, Integer.class)); |
|||
} else { |
|||
// 默认使用 Oracle 分页
|
|||
list = namedParameterJdbcTemplate.queryForList(OracleBuilder.sqlPage(sql.toString(), parameter.getPage(), parameter.getSize()), conditionParamsMap); |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), namedParameterJdbcTemplate.queryForObject(OracleBuilder.sqlCount(sql.toString()), conditionParamsMap, Integer.class)); |
|||
} |
|||
return pageData(list, parameter.getPage(), parameter.getSize(), list.size()); |
|||
} |
|||
|
|||
/** |
|||
* 组装分页数据 |
|||
* @param list 数据集 |
|||
* @param pageIndex 当前页 |
|||
* @param pageSize 每页大小 |
|||
* @param allCount 总记录数 |
|||
* @return 返回的Map: |
|||
* size=每页大小 |
|||
* totalElements=总记录数 |
|||
* number=当前页 |
|||
* data=数据集 |
|||
*/ |
|||
public static Map<String, Object> pageData(List<Map<String, Object>> list, Integer pageIndex, Integer pageSize, Integer allCount) { |
|||
Map<String, Object> rs = new HashMap<String, Object>(); |
|||
for (int i=0; i < list.size(); i++) { |
|||
Map<String, Object> map = list.get(i); |
|||
map.forEach((k, v) -> { |
|||
if (v instanceof LocalDateTime) { |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|||
map.replace(k, formatter.format(LocalDateTime.parse(map.get(k).toString()))); |
|||
} |
|||
}); |
|||
} |
|||
rs.put("content", list); |
|||
rs.put("size", pageSize); |
|||
rs.put("totalElements", allCount.longValue()); |
|||
if (null != pageIndex) { |
|||
rs.put("number", pageIndex.longValue()); |
|||
} else { |
|||
rs.put("number", 1); |
|||
} |
|||
return rs; |
|||
} |
|||
|
|||
public String buildQuerySql(GridPageEntity grid, String conditionSql, Condition condition, String orderBySql) throws Exception { |
|||
StringBuffer sql = new StringBuffer(); |
|||
if (grid.getFieldComeFrom().equals(FieldComeFrom.table)) { |
|||
sql.append("SELECT * FROM "); |
|||
sql.append(grid.getDatabaseTable()); |
|||
sql.append(conditionSql); |
|||
sql.append(orderBySql); |
|||
} else if (grid.getFieldComeFrom().equals(FieldComeFrom.sql)) { |
|||
if (null == condition.getParameters() || condition.getParameters().size() == 0) { |
|||
String sqlStr = sqlHandler(grid.getSql()); |
|||
sql.append(sqlStr); |
|||
} else { |
|||
Map<String, Object> map = condition.getParameters(); |
|||
String newSql = grid.getSql(); |
|||
Set<String> set = new LinkedHashSet<>(); |
|||
Matcher betweenAndMatcher = betweenAndPattern.matcher(grid.getSql()); |
|||
while (betweenAndMatcher.find()) { |
|||
set.add(betweenAndMatcher.group(0)); |
|||
} |
|||
Matcher equalsMatcher = equalsPattern.matcher(grid.getSql()); |
|||
while (equalsMatcher.find()) { |
|||
set.add(equalsMatcher.group(0)); |
|||
} |
|||
Matcher likeMatcher = likePattern.matcher(grid.getSql()); |
|||
while (likeMatcher.find()) { |
|||
set.add(likeMatcher.group(0)); |
|||
} |
|||
Matcher inMatcher = inPattern.matcher(grid.getSql()); |
|||
while (inMatcher.find()) { |
|||
set.add(inMatcher.group(0)); |
|||
} |
|||
if (set.size() > 0) { |
|||
for (String str : set) { |
|||
String replaceResult = str; |
|||
Matcher paramsMatcher = paramsPattern.matcher(str); |
|||
Boolean flag = true; |
|||
while (paramsMatcher.find()) { |
|||
String param = paramsMatcher.group(1); |
|||
if (map.containsKey(param)) { |
|||
replaceResult = replaceResult.replaceAll("#\\{"+param+"\\}", map.get(param).toString()); |
|||
} else { |
|||
flag = false; |
|||
} |
|||
} |
|||
if (flag) { |
|||
newSql = newSql.replace(str, replaceResult); |
|||
} else { |
|||
if (str.toLowerCase().startsWith("where")) { |
|||
newSql = newSql.replace(str, " where 1=1 "); |
|||
} else if (str.toLowerCase().startsWith("and")) { |
|||
newSql = newSql.replace(str, " and 1=1 "); |
|||
} else if (str.toLowerCase().startsWith("or")) { |
|||
newSql = newSql.replace(str, " or 1=1 "); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
sql.append(newSql); |
|||
} |
|||
} |
|||
return sql.toString(); |
|||
} |
|||
|
|||
public String builderQueryParams(Map<String, Object> paramsMap, List<GridFieldEntity> fields) throws Exception { |
|||
Map<String, GridFieldEntity> map = getTemplateGridFieldMap(fields); |
|||
StringBuffer sql = new StringBuffer(); |
|||
if (null!=paramsMap && paramsMap.size() > 0) { |
|||
sql.append(" WHERE 1=1 "); |
|||
if (DatabaseType.MYSQL.getProductName().equals(getDatabaseProductName())) { |
|||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) { |
|||
if (map.get(entry.getKey()).getQueryOperator().equals(OperatorType.contains.name())) { |
|||
sql.append(" AND " + entry.getKey() + " concat('%', :"+ entry.getKey() +", '%') "); |
|||
} else { |
|||
// 目前只支持模糊匹配及完全匹配,除模糊匹配外都使用完全匹配
|
|||
sql.append(" AND " + entry.getKey() + "=:"+entry.getKey()); |
|||
} |
|||
} |
|||
} else { |
|||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) { |
|||
if (map.get(entry.getKey()).getQueryOperator().equals(OperatorType.contains.name())) { |
|||
sql.append(" AND " + entry.getKey() + " like '%' || :"+ entry.getKey() +" || '%' "); |
|||
} else { |
|||
// 目前只支持模糊匹配及完全匹配,除模糊匹配外都使用完全匹配
|
|||
sql.append(" AND " + entry.getKey() + "=:"+entry.getKey()); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return sql.toString(); |
|||
} |
|||
|
|||
public String builderOrderBy(QueryParameter parameter){ |
|||
String sql = ""; |
|||
if (null != parameter.getSortBy() && parameter.getSortBy().size() > 0) { |
|||
sql = " ORDER BY "; |
|||
for (String sort: parameter.getSortBy()) { |
|||
if (sort.startsWith("-")) { |
|||
sql += sort.substring(1) + " DESC,"; |
|||
} else if (sort.startsWith("+")) { |
|||
sql += sort.substring(1) + " ASC,"; |
|||
} else { |
|||
sql += sort + " ASC,"; |
|||
} |
|||
} |
|||
sql = sql.substring(0, sql.length() - 1) + " "; |
|||
} |
|||
return sql; |
|||
} |
|||
|
|||
public Map<String, GridFieldEntity> getTemplateGridFieldMap(List<GridFieldEntity> fields) { |
|||
return fields.stream().collect(Collectors.toMap(GridFieldEntity::getFieldName, templateGridField -> templateGridField)); |
|||
} |
|||
} |
@ -0,0 +1,60 @@ |
|||
package io.sc.platform.lcdp.form.support; |
|||
|
|||
import org.springframework.jdbc.core.RowMapper; |
|||
|
|||
import java.sql.ResultSet; |
|||
import java.sql.SQLException; |
|||
|
|||
public class ColumnWrapper { |
|||
|
|||
public String tableName; |
|||
public String name; |
|||
public String comment; |
|||
public String columnType; |
|||
|
|||
public static RowMapper<ColumnWrapper> getRowMapper() { return new ColumnWrapperRowMapper(); }; |
|||
|
|||
public static class ColumnWrapperRowMapper implements RowMapper<ColumnWrapper> { |
|||
@Override |
|||
public ColumnWrapper mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
ColumnWrapper wrapper = new ColumnWrapper(); |
|||
wrapper.setName(rs.getString("COLUMN_NAME_")); |
|||
wrapper.setComment(rs.getString("COLUMN_COMMENT_")); |
|||
wrapper.setTableName(rs.getString("TABLE_NAME_")); |
|||
wrapper.setColumnType(rs.getString("COLUMN_TYPE_")); |
|||
return wrapper; |
|||
} |
|||
} |
|||
|
|||
public String getTableName() { |
|||
return tableName; |
|||
} |
|||
|
|||
public void setTableName(String tableName) { |
|||
this.tableName = tableName; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getComment() { |
|||
return comment; |
|||
} |
|||
|
|||
public void setComment(String comment) { |
|||
this.comment = comment; |
|||
} |
|||
|
|||
public String getColumnType() { |
|||
return columnType; |
|||
} |
|||
|
|||
public void setColumnType(String columnType) { |
|||
this.columnType = columnType; |
|||
} |
|||
} |
@ -0,0 +1,37 @@ |
|||
package io.sc.platform.lcdp.form.support; |
|||
|
|||
import io.sc.platform.lcdp.form.entity.FormEntity; |
|||
import io.sc.platform.lcdp.form.entity.GridFieldEntity; |
|||
import io.sc.platform.lcdp.form.entity.GridPageEntity; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class GridPageWrapper { |
|||
public FormEntity templateConfig; |
|||
public GridPageEntity templateGrid; |
|||
public List<GridFieldEntity> templateGridFields; |
|||
|
|||
public FormEntity getTemplateConfig() { |
|||
return templateConfig; |
|||
} |
|||
|
|||
public void setTemplateConfig(FormEntity templateConfig) { |
|||
this.templateConfig = templateConfig; |
|||
} |
|||
|
|||
public GridPageEntity getTemplateGrid() { |
|||
return templateGrid; |
|||
} |
|||
|
|||
public void setTemplateGrid(GridPageEntity templateGrid) { |
|||
this.templateGrid = templateGrid; |
|||
} |
|||
|
|||
public List<GridFieldEntity> getTemplateGridFields() { |
|||
return templateGridFields; |
|||
} |
|||
|
|||
public void setTemplateGridFields(List<GridFieldEntity> templateGridFields) { |
|||
this.templateGridFields = templateGridFields; |
|||
} |
|||
} |
@ -0,0 +1,48 @@ |
|||
package io.sc.platform.lcdp.form.support; |
|||
|
|||
public class MySqlBuilder { |
|||
|
|||
private static Integer PAGE_INDEX = 1; |
|||
private static Integer PAGE_SIZE = 10; |
|||
|
|||
public static String sqlPage(String sql, Integer pageIndex, Integer pageSize) { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
if (pageIndex == null) { |
|||
pageIndex = PAGE_INDEX; |
|||
} |
|||
if(pageSize == null) { |
|||
pageSize = PAGE_SIZE; |
|||
} |
|||
sqlBuffer.append("SELECT A.* FROM ("); |
|||
sqlBuffer.append(sql); |
|||
sqlBuffer.append(") A LIMIT " + ((pageIndex - 1) * pageSize) + "," + pageSize); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
|
|||
public static String sqlCount(String sql) { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
sqlBuffer.append("SELECT COUNT(*) FROM ("); |
|||
sqlBuffer.append(sql); |
|||
sqlBuffer.append(") A"); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
|
|||
public static String sqlTables() { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
sqlBuffer.append("SELECT T.TABLE_NAME AS TABLE_NAME_,T.TABLE_COMMENT AS TABLE_COMMENT_ FROM INFORMATION_SCHEMA.TABLES T "); |
|||
sqlBuffer.append("LEFT JOIN LCDP_EXCLUDE_TABLE ET ON lower(T.TABLE_NAME) = lower(ET.TABLE_) AND ET.EXCLUDE_TYPE_ IN (:excludeTableTypes) "); |
|||
sqlBuffer.append("WHERE T.TABLE_SCHEMA = database() AND T.TABLE_TYPE = :tableType "); |
|||
sqlBuffer.append("AND ET.ID_ IS NULL "); |
|||
sqlBuffer.append("ORDER BY T.TABLE_NAME ASC"); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
|
|||
public static String sqlColumns() { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
sqlBuffer.append("SELECT T.TABLE_NAME AS TABLE_NAME_,T.COLUMN_NAME AS COLUMN_NAME_,T.COLUMN_COMMENT AS COLUMN_COMMENT_,T.COLUMN_TYPE AS COLUMN_TYPE_ "); |
|||
sqlBuffer.append("FROM INFORMATION_SCHEMA.COLUMNS T "); |
|||
sqlBuffer.append("WHERE T.TABLE_NAME = :tableName "); |
|||
sqlBuffer.append("ORDER BY T.ORDINAL_POSITION ASC "); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
package io.sc.platform.lcdp.form.support; |
|||
|
|||
public class OracleBuilder { |
|||
|
|||
private static Integer PAGE_INDEX = 1; |
|||
private static Integer PAGE_SIZE = 10; |
|||
|
|||
public static String sqlPage(String sql, Integer pageIndex, Integer pageSize) { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
if (pageIndex == null) { |
|||
pageIndex = PAGE_INDEX; |
|||
} |
|||
if(pageSize == null) { |
|||
pageSize = PAGE_SIZE; |
|||
} |
|||
sqlBuffer.append("SELECT * FROM (SELECT A.*, ROWNUM RN FROM ("); |
|||
sqlBuffer.append(sql); |
|||
sqlBuffer.append(") A WHERE ROWNUM <= " + (pageIndex * pageSize) + " ) WHERE RN > " + (pageIndex * pageSize - pageSize)); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
|
|||
public static String sqlCount(String sql) { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
sqlBuffer.append("SELECT COUNT(*) FROM ("); |
|||
sqlBuffer.append(sql); |
|||
sqlBuffer.append(") A"); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
|
|||
public static String sqlTables() { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
sqlBuffer.append("SELECT UAC.TABLE_NAME AS TABLE_NAME_,UAC.COMMENTS AS TABLE_COMMENT_ FROM USER_TAB_COMMENTS UAC "); |
|||
// sqlBuffer.append("JOIN USER_TABLES UT ON UAC.TABLE_NAME=UT.TABLE_NAME ");
|
|||
sqlBuffer.append("LEFT JOIN LCDP_EXCLUDE_TABLE ET ON upper(UAC.TABLE_NAME) = upper(ET.TABLE_) AND ET.EXCLUDE_TYPE_ IN (:excludeTableTypes) "); |
|||
sqlBuffer.append("AND ET.ID_ IS NULL "); |
|||
// sqlBuffer.append("WHERE UAC.TABLE_TYPE = :tableType ");
|
|||
sqlBuffer.append("ORDER BY UAC.TABLE_NAME ASC"); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
|
|||
public static String sqlColumns() { |
|||
StringBuffer sqlBuffer = new StringBuffer(); |
|||
sqlBuffer.append("SELECT UTC.TABLE_NAME AS TABLE_NAME_,UTC.COLUMN_NAME AS COLUMN_NAME_, "); |
|||
sqlBuffer.append("CASE WHEN INSTR(UCC.COMMENTS,'|')>1 THEN REPLACE(UCC.COMMENTS,'|',';') ELSE UCC.COMMENTS END AS COLUMN_COMMENT_, "); |
|||
sqlBuffer.append("CASE WHEN UTC.CHAR_COL_DECL_LENGTH IS NOT NULL THEN UTC.DATA_TYPE||'('||UTC.CHAR_COL_DECL_LENGTH||')' ELSE UTC.DATA_TYPE END AS COLUMN_TYPE_ "); |
|||
sqlBuffer.append("FROM USER_TAB_COLUMNS UTC "); |
|||
sqlBuffer.append("JOIN USER_COL_COMMENTS UCC ON UTC.TABLE_NAME=UCC.TABLE_NAME AND UTC.COLUMN_NAME=UCC.COLUMN_NAME "); |
|||
sqlBuffer.append("WHERE UTC.TABLE_NAME = :tableName "); |
|||
sqlBuffer.append("ORDER BY UTC.COLUMN_ID ASC "); |
|||
return sqlBuffer.toString(); |
|||
} |
|||
} |
@ -0,0 +1,40 @@ |
|||
package io.sc.platform.lcdp.form.support; |
|||
|
|||
import org.springframework.jdbc.core.RowMapper; |
|||
|
|||
import java.sql.ResultSet; |
|||
import java.sql.SQLException; |
|||
|
|||
public class TableWrapper { |
|||
|
|||
public String name; |
|||
public String comment; |
|||
|
|||
public static RowMapper<TableWrapper> getRowMapper() { return new TableWrapperRowMapper(); }; |
|||
|
|||
public static class TableWrapperRowMapper implements RowMapper<TableWrapper> { |
|||
@Override |
|||
public TableWrapper mapRow(ResultSet rs, int rowNum) throws SQLException { |
|||
TableWrapper wrapper = new TableWrapper(); |
|||
wrapper.setName(rs.getString("TABLE_NAME_")); |
|||
wrapper.setComment(rs.getString("TABLE_COMMENT_")); |
|||
return wrapper; |
|||
} |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getComment() { |
|||
return comment; |
|||
} |
|||
|
|||
public void setComment(String comment) { |
|||
this.comment = comment; |
|||
} |
|||
} |
@ -0,0 +1,63 @@ |
|||
package io.sc.platform.lcdp.form.vo; |
|||
|
|||
import io.sc.platform.lcdp.form.enums.PageLoadType; |
|||
import io.sc.platform.lcdp.form.enums.PageType; |
|||
import io.sc.platform.orm.api.vo.CorporationAuditorVo; |
|||
|
|||
public class FormVo extends CorporationAuditorVo { |
|||
|
|||
//主键
|
|||
private String id; |
|||
|
|||
// 配置名称
|
|||
private String templateName; |
|||
|
|||
// 配置类型(grid:表格页面)
|
|||
private PageType templateType; |
|||
|
|||
// 页面配置项
|
|||
private String config; |
|||
|
|||
// 页面加载类型(JSON:通过本表的_config字段存储的json字符串加载;CONFIG:通过系统配置加载)
|
|||
private PageLoadType pageLoadType; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTemplateName() { |
|||
return templateName; |
|||
} |
|||
|
|||
public void setTemplateName(String templateName) { |
|||
this.templateName = templateName; |
|||
} |
|||
|
|||
public PageType getTemplateType() { |
|||
return templateType; |
|||
} |
|||
|
|||
public void setTemplateType(PageType templateType) { |
|||
this.templateType = templateType; |
|||
} |
|||
|
|||
public String getConfig() { |
|||
return config; |
|||
} |
|||
|
|||
public void setConfig(String config) { |
|||
this.config = config; |
|||
} |
|||
|
|||
public PageLoadType getPageLoadType() { |
|||
return pageLoadType; |
|||
} |
|||
|
|||
public void setPageLoadType(PageLoadType pageLoadType) { |
|||
this.pageLoadType = pageLoadType; |
|||
} |
|||
} |
@ -0,0 +1,315 @@ |
|||
package io.sc.platform.lcdp.form.vo; |
|||
|
|||
import io.sc.platform.lcdp.form.enums.AddValueType; |
|||
import io.sc.platform.orm.api.vo.CorporationAuditorVo; |
|||
|
|||
public class GridFieldVo extends CorporationAuditorVo { |
|||
|
|||
//主键
|
|||
private String id; |
|||
|
|||
// 所属表格模板ID
|
|||
private String templateGrid; |
|||
|
|||
// 字段所属的父类型(query_field: 查询字段;where_field: 条件字段)
|
|||
private String parent; |
|||
|
|||
// 字段名称
|
|||
private String fieldName; |
|||
|
|||
// 页面显示名称
|
|||
private String fieldLabel; |
|||
|
|||
// 字段类型
|
|||
private String fieldType; |
|||
|
|||
// 字段序号
|
|||
private Integer sortNo; |
|||
|
|||
// 字段长度
|
|||
private Integer fieldLength; |
|||
|
|||
// 字段精度
|
|||
private Integer fieldPrecision; |
|||
|
|||
// 字段是否为选项值
|
|||
private Boolean fieldIsSelect; |
|||
|
|||
// 选项值来源(dictionary: 数据字典, javaApi: java接口, array: 自定义数组)
|
|||
private String optionComeFrom; |
|||
|
|||
// 数据字典选项值
|
|||
private String dictionaryOptionValue; |
|||
|
|||
// 其他选项值
|
|||
private String otherOptionValue; |
|||
|
|||
// 新增时系统自动填充类型
|
|||
private AddValueType addValueType; |
|||
|
|||
// 修改时覆盖系统自动填充值
|
|||
private Boolean editOverride; |
|||
|
|||
// 查询面板中显示
|
|||
private Boolean queryShow; |
|||
|
|||
// 使用的表单类型
|
|||
private String queryFormType; |
|||
|
|||
// 默认值
|
|||
private String queryDefaultValue; |
|||
|
|||
// 是否必填项
|
|||
private Boolean queryIsRequired; |
|||
|
|||
// 匹配模式(like:模糊匹配, equals:完全匹配)
|
|||
private String queryOperator; |
|||
|
|||
// 列表中显示
|
|||
private Boolean tableShow; |
|||
|
|||
// 是否支持排序
|
|||
private Boolean tableSort; |
|||
|
|||
// 列对齐方式
|
|||
private String tableColumnAlign; |
|||
|
|||
// 列宽
|
|||
private Integer tableColumnWidth; |
|||
|
|||
// 新增编辑页面是否显示
|
|||
private Boolean editorShow; |
|||
|
|||
// 使用的表单类型
|
|||
private String editorFormType; |
|||
|
|||
// 默认值
|
|||
private String editorDefaultValue; |
|||
|
|||
// 是否必填项
|
|||
private Boolean editorIsRequired; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTemplateGrid() { |
|||
return templateGrid; |
|||
} |
|||
|
|||
public void setTemplateGrid(String templateGrid) { |
|||
this.templateGrid = templateGrid; |
|||
} |
|||
|
|||
public String getParent() { |
|||
return parent; |
|||
} |
|||
|
|||
public void setParent(String parent) { |
|||
this.parent = parent; |
|||
} |
|||
|
|||
public String getFieldName() { |
|||
return fieldName; |
|||
} |
|||
|
|||
public void setFieldName(String fieldName) { |
|||
this.fieldName = fieldName; |
|||
} |
|||
|
|||
public String getFieldLabel() { |
|||
return fieldLabel; |
|||
} |
|||
|
|||
public void setFieldLabel(String fieldLabel) { |
|||
this.fieldLabel = fieldLabel; |
|||
} |
|||
|
|||
public String getFieldType() { |
|||
return fieldType; |
|||
} |
|||
|
|||
public void setFieldType(String fieldType) { |
|||
this.fieldType = fieldType; |
|||
} |
|||
|
|||
public Integer getSortNo() { |
|||
return sortNo; |
|||
} |
|||
|
|||
public void setSortNo(Integer sortNo) { |
|||
this.sortNo = sortNo; |
|||
} |
|||
|
|||
public Integer getFieldLength() { |
|||
return fieldLength; |
|||
} |
|||
|
|||
public void setFieldLength(Integer fieldLength) { |
|||
this.fieldLength = fieldLength; |
|||
} |
|||
|
|||
public Integer getFieldPrecision() { |
|||
return fieldPrecision; |
|||
} |
|||
|
|||
public void setFieldPrecision(Integer fieldPrecision) { |
|||
this.fieldPrecision = fieldPrecision; |
|||
} |
|||
|
|||
public Boolean getFieldIsSelect() { |
|||
return fieldIsSelect; |
|||
} |
|||
|
|||
public void setFieldIsSelect(Boolean fieldIsSelect) { |
|||
this.fieldIsSelect = fieldIsSelect; |
|||
} |
|||
|
|||
public String getOptionComeFrom() { |
|||
return optionComeFrom; |
|||
} |
|||
|
|||
public void setOptionComeFrom(String optionComeFrom) { |
|||
this.optionComeFrom = optionComeFrom; |
|||
} |
|||
|
|||
public String getDictionaryOptionValue() { |
|||
return dictionaryOptionValue; |
|||
} |
|||
|
|||
public void setDictionaryOptionValue(String dictionaryOptionValue) { |
|||
this.dictionaryOptionValue = dictionaryOptionValue; |
|||
} |
|||
|
|||
public String getOtherOptionValue() { |
|||
return otherOptionValue; |
|||
} |
|||
|
|||
public void setOtherOptionValue(String otherOptionValue) { |
|||
this.otherOptionValue = otherOptionValue; |
|||
} |
|||
|
|||
public AddValueType getAddValueType() { |
|||
return addValueType; |
|||
} |
|||
|
|||
public void setAddValueType(AddValueType addValueType) { |
|||
this.addValueType = addValueType; |
|||
} |
|||
|
|||
public Boolean getEditOverride() { |
|||
return editOverride; |
|||
} |
|||
|
|||
public void setEditOverride(Boolean editOverride) { |
|||
this.editOverride = editOverride; |
|||
} |
|||
|
|||
public Boolean getQueryShow() { |
|||
return queryShow; |
|||
} |
|||
|
|||
public void setQueryShow(Boolean queryShow) { |
|||
this.queryShow = queryShow; |
|||
} |
|||
|
|||
public String getQueryFormType() { |
|||
return queryFormType; |
|||
} |
|||
|
|||
public void setQueryFormType(String queryFormType) { |
|||
this.queryFormType = queryFormType; |
|||
} |
|||
|
|||
public String getQueryDefaultValue() { |
|||
return queryDefaultValue; |
|||
} |
|||
|
|||
public void setQueryDefaultValue(String queryDefaultValue) { |
|||
this.queryDefaultValue = queryDefaultValue; |
|||
} |
|||
|
|||
public Boolean getQueryIsRequired() { |
|||
return queryIsRequired; |
|||
} |
|||
|
|||
public void setQueryIsRequired(Boolean queryIsRequired) { |
|||
this.queryIsRequired = queryIsRequired; |
|||
} |
|||
|
|||
public String getQueryOperator() { |
|||
return queryOperator; |
|||
} |
|||
|
|||
public void setQueryOperator(String queryOperator) { |
|||
this.queryOperator = queryOperator; |
|||
} |
|||
|
|||
public Boolean getTableShow() { |
|||
return tableShow; |
|||
} |
|||
|
|||
public void setTableShow(Boolean tableShow) { |
|||
this.tableShow = tableShow; |
|||
} |
|||
|
|||
public Boolean getTableSort() { |
|||
return tableSort; |
|||
} |
|||
|
|||
public void setTableSort(Boolean tableSort) { |
|||
this.tableSort = tableSort; |
|||
} |
|||
|
|||
public String getTableColumnAlign() { |
|||
return tableColumnAlign; |
|||
} |
|||
|
|||
public void setTableColumnAlign(String tableColumnAlign) { |
|||
this.tableColumnAlign = tableColumnAlign; |
|||
} |
|||
|
|||
public Integer getTableColumnWidth() { |
|||
return tableColumnWidth; |
|||
} |
|||
|
|||
public void setTableColumnWidth(Integer tableColumnWidth) { |
|||
this.tableColumnWidth = tableColumnWidth; |
|||
} |
|||
|
|||
public Boolean getEditorShow() { |
|||
return editorShow; |
|||
} |
|||
|
|||
public void setEditorShow(Boolean editorShow) { |
|||
this.editorShow = editorShow; |
|||
} |
|||
|
|||
public String getEditorFormType() { |
|||
return editorFormType; |
|||
} |
|||
|
|||
public void setEditorFormType(String editorFormType) { |
|||
this.editorFormType = editorFormType; |
|||
} |
|||
|
|||
public String getEditorDefaultValue() { |
|||
return editorDefaultValue; |
|||
} |
|||
|
|||
public void setEditorDefaultValue(String editorDefaultValue) { |
|||
this.editorDefaultValue = editorDefaultValue; |
|||
} |
|||
|
|||
public Boolean getEditorIsRequired() { |
|||
return editorIsRequired; |
|||
} |
|||
|
|||
public void setEditorIsRequired(Boolean editorIsRequired) { |
|||
this.editorIsRequired = editorIsRequired; |
|||
} |
|||
} |
@ -0,0 +1,414 @@ |
|||
package io.sc.platform.lcdp.form.vo; |
|||
|
|||
import io.sc.platform.lcdp.form.enums.FieldComeFrom; |
|||
import io.sc.platform.orm.api.vo.CorporationAuditorVo; |
|||
|
|||
public class GridPageVo extends CorporationAuditorVo { |
|||
|
|||
//主键
|
|||
private String id; |
|||
|
|||
// 所属模板
|
|||
private String templateConfig; |
|||
|
|||
// 字段来源
|
|||
private FieldComeFrom fieldComeFrom; |
|||
|
|||
// schema
|
|||
private String schema; |
|||
|
|||
// 数据表名
|
|||
private String databaseTable; |
|||
|
|||
// SQL
|
|||
private String sql; |
|||
|
|||
// 表格名称
|
|||
private String title; |
|||
|
|||
// 表格按钮
|
|||
private String[] buttons; |
|||
|
|||
// 选中模式(single:单选,multiple:多选)
|
|||
private String selection; |
|||
|
|||
// 数据主键
|
|||
private String primaryKey; |
|||
|
|||
// 数据外键
|
|||
private String foreignKey; |
|||
|
|||
// 数据操作URL前缀
|
|||
private String dataUrl; |
|||
|
|||
// 加载数据URL
|
|||
private String fetchDataUrl; |
|||
|
|||
// 新增URL
|
|||
private String addDataUrl; |
|||
|
|||
// 编辑URL
|
|||
private String editDataUrl; |
|||
|
|||
// 删除URL
|
|||
private String removeDataUrl; |
|||
|
|||
// 是否显示序号列
|
|||
private Boolean sortNo; |
|||
|
|||
// 是否显示复选框列
|
|||
private Boolean checkboxSelection; |
|||
|
|||
// 行是否允许拖拽
|
|||
private Boolean draggable; |
|||
|
|||
// 是否自动加载数据
|
|||
private Boolean autoFetchData; |
|||
|
|||
// 紧凑模式
|
|||
private String[] dense; |
|||
|
|||
// 列冻结数
|
|||
private Integer stickyNum; |
|||
|
|||
// 是否为树形表格
|
|||
private Boolean tree; |
|||
|
|||
// 树形表格数据关系
|
|||
private String treeRelationship; |
|||
|
|||
// 树形表格图标函数
|
|||
private String treeIcon; |
|||
|
|||
// 树形表格默认全部展开
|
|||
private Boolean treeDefaultExpandAll; |
|||
|
|||
// 树形表格勾选策略
|
|||
private String treeTickStrategy; |
|||
|
|||
// checkbox勾选映射字段名
|
|||
private String tickedField; |
|||
|
|||
// 行点击选中映射字段名
|
|||
private String selectedField; |
|||
|
|||
// 默认排序字段
|
|||
private String defaultSortBy; |
|||
|
|||
// 排序方式是否为倒序
|
|||
private Boolean descending; |
|||
|
|||
// 是否分页
|
|||
private Boolean pageable; |
|||
|
|||
// 每页显示行数
|
|||
private Integer rowsPerPage; |
|||
|
|||
// 后端查询使用的初始页码
|
|||
private Integer reqPageStart; |
|||
|
|||
// 查询面板一行显示个数(0为自适应)
|
|||
private Integer queryFormColsNum; |
|||
|
|||
// 查询面板显示行数
|
|||
private Integer queryFormRowNum; |
|||
|
|||
// 编辑面板一行显示元素个数
|
|||
private Integer editorFormColsNum; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTemplateConfig() { |
|||
return templateConfig; |
|||
} |
|||
|
|||
public void setTemplateConfig(String templateConfig) { |
|||
this.templateConfig = templateConfig; |
|||
} |
|||
|
|||
public FieldComeFrom getFieldComeFrom() { |
|||
return fieldComeFrom; |
|||
} |
|||
|
|||
public void setFieldComeFrom(FieldComeFrom fieldComeFrom) { |
|||
this.fieldComeFrom = fieldComeFrom; |
|||
} |
|||
|
|||
public String getSql() { |
|||
return sql; |
|||
} |
|||
|
|||
public void setSql(String sql) { |
|||
this.sql = sql; |
|||
} |
|||
|
|||
public String getSchema() { |
|||
return schema; |
|||
} |
|||
|
|||
public void setSchema(String schema) { |
|||
this.schema = schema; |
|||
} |
|||
|
|||
public String getDatabaseTable() { |
|||
return databaseTable; |
|||
} |
|||
|
|||
public void setDatabaseTable(String databaseTable) { |
|||
this.databaseTable = databaseTable; |
|||
} |
|||
|
|||
public String getTitle() { |
|||
return title; |
|||
} |
|||
|
|||
public void setTitle(String title) { |
|||
this.title = title; |
|||
} |
|||
|
|||
public String[] getButtons() { |
|||
return buttons; |
|||
} |
|||
|
|||
public void setButtons(String[] buttons) { |
|||
this.buttons = buttons; |
|||
} |
|||
|
|||
public String getSelection() { |
|||
return selection; |
|||
} |
|||
|
|||
public void setSelection(String selection) { |
|||
this.selection = selection; |
|||
} |
|||
|
|||
public String getPrimaryKey() { |
|||
return primaryKey; |
|||
} |
|||
|
|||
public void setPrimaryKey(String primaryKey) { |
|||
this.primaryKey = primaryKey; |
|||
} |
|||
|
|||
public String getForeignKey() { |
|||
return foreignKey; |
|||
} |
|||
|
|||
public void setForeignKey(String foreignKey) { |
|||
this.foreignKey = foreignKey; |
|||
} |
|||
|
|||
public String getDataUrl() { |
|||
return dataUrl; |
|||
} |
|||
|
|||
public void setDataUrl(String dataUrl) { |
|||
this.dataUrl = dataUrl; |
|||
} |
|||
|
|||
public String getFetchDataUrl() { |
|||
return fetchDataUrl; |
|||
} |
|||
|
|||
public void setFetchDataUrl(String fetchDataUrl) { |
|||
this.fetchDataUrl = fetchDataUrl; |
|||
} |
|||
|
|||
public String getAddDataUrl() { |
|||
return addDataUrl; |
|||
} |
|||
|
|||
public void setAddDataUrl(String addDataUrl) { |
|||
this.addDataUrl = addDataUrl; |
|||
} |
|||
|
|||
public String getEditDataUrl() { |
|||
return editDataUrl; |
|||
} |
|||
|
|||
public void setEditDataUrl(String editDataUrl) { |
|||
this.editDataUrl = editDataUrl; |
|||
} |
|||
|
|||
public String getRemoveDataUrl() { |
|||
return removeDataUrl; |
|||
} |
|||
|
|||
public void setRemoveDataUrl(String removeDataUrl) { |
|||
this.removeDataUrl = removeDataUrl; |
|||
} |
|||
|
|||
public Boolean getSortNo() { |
|||
return sortNo; |
|||
} |
|||
|
|||
public void setSortNo(Boolean sortNo) { |
|||
this.sortNo = sortNo; |
|||
} |
|||
|
|||
public Boolean getCheckboxSelection() { |
|||
return checkboxSelection; |
|||
} |
|||
|
|||
public void setCheckboxSelection(Boolean checkboxSelection) { |
|||
this.checkboxSelection = checkboxSelection; |
|||
} |
|||
|
|||
public Boolean getDraggable() { |
|||
return draggable; |
|||
} |
|||
|
|||
public void setDraggable(Boolean draggable) { |
|||
this.draggable = draggable; |
|||
} |
|||
|
|||
public Boolean getAutoFetchData() { |
|||
return autoFetchData; |
|||
} |
|||
|
|||
public void setAutoFetchData(Boolean autoFetchData) { |
|||
this.autoFetchData = autoFetchData; |
|||
} |
|||
|
|||
public String[] getDense() { |
|||
return dense; |
|||
} |
|||
|
|||
public void setDense(String[] dense) { |
|||
this.dense = dense; |
|||
} |
|||
|
|||
public Integer getStickyNum() { |
|||
return stickyNum; |
|||
} |
|||
|
|||
public void setStickyNum(Integer stickyNum) { |
|||
this.stickyNum = stickyNum; |
|||
} |
|||
|
|||
public Boolean getTree() { |
|||
return tree; |
|||
} |
|||
|
|||
public void setTree(Boolean tree) { |
|||
this.tree = tree; |
|||
} |
|||
|
|||
public String getTreeRelationship() { |
|||
return treeRelationship; |
|||
} |
|||
|
|||
public void setTreeRelationship(String treeRelationship) { |
|||
this.treeRelationship = treeRelationship; |
|||
} |
|||
|
|||
public String getTreeIcon() { |
|||
return treeIcon; |
|||
} |
|||
|
|||
public void setTreeIcon(String treeIcon) { |
|||
this.treeIcon = treeIcon; |
|||
} |
|||
|
|||
public Boolean getTreeDefaultExpandAll() { |
|||
return treeDefaultExpandAll; |
|||
} |
|||
|
|||
public void setTreeDefaultExpandAll(Boolean treeDefaultExpandAll) { |
|||
this.treeDefaultExpandAll = treeDefaultExpandAll; |
|||
} |
|||
|
|||
public String getTreeTickStrategy() { |
|||
return treeTickStrategy; |
|||
} |
|||
|
|||
public void setTreeTickStrategy(String treeTickStrategy) { |
|||
this.treeTickStrategy = treeTickStrategy; |
|||
} |
|||
|
|||
public String getTickedField() { |
|||
return tickedField; |
|||
} |
|||
|
|||
public void setTickedField(String tickedField) { |
|||
this.tickedField = tickedField; |
|||
} |
|||
|
|||
public String getSelectedField() { |
|||
return selectedField; |
|||
} |
|||
|
|||
public void setSelectedField(String selectedField) { |
|||
this.selectedField = selectedField; |
|||
} |
|||
|
|||
public String getDefaultSortBy() { |
|||
return defaultSortBy; |
|||
} |
|||
|
|||
public void setDefaultSortBy(String defaultSortBy) { |
|||
this.defaultSortBy = defaultSortBy; |
|||
} |
|||
|
|||
public Boolean getDescending() { |
|||
return descending; |
|||
} |
|||
|
|||
public void setDescending(Boolean descending) { |
|||
this.descending = descending; |
|||
} |
|||
|
|||
public Boolean getPageable() { |
|||
return pageable; |
|||
} |
|||
|
|||
public void setPageable(Boolean pageable) { |
|||
this.pageable = pageable; |
|||
} |
|||
|
|||
public Integer getRowsPerPage() { |
|||
return rowsPerPage; |
|||
} |
|||
|
|||
public void setRowsPerPage(Integer rowsPerPage) { |
|||
this.rowsPerPage = rowsPerPage; |
|||
} |
|||
|
|||
public Integer getReqPageStart() { |
|||
return reqPageStart; |
|||
} |
|||
|
|||
public void setReqPageStart(Integer reqPageStart) { |
|||
this.reqPageStart = reqPageStart; |
|||
} |
|||
|
|||
public Integer getQueryFormColsNum() { |
|||
return queryFormColsNum; |
|||
} |
|||
|
|||
public void setQueryFormColsNum(Integer queryFormColsNum) { |
|||
this.queryFormColsNum = queryFormColsNum; |
|||
} |
|||
|
|||
public Integer getQueryFormRowNum() { |
|||
return queryFormRowNum; |
|||
} |
|||
|
|||
public void setQueryFormRowNum(Integer queryFormRowNum) { |
|||
this.queryFormRowNum = queryFormRowNum; |
|||
} |
|||
|
|||
public Integer getEditorFormColsNum() { |
|||
return editorFormColsNum; |
|||
} |
|||
|
|||
public void setEditorFormColsNum(Integer editorFormColsNum) { |
|||
this.editorFormColsNum = editorFormColsNum; |
|||
} |
|||
} |
@ -0,0 +1,83 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<databaseChangeLog |
|||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" |
|||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd |
|||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> |
|||
|
|||
<changeSet id="io.sc.platform.lcdp_Excel_Template_DDL" author="platform"> |
|||
<!-- Excel模板主表 --> |
|||
<createTable tableName="LCDP_EXCEL_TEMPLATE" remarks="Excel模板主表"> |
|||
<column name="ID_" type="java.sql.Types.NVARCHAR(50)" remarks="ID主键"> |
|||
<constraints primaryKey="true"/> |
|||
</column> |
|||
<column name="CODE_" type="java.sql.Types.NVARCHAR(100)" remarks="模板编码"></column> |
|||
<column name="NAME_" type="java.sql.Types.NVARCHAR(500)" remarks="模板名称"></column> |
|||
<column name="CONFIG_" type="java.sql.Types.LONGNVARCHAR" remarks="模板配置的内容"></column> |
|||
<column name="DATA_COME_FROM_" type="java.sql.Types.NVARCHAR(10)" remarks="数据来源(INPUT:手工录入,IMPORT:系统自动导入)" defaultValue="INPUT"></column> |
|||
<column name="CREATOR_" type="java.sql.Types.NVARCHAR(255)" remarks="创建人"></column> |
|||
<column name="CREATE_DATE_" type="DATETIME" remarks="创建日期"></column> |
|||
<column name="LAST_MODIFIER_" type="java.sql.Types.NVARCHAR(255)" remarks="最后修改人"></column> |
|||
<column name="LAST_MODIFYDATE_" type="DATETIME" remarks="最后修改日期"></column> |
|||
<column name="CORP_CODE_" type="java.sql.Types.NVARCHAR(255)" remarks="所属法人代码" defaultValue="_PRIMARY_"> |
|||
</column> |
|||
</createTable> |
|||
|
|||
<!-- Excel模板变量 --> |
|||
<createTable tableName="LCDP_EXCEL_PARAMS" remarks="Excel模板变量表"> |
|||
<column name="ID_" type="java.sql.Types.NVARCHAR(50)" remarks="ID主键"> |
|||
<constraints primaryKey="true"/> |
|||
</column> |
|||
<column name="CODE_" type="java.sql.Types.NVARCHAR(100)" remarks="变量编码"></column> |
|||
<column name="NAME_" type="java.sql.Types.NVARCHAR(200)" remarks="变量名称"></column> |
|||
<column name="TPL_ID_" type="java.sql.Types.NVARCHAR(50)" remarks="模板ID"></column> |
|||
<column name="IS_COMMON_" type="java.sql.Types.SMALLINT" remarks="变量是否通用(0:模板ID对应的模板可使用,1:所有模板均可使用)"></column> |
|||
<column name="TYPE_" type="java.sql.Types.NVARCHAR(50)" remarks="变量类型(SING:单值,LIST:列表)"></column> |
|||
<column name="SQL_" type="java.sql.Types.LONGNVARCHAR" remarks="取值SQL"></column> |
|||
<column name="DATA_COME_FROM_" type="java.sql.Types.NVARCHAR(10)" remarks="数据来源(INPUT:手工录入,IMPORT:系统自动导入)" defaultValue="INPUT"></column> |
|||
<column name="CREATOR_" type="java.sql.Types.NVARCHAR(255)" remarks="创建人"></column> |
|||
<column name="CREATE_DATE_" type="DATETIME" remarks="创建日期"></column> |
|||
<column name="LAST_MODIFIER_" type="java.sql.Types.NVARCHAR(255)" remarks="最后修改人"></column> |
|||
<column name="LAST_MODIFYDATE_" type="DATETIME" remarks="最后修改日期"></column> |
|||
<column name="CORP_CODE_" type="java.sql.Types.NVARCHAR(255)" remarks="所属法人代码" defaultValue="_PRIMARY_"> |
|||
</column> |
|||
</createTable> |
|||
<!-- 当模板被删除,其变量也被删除 --> |
|||
<addForeignKeyConstraint |
|||
constraintName="FK_LCDP_EXCEL_PARAMS" |
|||
baseTableName="LCDP_EXCEL_PARAMS" |
|||
baseColumnNames="TPL_ID_" |
|||
referencedTableName="LCDP_EXCEL_TEMPLATE" |
|||
referencedColumnNames="ID_" onDelete="CASCADE"/> |
|||
|
|||
<!-- Excel列表类型的变量明细 --> |
|||
<createTable tableName="LCDP_EXCEL_LIST_DETAIL" remarks="Excel列表类型的变量明细"> |
|||
<column name="ID_" type="java.sql.Types.NVARCHAR(50)" remarks="ID主键"> |
|||
<constraints primaryKey="true"/> |
|||
</column> |
|||
<column name="PARAMS_ID_" type="java.sql.Types.NVARCHAR(50)" remarks="变量表ID"></column> |
|||
<column name="SORT_NO_" type="java.sql.Types.SMALLINT" remarks="排序号"></column> |
|||
<column name="FIELD_NAME_" type="java.sql.Types.NVARCHAR(200)" remarks="字段名称"></column> |
|||
<column name="FIELD_DESC_" type="java.sql.Types.NVARCHAR(500)" remarks="字段描述"></column> |
|||
<column name="FORMAT_TYPE_" type="java.sql.Types.NVARCHAR(100)" remarks="格式化类型"></column> |
|||
<column name="DICT_FORMAT_VALUE_" type="java.sql.Types.NVARCHAR(100)" remarks="数据字典格式化值"></column> |
|||
<column name="OTHER_FORMAT_VALUE_" type="java.sql.Types.NVARCHAR(1000)" remarks="其他格式化值"></column> |
|||
<column name="DATA_COME_FROM_" type="java.sql.Types.NVARCHAR(10)" remarks="数据来源(INPUT:手工录入,IMPORT:系统自动导入)" defaultValue="INPUT"></column> |
|||
<column name="CREATOR_" type="java.sql.Types.NVARCHAR(255)" remarks="创建人"></column> |
|||
<column name="CREATE_DATE_" type="DATETIME" remarks="创建日期"></column> |
|||
<column name="LAST_MODIFIER_" type="java.sql.Types.NVARCHAR(255)" remarks="最后修改人"></column> |
|||
<column name="LAST_MODIFYDATE_" type="DATETIME" remarks="最后修改日期"></column> |
|||
<column name="CORP_CODE_" type="java.sql.Types.NVARCHAR(255)" remarks="所属法人代码" defaultValue="_PRIMARY_"> |
|||
</column> |
|||
</createTable> |
|||
<!-- 当变量被删除,其列表配置也被删除 --> |
|||
<addForeignKeyConstraint |
|||
constraintName="FK_LCDP_EXCEL_LIST_DETAIL" |
|||
baseTableName="LCDP_EXCEL_LIST_DETAIL" |
|||
baseColumnNames="PARAMS_ID_" |
|||
referencedTableName="LCDP_EXCEL_PARAMS" |
|||
referencedColumnNames="ID_" onDelete="CASCADE"/> |
|||
|
|||
</changeSet> |
|||
</databaseChangeLog> |
@ -0,0 +1,150 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<databaseChangeLog |
|||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" |
|||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd |
|||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> |
|||
|
|||
<changeSet id="io.sc.platform.lcdp_Form_DDL.xml" author="platform"> |
|||
<!-- 低代码表单配置主表 --> |
|||
<createTable tableName="LCDP_FORM" remarks="低代码表单配置主表"> |
|||
<column name="ID_" type="java.sql.Types.NVARCHAR(50)" remarks="ID主键"> |
|||
<constraints primaryKey="true"/> |
|||
</column> |
|||
<column name="NAME_" type="java.sql.Types.NVARCHAR(500)" remarks="名称"></column> |
|||
<column name="TYPE_" type="java.sql.Types.NVARCHAR(50)" remarks="类型"></column> |
|||
<column name="CONFIG_" type="java.sql.Types.LONGNVARCHAR" remarks="配置内容"></column> |
|||
<column name="PAGE_LOAD_TYPE_" type="java.sql.Types.NVARCHAR(100)" remarks="页面加载类型(JSON:通过本表的_config字段存储的json字符串加载;CONFIG:通过系统配置加载)"></column> |
|||
<column name="DATA_COME_FROM_" type="java.sql.Types.NVARCHAR(10)" remarks="数据来源(INPUT:手工录入,IMPORT:系统自动导入)" defaultValue="INPUT"></column> |
|||
<column name="CREATOR_" type="java.sql.Types.NVARCHAR(255)" remarks="创建人"></column> |
|||
<column name="CREATE_DATE_" type="DATETIME" remarks="创建日期"></column> |
|||
<column name="LAST_MODIFIER_" type="java.sql.Types.NVARCHAR(255)" remarks="最后修改人"></column> |
|||
<column name="LAST_MODIFYDATE_" type="DATETIME" remarks="最后修改日期"></column> |
|||
<column name="CORP_CODE_" type="java.sql.Types.NVARCHAR(255)" remarks="所属法人代码" defaultValue="_PRIMARY_"> |
|||
</column> |
|||
</createTable> |
|||
|
|||
<!-- 低代码表单配置-需排除的表 --> |
|||
<createTable tableName="LCDP_EXCLUDE_TABLE" remarks="低代码表单配置-需排除的表"> |
|||
<column name="ID_" type="java.sql.Types.NVARCHAR(50)" remarks="ID主键"> |
|||
<constraints primaryKey="true"/> |
|||
</column> |
|||
<column name="TABLE_" type="java.sql.Types.NVARCHAR(200)" remarks="排除的数据表名"></column> |
|||
<column name="EXCLUDE_TYPE_" type="java.sql.Types.NVARCHAR(200)" remarks="排除类型(ALL:所有配置页面都排除该表,FORM:仅表单配置页面排除,REPORT:仅报表配置页面排除)"></column> |
|||
<column name="DATA_COME_FROM_" type="java.sql.Types.NVARCHAR(10)" remarks="数据来源(INPUT:手工录入,IMPORT:系统自动导入)" defaultValue="INPUT"></column> |
|||
<column name="CREATOR_" type="java.sql.Types.NVARCHAR(255)" remarks="创建人"></column> |
|||
<column name="CREATE_DATE_" type="DATETIME" remarks="创建日期"></column> |
|||
<column name="LAST_MODIFIER_" type="java.sql.Types.NVARCHAR(255)" remarks="最后修改人"></column> |
|||
<column name="LAST_MODIFYDATE_" type="DATETIME" remarks="最后修改日期"></column> |
|||
<column name="CORP_CODE_" type="java.sql.Types.NVARCHAR(255)" remarks="所属法人代码" defaultValue="_PRIMARY_"> |
|||
</column> |
|||
</createTable> |
|||
|
|||
<!-- 低代码表单配置-表格页面主要配置表 --> |
|||
<createTable tableName="LCDP_FORM_GRID" remarks="低代码表单配置-表格页面主要配置表"> |
|||
<column name="ID_" type="java.sql.Types.NVARCHAR(50)" remarks="ID主键"> |
|||
<constraints primaryKey="true"/> |
|||
</column> |
|||
<column name="TEMPLATE_ID_" type="java.sql.Types.NVARCHAR(50)" remarks="低代码表单配置主表ID"></column> |
|||
<column name="FIELD_COME_FROM" type="java.sql.Types.NVARCHAR(50)" remarks="字段来源"></column> |
|||
<column name="SCHEMA_" type="java.sql.Types.NVARCHAR(100)" remarks="数据库实例"></column> |
|||
<column name="DATABASE_TABLE_" type="java.sql.Types.NVARCHAR(100)" remarks="数据表名"></column> |
|||
<column name="SQL_" type="java.sql.Types.LONGNVARCHAR" remarks="sql"></column> |
|||
<column name="TITLE_" type="java.sql.Types.NVARCHAR(100)" remarks="表格名称"></column> |
|||
<column name="BUTTONS_" type="java.sql.Types.NVARCHAR(1000)" remarks="表格按钮"></column> |
|||
<column name="SELECTION_" type="java.sql.Types.NVARCHAR(100)" remarks="选择模式(none:不允许选中;cell:单元格选择;row:行选择)"></column> |
|||
<column name="PRIMARY_KEY_" type="java.sql.Types.NVARCHAR(100)" remarks="数据主键"></column> |
|||
<column name="FOREIGN_KEY_" type="java.sql.Types.NVARCHAR(100)" remarks="数据外键"></column> |
|||
<column name="DATA_URL_" type="java.sql.Types.NVARCHAR(1000)" remarks="数据操作URL前缀"></column> |
|||
<column name="FETCH_DATA_URL_" type="java.sql.Types.NVARCHAR(1000)" remarks="表格加载数据URL"></column> |
|||
<column name="ADD_DATA_URL_" type="java.sql.Types.NVARCHAR(1000)" remarks="新增URL"></column> |
|||
<column name="EDIT_DATA_URL_" type="java.sql.Types.NVARCHAR(1000)" remarks="编辑URL"></column> |
|||
<column name="REMOVE_DATA_URL_" type="java.sql.Types.NVARCHAR(1000)" remarks="删除URL"></column> |
|||
<column name="SORT_NO_" type="java.sql.Types.SMALLINT" remarks="是否显示序号列"></column> |
|||
<column name="CHECKBOX_SELECTION_" type="java.sql.Types.SMALLINT" remarks="是否显示复选框列"></column> |
|||
<column name="DRAGGABLE_" type="java.sql.Types.SMALLINT" remarks="行是否允许拖拽"></column> |
|||
<column name="AUTO_FETCH_DATA_" type="java.sql.Types.SMALLINT" remarks="是否自动加载数据"></column> |
|||
<column name="DENSE_" type="java.sql.Types.NVARCHAR(200)" remarks="紧凑模式"></column> |
|||
<column name="STICKY_NUM_" type="java.sql.Types.SMALLINT" remarks="列冻结数"></column> |
|||
<column name="TREE_" type="java.sql.Types.SMALLINT" remarks="是否为树形表格"></column> |
|||
<column name="TREE_RELATIONSHIP_" type="java.sql.Types.NVARCHAR(100)" remarks="树形表格数据关系"></column> |
|||
<column name="TREE_ICON_" type="java.sql.Types.NVARCHAR(1000)" remarks="树形表格图标函数"></column> |
|||
<column name="TREE_DEFAULT_EXPAND_ALL_" type="java.sql.Types.SMALLINT" remarks="树形表格默认全部展开"></column> |
|||
<column name="TREE_TICK_STRATEGY_" type="java.sql.Types.NVARCHAR(100)" remarks="树形表格勾选策略"></column> |
|||
<column name="TICKED_FIELD_" type="java.sql.Types.NVARCHAR(100)" remarks="checkbox勾选映射字段名"></column> |
|||
<column name="SELECTED_FIELD_" type="java.sql.Types.NVARCHAR(100)" remarks="行点击选中映射字段名"></column> |
|||
<column name="DEFAULT_SORT_BY_" type="java.sql.Types.NVARCHAR(100)" remarks="默认排序字段"></column> |
|||
<column name="DESCENDING_" type="java.sql.Types.SMALLINT" remarks="排序方式(1:倒序,0:正序)"></column> |
|||
<column name="PAGEABLE_" type="java.sql.Types.SMALLINT" remarks="是否分页"></column> |
|||
<column name="ROWS_PER_PAGE_" type="java.sql.Types.SMALLINT" remarks="每页显示行数"></column> |
|||
<column name="REQ_PAGE_START_" type="java.sql.Types.SMALLINT" remarks="后端查询使用的初始页码(默认从1开始)"></column> |
|||
<column name="QUERY_FORM_COLS_NUM_" type="java.sql.Types.SMALLINT" remarks="查询面板一行显示个数(0为自适应)"></column> |
|||
<column name="QUERY_FORM_ROW_NUM_" type="java.sql.Types.SMALLINT" remarks="查询面板显示行数(默认1)"></column> |
|||
<column name="EDITOR_FORM_COLS_NUM_" type="java.sql.Types.SMALLINT" remarks="编辑面板一行显示元素个数"></column> |
|||
<column name="DATA_COME_FROM_" type="java.sql.Types.NVARCHAR(10)" remarks="数据来源(INPUT:手工录入,IMPORT:系统自动导入)" defaultValue="INPUT"></column> |
|||
<column name="CREATOR_" type="java.sql.Types.NVARCHAR(255)" remarks="创建人"></column> |
|||
<column name="CREATE_DATE_" type="DATETIME" remarks="创建日期"></column> |
|||
<column name="LAST_MODIFIER_" type="java.sql.Types.NVARCHAR(255)" remarks="最后修改人"></column> |
|||
<column name="LAST_MODIFYDATE_" type="DATETIME" remarks="最后修改日期"></column> |
|||
<column name="CORP_CODE_" type="java.sql.Types.NVARCHAR(255)" remarks="所属法人代码" defaultValue="_PRIMARY_"> |
|||
</column> |
|||
</createTable> |
|||
<!-- 当模板被删除,其配置也被删除 --> |
|||
<addForeignKeyConstraint |
|||
constraintName="FK_LCDP_FORM_GRID" |
|||
baseTableName="LCDP_FORM_GRID" |
|||
baseColumnNames="TEMPLATE_ID_" |
|||
referencedTableName="LCDP_FORM" |
|||
referencedColumnNames="ID_" onDelete="CASCADE"/> |
|||
|
|||
<!-- 低代码表单配置-表格页面字段配置表 --> |
|||
<createTable tableName="LCDP_FORM_GRID_FIELD" remarks="低代码表单配置-表格页面字段配置表"> |
|||
<column name="ID_" type="java.sql.Types.NVARCHAR(50)" remarks="ID主键"> |
|||
<constraints primaryKey="true"/> |
|||
</column> |
|||
<column name="GRID_ID_" type="java.sql.Types.NVARCHAR(50)" remarks="表格ID"></column> |
|||
<column name="PARENT_" type="java.sql.Types.NVARCHAR(50)" remarks="字段所属的父类型(query_field: 查询字段;where_field: 条件字段)"></column> |
|||
<column name="FIELD_NAME_" type="java.sql.Types.NVARCHAR(100)" remarks="字段名称"></column> |
|||
<column name="FIELD_LABEL_" type="java.sql.Types.NVARCHAR(500)" remarks="页面显示名称"></column> |
|||
<column name="FIELD_TYPE_" type="java.sql.Types.NVARCHAR(100)" remarks="字段类型"></column> |
|||
<column name="SORT_NO_" type="java.sql.Types.SMALLINT" remarks="字段序号"></column> |
|||
<column name="FIELD_LENGTH_" type="java.sql.Types.SMALLINT" remarks="字段长度"></column> |
|||
<column name="FIELD_PRECISION_" type="java.sql.Types.SMALLINT" remarks="字段精度"></column> |
|||
<column name="FIELD_IS_SELECT_" type="java.sql.Types.SMALLINT" remarks="字段是否为选项值(0:否,1:是)"></column> |
|||
<column name="OPTION_COME_FROM_" type="java.sql.Types.NVARCHAR(100)" remarks="选项值来源"></column> |
|||
<column name="DICT_OPTION_VALUE_" type="java.sql.Types.NVARCHAR(100)" remarks="数据字典选项值"></column> |
|||
<column name="OTHER_OPTION_VALUE_" type="java.sql.Types.NVARCHAR(1000)" remarks="其他选项值"></column> |
|||
<column name="ADD_SYS_VALUE_TYPE_" type="java.sql.Types.NVARCHAR(100)" remarks="新增时系统自动填充类型"></column> |
|||
<column name="EDIT_OVERRIDE_" type="java.sql.Types.SMALLINT" remarks="修改时覆盖系统自动填充值(0:否,1:是)"></column> |
|||
<column name="QUERY_SHOW_" type="java.sql.Types.SMALLINT" remarks="查询面板中显示(0:否,1:是)"></column> |
|||
<column name="QUERY_FORM_TYPE_" type="java.sql.Types.NVARCHAR(100)" remarks="使用的表单类型"></column> |
|||
<column name="QUERY_DEFA_VALUE_" type="java.sql.Types.NVARCHAR(500)" remarks="默认值"></column> |
|||
<column name="QUERY_IS_REQUIRED_" type="java.sql.Types.SMALLINT" remarks="是否必填项(0:否,1:是)"></column> |
|||
<column name="QUERY_OPERATOR_" type="java.sql.Types.NVARCHAR(100)" remarks="查询时匹配模式"></column> |
|||
<column name="TABLE_SHOW_" type="java.sql.Types.SMALLINT" remarks="列表中显示(0:否,1:是)"></column> |
|||
<column name="TABLE_SORT_" type="java.sql.Types.SMALLINT" remarks="是否支持排序(0:否,1:是)"></column> |
|||
<column name="TABLE_COLUMN_ALIGN_" type="java.sql.Types.NVARCHAR(100)" remarks="列对齐方式"></column> |
|||
<column name="TABLE_COLUMN_WIDTH_" type="java.sql.Types.SMALLINT" remarks="列宽"></column> |
|||
<column name="EDITOR_SHOW_" type="java.sql.Types.SMALLINT" remarks="编辑页面是否显示(0:否,1:是)"></column> |
|||
<column name="EDITOR_FORM_TYPE_" type="java.sql.Types.NVARCHAR(100)" remarks="使用的表单类型"></column> |
|||
<column name="EDITOR_DEFA_VALUE_" type="java.sql.Types.NVARCHAR(500)" remarks="默认值"></column> |
|||
<column name="EDITOR_IS_REQUIRED_" type="java.sql.Types.SMALLINT" remarks="是否必填项(0:否,1:是)"></column> |
|||
<column name="DATA_COME_FROM_" type="java.sql.Types.NVARCHAR(10)" remarks="数据来源(INPUT:手工录入,IMPORT:系统自动导入)" defaultValue="INPUT"></column> |
|||
<column name="CREATOR_" type="java.sql.Types.NVARCHAR(255)" remarks="创建人"></column> |
|||
<column name="CREATE_DATE_" type="DATETIME" remarks="创建日期"></column> |
|||
<column name="LAST_MODIFIER_" type="java.sql.Types.NVARCHAR(255)" remarks="最后修改人"></column> |
|||
<column name="LAST_MODIFYDATE_" type="DATETIME" remarks="最后修改日期"></column> |
|||
<column name="CORP_CODE_" type="java.sql.Types.NVARCHAR(255)" remarks="所属法人代码" defaultValue="_PRIMARY_"> |
|||
</column> |
|||
</createTable> |
|||
<!-- 当模板被删除,其配置也被删除 --> |
|||
<addForeignKeyConstraint |
|||
constraintName="FK_LCDP_FORM_GRID_FIELD" |
|||
baseTableName="LCDP_FORM_GRID_FIELD" |
|||
baseColumnNames="GRID_ID_" |
|||
referencedTableName="LCDP_FORM_GRID" |
|||
referencedColumnNames="ID_" onDelete="CASCADE"/> |
|||
|
|||
</changeSet> |
|||
</databaseChangeLog> |
Loading…
Reference in new issue