<?php

/* ========================================================================
 * $Id: datas.php 1546 2020-05-15 10:14:30Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# index
$where=$G['this']->where();
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $action=onez()->gp('ac');
    if($action=='del'){
      $id=(int)onez()->gp('id');
      $G['this']->data()->open('datas')->delete("id='$id'$where");
      return $this->ok('删除成功','reload');
    }
    $data=array();
    $data['title']='数据体系';
    $data['btns'][]=array(
      'name'=>'新建数据体系',
      'href'=>'./edit.php',
      'args'=>'width=400&height=330&title=新建数据体系',
    );
    $datatable=$this->load('datatable');
    $datatable->set('edit',array(
      'event'=>array(
        'option'=>array(
          'title'=>'编辑数据体系',
          'width'=>400,
          'height'=>330,
        ),
      ),
    ));
    $datatable->set('del','1');
    $datatable->set('fields','id');
    $datatable->add('名称','name');
    $datatable->add('备注','summary');
    $datatable->output($data,array(
      'table'=>'datas',
      'where'=>"1$where order by id desc",
      'pagesize'=>20,
    ));
    $A['pagedata']=$data;
  }elseif($action=='del'){
    $id=(int)onez()->gp('id');
    $G['this']->data()->open('datas')->delete("id='$id'$where");
    $G['this']->siteUpdate();
    return $this->ok('','reload2');
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));

?>
