# app_script_history

id: 61873c175db28ef4db6d6a85
scriptid: 6183205499328c3820c0c8f1
tablename: app_template
clientip: 192.168.3.2
username: sa
createdate: 2021.11.07 11:25:31.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.getWorkSheet("filter").cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
        var ym = book.getWorkSheet("filter").cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.getWorkSheet("凭证详情").getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.getWorkSheet("凭证详情").yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {

    }

}

//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.getWorkSheet("list").View.forceCurrentEditControlGiveUpFocus();

    var v = book.getWorkSheet("list").cells('selection').getValueInt();

    book.getWorkSheet("list").paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.getWorkSheet("list").paintPermit = true;
}





/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        return;
        
        let brick = sheet.getBrick(name);
        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-crop",   // 字符图标
            "查看大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let img = $('#' + id).find('.image');
                let url = img.attr("largeimage");
                open(url);
            });


    }
}

/**
 * 图片控件中显示大图时添加水印图片
 * @param sheet   所在Sheet
 * @param name  图片控件的名称

 * @return  返回水印图片的url地址 ，如果返回  '' 则表示不添加水印图片
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnPopupWithWatermark(sheet , name ) {

    var info= currentUserShowName( ) +" "+ formatDate( new Date() , "yyyy.MM.dd HH:mm");
    info= encodeURI(info); 
    return "watermark?watermark="+info;

}


id: 61873c175db28ef4db6d6a92
scriptid: 6183205499328c3820c0c8f1
tablename: app_template
clientip: 192.168.3.2
username: sa
createdate: 2021.11.07 11:31:25.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.getWorkSheet("filter").cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
        var ym = book.getWorkSheet("filter").cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.getWorkSheet("凭证详情").getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.getWorkSheet("凭证详情").yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {

    }

}

//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.getWorkSheet("list").View.forceCurrentEditControlGiveUpFocus();

    var v = book.getWorkSheet("list").cells('selection').getValueInt();

    book.getWorkSheet("list").paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.getWorkSheet("list").paintPermit = true;
}





/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        return;
        
        let brick = sheet.getBrick(name);
        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-crop",   // 字符图标
            "查看大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let img = $('#' + id).find('.image');
                let url = img.attr("largeimage");
                open(url);
            });


    }
}

/**
 * 图片控件中显示大图时添加水印图片
 * @param sheet   所在Sheet
 * @param name  图片控件的名称

 * @return  返回水印图片的url地址 ，如果返回  '' 则表示不添加水印图片
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnPopupWithWatermark(sheet , name ) {

    var info= currentUserShowName( ) +" "+ formatDate( new Date() , "yyyy.MM.dd HH:mm");
    info= encodeURI(encodeURI(info)); 
    return "watermark?watermark="+info;

}


id: 61873c175db28ef4db6d6a98
scriptid: 6183205499328c3820c0c8f1
tablename: app_template
clientip: 192.168.3.2
username: sa
createdate: 2021.11.07 11:34:29.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.getWorkSheet("filter").cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
        var ym = book.getWorkSheet("filter").cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.getWorkSheet("凭证详情").getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.getWorkSheet("凭证详情").yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {

    }

}

//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.getWorkSheet("list").View.forceCurrentEditControlGiveUpFocus();

    var v = book.getWorkSheet("list").cells('selection').getValueInt();

    book.getWorkSheet("list").paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.getWorkSheet("list").paintPermit = true;
}





/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        return;
        
        let brick = sheet.getBrick(name);
        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-crop",   // 字符图标
            "查看大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let img = $('#' + id).find('.image');
                let url = img.attr("largeimage");
                open(url);
            });


    }
}

/**
 * 图片控件中显示大图时添加水印图片
 * @param sheet   所在Sheet
 * @param name  图片控件的名称

 * @return  返回水印图片的url地址 ，如果返回  '' 则表示不添加水印图片
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnPopupWithWatermark(sheet , name ) {

    var info= currentUserShowName( ) +" "+ formatDate( new Date() , "yyyy.MM.dd HH:mm");
    info= encodeURI(encodeURI(info)); 
    //return "watermark?watermark="+info;
    return "http://192.168.3.2:8080/watermark?watermark=abc测试";

}


id: 61874e8c9932a8d2510119a9
scriptid: 6183205499328c3820c0c8f1
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.07 11:59:39.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.getWorkSheet("filter").cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
        var ym = book.getWorkSheet("filter").cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.getWorkSheet("凭证详情").getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.getWorkSheet("凭证详情").yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {

    }

}

//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.getWorkSheet("list").View.forceCurrentEditControlGiveUpFocus();

    var v = book.getWorkSheet("list").cells('selection').getValueInt();

    book.getWorkSheet("list").paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.getWorkSheet("list").paintPermit = true;
}





/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        return;
        
        let brick = sheet.getBrick(name);
        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-crop",   // 字符图标
            "查看大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let img = $('#' + id).find('.image');
                let url = img.attr("largeimage");
                open(url);
            });


    }
}

/**
 * 图片控件中显示大图时添加水印图片
 * @param sheet   所在Sheet
 * @param name  图片控件的名称

 * @return  返回水印图片的url地址 ，如果返回  '' 则表示不添加水印图片
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnPopupWithWatermark(sheet , name ) {

    var info= currentUserShowName( ) +" "+ formatDate( new Date() , "yyyy.MM.dd HH:mm");
    info= encodeURI(encodeURI(info)); 
    return "watermark?watermark="+info;
    
}


id: 61874e8c9932a8d2510119af
scriptid: 6183205499328c3820c0c8f1
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.07 12:02:37.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.getWorkSheet("filter").cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
        var ym = book.getWorkSheet("filter").cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.getWorkSheet("凭证详情").getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.getWorkSheet("凭证详情").yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {

    }

}

//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.getWorkSheet("list").View.forceCurrentEditControlGiveUpFocus();

    var v = book.getWorkSheet("list").cells('selection').getValueInt();

    book.getWorkSheet("list").paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.getWorkSheet("list").paintPermit = true;
}





/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        return;
        
        let brick = sheet.getBrick(name);
        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-crop",   // 字符图标
            "查看大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let img = $('#' + id).find('.image');
                let url = img.attr("largeimage");
                open(url);
            });


    }
}

/**
 * 图片控件中显示大图时添加水印图片
 * @param sheet   所在Sheet
 * @param name  图片控件的名称

 * @return  返回水印图片的url地址 ，如果返回  '' 则表示不添加水印图片
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnPopupWithWatermark(sheet , name ) {

    var info= currentUserName( ) +" "+ formatDate( new Date() , "yyyy.MM.dd-HH:mm");
    
    return "watermark?watermark="+info;
    
}


id: 61874e8c9932a8d2510119b5
scriptid: 6183205499328c3820c0c8f1
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.07 12:04:07.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.getWorkSheet("filter").cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
        var ym = book.getWorkSheet("filter").cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.getWorkSheet("凭证详情").getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.getWorkSheet("凭证详情").yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {

    }

}

//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.getWorkSheet("list").View.forceCurrentEditControlGiveUpFocus();

    var v = book.getWorkSheet("list").cells('selection').getValueInt();

    book.getWorkSheet("list").paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.getWorkSheet("list").paintPermit = true;
}





/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        return;
        
        let brick = sheet.getBrick(name);
        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-crop",   // 字符图标
            "查看大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let img = $('#' + id).find('.image');
                let url = img.attr("largeimage");
                open(url);
            });


    }
}

/**
 * 图片控件中显示大图时添加水印图片
 * @param sheet   所在Sheet
 * @param name  图片控件的名称

 * @return  返回水印图片的url地址 ，如果返回  '' 则表示不添加水印图片
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnPopupWithWatermark(sheet , name ) {

    var info= currentUserName( ) +""+ formatDate( new Date() , "yyyy.MM.dd-HH:mm");
    
    return "watermark?watermark="+info;
    
}


id: 61874e8c9932a8d2510119bb
scriptid: 6183205499328c3820c0c8f1
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.07 12:10:39.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.getWorkSheet("filter").cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.getWorkSheet("filter").cells("corpid").getValueString();
        var ym = book.getWorkSheet("filter").cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.getWorkSheet("filter").cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.getWorkSheet("凭证详情").getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.getWorkSheet("凭证详情").yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {

    }

}

//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.getWorkSheet("list").View.forceCurrentEditControlGiveUpFocus();

    var v = book.getWorkSheet("list").cells('selection').getValueInt();

    book.getWorkSheet("list").paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.getWorkSheet("list").paintPermit = true;
}





/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        return;
        
        let brick = sheet.getBrick(name);
        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-crop",   // 字符图标
            "查看大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let img = $('#' + id).find('.image');
                let url = img.attr("largeimage");
                open(url);
            });


    }
}

/**
 * 图片控件中显示大图时添加水印图片
 * @param sheet   所在Sheet
 * @param name  图片控件的名称

 * @return  返回水印图片的url地址 ，如果返回  '' 则表示不添加水印图片
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnPopupWithWatermark(sheet , name ) {

    var info= currentUserShowName( ) +""+ formatDate( new Date() , "yyyy.MM.dd-HH:mm");
    
    return "watermark?watermark="+info;
    
}


id: 61922d309932fda9010e741f
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 17:58:28.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}


id: 60a3505f5db27838e0c015a0
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.18 16:22:20.000
script:
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}


function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
    var 
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a67c6b5db22d6e34006eb9
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.20 23:26:35.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


id: 61922d309932fda9010e7429
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 18:55:12.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    alert(1);
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}


id: 61922d309932fda9010e742f
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 18:58:27.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}


id: 60a3505f5db27838e0c0155f
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.18 13:34:31.000
script:
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user");
    return ret.gguid; 
    
}


id: 60a3505f5db27838e0c01565
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.18 13:36:30.000
script:
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return ret.gguid; 
    
}


id: 60a3505f5db27838e0c0156b
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.18 13:37:39.000
script:
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}


id: 60a37a225db27838e0c015c9
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.18 16:27:20.000
script:
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}




function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
    var 
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a37a225db27838e0c015f1
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.18 16:42:33.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
    var 
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a37a225db27838e0c015ff
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.18 23:18:27.000
script:
function formOpen()
{


 
  $('.gridly1').gridly({
    base: 60, // px 
    gutter: 20, // px
    columns: 12
  });
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


id: 60a4de8b5db22f67e8f93e66
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.19 22:40:47.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}




//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
    var 
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a4de8b5db22f67e8f93e6e
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.19 22:43:04.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}




//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
    
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a4de8b5db22f67e8f93e76
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.19 22:45:09.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}





//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
var     
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a528405db2f6898f0c9c7d
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.19 23:11:12.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}





//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
     
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a67c6b5db22d6e34006ec3
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 10:36:12.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    console.dir(data);
}


id: 60a67c6b5db22d6e34006ecc
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 10:43:15.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}


id: 60a67c6b5db22d6e34006ed5
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 11:01:14.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    $prompt("请输入凭证号码：","", function(){
            
    });
}


id: 60a722b95db22d6e34006edb
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 11:02:18.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    $prompt("标记为凭证","请输入凭证号码：","", function(){

    });
}


id: 60a722b95db22d6e34006ee1
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 11:02:47.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    $prompt("标记为凭证","请输入凭证号码：","", function(val){
        alert( val);

    });
}


id: 60a722b95db22d6e34006ee7
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 11:04:56.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    $prompt("标记为凭证","","","输入凭证号码", function(val){
        alert( val);

    });
}


id: 60a722b95db22d6e34006eed
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 11:13:28.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    inputBox("标记为凭证","","","输入凭证号码", function(val){
        alert( val);

    });
}


id: 60c1c2469932e1a17db2e4ad
scriptid: 60a31c3c5db27838e0c012a2
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.06.10 16:04:29.000
script:
/**
 * 表单初始化完成后，执行此事件
 */
