普元-提高效率:查询、删除、保存()

1.写一个公共查询、删除逻辑流

查询:

点击逻辑构件空白处:

此处的name则你前端JSP传递过来的实体、查询实体名称

删除:params是前端页面你勾选的数据

空白处:

保存:

空白处:

2.jsp页面:form表单放入你的查询条件(即界面显示或部分隐藏字段)

此处的bgtOrgId和setOfBooksId为隐藏字段。

<form id="searchform">
            <div class="nui-toolbar" style="border-bottom: 0; padding: 0px;">
                <table style="width:100%;" class="nui-form-table">
                    <tr>
                        <th class="form_label">类型代码:</th>
                        <td><input id="bgtJournalTypeCode" name="criteria/_expr[2]/bgtJournalTypeCode" class="nui-textbox nui-form-input" /></td>
                        <th class="form_label">类型描述:</th>
                        <td><input id="description" name="criteria/_expr[3]/description" class="nui-textbox nui-form-input"/></td>
                        <th class="form_label"></th>
                        <td>
                            <a class="mini-button" iconCls="fssc-save" οnclick="search()">查询</a>
                            <a class="mini-button" iconCls="fssc-ok" οnclick="onReset()">重置</a>
                        </td>
                    </tr>
                </table>
            </div>
            <input class="nui-hidden" name="criteria/_expr[1]/bgtOrgId" id="bgtOrgId" value=""/>
            <input class="nui-hidden" name="criteria/_expr[1]/_op" value="=">
            <input class="nui-hidden" name="criteria/_expr[2]/_op" value="like">
            <input class="nui-hidden" name="criteria/_expr[3]/_op" value="like">
            <input class="nui-hidden" id="setOfBooksId" name="setOfBooksId" >
        </form>

删除按钮:

<div style="width:100%;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">

<a class="nui-button" iconCls="fssc-save" οnclick="saveData()">保存</a>
                        <a class="nui-button" iconCls="fssc-collapse" οnclick="removeRow()">删除</a>
                    </td>
                </tr>
            </table>           
        </div>
    </div>

grid列表:此处的URL是你前面建的公共查询逻辑构件

 <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowAlternating="true"
                allowResize="false" pageSize="10" showPager="true" allowcellvalid="true" frozenStartColumn="0" frozenEndColumn="4"
                allowCellEdit="true" allowCellSelect="true" multiSelect="true" oncellbeginedit="onCellBeginEdit" oncellendedit="" oncellvalidation=""
                url="com.sgai.fssc.service.hec4cwgx.common.common.queryCommonConf.biz.ext" dataField="dataList" totalCount="total">
                <div property="columns" >
                    <div type="checkcolumn"></div>
                    <div field="bgtJournalTypeCode" align="center" headerAlign="center" width="100" vtype="required">类型代码
                        <input property="editor" class="mini-textbox" allowInput="true" style="width:100%;" />
                    </div>

............................此处字段太多久不放上了了

</div>

</div>

JS:如:

<script type="text/javascript">

var form = new nui.Form("#searchform");
    var grid1 = nui.get("datagrid1");
    var name = "com.sgai.fssc.service.hec4cwgx.bgtEntity.BgtJournalTypes";
    search();

function search(){
        //查询所属公司账簿的预算组织
        nui.ajax({
            url:"com.sgai.fssc.service.hec4cwgx.bgt.bgtperiods.queryBgtOrgCode.biz.ext",
            type:'post',
            contentType:'text/json',
            success:function(datas){
                if(datas.datas[0].bgtOrgCode==""){
                    showAlert("系统提示","请配置预算组织定义");
                }else{
                    nui.get("bgtOrgId").setValue(datas.datas[0].sid);
                    nui.get("setOfBooksId").setValue(datas.datas[0].setOfBooksId);
                    var json = form.getData(false,false);
                    var queryName = "com.sgai.fssc.service.hec4cwgx.bgtEntity.QueryBgtJournalTypeDef";//实体、查询实体名称
                    json.name = queryName;
                    grid1.load(json);
                }
            }
        });
    }

//删除
        function removeRow(){
            var rows=grid1.getSelecteds();
            if(rows.length > 0){
                var json=nui.encode({"params":rows,name:name});
                nui.confirm("确定删除选中记录?", "系统提示", function(action){
                    if(action!="ok")return;
                    nui.ajax({
                        url:"com.sgai.fssc.service.hec4cwgx.common.common.delCommonConf.biz.ext",
                        type:'post',
                        data:json,
                        contentType:'text/json',
                        success:function(text){
                            search();
                        }
                    });
                });
            } else {
                showAlert("失败","请选中一条记录");
            }
        }

function saveData(){
            grid1.validate();
             if(!grid1.isValid())return;
            var data = grid1.getChanges();
            var json=nui.encode({params:data,name:name});
            nui.ajax({
                url:"com.sgai.fssc.service.hec4cwgx.common.common.saveCommonConf.biz.ext",
                type:'post',
                contentType:'text/json',
                data:json,
                success:function(text){
                    var rtn = text.rtn;
                    if(rtn == "1"){
                        showAlert("成功","保存成功!");
                        search();
                    } else {
                        showAlert("失败","保存失败!");
                    }
                }
            });
        }

</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值