 /**
     * 
     * @param {Array} arg 
     * @return {String} 
     *
     */
    function template(arg) {
        let scriptTypeCode = {1: 'shell',2: 'bat',3: 'perl', 4: 'python', 5: 'Powershell'};
        var ao;
        var innerTem = ''
        if (Array.isArray(arg)) {
            
            for (var i = 0; i < arg.length; i++) {
                ao = scriptTypeCode[arg[i].scriptType]
                innerTem += `
                    <tr data-name='${arg[i].name}'>
                        <td>
                            <input type="checkbox" name="check" value="">
                        </td>
                        <td>${arg[i].name}</td>
                        <td>${arg[i].createUser}</td>
                        <td>${arg[i].createTime}</td>
                        <td>${ao}</td>
                        <td>${arg[i].description}</td>
                        <td>
                            
                            <button type="button" data-toggle="modal"  style="padding:2px 4px; font-size:12px" class="btn btn-success update-script" 
                                data-scriptid='${arg[i].script_id}'
                                data-name="${arg[i].name}"
                                data-scripttype="${arg[i].scriptType}"
                                data-description="${arg[i].description}">
                                <span style="display:none">${arg[i].scriptText}</span>
                                修改
                            </button>
                            <button  type="button" style="padding:2px 4px; font-size:12px" class="btn btn-success delete-script" 
                                data-scriptid="${arg[i].script_id}">
                                删除
                            </button>
                            <button type="button" style="padding:2px 4px; font-size:12px;display:none" class="btn btn-success" 
                                data-id="${arg[i].ScriptText}">
                                执行33
                            </button>
                        </td>
                    </tr>
                `
            }
            return innerTem;
        }
    }

    function selecedOption(arr) {
        if(Array.isArray(arr)) {
            var innerTem = ''
            for(var i = 0; i < arr.length; i++) {
                innerTem += `<option value="${arr[i].id}">${arr[i].name}</option>`
            }
            return innerTem
        }
    }

    /**
     * 选择脚本
     * @param {Array} arg
     * @return {String} 
     */

    function selectScr(arg) {
        if (Array.isArray(arg)) {
            var innerTem = ''
            for (var i = 0; i < arg.length; i++) {
                innerTem += `
                <tr>
                    <td>
                        <input type="checkbox" class="seleced-machine" value="${arg[i].script_id}">
                    </td>
                    <td>${arg[i].name}</td>
                    <td>${arg[i].scriptType}</td>
                    <td>${arg[i].createTime}</td>
                    <td>7</td>
                    <td>${arg[i].description}</td>
                </tr>
                `
            }
            return innerTem;
        }
    }

    function createTree(arg) {
        if(Array.isArray(arg)) {
            var treeString = ''
            arg.forEach(val => {
                treeString += `
                <li>
                    <a class="list-group-item node-plugin12_demo2 group-script" data-nodeid="${val.id}" href="javascript:;">
                        <span class="glyphicon glyphicon-chevron-down"></span>
                        ${val.name}
                        
                    </a>`
                if(val.children.length > 0) {
                    treeString += `<ul style="padding:0">`
                    for(var i = 0; i < val.children.length; i++) {
                        treeString += `<li>
                            <a href="javascript:;" onclick="getScript(${val.children[i].id})" style="padding-left:40px;height:42px" class="list-group-item node-plugin12_demo2 script-item ${i==0?'group-active':''}" data-nodeid="${val.children[i].id}">${val.children[i].name}
                                <span class="opt" style="float:right;display:none">
                                    <span class="edite" style="margin-right:10px;" onclick="editeScript(event, ${val.children[i].id}, '${val.children[i].name}', '${val.name}', ${val.id})">
                                        <i class="fa fa-pencil"  aria-hidden="true"></i>
                                    </span>
                                    <span class="delete" onclick="deleteScript(event, ${val.children[i].id})"><i class="fa fa-trash-o" aria-hidden="true"></i></span>
                                </span>
                            </a>
                        </li>`
                    }
                    treeString += `</ul>`
                }
                treeString += `</li>`
                
            })
            return treeString
        }
    }

    /**
     * 执行历史的列表
     * @param {Array}
     * @return {String}
     */
    function executeHis(arg) {
        if (Array.isArray(arg)) {
            var innerTem = ''
            for (var i = 0; i < arg.length; i++) {
                innerTem += `
                    
                <tr>
                    <td>
                        ${i + 1}
                    </td>
                    <td>${arg[i].ip}</td>
                    <td>${arg[i].hostName}</td>
                    <td>${arg[i].ciCode}</td>
                    <td>${arg[i].appSystem}</td>
                </tr>
                `
            }
            return innerTem;
        }
    }

    function machineList(arg) {
        if (Array.isArray(arg)) {
            var innerTem = ''
            for (var i = 0; i < arg.length; i++) {
                innerTem += `
                    
                <tr>
                    <td>
                        <input type="checkbox" value="${arg[i].bk_cloud_id}" data-ip="${arg[i].ip}" data-ostype="${arg[i].os_type}">
                    </td>
                    <td>
                        ${i + 1}
                    </td>
                    <td>${arg[i].ip}</td>
                    <td>${arg[i].os_type}</td>
                    <td>${arg[i].bk_agent_alive == 1? "是" : "否"}</td>
                </tr>
                `
            }
            return innerTem;
        }
    }


