Files
Web_Faces_Prod/Face.Web/Plugin/common.js
2025-11-25 17:41:57 +08:00

197 lines
6.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//修改数据库选择
$("#userCustomer").change(function () {
var customerID = $("#userCustomer").val();
$("#ordersPlannedSpeedBox_Content").empty();
// Ajax提交数据
$.ajax({
url: "/app/Home/SetCustomerID",//"APP/login/login", // 提交到controller的url路径
type: "post", // 提交方式
data: { "customerID": customerID }, // data为String类型必须为 Key/Value 格式。
dataType: "json", // 服务器端返回的数据类型
success: function (res) { // 请求成功后的回调函数其中的参数data为controller返回的map,也就是说然后通过data这个参数取JSON数据中的值
if (res.Status == 200) {
//textToast(res.Message);
//gotoDetailCommon();//首页数据表格显示
}
else if (res.Status != 200) {
//textToast(res.Message);
}
},
});
});
//打开普通的局部页
function gotoCommonPartial(url, containerDiv) {
$.ajax({
cache: true,
async: true,
type: 'POST',
url: url,
success: function (data) {
$('#' + containerDiv).html(data);
}
});
}
// 链接到明细数据页
function gotoDetailPartial(url, id, containerDiv) {
url = url + "/" + id;
$.ajax({
cache: true,
async: true,
type: 'POST',
url: url,
success: function (data) {
$('#' + containerDiv).html(data);
}
});
}
//打开普通的局部页
function gotoCommonPartialNeedDate(url, containerDiv) {
$.ajax({
cache: true,
async: true,
type: 'POST',
url: url,
success: function (data) {
addDatepicker();
$('#' + containerDiv).html(data);
}
});
}
// 链接到明细数据页 需要时间控件
function gotoDetailPartialNeedDate(url, id, containerDiv) {
url = url + "/" + id;
$.ajax({
cache: true,
async: true,
type: 'POST',
url: url,
success: function (data) {
addDatepicker();
$('#' + containerDiv).html(data);
}
});
}
// 链接到明细数据页 两个视图
function gotoDetailPartialTwoView(url, id, containerDiv, url2, containerDiv2) {
url = url + "/" + id;
$.ajax({
cache: true,
async: true,
type: 'POST',
url: url,
success: function (data) {
$('#' + containerDiv).html(data);
gotoDetailPartial(url2, id, containerDiv2);
}
});
}
function addDatepicker() {
$.getScript('/Theme/js/plugins/datapicker/bootstrap-datepicker.js');
$.getScript('/Theme/js/plugins/datapicker/locales/bootstrap-datepicker.zh-CN.js');
}
function gotoDetailCommon() {
// Ajax提交数据
$.ajax({
url: "/app/Order/GetOrdersPlannedSpeed",
type: "post",
dataType: "json",
success: function (res) { // 请求成功后的回调函数其中的参数data为controller返回的map,也就是说然后通过data这个参数取JSON数据中的值
if (res.Status == 200) {
$("#ordersPlannedSpeedBox_Content").empty();
if (res.Data) {
//填充数据
var jsonArray = res.Data;
var headArray = [];
//循环取字段名
for (var i in jsonArray[0]) {
headArray[headArray.length] = i;
}
var div = document.getElementById("ordersPlannedSpeedBox_Content");
var table = document.createElement("table");
table.id = "new_table";
table.setAttribute("class", "table table-striped table-bordered table-hover dataTables-example");
var theadH = document.createElement("thead");
var thead = document.createElement("tr");
//表头 从1开始 忽略ID
for (var count = 1; count < headArray.length; count++) {
var td = document.createElement("th");
td.innerHTML = headArray[count];
thead.appendChild(td);
}
theadH.appendChild(thead);
table.appendChild(theadH);
var theadY = document.createElement("tbody");
//表格数据
for (var tableRowNo = 0; tableRowNo < jsonArray.length; tableRowNo++) {
var tr = document.createElement("tr");
tr.setAttribute("onclick", "clickaction(" + jsonArray[tableRowNo]["ID"] + ")")
//从1开始 忽略ID
for (var headCount = 1; headCount < headArray.length; headCount++) {
var cell = document.createElement("td");
cell.innerHTML = jsonArray[tableRowNo][headArray[headCount]];
tr.appendChild(cell);
}
theadY.appendChild(tr);
table.appendChild(theadY);
}
div.appendChild(table);
} else { }
}
},
});
};
function updateCommonCache(url, sucUrl) {
$.ajax({
cache: true,
async: true,
type: 'GET',
url: url,
success: function (res) {
if (res.Status == 200) {
$.toastr.success('更新成功',
{
position: 'top-center',
time: 350,
callback: function () {
location.href = sucUrl;
}
});
}
else {
$.toastr.error('清除失败! <br />' + res.Message, {
time: 3000,
position: 'top-center'
});
}
}
});
};