//@comment (group=表单事件,caption=表单初始化完成)
function formOpen()
{
book.showTabOnWhere="top";



}

//图片控件初始化之前的处理，注入参数
function imageGridlyBefireInit(sheet, name, data)
{
                sheet.getBrick(name).config.uploadButtonDisabled  =true;
}


id: 61922d309932fda9010e7435
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 18:59:25.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(0  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}


id: 60a722b95db22d6e34006ef6
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 12:19:49.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet , name, data ) {
    
    book.sheet0.cells("imgPreview").setValue("");
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    inputBox("标记为凭证","","","输入凭证号码", function(val){
        alert( val);

    } , true /*允许为空*/);
}


id: 60a722b95db22d6e34006f00
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:09:40.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 
 $(document.body).append(`<style
      .pzh {position:absolute;left:0;bottom:0px; height:24px; line-height:24px;width:100%; background-color:#40af40a0; color:white;font-weight:bold;font-size:16px;text-align:center;}
 </style>
 `);


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet , name, data ) {
    
    book.sheet0.cells("imgPreview").setValue("");
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    inputBox("标记为凭证","","","输入凭证号码", function(val){
        if( val=='')
        {
            var p= find_pzh(data.id , false );
            if( p)  p.remove();    
        }else{
            find_pzh(dta.id,true).text( val); 
        }

    } , true /*允许为空*/);
}


function find_pzh( id , create_if_not_exists)
{
    var d= $('#'+id);
    if( !d)
    {
        $.alert(id+"不存在");
        return null; 
    }  

    var ret= d.find('.pzh');
    if( ret==null)
    {
        if( create_if_not_exists)
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret=d.find('.pzh');
    }
    return ret; 

}


