Commit 1c4a7fe6 by jianshuqin

增加功能:离线导出

parent e2144134
...@@ -29,7 +29,7 @@ namespace Bailun.DC.Models.Component.DTO ...@@ -29,7 +29,7 @@ namespace Bailun.DC.Models.Component.DTO
public object Data { get; set; } public object Data { get; set; }
} }
public class ResultDto<T> : ResultDTO public class ResultDTO<T> : ResultDTO
{ {
/// <summary> /// <summary>
/// 结果集 /// 结果集
......
...@@ -47,6 +47,11 @@ namespace Bailun.DC.Models.Component.DTO ...@@ -47,6 +47,11 @@ namespace Bailun.DC.Models.Component.DTO
public bool? IsShowExportButton { get; set; } public bool? IsShowExportButton { get; set; }
/// <summary> /// <summary>
/// 是否显示离线导出按钮:(默认否)
/// </summary>
public bool? IsShowOfflineExportButton { get; set; }
/// <summary>
/// 是否显示导入按钮:(默认否) /// 是否显示导入按钮:(默认否)
/// </summary> /// </summary>
public bool? IsShowImportButton { get; set; } public bool? IsShowImportButton { get; set; }
......
using Bailun.DC.Models.Component.Enum;
using Dapper;
using System;
namespace Bailun.DC.Models.Component.Entity
{
/// <summary>
/// 离线下载组件
/// </summary>
public class dc_component_offline_download
{
/// <summary>
/// ID
/// </summary>
public int id { get; set; }
/// <summary>
/// 编码
/// </summary>
public string code { get; set; }
/// <summary>
/// 名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 后缀
/// </summary>
public string suffix { get; set; }
/// <summary>
/// 状态:0:未执行, 1:执行中, 2:完成, 3:失败
/// </summary>
public OfflineDownloadStatusEnum? status { get; set; }
/// <summary>
/// 消息
/// </summary>
public string message { get; set; }
/// <summary>
/// 下载地址
/// </summary>
public string url { get; set; }
/// <summary>
/// 是否删除: 1:是; 0:否
/// </summary>
[IgnoreUpdate]
public bool is_delete { get; set; }
/// <summary>
/// 创建人ID
/// </summary>
public int? gmt_create_userid { get; set; }
/// <summary>
/// 创建人名称
/// </summary>
public string gmt_create_username { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[IgnoreUpdate]
public DateTime gmt_create_time { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime gmt_modified_time { get; set; }
}
}
...@@ -65,6 +65,11 @@ namespace Bailun.DC.Models.Component.Entity ...@@ -65,6 +65,11 @@ namespace Bailun.DC.Models.Component.Entity
public bool is_show_export_button { get; set; } public bool is_show_export_button { get; set; }
/// <summary> /// <summary>
/// 是否显示离线导出按钮:(默认否)
/// </summary>
public bool is_show_offline_export_button { get; set; }
/// <summary>
/// 是否显示导入按钮:(默认否) /// 是否显示导入按钮:(默认否)
/// </summary> /// </summary>
public bool is_show_import_button { get; set; } public bool is_show_import_button { get; set; }
......
using System.ComponentModel;
namespace Bailun.DC.Models.Component.Enum
{
/// <summary>
/// 状态:0:未执行, 1:执行中, 2:完成, 3:失败
/// </summary>
public enum OfflineDownloadStatusEnum
{
/// <summary>
/// 未执行
/// </summary>
[Description("未执行")]
UnExecuted = 0,
/// <summary>
/// 执行中
/// </summary>
[Description("执行中")]
Executing = 1,
/// <summary>
/// 完成
/// </summary>
[Description("完成")]
Complete = 2,
/// <summary>
/// 失败
/// </summary>
[Description("失败")]
Fail = 3,
}
}
...@@ -51,6 +51,7 @@ namespace Bailun.DC.Services.Component ...@@ -51,6 +51,7 @@ namespace Bailun.DC.Services.Component
IsShowSearchButton = entity.is_show_search_button, IsShowSearchButton = entity.is_show_search_button,
IsShowResetButton = entity.is_show_reset_button, IsShowResetButton = entity.is_show_reset_button,
IsShowExportButton = entity.is_show_export_button, IsShowExportButton = entity.is_show_export_button,
IsShowOfflineExportButton = entity.is_show_offline_export_button,
IsShowImportButton = entity.is_show_import_button, IsShowImportButton = entity.is_show_import_button,
IsShowSequenceColumn = entity.is_show_sequence_column, IsShowSequenceColumn = entity.is_show_sequence_column,
OperateControlsPosition = entity.operate_controls_position, OperateControlsPosition = entity.operate_controls_position,
...@@ -472,14 +473,17 @@ namespace Bailun.DC.Services.Component ...@@ -472,14 +473,17 @@ namespace Bailun.DC.Services.Component
return pageList; return pageList;
} }
public (string, byte[]) Export(QueryFilterDTO queryFilter) public (string, byte[]) Export(QueryFilterDTO queryFilter, TableDTO entity = null)
{ {
byte[] b = default(byte[]); byte[] b = default(byte[]);
string name = default(string); string name = default(string);
int dataCount = default(int); int dataCount = default(int);
if (queryFilter != null) if (queryFilter != null)
{ {
TableDTO entity = this.Get(queryFilter.Code); if (entity == null)
{
entity = this.Get(queryFilter.Code);
}
if (entity != null) if (entity != null)
{ {
name = string.Join(string.Empty, entity.ListCrumb); name = string.Join(string.Empty, entity.ListCrumb);
...@@ -550,6 +554,7 @@ namespace Bailun.DC.Services.Component ...@@ -550,6 +554,7 @@ namespace Bailun.DC.Services.Component
is_show_search_button = dto.IsShowSearchButton ?? false, is_show_search_button = dto.IsShowSearchButton ?? false,
is_show_reset_button = dto.IsShowResetButton ?? false, is_show_reset_button = dto.IsShowResetButton ?? false,
is_show_export_button = dto.IsShowExportButton ?? false, is_show_export_button = dto.IsShowExportButton ?? false,
is_show_offline_export_button = dto.IsShowOfflineExportButton ?? false,
is_show_import_button = dto.IsShowImportButton ?? false, is_show_import_button = dto.IsShowImportButton ?? false,
is_show_sequence_column = dto.IsShowSequenceColumn ?? false, is_show_sequence_column = dto.IsShowSequenceColumn ?? false,
is_show_column_search = dto.IsShowColumnSearch ?? false, is_show_column_search = dto.IsShowColumnSearch ?? false,
......
using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Services.Component;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Text;
namespace Bailun.DC.Web.Areas.Component.Controllers
{
[Area("Component")]
public class OfflineDownloadController : Base.BaseController
{
[HttpPost]
public JsonResult Export(QueryFilterDTO queryFilter)
{
ResultDTO result = default(ResultDTO);
try
{
if (Request.ContentType.Contains("application/json"))
{
using (Stream stream = Request.Body)
{
byte[] buffer = new byte[Request.ContentLength.Value];
stream.Read(buffer, 0, buffer.Length);
string content = Encoding.UTF8.GetString(buffer);
queryFilter = JsonConvert.DeserializeObject<QueryFilterDTO>(content);
}
}
result = new OfflineDownloadService().Export(queryFilter, Request.Cookies["BailunToken"]);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
[HttpPost]
public JsonResult Delete(int[] id)
{
ResultDTO result = default(ResultDTO);
try
{
result = new OfflineDownloadService().Save(id, true);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
}
}
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<el-form-control v-if="filter.isShowSearchButton" v-bind:item="{type: 'button',name:'查询',buttonType:'primary',icon:'el-icon-search'}" v-on:click="onSearch"></el-form-control> <el-form-control v-if="filter.isShowSearchButton" v-bind:item="{type: 'button',name:'查询',buttonType:'primary',icon:'el-icon-search'}" v-on:click="onSearch"></el-form-control>
<el-form-control v-if="filter.isShowResetButton" v-bind:item="{type: 'button',name:'重置',icon:'el-icon-refresh-right'}" v-on:click="onReset"></el-form-control> <el-form-control v-if="filter.isShowResetButton" v-bind:item="{type: 'button',name:'重置',icon:'el-icon-refresh-right'}" v-on:click="onReset"></el-form-control>
<el-form-control v-if="filter.isShowExportButton" v-bind:item="{type: 'button',name:'导出',buttonType:'success',icon:'el-icon-download'}" v-on:click="onExport"></el-form-control> <el-form-control v-if="filter.isShowExportButton" v-bind:item="{type: 'button',name:'导出',buttonType:'success',icon:'el-icon-download'}" v-on:click="onExport"></el-form-control>
<el-form-control v-if="filter.isShowOfflineExportButton" v-bind:item="{type: 'button',name:'离线导出',buttonType:'success',icon:'el-icon-download'}" v-on:click="onOfflineExport"></el-form-control>
<el-form-control v-if="filter.isShowImportButton" v-show="!filter.file || !filter.file.name" ref="file" v-bind:item="{type: 'file',name:'导入',action:filter.importApi,buttonType:'warning',icon:'el-icon-upload2',accept:'.xls,.xlsx'}" v-model="filter.file" v-on:import="onImport"></el-form-control> <el-form-control v-if="filter.isShowImportButton" v-show="!filter.file || !filter.file.name" ref="file" v-bind:item="{type: 'file',name:'导入',action:filter.importApi,buttonType:'warning',icon:'el-icon-upload2',accept:'.xls,.xlsx'}" v-model="filter.file" v-on:import="onImport"></el-form-control>
<el-form-control v-if="filter.isShowImportButton && filter.file && filter.file.name" class="el-upload-input" v-bind:item="{type: 'input',readonly:true}" v-model="filter.file.name"></el-form-control> <el-form-control v-if="filter.isShowImportButton && filter.file && filter.file.name" class="el-upload-input" v-bind:item="{type: 'input',readonly:true}" v-model="filter.file.name"></el-form-control>
<el-form-control v-if="filter.isShowImportButton && filter.file && filter.file.name" v-bind:item="{type: 'button',name:'上传',buttonType:'warning',icon:'el-icon-upload2'}" v-on:click="$refs.file.upLoad"></el-form-control> <el-form-control v-if="filter.isShowImportButton && filter.file && filter.file.name" v-bind:item="{type: 'button',name:'上传',buttonType:'warning',icon:'el-icon-upload2'}" v-on:click="$refs.file.upLoad"></el-form-control>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
v-on:search="onSearch" v-on:search="onSearch"
v-on:reset="onReset" v-on:reset="onReset"
v-on:export="onExport" v-on:export="onExport"
v-on:offline-export="onOfflineExport"
v-on:click="onClick"></el-form-filter> v-on:click="onClick"></el-form-filter>
</el-header> </el-header>
<el-main v-loading="$root.loading"> <el-main v-loading="$root.loading">
......
...@@ -117,6 +117,10 @@ ...@@ -117,6 +117,10 @@
onExport: function () { onExport: function () {
this.$emit("export", this.getFilter()); this.$emit("export", this.getFilter());
}, },
//离线导出
onOfflineExport: function () {
this.$emit("offline-export", this.getFilter());
},
//导入 //导入
onImport: function (result, file, message) { onImport: function (result, file, message) {
if (result) { if (result) {
......
...@@ -181,6 +181,28 @@ ...@@ -181,6 +181,28 @@
} }
} }
}, },
//离线导出
onOfflineExport: function (filterParams, cb) {
var that = this;
//异步请求
if (that.$refs.formFilter.validate()) {
that.$http.post("/Component/OfflineDownload/Export", ((filterParams.constructor === Object ? filterParams : null) || that.filterParams), { emulateJSON: true }).then(function (response) {
var result = response.data;
if (response.status === 200 && result.result) {
that.$message({ message: '正在导出,请稍后在离线下载页面下载文件!', type: 'success' });
} else {
this.$message(result.message || " 未知错误!");
}
}, function (error) {
this.$message(error.statusText || " 未知错误!");
});
} else {
var message = that.$refs.formFilter.getValidateMessage();
if (message && message.length) {
that.$message({ dangerouslyUseHTMLString: true, message: message.join("<br/>") });
}
}
},
//单击事件 //单击事件
onClick: function (fn) { onClick: function (fn) {
var that = this; var that = this;
......
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