Greasy Fork

Greasy Fork is available in English.

轻流QingFlow超级插件(体验版)

轻流QingFlow应用自动超级字段插件

当前为 2023-01-17 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         轻流QingFlow超级插件(体验版)
// @namespace    http://tampermonkey.net/
// @version      2.0.4
// @description  轻流QingFlow应用自动超级字段插件
// @author       Mr.Dragon King
// @license      Mr.Dragon King
// @match       *://*.qingflow.com/*
// @match       *://*.qingflow.com/f/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pmbaobao.com
// @require      https://cdn.bootcss.com/jquery/3.3.1/jquery.js
// @grant        GM_log
// @grant        GM_xmlhttpRequest
// ==/UserScript==

//消息推送
var MessagePushState = false;//是否开启消息推送
var QW_QrobotHook  = "";//企业微信群机器人Hook

//按钮配色方案(皮肤方案)
var ButtonColorOpen = true;//开启在线皮肤方案
var ButtonColorTypeID = "e1e9f3a163bbe6d4005e048b3470a015";//输入皮肤ID

//@Data
var fieldUN = "未同步!!!";//字段数量
var PageOptimizationOpen = false;
//@注册基础元素-字段
var field_Textfield = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[1]";//单行文字
var field_Textarea = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[2]";//多行文字
var field_Number = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[3]";//数字
var field_Link = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[4]";//链接
var field_Date = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[5]";//日期
var field_StartStopTime = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[6]";//起止时间
var field_Phone = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[7]";//电话
var field_Mailbox = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[8]";//邮箱
var field_AloneChoice = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[9]";//单项选择
var field_DropDownChoice = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[1]/div/div/div[10]";//下拉选择


//@注册基础元素-字段基础参数
var field_Title = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]/qf-edit-area/div/qf-function-lock/qf-title-and-hint/div[2]/input";//字段标题
var fieldParameter_Required = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]/qf-edit-area/div/qf-function-lock/div[1]/label";//必填
var fieldParameter_QRCode = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]/qf-edit-area/div/qf-function-lock/div[2]/label";//扫码(默认二维码)
var fieldParameter_BarCode = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]/qf-edit-area/div/qf-function-lock/div[2]/qf-radio-group/label[2]";//扫码-条形码
var fieldParameter_NotDuplicateValue = "/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]/qf-edit-area/div/qf-function-lock/div[3]/label"//不允许重复值

//@注册基础元素-字段高级参数
var fieldParameter_AssociateExistingData = "";//关联已有数据
var fieldParameter_LimitWords = "";//限制字数
var fieldParameter_DecimalsAllowed = "";//允许小数
var fieldParameter_DisplayAmount = ""//显示金额
var fieldParameter_TimeFormat = "";//时间格式
var fieldParameter_TimeOverlapNotAllowed = "";//不允许时间重叠
var fieldParameter_FixedTelephone = "";//支持固定电话
var fieldParameter_SMSVerification = "";//短信验证
var fieldParameter_OptionContent = "";//选项内容


//打印控制台版本信息
console.log("=====================================================================")
console.log("|| @name         QingFlow Dragon King Super Tools")
console.log("|| @version      体验版本0.1")
console.log("|| @description  轻流QingFlow应用自动超级字段插件")
console.log("|| @author       Mr.Dragon King")
console.log("|| @license      Mr.Dragon King")
console.log("=====================================================================")



console.log("Hello,欢迎使用【QingFlow Dragon King Super Tools】\n轻流QingFlow应用自动超级字段插件🐲\n\n@author       Mr.Dragon King \n@version      0.2\n\n使用帮助:\nhttps://www.yuque.com/g/mrscott-prexr/bgia0r/hfwq3pdgm0y7m50i/collaborator/join?token=Je5Br7K9hrV1R8FE# 《QingFlow Dragon King Super Tools使用帮助》\n\n更多信息可联系作者");
//@jquery库
function jquery() {
    var myScript = document.createElement('script');
    myScript.src = 'https://cdn.bootcss.com/jquery/3.3.1/jquery.js';
    document.getElementsByTagName('head')[0].appendChild(myScript);
}

