| var url = null; | 
| var depotData; | 
| var typeData; | 
| var startTime = ''; | 
| var endTime = ''; | 
| var name = '' | 
| var info = ''; | 
| var listPicker2 = []; | 
| var listPicker1 = []; | 
| var list = [{ | 
|     value: 'ywj', | 
|     text: '董事长 叶文洁' | 
| }, { | 
|     value: 'aaa', | 
|     text: '总经理 艾AA' | 
| }, { | 
|     value: 'lj', | 
|     text: '罗辑' | 
| }, { | 
|     value: 'ymt', | 
|     text: '云天明' | 
| }, { | 
|     value: 'shq', | 
|     text: '史强' | 
| }, { | 
|     value: 'zhbh', | 
|     text: '章北海' | 
| }, { | 
|     value: 'zhy', | 
|     text: '庄颜' | 
| }, { | 
|     value: 'gyf', | 
|     text: '关一帆' | 
| }, { | 
|     value: 'zhz', | 
|     text: '智子' | 
| }, { | 
|     value: 'gezh', | 
|     text: '歌者' | 
| }] | 
| //工单申请 | 
| var data = { | 
|     "interfaceId": "5701", | 
|     "outId": "10701", | 
|     "reqDateTime": new Date(), | 
|     "tokenAuth": "", | 
|     "data": { | 
|         "depotId": "", | 
|         "type": "", | 
|         "startTime": "", | 
|         "endTime": "", | 
|         "info": "" | 
|     } | 
| }; | 
|   | 
| //获取仓库列表 | 
| var data2 = { | 
|     "interfaceId": "5102", | 
|     "outId": "10102", | 
|     "reqDateTime": new Date(), | 
|     "tokenAuth": "", | 
|     "data": { | 
|         "deptId": "" | 
|     } | 
| }; | 
|   | 
| //获取业务类型 | 
| var data1 = { | 
|     "interfaceId": "6101", | 
|     "outId": "11101", | 
|     "reqDateTime": new Date(), | 
|     "tokenAuth": "", | 
|     "data": { | 
|          | 
|     } | 
| }; | 
|   | 
| function init() { | 
|     var user = JSON.parse(localStorage.getItem('user')); | 
|     var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId')); | 
|     url = user.url + "/api-phone/v35/gateway"; | 
|     data.tokenAuth = user.tokenAuth; | 
|     data1.tokenAuth = user.tokenAuth; | 
|     data2.tokenAuth = user.tokenAuth; | 
|     data2.data.deptId = selectDeptId; | 
|      | 
|     depotList(); | 
|     typeList(); | 
|   | 
| } | 
| //开始时间 | 
| function chooseDate() { | 
|     var dtpicker = new mui.DtPicker({ | 
|         // type: "hour", //设置日历初始视图模式 | 
|         type: "datetime", | 
|         // beginDate: new Date(2015, 04, 25), //设置开始日期 | 
|         // endDate: new Date(2016, 04, 25), //设置结束日期 | 
|         value: startTime | 
|     }) | 
|     dtpicker.show(function(e) { | 
|         var date_el = document.getElementById("date1-val") | 
|         date_el.innerText = e.value | 
|         startTime = e.value | 
|         data.data.startTime = startTime; | 
|         jQuery(date_el).prev().hide() | 
|     }) | 
| } | 
| // | 
| function chooseDate1() { | 
|     var dtpicker = new mui.DtPicker({ | 
|         // type: "hour", //设置日历初始视图模式 | 
|         type: "datetime", | 
|         // beginDate: new Date(2015, 04, 25), //设置开始日期 | 
|         // endDate: new Date(2016, 04, 25), //设置结束日期 | 
|         value:endTime | 
|     }) | 
|     dtpicker.show(function(e) { | 
|         var date_el = document.getElementById("date2-val") | 
|         date_el.innerText = e.value | 
|         endTime = e.value | 
|         data.data.endTime = endTime | 
|         jQuery(date_el).prev().hide() | 
|     }) | 
| } | 
|   | 
| //工单申请 | 
| function workApply() { | 
|     console.log(JSON.stringify(data.data)) | 
|     //发送请求进行工单申请 | 
|     mui.ajax(url, { | 
|         type: "POST", | 
|         dataType: "json", | 
|         crossDomain: true, | 
|         contentType: "application/json;charset=utf-8", | 
|         data: JSON.stringify(data), | 
|         success: function(result) { | 
|             if (result.code == "0000") { | 
|                 console.log(JSON.stringify(result)) | 
|                 mui.toast(result.msg); | 
|             } else { | 
|                 // console.log(JSON.stringify(result)) | 
|                 // mui.toast(result.msg); | 
|                 mui.alert(result.msg, '提示', ["确定"], function() {}, "div"); | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert('系统繁忙,请重新登录尝试!', '提示', ["确定"], function() {}, "div"); | 
|         } | 
|     }) | 
| } | 
|   | 
| function depotList() { | 
|     //获取仓库列表 | 
|     mui.ajax(url, { | 
|         type: "POST", | 
|         dataType: "json", | 
|         crossDomain: true, | 
|         contentType: "application/json;charset=utf-8", | 
|         data: JSON.stringify(data2), | 
|         success: function(result) { | 
|             if (result.code == "0000") { | 
|                 depotData = result.data | 
|                 conversion(depotData); | 
|                 // console.log(JSON.stringify(result)) | 
|             } else { | 
|                 mui.alert(result.msg, '提示', ["确定"], function() {}, "div"); | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert('系统繁忙,请重新登录尝试!', '提示', ["确定"], function() {}, "div"); | 
|         } | 
|     }) | 
| } | 
| //获取业务类型列表 | 
| function typeList() { | 
|     mui.ajax(url, { | 
|         type: "POST", | 
|         dataType: "json", | 
|         crossDomain: true, | 
|         contentType: "application/json;charset=utf-8", | 
|         data: JSON.stringify(data1), | 
|         success: function(result) { | 
|             if (result.code == "0000") { | 
|                 typeData = result.data | 
|                 conversionType(typeData); | 
|                 // console.log(JSON.stringify(result)) | 
|             } else { | 
|                 mui.alert(result.msg, '提示', ["确定"], function() {}, "div"); | 
|             } | 
|         }, | 
|         error: function() { | 
|             mui.alert('系统繁忙,请重新登录尝试!', '提示', ["确定"], function() {}, "div"); | 
|         } | 
|     }) | 
| } | 
| function conversion(data) { | 
|     var fenl = {} | 
|     $.each(data, function(index, item) { | 
|         fenl = { | 
|             value: item.name, | 
|             text: item.id, | 
|         } | 
|         listPicker2.push(fenl) | 
|     }) | 
| } | 
| function conversionType(data){ | 
|     var fenl = {} | 
|     $.each(data, function(index, item) { | 
|         fenl = { | 
|             value: item.name, | 
|             text: item.id, | 
|         } | 
|         listPicker1.push(fenl) | 
|     }) | 
| } | 
| function refresh(){ | 
|     var html = ''; | 
|     html += '<div class="m-gd"><div class="group"><div class="l">业务类型:</div><div class="r">' | 
|     html += '<div class="val" id="ywlx"><div class="placeholder">请选择</div>' | 
|     html += '<div class="real-val" id="ywlx-val" ></div></div></div></div>' | 
|     html += '<div class="group"><div class="l">关联仓库:</div><div class="r">'; | 
|     html += '<div class="val" id="glck"><div class="placeholder">请选择</div>'; | 
|     html += '<div class="real-val" id="glck-val" ></div></div></div></div>'; | 
|     html += '<div class="group"><div class="l">有效开始时间:</div><div class="r">'; | 
|     html += '<div class="val" id="date1" onclick="chooseDate();"><div class="placeholder">请选择</div>'; | 
|     html += '<div class="real-val" id="date1-val"></div></div></div></div>'; | 
|     html += '<div class="group"><div class="l">有效结束时间:</div><div class="r">'; | 
|     html += '<div class="val" id="date2" onclick="chooseDate1();"><div class="placeholder">请选择</div>'; | 
|     html += '<div class="real-val" id="date2-val"></div></div></div></div>'; | 
|     html += '<div class="group"><div class="l">工单内容:</div><div class="r">' | 
|     html += '<div class="gdnr" id="gdnr" "><div class="placeholder">请选择</div>' | 
|     html += '<div class="real-val" id="gdnr-val"></div></div></div></div>' | 
|     html += '<div type="submit" class="submit">提交</div></div>'; | 
|     $("#refresh").html(html); | 
|     data.data.depotId = ''; | 
|     data.data.type = '' | 
|     data.data.startTime = '' | 
|     data.data.endTime = '' | 
|     info = '' | 
|     data.data.info = info | 
|      | 
| } | 
|   | 
| //提交 | 
| mui(".mui-scroll").on("tap", ".wp form .submit", function() { | 
|     data.data.info = info; | 
|     workApply(); | 
|     // window.location.reload(); | 
|     window.setTimeout(function() { | 
|         refresh(); | 
|     }, 200) | 
| }) | 
|   | 
| mui('.mui-scroll-wrapper').scroll({ | 
|     indicators: false, //是否显示滚动条 | 
|     deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏 | 
|     bounce: false, //是否启用回弹 | 
|     deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 | 
| }); | 
|   | 
|   | 
| (function($, doc) { | 
|     $.init(); | 
|     $.ready(function() { | 
|         /** | 
|          * 获取对象属性的值 | 
|          * 主要用于过滤三级联动中,可能出现的最低级的数据不存在的情况,实际开发中需要注意这一点; | 
|          * @param {Object} obj 对象 | 
|          * @param {String} param 属性名 | 
|          */ | 
|         var _getParam = function(obj, param) { | 
|             return obj[param] || ''; | 
|         }; | 
|         //普通示例 | 
|         var showUserPickerButton = doc.getElementById('ywlx'); | 
|         showUserPickerButton.addEventListener('tap', function(event) { | 
|             var userResult = doc.getElementById('ywlx-val'); | 
|             var userPicker = new $.PopPicker(); | 
|             userPicker.setData(listPicker1); | 
|             userPicker.show(function(items) { | 
|                 // userResult.innerText = JSON.stringify(items[0]); | 
|                 console.log(JSON.stringify(items)) | 
|                 userResult.innerText = items[0].text; | 
|                 // userResult.previousSibling.style.display="none" | 
|                 jQuery(userResult).prev().hide() | 
|                 //返回 false 可以阻止选择框的关闭 | 
|                 //return false; | 
|             }); | 
|         }, false); | 
|         //---------------------------------------- | 
|         //关联仓库: | 
|         var showPicker2Button = doc.getElementById('glck'); | 
|         showPicker2Button.addEventListener('tap', function(event) { | 
|             var picker2Result = doc.getElementById('glck-val'); | 
|             var picker2 = new $.PopPicker(); | 
|             picker2.setData(listPicker2); | 
|             picker2.show(function(items) { | 
|                 // userResult.innerText = JSON.stringify(items[0]); | 
|                 picker2Result.innerText = items[0].text; | 
|                 data.data.depotId = items[0].value; | 
|                 // userResult.previousSibling.style.display="none" | 
|                 jQuery(picker2Result).prev().hide() | 
|                 //返回 false 可以阻止选择框的关闭 | 
|                 //return false; | 
|             }); | 
|         }, false); | 
|     }); | 
| })(mui, document); | 
|   | 
| //打开弹窗 | 
| mui(".mui-scroll").on("tap", ".wp form .gdnr", function() { | 
|     document.getElementById("textareaPop").value = info; | 
|     $("#m-pop").css('display', 'flex'); | 
| }) | 
|   | 
| //关闭弹窗 | 
| function closePop() { | 
|     $("#m-pop").css('display', 'none'); | 
| } | 
| //弹窗确定按钮 | 
| mui(".mui-content").on("tap", ".m-pop .inner .confirm", function() { | 
|     info = document.getElementById("textareaPop").value; | 
|     if(info){ | 
|         document.getElementById("gdnr").innerText = info     | 
|     } | 
|     closePop(); | 
| }) |