id: 60a722b95db22d6e34006f06
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:10:36.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 
 $(document.body).append(`<style
      .pzh {position:absolute;left:0;bottom:0px; height:24px; line-height:24px;width:100%; background-color:#40af40a0; color:white;font-weight:bold;font-size:16px;text-align:center;}
 </style>
 `);


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet , name, data ) {
    
    book.sheet0.cells("imgPreview").setValue("");
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    inputBox("标记为凭证","","","输入凭证号码", function(val){
        if( val=='')
        {
            var p= find_pzh(data.id , false );
            if( p)  p.remove();    
        }else{
            find_pzh(dta.id,true).text( val); 
        }

    } , true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh( id , create_if_not_exists)
{
    var d= $('#'+id);
    if( !d)
    {
        $.alert(id+"不存在");
        return null; 
    }  

    var ret= d.find('.pzh');
    if( ret==null)
    {
        if( create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret=d.find('.pzh');
    }
    return ret; 

}


id: 60a722b95db22d6e34006f0c
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:11:15.000
script:
function formOpen()
{
    book.sheet1.getBrick('imgPool').selectionMode='multi'; //图片设置成多选模式
 
 $(document.body).append(`<style
      .pzh {position:absolute;left:0;bottom:0px; height:24px; line-height:24px;width:100%; background-color:#40af40a0; color:white;font-weight:bold;font-size:16px;text-align:center;}
 </style>
 `);


  //  let data= loadImagePoolData();
  //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet , name, data ) {
    //console.dir(data);
    var url= data.url_img; 
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet , name, data ) {
    
    book.sheet0.cells("imgPreview").setValue("");
}
 

/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet , name, data ) {
    inputBox("标记为凭证","","","输入凭证号码", function(val){
        if( val=='')
        {
            var p= find_pzh(data.id , false );
            if( p)  p.remove();    
        }else{
            find_pzh(data.id,true).text( val); 
        }

    } , true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh( id , create_if_not_exists)
{
    var d= $('#'+id);
    if( !d)
    {
        $.alert(id+"不存在");
        return null; 
    }  

    var ret= d.find('.pzh');
    if( ret==null)
    {
        if( create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret=d.find('.pzh');
    }
    return ret; 

}


id: 61922d309932fda9010e743b
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 18:59:40.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(0.5  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}


id: 60a722b95db22d6e34006f12
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:12:56.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    inputBox("标记为凭证", "", "", "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret == null) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a722b95db22d6e34006f18
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:17:53.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    inputBox("标记为凭证", "", "", "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a722b95db22d6e34006f1e
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:36:49.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh= find_pzh(data.id,false).val();

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a722b95db22d6e34006f24
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:37:16.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh= find_pzh(data.id,false).val();
    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a722b95db22d6e34006f2a
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:38:13.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh= find_pzh(data.id,false).text();
    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a8a280efb25942c0f22376
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:29:30.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}

function  getImagePoolBlockSize()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).blockSize; 
    
}


function setImagePoolBlockSize(id, blockSize)
{
    runSQL(""," update  dzpz_imgpool set blocksize="+blockSize+" where gguid='"+ id+"'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
     
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a722b95db22d6e34006f30
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:42:56.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .pzh .delete_pzh {float:right; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh= find_pzh(data.id,false).text();
    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class=".delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a722b95db22d6e34006f36
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:45:30.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .pzh .delete_pzh {float:right; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no')text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class=".delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a722b95db22d6e34006f3c
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:45:38.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .pzh .delete_pzh {float:right; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class=".delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f42
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:46:01.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .pzh .delete_pzh { float:right; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class=".delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f48
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:47:04.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .pzh .delete_pzh { position:absolute; right:0; width:40px; height:20px; top:0; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class=".delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f4e
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:47:53.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:20px; top:0; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class=".delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f54
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:48:22.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:20px; top:0; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f5a
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:49:04.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { float:right; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f60
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:49:43.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:20px; top:0; text-align:right; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh">X</div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f66
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:50:26.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:20px; top:0; text-align:right; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close"></i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60c1c2469932e1a17db2e4b3
scriptid: 60a31c3c5db27838e0c012a2
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.06.10 16:04:37.000
script:
/**
 * 表单初始化完成后，执行此事件
 */
//@comment (group=表单事件,caption=表单初始化完成)
function formOpen()
{
book.showTabOnWhere="top";



}

//图片控件初始化之前的处理，注入参数
function imageGridlyBefireInit(sheet, name, data)
{
    sheet.getBrick(name).config.uploadButtonDisabled  =true;
}


id: 619240d09932fda9010e745c
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 19:44:42.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

     book.sheet2.getBrick('FJ').selectionMode = 'multi'; //图片设置成多选模式


    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}


id: 60a7c7a85db22d6e34006f6c
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:51:32.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:20px; top:0; text-align:right; vertical-align:top; font-size:12px; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close"></i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f72
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:51:59.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; }        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close"></i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f78
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:52:23.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;}        
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close"></i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f7e
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:52:57.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close"></i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f84
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:53:31.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f8a
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:54:35.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}


id: 60a7c7a85db22d6e34006f90
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:55:02.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}


id: 60a7c7a85db22d6e34006f96
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:55:47.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');event.preventDefault();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}


id: 60a7c7a85db22d6e34006f9c
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:57:21.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}


id: 60a7cab45db22d6e34006fa2
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.21 22:59:00.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}


id: 60a7cab45db22d6e34006fa8
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 00:46:41.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectAll_onClick()
{
    book.sheet1.getBrick('imgPool').selectAll();
}


function cb_selectnull_onClick()
{
    book.sheet1.getBrick('imgPool').unSelectAll();
}


id: 60a7cab45db22d6e34006fae
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 00:49:58.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    book.sheet1.getBrick('imgPool').selectAll();
}


function cb_selectnull_onClick()
{
    book.sheet1.getBrick('imgPool').unSelectAll();
}


id: 60a867ecefb25942c0f22047
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 10:40:17.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
    },200);
    
    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    book.sheet1.getBrick('imgPool').selectAll();
}


function cb_selectnull_onClick()
{
    book.sheet1.getBrick('imgPool').unSelectAll();
}


id: 60a867ecefb25942c0f2204d
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 10:40:56.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    book.sheet1.getBrick('imgPool').selectAll();
}


function cb_selectnull_onClick()
{
    book.sheet1.getBrick('imgPool').unSelectAll();
}


id: 60a90e745db21e3d0fbaae9b
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 22:49:05.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    var ds = newDataStore(config.dbpool, "select * from " + config.logTable + "  where  gguid='" + config.gguid + "'  order by info1 "); // info1 是客户端文件创建的时间，以它排序
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    return ret;

}


function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println( ds.getError().getMessage());

}

function  getMonitePath(hostName)
{
    return   getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


id: 60a867ecefb25942c0f22053
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 10:47:07.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
    book.sheet1.getBrick("imgPool").setImageSelected( data.id , true); 
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
        } else {
            find_pzh(data.id, true).find('.no').text(val);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    book.sheet1.getBrick('imgPool').selectAll();
}


function cb_selectnull_onClick()
{
    book.sheet1.getBrick('imgPool').unSelectAll();
}


id: 60a867ecefb25942c0f22059
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 10:47:56.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
   
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , false); 
        } else {
            find_pzh(data.id, true).find('.no').text(val);
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , true); 
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    book.sheet1.getBrick('imgPool').selectAll();
}


function cb_selectnull_onClick()
{
    book.sheet1.getBrick('imgPool').unSelectAll();
}


