function tan(ty){
alert('确定添加?');
if(ty=='f'){
var p= document.getElementById('facility');
var newfacility='
\n' +
' \n' +
' '
p.innerHTML+=newfacility;
}else if(ty=='s'){
var s= document.getElementById('schedule');
var newschedule=''
s.innerHTML+=newschedule;
}else{
alert('非法操作')
}
}
function tijiao(){
//作番号
var facilitynoslist = [];
$(".facilitynos").each(function () {
facilitynoslist.push($(this).val());
});
console.log('11111');
console.log(facilitynoslist);
console.log('22222');
console.log('数据');
//重量
var weightslist = [];
$(".weights").each(function () {
weightslist.push($(this).val());
});
//停数
var numberofstopslist=[];
$(".numberofstops").each(function () {
numberofstopslist.push($(this).val());
});
//楼层数
var numberoffloorslist=[];
$(".numberoffloors").each(function () {
numberoffloorslist.push($(this).val());
});
//开门方式
var opentypeslist=[];
$(".opentypes").each(function () {
opentypeslist.push($(this).val());
});
//速度
var speedslist=[];
$(".speeds").each(function () {
speedslist.push($(this).val());
});
//维护形态
var repairtypeslist=[];
$(".repairtypes").each(function () {
repairtypeslist.push($(this).val());
});
//地址
var addressslist=[];
$(".addresss").each(function () {
addressslist.push($(this).val());
});
//经度
var longitudeslist=[];
$(".longitudes").each(function () {
longitudeslist.push($(this).val());
});
//维度
var latitudeslist=[];
$(".latitudes").each(function () {
latitudeslist.push($(this).val());
});
//维护工号
var repaireridslist=[];
$(".repairerids").each(function () {
repaireridslist.push($(this).val());
});
//维护人员姓名
var repairernameslist=[];
$(".repairernames").each(function () {
repairernameslist.push($(this).val());
});
//合约号
var contractno = $('.contractno').val();
//客户编号
var customerid = $('.customerid').val();
//建档人
var creater = $('.creater').val();
//创建时间
var create_at = $('.create_at').val();
var type = $('.type').val();
var url = "facilityapi.php";
//提交创建
$.ajax({
method: 'post',
url: url,
data: {
facilitynos: JSON.stringify(facilitynoslist),
weights: JSON.stringify(weightslist),
numberofstops:JSON.stringify(numberofstopslist),
numberoffloors:JSON.stringify(numberoffloorslist),
opentypes:JSON.stringify(opentypeslist),
speeds:JSON.stringify(speedslist),
repairtypes:JSON.stringify(repairtypeslist),
addresss:JSON.stringify(addressslist),
longitudes:JSON.stringify(longitudeslist),
latitudes:JSON.stringify(latitudeslist),
repairerids:JSON.stringify(repaireridslist),
repairernames:JSON.stringify(repairernameslist),
type:type,
contractno:contractno,
customerid:customerid,
creater:creater,
create_at:create_at
},
success: function (data) {
var res=eval('('+data+')');
if(res.code=='200'){
window.location.href='custom-create-schedule.php?accountid='+customerid+'&contractno='+contractno;
}else{
alert('添加失败');
}
}
});
}
function tijiaosch(){
//作番号
var facilitynoslist = [];
$(".facilitynos").each(function () {
facilitynoslist.push($(this).val());
});
//保养套餐
var combonoslist=[];
$(".combonos").each(function () {
combonoslist.push($(this).val());
});
//保养日期duedates
var duedateslist=[];
$(".duedates").each(function () {
duedateslist.push($(this).val());
});
//保养工号
var repaireridslist=[];
$(".repairerids").each(function () {
repaireridslist.push($(this).val());
});
//保养人姓名
var repairernameslist=[];
$(".repairernames").each(function () {
repairernameslist.push($(this).val());
});
//合约号
var contractno = $('.contractno').val();
//建档人
var creater = $('.creater').val();
//创建时间
var create_at = $('.create_at').val();
var type = $('.type').val();
var url = "scheduleapi.php";
//提交创建
$.ajax({
method: 'post',
url: url,
data: {
facilitynos: JSON.stringify(facilitynoslist),
combonos:JSON.stringify(combonoslist),
duedates:JSON.stringify(duedateslist),
repairerids:JSON.stringify(repaireridslist),
repairernames:JSON.stringify(repairernameslist),
type:type,
contractno:contractno,
creater:creater,
create_at:create_at
},
success: function (data) {
var res=eval('('+data+')');
if(res.code=='200'){
window.location.href='custom-create.php';
}else{
alert('添加失败,请检查数据');
}
}
});
}
function show(id){
//removeClass
var t = document.getElementById('account');//选取id为test的div元素
t.style.display = 'none';// 隐藏选择的元素
t.style.display = 'block';// 以块级样式显示
}
function login(){
var account = $('.account').val();
var password = $('.password').val();
var url = "loginapi.php";
$.ajax({
method: 'post',
url: url,
data: {
account:account,
password:password
},
success: function (data) {
console.log('返回的结果');
res=eval("("+data+")");
console.log(res);
console.log(window.location.host);
console.log(res.code);
if(res.code=='200'){
var token=res.token;
console.log(token);
window.localStorage.setItem("token",token);
window.location.href='pricereview-index.php?token='+token;
}else{
window.location.href='login.php?errno=1';
}
}
});
}
function settoken(v){
window.localStorage.setItem("token",v);
}
function gettoken(v){
window.localStorage.getItem("token");
}