|
@@ -0,0 +1,118 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\company\controller;
|
|
|
+
|
|
|
+use app\common\controller\Apic;
|
|
|
+use think\Db;
|
|
|
+use fast\Tree;
|
|
|
+/**
|
|
|
+ * 技术规范
|
|
|
+ */
|
|
|
+class Jishuguifan extends Apic
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [];
|
|
|
+ protected $noNeedRight = [];
|
|
|
+
|
|
|
+ protected $table = 'jishuguifan';
|
|
|
+
|
|
|
+ public function index(){
|
|
|
+ $list = Db::name($this->table)->field('id,pid,name,createtime')->where('company_id',$this->auth->company_id)->select();
|
|
|
+
|
|
|
+ /*$tree = Tree::instance()->init($list);
|
|
|
+ $tree->icon = ['','',''];
|
|
|
+ $tree->nbsp = '';
|
|
|
+ $tree = $tree->getTreeList($tree->getTreeArray(0),'name');
|
|
|
+
|
|
|
+ $this->success(1,$tree);*/
|
|
|
+
|
|
|
+ $this->success($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function add(){
|
|
|
+ $pid = input('pid',0);
|
|
|
+
|
|
|
+ //找到最顶级id
|
|
|
+ $tid = 0;
|
|
|
+ if($pid != 0){
|
|
|
+ $tid = Db::name($this->table)->where('id',$pid)->value('tid');//父级的tid
|
|
|
+ if($tid == 0){ //父级就是顶级时
|
|
|
+ $tid = $pid; //顶级=父级
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'pid' => $pid,
|
|
|
+ 'tid' => $tid,
|
|
|
+ 'name' => input('name',''),
|
|
|
+ 'content' => input('content',''),
|
|
|
+ 'ismenu' => input('ismenu',1),
|
|
|
+ 'file' => input('file',''),
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'updatetime' => time(),
|
|
|
+ ];
|
|
|
+
|
|
|
+ Db::name($this->table)->insertGetId($data);
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function info(){
|
|
|
+ $id = input('id',0);
|
|
|
+ $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
|
|
|
+ $info = info_domain_image($info,['file']);
|
|
|
+
|
|
|
+ $this->success(1,$info);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function edit(){
|
|
|
+ $id = input('id',0);
|
|
|
+ $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
|
|
|
+ if(empty($info)){
|
|
|
+ $this->error('没找到该信息,请刷新重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ $pid = input('pid',0);
|
|
|
+
|
|
|
+ //找到最顶级id
|
|
|
+ $tid = 0;
|
|
|
+ if($pid != 0){
|
|
|
+ $tid = Db::name($this->table)->where('id',$pid)->value('tid');//父级的tid
|
|
|
+ if($tid == 0){ //父级就是顶级时
|
|
|
+ $tid = $pid; //顶级=父级
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'pid' => $pid,
|
|
|
+ 'tid' => $tid,
|
|
|
+ 'name' => input('name',''),
|
|
|
+ 'content' => input('content',''),
|
|
|
+ 'ismenu' => input('ismenu',1),
|
|
|
+ 'file' => input('file',''),
|
|
|
+ 'updatetime' => time(),
|
|
|
+ ];
|
|
|
+
|
|
|
+ Db::name($this->table)->where('id',$id)->update($data);
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function del(){
|
|
|
+ $ids = input('ids','');
|
|
|
+ $ids = explode(',',$ids);
|
|
|
+
|
|
|
+ if (empty($ids)) {
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|