//@XPath方法
function $x(STR_XPATH) {
    var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);
    var xnodes = [];
    var xres;
    while (xres = xresult.iterateNext()) {
        xnodes.push(xres);
    }
    return xnodes;
}

//@xlsx库
function xlsx() {
    var myScript = document.createElement('script');
    myScript.src = 'https://cdn.bootcss.com/xlsx/0.11.5/xlsx.core.min.js';
    document.getElementsByTagName('head')[0].appendChild(myScript);
}


//@页面启动
(function () {
    //加载库
    setTimeout(function () {
      jquery();
       Menu();
       xlsx();
       ButtonColorScheme()
        //alert("Hello,欢迎使用【QingFlow Dragon King Super Tools】\n轻流QingFlow应用自动超级字段插件🐲\n\n@author       Mr.Dragon King \n@version      0.2\n\n使用帮助:\nhttps://www.yuque.com/g/mrscott-prexr/bgia0r/hfwq3pdgm0y7m50i/collaborator/join?token=Je5Br7K9hrV1R8FE# 《QingFlow Dragon King Super Tools使用帮助》\n\n更多信息可联系作者");
    }, 2000);
})();


$(function () {
    $(document).on("click", "#a", function () {
        console.log("优化界面完成")
    });
});


//=================================功能菜单=================================
//@菜单menu
function Menu() {
    setInterval(function () {
        if (window.location.href.slice(0, 23) == "https://qingflow.com/f/" && $x("/html/body/qf-root/qf-pages/qf-app-item/qf-creation/qf-header-edit/div").length <= 0) {
            var BatchAddFields = "<button id='BatchAddFields'  style='height: 36px;margin-left:20px; margin-bottom:20px;  margin-top: 20px; border: 1px solid #e6eaf0;  border-radius: 4px; border-radius: 4px; color: #494f57;cursor: pointer; background: #F9FAFC;'><img src='https://676f-gokuschool-3gl85srrc0c313c4-1304791592.tcb.qcloud.la/cmsReminderServiceResources/%E6%9C%BA%E5%99%A8%E4%BA%BA.svg?sign=1727c41556cebb66a63fe2dc66ffbdcf&t=1670171513' width='20' height='20'><text style='margin-left:6px;'>批量添加字段</text></button>";//批量添加字段按钮
            var Help = "<button id='Help'  style='height: 36px;margin-left:20px; margin-bottom:20px;  margin-top: 20px; border: 1px solid #e6eaf0;  border-radius: 4px; border-radius: 4px; color: #494f57;cursor: pointer; background: #F9FAFC;'><img src='https://676f-gokuschool-3gl85srrc0c313c4-1304791592.tcb.qcloud.la/cmsReminderServiceResources/%E5%BD%A9%E8%89%B2-%E7%81%AF%E6%B3%A1.svg?sign=f387acd6cb69645382da1fe9df239091&t=1670173993' width='20' height='20'><text style='margin-left:6px;'>插件使用帮助</text></button>";//插件使用帮助按钮
            var SystemDesignDrawing = "<button id='SystemDesignDrawing'  style='height: 36px;margin-left:20px; margin-bottom:20px;  margin-top: 20px; border: 1px solid #e6eaf0;  border-radius: 4px; border-radius: 4px; color: #494f57;cursor: pointer; background: #F9FAFC;'><img src='https://dss0.bdstatic.com/-0U0bXSm1A5BphGlnYG/tam-ogel/1208056450_-1268512460_88_88.png' width='20' height='20'><text style='margin-left:6px;border-radius:20px'>QingFlow系统设计图</text></button>";//系统设计图
            var PageOptimization = "<button id='PageOptimization'  style='height: 36px;margin-left:20px; margin-bottom:20px;  margin-top: 20px; border: 1px solid #e6eaf0;  border-radius: 4px; border-radius: 4px; color: #494f57;cursor: pointer; background: #F9FAFC;'><img src='https://676f-gokuschool-3gl85srrc0c313c4-1304791592.tcb.qcloud.la/cmsReminderServiceResources/%E4%BC%98%E5%8C%962.svg?sign=53206c2ccaab27ae4ee1a624db4574d5&t=1670356354' width='20' height='20'><text style='margin-left:6px;border-radius:20px'>面板界面优化</text></button>";//界面优化
            var ExcelImport = "<input type='file' id='excel-file' style='height: 36px;margin-left:20px; margin-bottom:20px;  margin-top: 20px; border: 1px solid #e6eaf0;  border-radius: 4px; border-radius: 4px; color: #494f57;cursor: pointer; background: #F9FAFC;'>";//Excel导入
            $("body > qf-root > qf-pages > qf-app-item > qf-creation > qf-header-edit > header").before("<div style='z-index:999'>"+ BatchAddFields + PageOptimization + Help + SystemDesignDrawing + ExcelImport +"</div>");
        }
    }, 2000);
}

