信呼OA版本v2.3.8
This commit is contained in:
104
webmain/system/table/rock_table_fields.php
Normal file
104
webmain/system/table/rock_table_fields.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
{params}
|
||||
var tabelss = params.table;
|
||||
var a = $('#veiw_{rand}').bootstable({
|
||||
tablename:'table',celleditor:true,url:js.getajaxurl('tablefields','{mode}','{dir}'),
|
||||
params:{'table':tabelss},
|
||||
columns:[{
|
||||
text:'字段名',dataIndex:'name'
|
||||
},{
|
||||
text:'类型',dataIndex:'type'
|
||||
},{
|
||||
text:'类型',dataIndex:'types'
|
||||
},{
|
||||
text:'是否为空',dataIndex:'isnull'
|
||||
},{
|
||||
text:'默认值',dataIndex:'dev'
|
||||
},{
|
||||
text:'说明',dataIndex:'explain',type:'textarea',align:'left'
|
||||
}],
|
||||
itemclick:function(){
|
||||
btn(false);
|
||||
},
|
||||
beforeload:function(){
|
||||
btn(true);
|
||||
}
|
||||
});
|
||||
|
||||
var c = {
|
||||
del:function(){
|
||||
a.del({
|
||||
url:js.getajaxurl('delfields','{mode}','{dir}'),
|
||||
params:{table:tabelss}
|
||||
});
|
||||
},
|
||||
clickwin:function(o1,lx){
|
||||
var h = $.bootsform({
|
||||
title:'字段',height:400,width:500,
|
||||
tablename:'',isedit:lx,url:js.getajaxurl('savefields','{mode}','{dir}',{table:tabelss}),
|
||||
submitfields:'name,type,explain,lens,isnull,dev',
|
||||
items:[{
|
||||
labelText:'字段名',name:'name',required:true
|
||||
},{
|
||||
labelText:'类型',name:'type',type:'select',required:true,store:[['varchar','varchar(字符串)'],['int','int(长整数)'],['smallint','smallint(中整数)'],['tinyint','tinyint(短整数)'],['bigint','bigint(超长整数)'],['date','date(日期)'],['datetime','datetime(日期时间)'],['decimal','decimal(浮点数)'],['mediumint','mediumint(中等整数)'],['text','text(长文本域)']],valuefields:0,displayfields:1
|
||||
},{
|
||||
labelText:'长度',name:'lens',value:'0'
|
||||
},{
|
||||
labelText:'默认值',name:'dev'
|
||||
},{
|
||||
labelText:'说明',name:'explain'
|
||||
},{
|
||||
name:'isnull',labelText:'是否为空',type:'select',store:[['YES','是'],['NO','否']],valuefields:0,displayfields:1
|
||||
}],
|
||||
success:function(){
|
||||
a.reload();
|
||||
}
|
||||
});
|
||||
if(lx==1){
|
||||
h.setValues(a.changedata);
|
||||
var tys=a.changedata.types.split('(');
|
||||
var cd='0';
|
||||
if(tys[1])cd=tys[1].replace(')','');
|
||||
h.setValue('lens', cd);
|
||||
}
|
||||
h.getField('name').focus();
|
||||
},
|
||||
refresh:function(){
|
||||
a.reload();
|
||||
}
|
||||
};
|
||||
|
||||
function btn(bo){
|
||||
get('del_{rand}').disabled = bo;
|
||||
get('edit_{rand}').disabled = bo;
|
||||
}
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
|
||||
<table width="100%"><tr>
|
||||
<td nowrap>
|
||||
<button class="btn btn-primary" click="clickwin,0" type="button"><i class="icon-plus"></i> 新增字段</button>
|
||||
<button class="btn btn-default" click="refresh" type="button"><i class="icon-refresh"></i> 刷新</button>
|
||||
</td>
|
||||
|
||||
|
||||
<td width="80%">
|
||||
<font color="red"> 数据表字段关系到系统运行,请谨慎操作,</font>更好用的管理请使用其他工具。
|
||||
</td>
|
||||
<td align="right" nowrap>
|
||||
<button class="btn btn-danger" id="del_{rand}" click="del" disabled type="button"><i class="icon-trash"></i> 删除</button>
|
||||
<button class="btn btn-info" id="edit_{rand}" click="clickwin,1" disabled type="button"><i class="icon-edit"></i> 编辑 </button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="blank10"></div>
|
||||
<div id="veiw_{rand}"></div>
|
||||
|
||||
82
webmain/system/table/rock_table_list.php
Normal file
82
webmain/system/table/rock_table_list.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
|
||||
var a = $('#view_{rand}').bootstable({
|
||||
tablename:'table',fanye:true,modedir:'{mode}:{dir}',storebeforeaction:'tablebefore',celleditor:true,
|
||||
cellurl:js.getajaxurl('tablesm','{mode}','{dir}'),
|
||||
columns:[{
|
||||
text:'表名',dataIndex:'id',sortable:true
|
||||
},{
|
||||
text:'引擎',dataIndex:'engine'
|
||||
},{
|
||||
text:'总记录数',dataIndex:'rows',sortable:true
|
||||
},{
|
||||
text:'说明',dataIndex:'explain',editor:true
|
||||
},{
|
||||
text:'创建时间',dataIndex:'cjsj',sortable:true
|
||||
},{
|
||||
text:'字符集',dataIndex:'TABLE_COLLATION'
|
||||
},{
|
||||
text:'更新时间',dataIndex:'gxsj',sortable:true
|
||||
}],
|
||||
itemclick:function(){
|
||||
btn(false);
|
||||
},
|
||||
beforeload:function(){
|
||||
btn(true);
|
||||
}
|
||||
});
|
||||
|
||||
function btn(bo){
|
||||
get('edit_{rand}').disabled = bo;
|
||||
get('kanbtn_{rand}').disabled = bo;
|
||||
}
|
||||
var c={
|
||||
clickwin:function(){
|
||||
var name=a.changeid;
|
||||
addtabs({num:'tablefields'+name+'',url:'system,table,fields,table='+name+'',name:'['+name+']字段管理'});
|
||||
},
|
||||
kanjili:function(){
|
||||
var name=a.changeid;
|
||||
addtabs({num:'tablerecord'+name+'',url:'system,table,record,table='+name+'',name:'['+name+']记录'});
|
||||
},
|
||||
search:function(){
|
||||
a.setparams({
|
||||
key:get('key_{rand}').value
|
||||
},true);
|
||||
}
|
||||
};
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td >
|
||||
<input class="form-control" style="width:180px" id="key_{rand}" placeholder="表名">
|
||||
</td>
|
||||
|
||||
<td style="padding-left:10px">
|
||||
<button class="btn btn-default" click="search" type="button">搜索</button>
|
||||
</td>
|
||||
|
||||
<td width="80%" style="padding-left:10px">
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td align="right" nowrap>
|
||||
<button class="btn btn-info" id="edit_{rand}" click="clickwin,1" disabled type="button"><i class="icon-edit"></i> 编辑 </button>
|
||||
<button class="btn btn-default" id="kanbtn_{rand}" click="kanjili" disabled type="button">查看记录</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="blank10"></div>
|
||||
<div id="view_{rand}"></div>
|
||||
<div class="tishi">数据库表格管理请谨慎操作!</div>
|
||||
77
webmain/system/table/rock_table_record.php
Normal file
77
webmain/system/table/rock_table_record.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
{params}
|
||||
var tabs = params.table,bool=false;
|
||||
var a = $('#view_{rand}').bootstable({
|
||||
tablename:'option',fanye:true,modedir:'{mode}:{dir}',storebeforeaction:'tablerecord_before',
|
||||
storeafteraction:'tablerecord_after',params:{'stable':jm.encrypt(tabs)},checked:false,statuschange:false,
|
||||
columns:[{
|
||||
text:'ID',dataIndex:'id',sortable:true
|
||||
}],
|
||||
itemclick:function(){
|
||||
btn(false);
|
||||
},
|
||||
beforeload:function(){
|
||||
btn(true);
|
||||
},
|
||||
loadbefore:function(d){
|
||||
if(!bool){
|
||||
a.setColumns(d.fieldsarr);
|
||||
var str = '',i;
|
||||
for(i=0;i<d.fieldsarr.length;i++)str+='<option value="'+d.fieldsarr[i].dataIndex+'">'+d.fieldsarr[i].text+'</option>';
|
||||
bool = true;
|
||||
$('#fields_{rand}').html(str);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function btn(bo){
|
||||
|
||||
}
|
||||
var c={
|
||||
|
||||
search:function(){
|
||||
a.setparams({
|
||||
key:get('key_{rand}').value,
|
||||
fields:get('fields_{rand}').value
|
||||
},true);
|
||||
}
|
||||
};
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td >
|
||||
<select class="form-control" style="width:180px" id="fields_{rand}" >
|
||||
<option value="id">ID</option>
|
||||
</select>
|
||||
</td>
|
||||
<td >
|
||||
<input class="form-control" style="width:180px" id="key_{rand}" placeholder="等于值">
|
||||
</td>
|
||||
|
||||
<td style="padding-left:10px">
|
||||
<button class="btn btn-default" click="search" type="button">搜索</button>
|
||||
</td>
|
||||
|
||||
<td width="80%" style="padding-left:10px">
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td align="right" nowrap>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="blank10"></div>
|
||||
<div id="view_{rand}"></div>
|
||||
<div class="tishi">数据库记录管理请谨慎操作!</div>
|
||||
129
webmain/system/table/tableAction.php
Normal file
129
webmain/system/table/tableAction.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
class tableClassAction extends Action
|
||||
{
|
||||
public function initAction()
|
||||
{
|
||||
if($this->getsession('isadmin')!='1')backmsg('别乱来');
|
||||
if(getconfig('systype')=='demo')backmsg('演示的不要改');
|
||||
}
|
||||
|
||||
public function tablebefore($table)
|
||||
{
|
||||
$key = $this->post('key');
|
||||
$where = 'and `TABLE_SCHEMA`=\''.DB_BASE.'\'';
|
||||
if($key!='')$where.=" and (`TABLE_NAME` like '%$key%' or `TABLE_COMMENT` like '%$key%')";
|
||||
return array(
|
||||
'table' => 'information_schema.`TABLES`',
|
||||
'fields'=> '`TABLE_NAME` as id,`ENGINE` as `engine`,`TABLE_ROWS` as `rows`,`TABLE_COMMENT` as `explain`,`CREATE_TIME` as `cjsj`,`UPDATE_TIME` as `gxsj`,`TABLE_COLLATION`',
|
||||
'where' => $where
|
||||
);
|
||||
}
|
||||
|
||||
//保存表备注
|
||||
public function tablesmAjax()
|
||||
{
|
||||
$id = $this->post('id');
|
||||
$value = $this->post('value');
|
||||
$sql = "ALTER TABLE `$id` COMMENT '$value';";
|
||||
$this->db->query($sql);
|
||||
return 'success';
|
||||
}
|
||||
|
||||
public function tablefieldsAjax()
|
||||
{
|
||||
$table = $this->post('table');
|
||||
$rows = $this->db->gettablefields($table);
|
||||
foreach($rows as $k=>$rs)$rows[$k]['id']=$rs['name'];
|
||||
$arr['rows'] = $rows;
|
||||
$this->returnjson($arr);
|
||||
}
|
||||
|
||||
public function savefieldsAjax()
|
||||
{
|
||||
|
||||
$table = $this->post('table');
|
||||
$allfields = $this->db->getallfields($table);
|
||||
$name = strtolower($this->post('name'));
|
||||
if(c('check')->isincn($name))backmsg('字段名不能有中文');
|
||||
$type = $this->post('type');
|
||||
$dev = $this->post('dev');
|
||||
$isnull = $this->post('isnull');
|
||||
if($table=='' || $name=='' || $type=='')backmsg('hehe');
|
||||
|
||||
$lens = $this->post('lens');
|
||||
$sm = $this->post('explain');
|
||||
$sql = "ALTER TABLE `$table`";
|
||||
if(!in_array($name, $allfields)){
|
||||
$sql.=' ADD';
|
||||
}else{
|
||||
$sql.=' MODIFY';
|
||||
}
|
||||
$sql.=" `$name`";
|
||||
$cew = '[varchar][mediumint][int][bigint][smallint][tinyint][decimal]';
|
||||
if(contain($cew,'['.$type.']')){
|
||||
if($lens=='0')$lens='10';
|
||||
$sql.=" $type($lens)";
|
||||
}else{
|
||||
$sql.=" $type";
|
||||
}
|
||||
if($isnull=='NO')$sql.=' NOT NULL';
|
||||
if($dev==''){
|
||||
//$sql.=' DEFAULT NULL';
|
||||
}else{
|
||||
$sql.=" DEFAULT '$dev'";
|
||||
}
|
||||
$sql.=" COMMENT '$sm'";
|
||||
$bo = $this->db->query($sql);
|
||||
$msg = '';
|
||||
if(!$bo)$msg='错误《'.$sql.'》';
|
||||
backmsg($msg);
|
||||
}
|
||||
|
||||
public function delfieldsAjax()
|
||||
{
|
||||
$table = $this->post('table');
|
||||
$id = $this->post('id');
|
||||
$sql = "ALTER table `$table` DROP COLUMN `$id`;";
|
||||
$msg = '';
|
||||
$bo = $this->db->query($sql);
|
||||
if(!$bo)$msg='错误《'.$sql.'》';
|
||||
backmsg($msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function tablerecord_before()
|
||||
{
|
||||
$stable = $this->post('stable','', 1);
|
||||
$key = $this->post('key');
|
||||
$fid = $this->post('fields','id');
|
||||
$this->nowtablename = $stable;
|
||||
$where = '';
|
||||
if(!isempt($key))$where=" and `$fid`='$key'";
|
||||
return array(
|
||||
'table' => $stable,
|
||||
'order' => 'id desc',
|
||||
'where' => $where
|
||||
);
|
||||
}
|
||||
public function tablerecord_after($table, $rows)
|
||||
{
|
||||
$fieldsar = array();
|
||||
if($this->loadci==1){
|
||||
$fieldsarr = $this->db->gettablefields($this->nowtablename);
|
||||
foreach($fieldsarr as $k1=>$rs1){
|
||||
$sortable = in_array($rs1['type'], array('int','date','datetime','tinyint','smallint','decimal'));
|
||||
$text = $rs1['name'];
|
||||
if(!isempt($rs1['explain']))$text.='('.$rs1['explain'].')';
|
||||
$fieldsar[] = array(
|
||||
'text' => $text,
|
||||
'dataIndex' => $rs1['name'],
|
||||
'sortable' => $sortable
|
||||
);
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'fieldsarr' => $fieldsar
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user