@using ShippingRen.CommonV2.CloudStorage;
@using ShippingRen.Api.ServiceModel.PublicDataEntity.Lookup;
@using ShippingRen.WebApi.ServiceModel.SRDataEntity.Order;
@using Newtonsoft.Json;
@using ShippingRen;
@model ShippingRen.Api.ServiceModel.PublicDataEntity.Supplier.SRWarehouseDTO
@{
ViewBag.Title = "添加仓库";
Layout = "~/Views/Shared/_LayoutNew.cshtml";
ViewBag.PageTitle = "添加仓库";
ViewBag.SubTitle = "添加仓库";
var lisSRSupplier = ViewBag.lisSRSupplier as List<SRSupplierDTO>;
var pList = ViewBag.ProvinceList as List<ProvinceInfoDTO>;
var province = pList.Find(p => p.ProvinceID == Model.ProvinceID);
if (province == null)
{
province = new ProvinceInfoDTO() { ProvinceName = "请选择" };
}
string display = "";
string tag = ViewBag.Tag.ToString();
var pid = Model.ProvinceID != null ? Model.ProvinceID : -1;
var cityid = Model.CityID != null ? Model.CityID : -1;
var cid = Model.CountyID != null ? Model.CountyID : -1;
var fromtermId = Model.RelatedTerminalID ?? 0;
var listDock=JsonConvert.SerializeObject(Model.SRWarehouseDockRSList);
var fileAliUrl=Url.AliContent(Model.MapURL, BucketLevel.PrivateBucket);
var fileTrueName =string.IsNullOrWhiteSpace(Model.MapURLFileName)?"图片":Model.MapURLFileName;
var fileTrueUrl =Model.MapURL;
}
@using ShippingRen.CommonV2.CloudStorage;
@section headernav{
<li><a href="@Url.Action("SRWarehousesList", "Provider")">仓库管理</a></li>
<li class="active">添加仓库</li>
}
@section styles{
<link href="/Content/global.css" rel="stylesheet" />
<link href="/Content/page.css" rel="stylesheet" />
<style>
.radio, .checkbox {
display: inline;
}
.form-group input {
display: inline;
width: 240px;
}
.form-group select {
width: 140px;
height: 26px;
line-height: 26px;
}
input[type='radio'], input[type='checkbox'] {
width: 20px;
}
.error {
color: red;
}
.tbmain {
border: 1px solid gray;
border-collapse: collapse;
width: 100%;
}
.tbmain tr td, .tbmain tr th {
border: 1px solid gray;
text-align: center;
}
.btnSearch {
background-color: #e08e0b;
border: 1px solid transparent;
margin-left: 10px;
padding: 1px 5px;
font-size: 14px;
line-height: 1.5;
border-radius: 3px;
color: #fff;
display: inline-block;
}
.pagination {
font-size: 80%;
}
.tbcharge input {
width: 100px;
}
.tbcharge tr {
line-height: 20px;
}
.tbcharge tr td {
margin: 10px;
padding: 4px 2px;
}
.iframeSelectChecked {
width: 720px;
padding-left: 20px;
margin-top: 15px;
}
.iframeSelectChecked .textTit {
float: left;
width: 100%;
height: 20px;
line-height: 20px;
font-family: Microsoft YaHei;
font-size: 14px;
color: #666;
margin-top: 10px;
}
.selMemsShow {
width: 720px;
height: 69px;
float: left;
margin-top: 10px;
overflow-y: auto;
position: relative;
background-color: #fff;
}
.selMemsShow ul {
width: 700px;
float: left;
font-family: Microsoft YaHei;
font-size: 14px;
color: #666;
padding-left: 0;
}
.selMemsShow li {
float: left;
height: 20px;
line-height: 20px;
padding-right: 5px;
margin: 0 15px 3px 0;
display: inline;
white-space: nowrap;
position: relative;
}
.selMemsShow li .name {
padding-right: 15px;
white-space: nowrap;
}
.selMemsShow li .close {
width: 16px;
height: 16px;
line-height: 16px;
text-align: center;
font-size: 14px;
position: absolute;
right: 2px;
top: 2px;
}
.PaddleftSetClass {
padding-left: 20px;
}
.TextAlignClass {
text-align: right;
}
body .customsFormOrd ul li div.errTip {
border: 1px solid red;
}
.errTip {
border: 1px solid red;
}
</style>
}
<section class="content">
<input type="hidden" value="@listDock" id="listDock"/>
<div class="row">
<div class="col-xs-12">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">
添加仓库
</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-tooltip="tooltip" title="返回">
<i class="fa fa-minus"></i>
</button>
</div>
</div>
<form class="form-horizontal" id="fmWarehouse">
<input type="hidden" id="hidTypeVal"/>
<input type="hidden" name="SRWarehouseID" value="@Model.SRWarehouseID" />
<div class="box-body">
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceDate"><em style="color: red;">*</em>仓库名称:</label>
<div class="col-sm-10">
<input id="WarehouseName" value="@Model.WarehouseName" name="WarehouseName" type="text" placeholder="仓库名称" class="form-control" style="width: 200px;">
<span style="color:red;"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceNum"><em style="color: red;">*</em>联系人:</label>
<div class="col-sm-10">
<input id="Contact" class="form-control" value="@Model.Contact" name="Contact" style="width: 200px;" type="text" placeholder="联系人" />
<span style="color:red;"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="TargetBPId"><em style="color: red;">*</em>联系电话:</label>
<div class="col-sm-10">
<input type="text" placeholder="联系电话" id="Cellphone" name="Cellphone" value="@Model.Cellphone" class="form-control" style="width:200px;">
<span style="color:red;"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="TargetBPId"><em style="color: red;">*</em>Email:</label>
<div class="col-sm-10">
<input type="text" placeholder="Email" id="Email" name="Email" value="@Model.Email" class="form-control" style="width:200px;">
<span style="color:red;"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceTitle"><em style="color: red;">*</em>所属仓库供应商:</label>
<div class="col-sm-10">
<select id="SRSupplierID" style="width:200px;height:32px;" class="form-control" name="SRSupplierID">
<option value="">
请选择
</option>
@if (lisSRSupplier != null && lisSRSupplier.Count > 0)
{
foreach (var perSRS in lisSRSupplier)
{
if (perSRS.SRSupplierID==Model.SRSupplierID)
{
<option selected="selected" value="@perSRS.SRSupplierID">
@perSRS.SRSupplierName
</option>
}
else
{
<option value="@perSRS.SRSupplierID">
@perSRS.SRSupplierName
</option>
}
}
}
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceTitle"><em style="color: red;">*</em>所属港口:</label>
<div class="col-sm-10" id="divTerm">
<select class="form-control" style="width:200px;height:32px;" id="RelatedTerminalID" name="RelatedTerminalID">
@if (fromtermId != 0)
{
<option value="@(Model.RelatedTerminalID != null && Model.RelatedTerminalID!=0?Model.RelatedTerminalID:0)">@(string.IsNullOrWhiteSpace(Model.RelatedTerminalName) ? "请选择" : Model.RelatedTerminalName)</option>
}
else
{
<option value="">请选择</option>
}
</select>
</div>
</div>
<div class="form-group form-inline">
<label class="col-sm-2 control-label" for="InvoiceTitle"><em style="color: red;">*</em>覆盖码头:</label>
<div class="col-sm-10" id="divTermDock">
</div>
</div>
<div class="form-group form-inline">
<label class="col-sm-2 control-label" for="InvoiceTitle"><em style="color: red;">*</em>仓库地址:</label>
<div class="col-sm-10">
<select class="form-control" style="width:200px;height:32px;" id="ProvinceID" name="ProvinceID">
@if (pid != -1)
{
<option value="@(Model.ProvinceID != null && Model.ProvinceID!=0?Model.ProvinceID:-1)">@(string.IsNullOrWhiteSpace(Model.ProvinceName) ? "请选择" : Model.ProvinceName)</option>
}
else
{
<option value="">请选择</option>
}
@{
if (pList != null && pList.Any())
{
foreach (var p in pList)
{
if (p.ProvinceID==Model.ProvinceID)
{
<option selected="selected" value="@p.ProvinceID">
@p.ProvinceName
</option>
}
else
{
<option value="@p.ProvinceID">
@p.ProvinceName
</option>
}
}
}
}
</select>
<select class="form-control" style="width:200px;height:32px;" id="CityID" name="CityID">
@if (cityid != -1)
{
<option value="@(Model.CityID != null && Model.CityID!=0?Model.CityID:-1)">@(string.IsNullOrWhiteSpace(Model.CityName) ? "请选择" : Model.CityName)</option>
}
else
{
<option value="">请选择</option>
}
</select>
<select class="form-control" style="width:200px;height:32px;" id="CountyID" name="CountyID">
@if (cid != -1)
{
<option value="@(Model.CountyID != null && Model.CountyID!=0?Model.CountyID:-1)">@(string.IsNullOrWhiteSpace(Model.CountyName) ? "请选择" : Model.CountyName)</option>
}
else
{
<option value="">请选择</option>
}
</select>
<input class="form-control" style="width:200px;" type="text" id="Address" name="Address" value="@Model.Address" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceTitle"><em style="color: red;">*</em>仓库地图:</label>
<div class="col-sm-10" id="divMap">
<ul class="orderListCont clearfix" style="border-bottom:none;border-right:none;border-left:none;" id="fileList" data-bind="foreach:files,attr:{name:filesDiffLength}">
<li class="list" style="border-bottom:none;display: none;" data-bind="style:{display:OriginalName().length > 0 ? '' : 'none'}">
<div class="cell adminLoading" data-bind="style:{display:hasLoaded() == false ? '' : 'none'}" style="width: 200px; padding: 0"><span>正在上传...</span></div>
<div class="cell name" style="width: 200px;" data-bind="style:{display:hasLoaded() == true ? '' : 'none'}">
<a class="actLink actView" href="javascript:void(0)" data-bind="click:$root.view, style:{display:isImg() == true ? '' : 'none'},text:OriginalName"></a>
</div>
</li>
</ul>
<div class="listAddFile">
<a class="listAddSome" id="" href="javascript:void(0)">
<em></em>
<span>选择文件</span>
</a>
<div class="layer flash_area">
<span id="upload_div"></span>
<span id="spanButtonPlaceHolder"></span>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceTitle"><em style="color: red;">*</em>进仓联系人:</label>
<div class="col-sm-10">
<input id="WHContact" value="@Model.WHContact" class="form-control" name="WHContact" style="width: 200px;" type="text" placeholder="进仓联系人" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceTitle"><em style="color: red;">*</em>进仓联系电话:</label>
<div class="col-sm-10">
<input id="WHTellphone" value="@Model.WHTellphone" class="form-control" name="WHTellphone" style="width: 200px;" type="text" placeholder="进仓联系电话" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceTitle">总机:</label>
<div class="col-sm-10">
<input id="WHMainTellphone" value="@Model.WHMainTellphone" class="form-control" name="WHMainTellphone" style="width: 200px;" type="text" placeholder="总机" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="InvoiceTitle">传真:</label>
<div class="col-sm-10">
<input id="WHFax" value="@Model.WHFax" class="form-control" name="WHFax" style="width: 200px;" type="text" placeholder="传真" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="Comments">备注:</label>
<div class="col-sm-10">
<textarea id="Comments" class="form-control" name="Comments" style="width: 200px;" type="text" placeholder="备注">@Model.Comments</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="Comments"></label>
<div class="col-sm-10">
<div class="btnCoverModel">
<button type="button" class="btn btn-primary" id="btnSubmitWarehouse">保存</button>
<div class="btnCover" style=" width:138px;height:50px;">
<div class="shadow"></div>
<div class="loading"></div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
@section scripts{
<script src="@Url.Content("/Scripts/jquery-ui-1.9.0.custom.min.js")"></script>
<script src="@Url.Content("/Scripts/knockout-3.2.0.js")"></script>
<script src="@Url.Content("/Scripts/knockout.mapping-latest.js")"></script>
<script src="@Url.Content("/Content/uploader/jquery.fine-uploader.min.js")"></script>
<script src="@Url.Content("/Scripts/jquery.validate.js")"></script>
<script type="text/javascript">
var exceptProvinceId = new Array('1442', '1443', '1444');
var editmode = "@tag";
var Warehouse = {
};
Warehouse.Data = {
srsupplierId:"@Model.SRSupplierID",
fromTerminalId: "@Model.RelatedTerminalID",
srWarehouseID: "@Model.SRWarehouseID",
provinceId: "@province.ProvinceID",
cityId: "@Model.CityID",
countryId: '@Model.CountyID',
tag: '@tag'
}
Warehouse.BindEvent = function () {
$("#btnSubmitWarehouse").on("click", Warehouse.Func.saveAndNext);
$("#ProvinceID").on('change', Warehouse.Func.provienceChange);
$(document).on('change', '#CityID', Warehouse.Func.cityChange);
$(document).on('change', '#CountyID', Warehouse.Func.countyChange);
$(document).on('change', '#SRSupplierID', Warehouse.Func.TermChange);
$(document).on('change', '#RelatedTerminalID', Warehouse.Func.dockChange);
$("input:checkbox[name=DockIds]").on('change', Warehouse.Func.dockCheckboxChange);
if (Warehouse.Data.srsupplierId!=''&&Warehouse.Data.srsupplierId!='0') {
Warehouse.Func.bindTerminalList(Warehouse.Data.srsupplierId,1);
}
/*绑定起运港码头列表*/
if (Warehouse.Data.fromTerminalId != '' && Warehouse.Data.fromTerminalId != '0') {
Warehouse.Func.bindTerminalDockList(Warehouse.Data.fromTerminalId, 1);
}
/*绑定城市列表*/
if (Warehouse.Data.provinceId != '' && Warehouse.Data.provinceId != '0') {
Warehouse.Func.bindCityList(Warehouse.Data.provinceId, 1);
}
/*绑定县列表*/
if (Warehouse.Data.cityId != '' && Warehouse.Data.cityId != '0') {
Warehouse.Func.bindCountryList(Warehouse.Data.cityId, 1);
}
/*绑定验证*/
$("#fmWarehouse").validate({
focusInvalid: true,
onkeyup: false,
ignore: "",
errorPlacement: function (error, element) {
if ($.trim(element.val()) == "") {
//console.log(element.attr('id') + '=' + element.val());
element.css({ 'border-color': 'red' })
//console.log(element.parent().html());
} else {
element.css({ 'border-color': '#d2d6de' });
}
},
success: function (label, element) {
$(element).removeClass("errTip");
},
rules: {
WarehouseName: {
required: true
},
Contact: {
required: true
},
Cellphone: {
required: true
},
Email: {
required: true
},
SRSupplierID: {
required: true
},
DockIds: {
required: function () {
return model.listDock().length > 0
}
},
RelatedTerminalID: {
required: function () {
return model.listTerminals().length > 0
}
},
SRSupplierID: {
required: true
},
ProvinceID: {
required: true
},
CityID: {
required: function () {
return model.listCitys().length > 0;
}
},
CountyID: {
required: function () {
return model.listCountys().length > 0;
}
},
Address: {
required: true
},
WHContact: {
required: true
},
WHTellphone: {
required: true
}
}
});
}
Warehouse.Func = {
saveAndNext: function () {
if (editmode=="1") {
$("#hidTypeVal").val(-1);
}
if (model.listDock().length>0) {
if ($("input:checkbox[name=DockIds]:checked").length <= 0) {
$("#divTermDock").addClass("errTip");
}
}
if (model.files().length<=0) {
$("#divMap").addClass("errTip");
$.message.success('请上传图片!');
return;
}
if (!$('#fmWarehouse').valid()) {
$.message.success('请填写必填项!');
return;
}
var txtWarehouseName = $.trim($("#WarehouseName").val());
$("#WarehouseName").val(txtWarehouseName);
$("#btnSubmitWarehouse").siblings(".btnCover").show();
$.ajax({
url: '@Url.Action("SaveSRWarehouseInfo")',
type: 'post',
data: $('#fmWarehouse').serialize() + '&MapURL=' + model.files()[0].fileOppositeUrl() + '&MapURLFileName=' + model.files()[0].OriginalName(),
dataType: 'json',
success: function (resp) {
if (resp.State == 1) {
$.message.success('操作成功', 1000);
setTimeout(function () {
if (Warehouse.Data.tag == 0) {
window.location.href = 'srwarehouseslist';
} else {
window.location.href = 'srwarehouseslist';
}
}, 2000);
} else {
$.message.success('操作失败!' + resp.ErrorMsg);
$("#btnSubmitWarehouse").siblings(".btnCover").hide();
}
}
});
},
/*选择省份*/
provienceChange: function () {
var _this = $(this);
//请求
Warehouse.Func.bindCityList($("#ProvinceID").val(), 2);
},
/*选择城市*/
cityChange: function () {
var _this = $(this);
Warehouse.Func.bindCountryList($("#CityID").val(), 2);
},
/*选择checkbox相关*/
dockCheckboxChange: function () {
$("#divTermDock").removeClass("errTip");
},
/*选择港口*/
TermChange: function () {
var _this = $(this);
$("#divTerm").removeClass("errTip");
Warehouse.Func.bindTerminalList($("#SRSupplierID").val(), 2);
Warehouse.Func.bindTerminalDockList($("#RelatedTerminalID").val(), 2);
},
/*选择码头*/
dockChange: function () {
var _this = $(this);
$("#divTermDock").removeClass("errTip");
Warehouse.Func.bindTerminalDockList($("#RelatedTerminalID").val(), 2);
},
/*绑定城市列表1、初始化,2、chang*/
bindCityList: function (provinceId, t) {
var modelDat = {};
modelDat.provinceId = provinceId;
$.ajax({
url: "@Url.Action("GetCityByProvince", "lookup", new { area=""})",
type: 'post',
data: modelDat,
dataType: 'json',
success: function (data) {
if (data.success === true) {
model.listCitys([]);
var html = '';
if (data.Data.length == 0) {
html += "<option value='' >请选择</option>";
}
for (var i = 0; i < data.Data.length; i++) {
model.listCitys.push(new City(data.Data[i]));
if (editmode == "1") {
if (data.Data[i].Id == Warehouse.Data.cityId){
html += "<option selected='selected' value='" + data.Data[i].Id + "' >" + data.Data[i].Name + "</option>";
}
else {
html += "<option value='" + data.Data[i].Id + "' >" + data.Data[i].Name + "</option>";
}
}
else {
html += "<option value='" + data.Data[i].Id + "' >" + data.Data[i].Name + "</option>";
}
if (t == 2 && i == 0) {
//默认绑定第一项到当前列表
$("#CityID option[value='" + data.Data[i].Id + "']").attr("selected", true)
Warehouse.Func.bindCountryList(data.Data[i].Id, t);
} else {
if (data.Data[i].Id == Warehouse.Data.cityId) {
$("#CityID option[value='" + data.Data[i].Id + "']").attr("selected", true);
}
}
}
$("#CityID").html(html);
} else {
$.message.success(data.message);
}
}
});
},
bindCountryList: function (cityId, t) {
var modelDatpid = {};
modelDatpid.cityId = cityId
$.ajax({
url: "@Url.Action("GetCountyByCity", "lookup", new { area = "" })",
type: 'post',
data: modelDatpid,
dataType: 'json',
success: function (data) {
if (data.success) {
var html = '';
model.listCountys([]);
if (data.Data.length == 0) {
html += "<option value='' >请选择</option>";
}
for (var i = 0; i < data.Data.length; i++) {
model.listCountys.push(new County(data.Data[i]));
if (editmode==="1") {
if (data.Data[i].Id == Warehouse.Data.countryId) {
html += "<option selected='selected' value='" + data.Data[i].Id + "' >" + data.Data[i].Name + "</option>";
}
else {
html += "<option value='" + data.Data[i].Id + "' >" + data.Data[i].Name + "</option>";
}
}
else {
html += "<option value='" + data.Data[i].Id + "' >" + data.Data[i].Name + "</option>";
}
if (t == 2 && i == 0) {
$("#CityID option[value='" + data.Data[i].Id + "']").attr("selected", true)
} else {
if (data.Data[i].Id == Warehouse.Data.countryId) {
$("#CityID option[value='" + data.Data[i].Id + "']").attr("selected", true)
}
}
}
$("#CountyID").html(html);
} else {
$.message.success(data.message);
}
}
});
},
// 港口列表
bindTerminalList: function (srsupplierid, t) {
var modelDataTerminal = {};
modelDataTerminal.srsupplierid = srsupplierid
$.ajax({
async: false,
url: "@Url.Action("GetSRSupplierTerminalRSListBySupplierID")",
type: 'post',
data: modelDataTerminal,
dataType: 'json',
success: function (data) {
if (data) {
model.listTerminals([]);
var html = '';
if (data.length == 0) {
html += "<option value='' >请选择</option>";
}
for (var i = 0; i < data.length; i++) {
model.listTerminals.push(new Terminal(data[i]));
if (editmode == "1") {
if (data[i].LocationID == Warehouse.Data.fromTerminalId) {
html += "<option selected='selected' value='" + data[i].LocationID + "' >" + data[i].LocationName + "</option>";
}
else {
html += "<option value='" + data[i].LocationID + "' >" + data[i].LocationName + "</option>";
}
}
else {
html += "<option value='" + data[i].LocationID + "' >" + data[i].LocationName + "</option>";
}
if (t == 2 && i == 0) {
//默认绑定第一项到当前列表
$("#RelatedTerminalID option[value='" + data[i].LocationID + "']").attr("selected", true)
Warehouse.Func.bindTerminalDockList(data[i].LocationID, t);
} else {
if (data[i].LocationID == Warehouse.Data.fromTerminalId) {
$("#RelatedTerminalID option[value='" + data[i].LocationID + "']").attr("selected", true);
}
}
}
$("#RelatedTerminalID").html(html);
} else {
$.message.success(data.message);
}
}
});
},
// 码头列表
bindTerminalDockList: function (terminalId, t) {
var modelDatpid = {};
modelDatpid.terminalId = terminalId
$.ajax({
async: false,
url: "@Url.Action("GetAllTerminalDockList")",
type: 'post',
data: modelDatpid,
dataType: 'json',
success: function (data) {
if (data) {
var html = '';
model.listDock([]);
if (data.length === 0) {
$("#divTermDock").html("");
}
var flg = false;
var listDock = eval($("#listDock").val());
for (var i = 0; i < data.length; i++) {
var id = data[i].TerminalDockID;
var name = data[i].DockName;
model.listDock.push(new Dock(data[i]));
if (editmode === "1") {
for (var perDock = 0; perDock < listDock.length; perDock++) {
if (data[i].TerminalDockID == listDock[perDock].TerminalDockID) {
html += '<label style="float:left; margin-right: 50px; margin-top: 5px; margin-bottom: 5px;"><input style="margin-top: 0px" checked="checked" type="checkbox" value=\'' + data[i].TerminalDockID + '\' name="DockIds"/>' + data[i].DockName + '</label>';
flg = true;
break;
}
}
if (!flg) {
html += '<label style="float:left; margin-right: 50px; margin-top: 5px; margin-bottom: 5px;"><input style="margin-top: 0px" type="checkbox" value=\'' + data[i].TerminalDockID + '\' name="DockIds"/>' + data[i].DockName + '</label>';
}
}
else {
html += '<label style="float:left; margin-right: 50px; margin-top: 5px; margin-bottom: 5px;"><input style="margin-top: 0px" type="checkbox" value=\'' + data[i].TerminalDockID + '\' name="DockIds"/>' + data[i].DockName + '</label>';
}
flg = false;
}
$("#divTermDock").html(html);
} else {
$.message.success(data);
}
}
});
},
/*选择收货仓库*/
SRWarehouseChange: function () {
var _this = $(this);
var value = _this.children("span").attr("value");
var name = _this.children("span").attr("name");
var title = _this.children("span").attr("title");
$("#SRWarehouseID").parent().removeClass("errTip");
$("#SRWarehouseID").val(value);
var html = '';
html += "<a href='" + title + "' target='_blank'>查看地图</a>";
$("#divMapURL").html(html);
$("#SRWarehouseMapURL").val(title);
$("#divSRWarehouseAddress").html(name);
$("#SRWarehouseAddress").val(name);
},
// 收货仓库列表
bindSRWarehouseList: function (terminaldockId, t) {
$.post("/OrderIPWarehouse/GetSRWarehouseListByDockID", { TerminalDockID: terminaldockId }, function (data) {
if (data) {
var html = '';
if (data.Data.length === 0) {
$("#SRWarehouseMapURL").val('');
$("#SRWarehouseAddress").val('');
$(".liSRWarehouseAddress").hide();
$("#SRWarehouseList").parent().find('span').text('请选择').attr('value', '');
$("#SRWarehouseList").parent().find(':input').val('');
$("#SRWarehouseList").html(html);
}
else {
for (var i = 0; i < data.Data.length; i++) {
var id = data.Data[i].SRWarehouseID;
var name = data.Data[i].WarehouseName;
var mapurl = data.Data[i].MapURL;
var srwaddress = data.Data[i].SRWarehouseAddress;
html += "<dd><a href=\"javascript:void(0)\" ><span class=\"text\" title='" + mapurl + "' name='" + srwaddress + "' value='" + id + "' >" + name + "</span></a></dd>";
if (t == 2 && i === 0) {
$("#SRWarehouseList").parent().find('span').text(name).attr('value', id).attr("name", srwaddress).attr("title", mapurl);
$("#SRWarehouseList").parent().find(':input').val(id);
var htmlmap = '';
htmlmap += "<a href='" + mapurl + "' target='_blank'>查看地图</a>";
$("#divMapURL").html(htmlmap);
$("#SRWarehouseMapURL").val(mapurl);
$("#divSRWarehouseAddress").html(srwaddress);
$("#SRWarehouseAddress").val(srwaddress);
} else {
if (id == Warehouse.Data.SRWarehouseID) {
$("#SRWarehouseList").parent().find('span').text(name).attr('value', id).attr("name", srwaddress).attr("id", mapurl);
var htmlq = '';
htmlq += "<a href='" + mapurl + "' target='_blank'>查看地图</a>";
$("#divMapURL").html(htmlq);
$("#SRWarehouseMapURL").val(mapurl);
$("#divSRWarehouseAddress").html(srwaddress);
$("#SRWarehouseAddress").val(srwaddress);
}
}
}
$("#SRWarehouseList").html(html);
$(".liSRWarehouseAddress").show();
}
} else {
$.message.success(data.message);
}
});
}
}
function City(jsonObj) {
var self = this;
self.Id = ko.observable();
self.Name = ko.observable();
if (jsonObj != null) {
//jsonObj.SendDate = moment(jsonObj.SendDate).format('YYYY-MM-DD HH:mm:ss');
return ko.mapping.fromJS(jsonObj, {}, self);
}
}
function County(jsonObj) {
var self = this;
self.Id = ko.observable();
self.Name = ko.observable();
if (jsonObj != null) {
//jsonObj.SendDate = moment(jsonObj.SendDate).format('YYYY-MM-DD HH:mm:ss');
return ko.mapping.fromJS(jsonObj, {}, self);
}
}
function Terminal(jsonObj) {
var self = this;
self.LocationID = ko.observable(0);
self.LocationName = ko.observable();
if (jsonObj != null) {
//jsonObj.SendDate = moment(jsonObj.SendDate).format('YYYY-MM-DD HH:mm:ss');
return ko.mapping.fromJS(jsonObj, {}, self);
}
}
function Dock(jsonObj) {
var self = this;
self.TerminalDockID = ko.observable(0);
self.DockName = ko.observable();
if (jsonObj != null) {
//jsonObj.SendDate = moment(jsonObj.SendDate).format('YYYY-MM-DD HH:mm:ss');
return ko.mapping.fromJS(jsonObj, {}, self);
}
}
function file() {
var self = this;
self.fileSize = ko.observable('');
self.OriginalName = ko.observable('');
self.fileId = ko.observable(0);
self.fileUrl = ko.observable('');
self.fileOppositeUrl = ko.observable('');
self.isImg = ko.observable(false);
self.fineId = ko.observable(-1);
self.hasLoaded = ko.observable(false);
}
var filesArray = new Array();
$(document).ready(function () {
var fileTrueName = "@fileTrueName";
var fileopsiUrl = "@fileTrueUrl";
var fileAliUrl = "@fileAliUrl";
$('.flash_area').fineUploader({
request: {
endpoint: '@Url.Action("ProcessUpload", "FileUpload", new { area = "" })',
params: {
"jobType": 16
}
},
messages: {
typeError: "文件格式不正确",
sizeError: "文件不能超出5M."
},
multiple: false,
validation: {
allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
sizeLimit: "4M"
},
showMessage: function (message) {
$('#flash_area').append('<div class="alert alert-error">' + message + '</div>');
promptFailure(message);
},
callbacks: {
onUpload: function (id, name) {
model.files([]);
var f = new file();
f.OriginalName(name);
f.fineId(id);
$("#hidTypeVal").val(1);
model.files.push(f);
}
,
onError: function (id, name, errorReason) {
promptFailure(errorReason);
model.deletefromfiles(id);
return;
},
onCancel: function () {
return false;
}
}
}).on("complete", function (event, id, name, responseJSON, xhr) {
if (responseJSON == null || responseJSON.success == false) {
if (responseJSON != null && responseJSON.error != null && responseJSON.error != '') {
$.message.success(responseJSON.error);
return;
} else {
$.message.success('上传失败!');
return;
}
}
model.add(responseJSON, id);
});
function viewModel() {
var self = this;
self.listCitys = ko.observableArray([]);
self.listCountys = ko.observableArray([]);
self.listTerminals = ko.observableArray([]);
self.listDock = ko.observableArray([]);
self.files = ko.observableArray([]);
self.view = function (d) {
var fileUrl = self.getFile(d.fineId()).fileUrl();
fileUrl = encodeURIComponent(fileUrl);
var openUrl = "@Url.Action("File", "Common", new { area = "" })?fileUrl=" + fileUrl + "&IsAsAliyun=true";
window.open(openUrl, "_blank");
}
self.filesDiffLength = ko.computed(function () {
var hidTVal = $("#hidTypeVal").val();
if (hidTVal == "-1" || hidTVal == "1") {
if (self.files().length > 0) {
$("#divMap").removeClass("errTip");
}
else {
$("#divMap").addClass("errTip");
}
}
return self.files().length;
});
self.download = function (d) {
console.log(d);
var fileUrl = d.fileUrl();
console.log(fileUrl);
fileUrl = encodeURIComponent(fileUrl);
return fileUrl;
}
self.deleter = function (d) {
self.files.remove(d);
}
self.getFile = function (d) {
for (var i = 0; i < self.files().length; i++) {
if (self.files()[i].fineId() == d)
return self.files()[i];
}
}
self.add = function (d, id) {
if (d == null || d.success != true) {
self.deletefromfiles(id);
$.message.success('文件上传失败!');
return;
}
var fileName = d.OriginalName;
var fileExtendName = fileName.substr(fileName.lastIndexOf("."));
var imgExtendName = "*.png;*.jpg;*.gif;*.bmp;*.jpeg;";
for (var i = 0; i < self.files().length; i++) {
if (self.files()[i].fineId() == id) {
var fileObj = self.files()[i];
fileObj.OriginalName(d.OriginalName);
fileObj.fileId(d.fileId);
fileObj.fileSize(d.fileSize);
fileObj.fileOppositeUrl(d.fileOppositeUrl);
fileObj.fileUrl(d.fileUrl);
if (imgExtendName.indexOf(fileExtendName) >= 0) {
fileObj.isImg(true);
}
else {
fileObj.isImg(false);
}
fileObj.hasLoaded(true);
self.files()[i] = fileObj;
}
}
}
self.deletefromfiles = function (id) {
for (var i = 0; i < self.files().length; i++) {
if (self.files()[i].fineId() == id) {
self.files.remove(self.files()[i]);
}
}
};
}
window.model = new viewModel();
ko.applyBindings(model);
Warehouse.BindEvent();
if (editmode === "1") {
model.files([]);
var fileObj = new file();
fileObj.OriginalName(fileTrueName);
fileObj.fileId(2);
fileObj.fileSize(2);
fileObj.fileOppositeUrl(fileopsiUrl);
fileObj.fileUrl(fileAliUrl);
fileObj.isImg(true);
fileObj.hasLoaded(true);
model.files.push(fileObj);
$("#hidTypeVal").val(1);
}
else {
$("#hidTypeVal").val(editmode);
}
});
function ToDateTime(data) {
//var data = "/Date(1345517741000)/";
var date = new Date(parseInt(data.replace("/Date(", "").replace(")/", ""), 10));
var result = date.getFullYear() + "-" + (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-" + (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " " + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":" + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
return result;
}
var orderRelatedFileID = "";
var orderId = "";
function PreviewImg(obj) {
var fileUrl = encodeURIComponent(obj.id);
var openUrl = "@Url.Action("File", "FileUpload", new { area = "" })?fileUrl=" + fileUrl + "&IsAsAliyun=true";
window.open(openUrl, "_blank");
}
function DeleteRelateFile(obj) {
orderRelatedFileID = obj.id;
orderId = obj.name;
$.confirmDialog({
title: "提示",
content: "确定要删除此文件吗?",
btnDetermine: "确定",
btnCancel: "取消",
id: "divConfirmDialog"
});
}
function IsUploadFile() {
for (var i = 0; i < model.files().length; i++) {
if (model.files()[i].hasLoaded() == false) {
$.message.success('您有文件正在上传,请稍后提交!');
return true;
}
}
return false;
}
</script>
<script type="text/template" id="qq-template">
<div class="qq-uploader-selector qq-uploader">
<div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone style="display:none;">
<span>Drop files here to upload</span>
</div>
<div class="qq-upload-button-selector qq-upload-button" style="height:28px;">
<div> </div>
</div>
<span class="qq-drop-processing-selector qq-drop-processing" style="display:none;">
<span>Processing dropped files...</span>
<span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
</span>
<ul class="qq-upload-list-selector qq-upload-list" style="display:none;">
<li>
<div class="qq-progress-bar-container-selector">
<div class="qq-progress-bar-selector qq-progress-bar"></div>
</div>
<span class="qq-upload-spinner-selector qq-upload-spinner"></span>
<span class="qq-edit-filename-icon-selector qq-edit-filename-icon"></span>
<span class="qq-upload-file-selector qq-upload-file"></span>
<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
<span class="qq-upload-size-selector qq-upload-size"></span>
<a class="qq-upload-cancel-selector qq-upload-cancel" href="#">Cancel</a>
<a class="qq-upload-retry-selector qq-upload-retry" href="#">Retry</a>
<a class="qq-upload-delete-selector qq-upload-delete" href="#">Delete</a>
<span class="qq-upload-status-text-selector qq-upload-status-text"></span>
</li>
</ul>
</div>
</script>
}