//=================================插件使用帮助=================================
//@插件使用帮助Help
$(function () {
    $(document).on("click", "#Help", function () {
        alert("Hello,欢迎使用【QingFlow Dragon King Super Tools】\n轻流QingFlow应用自动超级字段插件🐲\n插件使用帮助文档待上传,当前如存在使用问题可联系作者!!!");
    });
});
//=================================轻流系统设计图=================================
//@轻流系统设计图SystemDesignDrawing
$(function () {
    $(document).on("click", "#SystemDesignDrawing", function () {
        window.open("https://exiao.yuque.com/pc5k40/ngqg4r/oucgap?singleDoc", "_blank");
    });
});

//=================================面板界面优化=================================
//@面板界面优化PageOptimization
$(function () {
    $(document).on("click", "#PageOptimization", function () {
        PageOptimizationOpen = true;
        setTimeout(() => {
            $x("/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]")[0].style.cssText = "width:350px";
            console.log("优化界面完成")
        }, 1000)
    });
});

//=================================按钮配色优化方案=================================
function ButtonColorScheme(){
    if(ButtonColorOpen){
     var ButtonColorURL = `https://gokuschool-3gl85srrc0c313c4-1304791592.ap-shanghai.service.tcloudbase.com/gokuschool/v1.0/QF_SkinColour/${ButtonColorTypeID}`
     console.log("获取在线皮肤方案")
    GM_xmlhttpRequest({
    method:     "GET",
    headers: {
            "Content-Type": "application/json"
        },
    url: ButtonColorURL,
        onload: function(res){
         console.log("返回",JSON.parse(res.response));
            $(`<style>${JSON.parse(res.response).data.style}</style>`).appendTo('head');
        }
});
    }
}

//=================================设计图添加=================================
//@批量添加字段BatchAddFields
$(function () {
    $(document).on("click", "#BatchAddFields", function () {
        BatchAddFields();
    });
});


//@触发批量添加字段BatchAddFields
function BatchAddFields() {
    var InputValue = prompt("Hello,欢迎使用【QingFlow Dragon King Super Tools】\n轻流QingFlow应用自动超级字段插件🐲\n@author       Mr.Dragon King \n@version      0.2\n\n请批量输入字段信息", "【单行文本】字段名称");
    if (InputValue != null && InputValue != "") {
        AnalysisOfConstructionContent(InputValue)
    }
}

