1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099 |
- // -------------------------------------------------------------页面初始化操作
- let myTaskListStateFalse = {}; // 我的任务暂存未读数据列表<id,T>
- let plusStatus = false;
- let loadingStatus = false;
- // plus end
- // 系统运行环境
- let SYSTEM_ENVIRONMENT = "Beta";
- let ENVIRONMENT = {
- // 本地测试环境(WEB端)
- DEV: {
- DMS_BASE_RUL: "http://121.43.55.7:10091"
- },
- // 预生产环境(移动端)
- Beta: {
- DMS_BASE_RUL: "http://121.43.55.7:10091"
- }
- }
- let allCount = 0; // 数据总条数
- let pageSize = 20; // 每页显示数据条数
- let page = 0; // 初始页
- let searchStateValue = 0;
- let fileList = {};
- let page_e; // mui-pullRefresh
- // 后台服务地址
- const DMS_BASE_RUL = ENVIRONMENT[SYSTEM_ENVIRONMENT].DMS_BASE_RUL;
- // 接口URL
- // ----------------系统设置-用户
- // 登录
- const loginUrl = "/ioc-server/system_user/login";
- // 注销登录
- const logoutUrl = "/ioc-server/system_user/logout";
- // token验证
- const getUserInfoUrl = "/ioc-server/system_user/validate";
- // 分页获取dms数据
- const getDataListUrl = "/proxy_dms/content/selectContentList";
- // 上传文件接口(提示跨域???)
- const proxyDmsFileUploadFile = "/proxy_dms/file/uploadFile";
- // 更新dms数据
- const updateContent = "/proxy_dms/content/updateContent";
- // 更新dms状态
- const updateAudit = "/proxy_dms/content/updateAudit";
- // 添加dms数据
- const addContent = "/proxy_dms/content/addContent";
- // ajax配置
- let requestSettins = {
- type: "POST",
- dataType: "json",
- async: true,
- crossDomain: true,
- processData: false,
- contentType: "application/json",
- timeout: 10000,
- headers: {
- "Content-Type": "application/json;charset=utf-8",
- "token": localStorage.getItem("token")
- }
- };
- let requestSettins2 = {
- type: "POST",
- dataType: "json",
- async: false,
- crossDomain: true,
- processData: false,
- contentType: "application/json",
- timeout: 10000,
- headers: {
- "Content-Type": "application/json;charset=utf-8",
- "token": localStorage.getItem("token")
- }
- };
- // 记住密码变量
- let isActive = localStorage.key('isActive') ? localStorage.getItem('isActive') : false;
- // -------------------------------------------------------------自定义的mui事件监听事件
- function muiInit() {
- //扩展mui.showLoading
- (function($, window) {
- //显示加载框
- $.showLoading = function showLoading(message, type) {
- if (loadingStatus) {
- return;
- } else {
- loadingStatus = true;
- }
- if ($.os.plus && type !== 'div') {
- $.plusReady(function() {
- plus.nativeUI.showWaiting(message);
- });
- } else {
- var html = '';
- html += '<i class="mui-spinner mui-spinner-white"></i>';
- html += '<p class="text">' + (message || "数据加载中") + '</p>';
- //遮罩层
- var mask = document.getElementsByClassName("mui-show-loading-mask");
- if (mask.length == 0) {
- mask = document.createElement('div');
- mask.classList.add("mui-show-loading-mask");
- document.body.appendChild(mask);
- mask.addEventListener("touchmove", function(e) {
- e.stopPropagation();
- e.preventDefault();
- });
- } else {
- mask[0].classList.remove("mui-show-loading-mask-hidden");
- }
- //加载框
- var toast = document.getElementsByClassName("mui-show-loading");
- if (toast.length == 0) {
- toast = document.createElement('div');
- toast.classList.add("mui-show-loading");
- toast.classList.add('loading-visible');
- document.body.appendChild(toast);
- toast.innerHTML = html;
- toast.addEventListener("touchmove", function(e) {
- e.stopPropagation();
- e.preventDefault();
- });
- } else {
- toast[0].innerHTML = html;
- toast[0].classList.add("loading-visible");
- }
- }
- };
- //隐藏加载框
- $.hideLoading = function(callback) {
- loadingStatus = false;
- setTimeout(() => {
- if ($.os.plus) {
- $.plusReady(function() {
- plus.nativeUI.closeWaiting();
- });
- }
- var mask = document.getElementsByClassName("mui-show-loading-mask");
- var toast = document.getElementsByClassName("mui-show-loading");
- if (mask.length > 0) {
- mask[0].classList.add("mui-show-loading-mask-hidden");
- }
- if (toast.length > 0) {
- toast[0].classList.remove("loading-visible");
- callback && callback();
- }
- }, 500);
- }
- })(mui, window);
- // 监听用户点击状态触发事件
- mui('body').on('tap', '#loginButton', function() {
- // 首页登录按钮触发事件
- login();
- }).on('tap', '.menuLocalPage', function(event) {
- /**
- * 自定义页面跳转事件,且阻止事件冒泡
- * class="menuLocalPage" data-page-name="要跳转的页面名称"
- */
- clearSearchValue();
- event.stopPropagation();
- let pageName = this.dataset.pageName;
- mui.openWindow("./" + pageName + ".html", pageName);
- }).on('tap', '.loginOutBtu', function(event) {
- // 个人中心退出登录
- loginOut();
- }).on('tap', '#muiSearchCancel', function(event) {
- /**
- * 首页搜索弹窗取消按钮
- */
- if (document.getElementById('searchPanelBox')) {
- document.getElementById('muiSearchCancel').style.display = "none";
- document.getElementsByClassName('mui-icon-clear')[0].style.right = "0";
- document.getElementById('searchInput').style.width = "100%";
- document.getElementById('searchPanelBox').style.height = "0";
- }
- }).on('tap', '.tabList div,.tabList span', function(event) {
- /**
- * 自定义切换组件
- * 子元素:
- * class="active" disabled="disabled" data-key="xxx" name="xxx"
- */
- if (document.getElementsByClassName('active') && document.getElementsByClassName(
- 'active')[0]
- .getAttribute('name') !=
- this.dataset.key && !document.getElementsByName(this.dataset.key)[0]
- .getAttribute('disabled')) {
- document.getElementsByName(this.dataset.key)[0].parentNode.getElementsByClassName(
- 'active')[0]
- .className = ""
- document.getElementsByName(this.dataset.key)[0].className = "active";
- if (document.getElementsByName(this.dataset.key) && this.dataset.url) {
- mui.showLoading("正在加载..", "div");
- let dataUrl = JSON.parse(this.dataset.url);
- kanbanData(dataUrl);
- }
- }
- }).on('change', '[required="required"] .formInput', function() {
- if (this.value) {
- // 非空验证通过
- var nextElementSibling = this.nextElementSibling;
- if (nextElementSibling && nextElementSibling.className == 'requiredMsgShow') {
- nextElementSibling.className = 'requiredMsgHide';
- }
- } else {
- // 提示该字段不可为空,或者直接通过js直接修改是否显示为空信息
- var nextElementSibling = this.nextElementSibling;
- if (nextElementSibling && nextElementSibling.className == 'requiredMsgHide') {
- nextElementSibling.className = 'requiredMsgShow';
- }
- }
- }).on('tap', '[customizeName="datePoppicker"]', function(event) {
- /**
- * 自定义时间组件
- * input type="text" readonly
- * customizeName="datePoppicker"
- * name="xxx" 类似id,唯一标识
- * data-key="xxx" 与name属性值一致
- * data-type="xxx" [datetime|date|time|month|hour] 配置详情: https://dev.dcloud.net.cn/mui/ui/#dtpicker
- */
- var dtPicker = new mui.DtPicker(this.dataset.type ? {
- type: this.dataset.type
- } : {
- type: "datetime"
- });
- let that = this;
- dtPicker.show(function(selectItems) {
- if (document.getElementsByName(that.dataset.key)) {
- document.getElementsByName(that.dataset.key)[0].value = selectItems
- .text;
- }
- })
- }).on('tap', '[name="submit"]', function(event) {
- /**
- * 自定义时间组件(提交按钮,自动校验非空字段并检验正确性)
- * div name="submit"
- * 本页面存在input标签且符合class="formInput"
- */
- let formOptionDoms = document.getElementsByClassName('formInput');
- let formOption = {};
- let that = this;
- let verification = true;
- if (formOptionDoms.length > 0) {
- for (let i = 0; i < formOptionDoms.length; i++) {
- // 是否必填
- let required = formOptionDoms[i].parentNode.parentNode.getAttribute('required');
- if (!required || required && formOptionDoms[i].value) {
- // 非空验证通过
- var nextElementSibling = formOptionDoms[i].nextElementSibling;
- if (nextElementSibling && nextElementSibling.className ==
- 'requiredMsgShow') {
- nextElementSibling.className = 'requiredMsgHide';
- }
- } else {
- // 提示该字段不可为空,或者直接通过js直接修改是否显示为空信息
- var nextElementSibling = formOptionDoms[i].nextElementSibling;
- if (nextElementSibling && nextElementSibling.className ==
- 'requiredMsgHide') {
- nextElementSibling.className = 'requiredMsgShow';
- }
- verification = false;
- }
- }
- }
- if (verification) {
- let pageName = this.dataset.pageName;
- mui.openWindow("./" + pageName + ".html", pageName);
- }
- }).on('tap', '[type="picker"]', function(event) {
- /**
- * 自定义下拉框组件
- * div type="picker" name = "xxx" parentOption = "xxx"
- */
- let that = this;
- let parentOptionList = pickerLists[this.getAttribute('parentOption')];
- if (parentOptionList) {
- for (let i = 0; i < parentOptionList.length; i++) {
- if (that.getAttribute('name') == parentOptionList[i].name) {
- let itemData = parentOptionList[i].data;
- let pickerData = [];
- var statePicker = new mui.PopPicker();
- for (let index in itemData) {
- pickerData.push({
- value: itemData[index].label != undefined ? itemData[index]
- .value : itemData[index],
- text: itemData[index].label != undefined ? itemData[index]
- .label : itemData[
- index]
- })
- }
- statePicker.setData(pickerData);
- statePicker.show(function(items) {
- that.innerText = items[0].text;
- if (document.getElementById('pageName')) {
- let pageName = document.getElementById('pageName')
- .innerText;
- dataUrl[pageName].params[that.getAttribute('name')] = items[
- 0].value;
- resetPageInfo();
- }
- });
- }
- }
- }
- }).on('tap', '.changeLoginTypeToPhone', function() {
- // 首页切换登录方式,为手机号码登录
- console.log("首页切换登录方式,为手机号码登录")
- document.getElementById('loginFormBox').style.display = "none";
- document.getElementById('loginForm2Box').style.display = "block";
- }).on('tap', '.changeLoginTypeToUser', function() {
- // 首页切换登录方式,为账号登录
- console.log("首页切换登录方式,为账号登录")
- document.getElementById('loginForm2Box').style.display = "none";
- document.getElementById('loginFormBox').style.display = "block";
- }).on('change', '#autoLogin', function() {
- isActive = this.checked ? "true" : "false";
- localStorage.setItem('isActive', isActive);
- }).on('tap', '#reSearch', function() {
- // 数据列表刷新,搜索框重置
- mui.confirm("是否重置并刷新?", "系统提示", function(status) {
- if (status.index == 1) {
- clearSearchValue();
- resetPageInfo();
- }
- })
- }).on('tap', '.toBackPage', function() {
- mui.back();
- })
- }
- // 原生请求
- function postRequest(url, setting, funSuccess, funError) {
- if (setting.data) {
- setting.data = JSON.stringify(setting.data);
- }
- requestSettins.success = funSuccess;
- requestSettins.error = funError;
- let newSetting = Object.assign(requestSettins, setting);
- mui.ajax(DMS_BASE_RUL + url, newSetting);
- }
- function postRequest2(url, setting, otherParams, funSuccess, funError) {
- try {
- if (setting.data) {
- setting.data = JSON.stringify(setting.data);
- }
- requestSettins2.success = (data) => {
- funSuccess(data, otherParams);
- };
- requestSettins2.error = funError;
- let newSetting = Object.assign(requestSettins2, setting);
- mui.ajax(DMS_BASE_RUL + url, newSetting);
- } catch (e) {
- //TODO handle the exception
- console.log("postRequest2 error:", e);
- }
- }
- // -------------------------------------------------------------自定义事件
- // 页面自动化配置生效
- function pageInit() {
- let tabBoxs = document.getElementsByClassName('tabBox');
- if (tabBoxs.length > 0) {
- for (let i = 0; i < tabBoxs.length; i++) {
- if (tabBoxs[i].getAttribute('option')) {
- let option_ = formTabOptions[tabBoxs[i].getAttribute('option')];
- if (option_.length > 0) {
- for (let i1 = 0; i1 < option_.length; i1++) {
- let dom = document.createElement('span');
- dom.setAttribute("data-key", option_[i1].lable + option_[i1].key);
- dom.setAttribute("data-url", JSON.stringify(option_[i1].url));
- dom.setAttribute("name", option_[i1].lable + option_[i1].key);
- dom.className = option_[i1].active ? 'active' : '';
- dom.innerText = option_[i1].lable
- tabBoxs[i].appendChild(dom);
- setTimeout(() => {
- if (option_[i1].active) {
- if (mui.showLoading != undefined) {
- mui.showLoading("正在加载..", "div");
- }
- kanbanData(option_[i1].url);
- }
- });
- }
- } else {
- mui.toast('form option:' + tabBoxs[i].getAttribute('option') + 'is undefined!');
- }
- }
- }
- }
- let echartDoms = document.getElementsByClassName('echartDom');
- if (echartDoms.length > 0) {
- for (let index = 0; index < echartDoms.length; index++) {
- let domId = echartDoms[index].getAttribute('id');
- let option = options[domId];
- if (option) {
- initEchart(domId, option, false);
- }
- }
- }
- if (document.getElementById('searchInput')) {
- // 存在搜索框的话开始监听{focus:获取焦点,input:内容修改,blur:失去焦点}
- document.getElementById('searchInput').addEventListener('focus', function(event) {
- if (document.getElementById('searchPanelBox')) {
- document.getElementsByClassName('mui-icon-clear')[0].style.right = "2rem";
- document.getElementById('searchInput').style.width = "calc(100% - 4rem)"
- document.getElementById('muiSearchCancel').style.display = "block";
- }
- // 展开搜索结果框
- homeSearch();
- })
- document.getElementById('searchInput').addEventListener('input', function(event) {
- if (document.getElementById('searchPanelBox')) {
- document.getElementsByClassName('mui-icon-clear')[0].style.right = "3rem";
- document.getElementById('searchInput').style.width = "calc(100% - 3rem)"
- document.getElementById('muiSearchCancel').style.display = "block";
- }
- // 展开搜索结果框
- homeSearch();
- })
- document.getElementById('searchInput').addEventListener('keypress', function(event) {
- if (event.keyCode == 13) {
- document.activeElement.blur(); // 收起模拟键盘
- // 展开搜索结果框
- if (document.getElementById('searchPanelBox')) {
- homeSearch();
- } else {
- resetPageInfo();
- }
- event.preventDefault(); // 阻止页面刷新
- }
- })
- }
- let formBoxs = document.getElementsByClassName('form-box');
- if (formBoxs.length > 0) {
- for (let i = 0; i < formBoxs.length; i++) {
- if (formBoxs[i].getAttribute('option')) {
- console.log("初始化表单", formBoxs[i].getAttribute('option'))
- let option_ = formOptions[formBoxs[i].getAttribute('option')];
- let dom = document.createElement('div');
- dom.innerHTML = `<div class="form-title">${formBoxs[i].getAttribute('title')}</div>`;
- formBoxs[i].appendChild(dom);
- if (option_.length > 0) {
- for (let i1 = 0; i1 < option_.length; i1++) {
- let doms = document.createElement('div');
- doms.innerHTML = `
- <div class="row" title="${option_[i1].title}" ${option_[i1].required ? 'required="required"' : ''}>
- <div>${option_[i1].title}</div>
- <div>
- <input class="formInput" name="${option_[i1].name}" data-key="${option_[i1].name}" ${option_[i1].customizeName ? 'customizeName="'+option_[i1].customizeName+'"' : ''} type="text">
- ${option_[i1].required ? '<p class="requiredMsgHide">'+option_[i1].title+'不能为空</p>' : ''}
- </div>
- </div>`;
- formBoxs[i].appendChild(doms);
- }
- } else {
- mui.toast('form option:' + formBoxs[i].getAttribute('option') + 'is undefined!');
- }
- }
- }
- }
- let formTabBoxs = document.getElementsByClassName('form-list-box');
- if (formTabBoxs.length > 0) {
- for (let i = 0; i < formTabBoxs.length; i++) {
- if (formTabBoxs[i].getAttribute('option')) {
- let option_ = formTabOptions[formTabBoxs[i].getAttribute('option')];
- if (option_.length > 0) {
- for (let i1 = 0; i1 < option_.length; i1++) {
- let dom = document.createElement('div');
- dom.className = "form-row tabList";
- let datas = option_[i1].data;
- for (let i2 = 0; i2 < datas.length; i2++) {
- dom.innerHTML +=
- `<div ${datas[i2].active ? 'class="active"' : ''} ${datas[i2].disabled ? 'disabled="disabled"' : ''} data-key="${option_[i1].name + datas[i2].key}" name="${option_[i1].name + datas[i2].key}">${datas[i2].lable}</div>`;
- }
- formTabBoxs[i].appendChild(dom);
- }
- } else {
- mui.toast('form option:' + formTabBoxs[i].getAttribute('option') + 'is undefined!');
- }
- }
- }
- }
- let pickerBoxs = document.getElementsByClassName('pickerBox');
- if (pickerBoxs.length > 0) {
- for (let i = 0; i < pickerBoxs.length; i++) {
- if (pickerBoxs[i].getAttribute('option') && pickerLists[pickerBoxs[i].getAttribute(
- 'option')]) {
- let pickerOptions = pickerLists[pickerBoxs[i].getAttribute('option')];
- if (pickerOptions.length > 0) {
- for (let i2 = 0; i2 < pickerOptions.length; i2++) {
- let pickerOption_ = pickerOptions[i2];
- let pickerDom = document.createElement('div');
- pickerDom.setAttribute('name', pickerOption_.name);
- pickerDom.setAttribute('type', 'picker');
- pickerDom.setAttribute('parentOption', pickerBoxs[i].getAttribute('option'));
- pickerDom.innerText = pickerOption_.label;
- pickerBoxs[i].appendChild(pickerDom);
- }
- }
- } else {
- mui.toast('picker option:' + pickerBoxs[i].getAttribute('option') + 'is undefined!');
- }
- }
- }
- }
- // 看板页面初始化配置mui请求
- function muiPageInit() {
- // mui请求
- let myTaskListDom = document.getElementById('myTaskListDom');
- if (myTaskListDom) {
- getMoveMyTaskList();
- myTaskListDom.addEventListener('scroll', function(event) {
- //scrollTop是滚动条滚动时,距离顶部的距离
- var scrollTop = myTaskListDom.scrollTop || document.body.scrollTop;
- //windowHeight是可视区的高度
- var windowHeight = myTaskListDom.clientHeight || document.body.clientHeight;
- //scrollHeight是滚动条的总高度
- var scrollHeight = myTaskListDom.scrollHeight || document.body.scrollHeight;
- //滚动条到底部的条件
- let scrollBottom = scrollHeight - scrollTop - windowHeight;
- if (scrollBottom == 0 && (allCount > page * pageSize)) {
- getMoveMyTaskList();
- }
- })
- }
- // mui请求
- // 如果在首页,先填充保存的用户名和密码,如果有token则进行token校验,通过提示欢迎回来
- if (document.getElementById('autoLogin')) {
- if (isActive) {
- document.getElementById('userName').value = localStorage.key('userName') ? localStorage
- .getItem(
- 'userName') : '';
- document.getElementById('passWord').value = localStorage.key('passWord') ? localStorage
- .getItem(
- 'passWord') : '';
- }
- document.getElementById('autoLogin').checked = isActive;
- if (localStorage.getItem('token') != null) {
- postRequest2(getUserInfoUrl, {}, null, function success(res, params) {
- if (res.code == 200) {
- mui.toast('欢迎回来', '系统提示');
- mui.openWindow("pages/homeNew.html", "homeNew");
- } else {
- localStorage.removeItem("token");
- }
- }, function error(xhr, type, errorThrown) {
- mui.alert('系统异常!请联系开发人员!', '系统提示');
- });
- }
- }
- }
- // 用户登录
- function apiLogin(setting, funSuccess, funError) {
- postRequest(loginUrl, setting, funSuccess, funError);
- }
- // 首页搜索弹窗事件
- function homeSearch() {
- if (document.getElementById('searchPanelBox')) {
- let searchPanelBoxDom = document.getElementById('searchPanelBox');
- let searchPanelBoxDomInnerHTML = ``;
- let paramValue = document.getElementById('searchInput').value;
- for (let key in menuList) {
- searchPanelBoxDomInnerHTML += `<h5>${key}</h5>
- <div>`;
- for (let i = 0; i < menuList[key].length; i++) {
- if (menuList[key][i].name.indexOf(paramValue) != -1) {
- if (menuList[key][i].pageName) {
- searchPanelBoxDomInnerHTML += `<div class="menuLocalPage" data-page-name="${menuList[key][i].pageName}" menuName="${menuList[key][i].name}">
- <div></div>${menuList[key][i].name}
- </div>`;
- }
- }
- }
- searchPanelBoxDomInnerHTML += `</div>`;
- }
- searchPanelBoxDom.innerHTML = searchPanelBoxDomInnerHTML;
- searchPanelBoxDom.style.height = "calc(100vh - 6.5rem)";
- }
- }
- // 登录请求
- function login() {
- let docUserName = document.getElementById('userName').value;
- let docPassword = document.getElementById('passWord').value;
- if (!docUserName) {
- mui.alert('请输入用户名!', '表单校验', function() {
- return false;
- });
- return false;
- }
- if (!docPassword) {
- mui.alert('请输入密码!', '表单校验', function() {
- return false;
- });
- return false;
- }
- // 登录请求
- if (docUserName && docPassword) {
- let param = {
- username: docUserName,
- password: docPassword
- }
- // 开始请求登录接口
- apiLogin({
- data: param
- }, function success(res, textStatus, xhr) {
- if (res.code == 200) {
- // 如果用户选中了记住密码,则保存账户信息
- if (isActive) {
- localStorage.setItem('userName', docUserName);
- localStorage.setItem('passWord', docPassword);
- }
- // 缓存登录状态主要信息
- localStorage.setItem("userId", res.data.userInfo.id);
- localStorage.setItem("userName", res.data.userInfo.userName);
- localStorage.setItem("token", res.data.token);
- // 跳转到主页
- mui.openWindow({
- url: "pages/homeNew.html",
- id: "homeNew",
- createNew: true
- });
- } else {
- mui.alert(res.msg ? res.msg : '登录失败!', '系统提示');
- }
- }, function error(xhr, type, errorThrown) {
- mui.alert('登录失败!', '系统提示');
- });
- }
- }
- // 看板数据初始化(主要是echart的自动化配置比较复杂)
- function kanbanData(url) {
- let outEchartBoxDom = document.getElementById('outEchartBox');
- outEchartBoxDom.innerHTML = "";
- // 数据指标
- if (url.countUrl) {
- let params = {};
- if (url.countParams) {
- params = {
- data: url.countParams
- };
- }
- postRequest2(url.countUrl, params, url.countList, function success(res, otherParams) {
- if (res.code == 200) {
- for (let i = 0; i < 4; i++) {
- document.getElementById('countTitle' + i).innerText = otherParams[i];
- document.getElementById('countValue' + i).innerText = res.data.list[i]
- .value;
- if (res.data.list[i].compare != undefined) {
- document.getElementById('countValue' + i).innerText = res.data.list[i]
- .value;
- document.getElementById('countValue' + i).className = "";
- document.getElementById('countCompare' + i).innerHTML = `同比 <span class="${res.data.list[i].compare > 0 ? 'monthOnMonth2' : 'monthOnMonth0'}">
- ${res.data.list[i].compare + "%"}
- </span>`
- } else {
- document.getElementById('countValue' + i).innerText = res.data.list[i]
- .value + "%";
- if (res.data.list[i].value > 0) {
- document.getElementById('countValue' + i).className = "trend1";
- } else if (res.data.list[i].value < 0) {
- document.getElementById('countValue' + i).className = "trend0";
- }
- document.getElementById('countCompare' + i).innerText = '';
- }
- }
- document.getElementById('worthAttention').innerText = res.data.worthAttention;
- if (url.listUrl) {
- for (let i_ = 0; i_ < url.listUrl.length; i_++) {
- let params = {};
- let listUrlItem = url.listUrl[i_];
- if (listUrlItem.params) {
- params = {
- data: listUrlItem.params
- };
- }
- let echartBox = document.createElement('div');
- echartBox.innerHTML = `<h4 style="padding-left: 10px;" class="echartTitle">${listUrlItem.title}</h4>
- <div class="echartBox">
- <div class="echartDom" id="${listUrlItem.echartDomId}"></div>
- </div>`;
- document.getElementById('outEchartBox').append(echartBox);
- setTimeout(() => {
- postRequest2(listUrlItem.url, params, listUrlItem,
- function success2(
- res2, otherParams) {
- if (res2.code == 200) {
- if (otherParams.jsonObject) {
- let echartData = {
- xData: []
- }
- echartData.echartJsonObject =
- otherParams
- .jsonObject;
- echartData.serverData = {};
- for (let key in otherParams
- .jsonObject) {
- echartData.serverData[key] = []
- }
- for (let i2 = 0; i2 < res2.data
- .length; i2++) {
- let item = res2.data[i2];
- echartData.xData.push(item.label);
- for (let key in otherParams
- .jsonObject) {
- echartData.serverData[key].push(
- item
- .jsonObject[key]);
- }
- }
- let option = options[otherParams
- .echartDomId];
- option.legend.data = [];
- option.color = [];
- option.xAxis[0].data = echartData.xData;
- option.xAxis[0].name = otherParams
- .xAxisName;
- option.yAxis = [];
- if (otherParams.yAxisName) {
- option.yAxis = [{
- type: 'value',
- name: otherParams
- .yAxisName,
- axisLine: {
- show: true,
- },
- }];
- }
- option.legend.selected = {};
- option.series = [];
- for (let serverItemKey in echartData
- .echartJsonObject) {
- let type = "line";
- if (echartData.echartJsonObject[
- serverItemKey]
- .hideSelected) {
- option.legend.selected[
- echartData
- .echartJsonObject[
- serverItemKey]
- .seriesName] =
- false;
- }
- if (otherParams.series) {
- type = otherParams.series[
- serverItemKey]
- .type;
- let yAxisItem = {
- type: "value",
- name: otherParams
- .series[
- serverItemKey]
- .yAxisName,
- position: otherParams
- .series[
- serverItemKey]
- .position,
- axisLine: {
- show: true,
- lineStyle: {
- color: echartData
- .echartJsonObject[
- serverItemKey
- ].color
- }
- }
- }
- option.yAxis.push(yAxisItem);
- }
- let seriesItem = {
- name: echartData
- .echartJsonObject[
- serverItemKey]
- .seriesName,
- type: type,
- smooth: true,
- lineStyle: {
- width: 0
- },
- // showSymbol: false,
- yAxisIndex: otherParams
- .series &&
- otherParams.series[
- serverItemKey]
- .yAxisIndex ?
- otherParams.series[
- serverItemKey]
- .yAxisIndex : 0,
- areaStyle: {
- opacity: 0.8,
- color: echartData
- .echartJsonObject[
- serverItemKey]
- .noLinearGradient ?
- echartData
- .echartJsonObject[
- serverItemKey]
- .color : new echarts
- .graphic
- .LinearGradient(0,
- 0, 0,
- 1, [{
- offset: 0,
- color: echartData
- .echartJsonObject[
- serverItemKey
- ]
- .color
- },
- {
- offset: 1,
- color: '#FFFFFF'
- }
- ])
- },
- emphasis: {
- focus: 'series'
- },
- data: echartData.serverData[
- serverItemKey]
- }
- if (!otherParams.series || !
- otherParams.series[
- serverItemKey].stack ==
- false) {
- seriesItem.stack = 'Total';
- }
- if (otherParams.series &&
- otherParams.series[
- serverItemKey].itemStyle) {
- seriesItem.itemStyle =
- otherParams.series[
- serverItemKey]
- .itemStyle;
- }
- if (otherParams.series &&
- otherParams.series[
- serverItemKey].barWidth) {
- seriesItem.barWidth =
- otherParams.series[
- serverItemKey].barWidth;
- }
- option.series.push(seriesItem);
- option.legend.data.push(echartData
- .echartJsonObject[
- serverItemKey]
- .seriesName);
- option.color.push(echartData
- .echartJsonObject[
- serverItemKey].color);
- }
- initEchart(otherParams.echartDomId,
- option, true);
- } else {
- let option = options[otherParams
- .echartDomId];
- option.series[0].data = res2.data;
- if (otherParams.labelFormatter) {
- option.series[0].label.formatter =
- otherParams
- .labelFormatter;
- }
- initEchart(otherParams.echartDomId,
- option, true);
- }
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- } else {
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- initEchart(otherParams.echartDomId, null,
- true);
- }
- },
- function error2(xhr, type, errorThrown) {
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- mui.alert('系统异常!请联系开发人员!', '系统提示');
- });
- })
- }
- }
- } else {
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- if (res.msg == "当前未登录" || res.msg == "请登录后重试" || res.msg == "登录失效") {
- if (mui.plus) {
- mui.alert(resJson.msg, '系统提示', function() {
- localStorage.removeItem("token");
- mui.openWindow("../index.html", "login");
- });
- } else {
- localStorage.removeItem("token");
- mui.openWindow("../index.html", "login");
- }
- }
- }
- }, function error(xhr, type, errorThrown) {
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- mui.alert('系统异常!请联系开发人员!', '系统提示');
- });
- }
- }
- // 注销登录
- function loginOut() {
- postRequest(logoutUrl, {}, function success(res, textStatus, xhr) {
- if (res.code == 200) {
- mui.toast('退出成功', '系统提示');
- localStorage.removeItem("token");
- mui.openWindow("../index.html", "login");
- }
- }, function error(xhr, type, errorThrown) {
- mui.alert('系统异常!请联系开发人员!', '系统提示');
- });
- }
- // 请求我的任务列表(下一页)
- function getMoveMyTaskList() {
- page_e = this;
- getMyTaskList();
- }
- // 清空搜索框值
- function clearSearchValue() {
- if (document.getElementById('searchInput')) {
- document.getElementById('searchInput').value = null;
- }
- }
- // 重置页面信息并查询
- function resetPageInfo() {
- allCount = 0;
- pageSize = 20;
- page = 0;
- // 删除数据列表
- if (document.getElementsByClassName('dataItem4').length > 0) {
- let displayFlexDoms = document.getElementsByClassName('dataItem4');
- const displayFlexDomsSize = displayFlexDoms.length;
- if (displayFlexDomsSize > 0) {
- for (let index = 0; index < displayFlexDomsSize; index++) {
- if (displayFlexDoms[0]) {
- displayFlexDoms[0].remove();
- }
- }
- }
- }
- // 重新请求数据
- getMyTaskList();
- if (document.getElementById('listMoveDom')) {
- // mui('#listMoveDom').pullRefresh().refresh(true);
- }
- };
- // 请求数据列表
- function getMyTaskList() {
- if (mui.showLoading != undefined) {
- mui.showLoading("正在加载..", "div");
- }
- sessionStorage.clear();
- // 首先获取页面标志
- let pageName = document.getElementById('pageName').innerText;
- dataUrl[pageName].params.pageStart = (page) * pageSize;
- postRequest2(dataUrl[pageName].url, {
- data: dataUrl[pageName].params
- }, {}, function funSuccess(res, params) {
- let resJson = res;
- try {
- if (resJson.code == 200 && resJson.data != null) {
- allCount = resJson.data.total;
- if (resJson.data.data && resJson.data.data.length > 0) {
- let listDom = document.getElementById('myTaskListDom');
- for (let i = 0; i < resJson.data.data.length; i++) {
- let moveDom = document.createElement('div');
- moveDom.className = "dataItem4 borderBottom";
- moveDom.setAttribute("data-messageId", resJson.data.data[i].id);
- moveDom.setAttribute("readStatus", resJson.data.data[i].status);
- moveDom.innerHTML = `<div>
- <span class="title">${resJson.data.data[i].title ? resJson.data.data[i].title : resJson.data.data[i].type}</span>
- <p>${resJson.data.data[i].time}</p>
- <div class="content">
- ${resJson.data.data[i].content}
- </div>
- </div>`;
- listDom.insertBefore(moveDom, document.getElementById(
- 'listMoveDom'));
- }
- }
- // 分页配置
- if (page_e) {
- if (allCount > (page + 1) * pageSize) {
- document.getElementById("upTitle").innerHTML = "上拉加载更多……";
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- // page_e.endPullupToRefresh(false);
- } else {
- mui.toast('没有更多数据了');
- document.getElementById("upTitle").innerHTML = "没有更多数据了";
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- }
- } else {
- console.log('page_e is null!')
- }
- page++;
- } else {
- // 请求失败!
- document.getElementById("upTitle").innerHTML = resJson.msg;
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- if (resJson.msg === "当前未登录" || resJson.msg === "请登录后重试" || res.msg == "登录失效") {
- if (mui.plus) {
- mui.alert(resJson.msg, '系统提示', function() {
- localStorage.removeItem("token");
- mui.openWindow("../index.html", "login");
- });
- } else {
- localStorage.removeItem("token");
- mui.openWindow("../index.html", "login");
- }
- }
- }
- } catch (e) {
- // 处理异常
- //TODO handle the exception
- mui.alert('try处理异常!' + e, '系统提示', function() {
- document.getElementById("upTitle").innerHTML = "处理异常!";
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- });
- }
- }, function error(xhr, type, errorThrown) {
- // request异常
- mui.alert('请求失败!' + JSON.stringify(xhr), '系统提示', function() {
- document.getElementById("upTitle").innerHTML = "请求失败!";
- if (mui.hideLoading != undefined)(
- mui.hideLoading()
- );
- });
- });
- };
- // echart初始化
- function initEchart(chartDomId, option, state) {
- var chartDom = document.getElementById(chartDomId);
- try {
- if (state) {
- echarts.init(chartDom).dispose();
- }
- if (option) {
- echarts.init(chartDom).setOption(option);
- }
- } catch (e) {
- //TODO handle the exception
- console.log(chartDomId, "dispose error", e);
- }
- }
- // 获取设备类型,后续很有可能会用到
- // if (mui.os.ios) {
- // console.log('苹果设备', 'version:' + mui.os.version, 'iphone:' + mui.os.iphone, 'ipad:' + mui.os.ipad);
- // SYSTEM_ENVIRONMENT = "DEV";
- // } else if (mui.os.android) {
- // console.log('安卓设备', 'version:' + mui.os.version, 'isBadAndroid:' + mui.os.isBadAndroid);
- // SYSTEM_ENVIRONMENT = "Beta";
- // }
- pageInit();
- if (SYSTEM_ENVIRONMENT == "Beta") {
- mui.plusReady(function() {
- if (plus) {
- console.log("plus初始化成功!")
- plusStatus = true;
- mui.init();
- muiInit();
- muiPageInit();
- }
- }, true);
- } else {
- mui.init();
- muiInit();
- muiPageInit();
- }
- // plus注释区域
- // }
- // }, true);
|