123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- <%@ page contentType="text/html; charset=utf-8" session="false" %>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- <head>
- <title>我的工作台</title>
- <%@ include file="../common/header.jsp" %>
- <link type="text/css" rel="stylesheet" href="${contextPath}/css/themes/easyui.css" />
- <script type="text/javascript" src="${contextPath }/js/jquery.easyui.min.js"></script>
- <script type="text/javascript" src="${contextPath }/js/mColorPicker.js"></script>
- <script type="text/javascript" src="${contextPath }/js/zxx.color_exchange.js"></script>
- <script type="text/javascript">
- var mydata,operType,panelCHeight=0,loadCount = 0,selRowId = 0,loadType=1;
- $(document).ready( function() {
- loadList(); //加载jqgrid
-
- panelC = $("body").layout("panel","center").panel();
- panelCHeight = panelC.height();
- $("#list").jqGrid("setGridHeight",panelC.height()-55);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 30);
-
- $("body").layout("panel","south").panel({
- onClose: function(){
- panelC = $("body").layout("panel","center").panel();
- $("#list").jqGrid("setGridHeight",panelC.height()-55);
- },
- onExpand: function(){
- panelS = $("body").layout("panel","south").panel();
- panelCHeight = document.body.clientHeight - panelS.height();
- $("#list").jqGrid("setGridHeight",panelCHeight-135);
- },
- onResize: function(){
- panelS = $("body").layout("panel","south").panel();
- panelCHeight = document.body.clientHeight - panelS.height();
- $("#list").jqGrid("setGridHeight",panelCHeight-135);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 30);
- $("#listFtdetail").jqGrid("setGridHeight",panelS.height()-75);
- $("#listFtdetail").jqGrid("setGridWidth",document.body.clientWidth - 30);
- }
- });
-
- //初始化绑定选颜色控件
- $('#mColorPickerImg').bind('click', function() {
- if(selRowId == 0){
- alert("请选择配方模版");
- }else{
- var color = $("#tColor").val();
- var str = color.substring(0,3);
- if(str == "rgb"){
- color = color.colorHex();
- }
- $.ajax({
- async: true,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "tcolor="+color+"&selId="+selRowId,
- url: "${contextPath }/admin/recipeplan/tcolorfeedtemplet.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- loadList(); //重新载入服务器数据
- }
- });
- }
- });
-
- });
-
- $(window).resize(function(){
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 10);
- $("#listFtdetail").jqGrid("setGridWidth",document.body.clientWidth - 10);
- });
-
- //jqgrid初始化
- function loadList(){
- jQuery("#list").jqGrid({
- datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
- height: 170, //高度
- colNames:['主键','模版名称','模板颜色','牲畜类型', '制定人', '说明', '是否补料模版', '顺序', '是否启用'], //列名
- colModel:[
- {
- name: "ID",
- index: "ID",
- align: "center",
- sorttype: "string",
- editable: true,
- hidden: true
- //editoptions:{readonly:true} 如果要显示该列可以设置只读
- },
- {
- name: "TNAME",
- index: "TNAME",
- align: "center",
- sorttype: "string",
- editable: true,
- editrules:{
- required: true,
- custom: true,
- custom_func: checkName
- }
- },
- {
- name: "tColor",
- index: "tColor",
- width: 70,
- align: "center",
- sorttype: "string",
- editable: false
- },
- {
- name: "CLASSNAME",
- index: "CLASSNAME",
- align: "center",
- sorttype: "int",
- editable: true,
- edittype: "select",
- editoptions:{
- dataUrl: "${contextPath }/admin/recipeplan/feedtempletselect.html"
- }
- },
- {
- name: "OWNER",
- index: "OWNER",
- align: "center",
- sorttype: "int",
- editable: true
- },
- {
- name: "REMARK",
- index: "REMARK",
- align: "center",
- sorttype: "int",
- editable: true
- },
- {
- name: "isSupplyFeed",
- index: "isSupplyFeed",
- align: "center",
- sorttype: "string",
- editable: true,
- edittype: "select",
- editoptions: {value:{"Yes":"是","No":"否"}}
- },
- {
- name: "SORT",
- index: "SORT",
- align: "center",
- sorttype: "int",
- editable: true,
- editrules:{
- required: true,
- integer: true
- }
- },
- {
- name: "ENABLE",
- index: "ENABLE",
- align: "center",
- sorttype: "string",
- editable: true,
- edittype: "select",
- editoptions: {value:{"Yes":"是","No":"否"}}
- }
- ],
-
- cellEdit: true,
- cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
-
- onSelectCell: function(rowid){
- var selId = $("#list").jqGrid("getGridParam","selrow"); //获取当前选中行号
- var rowData = $("#list").jqGrid("getRowData",selId); //获取当前选中行真实对象
- selRowId = rowData.ID;
- },
-
- afterEditCell: function(rowid,name,val,iRow,iCol){
- var selId = $("#list").jqGrid("getGridParam","selrow"); //获取当前选中行号
- var rowData = $("#list").jqGrid("getRowData",selId); //获取当前选中行真实对象
- $("#ftdetailResult").load("${contextPath }/admin/recipeplan/ftdetail.html?currentTfId="+rowData.ID);
- selRowId = rowData.ID;
- },
-
- afterSaveCell: function(rowid,name,val,iRow,iCol) {
- var rowData = $("#list").jqGrid("getRowData",rowid);
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型jsond
- data: "ID="+rowData.ID+"&colName="+name+"&colValue="+val,
- url: "${contextPath }/admin/recipeplan/feedtempletupdatedyg.html",
- error: function(){alert("系统错误");},
- success: function(json){
- }
- });
- },
-
- pager: "#page", //#page分页控件绑定的位置对象
- pginput: false, //不显示分页文本框
- pgbuttons: false, //不显示翻页按钮
- rowNum: 1000, //每页显示条数
- viewrecords: true, //是否显示总条数
- emptyrecords: "无数据", //服务器返回空列表时显示的内容
- autowidth: true, //自动调节宽度
- sortname: 'SORT' //按SORT进行排序 默认asc
-
-
- });
-
- //获取数据集
- mydata = getLists();
-
- if(mydata!=null){
- for(var i=0;i<=mydata.length;i++){
- jQuery("#list").jqGrid('addRowData',i+1,mydata[i]);
- }
- //jQuery("#list").jqGrid().trigger("reloadGrid"); //添加完数据后客户端自动刷新一次、实现客户端数据与服务器数据的完全分离
- }
- //绑定、设置工具栏
- jQuery("#list").jqGrid("navGrid","#page",{
- add: true, addtext: "添加",
- edit: false, edittext: "编辑",
- del: true, deltext: "删除",refresh: false,
- addfunc: addRow, //自定义添加方法
- delfunc: deleteRow, //自定义删除方法
- searchtext: "搜索",
- refreshtext: "刷新",
- alerttext:"请选择一条记录!"
- });
-
- if(loadCount == 0){
- $("#list").navButtonAdd("#page",{
- caption:"复制",
- buttonicon:"ui-icon-document",
- position: "last",
- title:"复制",
- cursor: "pointer", //光标类型
- onClickButton: copyRow
- });
- $("#list").navButtonAdd("#page",{
- caption:"显示启用",
- buttonicon:"ui-icon-document",
- position: "last",
- title:"显示启用",
- cursor: "pointer", //光标类型
- onClickButton: showUse
- });
- $("#list").navButtonAdd("#page",{
- caption:"显示禁用",
- buttonicon:"ui-icon-document",
- position: "last",
- title:"显示禁用",
- cursor: "pointer", //光标类型
- onClickButton: showBan
- });
- $("#list").navButtonAdd("#page",{
- caption:"显示全部",
- buttonicon:"ui-icon-document",
- position: "last",
- title:"显示全部",
- cursor: "pointer", //光标类型
- onClickButton: showAll
- });
- $("#list").navButtonAdd("#page",{
- caption:"导出Excel",
- buttonicon:"ui-icon-document",
- position: "last",
- title:"导出Excel",
- cursor: "pointer", //光标类型
- onClickButton: exportExcel
- });
- //$("#page_left").append(" <input id='tColor' name='tColor' style='width:50px; ' value='' type='color' class='color' readonly='readonly' />");
- $("#page_left").append(" <input id='tColor' name='tColor' style='width:50px; color: white; background-color: rgb(0, 0, 0);' value='' type='hidden' class='color mColorPicker' readonly='readonly' />");
- $("#page_left").append("<span onClick='selTColor1()' id='mcp_tColor' class='mColorPickerTrigger' style='display: inline-block; cursor: pointer;'><img src='images/color.png' style='border: 0px; margin: 0px 0px 0px 3px; vertical-align: text-bottom;'></span>");
- //$("#page_left").append("<input class='sysub' type='button' value='选择模版颜色' onClick='selTColor()' style='width:85px;height: 30px;'/>");
- loadCount++;
- }
-
- }
-
- //获取服务器数据
- function getLists(){
- var loadurl;
- if(loadType==1){
- loadurl="${contextPath }/admin/recipeplan/feedtempletlistuse.html";
- }
- else if(loadType==2){
- loadurl="${contextPath }/admin/recipeplan/feedtempletlistban.html";
- }
- else if(loadType==3){
- loadurl="${contextPath }/admin/recipeplan/feedtempletlist.html";
- }
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型json
- url: loadurl,
- error: function(){alert("系统错误");},
- success: function(json){
- mydata = json;
- }
- });
- return mydata;
- }
-
- //自定义添加方法
- function addRow(){
- var ids = $("#list").jqGrid("getDataIDs");
- $("#list").jqGrid("addRowData",ids.length+1,{},"first");
- $.ajax({
- async: false,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "oper=add&selId=",
- url: "${contextPath }/admin/recipeplan/feedtempletupdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- loadList(); //重新载入服务器数据
- }
- });
- }
-
- //自定义删除方法
- function deleteRow(){
- var count = 0;
- var row = $("#list").jqGrid("getGridParam","selrow");
- var selRow = $("#list").jqGrid("getRowData",row);
- $.ajax({
- async: false,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "selId="+selRow.ID,
- url: "${contextPath }/admin/recipeplan/queryfeedtempletglxx.html",
- error: function(){alert("系统错误");},
- success: function(json){
- count = json.status;
- }
- });
-
- var deletetype,warn;
- if(count==0){
- deletetype="realdel";
- warn="您确定要删除吗"
- }
- else{
- deletetype="unrealdel";
- warn="该配方模板已被使用,是否要删除\n(栏舍配方中相关信息将被清除)"
- }
- var flag = confirm(warn);
- if(flag){
- $.ajax({
- async: false,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "oper="+deletetype+"&selId="+selRow.ID,
- url: "${contextPath }/admin/recipeplan/feedtempletupdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- window.location.reload();
- }
- });
- }
- }
-
- //自定义验证名称是否存在方法
- function checkName(value, colname){
- var flag = 0;
- var selId = $("#list").jqGrid("getGridParam","selrow"); //获取当前选中行号
- var rowData = $("#list").jqGrid("getRowData",selId); //获取当前选中行真实对象
- $.ajax({
- async: false,
- type: 'POST',
- data: "entityName="+value+"&type="+operType+"&entityId="+rowData.ID,
- dataType: 'json',
- url: "${contextPath}/admin/recipeplan/feedtempletcheck.html",
- error: function(){alert("系统错误");},
- success: function(json){
- flag = json.status;
- }
- });
- if(flag == 0){
- return [true,""];
- }else{
- return [false,"模版名称已经存在!"];
- }
- }
-
- //复制记录
- function copyRow(){
- var selId = $("#list").jqGrid("getGridParam","selrow"); //获取当前选中行号
- if(selId!=null){
- var rowData = $("#list").jqGrid("getRowData",selId); //获取当前选中行真实对象
- $.ajax({
- async: false,
- type: 'POST',
- data: "entityId="+rowData.ID,
- dataType: 'json',
- url: "${contextPath}/admin/recipeplan/copyRow.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- window.location.reload();
- }
- });
- }else{
- alert("请选择记录");
- }
- }
-
- //导出Excel
- function exportExcel(){
- document.location.href="${contextPath }/admin/recipeplan/feedtempletexcel.html";
- }
-
- function selTColor(){
-
- $("body").layout("collapse","south");
- panelC = $("body").layout("panel","center").panel();
- $("#list").jqGrid("setGridHeight",panelC.height()-55);
-
- if(selRowId == 0){
- alert("请选择配方模版");
- }else{
- var color = $("#tColor").val();
- var str = color.substring(0,3);
- if(str == "rgb"){
- color = color.colorHex();
- }
- $.ajax({
- async: true,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "tcolor="+color+"&selId="+selRowId,
- url: "${contextPath }/admin/recipeplan/tcolorfeedtemplet.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- loadList(); //重新载入服务器数据
- }
- });
- }
- }
-
- function selTColor1(){
- $("body").layout("collapse","south");
- panelC = $("body").layout("panel","center").panel();
- $("#list").jqGrid("setGridHeight",panelC.height()-55);
-
- $("#mColorPickerSwatches").hide();
- $("#mColorPickerFooter").hide();
-
- //$("#mColorPicker").attr("style","height: 144px;");
-
- }
-
- function showAll(){
- loadType=3;
- $("#list").clearGridData();
- loadList();
- }
-
- function showBan(){
- loadType=2;
- $("#list").clearGridData();
- loadList();
- }
-
- function showUse(){
- loadType=1;
- $("#list").clearGridData();
- loadList();
- }
-
- </script>
- </head>
- <body class="easyui-layout">
- <div region="center" title="配方模版" style="padding:5px;background:#eee;">
- <table id="list"></table>
- <div id="page"></div>
- <input type="hidden" />
- </div>
- <div region="south" split="true" title="饲料" style="padding:5px;height:230px;">
- <div id="ftdetailResult"></div>
- </div>
- </body>
- </html>
|