//@解析文字算法AnalysisOfConstructionContent
function AnalysisOfConstructionContent(InputData) {
    InputData = InputData.replace(/\ +/g, "");
    InputData = InputData.replace(/[\r\n]/g, "");
    var FieldAnalysisData = [];//解析结果
    var fieldData = {//字段数据
        type: "",//字段类型
        title: "",//字段标题
        parameter: [],//字段参数
    }

    var fieldData_parameter_textData = "";//解析参数字段内容 二次解析内容

    var distinguishType = 0;//识别类型 1为字段类型 2为字段名称 3为参数

    for (let textLengthIndex = 0; InputData.length > textLengthIndex; textLengthIndex++) {
        if (InputData[textLengthIndex] == "【") {  //校验字段类型添加
            //识别上个字段内容并添加到字段信息中
            if (fieldData.type.length != 0) {
                FieldAnalysisData.push(fieldData);
                //初始化值
                fieldData = {//字段数据
                    type: "",//字段类型
                    title: "",//字段标题
                    parameter: [],//字段参数
                }
                fieldData_parameter_textData = "";//解析参数字段内容 二次解析内容
            } else {
            }
            //转换识别类型 为1 字段类型
            distinguishType = 1;
        }
        if (InputData[textLengthIndex] == "】") {  //校验字段类型添加结束,添加字段标题
            fieldData.type = `${fieldData.type}${InputData[textLengthIndex]}`;
            distinguishType = 2;
        }

        if (InputData[textLengthIndex] == "(" || InputData[textLengthIndex] == "(") {  //校验字段标题添加结束,添加字段参数
            distinguishType = 3;
        }



        if (distinguishType == 1) {
            fieldData.type = `${fieldData.type}${InputData[textLengthIndex]}`
        }


        if (distinguishType == 2) {
            if (InputData[textLengthIndex] != "】") {
                fieldData.title = `${fieldData.title}${InputData[textLengthIndex]}`
            }
        }

        if (distinguishType == 3) {
            if (InputData[textLengthIndex] != "(" && InputData[textLengthIndex] != "(") {

                if (InputData[textLengthIndex] == ")" || InputData[textLengthIndex] == ")") {
                    if (fieldData_parameter_textData.length == 0) {
                    } else {
                        let outfieldData_parameter_textData = ResolveFieldParameters(fieldData_parameter_textData)
                        if (outfieldData_parameter_textData.type == "非注册参数") {
                            alert(`Hello,欢迎使用【QingFlow Dragon King Super Tools】\n轻流QingFlow应用自动超级字段插件🐲\n\n@author       Mr.Dragon King \n@version      0.2\n\n【非注册参数】\n发现未注册的字段参数,错误参数将无法进行添加到字段中!!!\n\n${fieldData.type}${fieldData.title}(${fieldData_parameter_textData})\n\n如有疑问可仔细查阅插件帮助文档,更多信息可联系作者!`);
                            fieldData_parameter_textData = "";

                        } else {
                            fieldData.parameter.push(outfieldData_parameter_textData)

                            fieldData_parameter_textData = "";

                        }
                    }

                } else {
                    if (InputData[textLengthIndex] == ";" || InputData[textLengthIndex] == ";") {
                        let outfieldData_parameter_textData = ResolveFieldParameters(fieldData_parameter_textData)
                        if (outfieldData_parameter_textData.type == "非注册参数") {
                            alert(`Hello,欢迎使用【QingFlow Dragon King Super Tools】\n轻流QingFlow应用自动超级字段插件🐲\n\n@author       Mr.Dragon King \n@version      0.2\n\n【非注册参数】\n发现未注册的字段参数,错误参数将无法进行添加到字段中!!!\n\n${fieldData.type}${fieldData.title}(${fieldData_parameter_textData})\n\n如有疑问可仔细查阅插件帮助文档,更多信息可联系作者!`);
                            fieldData_parameter_textData = "";
                        } else {
                            fieldData.parameter.push(outfieldData_parameter_textData)
                            fieldData_parameter_textData = "";
                        }
                    } else {
                        fieldData_parameter_textData = `${fieldData_parameter_textData}${InputData[textLengthIndex]}`
                    }
                }
            }
        }



        if (textLengthIndex == InputData.length - 1) {
            console.log("字段校验完成判断是否存在fieldData数据...")
            if (fieldData.type.length != 0) {
                console.log("存在fieldData数据,添加到FieldAnalysisData")
                FieldAnalysisData.push(fieldData);
                console.log("添加到FieldAnalysisData完成")

            } else {
                console.log("不存在fieldData数据,添加到FieldAnalysisData")
            }
            //初始化值
            fieldData = {//字段数据
                type: "",//字段类型
                title: "",//字段标题
                parameter: [],//字段参数
            }
            fieldData_parameter_textData = "";//解析参数字段内容 二次解析内容
            console.log("【QingFlow Dragon King Super Tools】-->字段解析完成:", FieldAnalysisData)
            AddField(FieldAnalysisData);
        }
    }
}

