• bootstrap editable初始化后表单可修改数据


    function loadData() {
        var url = "${ctx }/sys/marketing/product/page";
        $('#tablepager').bootstrapTable({
            url: url,
            dataType: "json",
            pagination: true, //分页
    singleSelect: true,//只能选择一行
    clickToSelect: true,
            search: false, //显示搜索框
    sidePagination: "server", //服务端处理分
    pageNumber: 1,
            pageSize: 10,
            pageList: [10, 20, 50, 100],
            queryParams:function(params){
                var par={"markingCode":$("#searchmarkingCode").val(),"markingName":$("#searchMarkingName").val(),"productCode":$("#searchproductCode").val(),"productName":$("#searchProductName").val(),"productType":$("#searchproductType").val(),};
                var p= $.extend({},params,par);
                return p;
            },
            showColumns: true,
            showRefresh: true,
            showToggle: true,
            toolbar: "#tableToolbar",
            onEditableSave: function (field, row, oldValue, $el) {
                $.ajax({
                    type: "post",
                    url: "${ctx }/sys/marketing/product/" + row.id,
                    data:{ "_method": "put","id":row.id,"markingName":row.markingName,"productType":row.productType,
                        "markingPrice":row.markingPrice,"productName":row.productName,"markingCode":row.markingCode,
                        "productCode":row.productCode},
                    dataType: 'JSON',
                    success: function (data, textStatus, jqXHR) {
                        layer.msg("编辑成功", {icon: 7});
                    },
                    error: function () {
                        layer.msg("error", {icon: 7});
                    },
                    complete: function () {
    
                    }
                });
            },
            columns: [{
                checkbox: true
    },
                {
                    field : "markingCode",
                    title : "活动编码"
    }
                ,
                {
                    field : "markingName",
                    title : "活动名称"
    }
                ,
                {
                    field : "productCode",
                    title : "产品编码"
    }
                ,
                {
                    field : "productName",
                    title : "产品名称"
    }
                ,
                {
                    field : "markingPrice",
                    title : "活动价格(¥)",
                    editable: {
                        type: 'text',
                        title: '活动价格(¥)',
                        validate: function (v) {
                            if ($.trim(v) == '') {
                                return '活动价格不能为空!';
                            }
                            if (isNaN(v)) {
                                return '活动价格必须是数字';
                            }
                            var reg = /(^[1-9]d*(.d{1,2})?$)|(^0(.d{1,2})?$)/;
                            if(!reg.test(v)) {
                                return '请输入正确的价格';
                            }
                        },
                    }
                }
                ,
                {
                    field : "productType",
                    title : "产品类型",
                    formatter: function (value) {
                        switch (value) {
                            case 1:
                                return "门票";
                            case 2:
                                return "酒店";
                            case 3:
                                return "餐饮";
                            case 4:
                                return "普通商品";
                            default:
                                return "-";
                        }
                    }
                }
            ],
        });
    }
  • 相关阅读:
    VMDNAMD命令规则(转载)
    VMD的相关命令(转载)
    Clayff力场(转载)
    如何处理遇到的错误-lammps
    数据分析及结果
    了解vue里的Runtime Only和Runtime+Compiler
    实例的属性和方法
    组件通信精髓
    vue内置的标签(组件)
    class和style属性
  • 原文地址:https://www.cnblogs.com/zhuyeshen/p/11430629.html
Copyright © 2020-2023  润新知