MEST ProcessReport Helper

美尔斯通派工报工筛选

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         MEST ProcessReport Helper
// @namespace    joyings.com.cn
// @version      0.2.0
// @description  美尔斯通派工报工筛选
// @author       zmz125000
// @match       http://112.74.92.133/mest/*
// @icon          http://www.google.com/s2/favicons?domain=openwrt.org
// @grant        none
// @license     MIT
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    function waitForElm(selector) {
        return new Promise(resolve => {
            if (document.querySelector(selector)) {
                return resolve(document.querySelector(selector));
            }

            const observer = new MutationObserver(mutations => {
                if (document.querySelector(selector)) {
                    resolve(document.querySelector(selector));
                    observer.disconnect();
                }
            });

            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        });
    }
    var url = new URL(window.location.href);
    var scd = url.searchParams.get("scd");
    var process = url.searchParams.get("process");
    var order = url.searchParams.get("order");

    if (scd) {
        const scdbox = waitForElm('[placeholder="生产单号"]');
        scdbox.then((elm) => elm.value = scd);
        scdbox.then((elm) => elm.dispatchEvent(new Event('input', {
            bubbles: true
        })));
        scdbox.then(() => {
            document.querySelector('.el-icon-search').parentElement.click()
        })
    }

    const pbox = waitForElm('[placeholder="工序名称"]');
    pbox.then((elm) => elm.value = process);
    pbox.then((elm) => elm.dispatchEvent(new Event('input', {
        bubbles: true
    })));
    pbox.then(() => {
        document.querySelector('.el-icon-search').parentElement.click()
    })

    const obox = waitForElm('[placeholder="订单号"]');
    obox.then((elm) => elm.value = order);
    obox.then((elm) => elm.dispatchEvent(new Event('input', {
        bubbles: true
    })));
    obox.then(() => {
        document.querySelector('.el-icon-search').parentElement.click()
    })
})();