77 changed files with 1207 additions and 557 deletions
@ -0,0 +1,151 @@ |
|||||
|
{ |
||||
|
"name": "platform-core", |
||||
|
"version": "8.2.126", |
||||
|
"description": "前端核心包,用于快速构建前端的脚手架", |
||||
|
"//main": "库的主文件", |
||||
|
"main": "dist/platform-core.js", |
||||
|
"//files": "打包时需要包含的文件列表", |
||||
|
"files": [ |
||||
|
".bin", |
||||
|
"dist/configure.js", |
||||
|
"dist/css", |
||||
|
"dist/favicon.svg", |
||||
|
"dist/fonts", |
||||
|
"dist/index.html", |
||||
|
"dist/login-bg.jpg", |
||||
|
"dist/logo.svg", |
||||
|
"dist/platform-core.js", |
||||
|
"dist/types", |
||||
|
"template-project/*.*", |
||||
|
"template-project/public", |
||||
|
"template-project/src" |
||||
|
], |
||||
|
"//types": "类型申明主文件", |
||||
|
"types": "./dist/types/index.d.ts", |
||||
|
"private": false, |
||||
|
"keywords": [], |
||||
|
"author": "", |
||||
|
"license": "ISC", |
||||
|
"//bin": "可直接通过 npx 执行的命令", |
||||
|
"bin": { |
||||
|
"//platform": "npx platform", |
||||
|
"platform": "./.bin/platform.js" |
||||
|
}, |
||||
|
"scripts": { |
||||
|
"dev": "nodemon", |
||||
|
"serve": "node ./util-components-generator.cjs && cross-env NODE_ENV=development webpack serve --config webpack.env.serve.cjs", |
||||
|
"build": "node ./util-components-generator.cjs && cross-env NODE_ENV=development webpack --config webpack.env.build.cjs", |
||||
|
"prod": "node ./util-components-generator.cjs && cross-env NODE_ENV=production webpack --config webpack.env.prod.cjs", |
||||
|
"lib": "node ./util.template-generator.cjs && cross-env NODE_ENV=production webpack --config webpack.env.lib.cjs && tsc --project tsconfig.json --emitDeclarationOnly --noEmit false", |
||||
|
"check": "tsc --project tsconfig.json --emitDeclarationOnly --noEmit false", |
||||
|
"template": "node ./util.template-generator.cjs", |
||||
|
"clean": "platform clean dist ./node_modules ./pnpm-lock.yaml ./package-lock.json", |
||||
|
"sync": "platform sync" |
||||
|
}, |
||||
|
"engines": { |
||||
|
"node": ">=18", |
||||
|
"pnpm": ">=7" |
||||
|
}, |
||||
|
"publishConfig": { |
||||
|
"registry": "http://nexus.sc.io:8000/repository/npm-releases/", |
||||
|
"access": "public", |
||||
|
"no-git-checks": true |
||||
|
}, |
||||
|
"devDependencies": { |
||||
|
"@babel/core": "7.26.0", |
||||
|
"@babel/plugin-transform-class-properties": "7.25.9", |
||||
|
"@babel/plugin-transform-object-rest-spread": "7.25.9", |
||||
|
"@babel/preset-env": "7.26.0", |
||||
|
"@babel/preset-typescript": "7.26.0", |
||||
|
"@quasar/app-webpack": "4.0.7", |
||||
|
"@quasar/cli": "2.4.1", |
||||
|
"@types/mockjs": "1.0.10", |
||||
|
"@types/node": "22.10.7", |
||||
|
"@typescript-eslint/eslint-plugin": "8.20.0", |
||||
|
"@typescript-eslint/parser": "8.20.0", |
||||
|
"@vue/babel-plugin-jsx": "1.2.5", |
||||
|
"@vue/compiler-sfc": "3.5.13", |
||||
|
"@vuepress/bundler-webpack": "2.0.0-rc.15", |
||||
|
"@vuepress/theme-default": "2.0.0-rc.49", |
||||
|
"@webpack-cli/serve": "3.0.1", |
||||
|
"autoprefixer": "10.4.20", |
||||
|
"babel-loader": "9.2.1", |
||||
|
"clean-webpack-plugin": "4.0.0", |
||||
|
"copy-webpack-plugin": "12.0.2", |
||||
|
"cross-env": "7.0.3", |
||||
|
"css-loader": "7.1.2", |
||||
|
"eslint": "9.18.0", |
||||
|
"eslint-config-prettier": "10.0.1", |
||||
|
"eslint-plugin-prettier": "5.2.2", |
||||
|
"eslint-plugin-vue": "9.32.0", |
||||
|
"eslint-webpack-plugin": "4.2.0", |
||||
|
"html-webpack-plugin": "5.6.3", |
||||
|
"json5": "2.2.3", |
||||
|
"mini-css-extract-plugin": "2.9.2", |
||||
|
"nodemon": "3.1.9", |
||||
|
"postcss": "8.5.1", |
||||
|
"postcss-import": "16.1.0", |
||||
|
"postcss-loader": "8.1.1", |
||||
|
"postcss-preset-env": "10.1.3", |
||||
|
"prettier": "3.4.2", |
||||
|
"sass": "1.83.4", |
||||
|
"sass-loader": "16.0.4", |
||||
|
"tailwindcss": "3.4.17", |
||||
|
"typescript": "5.5.4", |
||||
|
"vue-loader": "17.4.2", |
||||
|
"vuepress": "2.0.0-rc.15", |
||||
|
"webpack": "5.97.1", |
||||
|
"webpack-bundle-analyzer": "4.10.2", |
||||
|
"webpack-cli": "6.0.1", |
||||
|
"webpack-dev-server": "5.2.0", |
||||
|
"webpack-merge": "6.0.1" |
||||
|
}, |
||||
|
"dependencies": { |
||||
|
"@codemirror/autocomplete": "6.18.6", |
||||
|
"@codemirror/commands": "6.8.1", |
||||
|
"@codemirror/lang-html": "6.4.9", |
||||
|
"@codemirror/lang-java": "6.0.1", |
||||
|
"@codemirror/lang-javascript": "6.2.3", |
||||
|
"@codemirror/lang-json": "6.0.1", |
||||
|
"@codemirror/lang-sql": "6.8.0", |
||||
|
"@codemirror/lang-xml": "6.1.0", |
||||
|
"@codemirror/language": "6.11.0", |
||||
|
"@codemirror/search": "6.5.10", |
||||
|
"@codemirror/state": "6.5.2", |
||||
|
"@codemirror/view": "6.36.5", |
||||
|
"@maxgraph/core": "0.14.0", |
||||
|
"@quasar/extras": "1.16.15", |
||||
|
"@quasar/quasar-ui-qmarkdown": "2.0.5", |
||||
|
"@univerjs/core": "0.5.4", |
||||
|
"@univerjs/design": "0.5.4", |
||||
|
"@univerjs/docs": "0.5.4", |
||||
|
"@univerjs/docs-ui": "0.5.4", |
||||
|
"@univerjs/engine-formula": "0.5.4", |
||||
|
"@univerjs/engine-render": "0.5.4", |
||||
|
"@univerjs/facade": "0.5.4", |
||||
|
"@univerjs/sheets": "0.5.4", |
||||
|
"@univerjs/sheets-formula": "0.5.4", |
||||
|
"@univerjs/sheets-ui": "0.5.4", |
||||
|
"@univerjs/thread-comment": "0.5.4", |
||||
|
"@univerjs/ui": "0.5.4", |
||||
|
"@vueuse/core": "12.4.0", |
||||
|
"axios": "1.8.2", |
||||
|
"codemirror": "6.0.1", |
||||
|
"dayjs": "1.11.13", |
||||
|
"echarts": "5.6.0", |
||||
|
"exceljs": "4.4.0", |
||||
|
"file-saver": "2.0.5", |
||||
|
"luckyexcel": "1.0.1", |
||||
|
"mockjs": "1.1.0", |
||||
|
"pinia": "2.3.0", |
||||
|
"quasar": "2.17.6", |
||||
|
"sort-array": "5.0.0", |
||||
|
"svg-path-commander": "2.1.7", |
||||
|
"vue": "3.5.13", |
||||
|
"vue-dompurify-html": "5.2.0", |
||||
|
"vue-i18n": "11.0.1", |
||||
|
"vue-router": "4.5.0", |
||||
|
"xml-formatter": "3.6.3", |
||||
|
"node-sql-parser": "5.3.6" |
||||
|
} |
||||
|
} |
@ -1,267 +1,271 @@ |
|||||
export type PropsType = { |
export type PropsType = { |
||||
refreshAfterActive: Boolean,// 当组件被激活时自动刷新一次
|
refreshAfterActive: Boolean; // 当组件被激活时自动刷新一次
|
||||
/** |
/** |
||||
* 表格高度 |
* 表格高度 |
||||
*/ |
*/ |
||||
height: number, |
height: number; |
||||
/** |
/** |
||||
* 表格标题 |
* 表格标题 |
||||
*/ |
*/ |
||||
title: string, |
title: string; |
||||
/** |
/** |
||||
* 自动加载数据 |
* 自动加载数据 |
||||
*/ |
*/ |
||||
autoFetchData: boolean, |
autoFetchData: boolean; |
||||
/** |
/** |
||||
* 本地模式,启用该模式后,除了查询数据依旧通过 autoFetchData 与 url 控制外,其他所有与后端交互的请求都失效,同时分页属性也失效 |
* 本地模式,启用该模式后,除了查询数据依旧通过 autoFetchData 与 url 控制外,其他所有与后端交互的请求都失效,同时分页属性也失效 |
||||
*/ |
*/ |
||||
localMode: boolean, |
localMode: boolean; |
||||
/** |
/** |
||||
* 选择模式 |
* 选择模式 |
||||
*/ |
*/ |
||||
selectMode: string, |
selectMode: string; |
||||
/** |
/** |
||||
* 拖拽数据行排序的模式,默认不可拖拽,字符串`local`为本地排序,只根据配置的字段进行本地排序,不会将数据发送至后端,字符串`server`为远程排序,拖拽完成后会将数据发送至后端。 |
* 拖拽数据行排序的模式,默认不可拖拽,字符串`local`为本地排序,只根据配置的字段进行本地排序,不会将数据发送至后端,字符串`server`为远程排序,拖拽完成后会将数据发送至后端。 |
||||
*/ |
*/ |
||||
dndMode?: undefined | string, |
dndMode?: undefined | string; |
||||
/** |
/** |
||||
* 拖拽排序时根据哪个字段进行排序,默认为`order`字段 |
* 拖拽排序时根据哪个字段进行排序,默认为`order`字段 |
||||
*/ |
*/ |
||||
dndOrderBy: string, |
dndOrderBy: string; |
||||
/** |
/** |
||||
* 是否需要分页,当启用树形表格模式时该属性失效,树形表格不支持分页。 |
* 是否需要分页,当启用树形表格模式时该属性失效,树形表格不支持分页。 |
||||
*/ |
*/ |
||||
pageable: boolean, |
pageable: boolean; |
||||
/** |
/** |
||||
* 是否显示表格配置按钮 |
* 是否显示表格配置按钮 |
||||
*/ |
*/ |
||||
configButton: boolean, |
configButton: boolean; |
||||
/** |
/** |
||||
* 表格数据操作请求的URL前缀 |
* 表格数据操作请求的URL前缀 |
||||
*/ |
*/ |
||||
dataUrl: string, |
dataUrl: string; |
||||
/** |
/** |
||||
* 获取数据URL |
* 获取数据URL |
||||
*/ |
*/ |
||||
fetchDataUrl: string, |
fetchDataUrl: string; |
||||
/** |
/** |
||||
* 新增数据url |
* 新增数据url |
||||
*/ |
*/ |
||||
addDataUrl: string, |
addDataUrl: string; |
||||
/** |
/** |
||||
* 修改数据url |
* 修改数据url |
||||
*/ |
*/ |
||||
editDataUrl: string, |
editDataUrl: string; |
||||
/** |
/** |
||||
* 删除数据url |
* 删除数据url |
||||
*/ |
*/ |
||||
removeDataUrl: string, |
removeDataUrl: string; |
||||
|
/** |
||||
|
* 导出数据url |
||||
|
*/ |
||||
|
exportDataUrl: string; |
||||
/** |
/** |
||||
* 自定义获取数据函数,若表格内置的查询参数或方式(GET、POST)等不满足使用场景,可使用该函数自定义进行查询,只需返回的结果结构与内置查询一致即可。 |
* 自定义获取数据函数,若表格内置的查询参数或方式(GET、POST)等不满足使用场景,可使用该函数自定义进行查询,只需返回的结果结构与内置查询一致即可。 |
||||
*/ |
*/ |
||||
customFetch?: Function | undefined, |
customFetch?: Function | undefined; |
||||
/** |
/** |
||||
* 表格整体紧凑模式 |
* 表格整体紧凑模式 |
||||
*/ |
*/ |
||||
dense?: undefined | boolean, |
dense?: undefined | boolean; |
||||
/** |
/** |
||||
* 表格列标题紧凑模式 |
* 表格列标题紧凑模式 |
||||
*/ |
*/ |
||||
denseHeader?: undefined | boolean, |
denseHeader?: undefined | boolean; |
||||
/** |
/** |
||||
* 表格数据行紧凑模式 |
* 表格数据行紧凑模式 |
||||
*/ |
*/ |
||||
denseBody?: undefined | boolean, |
denseBody?: undefined | boolean; |
||||
/** |
/** |
||||
* 表格底部分页栏紧凑模式 |
* 表格底部分页栏紧凑模式 |
||||
*/ |
*/ |
||||
denseBottom?: undefined | boolean, |
denseBottom?: undefined | boolean; |
||||
/** |
/** |
||||
* 表格toolbar按钮栏紧凑模式 |
* 表格toolbar按钮栏紧凑模式 |
||||
*/ |
*/ |
||||
denseToolbar?: undefined | boolean, |
denseToolbar?: undefined | boolean; |
||||
/** |
/** |
||||
* 是否显示排序号 |
* 是否显示排序号 |
||||
*/ |
*/ |
||||
sortNo: boolean, |
sortNo: boolean; |
||||
/** |
/** |
||||
* 从左侧开始冻结列数,复选框与排序列不计算在内,支持1-10列。 |
* 从左侧开始冻结列数,复选框与排序列不计算在内,支持1-10列。 |
||||
*/ |
*/ |
||||
stickyNum: number, |
stickyNum: number; |
||||
/** |
/** |
||||
* 斑马纹,当传入布尔值时斑马纹颜色默认,当传入字符串颜色时使用传入的颜色,支持rgb颜色。 |
* 斑马纹,当传入布尔值时斑马纹颜色默认,当传入字符串颜色时使用传入的颜色,支持rgb颜色。 |
||||
*/ |
*/ |
||||
stripe: boolean | string, |
stripe: boolean | string; |
||||
/** |
/** |
||||
* checkbox选择模式,默认启用 |
* checkbox选择模式,默认启用 |
||||
*/ |
*/ |
||||
checkboxSelection: boolean, |
checkboxSelection: boolean; |
||||
/** |
/** |
||||
* 行数据中记录checkbox勾选状态的字段名 |
* 行数据中记录checkbox勾选状态的字段名 |
||||
*/ |
*/ |
||||
tickedField: string, |
tickedField: string; |
||||
/** |
/** |
||||
* 行数据中记录行点击选中状态的字段名 |
* 行数据中记录行点击选中状态的字段名 |
||||
*/ |
*/ |
||||
selectedField: string, |
selectedField: string; |
||||
/** |
/** |
||||
* 树形表格模式,按照层级关系构建数据并以树形展现 |
* 树形表格模式,按照层级关系构建数据并以树形展现 |
||||
*/ |
*/ |
||||
tree: boolean, |
tree: boolean; |
||||
/** |
/** |
||||
* 树型表格模式, 懒加载 |
* 树型表格模式, 懒加载 |
||||
*/ |
*/ |
||||
treeLazyLoad: boolean, |
treeLazyLoad: boolean; |
||||
/** |
/** |
||||
* 树形表格模式,图标函数,带有一个参数,行数据 |
* 树形表格模式,图标函数,带有一个参数,行数据 |
||||
*/ |
*/ |
||||
treeIcon?: Function | undefined, |
treeIcon?: Function | undefined; |
||||
/** |
/** |
||||
* 树形表格模式,树形表格数据加载后是否全部展开 |
* 树形表格模式,树形表格数据加载后是否全部展开 |
||||
*/ |
*/ |
||||
treeDefaultExpandAll: boolean, |
treeDefaultExpandAll: boolean; |
||||
/** |
/** |
||||
* 树形表格模式,树勾选策略,strict:节点自己,leaf:包含子节点 |
* 树形表格模式,树勾选策略,strict:节点自己,leaf:包含子节点 |
||||
*/ |
*/ |
||||
treeTickStrategy: string, |
treeTickStrategy: string; |
||||
/** |
/** |
||||
* 树形表格模式的数据关系,包括:parent, children,当为parent时组件根据数据主键与数据外键构建树形数据,否则需要自己构建好树形数据放到children属性中。 |
* 树形表格模式的数据关系,包括:parent, children,当为parent时组件根据数据主键与数据外键构建树形数据,否则需要自己构建好树形数据放到children属性中。 |
||||
*/ |
*/ |
||||
treeRelationship: string, |
treeRelationship: string; |
||||
/** |
/** |
||||
* 数据主键(常规表格模式时,该字段可用作内置的编辑删除等功能对应的后端API入参,如:继承RestCrudController的update所需的入参。树形表格模式时,该字段为构建树数据的主键) |
* 数据主键(常规表格模式时,该字段可用作内置的编辑删除等功能对应的后端API入参,如:继承RestCrudController的update所需的入参。树形表格模式时,该字段为构建树数据的主键) |
||||
*/ |
*/ |
||||
primaryKey: string, |
primaryKey: string; |
||||
/** |
/** |
||||
* 数据外键(常规表格模式时,该字段暂时无用,将来可用作多个表格的数据关系字段。树形表格模式时,该字段为构建树数据的关系字段) |
* 数据外键(常规表格模式时,该字段暂时无用,将来可用作多个表格的数据关系字段。树形表格模式时,该字段为构建树数据的关系字段) |
||||
*/ |
*/ |
||||
foreignKey: string, |
foreignKey: string; |
||||
/** |
/** |
||||
* 新增、删除、修改成功后是否刷新数据列表,默认不刷新但是新增修改后台必须返回对应的行数据对象,删除则必须返回删除的记录集primaryKey集合。 |
* 新增、删除、修改成功后是否刷新数据列表,默认不刷新但是新增修改后台必须返回对应的行数据对象,删除则必须返回删除的记录集primaryKey集合。 |
||||
*/ |
*/ |
||||
refreshData?: boolean, |
refreshData?: boolean; |
||||
/** |
/** |
||||
* 默认的双击操作:可填写内置或自定义按钮name,执行的操作为按钮对应的click,固定值提供:expand(展开双击的行)、none(双击不执行任何动作) |
* 默认的双击操作:可填写内置或自定义按钮name,执行的操作为按钮对应的click,固定值提供:expand(展开双击的行)、none(双击不执行任何动作) |
||||
*/ |
*/ |
||||
dbClickOperation: string, |
dbClickOperation: string; |
||||
/** |
/** |
||||
* 表格分割线,支持:horizontal、vertical、cell、none |
* 表格分割线,支持:horizontal、vertical、cell、none |
||||
*/ |
*/ |
||||
separator: string, |
separator: string; |
||||
/** |
/** |
||||
* 隐藏表头 |
* 隐藏表头 |
||||
*/ |
*/ |
||||
hideHeader?: boolean, |
hideHeader?: boolean; |
||||
/** |
/** |
||||
* 隐藏底部 |
* 隐藏底部 |
||||
*/ |
*/ |
||||
hideBottom?: boolean, |
hideBottom?: boolean; |
||||
/** |
/** |
||||
* 分组模式,支持:alone、merge |
* 分组模式,支持:alone、merge |
||||
*/ |
*/ |
||||
groupMode?: undefined | string, |
groupMode?: undefined | string; |
||||
/** |
/** |
||||
* alone分组模式下默认展开的组,字符串支持:all、first、none,数组可配置多个组名。 |
* alone分组模式下默认展开的组,字符串支持:all、first、none,数组可配置多个组名。 |
||||
*/ |
*/ |
||||
groupStartOpen?: string | Array<any> | Function, |
groupStartOpen?: string | Array<any> | Function; |
||||
/** |
/** |
||||
* 分组字段配置,当分组模式为 alone 时若配置的为数组,取数组第一个字段。 |
* 分组字段配置,当分组模式为 alone 时若配置的为数组,取数组第一个字段。 |
||||
*/ |
*/ |
||||
groupByField: string | Array<any>, |
groupByField: string | Array<any>; |
||||
/** |
/** |
||||
* 分组显示内容,仅 alone 模式有效,支持字符串 `format` 使用分组字段列定义中配置的format进行内容显示处理,函数支持自定义显示内容 |
* 分组显示内容,仅 alone 模式有效,支持字符串 `format` 使用分组字段列定义中配置的format进行内容显示处理,函数支持自定义显示内容 |
||||
*/ |
*/ |
||||
groupByTitle?: string | Function, |
groupByTitle?: string | Function; |
||||
/** |
/** |
||||
* 表格追加行,添加到当前表格数据行尾,可添加多行,支持跨行跨列配置,用于添加合计或者额外信息。 |
* 表格追加行,添加到当前表格数据行尾,可添加多行,支持跨行跨列配置,用于添加合计或者额外信息。 |
||||
*/ |
*/ |
||||
appendRows: Array<any>, |
appendRows: Array<any>; |
||||
/** |
/** |
||||
* 默认排序字段,示例:['userName', '-lastModifyDate'],其中“-”开头表示倒序。 |
* 默认排序字段,示例:['userName', '-lastModifyDate'],其中“-”开头表示倒序。 |
||||
*/ |
*/ |
||||
sortBy: Array<any>, |
sortBy: Array<any>; |
||||
/** |
/** |
||||
* 默认勾选的记录,传入一个对象,包含:columnName(列名称,字符串类型,该属性不传默认根据数据主键查找)、data(需要勾选的数据,数组类型) |
* 默认勾选的记录,传入一个对象,包含:columnName(列名称,字符串类型,该属性不传默认根据数据主键查找)、data(需要勾选的数据,数组类型) |
||||
*/ |
*/ |
||||
tickedRecord: any, |
tickedRecord: any; |
||||
/** |
/** |
||||
* 高级查询 |
* 高级查询 |
||||
*/ |
*/ |
||||
advancedQuery: boolean, |
advancedQuery: boolean; |
||||
/** |
/** |
||||
* 查询条件,查询、翻页、刷新等操作都会带上的查询条件 |
* 查询条件,查询、翻页、刷新等操作都会带上的查询条件 |
||||
*/ |
*/ |
||||
queryCriteria: any, |
queryCriteria: any; |
||||
/** |
/** |
||||
* 列定义 |
* 列定义 |
||||
*/ |
*/ |
||||
columns: Array<any>, |
columns: Array<any>; |
||||
/** |
/** |
||||
* 查询表单字段 |
* 查询表单字段 |
||||
*/ |
*/ |
||||
queryFormFields: Array<any>, |
queryFormFields: Array<any>; |
||||
/** |
/** |
||||
* 查询表单一行显示几个元素 |
* 查询表单一行显示几个元素 |
||||
*/ |
*/ |
||||
queryFormColsNum: any, |
queryFormColsNum: any; |
||||
/** |
/** |
||||
* 查询表单显示几行 |
* 查询表单显示几行 |
||||
*/ |
*/ |
||||
queryFormRowsNum: number, |
queryFormRowsNum: number; |
||||
/** |
/** |
||||
* 查询表单 form 组件属性 |
* 查询表单 form 组件属性 |
||||
*/ |
*/ |
||||
queryFormAttrs: any, |
queryFormAttrs: any; |
||||
/** |
/** |
||||
* toolbar 按钮 |
* toolbar 按钮 |
||||
*/ |
*/ |
||||
toolbarActions: Array<any>, |
toolbarActions: Array<any>; |
||||
/** |
/** |
||||
* toolbar 属性 |
* toolbar 属性 |
||||
*/ |
*/ |
||||
toolbarConfigure: any, |
toolbarConfigure: any; |
||||
/** |
/** |
||||
* 数据行可选规则配置函数 |
* 数据行可选规则配置函数 |
||||
*/ |
*/ |
||||
selectableIf?: Function, |
selectableIf?: Function; |
||||
/** |
/** |
||||
* 数据行可选规则配置函数 |
* 数据行可选规则配置函数 |
||||
*/ |
*/ |
||||
treeTickableIf?: Function, |
treeTickableIf?: Function; |
||||
/** |
/** |
||||
* 分页大小,后台初始页码等配置 |
* 分页大小,后台初始页码等配置 |
||||
*/ |
*/ |
||||
pagination: any, |
pagination: any; |
||||
/** |
/** |
||||
* 编辑相关窗口、表单、字段配置 |
* 编辑相关窗口、表单、字段配置 |
||||
*/ |
*/ |
||||
editor?: any, |
editor?: any; |
||||
/** |
/** |
||||
* 查看抽屉、字段配置 |
* 查看抽屉、字段配置 |
||||
*/ |
*/ |
||||
viewer?: any, |
viewer?: any; |
||||
/** |
/** |
||||
* 作为form中的组件使用时控制表格是否显示 |
* 作为form中的组件使用时控制表格是否显示 |
||||
*/ |
*/ |
||||
showIf?: boolean | Function, |
showIf?: boolean | Function; |
||||
/** |
/** |
||||
* 作为form中的组件使用时配置表单form实例 |
* 作为form中的组件使用时配置表单form实例 |
||||
*/ |
*/ |
||||
form?: any, |
form?: any; |
||||
/** |
/** |
||||
* 用户自定义单击函数 |
* 用户自定义单击函数 |
||||
*/ |
*/ |
||||
onRowClick?: Function, |
onRowClick?: Function; |
||||
/** |
/** |
||||
* 用户自定义双击函数 |
* 用户自定义双击函数 |
||||
*/ |
*/ |
||||
onRowDbClick?: Function, |
onRowDbClick?: Function; |
||||
/** |
/** |
||||
* 用户自定义数据勾选函数 |
* 用户自定义数据勾选函数 |
||||
*/ |
*/ |
||||
onUpdateTicked?: Function, |
onUpdateTicked?: Function; |
||||
/** |
/** |
||||
* 用户自定义拖拽回调函数 |
* 用户自定义拖拽回调函数 |
||||
*/ |
*/ |
||||
onAfterDragAndDrop?: Function, |
onAfterDragAndDrop?: Function; |
||||
} |
}; |
||||
|
@ -1,7 +1,8 @@ |
|||||
export type UrlType = { |
export type UrlType = { |
||||
dataUrl: string, |
dataUrl: string; |
||||
fetchDataUrl: string, |
fetchDataUrl: string; |
||||
addDataUrl: string, |
addDataUrl: string; |
||||
editDataUrl: string, |
editDataUrl: string; |
||||
removeDataUrl: string, |
removeDataUrl: string; |
||||
} |
exportDataUrl: string; |
||||
|
}; |
||||
|
@ -0,0 +1,92 @@ |
|||||
|
<template> |
||||
|
<div ref="divRef" class="border border-gray-200" style="height: 100%"></div> |
||||
|
</template> |
||||
|
<script setup lang="ts"> |
||||
|
// import '@univerjs/design/lib/index.css'; |
||||
|
// import '@univerjs/ui/lib/index.css'; |
||||
|
// import '@univerjs/docs-ui/lib/index.css'; |
||||
|
// import '@univerjs/sheets-ui/lib/index.css'; |
||||
|
// import '@univerjs/sheets-formula/lib/index.css'; |
||||
|
|
||||
|
import { ref, onMounted } from 'vue'; |
||||
|
import { eventBus } from '@/platform'; |
||||
|
|
||||
|
import { LocaleType, Tools, Univer, UniverInstanceType } from '@univerjs/core'; |
||||
|
import { defaultTheme } from '@univerjs/design'; |
||||
|
|
||||
|
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; |
||||
|
import { UniverRenderEnginePlugin } from '@univerjs/engine-render'; |
||||
|
|
||||
|
import { UniverUIPlugin } from '@univerjs/ui'; |
||||
|
|
||||
|
import { UniverDocsPlugin } from '@univerjs/docs'; |
||||
|
import { UniverDocsUIPlugin } from '@univerjs/docs-ui'; |
||||
|
|
||||
|
import { UniverSheetsPlugin } from '@univerjs/sheets'; |
||||
|
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'; |
||||
|
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui'; |
||||
|
|
||||
|
import Design_en_US from '@univerjs/design/locale/en-US'; |
||||
|
import UI_en_US from '@univerjs/ui/locale/en-US'; |
||||
|
import DocsUI_en_US from '@univerjs/docs-ui/locale/en-US'; |
||||
|
import Sheets_en_US from '@univerjs/sheets/locale/en-US'; |
||||
|
import SheetsUI_en_US from '@univerjs/sheets-ui/locale/en-US'; |
||||
|
import SheetsFormula_en_US from '@univerjs/sheets-formula/locale/en-US'; |
||||
|
|
||||
|
import Design_zh_CN from '@univerjs/design/locale/zh-CN'; |
||||
|
import UI_zh_CN from '@univerjs/ui/locale/zh-CN'; |
||||
|
import DocsUI_zh_CN from '@univerjs/docs-ui/locale/zh-CN'; |
||||
|
import Sheets_zh_CN from '@univerjs/sheets/locale/zh-CN'; |
||||
|
import SheetsUI_zh_CN from '@univerjs/sheets-ui/locale/zh-CN'; |
||||
|
import SheetsFormula_zh_CN from '@univerjs/sheets-formula/locale/zh-CN'; |
||||
|
|
||||
|
import Design_zh_TW from '@univerjs/design/locale/zh-TW'; |
||||
|
import UI_zh_TW from '@univerjs/ui/locale/zh-TW'; |
||||
|
import DocsUI_zh_TW from '@univerjs/docs-ui/locale/zh-TW'; |
||||
|
import Sheets_zh_TW from '@univerjs/sheets/locale/zh-TW'; |
||||
|
import SheetsUI_zh_TW from '@univerjs/sheets-ui/locale/zh-TW'; |
||||
|
import SheetsFormula_zh_TW from '@univerjs/sheets-formula/locale/zh-TW'; |
||||
|
|
||||
|
const divRef = ref(); |
||||
|
|
||||
|
onMounted(() => { |
||||
|
const univer = new Univer({ |
||||
|
theme: defaultTheme, |
||||
|
locale: LocaleType.ZH_CN, |
||||
|
locales: { |
||||
|
[LocaleType.EN_US]: Tools.deepMerge(Sheets_en_US, DocsUI_en_US, SheetsUI_en_US, SheetsFormula_en_US, UI_en_US, Design_en_US), |
||||
|
[LocaleType.ZH_CN]: Tools.deepMerge(Sheets_zh_CN, DocsUI_zh_CN, SheetsUI_zh_CN, SheetsFormula_zh_CN, UI_zh_CN, Design_zh_CN), |
||||
|
[LocaleType.ZH_TW]: Tools.deepMerge(Sheets_zh_TW, DocsUI_zh_TW, SheetsUI_zh_TW, SheetsFormula_zh_TW, UI_zh_TW, Design_zh_TW), |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
/** |
||||
|
* 语言改变事件 |
||||
|
*/ |
||||
|
eventBus.on('onLocaleChanged', (locale) => { |
||||
|
if (locale === 'en') { |
||||
|
univer.setLocale(LocaleType.EN_US); |
||||
|
} else if (locale === 'zh_CN') { |
||||
|
univer.setLocale(LocaleType.ZH_CN); |
||||
|
} else if (locale === 'tw_CN') { |
||||
|
univer.setLocale(LocaleType.ZH_TW); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
univer.registerPlugin(UniverRenderEnginePlugin); |
||||
|
univer.registerPlugin(UniverFormulaEnginePlugin); |
||||
|
|
||||
|
univer.registerPlugin(UniverUIPlugin, { |
||||
|
container: divRef.value, |
||||
|
}); |
||||
|
|
||||
|
univer.registerPlugin(UniverDocsPlugin); |
||||
|
univer.registerPlugin(UniverDocsUIPlugin); |
||||
|
|
||||
|
univer.registerPlugin(UniverSheetsPlugin); |
||||
|
univer.registerPlugin(UniverSheetsUIPlugin); |
||||
|
univer.registerPlugin(UniverSheetsFormulaPlugin); |
||||
|
|
||||
|
univer.createUnit(UniverInstanceType.UNIVER_SHEET, {}); |
||||
|
}); |
||||
|
</script> |
@ -0,0 +1,92 @@ |
|||||
|
<template> |
||||
|
<div ref="divRef" class="border border-gray-200" style="height: 100%"></div> |
||||
|
</template> |
||||
|
<script setup lang="ts"> |
||||
|
// import '@univerjs/design/lib/index.css'; |
||||
|
// import '@univerjs/ui/lib/index.css'; |
||||
|
// import '@univerjs/docs-ui/lib/index.css'; |
||||
|
// import '@univerjs/sheets-ui/lib/index.css'; |
||||
|
// import '@univerjs/sheets-formula/lib/index.css'; |
||||
|
|
||||
|
import { ref, onMounted } from 'vue'; |
||||
|
import { eventBus } from '@/platform'; |
||||
|
|
||||
|
import { LocaleType, Tools, Univer, UniverInstanceType } from '@univerjs/core'; |
||||
|
import { defaultTheme } from '@univerjs/design'; |
||||
|
|
||||
|
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; |
||||
|
import { UniverRenderEnginePlugin } from '@univerjs/engine-render'; |
||||
|
|
||||
|
import { UniverUIPlugin } from '@univerjs/ui'; |
||||
|
|
||||
|
import { UniverDocsPlugin } from '@univerjs/docs'; |
||||
|
import { UniverDocsUIPlugin } from '@univerjs/docs-ui'; |
||||
|
|
||||
|
import { UniverSheetsPlugin } from '@univerjs/sheets'; |
||||
|
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'; |
||||
|
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui'; |
||||
|
|
||||
|
import Design_en_US from '@univerjs/design/locale/en-US'; |
||||
|
import UI_en_US from '@univerjs/ui/locale/en-US'; |
||||
|
import DocsUI_en_US from '@univerjs/docs-ui/locale/en-US'; |
||||
|
import Sheets_en_US from '@univerjs/sheets/locale/en-US'; |
||||
|
import SheetsUI_en_US from '@univerjs/sheets-ui/locale/en-US'; |
||||
|
import SheetsFormula_en_US from '@univerjs/sheets-formula/locale/en-US'; |
||||
|
|
||||
|
import Design_zh_CN from '@univerjs/design/locale/zh-CN'; |
||||
|
import UI_zh_CN from '@univerjs/ui/locale/zh-CN'; |
||||
|
import DocsUI_zh_CN from '@univerjs/docs-ui/locale/zh-CN'; |
||||
|
import Sheets_zh_CN from '@univerjs/sheets/locale/zh-CN'; |
||||
|
import SheetsUI_zh_CN from '@univerjs/sheets-ui/locale/zh-CN'; |
||||
|
import SheetsFormula_zh_CN from '@univerjs/sheets-formula/locale/zh-CN'; |
||||
|
|
||||
|
import Design_zh_TW from '@univerjs/design/locale/zh-TW'; |
||||
|
import UI_zh_TW from '@univerjs/ui/locale/zh-TW'; |
||||
|
import DocsUI_zh_TW from '@univerjs/docs-ui/locale/zh-TW'; |
||||
|
import Sheets_zh_TW from '@univerjs/sheets/locale/zh-TW'; |
||||
|
import SheetsUI_zh_TW from '@univerjs/sheets-ui/locale/zh-TW'; |
||||
|
import SheetsFormula_zh_TW from '@univerjs/sheets-formula/locale/zh-TW'; |
||||
|
|
||||
|
const divRef = ref(); |
||||
|
|
||||
|
onMounted(() => { |
||||
|
const univer = new Univer({ |
||||
|
theme: defaultTheme, |
||||
|
locale: LocaleType.ZH_CN, |
||||
|
locales: { |
||||
|
[LocaleType.EN_US]: Tools.deepMerge(Sheets_en_US, DocsUI_en_US, SheetsUI_en_US, SheetsFormula_en_US, UI_en_US, Design_en_US), |
||||
|
[LocaleType.ZH_CN]: Tools.deepMerge(Sheets_zh_CN, DocsUI_zh_CN, SheetsUI_zh_CN, SheetsFormula_zh_CN, UI_zh_CN, Design_zh_CN), |
||||
|
[LocaleType.ZH_TW]: Tools.deepMerge(Sheets_zh_TW, DocsUI_zh_TW, SheetsUI_zh_TW, SheetsFormula_zh_TW, UI_zh_TW, Design_zh_TW), |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
/** |
||||
|
* 语言改变事件 |
||||
|
*/ |
||||
|
eventBus.on('onLocaleChanged', (locale) => { |
||||
|
if (locale === 'en') { |
||||
|
univer.setLocale(LocaleType.EN_US); |
||||
|
} else if (locale === 'zh_CN') { |
||||
|
univer.setLocale(LocaleType.ZH_CN); |
||||
|
} else if (locale === 'tw_CN') { |
||||
|
univer.setLocale(LocaleType.ZH_TW); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
univer.registerPlugin(UniverRenderEnginePlugin); |
||||
|
univer.registerPlugin(UniverFormulaEnginePlugin); |
||||
|
|
||||
|
univer.registerPlugin(UniverUIPlugin, { |
||||
|
container: divRef.value, |
||||
|
}); |
||||
|
|
||||
|
univer.registerPlugin(UniverDocsPlugin); |
||||
|
univer.registerPlugin(UniverDocsUIPlugin); |
||||
|
|
||||
|
univer.registerPlugin(UniverSheetsPlugin); |
||||
|
univer.registerPlugin(UniverSheetsUIPlugin); |
||||
|
univer.registerPlugin(UniverSheetsFormulaPlugin); |
||||
|
|
||||
|
univer.createUnit(UniverInstanceType.UNIVER_SHEET, {}); |
||||
|
}); |
||||
|
</script> |
@ -1,77 +0,0 @@ |
|||||
package io.sc.platform.orm.service.support; |
|
||||
|
|
||||
import io.sc.platform.orm.service.DaoService; |
|
||||
import io.sc.platform.orm.task.ExportTask; |
|
||||
import io.sc.platform.orm.task.TaskStatus; |
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils; |
|
||||
import org.jxls.common.Context; |
|
||||
import org.jxls.util.JxlsHelper; |
|
||||
|
|
||||
import java.io.ByteArrayInputStream; |
|
||||
import java.io.FileOutputStream; |
|
||||
import java.io.InputStream; |
|
||||
|
|
||||
public class ExportExcelThread extends Thread { |
|
||||
protected ExportTask task; |
|
||||
protected DaoService daoService; |
|
||||
protected QueryParameter queryParameter; |
|
||||
|
|
||||
public ExportExcelThread(ExportTask task, DaoService daoService,QueryParameter queryParameter){ |
|
||||
this.task =task; |
|
||||
this.daoService =daoService; |
|
||||
this.queryParameter =queryParameter; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void run() { |
|
||||
try { |
|
||||
//获取模版
|
|
||||
byte[] templateBytes = daoService.getTemplateBytes(daoService.getExportTemplateConfigure()); |
|
||||
//导出
|
|
||||
String outputFilePath = task.getOutputPath(); |
|
||||
Context context = new Context(); |
|
||||
context.putVar("list", daoService.list(queryParameter)); |
|
||||
changeCurrentWeight(task.getTotalWeight()/2); |
|
||||
try ( |
|
||||
InputStream inputStream = new ByteArrayInputStream(templateBytes); |
|
||||
FileOutputStream outputStream = new FileOutputStream(outputFilePath); |
|
||||
) { |
|
||||
JxlsHelper.getInstance().setEvaluateFormulas(true).processTemplate(inputStream, outputStream, context); |
|
||||
} |
|
||||
|
|
||||
//存储到存储服务中
|
|
||||
daoService.getStorageService().add(outputFilePath, outputFilePath); |
|
||||
complete(); |
|
||||
} catch (Exception e) { |
|
||||
error(e.getClass().getName(),e.getMessage(), ExceptionUtils.getStackTrace(e)); |
|
||||
throw new RuntimeException(e); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public void startExportTask(){ |
|
||||
String id =daoService.getTaskService().create(task); |
|
||||
task.setId(id); |
|
||||
} |
|
||||
|
|
||||
public void create(){ |
|
||||
daoService.getTaskService().create(task); |
|
||||
} |
|
||||
public void changeStatus(TaskStatus status){ |
|
||||
daoService.getTaskService().changeStatus(task.getId(),status); |
|
||||
} |
|
||||
public void changeCurrentWeight(long currentWeight){ |
|
||||
daoService.getTaskService().changeCurrentWeight(task.getId(),currentWeight); |
|
||||
} |
|
||||
public void changeMessage(String message){ |
|
||||
daoService.getTaskService().changeMessage(task.getId(),message); |
|
||||
} |
|
||||
public void error(String exception,String exceptionMessage,String exceptionStackTrace){ |
|
||||
daoService.getTaskService().error(task.getId(),exception,exceptionMessage,exceptionStackTrace); |
|
||||
} |
|
||||
public void complete(){ |
|
||||
daoService.getTaskService().complete(task.getId()); |
|
||||
} |
|
||||
public boolean isCanceled(){ |
|
||||
return daoService.getTaskService().isCanceled(task.getId()); |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,133 @@ |
|||||
|
package io.sc.platform.orm.task; |
||||
|
|
||||
|
import io.sc.platform.orm.service.support.DataExportTemplateConfigure; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
public class ExportTaskBuilder extends TaskBuilder{ |
||||
|
protected DataExportTemplateConfigure templateConfigure; |
||||
|
protected String outputPath; |
||||
|
protected String exportResourceName; |
||||
|
protected String exportResourceUrl; |
||||
|
|
||||
|
public ExportTask build(){ |
||||
|
ExportTask task =new ExportTask(); |
||||
|
task.setType(TaskType.EXPORT); |
||||
|
task.setName(this.name); |
||||
|
task.setExecuteMode(this.executeMode); |
||||
|
task.setStatus(this.status); |
||||
|
task.setCreator(this.creator); |
||||
|
task.setCreateDate(this.createDate); |
||||
|
task.setCompletedDate(this.completedDate); |
||||
|
task.setCanceledDate(this.canceledDate); |
||||
|
task.setTotalWeight(this.totalWeight); |
||||
|
task.setCurrentWeight(this.currentWeight); |
||||
|
task.setMessage(this.message); |
||||
|
task.setException(this.exception); |
||||
|
task.setExceptionMessage(this.exceptionMessage); |
||||
|
task.setExceptionStackTrace(this.exceptionStackTrace); |
||||
|
|
||||
|
task.setOutputPath(this.outputPath); |
||||
|
task.setExportResourceName(this.exportResourceName); |
||||
|
task.setExportResourceUrl(this.exportResourceUrl); |
||||
|
|
||||
|
task.setTemplateConfigure(this.templateConfigure); |
||||
|
return task; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder name(String name){ |
||||
|
this.name =name; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder sync(){ |
||||
|
this.executeMode =TaskExecuteMode.SYNCHRONOUS; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder async(){ |
||||
|
this.executeMode =TaskExecuteMode.ASYNCHRONOUS; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder type(TaskType type){ |
||||
|
this.type =type; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder status(TaskStatus status){ |
||||
|
this.status =status; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder creator(String creator){ |
||||
|
this.creator =creator; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder createDate(Date createDate){ |
||||
|
this.createDate =createDate; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder completedDate(Date completedDate){ |
||||
|
this.completedDate =completedDate; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder canceledDate(Date canceledDate){ |
||||
|
this.canceledDate =canceledDate; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public ExportTaskBuilder totalWeight(Long totalWeight){ |
||||
|
this.totalWeight =totalWeight; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder currentWeight(Long currentWeight){ |
||||
|
this.currentWeight =currentWeight; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder message(String message){ |
||||
|
this.message =message; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder exception(String exception){ |
||||
|
this.exception =exception; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder exceptionMessage(String exceptionMessage){ |
||||
|
this.exceptionMessage =exceptionMessage; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder exceptionStackTrace(String exceptionStackTrace){ |
||||
|
this.exceptionStackTrace =exceptionStackTrace; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder outputPath(String outputPath){ |
||||
|
this.outputPath =outputPath; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder exportResourceName(String exportResourceName){ |
||||
|
this.exportResourceName =exportResourceName; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder exportResourceUrl(String exportResourceUrl){ |
||||
|
this.exportResourceUrl =exportResourceUrl; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ExportTaskBuilder templateConfigure(DataExportTemplateConfigure templateConfigure){ |
||||
|
this.templateConfigure =templateConfigure; |
||||
|
return this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,119 @@ |
|||||
|
package io.sc.platform.orm.task; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
public class TaskBuilder { |
||||
|
protected String name; |
||||
|
protected TaskExecuteMode executeMode; |
||||
|
protected TaskType type; |
||||
|
protected TaskStatus status; |
||||
|
protected String creator; |
||||
|
protected Date createDate; |
||||
|
protected Date completedDate; |
||||
|
protected Date canceledDate; |
||||
|
protected Long totalWeight; |
||||
|
protected Long currentWeight; |
||||
|
protected String message; |
||||
|
protected String exception; |
||||
|
protected String exceptionMessage; |
||||
|
protected String exceptionStackTrace; |
||||
|
|
||||
|
public static ExportTaskBuilder EXPORT(){ |
||||
|
return new ExportTaskBuilder(); |
||||
|
} |
||||
|
|
||||
|
public Task build(){ |
||||
|
Task task =new Task(); |
||||
|
task.setName(this.name); |
||||
|
task.setExecuteMode(this.executeMode); |
||||
|
task.setType(this.type); |
||||
|
task.setStatus(this.status); |
||||
|
task.setCreator(this.creator); |
||||
|
task.setCreateDate(this.createDate); |
||||
|
task.setCompletedDate(this.completedDate); |
||||
|
task.setCanceledDate(this.canceledDate); |
||||
|
task.setTotalWeight(this.totalWeight); |
||||
|
task.setCurrentWeight(this.currentWeight); |
||||
|
task.setMessage(this.message); |
||||
|
task.setException(this.exception); |
||||
|
task.setExceptionMessage(this.exceptionMessage); |
||||
|
task.setExceptionStackTrace(this.exceptionStackTrace); |
||||
|
return task; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder name(String name){ |
||||
|
this.name =name; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder sync(){ |
||||
|
this.executeMode =TaskExecuteMode.SYNCHRONOUS; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder async(){ |
||||
|
this.executeMode =TaskExecuteMode.ASYNCHRONOUS; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder type(TaskType type){ |
||||
|
this.type =type; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder status(TaskStatus status){ |
||||
|
this.status =status; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder creator(String creator){ |
||||
|
this.creator =creator; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder createDate(Date createDate){ |
||||
|
this.createDate =createDate; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder completedDate(Date completedDate){ |
||||
|
this.completedDate =completedDate; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder canceledDate(Date canceledDate){ |
||||
|
this.canceledDate =canceledDate; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public TaskBuilder totalWeight(Long totalWeight){ |
||||
|
this.totalWeight =totalWeight; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder currentWeight(Long currentWeight){ |
||||
|
this.currentWeight =currentWeight; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder message(String message){ |
||||
|
this.message =message; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder exception(String exception){ |
||||
|
this.exception =exception; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder exceptionMessage(String exceptionMessage){ |
||||
|
this.exceptionMessage =exceptionMessage; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public TaskBuilder exceptionStackTrace(String exceptionStackTrace){ |
||||
|
this.exceptionStackTrace =exceptionStackTrace; |
||||
|
return this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
package io.sc.platform.orm.task.exception; |
||||
|
|
||||
|
public class AsyncTaskAllreadyExistsException extends RuntimeException { |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
package io.sc.platform.orm.task.exception; |
||||
|
|
||||
|
public class JxlsTemplateNotFoundException extends Exception { |
||||
|
} |
@ -0,0 +1,93 @@ |
|||||
|
package io.sc.platform.orm.task.thread; |
||||
|
|
||||
|
import io.sc.platform.orm.service.DaoService; |
||||
|
import io.sc.platform.orm.service.support.QueryParameter; |
||||
|
import io.sc.platform.orm.storage.service.StorageService; |
||||
|
import io.sc.platform.orm.task.ExportTask; |
||||
|
import io.sc.platform.orm.task.Task; |
||||
|
import io.sc.platform.orm.task.exception.JxlsTemplateNotFoundException; |
||||
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
||||
|
import org.jxls.common.Context; |
||||
|
import org.jxls.util.JxlsHelper; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
|
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.FileOutputStream; |
||||
|
import java.io.InputStream; |
||||
|
|
||||
|
public class ExportTaskThread extends TaskThread { |
||||
|
private static final Logger log = LoggerFactory.getLogger(ExportTaskThread.class); |
||||
|
private long totalRowCount =0; |
||||
|
|
||||
|
public ExportTaskThread(Task task) { |
||||
|
super(task); |
||||
|
if(!(task instanceof ExportTask)) { |
||||
|
throw new IllegalArgumentException("task must been a ExportTask instance"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
boolean isAsyncExeucte() { |
||||
|
DaoService daoService =(DaoService)getContextObject("daoService"); |
||||
|
QueryParameter queryParameter =(QueryParameter)getContextObject("queryParameter"); |
||||
|
try { |
||||
|
totalRowCount = daoService.count(queryParameter); |
||||
|
return totalRowCount>getSynchronousExportMaxCount(); |
||||
|
} catch (Exception e) { |
||||
|
log.error("",e); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
DaoService daoService =(DaoService)getContextObject("daoService"); |
||||
|
QueryParameter queryParameter =(QueryParameter)getContextObject("queryParameter"); |
||||
|
ExportTask task =(ExportTask)this.task; |
||||
|
|
||||
|
setTotalWeight(totalRowCount);//设置进度条总量
|
||||
|
setCurrentWeight(1, "Query Database ......");//启动时设置当前进度
|
||||
|
try { |
||||
|
//获取模版
|
||||
|
byte[] templateBytes = getTemplateBytes(task.getTemplateConfigure()); |
||||
|
if(templateBytes==null){ |
||||
|
//未找到 jxls 模版错误
|
||||
|
error(JxlsTemplateNotFoundException.class.getName(),null,null); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
//查询数据
|
||||
|
Context context = new Context(); |
||||
|
context.putVar("list", daoService.list(queryParameter)); |
||||
|
|
||||
|
//查询完毕后设置进度为 1/2
|
||||
|
setCurrentWeight(totalRowCount/2,"Generate Excel ......"); |
||||
|
|
||||
|
//导出 Excel 文件
|
||||
|
String outputFilePath = task.getOutputPath(); |
||||
|
try ( |
||||
|
InputStream inputStream = new ByteArrayInputStream(templateBytes); |
||||
|
FileOutputStream outputStream = new FileOutputStream(outputFilePath); |
||||
|
) { |
||||
|
JxlsHelper.getInstance().setEvaluateFormulas(true).processTemplate(inputStream, outputStream, context); |
||||
|
} |
||||
|
|
||||
|
//查询完毕后设置进度为 1/2
|
||||
|
setCurrentWeight((long)(totalRowCount/1.1), "Save Excel ......"); |
||||
|
|
||||
|
//存储到存储服务中
|
||||
|
StorageService storageService =getSpringBean(StorageService.class); |
||||
|
storageService.add(outputFilePath, outputFilePath); |
||||
|
|
||||
|
sleep(10000); |
||||
|
|
||||
|
//完成
|
||||
|
complete(); |
||||
|
} catch (Exception e) { |
||||
|
//发生错误
|
||||
|
error(e.getClass().getName(),e.getMessage(), ExceptionUtils.getStackTrace(e)); |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,147 @@ |
|||||
|
package io.sc.platform.orm.task.thread; |
||||
|
|
||||
|
import io.sc.platform.core.Environment; |
||||
|
import io.sc.platform.orm.service.JxlsTemplateService; |
||||
|
import io.sc.platform.orm.service.support.DataExportTemplateConfigure; |
||||
|
import io.sc.platform.orm.service.support.JxlsTemplate; |
||||
|
import io.sc.platform.orm.task.Task; |
||||
|
import io.sc.platform.orm.task.TaskExecuteMode; |
||||
|
import io.sc.platform.orm.task.service.TaskService; |
||||
|
import io.sc.platform.util.ByteUtil; |
||||
|
import org.springframework.context.ApplicationContext; |
||||
|
import org.springframework.core.io.DefaultResourceLoader; |
||||
|
import org.springframework.core.io.Resource; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
import java.util.concurrent.Executor; |
||||
|
|
||||
|
public abstract class TaskThread extends Thread { |
||||
|
protected Task task; |
||||
|
protected Map<String,Object> context =new HashMap<>(); |
||||
|
|
||||
|
public TaskThread(Task task){ |
||||
|
this.task =task; |
||||
|
} |
||||
|
|
||||
|
public void addContextObject(String name,Object value){ |
||||
|
context.put(name,value); |
||||
|
} |
||||
|
|
||||
|
abstract boolean isAsyncExeucte(); |
||||
|
|
||||
|
|
||||
|
public Task execute(){ |
||||
|
if(isAsyncExeucte()){ |
||||
|
TaskService taskService = getSpringBean(TaskService.class); |
||||
|
task.setExecuteMode(TaskExecuteMode.ASYNCHRONOUS); |
||||
|
Task _task =taskService.create(task); |
||||
|
Executor executor =getSpringBean(Executor.class); |
||||
|
executor.execute(this); |
||||
|
return _task; |
||||
|
}else{ |
||||
|
run(); |
||||
|
return this.task; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected Object getContextObject(String name){ |
||||
|
return context.get(name); |
||||
|
} |
||||
|
|
||||
|
protected void setTotalWeight(long totalWeight){ |
||||
|
TaskService taskService =getSpringBean(TaskService.class); |
||||
|
taskService.setTotalWeight(task.getId(),totalWeight); |
||||
|
} |
||||
|
|
||||
|
protected void setCurrentWeight(long currentWeight,String message){ |
||||
|
TaskService taskService =getSpringBean(TaskService.class); |
||||
|
taskService.setCurrentWeight(task.getId(),currentWeight,message); |
||||
|
} |
||||
|
|
||||
|
protected void setMessage(String message){ |
||||
|
TaskService taskService =getSpringBean(TaskService.class); |
||||
|
taskService.setMessage(task.getId(),message); |
||||
|
} |
||||
|
|
||||
|
protected void error(String exception,String exceptionMessage,String exceptionStackTrace){ |
||||
|
TaskService taskService =getSpringBean(TaskService.class); |
||||
|
taskService.error(task.getId(),exception,exceptionMessage,exceptionStackTrace); |
||||
|
} |
||||
|
|
||||
|
protected void complete(){ |
||||
|
TaskService taskService =getSpringBean(TaskService.class); |
||||
|
taskService.complete(task.getId()); |
||||
|
} |
||||
|
|
||||
|
protected boolean isCanceled(){ |
||||
|
TaskService taskService =getSpringBean(TaskService.class); |
||||
|
return taskService.isCanceled(task.getId()); |
||||
|
} |
||||
|
|
||||
|
protected long getSynchronousExportMaxCount() { |
||||
|
JdbcTemplate jdbcTemplate =getSpringBean(JdbcTemplate.class); |
||||
|
Map<String,Object> row =jdbcTemplate.queryForMap("select VALUE_ from SYS_PARAMETER where CODE_=?","parameter.orm.exportExcel.synchronousExportMaxCount"); |
||||
|
if(row==null || row.isEmpty()){ |
||||
|
return 1000; |
||||
|
} |
||||
|
return Long.parseLong(row.get("VALUE_").toString()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取导出JXLS模版 |
||||
|
* @param configure 模版配置 |
||||
|
* @return 模版 |
||||
|
* @throws IOException 违例 |
||||
|
*/ |
||||
|
protected byte[] getTemplateBytes(DataExportTemplateConfigure configure) throws IOException { |
||||
|
if(configure==null){ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
JxlsTemplateService jxlsTemplateService =getSpringBean(JxlsTemplateService.class); |
||||
|
// 先查找 JXLS 模版中匹配的 code 的模版
|
||||
|
String templateCode =configure.getJxlsTemplateCode(); |
||||
|
if(StringUtils.hasText(templateCode)) { |
||||
|
JxlsTemplate template =jxlsTemplateService.findTemplateByCode(templateCode); |
||||
|
if(template!=null){ |
||||
|
return template.getBytes(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 再查找 JXLS 模版中匹配的实体类名的模版
|
||||
|
String templateJpaEntityClass =configure.getJxlsTemplateJpaEntityClass(); |
||||
|
if(StringUtils.hasText(templateJpaEntityClass)) { |
||||
|
JxlsTemplate template =jxlsTemplateService.findTemplateByJpaEntityClass(templateJpaEntityClass); |
||||
|
if(template!=null){ |
||||
|
return template.getBytes(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 最后查找预定义的模版类路径
|
||||
|
String templateClassPath =configure.getJxlsTemplateClassPath(); |
||||
|
if(StringUtils.hasText(templateClassPath)) { |
||||
|
Resource resource = new DefaultResourceLoader().getResource("classpath:/" + templateClassPath); |
||||
|
if (resource != null && resource.exists()) { |
||||
|
try (InputStream inputStream = resource.getInputStream();) { |
||||
|
return ByteUtil.read(inputStream); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
protected <T> T getSpringBean(Class<T> clazz){ |
||||
|
ApplicationContext applicationContext =Environment.getInstance().getApplicationContext(); |
||||
|
return applicationContext.getBean(clazz); |
||||
|
} |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
import com.deepoove.poi.XWPFTemplate; |
||||
|
|
||||
|
import java.io.FileNotFoundException; |
||||
|
import java.io.FileOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.util.Date; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public class WordTest { |
||||
|
public static void main(String[] args) throws IOException { |
||||
|
Map<String,Object> context =new HashMap<>(); |
||||
|
context.put("title", "Hi, poi-tl Word模板引擎"); |
||||
|
context.put("date", new Date()); |
||||
|
|
||||
|
XWPFTemplate template = XWPFTemplate.compile("/Users/wangshaoping/Desktop/test/template.docx").render(context); |
||||
|
template.writeAndClose(new FileOutputStream("/Users/wangshaoping/Desktop/test/out.docx")); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue