appendModel

append model in orderDetailAddPage

As of 22.05.2022. See апошняя версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         appendModel
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  append model in orderDetailAddPage
// @author       FengXia
// @match        http://47.107.106.156/*
// @icon
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    let newNode = document.createElement("td");
    newNode.innerText="规格:";
    newNode.id="model"
    let newNode2 = document.createElement("td");
    let newNode3 = document.createElement("tr");
    let oldxhr=window.XMLHttpRequest;
    let numI = true ;
    function newobj(){}

    window.XMLHttpRequest=function(){
        let tagetobk=new newobj();
        tagetobk.oldxhr=new oldxhr();
        let handle={
        get:    function(target, prop, receiver) {
                if(prop==='oldxhr'){
                    return Reflect.get(target,prop);
                }
                if(typeof Reflect.get(target.oldxhr,prop)==='function')
                {
                    if(Reflect.get(target.oldxhr,prop+'proxy')===undefined)
                    {
                        target.oldxhr[prop+'proxy']=(...funcargs)=> {
                            let result=target.oldxhr[prop].call(target.oldxhr,...funcargs)
                            // console.log('函数劫持获取结果',result)
                            return result;
                        }

                    }
                    return Reflect.get(target.oldxhr,prop+'proxy')
                }
                if(prop.indexOf('response')!==-1)
                {
                    //console.log('属性劫持结果',Reflect.get(target.oldxhr,prop))
                    let inputblur =document.querySelector('#sales-sourceid-orderAddPage');
                    if (inputblur && numI){
                        // console.log('add');
                        inputblur.addEventListener("focusout", function(event) {
                            let customerInput = document.querySelector('#sales-customer-showid-orderAddPage a');
                            if (inputblur.value){
                                QueryCustomerOrder(customerInput.innerText,inputblur.value);
                            }
                        },true);
                        numI = false;
                    }

                    let xhrString = Reflect.get(target.oldxhr,prop);
                    try {
                        xhrString = JSON.parse(xhrString)
                        //console.log('属性劫持结果2',xhrString)
                        //console.log('属性劫持结果3',xhrString.detail.goodsInfo.model)
                        let modelString =xhrString.detail.goodsInfo.model;
                        let newstorageprice = xhrString.detail.goodsInfo.newstorageprice;
                        let inputblur =document.querySelector('#sales-sourceid-orderAddPage');
                        console.log('$$$$$$$$$$$$$',inputblur);
                        if (modelString){
                            let ops=document.querySelectorAll('#sales-form-orderDetailAddPage tbody tr');
                            let ops2 =document.querySelector('#sales-form-orderDetailAddPage tbody');
                            let findModel=document.querySelectorAll('#sales-form-orderDetailAddPage tbody #model');
                            if (findModel){
                            }
                            newNode2.innerHTML=`<input class="len150 readonly" readonly="readonly" name="model" placeholder=${modelString}>`
                            newNode3.innerHTML=`<td>最新库存价:</td><td><input class="len150 readonly" readonly="readonly" name="newstorageprice" placeholder=${newstorageprice}></td>`
                            ops[11].appendChild(newNode);
                            ops[11].appendChild(newNode2);
                            ops2.appendChild(newNode3);
                        }
                        return Reflect.get(target.oldxhr,prop)
                    } catch(err){
                        return Reflect.get(target.oldxhr,prop)
                    }
                }
                return Reflect.get(target.oldxhr,prop);
            },
            set(target, prop, value) {
                return Reflect.set(target.oldxhr, prop, value);
            },
            has(target, key) {
                debugger;
                return Reflect.has(target.oldxhr,key);
            }
        }

        let ret = new Proxy(tagetobk, handle);

        return ret;
        let ops=document.querySelector('#sales-form-orderDetailAddPage .ops');
    }
})();


function QueryCustomerOrder(customer,order){
    let xhr = new XMLHttpRequest();
  
    let url = new URL('http://47.107.106.156:8888/sales/getOrderList.do');
    url.searchParams.set('businessdate', '');
    url.searchParams.set('businessdate1', '');
    url.searchParams.set('id', '');
    url.searchParams.set('salesdept', '');
    url.searchParams.set('customerid', customer);
    url.searchParams.set('status', '');
    url.searchParams.set('sourceid', order);
    url.searchParams.set('goodsid', '');
    url.searchParams.set('printsign', '');
    url.searchParams.set('queryprinttimes', '');
    url.searchParams.set('urgentlevel', '');
    url.searchParams.set('lineid', '');
    url.searchParams.set('isstoragelock', '0');
    url.searchParams.set('salesuserArrs', '');
    url.searchParams.set('page', '1');
    url.searchParams.set('rows', '200');
    url.searchParams.set('sort', 'addtime');
    url.searchParams.set('order', 'desc');
  
    // 2. 配置它:从 URL /article/.../load GET-request
    xhr.open('post', url);
  
    // 3. 通过网络发送请求
    xhr.send();
  
    // 4. 当接收到响应后,将调用此函数
    xhr.onload = function() {
      if (xhr.status != 200) { // 分析响应的 HTTP 状态
        alert(`Error ${xhr.status}: ${xhr.statusText}`); // 例如 404: Not Found
      } else { // 显示结果
        let xhrString = JSON.parse(xhr.response)
        // console.log(xhrString)
        if (xhrString.total > 0){
            let i = 0;
            let orderNo='';
            for (; i < xhrString.rows.length;i++) {
                if (xhrString.rows[i].status !== '4'){
                    orderNo += `${xhrString.rows[i].id},`
                }
            if (orderNo){
                alert( `有重复订单,订单号为${orderNo}`);
            }
            
            }

        }

        // alert(`Done, got ${xhr.response.length} bytes`); // response 是服务器响应
        
      }
    };
  
    xhr.onerror = function() {
      alert("Request failed");
  };
     
  }