Commit 486eec8b authored by 王文琼's avatar 王文琼

js

parent db4c8148
mui.plusReady(function() {
// plus.nativeUI.closeWaiting();
plus.nativeUI.showWaiting()
// mui.currentWebview.show();
initPage();
});
function initPage() {
plus.screen.lockOrientation("landscape-primary") //横屏
app.init();
}
var app = new Vue({
el: '#app',
data: {
number: 0,
qty: 0,
size: 0,
dateTime: "",
today: "",
link: "",
itemsDetail: [], //订单明细
itemsDetail1: [], //
itemsDetail2: [], //
paramUnDo: {
pageIndex: 2,
pageSize: 10
},
paramDone: {
pageIndex: 2,
pageSize: 10
},
paramUnDoSeach: {
pageIndex: 2,
pageSize: 10
},
paramDoneSeach: {
pageIndex: 2,
pageSize: 10
},
itemsHead: [], //未完成和搜索左侧数组
itemsLeft: [],
itemsLeft2: [], //已完成左侧数组
itemsSize: [],
SizeQty: [],
ReportType: 0,
IndexID: 0,
rightInfor: [], //右侧详情
cur: 0, //点击选中当前状态
completeState: true, //切换已完成和未完成状态
searchText: '', //搜索框输入的内容
datalen: 20, //默认取数据数量
reDatalen: 10, //每次加载的数据数量
isAlert: false,
disable_reportDelete: 'disabled',
disable_qq: 'disabled',
ReportID: 0,
// Report_IndexID: 0,
Model: 0,
CompleteRatio: 0, //完成进度
unPagenum: 1, //未完成页数
pagenum: 1, //已完成页数
displayModel: 1,
zhezhao: 1, //
mask_: mui.createMask(function(e) {
return false;
}),
appdis: 0,
searchData: [{
id: '0',
name: '指令号'
},
{
id: '1',
name: '订单号'
},
{
id: '2',
name: '货号'
}
],
current: '', //搜索选中
},
computed: {
disable_save_button_C: function() {
if (this.size != 0 && this.qty != 0 && this.IndexID != 0 && this.Model == 0) {
return null;
} else {
return 'disabled';
}
},
display_: function() {
if (this.displayModel == 1) {
return "display: none "
}
},
SOP__: function() {
if (this.IndexID == 0) {
return "disabled"
} else {
return null
}
},
},
// mounted:function(){
// this.$nextTick(function(){
// mui('#progress .mui-text-center').each(function() {
// console.log(this.getAttribute("data-progress"));
// mui(this).progressbar({progress:this.getAttribute("data-progress")}).show()
// })
// })
// },
created() {
//如果没有这句代码,select中初始化会是空白的,默认选中就无法实现
this.current = this.searchData[0].id;
},
methods: {
init: function() { //初始化
mui.init({
pullRefresh: {
container: '#pullrefresh',
up: {
height: 100,
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了',
callback: function() {
var reUnfinished = document.getElementById("theOne").getAttribute("state");
var reFinished = document.getElementById("theTow").getAttribute("state");
var UnfinishedUrl = '/api/vMES/CutOffProductionReport/ToDo';
var FinishedUrl = '/api/vMES/CutOffProductionReport/Done';
var searchUrl = '/api/vMES/CutOffProductionReport/Search';
var searchDoneUrl = '/api/vMES/CutOffProductionReport/SearchDone';
//console.log("未完成" + reUnfinished)
//console.log("已完成" + reFinished)
var UnfinishedData = app.itemsHead;
var FinishedUrlData = app.itemsLeft2;
if (reUnfinished) { //未完成
if (app.searchText != "") {
searchPull(searchUrl, UnfinishedData, app.paramUnDoSeach);
} else {
pullupRefresh(UnfinishedUrl, UnfinishedData, app.paramUnDo);
}
} else if (reFinished) { //已完成
if (app.searchText != "") {
searchPull(searchDoneUrl, FinishedUrlData, app.paramDoneSeach);
} else {
pullupRefresh(FinishedUrl, FinishedUrlData, app.paramDone);
}
}
}
},
}
});
function pullupRefresh(url, arr, params) {
//console.log("加载前1" + arr);
setTimeout(function() {
var para = {
PageSize: params.pageSize,
PageIndex: params.pageIndex
};
//console.log("canshu:" + JSON.stringify(para));
//console.log("之前的数据:" + arr);
Api.post(url, para, function(e) { //2.没数据 提示 但是可以一直发请求只不过传回来是空
if (e.success) {
//console.log("111:" + JSON.stringify(e.items));
var data = e.items;
if (e.items.length > 0) {
params.pageIndex++;
}
for (var i = 0; i < data.length; i++) {
arr.push(data[i]);
//console.log("changdu2222222:"+arr.length);
}
}
}, function(b, bb, bbb) {
mui.toast(JSON.stringify(bbb.message))
});
mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //参数为true代表没有更多数据了。
mui('#pullrefresh').pullRefresh().refresh(true);
//mui('#pullrefresh').pullRefresh().disablePullupToRefresh();
}, 1000);
}
function searchPull(url, arr, params) {
setTimeout(function() {
var para = {
searchText: app.searchText,
PageSize: params.pageSize,
PageIndex: params.pageIndex
};
Api.post(url, para, function(e) {
if (e.success) {
//console.log("111:" + JSON.stringify(e.items));
var data = e.items;
if (e.items.length > 0) {
params.pageIndex++;
}
for (var i = 0; i < data.length; i++) {
arr.push(data[i]);
}
//console.log("canshuqq:" + JSON.stringify(para));
}
}, function(b, bb, bbb) {
mui.toast(JSON.stringify(bbb.message))
});
mui('#pullrefresh').pullRefresh().endPullupToRefresh();
mui('#pullrefresh').pullRefresh().refresh(true);
}, 1000);
}
window.addEventListener('back', function(e) {
var that = this;
//app.getData();
//app.ChangeState(1);
});
mui(".mui-icon-clear")[0].addEventListener('tap', function() {
document.activeElement.blur(); //收起虚拟键盘
app.searchText = '';
app.completeState ? app.ChangeState(1) : app.ChangeState(2);
//console.log('1111');
});
setTimeout(function() {
plus.nativeUI.closeWaiting();
var ap = document.getElementById("app");
ap.style = " display: inline-block";
}, 200)
mui('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
});
this.dateTime = moment().format().substring(0, 10)
this.today = this.dateTime;
this.getData();
},
getData: function() {
var that = this;
this.createZhezhao(-1)
var para = {
PageSize: that.datalen,
PageIndex: that.unPagenum
};
//console.log("lalla" + JSON.stringify(para));
that.cur = 0;
Api.post('/api/vMES/CutOffProductionReport/ToDo', para, function(e) {
console.log("one :::;" + JSON.stringify(e.items.length))
console.log("getData:" + JSON.stringify(e.items[0]))
//console.log("点击之前"+JSON.stringify(that.rightInfor))
if (e.items.length > 0) {
that.itemsHead = e.items;
that.rightInfor = e.items[0];
that.itemsDetail = e.items[0];
that.IndexID = e.items[0].IndexID;
//that.ChangeState(1);
that.getTatolNum();
that.qty = 0;
that.disable_reportDelete = 'disabled';
that.sizeArr();
} else {
that.itemsHead = [];
that.rightInfor = [];
that.itemsDetail = [];
that.IndexID = 0;
that.itemsDetail1 = [];
that.itemsSize = [];
that.size = 0;
that.itemsLeft = [];
that.number = 0;
that.qty = 0;
that.disable_reportDelete = 'disabled'
//that.ChangeState(1);
that.getTatolNum();
}
}, function(xhr, type, res) {
//console.log(bbb);
mui.toast(JSON.stringify(res.message))
});
},
getDetailInfor: function(idInfor, index) { //获取实报详细 未完成,已完成的的尺码明细信息
this.IndexID = idInfor;
var that = this;
that.cur = index;
//that.searchText = '';
var para = {
"IndexID": idInfor
};
that.ReportID = idInfor;
Api.post('/api/vMES/CutOffProductionReport/Detail', para, function(e) {
if (e.success) {
that.rightInfor = e.data;
console.log("点击之后" + JSON.stringify(that.rightInfor))
that.itemsDetail = e.data;
that.sizeArr();
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
},
sizeArr: function() {
var that = this;
that.itemsSize = [];
that.itemsDetail.ReportDetail.forEach(function(item, index) {
that.itemsSize.push(item.SizeName);
})
console.log("size::" + JSON.stringify(that.itemsSize));
},
selectDisplay: function(n) {
//console.log("selectDisplay:" + n)
this.ChangeState(n); //n=1 未完成 ,2已完成
n == 1 ? this.completeState = true : this.completeState = false;
},
ChangeState: function(n) { //改变状态,切换已完成和未完成
//n= 1 未完成 n=2 已完成
var that = this;
// console.log(JSON.stringify(para))
if (n == 1) {
var para = {
PageSize: that.datalen,
PageIndex: that.unPagenum
};
that.searchText = '';
that.disable_reportDelete = "disabled";
Api.post('/api/vMES/CutOffProductionReport/ToDo', para, function(e) {
that.cur = 0;
if (e.items.length > 0) {
that.itemsHead = e.items;
that.rightInfor = e.items[0];
that.itemsDetail = e.items[0];
console.log("weiwancheng111" + JSON.stringify(that.itemsHead));
that.IndexID = that.itemsHead[0].IndexID;
that.sizeArr();
} else {
that.itemsHead = [];
that.rightInfor = [];
that.itemsDetail = [];
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
} else if (n == 2) {
var para = {
PageSize: that.datalen,
PageIndex: that.pagenum
};
//console.log("do para " + JSON.stringify(para))
that.disable_reportDelete = null;
that.searchText = '';
Api.post('/api/vMES/CutOffProductionReport/Done', para, function(e) {
console.log("已完成" + JSON.stringify(para))
var data = e.items.length;
if (data > 0) {
that.itemsLeft2 = e.items;
that.rightInfor = e.items[0];
that.cur = 0;
that.itemsDetail = e.items[0];
that.IndexID = that.itemsLeft2[0].IndexID;
that.sizeArr();
} else {
that.rightInfor = [];
that.itemsLeft2 = [];
that.itemsDetail = [];
that.cur = 0;
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
}
},
goSearch: function(event) {
var that = this;
var para = {
SearchText: that.searchText,
PageSize: 20,
PageIndex: that.pagenum,
};
if (event.keyCode == "13") {
document.activeElement.blur(); //收起虚拟键盘
if (that.searchText == '') return;
if (this.completeState) { //true 是未完成的搜索 false是已完成的搜索
Api.post('/api/vMES/CutOffProductionReport/Search', para, function(e) {
console.log("现在是未完成的搜索!");
var data = e.items.length;
if (data > 0) {
that.itemsHead = e.items;
console.log("未完成的搜索111" + JSON.stringify(that.itemsHead));
that.rightInfor = e.items[0];
that.itemsDetail = e.items[0];
that.cur = 0;
} else {
that.itemsHead = [];
that.rightInfor = [];
that.itemsDetail = [];
that.cur = 0;
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
} else {
Api.post('/api/vMES/CutOffProductionReport/SearchDone', para, function(e) {
console.log("现在是以111111完成的搜索!");
var data = e.items.length;
if (data > 0) {
that.itemsLeft2 = e.items;
that.rightInfor = e.items[0];
that.itemsDetail = e.items[0];
that.cur = 0;
} else {
that.itemsLeft2 = [];
that.rightInfor = [];
that.itemsDetail = [];
that.cur = 0;
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
}
event.preventDefault(); // 阻止默认事件---阻止页面刷新
//that.searchText = '';
}
},
getTatolNum: function() { //今日产量
var that = this;
var para = {
ReportType: this.ReportType,
Date: this.dateTime + " 00:00:00",
};
Api.post('/api/vMES/ProductionReport/TotalQty', para, function(e) {
if (e.success) {
that.number = e.data;
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
},
//完成进度
getCompleteRatio: function(n) {
var that = this;
var para = {
IndexID: n
};
if (n == 0) {
return;
}
// console.log(JSON.stringify(para))
Api.post('/api/vMES/ProductionReport/IndexNoCompleteRatio', para, function(e) {
that.CompleteRatio = e.data;
// console.log(JSON.stringify(e))
for (var i = 0; i < that.itemsHead.length; i++) {
if (that.itemsHead[i].IndexID == n) {
that.itemsHead[i].CompleteRatio = that.CompleteRatio;
// console.log(that.CompleteRatio);
}
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
},
reportDelete: function() { //
var that = this;
var para = {
ReportID: this.IndexID,
};
console.log(JSON.stringify(para)); //如果列表为空,弹出提示没有可以撤回的时报
Api.post('/api/vMES/ProductionReport/Delete', para, function(e) {
if (e.success) {
//console.log(JSON.stringify(e));
that.createZhezhao(-1)
that.size = 0;
that.qty = 0;
//that.getCompleteRatio(that.Report_IndexID); //订单进度
that.selectSize(0);
that.getTatolNum(); //获取今日完成数量
that.Model = 0;
mui.toast("撤回成功");
playVoice("cg.mp3");
console.log("删除的id11111111111:" + JSON.stringify(para));
var doneIndexArr = that.itemsLeft2;
var delIndexNoIndx = -1;
for (var i = 0; i < doneIndexArr.length; i++) {
//console.log("比对的id:" + doneIndexArr[i].IndexID);
if (doneIndexArr[i].IndexID == para.ReportID) {
delIndexNoIndx = i;
break;
}
}
doneIndexArr.splice(delIndexNoIndx, 1);
if (doneIndexArr.length > 0) {
if (doneIndexArr.length - 1 >= delIndexNoIndx) {
that.cur = delIndexNoIndx;
that.rightInfor = doneIndexArr[delIndexNoIndx];
that.itemsDetail = doneIndexArr[delIndexNoIndx];
that.IndexID = doneIndexArr[delIndexNoIndx].IndexID;
} else {
that.cur = doneIndexArr.length - 1;
that.rightInfor = doneIndexArr[delIndexNoIndx - 1];
that.itemsDetail = doneIndexArr[delIndexNoIndx - 1];
that.IndexID = doneIndexArr[doneIndexArr.length - 1].IndexID;
}
that.getDetailInfor(that.IndexID, that.cur);
}
} else {
mui.toast("撤回失败" + e.message);
}
}, function(xhr, type, res) {
playVoice("sb.mp3");
mui.toast(JSON.stringify(res.message))
});
},
getLink: function() {
var that = this;
var para = {
ReportType: this.ReportType,
StyleCode: this.itemsDetail.StyleCode
}
console.log(JSON.stringify(para))
Api.post('/api/vMES/Sop/StyleSop', para, function(e) {
if (e.success) {
// console.log( JSON.stringify(e))
that.link = e.data.Url;
var url_ = "sop.html";
var id_ = "sop.html";
mui.openWindow({
url: url_,
id: id_,
extras: {
style: that.itemsDetail.StyleCode,
ReportType: that.ReportType,
link: that.link,
parentPage: "Cutting.html"
},
});
} else {
mui.toast("获取sop地址失败: " + e.message)
}
}, function(xhr, type, res) {
mui.toast(JSON.stringify(res.message))
});
},
SizeQtyA: function() {
for (var i = 0; i < this.itemsSize.length; i++) {
var tempa = {
size: this.itemsSize[i],
qty: 0
}
this.SizeQty.push(tempa);
}
},
submit: function() {
if (!this.checkValue()) {
playVoice("sb.mp3");
return;
}
var para = {
IndexID: this.IndexID,
SizeName: this.size,
Qty: this.qty,
}
var that = this;
Api.post('/api/vMES/ProductionReport/Save', para, function(e) {
if (e.success) {
// that.disable_save_button = 'disabled'
that.size = 0;
that.qty = 0;
that.selectSize(0);
//that.getDataDetail1(); //获取列表尺码对应数量
that.getTatolNum(); //获取今日完成数量
that.getCompleteRatio(that.IndexID) //订单进度
playVoice("cg.mp3");
that.getDetailInfor(that.IndexID, that.cur)
//console.log("mmmmmmmmmmmmmmmmmmmmmmmm")
mui.toast("提交成功");
} else {
mui.toast("提交失败: " + e.message);
}
}, function(xhr, type, res) {
playVoice("sb.mp3");
mui.toast(JSON.stringify(res.message))
});
},
sureSubmit: function(num) {
console.log("num:" + num);
if (num == "0") {
var that = this;
var para = {
ReportType: this.ReportType,
IndexID: that.IndexID,
}
console.log(JSON.stringify(that.rightInfor));
// console.log(JSON.stringify(para));
Api.post('/api/vMES/ProductionReport/SingleComplete', para, function(e) {
if (e.success) {
// that.disable_save_button = 'disabled'
that.size = 0;
that.qty = 0;
that.selectSize(0);
that.getTatolNum(); //获取今日完成数量
//that.ChangeState(1);
//that.getCompleteRatio(that.IndexID) //订单进度
playVoice("cg.mp3");
mui.toast("提交成功");
var todoIndexArr = that.itemsHead;
var delIndexNoIndx = -1;
for (var i = 0; i < todoIndexArr.length; i++) {
if (todoIndexArr[i].IndexID == para.IndexID)
delIndexNoIndx = i;
}
todoIndexArr.splice(delIndexNoIndx, 1);
if (todoIndexArr.length > 0) {
if (todoIndexArr.length - 1 > delIndexNoIndx) {
that.cur = delIndexNoIndx;
that.rightInfor = todoIndexArr[delIndexNoIndx];
that.itemsDetail = todoIndexArr[delIndexNoIndx]
that.IndexID = todoIndexArr[delIndexNoIndx].IndexID;
} else {
that.cur = todoIndexArr.length - 1;
that.rightInfor = todoIndexArr[delIndexNoIndx - 1];
that.itemsDetail = todoIndexArr[delIndexNoIndx - 1];
that.IndexID = todoIndexArr[todoIndexArr.length - 1].IndexID;
}
that.getDetailInfor(that.IndexID, that.cur);
}
} else {
mui.toast("提交失败: " + e.message);
}
}, function(xhr, type, res) {
playVoice("sb.mp3");
mui.toast(JSON.stringify(res.message))
});
that.isAlert = false;
} else {
this.isAlert = false;
return;
}
},
submitZD: function() {
this.isAlert = true;
},
selectIndex: function(idx) {
this.createZhezhao(-1) //关闭遮罩
var indxx = document.getElementsByClassName("Index");
var indx = document.getElementById("Index_" + idx)
for (var i = 0; i < indxx.length; i++) {
indxx[i].style.background = "";
}
indx.style.background = "#02C1ED";
this.IndexID = idx
this.Model = 0
if (this.IndexID != 0) {
that.ChangeState(1);
that.ChangeState(2);
this.getTatolNum();
this.selectSize(0);
//this.selectReport(0);
this.qty = 0;
this.size = 0;
//this.disable_reportDelete = 'disabled';
} else {
this.itemsDetail = [];
this.IndexID = 0;
this.itemsDetail1 = [];
this.itemsSize = [];
this.size = 0;
this.itemsLeft = [];
this.number = 0;
this.qty = 0;
//this.disable_reportDelete = 'disabled'
}
mui('.scroll1').scroll().scrollTo(0, 0, 100);
mui('.scroll2').scroll().scrollTo(0, 0, 100);
// mui('.scroll3').scroll().scrollTo(0,0,100);
mui('.scroll4').scroll().scrollTo(0, 0, 100);
},
createZhezhao: function(n) {
// console.log(n)
if (n == -1) {
// var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
// this.mask_.close();
this.mask_._remove()
this.zhezhao = 1;
} else {
if (this.zhezhao == 1) {
this.mask_.show(); //显示遮罩
this.zhezhao = 2
// mask.close();//关闭遮罩
}
}
},
changeValue: function() {
if (isNaN(parseInt(this.qty))) {
this.qty = 0;
// this.disable_save_button = 'disabled';
}
if (parseInt(this.qty) > 0) {
this.qty = parseInt(this.qty);
// this.disable_save_button = null;
}
},
checkValue: function() {
//数量不正确
if (isNaN(parseInt(this.qty)) || parseInt(this.qty) <= 0) {
mui.toast("数量不正确")
return false;
}
//尺码不正确
else if (this.size == 0) {
mui.toast("尺码不正确")
return false;
} else if (this.IndexID == 0) {
mui.toast("订单号不正确")
return false;
} else {
return true;
}
},
backNumber: function() {
if (this.Model == 1) {
return;
}
var str = this.qty.toString();
this.qty = str.substring(0, str.length - 1);
},
selectNumber: function(n) {
if (this.Model == 1) {
return;
}
this.qty = this.qty.toString() + n.toString();
// this.qty = isNaN(parseInt(this.qty)) ? 0 + parseInt(n) : parseInt(this.qty) + parseInt(n);
},
selectSize: function(n) {
var bg = document.getElementsByClassName("bg");
for (var i = 0; i < bg.length; i++) {
bg[i].style.background = ""
if (bg[i].innerHTML == n) {
bg[i].style.background = "#02C1ED"
}
}
if (n != 0) {
this.size = n;
// bg[0].style.background = "#02C1ED"
}
},
nextday: function(n) {
this.createZhezhao(-1)
var d = new Date(this.dateTime);
d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * n);
if (d.getDate().toString().length == 1) {
this.dateTime = d.getFullYear() + "-" + (d.getMonth() + 1) + "-0" + d.getDate();
} else {
this.dateTime = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
}
this.getData();
mui('.scroll1').scroll().scrollTo(0, 0, 100);
mui('.scroll2').scroll().scrollTo(0, 0, 100);
mui('.scroll3').scroll().scrollTo(0, 0, 100);
mui('.scroll4').scroll().scrollTo(0, 0, 100);
},
stylebg: function(n) {
if (n == 0) {
return {
"background": "#02C1ED"
}
}
},
nextPage: function(n, k) {
var url_;
var id_;
url_ = "CuttingQuality.html";
id_ = "CuttingQuality.html";
var detail = {
IndexID: this.IndexID,
dateTime: this.dateTime,
itemsDetail: this.itemsDetail,
itemsSize: this.itemsSize, //
type: n, // n =2 点击不合格进去 ,
parentSize: k,
sizeNum: this.rightInfor.ReportDetail //尺码和数量
}
console.log("品质问题:" + JSON.stringify(detail));
mui.openWindow({
url: url_,
id: id_,
extras: {
IndexID: this.IndexID,
dateTime: this.dateTime,
itemsDetail: this.itemsDetail,
itemsSize: this.itemsSize,
type: n, // n =2 点击不合格进去 ,
parentSize: k,
sizeNum: this.itemsDetail1, //尺码和数量
ReportType: this.ReportType
},
});
},
sop: function() {
this.getLink();
},
selecttime: function() {
var that = this;
var _self = document.getElementById("selectdate")
if (_self.picker) {
_self.picker.show(function(rs) {
_self.innerText = rs.text
_self.picker.dispose();
_self.picker = null;
});
} else {
var optionsJson = _self.getAttribute('data-options') || '{}';
var options = JSON.parse(optionsJson);
var id = _self.getAttribute('id');
/*
* 首次显示时实例化组件
* 示例为了简洁,将 options 放在了按钮的 dom 上
* 也可以直接通过代码声明 optinos 用于实例化 DtPicker
*/
_self.picker = new mui.DtPicker(options);
_self.picker.show(function(rs) {
/*
* rs.value 拼合后的 value
* rs.text 拼合后的 text
* rs.y 年,可以通过 rs.y.vaue 和 rs.y.text 获取值和文本
* rs.m 月,用法同年
* rs.d 日,用法同年
* rs.h 时,用法同年
* rs.i 分(minutes 的第二个字母),用法同年
*/
_self.innerText = rs.text;
that.dateTime = rs.text;
that.getData();
/*
* 返回 false 可以阻止选择框的关闭
* return false;
*/
/*
* 释放组件资源,释放后将将不能再操作组件
* 通常情况下,不需要示放组件,new DtPicker(options) 后,可以一直使用。
* 当前示例,因为内容较多,如不进行资原释放,在某些设备上会较慢。
* 所以每次用完便立即调用 dispose 进行释放,下次用时再创建新实例。
*/
_self.picker.dispose();
_self.picker = null;
});
}
mui('.scroll1').scroll().scrollTo(0, 0, 100);
mui('.scroll2').scroll().scrollTo(0, 0, 100);
mui('.scroll3').scroll().scrollTo(0, 0, 100);
mui('.scroll4').scroll().scrollTo(0, 0, 100);
}, //selecttime
back: function() {
console.log("back")
mui.back()
// plus.screen.lockOrientation("portrait-primary") //横屏
},
changePosition: function() {
var btn1 = document.getElementById("changePosition");
var Height = document.documentElement.clientHeight || document.body.clientHeight;
//console.log("得到焦点。。。。" + Height);
window.onresize = function() {
var Height1 = document.documentElement.clientHeight || document.body.clientHeight;
//console.log("得到焦点。。。。" + Height1);
if (Height > Height1) {
btn1.style.display = "none";
} else {
btn1.style.display = "block";
}
}
},
changePosition1: function() {
var btn1 = document.getElementById("changePosition");
var Height = document.documentElement.clientHeight || document.body.clientHeight;
window.onresize = function() {
var Height1 = document.documentElement.clientHeight || document.body.clientHeight;
if (Height < Height1) {
btn1.style.display = "block";
} else {
btn1.style.display = "none";
}
}
}
}
})
/**
* 选择列表插件
* varstion 2.0.0
* by Houfeng
* Houfeng@DCloud.io
**/
! function(e, t, i, n) {
var a = 30,
r = 90,
s = 40,
c = 10,
l = e.rad2deg = function(e) {
return e / (Math.PI / 180)
},
o = (e.deg2rad = function(e) {
return e * (Math.PI / 180)
}, navigator.platform.toLowerCase()),
d = navigator.userAgent.toLowerCase(),
u = (d.indexOf("iphone") > -1 || d.indexOf("ipad") > -1 || d.indexOf("ipod") > -1) && (o.indexOf("iphone") > -1 || o.indexOf(
"ipad") > -1 || o.indexOf("ipod") > -1),
p = e.Picker = function(e, t) {
var i = this;
i.holder = e, i.options = t || {}, i.init(), i.initInertiaParams(), i.calcElementItemPostion(!0), i.bindEvent()
};
p.prototype.findElementItems = function() {
var e = this;
return e.elementItems = [].slice.call(e.holder.querySelectorAll("li")), e.elementItems
}, p.prototype.init = function() {
var e = this;
e.list = e.holder.querySelector("ul"), e.findElementItems(), e.height = e.holder.offsetHeight, e.r = e.height / 2 -
c, e.d = 2 * e.r, e.itemHeight = e.elementItems.length > 0 ? e.elementItems[0].offsetHeight : s, e.itemAngle =
parseInt(e.calcAngle(.8 * e.itemHeight)), e.hightlightRange = e.itemAngle / 2, e.visibleRange = r, e.beginAngle = 0,
e.beginExceed = e.beginAngle - a, e.list.angle = e.beginAngle, u && (e.list.style.webkitTransformOrigin =
"center center " + e.r + "px")
}, p.prototype.calcElementItemPostion = function(e) {
var t = this;
e && (t.items = []), t.elementItems.forEach(function(i) {
var n = t.elementItems.indexOf(i);
if (t.endAngle = t.itemAngle * n, i.angle = t.endAngle, i.style.webkitTransformOrigin = "center center -" + t.r +
"px", i.style.webkitTransform = "translateZ(" + t.r + "px) rotateX(" + -t.endAngle + "deg)", e) {
var a = {};
a.text = i.innerHTML || "", a.value = i.getAttribute("data-value") || a.text, t.items.push(a)
}
}), t.endExceed = t.endAngle + a, t.calcElementItemVisibility(t.beginAngle)
}, p.prototype.calcAngle = function(e) {
var t = this,
i = b = parseFloat(t.r);
e = Math.abs(e);
var n = 180 * parseInt(e / t.d);
e %= t.d;
var a = (i * i + b * b - e * e) / (2 * i * b),
r = n + l(Math.acos(a));
return r
}, p.prototype.calcElementItemVisibility = function(e) {
var t = this;
t.elementItems.forEach(function(i) {
var n = Math.abs(i.angle - e);
n < t.hightlightRange ? i.classList.add("highlight") : n < t.visibleRange ? (i.classList.add("visible"), i.classList
.remove("highlight")) : (i.classList.remove("highlight"), i.classList.remove("visible"))
})
}, p.prototype.setAngle = function(e) {
var t = this;
t.list.angle = e, t.list.style.webkitTransform = "perspective(1000px) rotateY(0deg) rotateX(" + e + "deg)", t.calcElementItemVisibility(
e)
}, p.prototype.bindEvent = function() {
var t = this,
i = 0,
n = null,
a = !1;
t.holder.addEventListener(e.EVENT_START, function(e) {
a = !0, e.preventDefault(), t.list.style.webkitTransition = "", n = (e.changedTouches ? e.changedTouches[0] : e).pageY,
i = t.list.angle, t.updateInertiaParams(e, !0)
}, !1), t.holder.addEventListener(e.EVENT_END, function(e) {
a = !1, e.preventDefault(), t.startInertiaScroll(e)
}, !1), t.holder.addEventListener(e.EVENT_CANCEL, function(e) {
a = !1, e.preventDefault(), t.startInertiaScroll(e)
}, !1), t.holder.addEventListener(e.EVENT_MOVE, function(e) {
if (a) {
e.preventDefault();
var r = (e.changedTouches ? e.changedTouches[0] : e).pageY,
s = r - n,
c = t.calcAngle(s),
l = s > 0 ? i - c : i + c;
l > t.endExceed && (l = t.endExceed), l < t.beginExceed && (l = t.beginExceed), t.setAngle(l), t.updateInertiaParams(
e)
}
}, !1), t.list.addEventListener("tap", function(e) {
elementItem = e.target, "LI" == elementItem.tagName && t.setSelectedIndex(t.elementItems.indexOf(elementItem),
200)
}, !1)
}, p.prototype.initInertiaParams = function() {
var e = this;
e.lastMoveTime = 0, e.lastMoveStart = 0, e.stopInertiaMove = !1
}, p.prototype.updateInertiaParams = function(e, t) {
var i = this,
n = e.changedTouches ? e.changedTouches[0] : e;
if (t) i.lastMoveStart = n.pageY, i.lastMoveTime = e.timeStamp || Date.now(), i.startAngle = i.list.angle;
else {
var a = e.timeStamp || Date.now();
a - i.lastMoveTime > 300 && (i.lastMoveTime = a, i.lastMoveStart = n.pageY)
}
i.stopInertiaMove = !0
}, p.prototype.startInertiaScroll = function(e) {
var t = this,
i = e.changedTouches ? e.changedTouches[0] : e,
n = e.timeStamp || Date.now(),
a = (i.pageY - t.lastMoveStart) / (n - t.lastMoveTime),
r = a > 0 ? -1 : 1,
s = 6e-4 * r * -1,
c = Math.abs(a / s),
l = a * c / 2,
o = t.list.angle,
d = t.calcAngle(l) * r,
u = d;
return o + d < t.beginExceed && (d = t.beginExceed - o, c = c * (d / u) * .6), o + d > t.endExceed && (d = t.endExceed -
o, c = c * (d / u) * .6), 0 == d ? void t.endScroll() : void t.scrollDistAngle(n, o, d, c)
}, p.prototype.scrollDistAngle = function(e, t, i, n) {
var a = this;
a.stopInertiaMove = !1,
function(e, t, i, n) {
var r = 13,
s = n / r,
c = 0;
! function l() {
if (!a.stopInertiaMove) {
var e = a.quartEaseOut(c, t, i, s);
return a.setAngle(e), c++, c > s - 1 || e < a.beginExceed || e > a.endExceed ? void a.endScroll() : void setTimeout(
l, r)
}
}()
}(e, t, i, n)
}, p.prototype.quartEaseOut = function(e, t, i, n) {
return -i * ((e = e / n - 1) * e * e * e - 1) + t
}, p.prototype.endScroll = function() {
var e = this;
if (e.list.angle < e.beginAngle) e.list.style.webkitTransition = "150ms ease-out", e.setAngle(e.beginAngle);
else if (e.list.angle > e.endAngle) e.list.style.webkitTransition = "150ms ease-out", e.setAngle(e.endAngle);
else {
var t = parseInt((e.list.angle / e.itemAngle).toFixed(0));
e.list.style.webkitTransition = "100ms ease-out", e.setAngle(e.itemAngle * t)
}
e.triggerChange()
}, p.prototype.triggerChange = function(t) {
var i = this;
setTimeout(function() {
var n = i.getSelectedIndex(),
a = i.items[n];
!e.trigger || n == i.lastIndex && t !== !0 || e.trigger(i.holder, "change", {
index: n,
item: a
}), i.lastIndex = n, "function" == typeof t && t()
}, 0)
}, p.prototype.correctAngle = function(e) {
var t = this;
return e < t.beginAngle ? t.beginAngle : e > t.endAngle ? t.endAngle : e
}, p.prototype.setItems = function(e) {
var t = this;
t.items = e || [];
var i = [];
t.items.forEach(function(e) {
null !== e && e !== n && i.push("<li>" + (e.text || e) + "</li>")
}), t.list.innerHTML = i.join(""), t.findElementItems(), t.calcElementItemPostion(), t.setAngle(t.correctAngle(t.list
.angle)), t.triggerChange(!0)
}, p.prototype.getItems = function() {
var e = this;
return e.items
}, p.prototype.getSelectedIndex = function() {
var e = this;
return parseInt((e.list.angle / e.itemAngle).toFixed(0))
}, p.prototype.setSelectedIndex = function(e, t, i) {
var n = this;
n.list.style.webkitTransition = "";
var a = n.correctAngle(n.itemAngle * e);
if (t && t > 0) {
var r = a - n.list.angle;
n.scrollDistAngle(Date.now(), n.list.angle, r, t)
} else n.setAngle(a);
n.triggerChange(i)
}, p.prototype.getSelectedItem = function() {
var e = this;
return e.items[e.getSelectedIndex()]
}, p.prototype.getSelectedValue = function() {
var e = this;
return (e.items[e.getSelectedIndex()] || {}).value
}, p.prototype.getSelectedText = function() {
var e = this;
return (e.items[e.getSelectedIndex()] || {}).text
}, p.prototype.setSelectedValue = function(e, t, i) {
var n = this;
for (var a in n.items) {
var r = n.items[a];
if (r.value == e) return void n.setSelectedIndex(a, t, i)
}
}, e.fn && (e.fn.picker = function(e) {
return this.each(function(t, i) {
if (!i.picker)
if (e) i.picker = new p(i, e);
else {
var n = i.getAttribute("data-picker-options"),
a = n ? JSON.parse(n) : {};
i.picker = new p(i, a)
}
}), this[0] ? this[0].picker : null
}, e.ready(function() {
e(".mui-picker").picker()
}))
}(window.mui || window, window, document, void 0),
function(e, t) {
e.dom = function(i) {
return "string" != typeof i ? i instanceof Array || i[0] && i.length ? [].slice.call(i) : [i] : (e.__create_dom_div__ ||
(e.__create_dom_div__ = t.createElement("div")), e.__create_dom_div__.innerHTML = i, [].slice.call(e.__create_dom_div__
.childNodes))
};
var i =
'<div class="mui-poppicker"> <div class="mui-poppicker-header"> <button class="mui-btn mui-poppicker-btn-cancel">取消</button> <button class="mui-btn mui-btn-blue mui-poppicker-btn-ok">确定</button> <div class="mui-poppicker-clear"></div> </div> <div class="mui-poppicker-body"> </div> </div>',
n =
'<div class="mui-picker"> <div class="mui-picker-inner"> <div class="mui-pciker-rule mui-pciker-rule-ft"></div> <ul class="mui-pciker-list"> </ul> <div class="mui-pciker-rule mui-pciker-rule-bg"></div> </div> </div>';
e.PopPicker = e.Class.extend({
init: function(n) {
var a = this;
a.options = n || {}, a.options.buttons = a.options.buttons || ["取消", "确定"], a.panel = e.dom(i)[0], t.body.appendChild(
a.panel), a.ok = a.panel.querySelector(".mui-poppicker-btn-ok"), a.cancel = a.panel.querySelector(
".mui-poppicker-btn-cancel"), a.body = a.panel.querySelector(".mui-poppicker-body"), a.mask = e.createMask(), a
.cancel.innerText = a.options.buttons[0], a.ok.innerText = a.options.buttons[1], a.cancel.addEventListener("tap",
function(e) {
a.hide()
}, !1), a.ok.addEventListener("tap", function(e) {
if (a.callback) {
var t = a.callback(a.getSelectedItems());
t !== !1 && a.hide()
}
}, !1), a.mask[0].addEventListener("tap", function() {
a.hide()
}, !1), a._createPicker(), a.panel.addEventListener(e.EVENT_START, function(e) {
e.preventDefault()
}, !1), a.panel.addEventListener(e.EVENT_MOVE, function(e) {
e.preventDefault()
}, !1)
},
_createPicker: function() {
var t = this,
i = t.options.layer || 1,
a = 100 / i + "%";
t.pickers = [];
for (var r = 1; i >= r; r++) {
var s = e.dom(n)[0];
s.style.width = a, t.body.appendChild(s);
var c = e(s).picker();
t.pickers.push(c), s.addEventListener("change", function(e) {
var t = this.nextSibling;
if (t && t.picker) {
var i = e.detail || {},
n = i.item || {};
t.picker.setItems(n.children)
}
}, !1)
}
},
setData: function(e) {
var t = this;
e = e || [], t.pickers[0].setItems(e)
},
getSelectedItems: function() {
var e = this,
t = [];
for (var i in e.pickers) {
var n = e.pickers[i];
t.push(n.getSelectedItem() || {})
}
return t
},
show: function(i) {
var n = this;
n.callback = i, n.mask.show(), t.body.classList.add(e.className("poppicker-active-for-page")), n.panel.classList.add(
e.className("active")), n.__back = e.back, e.back = function() {
n.hide()
}
},
hide: function() {
var i = this;
i.disposed || (i.panel.classList.remove(e.className("active")), i.mask.close(), t.body.classList.remove(e.className(
"poppicker-active-for-page")), e.back = i.__back)
},
dispose: function() {
var e = this;
e.hide(), setTimeout(function() {
e.panel.parentNode.removeChild(e.panel);
for (var t in e) e[t] = null, delete e[t];
e.disposed = !0
}, 300)
}
})
}(mui, document),
function(e, t) {
e.dom = function(i) {
return "string" != typeof i ? i instanceof Array || i[0] && i.length ? [].slice.call(i) : [i] : (e.__create_dom_div__ ||
(e.__create_dom_div__ = t.createElement("div")), e.__create_dom_div__.innerHTML = i, [].slice.call(e.__create_dom_div__
.childNodes))
};
var i =
'<div class="mui-dtpicker" data-type="datetime"> <div class="mui-dtpicker-header"> <button data-id="btn-cancel" class="mui-btn" id="quxiao">取消</button> <button data-id="btn-ok" id="queding" class="mui-btn mui-btn-blue">确定</button> </div> <div class="mui-dtpicker-title"><h5 data-id="title-y">年</h5><h5 data-id="title-m">月</h5><h5 data-id="title-d">日</h5><h5 data-id="title-h">时</h5><h5 data-id="title-i">分</h5></div> <div class="mui-dtpicker-body"> <div data-id="picker-y" class="mui-picker"> <div class="mui-picker-inner"> <div class="mui-pciker-rule mui-pciker-rule-ft"></div> <ul class="mui-pciker-list"> </ul> <div class="mui-pciker-rule mui-pciker-rule-bg"></div> </div> </div> <div data-id="picker-m" class="mui-picker"> <div class="mui-picker-inner"> <div class="mui-pciker-rule mui-pciker-rule-ft"></div> <ul class="mui-pciker-list"> </ul> <div class="mui-pciker-rule mui-pciker-rule-bg"></div> </div> </div> <div data-id="picker-d" class="mui-picker"> <div class="mui-picker-inner"> <div class="mui-pciker-rule mui-pciker-rule-ft"></div> <ul class="mui-pciker-list"> </ul> <div class="mui-pciker-rule mui-pciker-rule-bg"></div> </div> </div> <div data-id="picker-h" class="mui-picker"> <div class="mui-picker-inner"> <div class="mui-pciker-rule mui-pciker-rule-ft"></div> <ul class="mui-pciker-list"> </ul> <div class="mui-pciker-rule mui-pciker-rule-bg"></div> </div> </div> <div data-id="picker-i" class="mui-picker"> <div class="mui-picker-inner"> <div class="mui-pciker-rule mui-pciker-rule-ft"></div> <ul class="mui-pciker-list"> </ul> <div class="mui-pciker-rule mui-pciker-rule-bg"></div> </div> </div> </div> </div>';
e.DtPicker = e.Class.extend({
init: function(n) {
var a = this,
r = e.dom(i)[0];
t.body.appendChild(r), e('[data-id*="picker"]', r).picker();
var s = a.ui = {
picker: r,
mask: e.createMask(),
ok: e('[data-id="btn-ok"]', r)[0],
cancel: e('[data-id="btn-cancel"]', r)[0],
y: e('[data-id="picker-y"]', r)[0],
m: e('[data-id="picker-m"]', r)[0],
d: e('[data-id="picker-d"]', r)[0],
h: e('[data-id="picker-h"]', r)[0],
i: e('[data-id="picker-i"]', r)[0],
labels: e('[data-id*="title-"]', r)
};
s.cancel.addEventListener("tap", function() {
a.hide()
}, !1), s.ok.addEventListener("tap", function() {
var e = a.callback(a.getSelected());
e !== !1 && a.hide()
}, !1), s.y.addEventListener("change", function(e) {
a.options.beginMonth || a.options.endMonth ? a._createMonth() : a._createDay()
}, !1), s.m.addEventListener("change", function(e) {
a._createDay()
}, !1), s.d.addEventListener("change", function(e) {
(a.options.beginMonth || a.options.endMonth) && a._createHours()
}, !1), s.h.addEventListener("change", function(e) {
(a.options.beginMonth || a.options.endMonth) && a._createMinutes()
}, !1), s.mask[0].addEventListener("tap", function() {
a.hide()
}, !1), a._create(n), a.ui.picker.addEventListener(e.EVENT_START, function(e) {
e.preventDefault()
}, !1), a.ui.picker.addEventListener(e.EVENT_MOVE, function(e) {
e.preventDefault()
}, !1)
},
getSelected: function() {
var e = this,
t = e.ui,
i = e.options.type,
n = {
type: i,
y: t.y.picker.getSelectedItem(),
m: t.m.picker.getSelectedItem(),
d: t.d.picker.getSelectedItem(),
h: t.h.picker.getSelectedItem(),
i: t.i.picker.getSelectedItem(),
toString: function() {
return this.value
}
};
switch (i) {
case "datetime":
n.value = n.y.value + "-" + n.m.value + "-" + n.d.value + " " + n.h.value + ":" + n.i.value, n.text = n.y.text +
"-" + n.m.text + "-" + n.d.text + " " + n.h.text + ":" + n.i.text;
break;
case "date":
n.value = n.y.value + "-" + n.m.value + "-" + n.d.value, n.text = n.y.text + "-" + n.m.text + "-" + n.d.text;
break;
case "time":
n.value = n.h.value + ":" + n.i.value, n.text = n.h.text + ":" + n.i.text;
break;
case "month":
n.value = n.y.value + "-" + n.m.value, n.text = n.y.text + "-" + n.m.text;
break;
case "hour":
n.value = n.y.value + "-" + n.m.value + "-" + n.d.value + " " + n.h.value, n.text = n.y.text + "-" + n.m.text +
"-" + n.d.text + " " + n.h.text
}
return n
},
setSelectedValue: function(e) {
var t = this,
i = t.ui,
n = t._parseValue(e);
i.y.picker.setSelectedValue(n.y, 0, function() {
i.m.picker.setSelectedValue(n.m, 0, function() {
i.d.picker.setSelectedValue(n.d, 0, function() {
i.h.picker.setSelectedValue(n.h, 0, function() {
i.i.picker.setSelectedValue(n.i, 0)
})
})
})
})
},
isLeapYear: function(e) {
return e % 4 == 0 && e % 100 != 0 || e % 400 == 0
},
_inArray: function(e, t) {
for (var i in e) {
var n = e[i];
if (n === t) return !0
}
return !1
},
getDayNum: function(e, t) {
var i = this;
return i._inArray([1, 3, 5, 7, 8, 10, 12], t) ? 31 : i._inArray([4, 6, 9, 11], t) ? 30 : i.isLeapYear(e) ? 29 :
28
},
_fill: function(e) {
return e = e.toString(), e.length < 2 && (e = 0 + e), e
},
_isBeginYear: function() {
return this.options.beginYear === parseInt(this.ui.y.picker.getSelectedValue())
},
_isBeginMonth: function() {
return this.options.beginMonth && this._isBeginYear() && this.options.beginMonth === parseInt(this.ui.m.picker.getSelectedValue())
},
_isBeginDay: function() {
return this._isBeginMonth() && this.options.beginDay === parseInt(this.ui.d.picker.getSelectedValue())
},
_isBeginHours: function() {
return this._isBeginDay() && this.options.beginHours === parseInt(this.ui.h.picker.getSelectedValue())
},
_isEndYear: function() {
return this.options.endYear === parseInt(this.ui.y.picker.getSelectedValue())
},
_isEndMonth: function() {
return this.options.endMonth && this._isEndYear() && this.options.endMonth === parseInt(this.ui.m.picker.getSelectedValue())
},
_isEndDay: function() {
return this._isEndMonth() && this.options.endDay === parseInt(this.ui.d.picker.getSelectedValue())
},
_isEndHours: function() {
return this._isEndDay() && this.options.endHours === parseInt(this.ui.h.picker.getSelectedValue())
},
_createYear: function(e) {
var t = this,
i = t.options,
n = t.ui,
a = [];
if (i.customData.y) a = i.customData.y;
else
for (var r = i.beginYear, s = i.endYear, c = r; s >= c; c++) a.push({
text: c + "",
value: c
});
n.y.picker.setItems(a)
},
_createMonth: function(e) {
var t = this,
i = t.options,
n = t.ui,
a = [];
if (i.customData.m) a = i.customData.m;
else
for (var r = i.beginMonth && t._isBeginYear() ? i.beginMonth : 1, s = i.endMonth && t._isEndYear() ? i.endMonth :
12; s >= r; r++) {
var c = t._fill(r);
a.push({
text: c,
value: c
})
}
n.m.picker.setItems(a)
},
_createDay: function(e) {
var t = this,
i = t.options,
n = t.ui,
a = [];
if (i.customData.d) a = i.customData.d;
else
for (var r = t._isBeginMonth() ? i.beginDay : 1, s = t._isEndMonth() ? i.endDay : t.getDayNum(parseInt(this.ui.y
.picker.getSelectedValue()), parseInt(this.ui.m.picker.getSelectedValue())); s >= r; r++) {
var c = t._fill(r);
a.push({
text: c,
value: c
})
}
n.d.picker.setItems(a), e = e || n.d.picker.getSelectedValue()
},
_createHours: function(e) {
var t = this,
i = t.options,
n = t.ui,
a = [];
if (i.customData.h) a = i.customData.h;
else
for (var r = t._isBeginDay() ? i.beginHours : 0, s = t._isEndDay() ? i.endHours : 23; s >= r; r++) {
var c = t._fill(r);
a.push({
text: c,
value: c
})
}
n.h.picker.setItems(a)
},
_createMinutes: function(e) {
var t = this,
i = t.options,
n = t.ui,
a = [];
if (i.customData.i) a = i.customData.i;
else
for (var r = t._isBeginHours() ? i.beginMinutes : 0, s = t._isEndHours() ? i.endMinutes : 59; s >= r; r++) {
var c = t._fill(r);
a.push({
text: c,
value: c
})
}
n.i.picker.setItems(a)
},
_setLabels: function() {
var e = this,
t = e.options,
i = e.ui;
i.labels.each(function(e, i) {
i.innerText = t.labels[e]
})
},
_setButtons: function() {
var e = this,
t = e.options,
i = e.ui;
i.cancel.innerText = t.buttons[0], i.ok.innerText = t.buttons[1]
},
_parseValue: function(e) {
var t = {};
if (e) {
var i = e.replace(":", "-").replace(" ", "-").split("-");
t.y = i[0], t.m = i[1], t.d = i[2], t.h = i[3], t.i = i[4]
} else {
var n = new Date;
t.y = n.getFullYear(), t.m = n.getMonth() + 1, t.d = n.getDate(), t.h = n.getHours(), t.i = n.getMinutes()
}
return t
},
_create: function(e) {
var t = this;
e = e || {}, e.labels = e.labels || ["年", "月", "日", "时", "分"], e.buttons = e.buttons || ["取消", "确定"], e.type = e.type ||
"datetime", e.customData = e.customData || {}, t.options = e;
var i = new Date,
n = e.beginDate;
n instanceof Date && !isNaN(n.valueOf()) && (e.beginYear = n.getFullYear(), e.beginMonth = n.getMonth() + 1, e.beginDay =
n.getDate(), e.beginHours = n.getHours(), e.beginMinutes = n.getMinutes());
var a = e.endDate;
a instanceof Date && !isNaN(a.valueOf()) && (e.endYear = a.getFullYear(), e.endMonth = a.getMonth() + 1, e.endDay =
a.getDate(), e.endHours = a.getHours(), e.endMinutes = a.getMinutes()), e.beginYear = e.beginYear || i.getFullYear() -
5, e.endYear = e.endYear || i.getFullYear() + 5;
var r = t.ui;
t._setLabels(), t._setButtons(), r.picker.setAttribute("data-type", e.type), t._createYear(), t._createMonth(), t
._createDay(), t._createHours(), t._createMinutes(), t.setSelectedValue(e.value)
},
show: function(i) {
var n = this,
a = n.ui;
n.callback = i || e.noop, a.mask.show(), t.body.classList.add(e.className("dtpicker-active-for-page")), a.picker.classList
.add(e.className("active")), n.__back = e.back, e.back = function() {
n.hide()
}
},
hide: function() {
var i = this;
if (!i.disposed) {
var n = i.ui;
n.picker.classList.remove(e.className("active")), n.mask.close(), t.body.classList.remove(e.className(
"dtpicker-active-for-page")), e.back = i.__back
}
},
dispose: function() {
var e = this;
e.hide(), setTimeout(function() {
e.ui.picker.parentNode.removeChild(e.ui.picker);
for (var t in e) e[t] = null, delete e[t];
e.disposed = !0
}, 300)
}
})
}(mui, document);
function pullupRefresh(url, arr, params) {
//console.log("加载前1" + arr);
setTimeout(function() {
var para = {
PageSize: params.pageSize,
PageIndex: params.pageIndex,
ReportType: params.ReportType,
SearchType:app.current,
searchText:''
};
console.log("canshu:" + JSON.stringify(para));
//console.log("之前的数据:" + arr);
Api.post(url, para, function(e) { //2.没数据 提示 但是可以一直发请求只不过传回来是空
if (e.success) {
//console.log("111:" + JSON.stringify(e.items));
var data = e.items;
if (e.items.length > 0) {
params.pageIndex++;
}
for (var i = 0; i < data.length; i++) {
arr.push(data[i]);
//console.log("changdu2222222:" + arr.length);
}
}
}, function(b, bb, bbb) {
mui.toast(JSON.stringify(bbb.message))
});
mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //参数为true代表没有更多数据了。
mui('#pullrefresh').pullRefresh().refresh(true);
//mui('#pullrefresh').pullRefresh().disablePullupToRefresh();
}, 1000);
}
function searchPull(url, arr, params) {
setTimeout(function() {
var para = {
searchText: app.searchText,
PageSize: params.pageSize,
PageIndex: params.pageIndex,
ReportType: params.ReportType,
SearchType:app.current,
};
Api.post(url, para, function(e) {
if (e.success) {
//console.log("111:" + JSON.stringify(e.items));
var data = e.items;
if (e.items.length > 0) {
params.pageIndex++;
}
for (var i = 0; i < data.length; i++) {
arr.push(data[i]);
}
console.log("canshuqq:" + JSON.stringify(para));
}
}, function(b, bb, bbb) {
mui.toast(JSON.stringify(bbb.message))
});
mui('#pullrefresh').pullRefresh().endPullupToRefresh();
mui('#pullrefresh').pullRefresh().refresh(true);
}, 1000);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment