select([]); } elseif ($value == 2) { $option = Dever::db('crop', 'image')->select([]); } elseif ($value == 3) { $option = Dever::db('water_pic', 'image')->select([]); } elseif ($value == 4) { $option = Dever::db('water_txt', 'image')->select([]); } $result['type_id']['type'] = 'select'; $result['type_id']['option'] = $option; $result['type_id']['value'] = $option[0]['id'] ?? ''; return $result; } # 删除文件 public function upFileStatus() { $rule_id = Dever::input('id'); $id = Dever::input('file_id'); $status = Dever::input('status', 'is_numeric', '状态', 2); $user_id = Dever::load('util', 'upload')->getUser(); return Dever::db('file', 'upload')->update(array('id' => $id, 'user_id' => $user_id), array('status' => $status)); } # 彻底删除文件 public function delFile() { $rule_id = Dever::input('id'); $id = Dever::input('file_id'); $user_id = Dever::load('util', 'upload')->getUser(); $state = Dever::db('file', 'upload')->delete(array('id' => $id, 'status' => 2, 'user_id' => $user_id)); if ($state) { # 同时删除文件 } return 'ok'; } # 添加文件 public function addFile($id, $url, $file, $source, $name, $size) { $data = Dever::load('save', 'upload')->init($id)->addFile($url, $source, $name, $file, $size); return $data; } # 获取文件库文件列表 public function getFileList() { $type = Dever::input('type', 'is_numeric', '类型', 0); $id = Dever::input('id', 'is_numeric', '上传规则错误', 1); $cate_id = Dever::input('cate_id', 'is_numeric', '上传分类', 1); $group_id = Dever::load('util', 'upload')->getGroup(); $user_id = Dever::load('util', 'upload')->getUser(); $file = Dever::input('file'); $data = Dever::input(); $set = array(); $set['num'] = 10; $where['rule_id'] = $id; $where['status'] = 1; #$where['cate_id'] = $cate_id; if ($type == 1) { $where['group_id'] = $group_id; } elseif ($type == 2) { $where['user_id'] = $user_id; } elseif ($type == 4) { $where['status'] = 2; } $result['file'] = Dever::db('file', 'upload')->select($where, $set); if ($result['file']) { foreach ($result['file'] as &$v) { if ($v['source_name']) { $v['name'] = $v['source_name']; } $v['url'] = Dever::load('view', 'upload')->getUrl($v); $v['class'] = ''; $v['del'] = 2; if ($user_id == $v['user_id']) { $v['del'] = 1; } if ($file) { foreach ($file as $v1) { if ($v1 && $v1['url'] == $v['url']) { $v['class'] = 'show-image-active'; } } } } } $result['total'] = Dever::page('total'); return $result; } }