//@解析字段参数算法ResolveFieldParameters
function ResolveFieldParameters(fieldData_parameter_textData) {
    fieldData_parameter_textData = fieldData_parameter_textData.replace(/\ +/g, "");
    fieldData_parameter_textData = fieldData_parameter_textData.replace(/[\r\n]/g, "");
    var fieldData_parameter = {
        type: "",//参数类型
    };//缓存字段参数
    switch (fieldData_parameter_textData) {
        case "必填": {
            fieldData_parameter.type = "必填";
        }
            break;
        case "二维码": {
            fieldData_parameter.type = "二维码";
        }
            break;
        case "条形码": {
            fieldData_parameter.type = "条形码";
        }
            break;
        case "不允许重复值": {
            fieldData_parameter.type = "不允许重复值";
        }
            break;
        case "金额¥": {
            fieldData_parameter.type = "金额¥";
        }
            break;
        case "金额$": {
            fieldData_parameter.type = "金额$";
        }
        case "不允许时间重叠": {
            fieldData_parameter.type = "不允许时间重叠";
        }
            break;
        case "年": {
            fieldData_parameter.type = "年";
        }
            break;
        case "年月": {
            fieldData_parameter.type = "年月";
        }
            break;
        case "年月日": {
            fieldData_parameter.type = "年月日";
        }
            break;
        case "年月日时分": {
            fieldData_parameter.type = "年月日时分";
        }
            break;
        case "年月日时分秒": {
            fieldData_parameter.type = "年月日时分秒";
        }
        case "固定电话": {
            fieldData_parameter.type = "年月日时分秒";
        }
            break;
        case "短信验证": {
            fieldData_parameter.type = "年月日时分秒";
        }
            break;
        default: {
            if (fieldData_parameter_textData.slice(1, 7) == "关联已有数据") {
                fieldData_parameter.type = "关联已有数据";
                var DataType = 1
                var AssociateExistingData = {
                    "app": "",
                    "field": "",
                }
                for (let index = 8; index < fieldData_parameter_textData.length; index++) {
                    if (DataType == 1) {
                        if (fieldData_parameter_textData[index] != "-") {
                            AssociateExistingData.app = `${AssociateExistingData.app}${fieldData_parameter_textData[index]}`
                        } else {
                            DataType = 2;
                        }
                    }
                    if (DataType == 2) {
                        if (fieldData_parameter_textData[index] != "/" && fieldData_parameter_textData[index] != "-") {
                            AssociateExistingData.field = `${AssociateExistingData.field}${fieldData_parameter_textData[index]}`
                        }
                    }

                }
                fieldData_parameter["AssociateExistingData"] = AssociateExistingData;


            } else {
                fieldData_parameter.type = "非注册参数";
            }
        }
    }
    return fieldData_parameter;
}