id: 60a867ecefb25942c0f2205f
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 10:52:17.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
   
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , false); 
        } else {
            find_pzh(data.id, true).find('.no').text(val);
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , true); 
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    var imgPool=  book.sheet1.getBrick('imgPool');
    if( imgPool.getSelectedImageList().length==0)
    {
        imgPool.selectAll();
    }else{
        imgPool.unSelectAll();
    }
}


id: 60a867ecefb25942c0f22065
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 12:50:24.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    $('#blockSize').on('change', function()
    {
        let v= $('#blockSize').val();
        var imgPool=  book.sheet1.getBrick('imgPool');
        imgPool.blockSize= v; 
        imgPool.rebuildGridly();
    });

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
   
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , false); 
        } else {
            find_pzh(data.id, true).find('.no').text(val);
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , true); 
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    var imgPool=  book.sheet1.getBrick('imgPool');
    if( imgPool.getSelectedImageList().length==0)
    {
        imgPool.selectAll();
    }else{
        imgPool.unSelectAll();
    }
}


id: 60aa79be5db2172e3066fcad
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 192.168.3.2
username: sa
createdate: 2021.05.24 00:41:11.000
script:
var pathToMonit = "";
var electron=null; 

var timeHandle=0; 

function formOpen() {
    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage" , function(msg){
        msg= JSON.parse(msg);
        if( msg.cmd=="newFileUploaded")   newImgCommingTipVisible(true); //通知有新文件上传了
        if( msg.cmd=="notifyNeedUploadFileCount")  notifyNeedUploadFileCount( msg.fileCount); //通知还有多少个文件等待上传
    });

    electron= getElectron();

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);

    setTimeout(function () {
        //调取缩略图大小
        var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);


    //调取图片目录
    setTimeout( function(){
    if (electron != null) {
        var hostName = electron.getHostName();
        pathToMonit = getMonitePath(hostName);
        
        //开启监控
        if( pathToMonit!='') moniteStart(pathToMonit);
    }
    },500);
}

// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
function  saveSelectionAndPZInfo( )
{
     
    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection=selection;
    g_pzMap=pzhMap;
}

function  restoreSelectionAndPZInfo()
{
     var selection= g_selection;
     var pzhMap= g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

     //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');


    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
   
    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);
 
    moniteStart(path);


}

function moniteStart(path)
{
    pathToMonit=path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

     if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit+ " 监控中...");
    electron.ipcSendMessage( {cmd:"moniteStart" , path:path});
}

function cb_refresh_onClick()
{
    newImgCommingTipVisible(false);

     // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit( restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");
   
     
    
}

function newImgCommingTipVisible(v)
{
    book.sheet0.getBrick('shineText').visible=v;
 
}

function notifyNeedUploadFileCount( fc)
{
    var info=  fc==0?"": "【"+fc+"】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


id: 60aae1b35db2f37491f98fb2
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 192.168.3.2
username: sa
createdate: 2021.05.24 08:33:30.000
script:
var pathToMonit = "";//当前监控的目录
var electron=null; 


function formOpen() {
    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage" , function(msg){
        msg= JSON.parse(msg);
        if( msg.cmd=="newFileUploaded")   newImgCommingTipVisible(true); //通知有新文件上传了
        if( msg.cmd=="notifyNeedUploadFileCount")  notifyNeedUploadFileCount( msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron= getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);

 
    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);

    setTimeout(function () {
        //调取缩略图大小
        var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout( function(){
    if (electron != null) {
        var hostName = electron.getHostName();
        pathToMonit = getMonitePath(hostName);
        
        //开启监控
        if( pathToMonit!='') moniteStart(pathToMonit);
    }
    },500);
}

// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function  saveSelectionAndPZInfo( )
{
     
    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection=selection;
    g_pzMap=pzhMap;
}

//@comment (group=图片控件,caption=还原选中及凭证标记,needRightControl=false)
function  restoreSelectionAndPZInfo()
{
     var selection= g_selection;
     var pzhMap= g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

     //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
   
    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=图片清单刷新,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);
 
    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path)
{
    pathToMonit=path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

     if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit+ " 监控中...");
    electron.ipcSendMessage( {cmd:"moniteStart" , path:path});
}

function cb_refresh_onClick()
{
    newImgCommingTipVisible(false);

     // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit( restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");
   
     
    
}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v)
{
    book.sheet0.getBrick('shineText').visible=v;
 
}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount( fc)
{
    var info=  fc==0?"": "【"+fc+"】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


id: 60aae1b35db2f37491f98fb8
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 192.168.3.2
username: sa
createdate: 2021.05.24 08:35:52.000
script:
var pathToMonit = "";//当前监控的目录
var electron=null; 


function formOpen() {
    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage" , function(msg){
        msg= JSON.parse(msg);
        if( msg.cmd=="newFileUploaded")   newImgCommingTipVisible(true); //通知有新文件上传了
        if( msg.cmd=="notifyNeedUploadFileCount")  notifyNeedUploadFileCount( msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron= getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);

 
    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);

    setTimeout(function () {
        //调取缩略图大小
        var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout( function(){
    if (electron != null) {
        var hostName = electron.getHostName();
        pathToMonit = getMonitePath(hostName);
        
        //开启监控
        if( pathToMonit!='') moniteStart(pathToMonit);
    }
    },500);
}

// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function  saveSelectionAndPZInfo( )
{
     
    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection=selection;
    g_pzMap=pzhMap;
}

//@comment (group=图片控件,caption=还原选中及凭证标记,needRightControl=false)
function  restoreSelectionAndPZInfo()
{
     var selection= g_selection;
     var pzhMap= g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

     //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
   
    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=图片清单刷新,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);
 
    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path)
{
    pathToMonit=path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

     if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit+ " 监控中...");
    electron.ipcSendMessage( {cmd:"moniteStart" , path:path});
}

function cb_refresh_onClick()
{
    newImgCommingTipVisible(false);

     // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit( restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");
   
     
    
}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v)
{
    book.sheet0.getBrick('shineText').visible=v;
 
}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount( fc)
{
    var info=  fc==0?"": "【"+fc+"】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


id: 619240d09932fda9010e7462
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 19:47:11.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

     book.sheet2.getBrick('FJ').selectionMode = 'multi'; //图片设置成多选模式


    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-arrows-alt",   // 字符图标
            "浏览大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}


id: 60a867ecefb25942c0f2206b
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 12:52:07.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    $('#blockSize').on('change', function()
    {
        let v= $('#blockSize').val();
        var imgPool=  book.sheet1.getBrick('imgPool');
        imgPool.config.blockSize= v; 
        imgPool.rebuildGridly();
    });

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
   
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , false); 
        } else {
            find_pzh(data.id, true).find('.no').text(val);
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , true); 
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    var imgPool=  book.sheet1.getBrick('imgPool');
    if( imgPool.getSelectedImageList().length==0)
    {
        imgPool.selectAll();
    }else{
        imgPool.unSelectAll();
    }
}


