Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
DataCenter_Core2.1_20190520
Commits
55ec2270
Commit
55ec2270
authored
Nov 25, 2021
by
jianshuqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化:组件功能
parent
6123a96d
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
287 additions
and
14 deletions
+287
-14
FormDTO.cs
Bailun.DC.Models/Component/DTO/FormDTO.cs
+10
-0
dc_component_form.cs
Bailun.DC.Models/Component/Entity/dc_component_form.cs
+3
-1
FormService.cs
Bailun.DC.Services/Component/FormService.cs
+168
-0
FormController.cs
Bailun.DC.Web/Areas/Component/Controllers/FormController.cs
+50
-0
TableController.cs
Bailun.DC.Web/Areas/Component/Controllers/TableController.cs
+1
-1
Form.cshtml
Bailun.DC.Web/Areas/Component/Views/Dialog/Form.cshtml
+1
-0
Control.cshtml
Bailun.DC.Web/Areas/Component/Views/Form/Control.cshtml
+4
-4
Control.cshtml
Bailun.DC.Web/Areas/Component/Views/Table/Control.cshtml
+8
-0
Index.cshtml
Bailun.DC.Web/Areas/Component/Views/Table/Index.cshtml
+9
-3
Query.cshtml
Bailun.DC.Web/Areas/Component/Views/Table/Query.cshtml
+3
-1
el-dialog-form.css
Bailun.DC.Web/wwwroot/css/component/el-dialog-form.css
+4
-0
el-table-control.css
Bailun.DC.Web/wwwroot/css/component/el-table-control.css
+5
-2
el-dialog-form.js
Bailun.DC.Web/wwwroot/js/component/el-dialog-form.js
+2
-2
el-form-control.js
Bailun.DC.Web/wwwroot/js/component/el-form-control.js
+11
-0
el-table-control.js
Bailun.DC.Web/wwwroot/js/component/el-table-control.js
+8
-0
No files found.
Bailun.DC.Models/Component/DTO/FormDTO.cs
View file @
55ec2270
...
...
@@ -5,6 +5,11 @@ namespace Bailun.DC.Models.Component.DTO
public
class
FormDTO
{
/// <summary>
/// Id
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 编码
/// </summary>
public
string
Code
{
get
;
set
;
}
...
...
@@ -60,6 +65,11 @@ namespace Bailun.DC.Models.Component.DTO
public
bool
?
IsValidate
{
get
;
set
;
}
/// <summary>
/// 是否可以移动:(默认可以)
/// </summary>
public
bool
?
IsDrag
{
get
;
set
;
}
/// <summary>
/// 保存脚本
/// </summary>
public
string
SaveScript
{
get
;
set
;
}
...
...
Bailun.DC.Models/Component/Entity/dc_component_form.cs
View file @
55ec2270
using
System
;
using
Dapper
;
using
System
;
namespace
Bailun.DC.Models.Component.Entity
{
...
...
@@ -105,6 +106,7 @@ namespace Bailun.DC.Models.Component.Entity
/// <summary>
/// 创建时间
/// </summary>
[
IgnoreUpdate
]
public
DateTime
gmt_create
{
get
;
set
;
}
/// <summary>
...
...
Bailun.DC.Services/Component/FormService.cs
View file @
55ec2270
using
Bailun.DC.Models.Component.DTO
;
using
Bailun.DC.Models.Component.Entity
;
using
Dapper
;
using
MySql.Data.MySqlClient
;
using
Newtonsoft.Json
;
using
System
;
using
System.Linq
;
namespace
Bailun.DC.Services.Component
{
...
...
@@ -31,6 +35,7 @@ namespace Bailun.DC.Services.Component
{
dto
=
new
FormDTO
{
Id
=
entity
.
id
,
Code
=
entity
.
code
,
Name
=
entity
.
name
,
Width
=
entity
.
width
,
...
...
@@ -42,6 +47,7 @@ namespace Bailun.DC.Services.Component
CancelButtonText
=
entity
.
cancel_button_text
,
Justify
=
entity
.
justify
,
IsValidate
=
entity
.
is_validate
,
IsDrag
=
entity
.
is_drag
,
SaveScript
=
entity
.
save_script
,
javascript
=
entity
.
javascript
,
ListFormItem
=
!
string
.
IsNullOrWhiteSpace
(
entity
.
form_item
)
?
DeserializeCollection
<
dynamic
>(
entity
.
form_item
)
:
null
,
...
...
@@ -53,5 +59,167 @@ namespace Bailun.DC.Services.Component
return
dto
;
}
/// <summary>
/// 保存报表组件
/// </summary>
/// <param name="dto">报表组件对象</param>
/// <returns>保存结果</returns>
public
ResultDTO
Save
(
FormDTO
dto
)
{
ResultDTO
result
=
this
.
BeforeSave
(
dto
);
if
(
result
.
Result
)
{
dc_component_form
entity
=
new
dc_component_form
()
{
id
=
dto
.
Id
,
code
=
dto
.
Code
,
name
=
dto
.
Name
,
width
=
dto
.
Width
,
label_width
=
dto
.
LabelWidth
,
is_show_border
=
dto
.
IsShowBorder
,
is_show_save_button
=
dto
.
IsShowSaveButton
,
save_button_text
=
dto
.
SaveButtonText
,
is_show_cancel_button
=
dto
.
IsShowCancelButton
,
cancel_button_text
=
dto
.
CancelButtonText
,
justify
=
dto
.
Justify
,
is_validate
=
dto
.
IsValidate
,
is_drag
=
dto
.
IsDrag
,
save_script
=
dto
.
SaveScript
,
javascript
=
dto
.
javascript
,
gmt_create
=
DateTime
.
Now
,
gmt_modified
=
DateTime
.
Now
,
form_item
=
dto
.
ListFormItem
?.
Count
()
>
0
?
JsonConvert
.
SerializeObject
(
dto
.
ListFormItem
)
:
null
,
controls
=
dto
.
ListControl
?.
Count
()
>
0
?
JsonConvert
.
SerializeObject
(
dto
.
ListControl
)
:
null
,
javascript_src
=
dto
.
ListJavascriptSrc
?.
Where
(
l
=>
!
string
.
IsNullOrWhiteSpace
(
l
)).
Count
()
>
0
?
JsonConvert
.
SerializeObject
(
dto
.
ListJavascriptSrc
)
:
null
};
using
(
var
db
=
DB
)
{
//开启事务
MySqlTransaction
transaction
=
db
.
BeginTransaction
();
try
{
int
?
resultCount
=
entity
.
id
>
0
?
db
.
Update
(
entity
)
:
db
.
Insert
(
entity
);
if
(
resultCount
==
0
)
{
throw
new
Exception
(
"保存失败"
);
}
else
{
//提交事务
transaction
.
Commit
();
result
.
Message
=
"保存成功"
;
}
}
catch
(
Exception
ex
)
{
//回滚事务
transaction
.
Rollback
();
result
.
Message
=
ex
.
Message
;
result
.
Result
=
false
;
}
}
}
return
result
;
}
/// <summary>
/// 保存报表组件
/// </summary>
/// <param name="id">ID</param>
/// <param name="is_delete">是否删除</param>
/// <returns>保存结果</returns>
public
ResultDTO
Save
(
int
[]
id
,
bool
is_delete
)
{
ResultDTO
result
=
this
.
BeforeSave
(
id
);
if
(
result
.
Result
)
{
string
sql
=
"update dc_component_form set is_delete = @is_delete, gmt_modified = @gmt_modified where id in @id"
;
using
(
var
db
=
DB
)
{
//开启事务
MySqlTransaction
transaction
=
db
.
BeginTransaction
();
try
{
int
resultCount
=
db
.
Execute
(
sql
,
new
{
id
=
id
,
is_delete
=
is_delete
,
gmt_modified
=
DateTime
.
Now
});
if
(
resultCount
==
0
)
{
throw
new
Exception
(
"保存失败"
);
}
else
{
//提交事务
transaction
.
Commit
();
result
.
Message
=
"保存成功"
;
}
}
catch
(
Exception
ex
)
{
//回滚事务
transaction
.
Rollback
();
result
.
Message
=
ex
.
Message
;
result
.
Result
=
false
;
}
}
}
return
result
;
}
/// <summary>
/// 保存报表组件
/// </summary>
/// <param name="dto">报表组件对象</param>
/// <returns>保存结果</returns>
private
ResultDTO
BeforeSave
(
FormDTO
dto
)
{
ResultDTO
result
=
new
ResultDTO
();
if
(
dto
==
null
)
{
result
.
Message
=
"参数有误"
;
}
else
if
(
string
.
IsNullOrWhiteSpace
(
dto
.
Code
))
{
result
.
Message
=
"编码不能为空"
;
}
else
if
(
string
.
IsNullOrWhiteSpace
(
dto
.
Name
))
{
result
.
Message
=
"名称不能为空"
;
}
else
if
(
string
.
IsNullOrWhiteSpace
(
dto
.
Name
))
{
result
.
Message
=
"名称不能为空"
;
}
else
{
result
.
Result
=
true
;
}
return
result
;
}
/// <summary>
/// 保存报表组件
/// </summary>
/// <param name="id">ID</param>
/// <returns>保存结果</returns>
private
ResultDTO
BeforeSave
(
int
[]
id
)
{
ResultDTO
result
=
new
ResultDTO
();
if
(
id
==
null
||
id
.
Length
==
0
||
id
.
Contains
(
0
))
{
result
.
Message
=
"ID不能为空"
;
}
else
{
result
.
Result
=
true
;
}
return
result
;
}
}
}
Bailun.DC.Web/Areas/Component/Controllers/FormController.cs
View file @
55ec2270
...
...
@@ -25,5 +25,55 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
return
Json
(
result
);
}
[
HttpPost
]
public
JsonResult
Save
([
FromBody
]
FormDTO
dto
)
{
ResultDTO
result
=
default
(
ResultDTO
);
try
{
result
=
new
FormService
().
Save
(
dto
);
}
catch
(
Exception
ex
)
{
result
=
new
ResultDTO
()
{
Message
=
ex
.
Message
};
}
return
Json
(
result
);
}
[
HttpPost
]
public
JsonResult
Enable
(
int
[]
id
)
{
ResultDTO
result
=
default
(
ResultDTO
);
try
{
result
=
new
FormService
().
Save
(
id
,
true
);
}
catch
(
Exception
ex
)
{
result
=
new
ResultDTO
()
{
Message
=
ex
.
Message
};
}
return
Json
(
result
);
}
[
HttpPost
]
public
JsonResult
Disable
(
int
[]
id
)
{
ResultDTO
result
=
default
(
ResultDTO
);
try
{
result
=
new
FormService
().
Save
(
id
,
false
);
}
catch
(
Exception
ex
)
{
result
=
new
ResultDTO
()
{
Message
=
ex
.
Message
};
}
return
Json
(
result
);
}
}
}
Bailun.DC.Web/Areas/Component/Controllers/TableController.cs
View file @
55ec2270
...
...
@@ -87,7 +87,7 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
}
[
HttpPost
]
public
JsonResult
Save
(
TableDTO
dto
)
public
JsonResult
Save
(
[
FromBody
]
TableDTO
dto
)
{
ResultDTO
result
=
default
(
ResultDTO
);
try
...
...
Bailun.DC.Web/Areas/Component/Views/Dialog/Form.cshtml
View file @
55ec2270
<el-container class="el-dialog-form">
<el-dialog ref="dialog"
top="15px"
class="el-dialog-form"
el-dialog
append-to-body
...
...
Bailun.DC.Web/Areas/Component/Views/Form/Control.cshtml
View file @
55ec2270
...
...
@@ -128,17 +128,17 @@
v-on:change="javaScript.call(this,item.onchange,$event)">
</el-upload-form>
<template v-else-if="item.type == 'table' && item.code">
<el-button v-if="!item
.value || !item.value.length"
<el-button v-if="!item
_value || !item_value.length"
type="success"
icon="el-icon-plus"
v-bind:size="item.size || 'small'"
v-on:click="
$set(item,'value',[]);item.value.push({});
">
v-on:click="
onClick
">
{{"新增"}}
</el-button>
<el-table-control ref="table"
v-else
v-bind:code="item.code"
v-model="item
.
value"
v-model="item
_
value"
v-on:show-dialog="showDialog">
</el-table-control>
</template>
...
...
@@ -147,7 +147,7 @@
v-bind:style="item.color ? 'color:' + item.color: ''">{{item.value}}</span>
</template>
<template v-else-if="item_value != null">
{{ item.format ? (item_value.constructor === Boolean ? (item_value ? '是' : '否') :(new Date(item_value).format(item.format))) : item_value}}
{{ item.format ? (item_value.constructor === Boolean
|| item_value == 1 || item_value == 0
? (item_value ? '是' : '否') :(new Date(item_value).format(item.format))) : item_value}}
</template>
</span>
</script>
...
...
Bailun.DC.Web/Areas/Component/Views/Table/Control.cshtml
View file @
55ec2270
...
...
@@ -78,6 +78,14 @@
v-bind:key="index"
v-bind:width="column.width || ''"
v-bind:min-width="!column.width && ((column.name || ' ').length * 15 + 45)">
<template slot-scope="scope">
<el-form-control v-model="scope.row[column.prop]"
v-bind:item="column"
v-bind:scope="scope"
v-on:click="javaScript.call(scope,column.click,scope)"
v-on:change="javaScript.call(scope,column.change,scope)">
</el-form-control>
</template>
</el-table-column>
<template slot-scope="scope">
<el-form-control v-model="scope.row[column.prop]"
...
...
Bailun.DC.Web/Areas/Component/Views/Table/Index.cshtml
View file @
55ec2270
...
...
@@ -35,11 +35,17 @@
loading: false
},
methods: {
onShowDialog(title, form, code) {
//显示弹窗
onShowDialog: function (title, form, code) {
this.$refs.dialogForm.showDialog(title, form, code);
},
onCloseDialog(title, form, code) {
//关闭弹窗
onCloseDialog: function (title, form, code) {
this.$refs.dialogForm.closeDialog();
},
//查询数据
onSearch: function () {
this.$refs.tableQuery.onSearch();
}
}
})
...
...
@@ -47,6 +53,6 @@
</script>
}
<div id="app" v-cloak>
<el-table-query v-bind:code="code" v-on:show-dialog="onShowDialog" v-on:close-dialog="onCloseDialog"></el-table-query>
<el-table-query v-bind:code="code"
ref="tableQuery"
v-on:show-dialog="onShowDialog" v-on:close-dialog="onCloseDialog"></el-table-query>
<el-dialog-form v-bind:code="code" ref="dialogForm"></el-dialog-form>
</div>
Bailun.DC.Web/Areas/Component/Views/Table/Query.cshtml
View file @
55ec2270
...
...
@@ -13,7 +13,9 @@
<el-table-control ref="table"
v-bind:code="code"
v-bind:filterParams="filterParams"
v-on:init="onInit"></el-table-control>
v-on:init="onInit"
v-on:show-dialog="showDialog"
v-on:close-dialog="closeDialog"></el-table-control>
</el-main>
<el-footer>
<el-pagination background layout="total,sizes,jumper,prev, pager, next"
...
...
Bailun.DC.Web/wwwroot/css/component/el-dialog-form.css
View file @
55ec2270
...
...
@@ -51,3 +51,7 @@
.el-dialog-form
.el-form-control
.el-input-number
{
width
:
100%
;
}
.el-dialog__wrapper.el-dialog-form
{
overflow
:
hidden
;
}
Bailun.DC.Web/wwwroot/css/component/el-table-control.css
View file @
55ec2270
...
...
@@ -10,4 +10,8 @@
.el-table-control
.el-table__body
tr
td
a
{
color
:
#3a8ee6
;
margin
:
0px
5px
;
}
\ No newline at end of file
}
.el-table-control
.el-table__header
th
.el-table__cell
{
padding
:
0px
;
}
Bailun.DC.Web/wwwroot/js/component/el-dialog-form.js
View file @
55ec2270
...
...
@@ -91,8 +91,8 @@
}
else
{
isvalid
=
true
}
if
(
isvalid
&&
that
.
dialog
.
s
ubmit
Script
)
{
that
.
javaScript
.
call
(
that
,
that
.
dialog
.
s
ubmit
Script
,
that
.
form
)
if
(
isvalid
&&
that
.
dialog
.
s
ave
Script
)
{
that
.
javaScript
.
call
(
that
,
that
.
dialog
.
s
ave
Script
,
that
.
form
)
}
},
//
...
...
Bailun.DC.Web/wwwroot/js/component/el-form-control.js
View file @
55ec2270
...
...
@@ -15,6 +15,10 @@
//是否禁用
disabled
:
{
default
:
null
},
//表单
form
:
{
default
:
null
}
},
//双向绑定
...
...
@@ -163,6 +167,12 @@
//弹出窗
showDialog
(
title
,
form
,
code
)
{
},
//单击事件
onClick
:
function
()
{
var
that
=
this
;
Vue
.
set
(
that
,
'item_value'
,
[]);
that
.
item_value
.
push
({});
}
},
template
:
'#elFormControl'
});
\ No newline at end of file
Bailun.DC.Web/wwwroot/js/component/el-table-control.js
View file @
55ec2270
...
...
@@ -59,6 +59,14 @@
})
}
},
//关闭弹出窗
closeDialog
()
{
this
.
$emit
(
"close-dialog"
)
},
//弹出窗
showDialog
(
title
,
form
,
code
)
{
this
.
$emit
(
"show-dialog"
,
title
,
form
,
code
)
},
//获取表单组件信息
getTable
:
function
()
{
var
that
=
this
;
...
...
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