DS7_HYRD
ddlucky 10 months ago
parent 31b4d49a09
commit 01e143c008

@ -831,6 +831,84 @@ namespace DSWeb.MvcShipping.Controllers
return new ContentResult { Content = jsonRespose };
}
}
public ContentResult FileUpload2()
{
var jsonRespose = JsonConvert.Serialize(new { success = false, message = "未上传文件" });
try
{
// 型号 提单号 箱号 批次号 件数 净重(吨) 毛重(吨) 包装 备注
var file = Request.Files["file"];//获取文件
if (file == null)//未上传文件
return new ContentResult { Content = jsonRespose };
//var path = Server.MapPath("../../UploadFiles/CtnTkDetail");//获取物理路径
//if (!Directory.Exists(path))
// Directory.CreateDirectory(path);
//var name = Path.GetFileName(file.FileName);
//var usercode = CookieConfig.GetCookie_UserCode(Request);
//string filepath = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
//if (System.IO.File.Exists(filepath))
// System.IO.File.Delete(filepath);
//file.SaveAs(filepath);
//DataSet ds = GetExcelDs(filepath);
string ext = Path.GetExtension(file.FileName).ToLower();
var strMsg = "";
DataTable dt = BasicDataRefDAL.ExcelToDatatable(file.InputStream, ext, out strMsg);
if (dt!=null)
{
//DataTable dt = ds.Tables[0];
//修改导入的列名为字段名
string[] arr =
{
"GOODSMODEL","BLNO","CNTRNO","PICIHAO","件数","净重","毛重", "KINDPKGS", "REMARK"
};
for (int i = 0; i < arr.Length; i++)
dt.Columns[i].ColumnName = arr[i];
//增加显示品名
dt.Columns.Add(new DataColumn() { ColumnName = "GOODSNAMEID" });
dt.Columns.Add(new DataColumn() { ColumnName = "GOODSNAMEDISPLAY" });
dt.Columns.Add(new DataColumn() { ColumnName = "GOODSNAME" });
dt.Columns.Add(new DataColumn() { ColumnName = "GID" });
dt.Columns.Add(new DataColumn() { ColumnName = "ZHONGLIANG2" });
foreach (DataRow item in dt.Rows)
{
item["GID"] = Guid.NewGuid().ToString();
item["ZHONGLIANG2"] = "0";
var model = BasicDataRefDAL.GetCodeGoodsList(string.Format("GOODCODE = '{0}' or GOODNAME like '%{0}%'", item["GOODSMODEL"]), "").FirstOrDefault();
if (model != null)
{
item["GOODSNAMEID"] = model.GID;
item["GOODSNAMEDISPLAY"] = model.CodeAndName;
item["GOODSNAME"] = model.GOODNAME;
}
}
var list = ToJson(dt);
jsonRespose = JsonConvert.Serialize(new
{
success = true,
data = list,
totalCount = dt.Rows.Count,
message = "导入成功"
});
}
return new ContentResult { Content = jsonRespose };
}
catch (Exception se)
{
jsonRespose = JsonConvert.Serialize(new
{
success = false,
message = se.Message
});
return new ContentResult { Content = jsonRespose };
}
}
/// <summary>
/// 获取DataSet
/// </summary>