id: 60a867ecefb25942c0f22071
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 12:56:56.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    $('#blockSize').on('change', function()
    {
        let v= $('#blockSize').val();
        var imgPool=  book.sheet1.getBrick('imgPool');
        imgPool.config.blockSize= parseInt(v); 
        imgPool.rebuildGridly();
    });

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
   
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , false); 
        } else {
            find_pzh(data.id, true).find('.no').text(val);
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , true); 
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    var imgPool=  book.sheet1.getBrick('imgPool');
    if( imgPool.getSelectedImageList().length==0)
    {
        imgPool.selectAll();
    }else{
        imgPool.unSelectAll();
    }
}


id: 60a867ecefb25942c0f22077
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 12:59:00.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    $('#blockSize').on('input', function()
    {
        let v= $('#blockSize').val();
        var imgPool=  book.sheet1.getBrick('imgPool');
        imgPool.config.blockSize= parseInt(v); 
        imgPool.rebuildGridly();
    });

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout( function(){
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
   
    },200);

    var pzh='';
    try{

        pzh = find_pzh(data.id,false).find('.no').text();
    }catch(err)
    {

    }

    if( pzh==undefined) pzh='';

    inputBox("标记为凭证", "", pzh , "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , false); 
        } else {
            find_pzh(data.id, true).find('.no').text(val);
             book.sheet1.getBrick("imgPool").setImageSelected( data.id , true); 
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id)
{
     var p = find_pzh(id, false);
     if (p) p.remove();
}

function cb_selectall_onClick()
{
    var imgPool=  book.sheet1.getBrick('imgPool');
    if( imgPool.getSelectedImageList().length==0)
    {
        imgPool.selectAll();
    }else{
        imgPool.unSelectAll();
    }
}


id: 60a8932defb25942c0f22081
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 13:15:53.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    let blockSizeChangedTimeID = 0;
    $('#blockSize').on('input', function () {
        clearTimeout(blockSizeChangedTimeID);
        blockSizeChangedTimeID = setTimeout(function () {
            let v = $('#blockSize').val();
            var imgPool = book.sheet1.getBrick('imgPool');
            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
        }, 200);
    });

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 619240d09932fda9010e7468
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 20:08:35.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

     book.sheet2.getBrick('FJ').selectionMode = 'multi'; //图片设置成多选模式


    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

         g_selectedAll=false; //加载一个凭证的图片后 ，默认是不全选中的
    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-arrows-alt",   // 字符图标
            "浏览大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}

var g_selectedAll= false;
function cb_selectall_onClick() { doSelect(!g_selectedAll); }


function doSelect(b) {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 619240d09932fda9010e746e
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 10.255.0.2
username: sa
createdate: 2021.11.15 20:08:56.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    book.showTabOnWhere = 'none';
    //加载帐套信息及年月
    var corpid = book.sheet0.cells("corpid").getValueString();
    runTask("当前记帐期", { corpid: corpid }, function (ym) {
        if (ym == null || ym == 'null') return;
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen(corpid);

        book.sheet0.cells("ym").setValue(ym);

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);


    });

     book.sheet2.getBrick('FJ').selectionMode = 'multi'; //图片设置成多选模式


    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}

function cb_check_onClick() {
    smartRetrieve(book.sheet0, "pzh_check", true, false, function () { //检索完后回调
        if ($pzh_check_ds.rowCount == 0) {
            toastr.success("凭证号检测通过");

        } else {
            book.sheet3.popup('fa fa-cog', '缺失的凭证', 250, 350, true, true, {});
        }
    });
}


/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}

/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //如果是绑定了数据库的，强烈不建议使用本事件，换用结果集变化事件 itemChanged

    //通过别名来判断
    if (cell.alias == 'ym') {
        var corpid = book.sheet0.cells("corpid").getValueString();
        var ym = book.sheet0.cells("ym").getValue();

        pzh_prefix = getPZHPrefix(corpid, ym);
        book.sheet0.cells("pzh_prefix").setValue(pzh_prefix);
    }




}

function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

         g_selectedAll=false; //加载一个凭证的图片后 ，默认是不全选中的
    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}

function do_sh2(innerRow, callback) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id, false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");


        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);

        }
        if (callback) callback();
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    //让selection单元格失去编辑焦点，不然再点击，它不会触发单元格的点击事件，因为此时点击的编辑框对象，不会触发单元格的点击
    book.sheet1.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet1.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


function cb_verify_onClick() {
    $confirm('', '确信要对选中的凭证做审核确认吗?', function () {



        let verifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            verifyCount++;
            showInfoPane("* 正在审核确认...");
            do_sh1(i, function () {
                verifyCount--;
                console.info(verifyCount);
                if (verifyCount == 0) hideInfoPane();
            })
        }


    });
}



function cb_unverify_onClick() {
    $confirm('', '确信要对选中的凭证做取消审核吗?', function () {



        let unverifyCount = 0;
        for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
            if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
            unverifyCount++;
            showInfoPane("* 正在取消确认...");
            do_sh2(i, function () {
                unverifyCount--;
                console.info(unverifyCount);
                if (unverifyCount == 0) hideInfoPane();
            });
        }


    });
}


function cb_package_onClick() {

    let ids = [];
    for (let i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        if ($dzpz_pz_ds.getInt(i, "selected") == 0) continue;
        ids.push($dzpz_pz_ds.getString(i, "id"));
    }

    if (ids.length == 0) {
        toastr.info("至少选中一张凭证");
        return;
    }

    $confirm('', '确信要将选中的凭证打包下载吗?', function () {
        showInfoPane("*正在压缩打包...");
        runTask("打包下载", { fileName: formatDate(newDate(), "yyyyMMddHHmm") + ".zip", ids: ids },
            function (ret) {
                ret = JSON.parse(ret);
                hideInfoPane();
                if (ret.success) {
                    openWindow(ret.url);
                } else {
                    toastr.error(ret.message);
                }
            });

    });
}



/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "FJ") {
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        brick.addToolButton(1  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '90');

            }
        );


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-arrows-alt",   // 字符图标
            "浏览大图",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                

            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-rotate-left",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数
                rotateImg(sheet,id, '270');

            }
        );



    }
}


function rotateImg(sheet, id, degree) {
    let brick = sheet.getBrick('FJ');
    showInfoPane('*正在旋转图片...');
    setTimeout(function () {
        //toastr.info(id);  // id 是当前操作的图片对应数据的ID
        var ret = do_imageRotate(id, degree);
        if (ret.success) {
            //把数据中的图片替换，
            for (let i = 0; i < brick.data.length; i++) {
                if (brick.data[i].id == id) {
                    //属性从新的属性中替换 
                    for (let prop in brick.data[i]) {
                        brick.data[i][prop] = ret.data[prop];
                    }
                    break;
                }
            }
            //把缩略图的图片地址替换 ， 

            let img = $('#' + id).find('.image');
            img.attr("src", ret.data.url_thumbnail);
            img.attr('largeimage', ret.data.url_img);
            //把大图预览的地址替换掉
            //book.sheet0.cells("imgPreview").setValue(ret.data.url_img);

            hideInfoPane();

        }
    }, 10);

}

var g_selectedAll= false;
function cb_selectall_onClick() { doSelect(!g_selectedAll); }


