setting('field', $data['head']); $data['search'] = $this->search($where); $data['button'] = $this->button(); $data['body_button'] = $this->button('data_button'); $data['body'] = $this->data($where); $data['total'] = Dever::page('total'); $data['height'] = $this->config['height'] ?? '100%'; $data['filter'] = $this->config['filter'] ?? 'name'; $data['desc'] = $this->config['desc'] ?? ''; return $data; } private function data($where) { $set['num'] = Dever::input('pgnum', '', '', 10); $data = $this->db->select($where, $set); if ($data) { foreach ($data as $k => $v) { foreach ($v as $key => $value) { if (isset($this->config['field'][$key]) && $show = Dever::isset($this->config['field'][$key], 'show')) { $data[$k][$key] = $this->getShow($show, $v); } elseif ($value && isset($this->db->config['struct'][$key]['value']) && $this->db->config['struct'][$key]['value']) { $data[$k][$key] = $this->db->value($key, $value); } elseif ($key == 'cdate') { $data[$k][$key] = date('Y-m-d H:i', $value); } } } } return $data; } private function search(&$where) { $search = Dever::input('search'); $list_search = $result = array(); $this->setting('search', $list_search, false, 'text'); if ($list_search && $search) { foreach ($list_search as $v) { if ($v['type'] != 'hidden') { $result[] = $v; } if ($value = Dever::isset($search, $v['key'])) { if ($v['type'] == 'group') { $where[$v['key']] = array('group', $value); } elseif ($v['type'] == 'selects') { $where[$v['key']] = array('group', $value); } elseif ($v['type'] == 'like') { $where[$v['key']] = array('like', $value); } elseif ($v['type'] == 'in') { $where[$v['key']] = array('in', $value); } else { $where[$v['key']] = $value; } } } } else { $result = $list_search; } return $result; } private function button($key = 'button') { $result = array(); if (empty($this->config[$key])) { if ($key == 'list_button') { $this->config[$key] = array('新增' => 'fastadd', '删除' => 'del'); } else { $this->config[$key] = array('编辑' => 'fastedit', '删除' => 'del'); } } foreach ($this->config[$key] as $k => $v) { $p = ''; $i = ''; if (is_array($v)) { if (isset($v[2])) { $i = $v[2]; } if (isset($v[1])) { $p = $v[1]; } $v = $v[0]; } if (strstr($v, 'add')) { $icon = 'Plus'; $button = 'primary'; } elseif (strstr($v, 'edit')) { $icon = 'Edit'; $button = 'primary'; } elseif (strstr($v, 'view')) { $icon = 'View'; $button = ''; } elseif ($v == 'del') { $icon = 'Delete'; $button = 'danger'; } elseif ($v == 'oper') { $icon = 'Notification'; $button = 'warning'; } elseif ($v == 'link') { $icon = 'Link'; $button = 'success'; } elseif ($v == 'recover') { $icon = 'HelpFilled'; $button = 'info'; } elseif ($v == 'recycler') { $icon = 'HelpFilled'; $button = 'info'; } if ($i) { $icon = $i; } $result[] = array ( 'name' => $k, 'type' => $v, 'param' => $p, 'icon' => $icon, 'button' => $button, ); } return $result; } }