JS完成按钮判断(根据字段来判断是什么按钮)

  • Post author:
  • Post category:其他


前端页面 js代码:

<script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('csCtdc:ctdcYhsh:editYhsh')}]];
        var editFlagCK = [[${@permission.hasPermi('csCtdc:ctdcYhsh:editYhshCK')}]];
        var removeFlag = [[${@permission.hasPermi('csCtdc:ctdcYhsh:removeYhsh')}]];
        var prefix = ctx + "csCtdc/ctdcYhsh";

        $(function() {
            var options = {
                url: prefix + "/listYhsh",
                createUrl: prefix + "/addYhsh",
                updateUrl: prefix + "/editYhsh/{id}",
                updateUrl: prefix + "/editYhshCK/{id}",
                removeUrl: prefix + "/removeYhsh",
                exportUrl: prefix + "/exportYhsh",
                modalName: "我的上报",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'csCtdcId',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'csCtdcUnit',
                    title: '单位'
                },
                
                {
                    field: 'csCtdcSite',
                    title: '地点'
                },
                {
                    field: 'csCtdcHidden',
                    title: '隐患描述'
                },
                {
                    field: 'csCtdcTime',
                    title: '发现时间'
                },
                
                {
                    field: 'csCtdcUppeople',
                    title: '上报人'
                },
                {
                    field: 'csCtdcAuditpeople',
                    title: '审核人'
                },
                {
                    field: 'csCtdcAudittime',
                    title: '审核时间'
                },
                {
                    field: 'csCtdcMoney',
                    title: '奖励金额'
                },
                {
                    field: 'csCtdcState',
                    title: '审核进度'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.csCtdcState == "待审核"){
                        	actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="shenhe(\'' + row.csCtdcId + '\')"><i class="fa fa-edit"></i>审核</a> ');
                        }else{
                        	 actions.push('<a class="btn btn-success btn-xs ' + editFlagCK + '" href="javascript:void(0)" onclick="chakan(\'' + row.csCtdcId + '\')"><i class="fa fa-eye"></i>查看</a> ');	
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        //隐患审核 
        function shenhe(id) {
            $.modal.open("审核", prefix + "/editYhsh?csCtdcId="+id);
        };
        //隐患查看
        function chakan(id) {
            $.modal.open("查看", prefix + "/editYhshCK/" + id);
        };

       /*  //隐患流程
        function chakanLiuCheng(id){
            $.modal.openNoBtn("流程", prefix + "/chakanLiuCheng/"+id);
        } */
    </script>

审核页面的js代码

<script th:inline="javascript">
        var prefix = ctx + "csCtdc/ctdcYhsh";
        $("#form-ctdcYhsh-editYhsh").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/editYhsh", $('#form-ctdcYhsh-editYhsh').serialize());
            }
        }

        $("input[name='csCtdcTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='csCtdcAudittime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>

查看页面的js代码

<script th:inline="javascript">
        var prefix = ctx + "csCtdc/ctdcYhsh";
        $("#form-ctdcYhsh-editYhshCK").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/editYhshCK", $('#form-ctdcYhsh-editYhshCK').serialize());
            }
        }

        $("input[name='csCtdcTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='csCtdcAudittime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>

Controller对应代码

 /**
     * 隐患审核 审核
     */
    @GetMapping("/editYhsh")
    public String edit(Long csCtdcId, ModelMap mmap)
    {
        CsCTDC csCTDC = csCTDCService.selectCsCTDCById(csCtdcId);
        mmap.put("csCTDC", csCTDC);
        return prefix + "/editYhsh";
    }

    /**
     * 隐患审核 审核
     */
    @RequiresPermissions("csCtdc:ctdc:editYhsh")
    @Log(title = "我的上报", businessType = BusinessType.UPDATE)
    @PostMapping("/editYhsh")
    @ResponseBody
    public AjaxResult editSave(CsCTDC csCTDC,HttpSession session)
    {
    	csCTDC.setCsCtdcAuditpeople((String) session.getAttribute("ShenHe"));
    	Date date = new Date();
    	csCTDC.setCsCtdcAudittime(date);
        return toAjax(csCTDCService.updateCsCTDC(csCTDC));
    }

    /**
     * 隐患审核 查看
     */
    @GetMapping("/editYhshCK/{csCtdcId}")
    public String editCK(@PathVariable("csCtdcId") Long csCtdcId, ModelMap mmap)
    {
        CsCTDC csCTDC = csCTDCService.selectCsCTDCById(csCtdcId);
        mmap.put("csCTDC", csCTDC);
        return prefix + "/editYhshCK";
    }

    /**
     * 隐患审核 查看
     */
    @RequiresPermissions("csCtdc:ctdc:editYhshCK")
    @Log(title = "我的上报", businessType = BusinessType.UPDATE)
    @PostMapping("/editYhshCK")
    @ResponseBody
    public AjaxResult editSaveCK(CsCTDC csCTDC,HttpSession session)
    {
//    	csCTDC.setCsCtdcAuditpeople((String) session.getAttribute("ShenHe"));
//    	Date date = new Date();
//    	csCTDC.setCsCtdcAudittime(date);
        return toAjax(csCTDCService.updateCsCTDC(csCTDC));
    }



版权声明:本文为Hao1999_原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。