function doSelect(b) {
    var imgPool = book.sheet2.getBrick('FJ');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8932defb25942c0f22087
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 13:16:40.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    
    $('#blockSize').on('change', function () {
       
            let v = $('#blockSize').val();
            var imgPool = book.sheet1.getBrick('imgPool');
            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
        
    });

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8932defb25942c0f2208d
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 13:25:18.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    
    $('#blockSize').on('input', function () {
       
            let v = $('#blockSize').val();
            var imgPool = book.sheet1.getBrick('imgPool');
            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
        
    });

}


/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8932defb25942c0f22093
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 13:34:48.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    
    $('#blockSize').on('input',  resetImgPoolBlockSize);
     
}


function  resetImgPoolBlockSize()
{
            var imgPool = book.sheet1.getBrick('imgPool');

                // 先保存当前选中状态及设置的凭证号信息
            var selection=  imgPool.getSelectedImageList();
            var pzhMap={};
            var pzhs= imgPool.dom.find('.pzh');
            for( let i=0;i<pzhs.length; i++)
            {
                let id=$(pzhs[i]).parent().attr('id');
                let pzh=  $(pzhs[i]).find('.no').text()  ;
                pzhMap[id] = pzh; 

            }


            let v = $('#blockSize').val();

            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
            //恢复选中状态
            for( let i=0;i<selection.length;i++)
            {
                imgPool.setImageSelected(selection[i].id , true);
            }
            //恢复凭证号
            for( let id in pzhMap)
            {
                var pzh= pzhMap[id];
                 find_pzh(id, true).find('.no').text(pzh);
            }


    
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a280efb25942c0f22356
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:25:00.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}

function  getImagePoolBlockSize()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).blockSize; 
    
}



//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
     
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a8a280efb25942c0f22362
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:26:42.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    
    $('#blockSize').on('input',  resetImgPoolBlockSize);
}


function afterOpen()
{
    //调取缩略图大小
    let blockSize= getImagePoolBlockSize();
    if( blockSize!=128)
    {
        $('#blockSize').val(blockSize);
        resetImgPoolBlockSize();
    }
     
}



function  resetImgPoolBlockSize()
{
            var imgPool = book.sheet1.getBrick('imgPool');

                // 先保存当前选中状态及设置的凭证号信息
            var selection=  imgPool.getSelectedImageList();
            var pzhMap={};
            var pzhs= imgPool.dom.find('.pzh');
            for( let i=0;i<pzhs.length; i++)
            {
                let id=$(pzhs[i]).parent().attr('id');
                let pzh=  $(pzhs[i]).find('.no').text()  ;
                pzhMap[id] = pzh; 

            }


            let v = $('#blockSize').val();

            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
            //恢复选中状态
            for( let i=0;i<selection.length;i++)
            {
                imgPool.setImageSelected(selection[i].id , true);
            }
            //恢复凭证号
            for( let id in pzhMap)
            {
                var pzh= pzhMap[id];
                 find_pzh(id, true).find('.no').text(pzh);
            }


    
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a280efb25942c0f22368
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:28:09.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    
    $('#blockSize').on('input',  resetImgPoolBlockSize);
}


function afterOpen()
{
    //调取缩略图大小
    let blockSize= getImagePoolBlockSize();
    if( blockSize!=128)
    {
        $('#blockSize').val(blockSize);
        resetImgPoolBlockSize( false);
    }
     
}



function  resetImgPoolBlockSize( needSaveSetting)
{
            var imgPool = book.sheet1.getBrick('imgPool');

                // 先保存当前选中状态及设置的凭证号信息
            var selection=  imgPool.getSelectedImageList();
            var pzhMap={};
            var pzhs= imgPool.dom.find('.pzh');
            for( let i=0;i<pzhs.length; i++)
            {
                let id=$(pzhs[i]).parent().attr('id');
                let pzh=  $(pzhs[i]).find('.no').text()  ;
                pzhMap[id] = pzh; 

            }


            let v = $('#blockSize').val();

            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
            //恢复选中状态
            for( let i=0;i<selection.length;i++)
            {
                imgPool.setImageSelected(selection[i].id , true);
            }
            //恢复凭证号
            for( let id in pzhMap)
            {
                var pzh= pzhMap[id];
                 find_pzh(id, true).find('.no').text(pzh);
            }

            if( needSaveSetting )
            {
                setImagePoolBlockSize(v);
            }


    
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a280efb25942c0f2236e
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:28:40.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    
    $('#blockSize').on('input',  resetImgPoolBlockSize);
}


function afterOpen()
{
    //调取缩略图大小
    let blockSize= getImagePoolBlockSize();
    if( blockSize!=128)
    {
        $('#blockSize').val(blockSize);
        resetImgPoolBlockSize( false);
    }
     
}



function  resetImgPoolBlockSize( needSaveSetting)
{
            var imgPool = book.sheet1.getBrick('imgPool');

                // 先保存当前选中状态及设置的凭证号信息
            var selection=  imgPool.getSelectedImageList();
            var pzhMap={};
            var pzhs= imgPool.dom.find('.pzh');
            for( let i=0;i<pzhs.length; i++)
            {
                let id=$(pzhs[i]).parent().attr('id');
                let pzh=  $(pzhs[i]).find('.no').text()  ;
                pzhMap[id] = pzh; 

            }


            let v = $('#blockSize').val();

            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
            //恢复选中状态
            for( let i=0;i<selection.length;i++)
            {
                imgPool.setImageSelected(selection[i].id , true);
            }
            //恢复凭证号
            for( let id in pzhMap)
            {
                var pzh= pzhMap[id];
                 find_pzh(id, true).find('.no').text(pzh);
            }

            if( needSaveSetting )
            {
                setImagePoolBlockSize( imgPool.config.gguid, v);
            }


    
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60c6dd525db2f1975180399e
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 192.168.3.2
username: sa
createdate: 2021.06.15 06:05:23.000
script:
function formOpen()
{
    //加载帐套信息及年月
    var corporationid = book.sheet2.cells("corporationid").getValueString();
    runTask("当前记帐期", { corporationid: corporationid }, function (ym) {
        book.sheet2.cells("ym").setValue(ym);
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen();
        pzh_prefix = getPZHPrefix(ym);


    });


}


id: 60a8a280efb25942c0f2237e
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:29:53.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function  getImagePoolGGUID()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).gguid; 
    
}

function  getImagePoolBlockSize()
{
    var ret= runTask("get_dzpz_imgpool_id_of_current_user",{});
    return JSON.parse(ret).blockSize; 
    
}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize)
{
    runSQL(""," update  dzpz_imgpool set blocksize="+blockSize+" where gguid='"+ id+"'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData()
{
    var config= JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user",{}));
     
    var ds=newDataStore( config.dbpool ,"select * from "+ config.logTable+"  where  gguid='"+config.gguid+"'  order by info1 ") ; // info1 是客户端文件创建的时间，以它排序
    var n=ds.retrieve();
    var ret=[];
    for( var i=0;i<n;i++)
    {
        ret.push(  JSON.parse( ds.getJSONRow(i,true)));
    }

    return ret; 

}


id: 60a8a280efb25942c0f22384
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:30:31.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);

    
    $('#blockSize').on('input',  resetImgPoolBlockSize);
}


