|
|
@@ -2,13 +2,13 @@ var page_size=10;
|
|
|
// var p_cur = 1; //页号
|
|
|
// var p_pages; //总页码
|
|
|
// var p_totalRecords;
|
|
|
-// var curTable;
|
|
|
+var curTable;
|
|
|
var curDatas;
|
|
|
function queryConstant(){
|
|
|
- p_cur = 1;
|
|
|
+ // p_cur = 1;
|
|
|
getConstant();
|
|
|
}
|
|
|
-function getConstant(p_cur){
|
|
|
+function getConstant(){
|
|
|
// var data = {
|
|
|
// "flag_name": $("#keywords").val()
|
|
|
// }
|
|
|
@@ -33,8 +33,8 @@ function updateTable(){
|
|
|
// var tableData=data.list;
|
|
|
var cols = [
|
|
|
{width: 80, text: '序号', type: 'number', flex: false, field: 'num'},
|
|
|
- {width: 80, text: '代码编号', type: 'date', flex: false, field: 'code_flag'},
|
|
|
- {width: 80, text: '代码名称', type: 'string', flex: true, field: 'code_name'},
|
|
|
+ {width: 80, text: '字典值', type: 'date', flex: false, field: 'code_value'},
|
|
|
+ {width: 80, text: '字典名称', type: 'string', flex: true, field: 'code_name'},
|
|
|
{width: 80, text: '有效标志', type: 'date', flex: false, field: 'valid'},
|
|
|
{width: 80, text: '代码标识', type: 'string', flex: true, field: 'code_flag'},
|
|
|
{width: 160, text: '标识名称', type: 'date', flex: false, field: 'flag_name'},
|
|
|
@@ -48,19 +48,14 @@ function updateTable(){
|
|
|
];
|
|
|
|
|
|
var pager = {
|
|
|
- page_size:10,
|
|
|
- p_cur : data.pageNum, //页号
|
|
|
- p_pages:data.pages, //总页码
|
|
|
- p_totalRecords:data.total,
|
|
|
- 'cb':getConstant
|
|
|
+ page_size:10
|
|
|
}
|
|
|
- curTable = $('.datatable').mytable({'cols':cols,
|
|
|
- 'tableData':'',//tableData,
|
|
|
- 'url':"/constant/getConstantByName/",
|
|
|
- 'param':data,
|
|
|
- 'pager':pager}
|
|
|
- );
|
|
|
-
|
|
|
+ $('.datatable').mytable({'cols':cols,
|
|
|
+ // 'tableData':tableData,
|
|
|
+ 'url':"/constant/getConstantByName/",
|
|
|
+ 'param':data,
|
|
|
+ 'pager':pager}
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
function showAddConstant(){
|
|
|
@@ -72,7 +67,7 @@ function showAddConstant(){
|
|
|
$('#sort_no').val('');
|
|
|
$('#remark').val('');
|
|
|
$("#valid").attr('checked','true');
|
|
|
- $("#operation-btn").click(function(){
|
|
|
+ $("#operation-btn").unbind("click").click(function(){
|
|
|
addConstant();
|
|
|
});
|
|
|
}
|
|
|
@@ -81,10 +76,12 @@ function addConstant(){
|
|
|
addOrUpdateConstant("/constant/add/");
|
|
|
}
|
|
|
|
|
|
+var cur_id;
|
|
|
function addOrUpdateConstant(url){
|
|
|
var valid=1;
|
|
|
if(!$("#valid").is(':checked')) valid=0;
|
|
|
var param ={
|
|
|
+ 'id':cur_id,
|
|
|
'code_flag':$('#code_flag').val(),
|
|
|
'flag_name':$('#flag_name').val(),
|
|
|
'code_value':Number($('#code_value').val()),
|
|
|
@@ -103,9 +100,9 @@ function addOrUpdateConstant(url){
|
|
|
}
|
|
|
|
|
|
function showEditConstant(id){
|
|
|
-
|
|
|
- // alert(curTable.getPager());
|
|
|
+ cur_id='';
|
|
|
$('#formModal').modal('toggle');
|
|
|
+ var curDatas = $('.datatable').mytable('getTableData');
|
|
|
var rowData;
|
|
|
for(var i=0;i<curDatas.length;i++){
|
|
|
if(id==curDatas[i].id){
|
|
|
@@ -113,21 +110,24 @@ function showEditConstant(id){
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- $('#code_flag').val(rowData.code_flag);
|
|
|
- $('#flag_name').val(rowData.flag_name);
|
|
|
- $('#code_value').val(rowData.code_value);
|
|
|
- $('#code_name').val(rowData.code_name);
|
|
|
- $('#sort_no').val(rowData.sort_no);
|
|
|
- $('#remark').val(rowData.remark);
|
|
|
- if(rowData.valid==1){
|
|
|
- $("#valid").attr('checked','true');
|
|
|
- }else{
|
|
|
- $("#valid").attr('checked','false');
|
|
|
+ if(rowData) {
|
|
|
+ cur_id = rowData.id;
|
|
|
+ $('#code_flag').val(rowData.code_flag);
|
|
|
+ $('#flag_name').val(rowData.flag_name);
|
|
|
+ $('#code_value').val(rowData.code_value);
|
|
|
+ $('#code_name').val(rowData.code_name);
|
|
|
+ $('#sort_no').val(rowData.sort_no);
|
|
|
+ $('#remark').val(rowData.remark);
|
|
|
+ if(rowData.valid==1){
|
|
|
+ $("#valid").attr('checked','true');
|
|
|
+ }else{
|
|
|
+ $("#valid").attr('checked','false');
|
|
|
+ }
|
|
|
+
|
|
|
+ $("#operation-btn").unbind("click").click(function(){
|
|
|
+ updateConstant();
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
- $("#operation-btn").click(function(){
|
|
|
- updateConstant();
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
function updateConstant(){
|