Commit 45d7bb46 by jianshuqin

优化:组件功能

parent bfaf066f
...@@ -57,6 +57,11 @@ namespace Bailun.DC.Models.Component.DTO ...@@ -57,6 +57,11 @@ namespace Bailun.DC.Models.Component.DTO
public bool? IsShowSequenceColumn { get; set; } public bool? IsShowSequenceColumn { get; set; }
/// <summary> /// <summary>
/// 导入接口
/// </summary>
public string ImportApi { get; set; }
/// <summary>
/// 操作控件位置:NULL/1:换行,2:同行 /// 操作控件位置:NULL/1:换行,2:同行
/// </summary> /// </summary>
public int? OperateControlsPosition { get; set; } public int? OperateControlsPosition { get; set; }
......
...@@ -70,6 +70,11 @@ namespace Bailun.DC.Models.Component.Entity ...@@ -70,6 +70,11 @@ namespace Bailun.DC.Models.Component.Entity
public bool is_show_import_button { get; set; } public bool is_show_import_button { get; set; }
/// <summary> /// <summary>
/// 导入接口
/// </summary>
public string import_api { get; set; }
/// <summary>
/// 操作控件 /// 操作控件
/// </summary> /// </summary>
public string operate_controls { get; set; } public string operate_controls { get; set; }
......
...@@ -53,6 +53,7 @@ namespace Bailun.DC.Services.Component ...@@ -53,6 +53,7 @@ namespace Bailun.DC.Services.Component
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,
ImportApi = entity.import_api,
ColumnType = entity.column_type, ColumnType = entity.column_type,
ColumnValue = entity.column_value, ColumnValue = entity.column_value,
DataType = entity.data_type, DataType = entity.data_type,
...@@ -539,6 +540,7 @@ namespace Bailun.DC.Services.Component ...@@ -539,6 +540,7 @@ namespace Bailun.DC.Services.Component
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,
import_api = dto.ImportApi,
column_type = dto.ColumnType, column_type = dto.ColumnType,
column_value = dto.ColumnType == ColumnTypeEnum.Config && dto.ListColumn?.Count() > 0 ? JsonConvert.SerializeObject(dto.ListColumn) : dto.ColumnValue, column_value = dto.ColumnType == ColumnTypeEnum.Config && dto.ListColumn?.Count() > 0 ? JsonConvert.SerializeObject(dto.ListColumn) : dto.ColumnValue,
data_type = dto.DataType, data_type = dto.DataType,
......
...@@ -8,6 +8,7 @@ using System.Linq; ...@@ -8,6 +8,7 @@ using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using Microsoft.AspNetCore.Http;
namespace Bailun.DC.Web.Areas.Component.Controllers namespace Bailun.DC.Web.Areas.Component.Controllers
{ {
...@@ -180,6 +181,22 @@ namespace Bailun.DC.Web.Areas.Component.Controllers ...@@ -180,6 +181,22 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
return Json(result); return Json(result);
} }
[HttpPost]
public JsonResult Import(IFormFile file)
{
ResultDTO result = default(ResultDTO);
try
{
result = new ResultDTO { Result = true };
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
private class IgnoreJsonAttributesResolver : DefaultContractResolver private class IgnoreJsonAttributesResolver : DefaultContractResolver
{ {
private string Id { get; set; } private string Id { get; set; }
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
v-bind:size="item.size || 'small'" v-bind:size="item.size || 'small'"
v-bind:maxlength="item.maxlength" v-bind:maxlength="item.maxlength"
v-bind:type="item.type == 'textarea' ? 'textarea' : 'text'" v-bind:type="item.type == 'textarea' ? 'textarea' : 'text'"
v-bind:show-word-limit="item.maxlength > 0"> v-bind:show-word-limit="item.maxlength > 0"
v-bind:readonly="item.readonly == true ? 'readonly' : false">
</el-input> </el-input>
<el-input-number v-else-if="item.type == 'number'" <el-input-number v-else-if="item.type == 'number'"
v-model="item_value" v-model="item_value"
...@@ -119,14 +120,24 @@ ...@@ -119,14 +120,24 @@
v-on:click="$emit('click')"> v-on:click="$emit('click')">
{{item.name}} {{item.name}}
</el-link> </el-link>
<el-upload-form ref="upload" <el-upload ref="upload" class="el-upload"
v-else-if="item.type == 'file'" v-else-if="item.type == 'file'"
v-bind:multiple="item.multiple" v-bind:action="item.action"
v-bind:action="item.api" v-bind:data="item.data"
v-bind:accept="item.accept" v-bind:auto-upload="false"
v-on:upload-success="(response,file) => $emit('upload-success',response,file)" v-bind:show-file-list="false"
v-on:change="javaScript.call(this,item.onchange,$event)"> v-bind:multiple="item.multiple"
</el-upload-form> v-bind:accept="item.accept"
v-bind:on-change="onFileChange"
v-bind:on-success="onSuccess"
v-bind:on-error="onError">
<el-button v-bind:icon="item.icon"
v-bind:size="item.size || 'small'"
v-bind:type="item.buttonType"
v-bind:disabled="disabled != null ? disabled :(item.disabled == true || javaScript.call(this,item.disabled))">
{{ item.name || '浏览' }}
</el-button>
</el-upload>
<el-breadcrumb v-else-if="item.type == 'breadcrumb'" <el-breadcrumb v-else-if="item.type == 'breadcrumb'"
v-bind:size="item.size || 'small'" v-bind:size="item.size || 'small'"
separator-class="el-icon-arrow-right"> separator-class="el-icon-arrow-right">
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
<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.isShowImportButton" v-bind:item="{type: 'button',name:'导入',icon:'el-icon-upload2'}" v-on:click="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" 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-refresh-right'}" v-on:click="$refs.file.clearFiles"></el-form-control>
<template v-if="filter.operateControlsPosition == 2"> <template v-if="filter.operateControlsPosition == 2">
<el-form-control v-for="(item,index) in filter.listOperateControl" v-bind:item="item" v-bind:key="index" v-on:click="onClick(item.click)"></el-form-control> <el-form-control v-for="(item,index) in filter.listOperateControl" v-bind:item="item" v-bind:key="index" v-on:click="onClick(item.click)"></el-form-control>
</template> </template>
......
...@@ -81,3 +81,11 @@ ...@@ -81,3 +81,11 @@
.el-form-control .el-textarea.el-input--small span { .el-form-control .el-textarea.el-input--small span {
height: 25px; height: 25px;
} }
.el-form-control .div-el-upload {
display: inline;
}
.el-form-control .el-upload input[type=file] {
display: none;
}
\ No newline at end of file
...@@ -54,3 +54,7 @@ ...@@ -54,3 +54,7 @@
.el-form-filter .el-select__caret.el-input__icon.el-icon-circle-close { .el-form-filter .el-select__caret.el-input__icon.el-icon-circle-close {
height: 90%; height: 90%;
} }
.el-form-filter .el-upload-input .el-input {
width: auto;
}
\ No newline at end of file
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
//表单标题 //表单标题
formTitle: null, formTitle: null,
//表单编码 //表单编码
formCode: null, formCode: null
} }
}, },
created() { created() {
...@@ -209,7 +209,50 @@ ...@@ -209,7 +209,50 @@
var that = this; var that = this;
Vue.set(that, 'item_value', []); Vue.set(that, 'item_value', []);
that.item_value.push(value); that.item_value.push(value);
} },
//上传文件
upLoad() {
this.$refs.upload.submit();
},
//清除文件
clearFiles() {
this.$refs.upload.clearFiles()
this.$set(this, "item_value", {})
},
//添加文件事件
onFileChange(file, listFile) {
if (file.status == "ready") {
var that = this
if (this.item.accept.includes(file.name.substr(file.name.lastIndexOf(".")))) {
if (listFile.length > 1) {
listFile.splice(0, 1)
}
that.$set(that, "item_value", file)
that.$emit("change", file)
} else {
listFile.splice(listFile.length - 1, 1)
that.$message.error('上传文件只能是' + that.item.accept + '格式!')
}
}
},
//文件上传成功
onSuccess(response, file, listFile) {
var that = this;
if (response.code = 200) {
listFile.splice(listFile.length - 1, 1)
that.$emit("import", true, file)
} else {
file.status = "ready"
that.loading = false
that.$emit("import", false, file, response.message || "上传文件失败!")
}
},
//文件上传失败
onError(err, file, listFile) {
file.status = "ready"
this.loading = false
this.$emit("import", false, file, err)
},
}, },
template: '#elFormControl' template: '#elFormControl'
}); });
\ No newline at end of file
...@@ -118,8 +118,13 @@ ...@@ -118,8 +118,13 @@
this.$emit("export", this.getFilter()); this.$emit("export", this.getFilter());
}, },
//导入 //导入
onImport: function () { onImport: function (result, file, message) {
this.$emit("import"); if (result) {
this.$message("导入成功!")
this.$refs.file.clearFiles();
} else {
this.$message.error(message)
}
}, },
//单击事件 //单击事件
onClick: function (fn) { onClick: function (fn) {
......
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
} }
}, },
//导入 //导入
onImport: function () { onImport: function (file) {
debugger; debugger;
}, },
//单击事件 //单击事件
......
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