function afterOpen()
{
    //调取缩略图大小
    let blockSize= getImagePoolBlockSize();
    if( blockSize!=128)
    {
        $('#blockSize').val(blockSize);
        resetImgPoolBlockSize( false);
    }
     
}



function  resetImgPoolBlockSize( needSaveSetting)
{
        if( needSaveSetting==null) needSaveSetting=true; 
            var imgPool = book.sheet1.getBrick('imgPool');

                // 先保存当前选中状态及设置的凭证号信息
            var selection=  imgPool.getSelectedImageList();
            var pzhMap={};
            var pzhs= imgPool.dom.find('.pzh');
            for( let i=0;i<pzhs.length; i++)
            {
                let id=$(pzhs[i]).parent().attr('id');
                let pzh=  $(pzhs[i]).find('.no').text()  ;
                pzhMap[id] = pzh; 

            }


            let v = $('#blockSize').val();

            imgPool.config.blockSize = parseInt(v);
            imgPool.rebuildGridly();
            //恢复选中状态
            for( let i=0;i<selection.length;i++)
            {
                imgPool.setImageSelected(selection[i].id , true);
            }
            //恢复凭证号
            for( let id in pzhMap)
            {
                var pzh= pzhMap[id];
                 find_pzh(id, true).find('.no').text(pzh);
            }

            if( needSaveSetting )
            {
                setImagePoolBlockSize( imgPool.config.gguid, v);
            }


    
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a280efb25942c0f2238a
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:30:46.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
}


function afterOpen() {
    //调取缩略图大小
    let blockSize = getImagePoolBlockSize();
    if (blockSize != 128) {
        $('#blockSize').val(blockSize);
        resetImgPoolBlockSize(false);
    }

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setImagePoolBlockSize(imgPool.config.gguid, v);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a280efb25942c0f22390
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:33:03.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
}


function afterOpen() {
    //调取缩略图大小
    let blockSize = getImagePoolBlockSize();
    if (blockSize != 128) {
        $('#blockSize').val(blockSize);
        resetImgPoolBlockSize(false);
    }

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a280efb25942c0f22396
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:33:23.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
}


function afterOpen() {
    //调取缩略图大小
    let blockSize = getImagePoolBlockSize();
    if (blockSize != 128) {
        $('#blockSize').val(blockSize);
        resetImgPoolBlockSize(false);
    }

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout( function()
        {
        setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        },1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a653efb25942c0f2239c
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:36:04.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    setTimeout(function () {
        //调取缩略图大小
        let blockSize = getImagePoolBlockSize();
        if (blockSize != 128) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 2000);

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a653efb25942c0f223a2
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:36:40.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    setTimeout(function () {
        //调取缩略图大小
        let blockSize = getImagePoolBlockSize();
        if (blockSize != 128) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a653efb25942c0f223a8
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 14:44:25.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    setTimeout(function () {
        //调取缩略图大小
        return; 
        let blockSize = getImagePoolBlockSize();
        if (blockSize != 128) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a653efb25942c0f223b4
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 15:00:01.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    setTimeout(function () {
        //调取缩略图大小
       
        let blockSize = getImagePoolBlockSize();
        if (blockSize != 128) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a653efb25942c0f223bf
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 15:04:29.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    

}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet , name, data ) {
  //调取缩略图大小
       
        let blockSize = getImagePoolBlockSize();
        if (blockSize != 128) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
}


function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a653efb25942c0f223c5
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 15:05:34.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    

}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet , name, data ) {
  //调取缩略图大小
       var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
}


function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a8a653efb25942c0f223cb
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 15:07:19.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    
    setTimeout( function()
    {
        //调取缩略图大小
       var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    },1000);

}

 

function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


id: 60a903715db21e3d0fbaadd1
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:20:36.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    
    setTimeout( function()
    {
        //调取缩略图大小
       var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    },1000);

}

 

function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick()
{
    if( window.electron==null)
    {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    electron.ipcSendMessage(JSON.stringify({actipn:"selectClientPathToMonite"}));
}


id: 60a903715db21e3d0fbaadd7
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:35:21.000
script:
function formOpen() {
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    
    setTimeout( function()
    {
        //调取缩略图大小
       var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    },1000);

}

 

function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick()
{
    if( window.electron==null)
    {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path=electron.showOpenDialogSync(''); 
    alert( path);
}


id: 60a903715db21e3d0fbaadde
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:43:42.000
script:
function formOpen() {
    book.showTabOnWhere="none";
    
    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    
    setTimeout( function()
    {
        //调取缩略图大小
       var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    },1000);

}

 

function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick()
{
    if( window.electron==null)
    {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path=electron.showOpenDialogSync(''); 
    alert( path);
}


id: 60a903715db21e3d0fbaade4
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:48:45.000
script:
function formOpen() {
    book.showTabOnWhere="none";

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);
    
    setTimeout( function()
    {
        //调取缩略图大小
       var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    },1000);

}

 

function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick()
{
    if( window.electron==null)
    {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path=electron.showOpenDialogSync(''); 
    if( path=='') return; 
    var hostName=  electron.getHostName();
    setMonitePath( hostName, path);
    

}


id: 60a90cf15db21e3d0fbaae04
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:53:54.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    var ds = newDataStore(config.dbpool, "select * from " + config.logTable + "  where  gguid='" + config.gguid + "'  order by info1 "); // info1 是客户端文件创建的时间，以它排序
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    return ret;

}


function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);


}


id: 60a90cf15db21e3d0fbaae0c
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:54:53.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    var ds = newDataStore(config.dbpool, "select * from " + config.logTable + "  where  gguid='" + config.gguid + "'  order by info1 "); // info1 是客户端文件创建的时间，以它排序
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    return ret;

}


function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);


}

