Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sample-form-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
sample-form-platform
Commits
6448da90
Commit
6448da90
authored
Nov 10, 2022
by
“yiyousong”
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.scsmile.cn/zxf/sample-form-platform
parents
650c003b
87ee3328
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
163 deletions
+11
-163
sample-form-manager-ui/admin/src/pages/software/materials/modal/AddMaterials.vue
...admin/src/pages/software/materials/modal/AddMaterials.vue
+7
-6
sample-form-manager/src/main/java/com/mortals/xhx/module/matter/model/MatterDatumEntity.java
...om/mortals/xhx/module/matter/model/MatterDatumEntity.java
+2
-2
sample-form-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterDatumServiceImpl.java
...hx/module/matter/service/impl/MatterDatumServiceImpl.java
+2
-155
No files found.
sample-form-manager-ui/admin/src/pages/software/materials/modal/AddMaterials.vue
View file @
6448da90
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
>
>
</el-switch>
</el-switch>
</el-form-item>
</el-form-item>
<!--
<el-form-item
label=
"上传附件"
prop=
"fileUrl"
>
<el-form-item
label=
"上传附件"
prop=
"fileUrl"
>
<el-upload
<el-upload
class=
"upload-demo"
class=
"upload-demo"
...
@@ -53,7 +54,7 @@
...
@@ -53,7 +54,7 @@
<el-button
size=
"small"
type=
"primary"
>
上传Word文件
</el-button>
<el-button
size=
"small"
type=
"primary"
>
上传Word文件
</el-button>
</el-upload>
</el-upload>
</el-form-item>
</el-form-item>
<el-form-item
label=
"上传模板"
prop=
"templatePath"
>
<el-form-item
label=
"上传模板"
prop=
"templatePath"
>
<el-upload
<el-upload
class=
"upload-demo"
class=
"upload-demo"
:action=
"api + 'sampleform/file/commonupload'"
:action=
"api + 'sampleform/file/commonupload'"
...
@@ -67,7 +68,7 @@
...
@@ -67,7 +68,7 @@
>
>
<el-button
size=
"small"
type=
"primary"
>
上传Word文件
</el-button>
<el-button
size=
"small"
type=
"primary"
>
上传Word文件
</el-button>
</el-upload>
</el-upload>
</el-form-item>
</el-form-item>
-->
<el-form-item
label=
"上传样表"
prop=
"samplePath"
>
<el-form-item
label=
"上传样表"
prop=
"samplePath"
>
<el-upload
<el-upload
class=
"upload-demo"
class=
"upload-demo"
...
@@ -144,13 +145,13 @@ export default {
...
@@ -144,13 +145,13 @@ export default {
materiaFullName
:
[
materiaFullName
:
[
{
required
:
true
,
message
:
"
请输入全称
"
,
trigger
:
"
blur
"
},
{
required
:
true
,
message
:
"
请输入全称
"
,
trigger
:
"
blur
"
},
],
],
fileUrl
:
[{
required
:
true
,
message
:
"
请上传表单
"
,
trigger
:
"
change
"
}],
//
fileUrl: [{ required: true, message: "请上传表单", trigger: "change" }],
samplePath
:
[
samplePath
:
[
{
required
:
true
,
message
:
"
请上传样表
"
,
trigger
:
"
change
"
},
{
required
:
true
,
message
:
"
请上传样表
"
,
trigger
:
"
change
"
},
],
],
templatePath
:
[
//
templatePath: [
{
required
:
true
,
message
:
"
请上传模板
"
,
trigger
:
"
change
"
},
//
{ required: true, message: "请上传模板", trigger: "change" },
],
//
],
},
},
headers
:
{
headers
:
{
Authorization
:
local
.
getLocal
(
"
sampleToken
"
)
Authorization
:
local
.
getLocal
(
"
sampleToken
"
)
...
...
sample-form-manager/src/main/java/com/mortals/xhx/module/matter/model/MatterDatumEntity.java
View file @
6448da90
...
@@ -363,9 +363,9 @@ public class MatterDatumEntity extends MatterDatumVo {
...
@@ -363,9 +363,9 @@ public class MatterDatumEntity extends MatterDatumVo {
this
.
isRecommend
=
0
;
this
.
isRecommend
=
0
;
this
.
total
=
null
;
this
.
total
=
0
;
this
.
sort
=
null
;
this
.
sort
=
0
;
this
.
fileName
=
""
;
this
.
fileName
=
""
;
...
...
sample-form-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterDatumServiceImpl.java
View file @
6448da90
...
@@ -99,18 +99,11 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
...
@@ -99,18 +99,11 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
@Override
@Override
protected
void
saveBefore
(
MatterDatumEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
saveBefore
(
MatterDatumEntity
entity
,
Context
context
)
throws
AppException
{
if
(
StringUtils
.
isEmpty
(
entity
.
getFileUrl
())){
throw
new
AppException
(
"填单附件不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
entity
.
getSamplePath
())){
if
(
StringUtils
.
isEmpty
(
entity
.
getSamplePath
())){
throw
new
AppException
(
"样表地址不能为空"
);
throw
new
AppException
(
"样表地址不能为空"
);
}
}
if
(
StringUtils
.
isEmpty
(
entity
.
getTemplatePath
())){
throw
new
AppException
(
"样表模板地址不能为空"
);
}
entity
.
setTotal
(
0
);
entity
.
setSort
(
0
);
entity
.
setIsRecommend
(
0
);
//生成样表预览图片
//生成样表预览图片
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
String
samplePath
=
rootPath
+
entity
.
getSamplePath
();
String
samplePath
=
rootPath
+
entity
.
getSamplePath
();
...
@@ -126,10 +119,6 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
...
@@ -126,10 +119,6 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
WordUtil
.
convertWordToJPEG
(
samplePath
,
filePathAll
);
WordUtil
.
convertWordToJPEG
(
samplePath
,
filePathAll
);
entity
.
setPreViewPath
(
prePath
+
newName
);
entity
.
setPreViewPath
(
prePath
+
newName
);
//校验模板变量正确性 todo
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getTemplatePath
()))
{
parseDocxToJson
(
entity
);
}
super
.
saveBefore
(
entity
,
context
);
super
.
saveBefore
(
entity
,
context
);
}
}
...
@@ -154,148 +143,6 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
...
@@ -154,148 +143,6 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
}
}
}
}
private
void
parseDocxToJson
(
MatterDatumEntity
entity
)
{
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
String
filepath
=
rootPath
+
entity
.
getTemplatePath
();
ConfigureBuilder
builder
=
Configure
.
builder
();
builder
.
setValidErrorHandler
(
new
Configure
.
DiscardHandler
());
builder
.
useDefaultEL
(
false
);
builder
.
buildGrammerRegex
(
RegexUtils
.
createGeneral
(
"{{"
,
"}}"
));
//builder.buildGramer("[","]");
XWPFTemplate
template
=
XWPFTemplate
.
compile
(
filepath
,
builder
.
build
());
FormDesignRoot
root
=
new
FormDesignRoot
();
FormDesignConfig
config
=
new
FormDesignConfig
();
config
.
initAttribute
();
root
.
setConfig
(
config
);
List
<
ListItem
>
collect
=
new
ArrayList
<>();
for
(
MetaTemplate
item
:
template
.
getElementTemplates
())
{
//识别简单输入
String
val
=
StrUtil
.
strip
(
item
.
variable
(),
"{{"
,
"}}"
);
List
<
String
>
keys
=
StrSplitter
.
split
(
val
,
"_"
,
true
,
true
);
//切分分隔符后动态 创建组件 i_1_姓名(第一个代表类型,第二个如果是多个累加,第三个显示label)
if
(
keys
.
size
()
>
2
)
{
String
label
=
keys
.
get
(
2
);
String
type
=
keys
.
get
(
0
);
ComponentCons
cons
=
new
ComponentCons
();
cons
.
setLabel
(
label
);
cons
.
setVal
(
val
);
cons
.
setEl
(
item
.
variable
());
cons
.
setUploadFileUrl
(
uploadUrl
);
if
(
type
.
equalsIgnoreCase
(
ComponentEnum
.
DYNAMIC_TABLE
.
getValue
()))
{
List
<
TableColItem
>
colList
=
new
ArrayList
<>();
//表格 结构化绑定数据
ConfigureBuilder
builderTable
=
Configure
.
builder
();
builderTable
.
setValidErrorHandler
(
new
Configure
.
DiscardHandler
());
builderTable
.
useDefaultEL
(
false
);
builderTable
.
buildGramer
(
"["
,
"]"
);
XWPFTemplate
templateTable
=
XWPFTemplate
.
compile
(
filepath
,
builderTable
.
build
());
for
(
MetaTemplate
col
:
templateTable
.
getElementTemplates
())
{
String
colVal
=
StrUtil
.
strip
(
col
.
variable
(),
"["
,
"]"
);
if
(!
StrUtil
.
startWith
(
colVal
,
label
))
{
continue
;
}
List
<
String
>
colKeys
=
StrSplitter
.
split
(
colVal
,
"_"
,
true
,
true
);
//提取当前table中的列元素
if
(
colKeys
.
size
()
>
3
)
{
String
colLabel
=
colKeys
.
get
(
3
);
String
colType
=
colKeys
.
get
(
1
);
TableColItem
tableColItem
=
new
TableColItem
();
tableColItem
.
setLabel
(
colLabel
);
tableColItem
.
setColType
(
colType
);
tableColItem
.
setVal
(
colVal
);
colList
.
add
(
tableColItem
);
//System.out.println("列元素" + col.variable());
}
}
cons
.
setColList
(
colList
);
DesignComponent
designComponent
=
DesignComponent
.
createType
(
type
);
ListItem
listItem
=
designComponent
.
buildDefaultComponent
(
cons
);
collect
.
add
(
listItem
);
continue
;
}
DesignComponent
designComponent
=
DesignComponent
.
createType
(
type
);
ListItem
listItem
=
designComponent
.
buildDefaultComponent
(
cons
);
collect
.
add
(
listItem
);
}
}
root
.
setList
(
collect
);
entity
.
setFormContent
(
JSON
.
toJSONString
(
root
));
}
// public static void main(String[] arg){
// String filepath = "D:\\mortals\\app\\data\\file\\uploadfile\\1665472289712.docx";
// ConfigureBuilder builder = Configure.builder();
// builder.setValidErrorHandler(new Configure.DiscardHandler());
// builder.useDefaultEL(false);
// builder.buildGrammerRegex(RegexUtils.createGeneral("{{", "}}"));
// //builder.buildGramer("[","]");
// XWPFTemplate template = XWPFTemplate.compile(filepath, builder.build());
// System.out.println(template.getElementTemplates().toString());
// FormDesignRoot root = new FormDesignRoot();
// FormDesignConfig config = new FormDesignConfig();
// config.initAttribute();
// root.setConfig(config);
// List<ListItem> collect = new ArrayList<>();
// for (MetaTemplate item : template.getElementTemplates()) {
// //识别简单输入
// String val = StrUtil.strip(item.variable(), "{{", "}}");
// List<String> keys = StrSplitter.split(val, "_", true, true);
// //切分分隔符后动态 创建组件 i_1_姓名(第一个代表类型,第二个如果是多个累加,第三个显示label)
// if (keys.size() > 2) {
// String label = keys.get(2);
// String type = keys.get(0);
// ComponentCons cons = new ComponentCons();
// cons.setLabel(label);
// cons.setVal(val);
// cons.setEl(item.variable());
// cons.setUploadFileUrl("");
//
// if (type.equalsIgnoreCase(ComponentEnum.DYNAMIC_TABLE.getValue())) {
// List<TableColItem> colList = new ArrayList<>();
// //表格 结构化绑定数据
// ConfigureBuilder builderTable = Configure.builder();
// builderTable.setValidErrorHandler(new Configure.DiscardHandler());
// builderTable.useDefaultEL(false);
// builderTable.buildGramer("[", "]");
// XWPFTemplate templateTable = XWPFTemplate.compile(filepath, builderTable.build());
//
// for (MetaTemplate col : templateTable.getElementTemplates()) {
// String colVal = StrUtil.strip(col.variable(), "[", "]");
// if (!StrUtil.startWith(colVal, label)) {
// continue;
// }
// List<String> colKeys = StrSplitter.split(colVal, "_", true, true);
// //提取当前table中的列元素
// if (colKeys.size() > 3) {
// String colLabel = colKeys.get(3);
// String colType = colKeys.get(1);
// TableColItem tableColItem = new TableColItem();
// tableColItem.setLabel(colLabel);
// tableColItem.setColType(colType);
// tableColItem.setVal(colVal);
// colList.add(tableColItem);
// //System.out.println("列元素" + col.variable());
// }
// }
// cons.setColList(colList);
// DesignComponent designComponent = DesignComponent.createType(type);
// ListItem listItem = designComponent.buildDefaultComponent(cons);
// collect.add(listItem);
// continue;
// }
// DesignComponent designComponent = DesignComponent.createType(type);
// ListItem listItem = designComponent.buildDefaultComponent(cons);
// collect.add(listItem);
// }
// }
// root.setList(collect);
// System.out.println(JSON.toJSONString(root));
// }
@Override
@Override
public
String
mergeFormToDoc
(
MatterDatumEntity
docFormVo
,
Context
context
)
{
public
String
mergeFormToDoc
(
MatterDatumEntity
docFormVo
,
Context
context
)
{
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment