// ==UserScript== // @name OA插件 // @namespace http://tampermonkey.net/ // @version 1.2 // @description try to take over the world! // @author You // @match http://*.zhbg.kjt.gx.gov/* // @grant none // @run-at context-menu // ==/UserScript== (function() { 'use strict'; // Your code here... /* Just draw a border round the document.body. */ //设置列表宽度 updateColSize(); document.body.style.border = "5px solid red"; window.Config.enablesecret = true; var username = ""; var boxobserver = null; var bodyobserver = null; var paneobserver = null; var sizeobserver = null; document.styleSheets[0].addRule('.el-tooltip', 'white-space:normal!important'); document.styleSheets[0].addRule('.titlefont', 'white-space:normal!important'); setTimeout(setobserve, 2000); UpdateHuibanOpinoin(); function setobserve(){ //监视界面操作,丢失会办页面后重新设置对会办页面的监视 var header = document.getElementById("js-async-header"); var headerconfig = {attributes:true,subtree:true}; var headerobserver = new MutationObserver(function (mutationsList, observer) { setobserve2(); }); headerobserver.observe(header, headerconfig); //设置对编辑页面打开、会办页面切换、排序的监视 setobserve2(); } function setobserve2(){ //监视会办页面切换 if (boxobserver != null){//清理事件,防止重复刷新 boxobserver.disconnect(); } var box = document.getElementById("tab-hbhq"); var boxconfig = { attributes: true,attributeFilter:["aria-selected"]}; boxobserver = new MutationObserver(function (mutationsList, observer) { doit(mutationsList, observer); }); boxobserver.observe(box, boxconfig); //监视编辑页面打开 if (bodyobserver != null){ bodyobserver.disconnect(); } var body = document.querySelector("body"); var bodyconfig = { attributes: true,attributeFilter:["class"]}; bodyobserver = new MutationObserver(function (mutationsList, observer) { doit(mutationsList, observer); }); bodyobserver.observe(body,bodyconfig); //监视排序 if (paneobserver != null){ paneobserver.disconnect(); } var pane = document.getElementById("pane-hbhq"); var paneconfig = { characterData:true,subtree:true}; paneobserver = new MutationObserver(function (mutationsList, observer) { doit(mutationsList, observer); }); paneobserver.observe(pane, paneconfig); } function doit(mutationsList, observer){ var tabfourth = document.querySelector("div#tab-hbhq_1.is-active"); var body = document.querySelector("body.fullpage"); if (tabfourth != null && body == null ){//如果显示了会办页面 username = document.querySelector("div.async-header__right__name").innerText; username = username.substring(username.length-2); UpdateHuibanOpinoin(); updateColSize(); setobserve2(); } return; } function UpdateHuibanOpinoin(){ //判断列表是否变化 //http://dzgw.zhbg.kjt.gx.gov/bgtoa/rest/arceinboxdaichuliaction/getDataGridDataHuiBan?type=1&isCommondto=true&action2rest=true&controlself=true //下载处理会办列表(最大100项) var httpRequest = new XMLHttpRequest(); httpRequest.open('POST', ' http://dzgw.zhbg.kjt.gx.gov/bgtoa/rest/arceinboxdaichuliaction/getDataGridDataHuiBan?type=1&isCommondto=true&action2rest=true&controlself=true&my=true', true); //第二步:打开连接 httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded"); httpRequest.send('params=%7B%22title%22%3A%22%22%2C%22bianhao%22%3A%22%22%2C%22fawendz%22%3A%22%22%2C%22fawenyear%22%3A%22%22%2C%22fawenserialnumber%22%3A%22%22%2C%22laiwennumber%22%3A%22%22%2C%22urgencydegree%22%3A%22%22%2C%22senddate%22%3A%22%22%2C%22processingstatus%22%3A%22%22%2C%22senddeptname%22%3A%22%22%2C%22fullfiletype%22%3A%22%22%2C%22senddatefrom%22%3A%22%22%2C%22senddateto%22%3A%22%22%2C%22pageIndex%22%3A0%2C%22pageSize%22%3A100%2C%22tabtype%22%3A%220%22%7D&cmdParams=%5B%5D');//发送请求 将情头体写在send中 httpRequest.onreadystatechange = function () { if (httpRequest.readyState == 4 && httpRequest.status == 200) { var huiban = JSON.parse(httpRequest.responseText); //逐项处理会办文 for (var i = 0; i < huiban.custom.data.length; i++){ HandleHuibanData(huiban.custom.data[i]) } } }; } //处理会办文 function HandleHuibanData(data){ //下载会办意见 var httpRequest = new XMLHttpRequest(); httpRequest.open('POST', 'http://dzgw.zhbg.kjt.gx.gov/bgtoa/rest/wd25formhbaction/getDataBean?isCommondto=true&action2rest=true', true); //第二步:打开连接 httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");//设置请求头 注:post方式必须设置请求头(在建立连接后设置请求头) var params = {inboxGuid:data.inboxguid, outboxGuid:data.outboxguid, rowGuid:data.rowguid,istrack:"undefined",fileType:data.filetype}; httpRequest.send("params=" + JSON.stringify(params)); httpRequest.onreadystatechange = function () { if (httpRequest.readyState == 4 && httpRequest.status == 200) { var databean = JSON.parse(httpRequest.responseText); var opinion = "未反馈"; //在各处室遍历查找高新处意见 for (var i = 0; i < databean.custom.opinionList.length; i++){ var name = document.querySelector('span[data-inboxguid="' + data.inboxguid +'"]'); name.style.whiteSpace="normal"; if(databean.custom.opinionList[i].ouname.indexOf("成果转化与区域创新处") >= 0){//查找到高新技术处意见 //汇总高新处意见 opinion = HandleOpinions(data.inboxguid, databean.custom.opinionList[i].opinions); break; } } //显示高新处意见 var itemspan = document.querySelector('span[data-inboxguid="' + data.inboxguid +'"]'); var state = itemspan.parentNode.parentNode.parentNode.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.firstElementChild; var huibanfenbanstatustext = data.huibanfenbanstatustext; //高亮显示未分办 if (huibanfenbanstatustext.indexOf("未分办") >= 0){ huibanfenbanstatustext = " " + huibanfenbanstatustext + " " } //高亮显示全部反馈 if (itemspan.getAttribute("data-processingstatus") == "全部反馈"){ state.innerHTML = "

全部反馈

" + opinion; } else{ state.innerHTML = "

" + huibanfenbanstatustext + "

" +opinion; } state.style.textAlign = "left"; } }; } //汇总高新处意见 function HandleOpinions(inboxguid, opinions){ var opinion = ""; for (var i = 0; i < opinions.length; i++){//高亮显示姓名和时间 opinion = opinion + "

" +opinions[i].createtime + " " + opinions[i].username + " : " + opinions[i].opinion.replace(username, " " + username + " ").replace(/\d+月\d+日/, function(match){return " " + match + " "}) + "

"; } return opinion; } //设置列表宽度 function updateColSize(){ let columns = document.querySelector("#pane-hbhq_1 > div > div > div.el-table__body-wrapper.is-scrolling-left > table").__vue__.columns; for (let index = 0; index < 9; index++) { //读取保存的长度index let size = localStorage.getItem("table_column_" + (index + 1)); if (index != 2){ columns[index].width = size; } columns[index].realWidth = size; columns[index].minWidth = size; } } })();