产品定义原始完工
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using CSRedis;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
@@ -130,7 +131,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
|
||||
/// <param name="productName"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("exportProduct")]
|
||||
public IActionResult ExportProduct(DateTime starttime, DateTime endtime, string productCode="", string productName = "")
|
||||
public IActionResult ExportProduct(DateTime starttime, DateTime endtime, string productCode = "", string productName = "")
|
||||
{
|
||||
List<MdProductDefine> units = null;
|
||||
|
||||
@@ -141,6 +142,46 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="updateSupport">0:只新增 1:新增且更新</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("importExcel")]
|
||||
public IActionResult ImportExcel()
|
||||
{
|
||||
|
||||
|
||||
IFormFileCollection files = Request.Form.Files;
|
||||
foreach (IFormFile file in files)
|
||||
{
|
||||
string directory = Path.Combine(App.WebHostEnvironment.ContentRootPath, "Images");
|
||||
string fileExtension = Path.GetExtension(file.FileName);
|
||||
string fileName = Guid.NewGuid().ToString() + fileExtension;
|
||||
string filePath = Path.Combine(directory, fileName);// 生成文件路径
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
// 写入文件
|
||||
using (var stream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
file.CopyTo(stream);
|
||||
stream.Flush();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IActionResult importTemplate()
|
||||
{
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -104,18 +104,17 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
|
||||
public IActionResult exportUnit([FromQuery] SearchOptionDTO searchOption)
|
||||
{
|
||||
List<MdUnit> units = null;
|
||||
if(searchOption != null)
|
||||
if (searchOption != null)
|
||||
{
|
||||
units= unitService.GetList(searchOption);
|
||||
units = unitService.GetList(searchOption);
|
||||
}
|
||||
|
||||
var result = ExportExcelMini(units, "unit", "单位列表");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
BIN
ZR.Admin.WebApi/Images/0c1af12b-35be-44fe-8dd6-8c425ce93552.xls
Normal file
BIN
ZR.Admin.WebApi/Images/0c1af12b-35be-44fe-8dd6-8c425ce93552.xls
Normal file
Binary file not shown.
BIN
ZR.Admin.WebApi/Images/b39d12da-04ca-4d1b-93e2-9bec69e6f36c.xlsx
Normal file
BIN
ZR.Admin.WebApi/Images/b39d12da-04ca-4d1b-93e2-9bec69e6f36c.xlsx
Normal file
Binary file not shown.
@@ -26,6 +26,9 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExcel_export">导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-download" size="mini" @click="handleExcel_import">导入</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
@@ -102,6 +105,35 @@
|
||||
<el-button @click="exportopen = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 产品上传对话框 -->
|
||||
<el-dialog title="上传产品" :visible.sync="upload.open" width="400px" append-to-body>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:limit="1"
|
||||
accept=".xlsx, .xls"
|
||||
:headers="upload.headers"
|
||||
:action="upload.url"
|
||||
:disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess"
|
||||
:auto-upload="false"
|
||||
drag
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
|
||||
<div class="el-upload__tip text-center" slot="tip">
|
||||
<div class="el-upload__tip" slot="tip"><el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的设备数据</div>
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
</el-upload>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||
<el-button @click="upload.open = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -115,6 +147,7 @@ import {
|
||||
delproduct,
|
||||
exportProduct,
|
||||
} from '@/api/basisManagement/productEfinition.js'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { debounce } from '@/utils'
|
||||
|
||||
export default {
|
||||
@@ -198,6 +231,21 @@ export default {
|
||||
},
|
||||
],
|
||||
},
|
||||
//上传配置
|
||||
upload: {
|
||||
// 是否显示弹出层(用户导入)
|
||||
open: false,
|
||||
// 弹出层标题(用户导入)
|
||||
title: '上传',
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 是否更新已经存在的用户数据
|
||||
updateSupport: 0,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + '/mes/md/product/importExcel',
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -221,8 +269,8 @@ export default {
|
||||
this.open = true
|
||||
},
|
||||
handleUpdate(row) {
|
||||
debugger
|
||||
this.dmlform.productUnitName = '22222222222222222'
|
||||
|
||||
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = '修改'
|
||||
@@ -379,6 +427,35 @@ export default {
|
||||
handleProcessrouteNameSelect(row) {
|
||||
this.dmlform.Processroute = row.measureId
|
||||
},
|
||||
|
||||
//导入excel
|
||||
handleExcel_import() {
|
||||
this.upload.open = true
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
this.upload.isUploading = true
|
||||
},
|
||||
// 文件上传成功处理
|
||||
handleFileSuccess(response, file, fileList) {
|
||||
this.upload.open = false
|
||||
this.upload.isUploading = false
|
||||
this.$refs.upload.clearFiles()
|
||||
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', {
|
||||
dangerouslyUseHTMLString: true,
|
||||
})
|
||||
this.getList()
|
||||
},
|
||||
|
||||
// 提交上传文件
|
||||
submitFileForm() {
|
||||
this.$refs.upload.submit()
|
||||
},
|
||||
|
||||
/** 下载模板操作 */
|
||||
importTemplate() {
|
||||
this.download('mes/dv/product/importTemplate', {}, `md_item_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 搜索部分 -->
|
||||
<div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "workshop"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
||||
Reference in New Issue
Block a user