@ -2753,7 +2753,7 @@ Ext.extend(Shipping.MsOpAirnEdit, Ext.Panel, {
}
this.tabSeaepanel.doLayout();
this.LoadPeriodStatus(this.opStatus);
this.storeCargo.load({ params: { condition: " C.BSNO='123456'" } });
}
else {
@ -4815,7 +4815,7 @@ Ext.extend(Shipping.MsOpAirnEdit, Ext.Panel, {
//this.storeCargo.load({ params: { condition: " C.BSNO='" + data.BSNO + "'" } });
this.storeCargo.load({ params: { condition: " C.BSNO='123456'" } });
},
@ -4869,7 +4869,7 @@ Ext.extend(Shipping.MsOpAirnEdit, Ext.Panel, {
}
this.tabSeaepanel.doLayout();
this.storeCargo.load({ params: { condition: " C.BSNO='123456'" } });
},

@ -1681,6 +1681,8 @@ Ext.extend(Shipping.MsOpSeaeFenEdit, Ext.Panel, {
}
}
this.tabSeaepanel.doLayout();
//this.storeCargo.load({ params: { condition: " C.BSNO='123456'" } });
},
scope: this
}, '-', {

@ -2546,7 +2546,7 @@ Ext.extend(Shipping.MsOpAirnEdit, Ext.Panel, {
}
}
this.tabSeaepanel.doLayout();
this.storeCargo.load({ params: { condition: " C.BSNO='123456'" } });
} else {
this.CopyNew();
@ -3390,7 +3390,7 @@ Ext.extend(Shipping.MsOpAirnEdit, Ext.Panel, {
field = basicForm.findField('ACCDATE');
field.setValue(mydatestr);
this.storeCargo.load({ params: { condition: " C.BSNO='123456'" } });
},
@ -3456,7 +3456,7 @@ Ext.extend(Shipping.MsOpAirnEdit, Ext.Panel, {
this.formEdit_2.getForm().reset();
this.storeCargo.load({ params: { condition: " C.BSNO='123456'" } });
}, //end save
//#endregion

@ -2016,10 +2016,144 @@ Ext.extend(Shipping.WMSNewINEdit, Ext.Panel, {
}
}, {
text: "导入数据2",
handler: function (button, event) {
if (Ext.get("importWin") == null) {
var upform = Ext.create('Ext.form.Panel', {
width: 500,
bodyPadding: '6 6 6 6',
id: "upform",
defaults: {
anchor: '100%',
allowBlank: false,
msgTarget: 'side',
labelWidth: 100
},
items: [{
xtype: 'filefield',
id: 'form-file',
emptyText: '请选择文件',
fieldLabel: '文件路径',
name: 'file',
buttonText: '浏览',
regex: /^.+\.(xls|xlsx)$/,
regexText: "只能选择xls|xlsx格式的文件",
buttonConfig: {
iconCls: 'upload-icon'
}
}],
buttons: [{
text: '开始导入',
handler: function () {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
method: 'post',
url: '/mvcshipping/WMSNew/FileUpload2',
waitMsg: '正在上传您的文件,请耐心等候...',
success: function (form, action) {
var data = _this.formEdit.getForm().getValues();
//导入的数据
var data1 = eval(action.result.data);
data1.forEach(function (item, index) {
_this.formEdit.getForm().findField('BLNO').setValue(item.BLNO);
var record = Ext.create('WMSINmb', {
CTNALL: CTNALL,
SEALNO: BLNO,
CLIENTNAME: data.CUSTOMERNAME,
AREANAME: data.AREANAME,
GOODSNAME: data.GOODSMODEL,
GOODSMODEL: data.GOODSMODEL,//型号
CHARGEUNIT: data.CHARGEUNIT,
BLNO: item.BLNO,
CNTRNO: item.CNTRNO,
GOODSRKSL: item.毛重,
GOODSSTOCK: item.毛重,
PICIHAO: item.批次号,
GOODSPACK: item.件数,
GOODSPACKACTUAL: item.件数,
GOODSRKSLACTUAL: item.件数,
GOODSPACKSTOCK: item.件数,
GOODSKGS: item.净重,
FREESTORAGEPERIOD: "0",
ISLOCK: "0",
ISDELETE: "0",
ARFEE: "0",
APFEE: "0",
//GOODSKGS: "0",
CORPID: COMPANYID,
GOODSTHICKNESS: "0",
GOODSWIDTH: "0",
GOODSLENGTH: "0",
ISCHANGE: "0",
MARKETVALUE: "0",
BANKVALUE: "0",
LINENUM: _this.getLinenum(),
CHIMA1: "0",
CHIMA2: "0",
ZHONGLIANG2: "0",
SHIJIZHONGLIANG: "0",
SHIJICHIMA: "0"
});
for (var o in item) {
if (item.hasOwnProperty(o)) {
record.data[o] = item[o];
}
}
_this.storeWMSIN.add(record);
});
Ext.getCmp("importWin").close();
Ext.Msg.alert("提示信息", "导入成功!");
},
failure: function (form, action) {
Ext.Msg.alert("提示信息", "导入失败,请重试!");
}
});
}
}
}, {
text: '重置',
handler: function () {
this.up('form').getForm().reset();
}
}]
});
var win = Ext.create('Ext.window.Window',
{
title: '导入文件',
layout: 'fit',
id: 'importWin',
draggable: true, //拖动
x: event.clientX,
y: event.clientY,
resizable: false,
items: {
xtype: 'panel',
border: true,
items: [upform]
}
});
win.show();
}
}
}, {
text: "下载模板",
handler: function (menu, event) {
window.open("/download/入库信息_模板.xlsx", "_blank");
}
}, {
text: "下载模板2",
handler: function (menu, event) {
window.open("/download/入库信息_模板2.xlsx", "_blank");
}
}],
scope: this
}, {

Loading…
Cancel
Save