function  getMonitePath(hostName)
{
    return   getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


id: 60a90cf15db21e3d0fbaae12
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:57:43.000
script:
var pathToMonit = "";

function formOpen() {
    book.showTabOnWhere = "none";

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);

    setTimeout(function () {
        //调取缩略图大小
        var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

//调取图片目录
    if (window.electron != null) {
        var hostName = electron.getHostName();
        pathToMonit = getMonitePath(hostName);
        book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);
    }

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (window.electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);


}


id: 60a90cf15db21e3d0fbaae18
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 0:0:0:0:0:0:0:1
username: sa
createdate: 2021.05.22 21:57:52.000
script:
var pathToMonit = "";

function formOpen() {
    book.showTabOnWhere = "none";

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:16px;text-align:center;}

                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
 `);


    //  let data= loadImagePoolData();
    //  console.dir(data);


    $('#blockSize').on('input', resetImgPoolBlockSize);

    setTimeout(function () {
        //调取缩略图大小
        var imgPool = book.sheet1.getBrick('imgPool');

        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录
    if (window.electron != null) {
        var hostName = electron.getHostName();
        pathToMonit = getMonitePath(hostName);
        book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);
    }

}



function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }


    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();
    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
function imageOnMouseOut(sheet, name, data) {

    book.sheet0.cells("imgPreview").setValue("");
}


/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data) {

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = '';

    inputBox("标记为凭证", "", pzh, "输入凭证号码", function (val) {
        if (val == '') {
            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
        } else {
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
        }

    }, true /*允许为空*/);
}


//@comment (group=,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists) {
    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" ><div class="no"></div><div class="delete_pzh"><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div></div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (imgPool.getSelectedImageList().length == 0) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (window.electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);


}


id: 60c80f1c5db2d209d074b60a
scriptid: 60c4bd735db2478f9c5a111c
tablename: app_template
clientip: 192.168.1.140
username: sa
createdate: 2021.06.15 10:36:27.000
script:
var pzh_prefix;
var pzh_length;

var fullScreenDiv = null;



function formOpen() {
    //加载帐套信息及年月
    var corporationid = book.sheet0.cells("corporationid").getValueString();
    runTask("当前记帐期", { corporationid: corporationid }, function (ym) {
        book.sheet0.cells("ym").setValue(ym);
        //得到年月后，获取凭证号相关设置
        pzh_len = getPZHLen();
        
        pzh_prefix = getPZHPrefix(ym);
        book.sheet0.cells("pzh_prefix").setValue( pzh_prefix);


    });

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:24px; line-height:24px;width:100%; 
                                background-color:#40af40a0; 
                                color:white;font-weight:bold;font-size:12px;text-align:center;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:14px; top:0; text-align:right; 
                                    vertical-align:top; font-size:12px; color:gray;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


}



function fullScreenViewImageOpen() {
    var imgPool = book.sheet2.getBrick('FJ');
    if (imgPool.currentImageData != null) {

        if (fullScreenDiv == null) {
            fullScreenDiv = $(`<div style="position:absolute;left:0;top:0;width:100%;height:100%;z-index:9999;background-color:#000000b0; 
            pointer-events: none; 
            display:table-cell;
            text-align:center;
        
            vertical-align:middle;"><img class="fullScreenImage" src="" style="display: inline-block; pointer-events: none; height:100%;" ></img></div>`);
            $(document.body).append(fullScreenDiv);
        }


        let imgContainer = fullScreenDiv.find('.fullScreenImage');

        //临时计算一下比例
        let h = fullScreenDiv.height();
        let w = fullScreenDiv.width();
        let delta = h * 1.0 / w;

        let img = $('#' + imgPool.currentImageData.id).find('.image');
        let h2 = img.height();
        let w2 = img.width();
        let delta2 = h2 * 1.0 / w2;

        if (delta2 > delta)  // 图片的高宽比 比显示区域的高宽比要大，说明需要适应高度
        {
            imgContainer.css({ "height": "100%", "width": "auto" });
        } else {
            imgContainer.css({ "height": "auto", "width": "100%" });
        }

        imgContainer.attr("src", imgPool.currentImageData.url_img);
        fullScreenDiv.css("display", "");
    }
}

function fullScreenViewImageClose() {
    if (fullScreenDiv != null) {
        fullScreenDiv.css("display", "none");
    }
}



/**
 * 多行结果集当前焦点行发生变化
 * @param dsname  结果集名称
 * @param row  行号
 */
function currentBindRowChanged(dsname, row) {
    if (dsname == 'dzpz_pz') {
        //重新加载凭证图片列表

        let id = $dzpz_pz_ds.getString(row, "id");
        let pzh = $dzpz_pz_ds.getString(row, "pzh");
        loadPZ(pzh, id);

    }
}


function loadPZ(pzh, id) {
    let data = getPZFJ(id); //得到凭证的所有图片
    let FJ = book.sheet2.getBrick('FJ');
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet2.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}



/**
 * 图片控件中鼠标按下
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 * @param data  该图片的详细信息
 * @param event  事件对象
 *
 */
//@comment (group=图片控件,caption=鼠标在某个图片上按下)
function imageOnMouseDown(sheet, name, data, event) {

    if (event.which == 1) {
        console.info("左键按下");
    }
    if (event.which == 3) {
        console.info("右键按下");
        fullScreenViewImageOpen();
    }

}
/**
 * 图片控件中鼠标释放
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 * @param data  该图片的详细信息
 * @param event  事件对象
 *
 */
//@comment (group=图片控件,caption=鼠标在某个图片上释放)
function imageOnMouseUp(sheet, name, data, event) {

    if (event.which == 1) {
        console.info("左键松开");
    }
    if (event.which == 3) {
        console.info("右键松开");
        fullScreenViewImageClose();
    }

}


/**
 * 单元格单击事件
 * @param sheet
 * @param cell
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行被点击
 * @param event 事件对象
 */
//@comment (group=单元格事件,caption=单元格点击)
function cellOnClick(sheet, cell, innerRow, event) {

    //通过别名来判断
    if (cell.alias == 'XXX') {

    }

    //通过数据库绑定情况来判断
    let bind = cell.bind;
    if (bind != null && bind.dataSource == 'dzpz_pz') {
        if (bind.DBCol == 'c_sh1') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") != 0) return; //已审核，不要再审核
            do_sh1(innerRow);
        }
        if (bind.DBCol == 'c_sh2') {
            if ($dzpz_pz_ds.getInt(innerRow, "verifierid") == 0) return; //没有审核，不需要取消审核
            do_sh2(innerRow);
        }
    }

}

function do_sh1(innerRow) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    let pzh = $dzpz_pz_ds.getString(innerRow, "pzh");

    do_sh(id, true, function (ret)  //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", ret.verifierid);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", ret.verifiername);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", ret.verifieddate);
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", "审核成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "取消");

            return true;
        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);
            return false;
        }
    });
}

function do_sh2(innerRow) {
    let id = $dzpz_pz_ds.getString(innerRow, "id");
    do_sh(id , false, function (ret) //后台执行
    {
        if (ret.success) {
            $dzpz_pz_ds.setValue(innerRow, "verifierid", null);
            $dzpz_pz_ds.setValue(innerRow, "verifiername", null);
            $dzpz_pz_ds.setValue(innerRow, "verifieddate", null);
             $dzpz_pz_ds.setValue(innerRow, "tipinfo", "取消成功");
            $dzpz_pz_ds.setValue(innerRow, "c_sh1", "审核");
            $dzpz_pz_ds.setValue(innerRow, "c_sh2", "");
            toastr.success(pzh + "成功取消审核");
            return true;
        } else {
            $dzpz_pz_ds.setValue(innerRow, "tipinfo", ret.message);
            return false;
        }
    });
}



//@comment (group=工具函数,caption=全选或取消全选)
function seletOrUnSelectAll() {
    book.sheet0.View.forceCurrentEditControlGiveUpFocus();

    var v = book.sheet0.cells('selection').getValueInt();

    book.sheet1.paintPermit = false;
    $dzpz_pz_ds.setValueWithTrigger = false;
    for (var i = 0; i < $dzpz_pz_ds.rowCount; i++) {
        $dzpz_pz_ds.setValue(i, "selected", v);
    }
    $dzpz_pz_ds.setValueWithTrigger = true;
    book.sheet1.paintPermit = true;
}


