@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 : -;
var cityid = Model.CityID != null ? Model.CityID : -;
var cid = Model.CountyID != null ? Model.CountyID : -;
var fromtermId = Model.RelatedTerminalID ?? ;
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: %;
} .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: %;
} .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: %;
height: 20px;
line-height: 20px;
font-family: Microsoft YaHei;
font-size: 14px;
color: #;
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: #;
padding-left: ;
} .selMemsShow li {
float: left;
height: 20px;
line-height: 20px;
padding-right: 5px;
margin: 15px 3px ;
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 > )
{
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 != )
{
<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 != -)
{
<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 != -)
{
<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 != -)
{
<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..custom.min.js")"></script>
<script src="@Url.Content("/Scripts/knockout-3.2..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('', '', '');
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!='') {
Warehouse.Func.bindTerminalList(Warehouse.Data.srsupplierId,);
}
/*绑定起运港码头列表*/
if (Warehouse.Data.fromTerminalId != '' && Warehouse.Data.fromTerminalId != '') { Warehouse.Func.bindTerminalDockList(Warehouse.Data.fromTerminalId, );
}
/*绑定城市列表*/
if (Warehouse.Data.provinceId != '' && Warehouse.Data.provinceId != '') {
Warehouse.Func.bindCityList(Warehouse.Data.provinceId, );
}
/*绑定县列表*/
if (Warehouse.Data.cityId != '' && Warehouse.Data.cityId != '') {
Warehouse.Func.bindCountryList(Warehouse.Data.cityId, );
} /*绑定验证*/
$("#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 >
}
},
RelatedTerminalID: {
required: function () {
return model.listTerminals().length >
}
},
SRSupplierID: {
required: true
},
ProvinceID: {
required: true
},
CityID: {
required: function () {
return model.listCitys().length > ;
}
},
CountyID: {
required: function () {
return model.listCountys().length > ;
}
},
Address: {
required: true
},
WHContact: {
required: true
},
WHTellphone: {
required: true
}
}
});
}
Warehouse.Func = {
saveAndNext: function () {
if (editmode=="") {
$("#hidTypeVal").val(-);
}
if (model.listDock().length>) {
if ($("input:checkbox[name=DockIds]:checked").length <= ) {
$("#divTermDock").addClass("errTip");
}
}
if (model.files().length<=) {
$("#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()[].fileOppositeUrl() + '&MapURLFileName=' + model.files()[].OriginalName(),
dataType: 'json',
success: function (resp) {
if (resp.State == ) {
$.message.success('操作成功', );
setTimeout(function () {
if (Warehouse.Data.tag == ) {
window.location.href = 'srwarehouseslist';
} else {
window.location.href = 'srwarehouseslist';
} }, );
} else {
$.message.success('操作失败!' + resp.ErrorMsg);
$("#btnSubmitWarehouse").siblings(".btnCover").hide();
}
}
});
}, /*选择省份*/
provienceChange: function () {
var _this = $(this);
//请求
Warehouse.Func.bindCityList($("#ProvinceID").val(), );
},
/*选择城市*/
cityChange: function () {
var _this = $(this);
Warehouse.Func.bindCountryList($("#CityID").val(), );
},
/*选择checkbox相关*/
dockCheckboxChange: function () {
$("#divTermDock").removeClass("errTip");
},
/*选择港口*/
TermChange: function () {
var _this = $(this);
$("#divTerm").removeClass("errTip");
Warehouse.Func.bindTerminalList($("#SRSupplierID").val(), );
Warehouse.Func.bindTerminalDockList($("#RelatedTerminalID").val(), );
},
/*选择码头*/
dockChange: function () {
var _this = $(this);
$("#divTermDock").removeClass("errTip");
Warehouse.Func.bindTerminalDockList($("#RelatedTerminalID").val(), );
}, /*绑定城市列表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 == ) {
html += "<option value='' >请选择</option>";
}
for (var i = ; i < data.Data.length; i++) {
model.listCitys.push(new City(data.Data[i]));
if (editmode == "") {
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 == && i == ) {
//默认绑定第一项到当前列表
$("#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 == ) {
html += "<option value='' >请选择</option>";
}
for (var i = ; i < data.Data.length; i++) {
model.listCountys.push(new County(data.Data[i]));
if (editmode==="") {
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 == && i == ) {
$("#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 == ) {
html += "<option value='' >请选择</option>";
}
for (var i = ; i < data.length; i++) {
model.listTerminals.push(new Terminal(data[i]));
if (editmode == "") {
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 == && i == ) {
//默认绑定第一项到当前列表
$("#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 === ) {
$("#divTermDock").html("");
}
var flg = false;
var listDock = eval($("#listDock").val());
for (var i = ; i < data.length; i++) {
var id = data[i].TerminalDockID;
var name = data[i].DockName;
model.listDock.push(new Dock(data[i]));
if (editmode === "") { for (var perDock = ; 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 === ) {
$("#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 = ; 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 == && i === ) {
$("#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();
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();
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();
self.fileUrl = ko.observable('');
self.fileOppositeUrl = ko.observable('');
self.isImg = ko.observable(false);
self.fineId = ko.observable(-);
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":
}
},
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();
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 == "") {
if (self.files().length > ) {
$("#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 = ; 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 = ; 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) >= ) {
fileObj.isImg(true);
}
else {
fileObj.isImg(false);
}
fileObj.hasLoaded(true);
self.files()[i] = fileObj; } }
}
self.deletefromfiles = function (id) {
for (var i = ; 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 === "") {
model.files([]);
var fileObj = new file();
fileObj.OriginalName(fileTrueName);
fileObj.fileId();
fileObj.fileSize();
fileObj.fileOppositeUrl(fileopsiUrl);
fileObj.fileUrl(fileAliUrl);
fileObj.isImg(true);
fileObj.hasLoaded(true);
model.files.push(fileObj);
$("#hidTypeVal").val();
}
else {
$("#hidTypeVal").val(editmode);
}
}); function ToDateTime(data) {
//var data = "/Date(1345517741000)/";
var date = new Date(parseInt(data.replace("/Date(", "").replace(")/", ""), ));
var result = date.getFullYear() + "-" + (date.getMonth() + < ? "" + (date.getMonth() + ) : date.getMonth() + ) + "-" + (date.getDate() < ? "" + date.getDate() : date.getDate()) + " " + (date.getHours() < ? "" + date.getHours() : date.getHours()) + ":" + (date.getMinutes() < ? "" + 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 = ; 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>&nbsp;</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="" 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>
}

AJAX同步问题的更多相关文章

  1. ajax同步异步问题

    之前一直在写JQUERY代码的时候遇到AJAX加载数据都需要考虑代码运行顺序问题.最近的项目用了到AJAX同步.这个同步的意思是当JS代码加载到当前AJAX的时候会把页面里所有的代码停止加载,页面出去 ...

  2. ajax同步、异步执行简单理解与证明

    此理解范例代码来自前几篇随笔! 首先我们来先了解下AJAX: Ajax:全称“Asynchronous Javascript and XML”(异步Javascript和XML),他是由Javascr ...

  3. jquery的ajax同步和异步

    之前一直在写JQUERY代码的时候遇到AJAX加载数据都需要考虑代码运行顺序问题.最近的项目用了到AJAX同步.这个同步的意思是当JS代码加载到当前AJAX的时候会把页面里所有的代码停止加载,页面出去 ...

  4. jquery的ajax同步和异步的理解及示例

    之前一直在写JQUERY代码的时候遇到AJAX加载数据都需要考虑代码运行顺序问题.最近的项目用了到AJAX同步.这个同步的意思是当JS代码加载到当前AJAX的时候会把页面里所有的代码停止加载,页面出去 ...

  5. ajax同步请求JS代码

    ajax同步请求JS代码 <script type="text/javascript"> var txt = document.getElementById('txt' ...

  6. ajax同步与异步的坑

      之前工作中一个需求,需要动态的添加一组下拉菜单并为这个菜单绑定一个插件,很明显获取数据用Ajax,这本身是没错的,坑就坑在我用了 同步请求,当服务器端正确返回数据时再去执行下一个方法,这逻辑本身没 ...

  7. 浅谈ajax同步、异步的问题

    最近实习的时候看到过firefox的同步.异步的警告,想着概念不是那么清楚,于是整理了一下ajax同步异步方面的知识.我是小白,做个笔记. 首先就是概念问题,ajax根据async进行区分同步和异步过 ...

  8. AJAX同步设置以及请求代码

    全局设置ajax同步 更正一点:这个的同步,针对的是ajax请求的返回,而不是ajax-success返回后所有进行处理后才进行下一步.所以,window.location.href转跳这个在执行的时 ...

  9. JQ Ajax 同步与异步的区别

    $.ajax({ url: xml_addr, type: 'get', dataType: 'xml', timeout: 1000, //设定超时 cache: false, //禁用缓存 asy ...

  10. ajax同步导致ajax上面的代码不执行?

    js代码:环境:IE11要求:点击一个按钮后,页面xxx的地方立即显示"开始处理...",直到ajax处理结束后,xxx内容才更新为新的处理结果:点击事件执行代码如下:xxx.in ...

随机推荐

  1. c语言第一次作业--顺序、分支结构

    1.1思维导图 1.2.1本周学习体会以及代码量学习体会 1.2.2学习体会     因为在暑假时候没有对c语言进行学习,没太关注一些学习资料,一些教学视频也没看,感觉对c语言是陌生的,刚开课的时候自 ...

  2. 多个音频audio2

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. “全栈2019”Java第一百零七章:匿名内部类与构造方法注意事项

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

  4. 【文文殿下】 [SDOI2016]生成魔咒

    字符集大小为1e9.............使用 map 吧 统计本质不同的子串个数是SAM的经典应用之一 本质不同的子串个数其实就是\(\sum max(x)-min(x)+1\) 所以我们新建结点 ...

  5. 洛谷P3964 [TJOI2013]松鼠聚会(坐标系变换)

    题面 传送门 题解 对于两个点\((x_i,y_i)\)和\(x_j,y_j\),我们定义它们之间的曼哈顿距离为 \[|x_i-x_j|+|y_i-y_j|\] 定义它们的切比雪夫距离为 \[\max ...

  6. 洛谷P5280 [ZJOI2019]线段树(线段树)

    题面 传送门 题解 考场上就这么一道会做的其它连暴力都没打--活该爆炸-- 首先我们得看出问题的本质:有\(m\)个操作,总共\(2^m\)种情况分别对应每个操作是否执行,求这\(2^m\)棵线段树上 ...

  7. BZOJ 1934--善意的投票(最小割)

    1934: [Shoi2007]Vote 善意的投票 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 2354  Solved: 1471[Submit][ ...

  8. jzoj5813

    tj:可以知道,隨意構造一個數列x,且x的第i位被n整除的方案是(約數個數)^2m,因為所有數可以隨便選,只要這個數能被n整除即可,方案為約數個數 設一個合法數列a的f值為x,則x小於n^m 假設所有 ...

  9. python unittest框架理解与总结(二)

    unittest基本原理: ♦整个平台的搭建使用的是python的unittest测试框架,这里简单介绍下unittest模块的简单应用. ♦unittest是python的标准测试库,相比于其他测试 ...

  10. 题目1000:计算a+b

    问题来源 http://ac.jobdu.com/problem.php?pid=1000 问题描述 简单a+b测试,没什么限制,入门级题目. 问题分析 使用scanf.printf或者cin.cou ...