美文网首页
SpringBoot Icream项目整理总结

SpringBoot Icream项目整理总结

作者: CNSTT | 来源:发表于2019-02-14 11:00 被阅读0次

Html 层

一、下拉框

1、字典Status表

data-dictCode 取前四位查询字典表
data-value 下拉框默认值

<div class="col-xs-8">
    <select id="isEnabled" name="isEnabled" class="bs-select form-control"  
    data-type="dict" data-dictCode="1278" data-value="12781001"></select>
</div>
下拉框1-示例

2、关联其他表某字段

data-url 发起请求数据的url
data-model 发起请求的系统模块名

<option value="data-labelValue">data-lableDesc</option>

data-labelValue 一般为Code,下拉框value值
data-lableDesc 一般为Name,下拉框显示值
data-fieldName 请求传来的值
data-live-search 是否开启搜索

<div class="col-xs-12 col-lg-6">
    <div class="form-group">
        <label class="control-label col-xs-4 ">图书分类</label>
        <div class="col-xs-8">
            <select id="cateCode" name="cateCode" 
            class="bs-select form-control" data-url="/basedata/books/getTypeName" 
            data-model="system" data-labelValue="cateCode" 
            data-lableDesc="cateName" data-live-search="true">
            </select>
         </div>
    </div>
</div>

根据图书分类代码显示分类名称


下拉框2-示例

二、表格Table

<div class="panel-body">
    <table class="table table-striped table-bordered table-hover table-responsive" 
    id="bookList"></table>
</div>
<script type="text/javascript">
    $(document).one("onload.dms",function(event,container){
        new Datatable().initPagination({
            src : "bookList",  //对应html中table的id
            container:container,
            //url请求,分页查询所有数据
            url : dmsCommon.getDmsPath()["system"] + "/basedata/books",  
            rowID : "id",  //默认根据主键,但是一定要写!
            sortName : "id", 
            sortOrder : "asc",
            columns : [
                //type: edit编辑 | del 删除 | forbid 停用
                {field: "", title: "操作", operateFormat: [
                    {type: "edit", url: "repair/basedata/books/editItem.html", openWidth:"modal-sm", 
                    doubleClick: true, isShow: function(value, row, index){
                        return true;
                    }},
                    {type: "forbid", url:"/basedata/books/forbid/{[id]}", model: "system", callBack: function(response){
                        $("#additionalItemList",getElementContext()).dmsTable().refreshTableWithForm();
                    }, isShow: function(value, row, index){
                        if(row.isValid == "12781001"){
                            return true;
                        }else{
                            return false;
                        }
                    }}
                ]},
                {field: "bookCode", title: "图书编号"},
                {field: "bookName", title: "图书名称"},
                {field: "author", title: "作者"},
                {field: "price", title: "指导价"},
                {field: "cateCode", title: "图书分类", codeFormat: {type: "dict", codeType: "xxxx"}}, 
                {field: "publishDate", title: "出版日期", dateFormat: {format: "YYYY-MM-DD HH:mm:ss"}}              
            ]
        });     
    }); 
</script>
图片仅供参考

三、页面初始化

// 回调函数为true才执行提交订单
$("a[data-callBack='true']", container).on("callBack.dms",
    function(event, response){
    // 提交订单后的页面初始化
    let url = "system/basedata/book/bookManager/bookOrder.html"
    dmsCommon.refreshPageByUrl(url, container, function(){
        console.log("提交订单成功,执行页面初始化")
    })
})

Controller层

一、Excel导出

<a href="javascript:;" data-url="/basedata/books/export/excel" data-model="system"
data-method="downLoad" data-toggle="confirmation" class="btn btn-outline">
    <i class="fa fa-download"></i> 导出
</a>
    /**
     * <p>Description: 导出Excel</p>
     * <p>Create by: Tan
     * <p>Create at: 2019年2月14日 下午3:13:47
     * @param queryParam
     * @param request
     * @param response
     * @throws Exception
     */
    @SuppressWarnings("rawtypes")
    @GetMapping("/export/excel")
    public void export(@RequestParam Map<String, String> queryParam, 
        HttpServletRequest request, HttpServletResponse response) throws Exception {
        List<Map> resultList =bookService.export(queryParam);
        log.debug("正在导出图书管理Excel文件");
        Map<String, List<Map>> excelData = new HashMap<String, List<Map>>();
        excelData.put("图书管理", resultList);  //sheet页名字
        List<ExcelExportColumn> exportColumnList = new ArrayList<ExcelExportColumn>();        
        exportColumnList.add(new ExcelExportColumn("BOOK_ID","图书编号"));
        exportColumnList.add(new ExcelExportColumn("BOOK_NAME","图书名称"));
        exportColumnList.add(new ExcelExportColumn("AUTHOR","作者"));
        exportColumnList.add(new ExcelExportColumn("GUIDE_PRICE","指导价"));
        exportColumnList.add(new ExcelExportColumn("PUBLISH_DATE","发布日期"));
        excelService.generateExcel(excelData, exportColumnList, "图书管理列表.xls", request, response);
    }

导出如图所示


导出Excel

相关文章

网友评论

      本文标题:SpringBoot Icream项目整理总结

      本文链接:https://www.haomeiwen.com/subject/wvbseqtx.html