//=================================添加字段算法=================================
var fieldloopIndex = 0;
//@添加字段AddField
async function AddField(FieldAnalysisData) {
    switch (FieldAnalysisData[fieldloopIndex].type) {
        case "【单行文本】": {
            await Add_field_click(field_Textfield);//添加单行文本字段
            await InputData(field_Title, FieldAnalysisData[fieldloopIndex].title);//设置字段标题
            //设置字段参数
            for (let Parameter_index = 0; Parameter_index < FieldAnalysisData[fieldloopIndex].parameter.length; Parameter_index++) {
                if (FieldAnalysisData[fieldloopIndex].parameter[Parameter_index].type == "关联已有数据") {
                    await ToggleDefault();//切换默认内容选择
                    await Choice_AssociateExistingData();//选择元素2-关联已有数据
                    await Choice_AssociateExistingData_App();//触发关联已有数据的应用
                    await Choice_AssociateExistingData_AppInput(FieldAnalysisData[fieldloopIndex].parameter[Parameter_index].AssociateExistingData.app);//关联已有数据的应用名称输入
                    await Choice_AssociateExistingData_AppChoice(FieldAnalysisData[fieldloopIndex].parameter[Parameter_index].AssociateExistingData.app);//关联已有数据的应用选择
                    await Choice_AssociateExistingData_Field();//触发关联已有数据的字段
                    await Choice_AssociateExistingData_FieldInput(FieldAnalysisData[fieldloopIndex].parameter[Parameter_index].AssociateExistingData.field);//关联已有数据的字段名称输入
                    await Choice_AssociateExistingData_FieldChoice(FieldAnalysisData[fieldloopIndex].parameter[Parameter_index].AssociateExistingData.field);//关联已有数据的字段选择
                } else {
                    await Textfield_Parameter(FieldAnalysisData[fieldloopIndex].parameter[Parameter_index])
                }
            }
        }
            break;
        default: {
            console.log("未注册字段", FieldAnalysisData[fieldloopIndex].type)
        }

    }

    fieldloopIndex = fieldloopIndex + 1;
    if (fieldloopIndex < FieldAnalysisData.length) {
        AddField(FieldAnalysisData)
    } else {
        fieldloopIndex = 0;
        //字段添加任务完完成进行消息推送
        if(MessagePushState == true){
            MessagePush()
        }
         setTimeout(() => {
            alert("【QingFlow Dragon King Super Tools】\n轻流QingFlow应用自动超级字段插件🐲\n字段批量添加任务已经完成😀")
        }, 1000)

    }
}
//===========================================================================================
//====================================方法事件【添加字段】===================================

//@添加字段方法 Add_field_click(field)
function Add_field_click(field) {
    return new Promise(resolve => {
        setTimeout(() => {
            $x(field)[0].click();
            resolve()//成功态
        }, 500)
    })
}
//===========================================================================================
//=================================方法事件【输入&输入结束】=================================
//@输入内容 InputData
function InputData(element, data) {
    return new Promise(resolve => {
        setTimeout(() => {
            $x(element)[0].value = data;
            InputEnd(element);
            resolve()//成功态
        }, 500)
    })
}

//@输入结束 InputEvent
function InputEnd(data) {
    return new Promise(resolve => {
        $x(data)[0].dispatchEvent(new InputEvent("input"));
        resolve()//成功态
    })
}
//===========================================================================================
//====================================字段参数===============================================
//=================================字段参数【单行文本参数】==================================
//@添加单行文本参数Textfield_Parameter
async function Textfield_Parameter(parameter) {
    return new Promise(resolve => {
        setTimeout(() => {
            switch (parameter.type) {
                case "必填": {
                    if($x(fieldParameter_Required).length == 1){
                     $x(fieldParameter_Required)[0].click()
                    }
                }
                    break;
                case "二维码": {
                     if($x(fieldParameter_QRCode).length == 1){
                     $x(fieldParameter_QRCode)[0].click()
                    }
                   }
                    break;
                case "条形码": {
                    if($x(fieldParameter_QRCode).length == 1){
                     $x(fieldParameter_QRCode)[0].click()
                        setTimeout(() => {
                            if( $x(fieldParameter_BarCode).length == 1){
                                $x(fieldParameter_BarCode)[0].click()
                            }
                    }, 200)
                    }
                }
                    break;
                case "不允许重复值": {
                    if($x(fieldParameter_NotDuplicateValue).length == 1){
                     $x(fieldParameter_NotDuplicateValue)[0].click()
                    }
                }
                    break;
                default: {
                    console.log("未注册字段参数")
                }
            }
            resolve()//成功态
        }, 500)
    })
}
//=================================字段参数【多行文本参数】=================================
//@添加多行文本参数Textarea_Parameter
async function Textarea_Parameter(parameter) {
    return new Promise(resolve => {
        setTimeout(() => {
            switch (parameter.type) {
                case "必填": {
                    $x("/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]/qf-edit-area/div/qf-function-lock/div[1]/label")[0].click()
                }
                    break;
                case "不允许重复值": {
                    $x("/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[3]/qf-edit-area/div/qf-function-lock/div[3]/label")[0].click()
                }
                    break;
                default: {
                    console.log("未注册字段参数")
                }
            }
            resolve()//成功态
        }, 500)
    })
}
//=================================特殊参数【关联已有数据】=================================

