Bladeren bron

添加发票管理功能

liuhj 4 jaren geleden
bovenliggende
commit
a0615c36f0

+ 109 - 0
WebContent/WEB-INF/view/bus/invoice-edit.jsp

@@ -0,0 +1,109 @@
+[#ftl]
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <title>编辑发票信息</title>
+    <!--框架必需start-->
+    <script type="text/javascript" src="${ctx}/qui/libs/js/jquery.js"></script>
+    <script type="text/javascript" src="${ctx}/qui/libs/js/framework.js"></script>
+    <link href="${ctx}/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
+    <link rel="stylesheet" type="text/css" id="skin" prePath="${ctx}/qui/"/>
+    <link rel="stylesheet" type="text/css" id="customSkin"/>
+    <!--框架必需end-->
+
+    <!-- 表单验证start -->
+    <link rel="stylesheet" href="${ctx}/qui/libs/js/form/validform/css/style.css" type="text/css" media="all" />
+    <script src="${ctx}/qui/libs/js/form/validform/validform.js" type="text/javascript"></script>
+    <!-- 表单验证end -->
+
+    <!--表单异步提交start-->
+    <script src="${ctx}/qui/libs/js/form/form.js" type="text/javascript"></script>
+    <!--表单异步提交end-->
+
+    <!--箭头分页start-->
+    <script type="text/javascript" src="${ctx}/qui/libs/js/nav/pageArrow.js"></script>
+    <!--箭头分页end-->
+</head>
+<body>
+<form id="myFormId" action="${ctx}/invoice/editData.do" method="post" target="frmright">
+    <div class="box1" id="formContent" whiteBg="true">
+        <input type="hidden" name="invoiceId" value='${bwp.invoiceId!""}'/>
+        <table class="tableStyle" formMode="transparent">
+            <tr>
+                <td><span class="star">*</span>发票号:</td>
+                <td><input type="text" name="invoiceNumb" value='${bwp.invoiceNumb!""}' datatype="*"/></td>
+            </tr>
+            <tr>
+                <td><span class="star">*</span>发票代码:</td>
+                <td><input type="text" name="invoiceCode" value='${bwp.invoiceCode!""}' datatype="*"/></td>
+            </tr>
+            <tr>
+                <td>金额:</td>
+                <td><input type="text" name="amountMoney" value='${bwp.amountMoney!""}' /></td>
+            </tr>
+            <tr>
+                <td>开票信息:</td>
+                <td><textarea name="invoiceInfo">${bwp.invoiceInfo!""}</textarea></td>
+            </tr>
+            <tr>
+                <td>发票状态:</td>
+                <td><select prompt="请选择" id="state"
+                            data='{"list":[{"value":"1","key":"冲红机制"},{"value":"0","key":"发票作废"}]}'
+                            name="state"></select></td>
+            </tr>
+            <tr>
+                <td>备注:</td>
+                <td><textarea name="remark">${bwp.remark!""}</textarea></td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <input type="submit" value="提交"/>
+                    <input type="button" value="取消" onclick="top.Dialog.close()"/>
+                </td>
+            </tr>
+        </table>
+    </div>
+</form>
+<!-- 异步提交start -->
+<script type="text/javascript">
+    function initComplete(){
+
+        //表单提交
+        $("#myFormId").Validform({
+            tiptype:3,//表示在右边显示
+            ajaxPost:true,
+            datatype:{
+                //小数
+                "decimal" : /^\d+\.\d+$/
+
+            },
+            showAllError:true,
+            callback:function(responseText){
+                $.Hidemsg();
+                if(responseText.status=="y"){
+                    top.Dialog.alert(responseText.info,function(){
+                        closeWin();
+                    });
+                }else{
+                    top.Dialog.alert(responseText.info,function(){
+                        return false;
+                    });
+                }
+
+            }
+        });
+    }
+
+
+    //重置
+    function closeWin() {
+        //刷新数据
+        top.frmright.resetSearch();
+        //关闭窗口
+        top.Dialog.close();
+    }
+</script>
+<!-- 异步提交end -->
+</body>
+</html>

+ 200 - 0
WebContent/WEB-INF/view/bus/invoice-list.jsp

@@ -0,0 +1,200 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <title>发票信息列表</title>
+    <!--框架必需start-->
+    <script type="text/javascript" src="${ctx}/qui/libs/js/jquery.js"></script>
+    <script type="text/javascript" src="${ctx}/qui/libs/js/framework.js"></script>
+    <link href="${ctx}/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
+    <link rel="stylesheet" type="text/css" id="skin" prePath="${ctx}/qui/"/>
+    <link rel="stylesheet" type="text/css" id="customSkin"/>
+    <!--框架必需end-->
+
+    <!--数据表格start-->
+    <script src="${ctx}/qui/libs/js/table/quiGrid.js" type="text/javascript"></script>
+    <!--数据表格end-->
+
+    <!--箭头分页start-->
+    <script type="text/javascript" src="${ctx}/qui/libs/js/nav/pageArrow.js"></script>
+    <!--箭头分页end-->
+
+    <!--表单异步提交start-->
+    <script src="${ctx}/qui/libs/js/form/form.js" type="text/javascript"></script>
+    <!--表单异步提交end-->
+
+    <script type="text/javascript">
+        var g_pageNo = 1;
+        var g_pageSize = 10;
+        //数据表格使用
+        var g;
+        var gridData;
+        function initComplete(){
+            g = $("#maingrid").quiGrid({
+                columns: [
+                    // { display: 'id', name: 'invoiceId',  key: true, hidden: true , align: 'center', width: "8%"},
+                    { display: '发票号', name: 'invoiceNumb',     align: 'center', width: "8%"},
+                    { display: '发票代码', name: 'invoiceCode',     align: 'center', width: "8%"},
+                    { display: '金额', name: 'amountMoney',     align: 'center', width: "10%"},
+                    { display: '开票时间', name: 'billingTime',     align: 'center', width: "10%"},
+                    { display: '开票人', name: 'billingUser',     align: 'center', width: "8%"},
+                    { display: '开票信息', name: 'invoiceInfo',     align: 'center', width: "15%"},
+                    {  display: '发票状态', name: 'state',     align: 'center', width: "8%",
+                        render : function(rowdata, rowindex, value, column){
+                            if("0"==value)
+                                return "<font color=red>发票作废</font>";
+                            if("1"==value)
+                                return "<font color=blue>冲红机制</font>";
+                        }	},
+                    { display: '备注', name: 'remark',     align: 'center', width: "20%"},
+                    { display: '操作', isAllowHide: false, align: 'left', width:"15%",
+                        render: function (rowdata, rowindex, value, column){
+                            return '<div class="padding_top4 padding_left20">'
+                                +'<a href="#"  onclick="onEdit(' + rowdata.invoiceId +')"><span class="icon_edit">修改</span></a>'
+                                +'<a href="#"  onclick="onDelete(' + rowdata.invoiceId +')"><span class="icon_remove">删除</span></a>'
+                                + '</div>';
+                        }
+                    }
+                ],
+                toolbar:{
+                    items:[
+                    <@pop_perm url="/invoice/edit.do"> {text:'新增',click:addUnit,iconClass:'icon_add'},</@pop_perm>
+                    {line:true}
+        ]
+        },
+            data:[],rownumbers:true,dataAction:'local',checkbox:false,usePager: false,
+                height: '100%', width:"100%",heightDiff:-40
+        });
+        }
+
+        $(function(){
+            getData(g_pageNo,g_pageSize);
+        });
+
+        /**初始时通过向后台传递排序id、排序顺序、初始页码、每页条数**/
+        function getData(pageNo,pageSize){
+            jQuery.post("${ctx}/invoice/listPage.do",
+                getFormParams(pageNo,pageSize),
+                function(result){
+                    gridData = result;
+                    //刷新表格
+                    g.loadData(gridData);
+                    //设置左边内容页
+                    var content ="共有" + gridData["pager.totalRows"] + "条记录";
+                    $("#letfContent").html("");
+                    $("#letfContent").html(content);
+                    //取得分页组件
+                    var pager=$("#pager");
+                    //设置总页页数
+                    pager.attr("total",gridData["pager.totalRows"]);
+                    pager.render();
+                    //绑定翻页事件
+                    pager.unbind("pageChange");
+                    pager.bind("pageChange",function(e,index){
+                        g_pageNo = index + 1;
+                        getData(g_pageNo,g_pageSize);
+                    });
+                    //绑定选择每页显示记录数事件
+                    pager.bind("sizeChange",function(e,num){
+                        g_pageSize = num;
+                        getData(g_pageNo,g_pageSize);
+                    });
+                },"json");
+        }
+
+
+        //查询
+        function searchHandler(){
+            //重新加载数据,设置当前页面为1
+            getData(1,g_pageSize);
+        }
+
+        /**获得查询表单的提交查询的值**/
+        function getFormParams(pageNo,pageSize){
+            $("#pageNo").val(pageNo);
+            $("#pageSize").val(pageSize);
+            return $("#searchForm").formToArray();
+        }
+
+        /**重置于查询表单,然后重新加载表格数据**/
+        function resetSearch(){
+            $("#searchForm")[0].reset();
+            //重新加载数据,设置当前页面为1
+            getData(1,g_pageSize);
+        }
+
+
+        //编辑
+        function onEdit(rowId) {
+            top.Dialog.open({
+                URL : "${ctx}/invoice/edit.do?invoiceId="+rowId,
+                Title : "编辑发票性质",
+                Width : 500,
+                Height : 320
+            });
+        }
+
+        //新增
+        function addUnit() {
+            top.Dialog.open({
+                URL : "${ctx}/invoice/edit.do",
+                Title : "新增发票性质",
+                Width : 500,
+                Height : 320
+            });
+        }
+
+        //单条记录删除
+        function onDelete(rowid){
+            top.Dialog.confirm("确定要删除该记录吗?",function(){
+                //删除记录
+                jQuery.post("${ctx}/invoice/delete.do",
+                    {"ids":rowid},
+                    function(responseText){
+                        if(responseText.status=="y"){
+                            top.Dialog.alert(responseText.info);
+                            resetSearch();
+                        }else{
+                            top.Dialog.alert(responseText.info);
+                        }
+
+                    },
+                    "json");
+            });
+        }
+
+    </script>
+
+</head>
+<body>
+<div class="box2" panelTitle="发票信息列表">
+    <form action="" id="searchForm" method="post">
+        <input type="hidden" id="pageNo" name="pageNo" value="1"/>
+        <input type="hidden" id="pageSize" name="pageSize" value="10"/>
+        <table>
+            <tr>
+                <td>发票号:</td>
+                <td>
+                    <input type="text" id="Q_invoiceNumb_S_LK" name="Q_invoiceNumb_S_LK" />
+                </td>
+                <td><button type="button" onclick="searchHandler()"><span class="icon_find">查询</span></button></td>
+                <td><button type="button" onclick="resetSearch()"><span class="icon_reload">重置</span></button></td>
+            </tr>
+        </table>
+    </form>
+</div>
+<div id="scrollContent">
+    <div class="padding_right5">
+        <div id="maingrid"></div>
+    </div>
+</div>
+<!-- 分页组件 -->
+<div style="height:35px;">
+    <div id="letfContent" class="float_left padding5"></div>
+    <div class="float_right padding5">
+        <div id="pager" total="0" class="pageArrow" showSelect="true" inputPosition="right"></div>
+    </div>
+    <div class="clear"></div>
+</div>
+</body>
+</html>

+ 3 - 0
src/config/spring-dao.xml

@@ -29,6 +29,9 @@
 
 	<!-- 业务模块 -->
 
+	<!--发票管理信息-->
+	<bean id="InvoiceDao" class="com.bus.dao.impl.InvoiceDaoImpl"/>
+
 	<!-- 单位基本信息 -->
 	<bean class="com.bus.dao.impl.BusOrgDaoImpl" id="busOrgDao"/>
 

+ 4 - 1
src/config/spring-service.xml

@@ -23,7 +23,10 @@
 	<bean id="taskUserAssignService" class="com.bpm.service.impl.TaskUserAssignServiceImpl"/>
 	<!--任务审批意见服务-->
 	<bean id="bpmTaskOpinionService" class="com.bpm.service.impl.BpmTaskOpinionServiceImpl"/>
-			
+
+	<!--发票管理服务-->
+	<bean id="InvoiceService" class="com.bus.service.impl.InvoiceServiceImpl" />
+
 	<!--微信-->
 	<bean class="com.popedom.service.impl.WxOrgServiceImpl" id="WxOrgService"/>
 

+ 7 - 0
src/java/com/bus/dao/InvoiceDao.java

@@ -0,0 +1,7 @@
+package com.bus.dao;
+
+import com.bus.model.Invoice;
+import com.core.dao.IGenericDao;
+
+public interface InvoiceDao extends IGenericDao<Invoice, Long> {
+}

+ 15 - 0
src/java/com/bus/dao/impl/InvoiceDaoImpl.java

@@ -0,0 +1,15 @@
+package com.bus.dao.impl;
+
+import com.bus.dao.InvoiceDao;
+import com.bus.model.Invoice;
+import com.core.dao.impl.GenericDaoImpl;
+
+/**
+ * 数据导入文件持久层接口类
+ *
+ * @author Liuhj
+ *
+ */
+public class InvoiceDaoImpl extends GenericDaoImpl<Invoice, Long>
+        implements InvoiceDao {
+}

+ 41 - 0
src/java/com/bus/model/Invoice.hbm.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+<!-- Generated 2014-10-25 18:34:16 by Hibernate Tools 4.0.0 -->
+<hibernate-mapping>
+    <class name="com.bus.model.Invoice" table="invoice">
+       	<id name="invoiceId" type="long">
+			<column name="invoice_id" />
+			<generator class="native" />
+		</id>
+       
+        <property name="invoiceNumb" type="string">
+           <column name="invoice_numb" length="64"/>
+        </property>
+ 
+        
+      <property name="invoiceCode" type="string">
+            <column name="invoice_code" length="64" />
+        </property>
+        <property name="amountMoney" type="string">
+            <column name="amount_money" length="64" />
+        </property>
+        
+         <property name="billingTime">
+            <column name="billing_time" />
+        </property>       
+         <property name="billingUser" type="string">
+            <column name="billing_user" length="128" />
+        </property>
+        <property name="invoiceInfo" type="string">
+            <column name="invoice_info" length="1024" />
+        </property>
+        <property name="state" type="long">
+            <column name="state" length="32" />
+        </property>
+        <property name="remarks" type="string">
+            <column name="remarks" length="1024" />
+        </property>
+
+    </class>
+</hibernate-mapping>

+ 85 - 0
src/java/com/bus/model/Invoice.java

@@ -0,0 +1,85 @@
+package com.bus.model;
+
+import java.util.Date;
+
+import flexjson.JSON;
+import org.joda.time.DateTime;
+
+/**
+ * 发票管理
+ * @author Liuhj
+ */
+public class Invoice {
+
+    /**发票id**/
+    private Long invoiceId;
+
+    /**发票号**/
+    private String invoiceNumb;
+
+    /**发票代码**/
+    private String invoiceCode;
+
+    /**金额**/
+    private String amountMoney;
+
+    /**开票时间**/
+    private Date billingTime;
+
+    /**开票人**/
+    private String billingUser;
+
+    /**开票信息**/
+    private String invoiceInfo;
+
+    /**发票状态**/
+    private Long state;
+
+    /**备注**/
+    private String remarks;
+
+    public String getInvoiceNumb() {
+        return invoiceNumb;
+    }
+
+    public void setInvoiceNumb(String invoiceNumb) { this.invoiceNumb = invoiceNumb; }
+
+    public Long getInvoiceId() {
+        return invoiceId;
+    }
+
+    public void setInvoiceId(Long invoiceId) {
+        this.invoiceId = invoiceId;
+    }
+
+    public String getInvoiceCode() { return invoiceCode; }
+
+    public void setInvoiceCode(String invoiceCode) { this.invoiceCode = invoiceCode; }
+
+    public String getAmountMoney() { return amountMoney; }
+
+    public void setAmountMoney(String amountMoney) { this.amountMoney = amountMoney; }
+
+    public Date getBillingTime() { return billingTime; }
+
+    public void setBillingTime(Date billingTime) { this.billingTime = billingTime; }
+
+    public String getBillingUser() { return billingUser; }
+
+    public void setBillingUser(String billingUser) { this.billingUser = billingUser; }
+
+    public String getInvoiceInfo() { return invoiceInfo; }
+
+    public void setInvoiceInfo(String invoiceInfo) { this.invoiceInfo = invoiceInfo; }
+
+    public Long getState() {
+        return state;
+    }
+
+    public void setState(Long state) { this.state = state; }
+
+    public String getRemarks() { return remarks; }
+
+    public void setRemarks(String remarks) { this.remarks = remarks; }
+
+}

+ 7 - 0
src/java/com/bus/service/InvoiceService.java

@@ -0,0 +1,7 @@
+package com.bus.service;
+
+import com.bus.model.Invoice;
+import com.core.service.IGenericService;
+
+public interface InvoiceService extends IGenericService<Invoice, Long> {
+}

+ 19 - 0
src/java/com/bus/service/impl/InvoiceServiceImpl.java

@@ -0,0 +1,19 @@
+package com.bus.service.impl;
+
+import com.bus.dao.InvoiceDao;
+import com.bus.model.Invoice;
+import com.bus.service.InvoiceService;
+import com.core.service.impl.GenericServiceImpl;
+import com.core.dao.IGenericDao;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class InvoiceServiceImpl extends GenericServiceImpl<Invoice, Long> implements InvoiceService {
+
+    @Autowired
+    private InvoiceDao dao;
+
+    @Override
+    protected IGenericDao<Invoice, Long> getGenericDao() {
+        return this.dao;
+    }
+}

+ 113 - 0
src/java/com/bus/web/InvoiceController.java

@@ -0,0 +1,113 @@
+package com.bus.web;
+
+import com.bus.model.Invoice;
+import com.bus.service.InvoiceService;
+import com.core.dao.util.Updater;
+import com.core.web.BaseController;
+import com.core.web.query.QueryFilter;
+import com.core.web.security.ContextUtil;
+import com.popedom.model.PopUser;
+import org.joda.time.DateTime;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+
+/**
+ *发票控制类
+ * @author Liuhj
+ *
+ */
+@Controller
+@RequestMapping({"/invoice/"})
+public class InvoiceController extends BaseController {
+
+    @Autowired
+    private InvoiceService invoiceService;
+    /**
+     * 发票信息列表
+     * @param model
+     * @return
+     */
+    @RequestMapping("list.do")
+    public String list(ModelMap model){
+        return "bus/invoice-list";
+    }
+
+    @RequestMapping("listPage.do")
+    @ResponseBody
+    public String listPage(HttpServletRequest request, ModelMap model){
+        QueryFilter filter=new QueryFilter(request);
+        filter.addSorted("invoiceId", QueryFilter.ORDER_DESC);
+        this.page = invoiceService.getPageByFilter(filter);
+        return this.getPageJosnResult();
+    }
+
+    /**
+     * 打开编辑页面
+     * @param invoiceId
+     * @param model
+     * @return
+     */
+    @RequestMapping("edit.do")
+    public String edit(Long invoiceId,ModelMap model){
+        Invoice bwp=null;
+        if(invoiceId!=null){
+            bwp = invoiceService.get(invoiceId);
+        }else{
+            bwp =new Invoice();
+        }
+
+        model.addAttribute("bwp", bwp);
+        return "bus/invoice-edit";
+    }
+
+    /**
+     * 编辑发票信息
+     * @param role
+     * @return
+     */
+    @RequestMapping("editData.do")
+    @ResponseBody
+    public Object editData(Invoice bwp,ModelMap model){
+        try {
+            if(bwp.getInvoiceId()!=null){
+                Updater<Invoice> updater = new Updater<Invoice>(bwp);
+                invoiceService.updateByUpdater(updater);
+                return addJsonSuccessMsg("修改成功!");
+            }else{
+                PopUser popUser=ContextUtil.getCurrentUser();
+                bwp.setBillingUser(popUser.getFullName());
+                bwp.setBillingTime(new Date());
+                invoiceService.save(bwp);
+                return addJsonSuccessMsg("新增成功!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return addJsonErrorMsg("操作失败");
+        }
+    }
+
+    /**
+     * 删除发票信息
+     * @param ids
+     * @return
+     */
+    @RequestMapping("delete.do")
+    @ResponseBody
+    public Object delete(Long[] ids){
+
+        try {
+            invoiceService.removeByIds(ids);
+            return addJsonSuccessMsg("删除成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return addJsonErrorMsg("操作失败");
+        }
+
+    }
+}