@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. Android ImageView,ImageButton 与 Button

    1. ImageButton 继承自 ImageView.两者具备甚小,因为 ImageView 同样可以点击相应,同样有点击的阴影效果.实际上他们的区别在于默认 style.比如同样放一个背景和一个 ...

  2. yum 下载RPM包而不进行安装

    yum命令本身就可以用来下载一个RPM包,标准的yum命令提供了--downloadonly(只下载)的选项来达到这个目的. $ sudo yum install --downloadonly < ...

  3. css3旋转动画

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  4. aspx代码审计-2

    今天和大家分享一下aspx网站的代码审计,漏洞类型为:未授权访问和任意文件下载. 本文作者:i春秋签约作家——非主流 今天看的源码文件就不共享给大家了,本文只作学习只用. 还是先看我们的文件夹目录和d ...

  5. AssertionError: View function mapping is overwriting an existing endpoint function: admin.main

    刚才给views.py文件添加了一个路由地址: @admin_view.route('/test', methods=["get", "post"]) @log ...

  6. java使用Redis6--sentinel单点故障主从自动切换

    Redis SentinelSentinel(哨兵)是用于监控redis集群中Master状态的工具,其已经被集成在redis2.4+的版本中 一.Sentinel作用:1):Master状态检测 2 ...

  7. 【性能分析】使用Intel VTune Amplifier

    本文转自 https://software.intel.com/zh-cn/blogs/2010/11/10/amplxe-cl/版权归原作者所有,如原作者有任何不允许转载之理由,本文将自行删除. I ...

  8. multiprocessor(下)

    一.数据共享 展望未来,基于消息传递的并发编程是大势所趋即便是使用线程,推荐做法也是将程序设计为大量独立的线程集合,通过消息队列交换数据.这样极大地减少了对使用锁定和其他同步手段的需求,还可以扩展到分 ...

  9. BootStrap Modal 点击空白时自动关闭

    本文为大家讲解的是如何禁用 BootStrap Modal 点击空白时自动关闭的方法,感兴趣的同学参考下. 方法如下 $('#myModal').modal({backdrop: 'static', ...

  10. [BZOJ 5072][Lydsy1710月赛]小A的树

    传送门 \(\color{green}{solution}\) 嗯...其实我也不太会,所以大胆猜个结论吧(后来证了一下,然后放弃了...). 我们发现如果要使一个联通块的黑点数量为\(k\)的方案最 ...