//@切换默认 ToggleDefault
function ToggleDefault() {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                if ($x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-select/qf-select-top-control/qf-select-item`).length == 1) {
                    $x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-select/qf-select-top-control/qf-select-item`)[0].click();
                    openType = false;
                }
            }
            resolve()//成功态
        }, 200)
    })
}

//@切换关联已有数据 Choice_AssociateExistingData
function Choice_AssociateExistingData() {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                for (let index_1 = 0; index_1 < 99 && openType == true; index_1++) {
                    if ($x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item[2]`).length == 1) {
                        $x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item[2]`)[0].click();
                        openType = false;
                    }
                }
            }
            resolve()//成功态
        }, 200)
    })
}


//@触发关联已有数据的应用 Choice_AssociateExistingData_App
function Choice_AssociateExistingData_App() {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                if ($x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[1]/qf-select-top-control/div[1]/input`).length==1) {
                    $x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[1]/qf-select-top-control/div[1]/input`)[0].click();
                    openType = false;
                }
            }
            resolve()//成功态
        }, 200)
    })
}

//@关联已有数据的应用名称输入 Choice_AssociateExistingData_AppInput
function Choice_AssociateExistingData_AppInput(appName) {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                if ($x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[1]/qf-select-top-control/div[1]/input`).length == 1) {
                    $x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[1]/qf-select-top-control/div[1]/input`)[0].value = appName;
                    InputEnd(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[1]/qf-select-top-control/div[1]/input`);
                    openType = false;
                }
            }
            resolve()//成功态
        }, 200)
    })
}


//@关联已有数据的应用选择 Choice_AssociateExistingData_AppChoice
function Choice_AssociateExistingData_AppChoice(appName) {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                for (let index_1 = 0; index_1 < 99 && openType == true; index_1++) {
                    if ($x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item`).length>0) {
                        for (let index_2 = 0; index_2 < $x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item`).length; index_2++) {
                            let index_3 = index_2+1;
                            if ($x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item[${index_3}]/div`)[0].innerText==appName) {
                                $x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item`)[`${index_2}`].click();
                                openType = false;
                            }
                        }
                    }
                }
            }
            resolve()//成功态
        }, 200)
    })
}

//@触发关联已有数据的字段 Choice_AssociateExistingData_Field
function Choice_AssociateExistingData_Field() {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                if ($x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[2]/qf-select-top-control/div[1]/input`).length == 1) {
                    $x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[2]/qf-select-top-control/div[1]/input`)[0].click();
                    openType = false;
                }
            }
            resolve()//成功态
        }, 200)
    })
}

//@关联已有数据的字段名称输入 Choice_AssociateExistingData_FieldInput
function Choice_AssociateExistingData_FieldInput(fieldName) {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                if ($x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[2]/qf-select-top-control/div[1]/input`).length == 1) {
                    $x(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[2]/qf-select-top-control/div[1]/input`)[0].value = fieldName;;
                    InputEnd(`/html/body/qf-root/qf-pages/qf-app-item/qf-creation/div/div[${index}]/qf-edit-area/div/qf-function-lock/qf-dft-val-edit/div/qf-function-lock/qf-dft-associate-data/div[1]/qf-select[2]/qf-select-top-control/div[1]/input`);
                    openType = false;
                }
            }
            resolve()//成功态
        }, 200)
    })
}


//@关联已有数据的字段选择Choice_AssociateExistingData_FieldChoice
function Choice_AssociateExistingData_FieldChoice(fieldName) {
    return new Promise(resolve => {
        setTimeout(() => {
            var openType = true
            for (let index = 0; index < 99 && openType == true; index++) {
                for (let index_1 = 0; index_1 < 99 && openType == true; index_1++) {
                    if ($x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item`).length>0) {
                        for (let index_2 = 0; index_2 < $x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item`).length; index_2++) {
                            let index_3 = index_2+1;
                            if ($x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item[${index_3}]/div`)[0].innerText==fieldName) {
                                $x(`/html/body/div[${index}]/div[${index_1}]/div/qf-option-container/div[2]/cdk-virtual-scroll-viewport/div[1]/div/qf-option-item`)[`${index_2}`].click();
                                openType = false;
                            }
                        }
                    }
                }
            }
            resolve()//成功态
        }, 200)
    })
}
//=========================================================================================
//=======================================Excel字段导入【Excel】============================
$(function () {
    $(document).on("change", "#excel-file", function (e) {
 var files = e.target.files;
        var fileReader = new FileReader();
        fileReader.onload = function (ev) {
            try {
                var data = ev.target.result
                var workbook = XLSX.read(data, {
                    type: 'binary'
                }) // 以二进制流方式读取得到整份excel表格对象
                var persons = []; // 存储获取到的数据
            } catch (e) {
                console.log('文件类型不正确');
                return;
            }
            // 表格的表格范围,可用于判断表头是否数量是否正确
            var fromTo = '';
            // 遍历每张表读取
            for (var sheet in workbook.Sheets) {
                if (workbook.Sheets.hasOwnProperty(sheet)) {
                    fromTo = workbook.Sheets[sheet]['!ref'];
                    persons = persons.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
                    let FieldAnalysisData  = EXCEL_FieldAnalysisData(workbook.Sheets[sheet])
                    console.log("【QingFlow Dragon King Super Tools】-->Excel字段导入解析完成:", FieldAnalysisData)
                    AddField(FieldAnalysisData);
                    break; // 如果只取第一张表,就取消注释这行
                }
            }
            var index = 0;
            for (var i in persons) {
                var prjid = persons[i].prjid;
                var parentid = persons[i].parentid;
                var subject = persons[i].subject;
                var hrmid = persons[i].hrmid;
                var begindate = persons[i].begindate;
                begindate = new Date(begindate).toLocaleDateString().replace(/\//g, '-');

                var enddate = persons[i].enddate;
                enddate = new Date(enddate).toLocaleDateString().replace(/\//g, '-');

                var actualbegindate = persons[i].actualbegindate;
                actualbegindate = new Date(actualbegindate).toLocaleDateString().replace(/\//g, '-');

                var actualenddate = persons[i].actualenddate;
                actualenddate = new Date(actualenddate).toLocaleDateString().replace(/\//g, '-');

                var stageid = persons[i].stageid;
                var finish = persons[i].finish;

            }
            //在控制台打印出来表格中的数据
        };
        // 以二进制方式打开文件
        fileReader.readAsBinaryString(files[0]);
        console.log(files);
    });
});
    function EXCEL_FieldAnalysisData(sheet) {
            const FieldAnalysisData = [];//解析结果
            /* sheet['!ref']表示所有单元格的范围,例如从A1到F8则记录为 A1:F8*/
            const range = XLSX.utils.decode_range(sheet['!ref'])
            let C,
                R = range.s.r + 0 /* 从第一行开始 */
            /* 按列进行数据遍历 */
            for (C = range.s.c; C <= range.e.c; ++C) {
                /* 查找第一行中的单元格 */
                const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]
                let hdr = 'UNKNOWN ' + C // <-- 进行默认值设置
                if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
                //格式化数据格式

                var fieldData = {//字段数据
                    type: "【单行文本】",//字段类型
                    title: hdr,//字段标题
                    parameter: [],//字段参数
                }
                FieldAnalysisData.push(fieldData)

            }
            return FieldAnalysisData
        };
//===========================================================================
//=======================================消息推送============================
function MessagePush(){
     var data = {
            QW_QrobotHook: QW_QrobotHook,
    };
    GM_xmlhttpRequest({
    method: "post",
    headers: {
            "Content-Type": "application/json"
        },
    url: "https://api.hiflow.tencent.com/engine/webhook/31/1609213102068162561",
    data: JSON.stringify(data),
        onload: function(res){
                // code
         console.log("返回",res);
        }
});
}
//===========================================================================