Commit b39883af by wish_lf

增加功能:流水自动检测

parent bd0d13ee
using Newtonsoft.Json;
using Bailun.DC.Models.Component.Enum;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Bailun.DC.Models.Component.DTO
......@@ -41,6 +42,11 @@ namespace Bailun.DC.Models.Component.DTO
public bool IsShowImportButton { get; set; }
/// <summary>
/// 是否显示顺序列: 1:显示; 0:不显示
/// </summary>
public bool IsShowSequenceColumn { get; set; }
/// <summary>
/// 选择行方式:1: 单选, 2: 多选
/// </summary>
public int? SelectRowMethod { get; set; }
......@@ -48,7 +54,7 @@ namespace Bailun.DC.Models.Component.DTO
/// <summary>
/// 列类型: 1: 控制器函数, 2: WebApi, 3:数据源编码, 4:SQL, 5:本地配置
/// </summary>
public int? ColumnType { get; set; }
public ColumnTypeEnum? ColumnType { get; set; }
/// <summary>
/// 列值
......@@ -69,7 +75,7 @@ namespace Bailun.DC.Models.Component.DTO
/// <summary>
/// 数据类型:1: 控制器函数, 2: WebApi, 3:数据库表或视图, 4:SQL
/// </summary>
public int? DataType { get; set; }
public DataTypeEnum? DataType { get; set; }
/// <summary>
/// 数据值
......@@ -78,6 +84,12 @@ namespace Bailun.DC.Models.Component.DTO
public string DataValue { get; set; }
/// <summary>
/// 数据库:1: 数据中心, 2: 交易流水
/// </summary>
[JsonIgnore]
public DBEnum? DataDB { get; set; }
/// <summary>
/// 数据默认排序SQL
/// </summary>
[JsonIgnore]
......
using System;
using Bailun.DC.Models.Component.Enum;
using System;
namespace Bailun.DC.Models.Component.Entity
{
......@@ -68,6 +69,11 @@ namespace Bailun.DC.Models.Component.Entity
public string operate_controls { get; set; }
/// <summary>
/// 是否显示顺序列: 1:显示; 0:不显示
/// </summary>
public bool is_show_sequence_column { get; set; }
/// <summary>
/// 选择行方式:1: 单选, 2: 多选
/// </summary>
public int? select_row_method { get; set; }
......@@ -75,7 +81,7 @@ namespace Bailun.DC.Models.Component.Entity
/// <summary>
/// 列类型: 1: 控制器函数, 2: WebApi, 3:数据源编码, 4:SQL, 5:本地配置
/// </summary>
public int? column_type { get; set; }
public ColumnTypeEnum? column_type { get; set; }
/// <summary>
/// 列值
......@@ -100,7 +106,7 @@ namespace Bailun.DC.Models.Component.Entity
/// <summary>
/// 数据类型:1: 控制器函数, 2: WebApi, 3:数据库表或视图, 4:SQL
/// </summary>
public int? data_type { get; set; }
public DataTypeEnum? data_type { get; set; }
/// <summary>
/// 列值
......@@ -113,6 +119,11 @@ namespace Bailun.DC.Models.Component.Entity
public string data_sort_sql { get; set; }
/// <summary>
/// 数据库:1: 数据中心, 2: 交易流水
/// </summary>
public DBEnum? data_db { get; set; }
/// <summary>
/// 是否自动查询: 1:是; 0:否
/// </summary>
public bool is_auto_search { get; set; }
......
......@@ -3,34 +3,21 @@
namespace Bailun.DC.Models.Component.Enum
{
/// <summary>
/// 列名类型:1:控制器函数,2:WEBAPI,3:数据源编码,4:SQL,5:本地配置
/// 列名类型:1:API,2:SQL,3:本地配置
/// </summary>
public enum ColumnTypeEnum
{
/// <summary>
/// 控制器函数
/// </summary>
[Description("控制器函数")]
Controller = 1,
/// <summary>
/// WEBAPI
/// </summary>
[Description("WEBAPI")]
Webapi = 2,
/// <summary>
/// 数据源编码
/// </summary>
[Description("数据源编码")]
DataSourceCode = 3,
[Description("API")]
Api = 1,
/// <summary>
/// SQL
/// </summary>
[Description("SQL")]
Sql = 4,
Sql = 2,
/// <summary>
/// 本地配置
/// </summary>
[Description("本地配置")]
Config = 5
[Description("配置")]
Config = 3
}
}
using System.ComponentModel;
namespace Bailun.DC.Models.Component.Enum
{
/// <summary>
/// 数据库:1: 数据中心, 2: 交易流水
/// </summary>
public enum DBEnum
{
/// <summary>
/// 数据中心
/// </summary>
[Description("数据中心")]
DataCenter = 1,
/// <summary>
/// 交易流水
/// </summary>
[Description("交易流水")]
DataWareHouse = 2
}
}
......@@ -3,39 +3,38 @@
namespace Bailun.DC.Models.Component.Enum
{
/// <summary>
/// 列名类型:1:控制器函数,2:WEBAPI,3:数据库表或视图,4:SQL,5:动态SQL,6:储存过程
/// 列名类型:1:Api,2:Sql,3:数据库表或视图,4:动态SQL,5:储存过程
/// </summary>
public enum DataTypeEnum
{
/// <summary>
/// 控制器函数
/// API
/// </summary>
[Description("控制器函数")]
Controller = 1,
[Description("Api")]
Api = 1,
/// <summary>
/// WEBAPI
/// SQL
/// </summary>
[Description("WEBAPI")]
Webapi = 2,
[Description("SQL")]
Sql = 2,
/// <summary>
/// 数据源编数据库表或视图码
/// 数据库表或视图
/// </summary>
[Description("数据库表或视图")]
Table = 3,
/// <summary>
/// SQL
/// </summary>
[Description("SQL")]
Sql = 4,
/// <summary>
/// SQL
/// 动态SQL
/// </summary>
[Description("动态SQL")]
DynamicSql = 5,
DynamicSql = 4,
/// <summary>
/// 储存过程
/// </summary>
[Description("储存过程")]
ExecuteSql = 6,
ExecuteSql = 5,
}
}
......@@ -29,13 +29,9 @@ namespace Bailun.DC.Services.Component
dc_component_query entity = default(dc_component_query);
using (var db = DB)
{
if (db.State == System.Data.ConnectionState.Closed)
{
db.Open();
}
DynamicParameters sqlparam = new DynamicParameters();
sqlparam.Add("code", code);
entity = db.QueryFirst<dc_component_query>("select * from dc_component_query where is_delete = 0 and code = @code", sqlparam);
entity = db.QueryFirstOrDefault<dc_component_query>("select * from dc_component_query where is_delete = 0 and code = @code", sqlparam);
}
if (entity != null)
{
......@@ -48,10 +44,12 @@ namespace Bailun.DC.Services.Component
IsShowResetButton = entity.is_show_reset_button,
IsShowExportButton = entity.is_show_export_button,
IsShowImportButton = entity.is_show_import_button,
IsShowSequenceColumn = entity.is_show_sequence_column,
ColumnType = entity.column_type,
ColumnValue = entity.column_value,
DataType = entity.data_type,
DataValue = entity.data_value,
DataDB = entity.data_db,
DataSortSql = entity.data_sort_sql,
IsAutoSearch = entity.is_auto_search,
SelectRowMethod = entity.select_row_method,
......@@ -64,7 +62,7 @@ namespace Bailun.DC.Services.Component
ListOperateColumnControl = !string.IsNullOrWhiteSpace(entity.operate_column_value) ? DeserializeCollection<ControlDTO>(entity.operate_column_value) : null,
};
//列
if (dto.ColumnType == 5 && !string.IsNullOrWhiteSpace(entity.column_value))
if (dto.ColumnType == ColumnTypeEnum.Config && !string.IsNullOrWhiteSpace(entity.column_value))
{
dto.ListColumn = DeserializeCollection<ColumnDTO>(entity.column_value);
}
......@@ -85,13 +83,12 @@ namespace Bailun.DC.Services.Component
if (queryFilter != null && !string.IsNullOrWhiteSpace(queryFilter.Code))
{
QueryDTO entity = this.Get(queryFilter.Code);
if (entity != null && (!string.IsNullOrWhiteSpace(entity.ColumnValue) || entity.ColumnType == (int)ColumnTypeEnum.Controller))
if (entity != null && (!string.IsNullOrWhiteSpace(entity.ColumnValue)))
{
switch (entity.ColumnType)
{
#region 控制器函数/Webapi
case (int)ColumnTypeEnum.Controller:
case (int)ColumnTypeEnum.Webapi:
case ColumnTypeEnum.Api:
/*
ValidateResult result = default(ValidateResult);
Uri uri = HttpContext.Current.Request.Url;
......@@ -145,46 +142,21 @@ namespace Bailun.DC.Services.Component
#endregion
#region 数据源编码
case (int)ColumnTypeEnum.DataSourceCode:
/*
var linq = from dataSource in this.DbContext.MSTB_OSMS_ONSITE_DATA_SOURCE
join dataSourceItems in this.DbContext.MSTB_OSMS_ONSITE_DATA_SOURCE_ITEMS on new { DataSourceCode = dataSource.Code, FieldType = (int?)FieldTypeEnum.Field, dataSource.RecordID, dataSource.Status } equals new { dataSourceItems.DataSourceCode, dataSourceItems.FieldType, dataSourceItems.RecordID, dataSourceItems.Status }
where dataSource.Code == entity.ColumnValue
&& dataSource.RecordID == recordId
&& dataSource.Status == (int)RecordStatus.Enabled
orderby dataSourceItems.Sort
select new ColumnDTO
{
Name = dataSourceItems.ViewFieldName,
Code = dataSourceItems.ViewField,
//Type = dataSourceItems.FieldDataType
};
list = linq.ToList();
*/
break;
#endregion
#region SQL
case (int)ColumnTypeEnum.Sql:
case ColumnTypeEnum.Sql:
DynamicParameters sqlparam = new DynamicParameters();
//过虑条件SQL
this.GetFilterSql(queryFilter, ref sqlparam);
//查询
using (var db = DB)
{
if (db.State == System.Data.ConnectionState.Closed)
using (var db = (entity.DataDB == DBEnum.DataWareHouse ? DW_DB : DB))
{
db.Open();
}
list = DB.Query<ColumnDTO>(entity.ColumnValue, sqlparam).ToList();
}
break;
#endregion
#region 本地配置
case (int)ColumnTypeEnum.Config:
case ColumnTypeEnum.Config:
list = DeserializeCollection<ColumnDTO>(entity.ColumnValue).ToList();
break;
#endregion
......@@ -258,13 +230,12 @@ namespace Bailun.DC.Services.Component
if (queryFilter != null && !string.IsNullOrWhiteSpace(queryFilter.Code))
{
QueryDTO entity = this.Get(queryFilter.Code);
if (entity != null && (!string.IsNullOrWhiteSpace(entity.DataValue) || entity.DataType == (int)DataTypeEnum.Controller || entity.DataType == (int)DataTypeEnum.DynamicSql))
if (entity != null && (!string.IsNullOrWhiteSpace(entity.DataValue)))
{
switch (entity.DataType)
{
#region 控制器函数/Webapi
case (int)DataTypeEnum.Controller:
case (int)DataTypeEnum.Webapi:
#region Api
case DataTypeEnum.Api:
/*
//Uri uri = HttpContext.Current.Request.Url;
//ValidateResult result = default(ValidateResult);
......@@ -322,21 +293,21 @@ namespace Bailun.DC.Services.Component
#endregion
#region 数据库表或视图/SQL
case (int)DataTypeEnum.Table:
case (int)DataTypeEnum.Sql:
case DataTypeEnum.Table:
case DataTypeEnum.Sql:
DynamicParameters sqlparam = new DynamicParameters();
int fetch = (queryFilter.pageSize > 0 ? queryFilter.pageSize : int.MaxValue).Value;
int offset = (((queryFilter.CurrentPage > 1 ? queryFilter.CurrentPage : 1) - 1) * fetch).Value;
//过虑条件SQL
string whereSql = this.GetFilterSql(queryFilter, ref sqlparam);
//排序条件SQL
string orderbySql = this.GetOrderBySql(queryFilter);
string fromSql = $"FROM {(entity.DataType == (int)DataTypeEnum.Table ? $"[dbo].[{entity.DataValue}]" : $"( {entity.DataValue} )")} AS A {whereSql}";
string orderbySql = this.GetOrderBySql(queryFilter, entity);
string fromSql = $"FROM {(entity.DataType == DataTypeEnum.Table ? $"[dbo].[{entity.DataValue}]" : $"( {entity.DataValue} )")} AS A {whereSql}";
string totalSql = $"SELECT COUNT(*) {fromSql}";
string dataSql = $"SELECT A.* {fromSql} ORDER BY {orderbySql} LIMIT {offset} , {fetch}";
using (var db = DW_DB)
using (var db = (entity.DataDB == DBEnum.DataWareHouse ? DW_DB : DB))
{
pageList.TotalCount = db.QueryFirst<int>(totalSql, sqlparam);
pageList.TotalCount = db.QueryFirstOrDefault<int>(totalSql, sqlparam);
if (pageList.TotalCount > 0)
{
var reader = db.ExecuteReader(dataSql, sqlparam);
......@@ -349,7 +320,7 @@ namespace Bailun.DC.Services.Component
#region 动态SQL
case (int)DataTypeEnum.DynamicSql:
case DataTypeEnum.DynamicSql:
/*
string sql = default(string);
uri = HttpContext.Current.Request.Url;
......@@ -624,7 +595,7 @@ namespace Bailun.DC.Services.Component
else
{
IList<ColumnDTO> listColumn = default(IList<ColumnDTO>);
if (entity.ColumnType == (int)ColumnTypeEnum.Config)
if (entity.ColumnType == ColumnTypeEnum.Config)
{
listColumn = DeserializeCollection<ColumnDTO>(entity.ColumnValue).ToList();
}
......
......@@ -8,10 +8,6 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
[Area("Component")]
public class QueryController : Base.BaseController
{
public IActionResult Index()
{
return View();
}
[HttpGet]
public JsonResult Get(string code = null)
......
using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Services.Component;
using Microsoft.AspNetCore.Mvc;
using System;
namespace Bailun.DC.Web.Areas.Component.Controllers
{
[Area("Component")]
public class TableController : Base.BaseController
{
public IActionResult Index()
{
return View();
}
}
}
......@@ -39,13 +39,16 @@
v-bind:value="option[item.value] || option.value">
</el-option>
</el-select>
<el-date-picker v-else-if="item.type == 'date'"
<el-date-picker v-else-if="item.type == 'date' || item.type == 'daterange'"
v-model="item_value"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
v-bind:clearable="item.clearable == null || item.clearable"
v-bind:disabled="disabled || (disabled == null && item.disabled != null && (item.disabled == true || javaScript.call(this,item.disabled)))"
v-bind:placeholder="item.placeholder || ('请选择' + (item.label || item.name || ''))"
v-bind:size="item.size || 'small'"
type="date"
v-bind:type="item.type"
value-format="yyyy/MM/dd"
v-bind:picker-options="{shortcuts: [{text: '今天',onClick:function(picker) {picker.$emit('pick', new Date())}}]}">
</el-date-picker>
......
@{
ViewData["Title"] = "自动对账面板";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "自动对账", "情况表" };
}
@section css{
<link href="@Url.Content("~/css/vue/v-cloak.css")" rel="stylesheet" />
<link href="@Url.Content("~/css/vue/element-ui-2.15.6.css")" rel="stylesheet" />
<link href="@Url.Content("~/css/component/query-table.css")" rel="stylesheet" />
}
@section scripts{
<script src="@Url.Content("~/js/vue/vue-2.6.14.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/vue/element-ui-2.15.6.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/vue/vue-resource.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/component/js.prototype.ex.js")" type="text/javascript"></script>
<script type="text/x-template" id="elQueryTable">
@Html.PartialAsync("~/Areas/Component/Views/Table/Query.cshtml").Result
</script>
<script>
$(document).ready(function () {
new Vue({
el: '#app',
data: {
code: getUrlParam("code")
}
})
})
</script>
}
<div id="app" v-cloak>
<el-query-table v-bind:code="code"></el-query-table>
</div>
......@@ -20,10 +20,10 @@
<el-main>
<el-table ref="table"
class="form-table el-table--scrollable-y"
v-bind:data="listData"
row-key="onRowKey"
stripe
border
v-bind:data="listData"
v-bind:row-key="id"
v-bind:highlightCurrentRow="setting.selectRowMethod == 1"
v-on:sort-change="onSortChange"
v-on:selection-change="onSelectionChange"
......@@ -48,10 +48,10 @@
</el-radio>
</template>
</el-table-column>
<el-table-column v-if="setting.showIndex"
<el-table-column v-if="setting.isShowSequenceColumn"
type="index"
header-align="center"
v-bind:index="handleIndexCalc"
v-bind:index="onSequenceIndex"
label="序号"
width="60"
align="center" />
......@@ -110,5 +110,4 @@
</script>
<script src="@Url.Content("~/js/component/xlsx.full.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/component/file-saver.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/component/js.prototype.ex.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/component/query-table.js")" type="text/javascript">
......@@ -14,25 +14,18 @@
<script src="@Url.Content("~/js/vue/vue-2.6.14.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/vue/element-ui-2.15.6.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/vue/vue-resource.js")" type="text/javascript"></script>
<script src="@Url.Content("~/js/component/js.prototype.ex.js")" type="text/javascript"></script>
<script type="text/x-template" id="elQueryTable">
@Html.PartialAsync("~/Areas/Component/Views/Table/Query.cshtml").Result
</script>
<script>
$(document).ready(function () {
new Vue({
el: '#app',
data: {
code: "test"
},
created() {
},
mounted() {
},
el: '#app'
})
})
</script>
}
<div id="app" v-cloak>
<el-query-table v-bind:code="code"></el-query-table>
<el-query-table code="dw_auto_check"></el-query-table>
</div>
.wrapper.wrapper-content.animated.fadeInRight {
.wrapper.wrapper-content.animated.fadeInRight,
.el-query-table .el-main .el-table .el-table__body-wrapper {
height: calc(100% - 40px);
}
......@@ -16,11 +17,6 @@
padding-left: 10px;
}
.el-query-table .el-main .el-table .el-table__body-wrapper {
height: 100%
}
.el-query-table .el-form-item {
margin-bottom: 0px;
margin-top: 5px;
......
......@@ -90,7 +90,7 @@
that.onSearch();
}
} else {
this.$message(result.Message || " 未知错误!");
this.$message((!result.data && "配置错误") || (result.Message || " 未知错误!"));
}
that.loading = false;
}, function (error) {
......@@ -108,13 +108,13 @@
that.setting.listFilterControl.forEach(function (l) {
if (l.value) {
var filter = { field: l.prop };
//数据
if (l.value.constructor === Array && l.value == 2) {
//日期区间
if (l.type == "daterange") {
filter.operator = "between";
filter.value = l.value.join(",");
}
//对象
else if (l.value.constructor === Object) {
else if (l.value.constructor === Object || l.value.constructor === Array) {
filter.operator = "in";
filter.value = l.value.join(",");
}
......@@ -176,33 +176,31 @@
//查询字段
onSearchColumn: function (isRefreshListOption) {
var that = this;
that.loading = true;
that.getQueryFilter();
that.$http({
method: 'post',
url: SysUrl + "/DataSourceQuery/GetListColumn?code=" + that.code,
data: that.query
}).then(function (resp) {
var result = resp.data;
if (resp.status === 200 && result.Result && result.Data) {
that.$http.post("/Component/Query/GetListColumn", that.filterParams, { emulateJSON: true }).then(function (response) {
var result = response.data;
if (response.status === 200 && result.result && result.data) {
if (isRefreshListOption) {
if (result.Data && result.Data.length) {
if (result.data && result.data.length) {
that.listColumn.forEach(function (l) {
var column = result.Data.find(function (l2) {
return l.Code == l2.Code;
var column = result.data.find(function (l2) {
return l.code == l2.code;
});
if (column) {
Vue.set(l, "ListOption", column.ListOption);
Vue.set(l, "listOption", column.listOption);
}
});
}
} else {
Vue.set(that, "listColumn", result.Data);
Vue.set(that.setting, "listColumn", result.data);
}
} else {
this.$message(result.Message || " 未知错误!");
this.$message(result.message || " 未知错误!");
}
}, function (error) {
this.$message(error);
this.$message(error.statusText || " 未知错误!");
that.loading = false;
});
},
//查询数据
......@@ -227,7 +225,7 @@
//查询
onSearch: function () {
var that = this;
if (!that.setting || that.setting.columnType != 5) {
if (!that.setting || that.setting.columnType != 3) {
this.onSearchColumn();
}
this.onSearchData();
......@@ -371,15 +369,6 @@
}
}
},
//绑定行KEY
onRowKey: function (obj) {
//多选绑定Key
var key = obj.ID
if (!key) {
key = JSON.stringify(obj);
}
return key;
},
//排序
onSortChange: function (column) {
var that = this;
......@@ -412,6 +401,10 @@
this.rows = selection
this.$emit("selection-change", selection)
},
//顺序号
onSequenceIndex: function (index) {
return (this.filterParams.currentPage - 1) * this.filterParams.pageSize + index + 1;
},
/** 自定义JS */
javaScript(js, scope) {
if (js) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment