📄 cg_detail.jsp
字号:
<%@ page language="java" import="java.util.*,java.text.*"
pageEncoding="GB18030"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>采购单主界面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/style.css" rel="stylesheet" type="text/css">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="dwr/interface/PomainDAO.js"></script>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>
<script language="javascript" src="<%=basePath%>script/common.js"></script>
<script language="javascript" type="text/javascript">
var reVenderCode;
var mrow;
var flag = true;
function init() {
window.moveTo(0,0);
window.resizeTo(screen.width, screen.height);
}
//打开添加框
function openAddStockTable()
{
flag = true;
clearItem();
$("addStockTable").style.display="block";
}
//关闭添加框
function colseaddStockTable()
{
$("addStockTable").style.display="none";
}
//清空添加界面的元素
function clearItem()
{
$("poid").value="";
$("poid").disabled = false;
$("createTime").value="<%=new SimpleDateFormat("yyyy-MM-dd").format(new Date())%>";
$("name").value="";
$("account").value="";
$("tipFee").value="";
$("productTotal").value="";
$("poTotal").value="";
$("payType").value="";
$("prePayFee").value="";
$("remark").value="";
DWRUtil.removeAllRows("productDetailTable");
}
//产品明细选择
function choiceSpxx(rowIndex) {
var productDetailTable = document.getElementById("productDetailTable");
var length = productDetailTable.rows.length;
var currentSpbm = null;
if (length>1) {
currentSpbm = document.mainFrm.spbm[rowIndex].value;
} else {
currentSpbm = document.mainFrm.spbm.value;
}
var returnValue = window.showModalDialog("<%=basePath%>servlet/ProServlet", null, "dialogHeight:400px; dialogWidth:600px; help:no; status:no");
if (returnValue==null) return;
if (length>1) {
document.mainFrm.spbm[rowIndex].value = returnValue[0];
document.mainFrm.sptj[rowIndex].value = returnValue[1];
} else {
document.mainFrm.spbm.value = returnValue[0];
document.mainFrm.sptj.value = returnValue[1];
}
}
//选择供应商名称
function choiceName()
{
var returnValue = window.showModalDialog("<%=basePath%>servlet/VenderServlet?flog=select", null, "dialogHeight:400px; dialogWidth:600px; scroll:yes; help:no; status:no");
$("name").value = returnValue[1];
reVenderCode = returnValue[0];
}
//产品明细添加一行
function addItem() {
var detailTable = document.getElementById("productDetailTable");
var oRow = detailTable.insertRow(-1);//在表格最后添加一行
oRow.align = "center";
oCell = oRow.insertCell(0);//添加单元格
oCell.innerHTML = oRow.rowIndex;
oCell = oRow.insertCell(1);
oCell.innerHTML = "<input type='text' name='spbm' size='10' readonly> <span class='LL'><image src='images/selectDate.gif' onClick='choiceSpxx(\""+(oRow.rowIndex-1)+"\")'></span>";
oCell = oRow.insertCell(2);
oCell.innerHTML = "<input type='text' name='spmc' size='15'>";
oCell = oRow.insertCell(3);
oCell.innerHTML = "<input type='text' name='ytsl' size='10' value='0'>";
oCell = oRow.insertCell(4);
oCell.innerHTML = "<input type='text' name='sptj' size='10' value='0' readonly>";
oCell = oRow.insertCell(5);
oCell.innerHTML = "<input type='text' name='spzl' size='10' value='0' >";
oCell = oRow.insertCell(6);
oCell.innerHTML = '<input type="button" value="删除" class="LL" onclick="delItem(this.parentNode.parentNode)"/>';
}
//保存按钮 采购单添加与修改
function addItems_CG()
{
if(flag==true)//采购单添加
{
var pomain={};
pomain.poid = DWRUtil.getValue("poid");
pomain.createTime = DWRUtil.getValue("createTime");
pomain.venderCode = reVenderCode;
pomain.account = DWRUtil.getValue("account");
pomain.tipFee = DWRUtil.getValue("tipFee");
pomain.productTotal = DWRUtil.getValue("productTotal");
pomain.poTotal = DWRUtil.getValue("poTotal");
pomain.payType = $("payType").options[$("payType").selectedIndex].value;
pomain.prePayFee = DWRUtil.getValue("prePayFee");
pomain.remark = DWRUtil.getValue("remark");
pomain.status = 1;//设置新添采购单状态为1
//对产品明细执行添加操作
var productDetailTable = document.getElementById("productDetailTable");
var length = productDetailTable.rows.length;
var productArray = new Array();
if(length>0){
for(var i = 0;i<length;i++)
{
var poitem = {};
poitem.poid = DWRUtil.getValue("poid");
poitem.productCode = document.getElementsByName("spbm")[i].value;
poitem.unitPrice = document.getElementsByName("spmc")[i].value;
poitem.num = document.getElementsByName("ytsl")[i].value;
poitem.unitName = document.getElementsByName("sptj")[i].value;
poitem.itemPrice = document.getElementsByName("spzl")[i].value;
productArray.push(poitem);
}
}
PomainDAO.addItems_CG(pomain,productArray,addItems_CG_CallBack);
}else if(flag == false){//采购单修改
var pomain={};
pomain.poid = DWRUtil.getValue("poid");
pomain.venderCode = reVenderCode;
pomain.account = DWRUtil.getValue("account");
pomain.tipFee = DWRUtil.getValue("tipFee");
pomain.productTotal = DWRUtil.getValue("productTotal");
pomain.poTotal = DWRUtil.getValue("poTotal");
pomain.payType = $("payType").options[$("payType").selectedIndex].value;
pomain.prePayFee = DWRUtil.getValue("prePayFee");
pomain.remark = DWRUtil.getValue("remark");
//对产品明细执行添加操作
var productDetailTable = document.getElementById("productDetailTable");
var length = productDetailTable.rows.length;
var productArray = new Array();
if(length>0){
for(var i = 0;i<length;i++)
{
var poitem = {};
poitem.poid = DWRUtil.getValue("poid");
poitem.productCode = document.getElementsByName("spbm")[i].value;
poitem.unitPrice = document.getElementsByName("spmc")[i].value;
poitem.num = document.getElementsByName("ytsl")[i].value;
poitem.unitName = document.getElementsByName("sptj")[i].value;
poitem.itemPrice = document.getElementsByName("spzl")[i].value;
productArray.push(poitem);
}
}
PomainDAO.modifyItems_CG(pomain,productArray,modifyItems_CG_CallBack);
}
}
//PoaminDAO返回结果处理
function addItems_CG_CallBack(data)
{
if(data==1)
{
var row = $("CG_Tbody").insertRow(-1);
var cell = row.insertCell(0);
cell.innerHTML = row.rowIndex;
cell = row.insertCell(1);
cell.innerHTML = DWRUtil.getValue("poid");
cell = row.insertCell(2);
cell.innerHTML = DWRUtil.getValue("createTime");
cell = row.insertCell(3);
cell.innerHTML = DWRUtil.getValue("name");//有问题
cell = row.insertCell(4);
cell.innerHTML = DWRUtil.getValue("account");
cell = row.insertCell(5);
cell.innerHTML = DWRUtil.getValue("tipFee");
cell = row.insertCell(6);
cell.innerHTML = DWRUtil.getValue("productTotal");
cell = row.insertCell(7);
cell.innerHTML = DWRUtil.getValue("poTotal");
cell = row.insertCell(8);
cell.innerHTML = $("payType").options[$("payType").selectedIndex].text;
cell = row.insertCell(9);
cell.innerHTML = DWRUtil.getValue("prePayFee");
cell = row.insertCell(10);
cell.innerHTML = '<input type="button" value="修改" class="LL" onClick="modifyItem(this.parentNode.parentNode)"/> <input type="button" value="删除" class="LL" onClick="delMainItems(this.parentNode.parentNode)"/>';
alert("添加成功!");
colseaddStockTable();
}
}
//修改
function modifyItem(row)
{
mrow = row;
flag = false;
$("addStockTable").style.display="block";
$("poid").value = row.cells[1].innerHTML;
var poid = $("poid").value;
$("poid").disabled = true;
$("createTime").value = row.cells[2].innerHTML;
$("createTime").disabled = true;
$("name").value = row.cells[3].innerHTML;
$("account").value = row.cells[4].innerHTML;
$("account").disabled = true;
$("tipFee").value = row.cells[5].innerHTML;
$("productTotal").value = row.cells[6].innerHTML;
$("poTotal").value = row.cells[7].innerHTML;
var payType = row.cells[8].innerHTML;
$("payType").value = set_payType(payType);
$("prePayFee").value = row.cells[9].innerHTML;
PomainDAO.get_Remark(poid,get_RemarkCallBack);
PomainDAO.getProductDetail(poid,getProductDetailCallBack);
}
//修改显示备注的内容
function get_RemarkCallBack(data)
{
$("remark").value = data ;
}
//修改显示明细单的内容
function getProductDetailCallBack(data)
{
if(data!=null)
{
DWRUtil.removeAllRows("productDetailTable");
for(var i = 0;i<data.length;i++)
{
addItem();
document.getElementsByName("spbm")[i].value = data[i].productCode ;
document.getElementsByName("spmc")[i].value = data[i].unitPrice;
document.getElementsByName("ytsl")[i].value = data[i].num;
document.getElementsByName("sptj")[i].value = data[i].unitName;
document.getElementsByName("spzl")[i].value = data[i].itemPrice ;
}
}
}
function modifyItems_CG_CallBack(data)
{
if(data)
{
mrow.cells[3].innerHTML=$("name").value;
mrow.cells[5].innerHTML=$("tipFee").value;
mrow.cells[6].innerHTML=$("productTotal").value;
mrow.cells[7].innerHTML=$("poTotal").value;
mrow.cells[8].innerHTML=$("payType").options[$("payType").selectedIndex].text;
mrow.cells[9].innerHTML=$("prePayFee").value;
alert("修改成功!");
}else if(data==0){
alert("修改失败!");
}
}
//删除主单并将明细删除
function delMainItems(row)
{
mrow = row;
var flag1 = window.confirm("确定要删除此采购单嘛?") ;
if(flag1 ==true)
{
var poid = row.cells[1].innerHTML;
PomainDAO.delMainItems(poid,delMainItemsCallBack);
}
}
function delMainItemsCallBack(data)
{
if(data==1)
{
var CG_Tbody = $("CG_Tbody");
var index = mrow.rowIndex-1;
CG_Tbody.deleteRow(index);
var rowNum = CG_Tbody.rows.length;
for (i=index; i<rowNum; i++) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -