|
@@ -0,0 +1,99 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\company\controller;
|
|
|
+
|
|
|
+use app\common\controller\Apic;
|
|
|
+use think\Db;
|
|
|
+/**
|
|
|
+ * 检测下发
|
|
|
+ */
|
|
|
+class Jianceproject extends Apic
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [];
|
|
|
+ protected $noNeedRight = [];
|
|
|
+
|
|
|
+ protected $table = 'jiance_project';
|
|
|
+
|
|
|
+ //检测项目,父+子,一次给出
|
|
|
+ public function index(){
|
|
|
+ $lists = Db::name('jiance_project')->field('id,pid as parentId,title,createtime')
|
|
|
+ ->where('company_id',$this->auth->company_id)
|
|
|
+ ->where('deletetime',NULL)->order('weigh asc')->select();
|
|
|
+
|
|
|
+ $this->success(1,$lists);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function add(){
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'pid' => input('pid',0),
|
|
|
+ 'title' => input('title',''),
|
|
|
+ 'type' => input('type',1),
|
|
|
+ 'info' => input('info',''),
|
|
|
+ 'weigh' => input('weigh',0),
|
|
|
+ 'createtime' => time(),
|
|
|
+ ];
|
|
|
+
|
|
|
+ if($data['pid'] == 0){
|
|
|
+ $data['info'] = '';
|
|
|
+ $data['type'] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = Db::name($this->table)->insertGetId($data);
|
|
|
+
|
|
|
+ if($data['weigh'] == 0){
|
|
|
+ Db::name($this->table)->where('id',$id)->update(['weigh'=>$id]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function info(){
|
|
|
+ $id = input('id',0);
|
|
|
+ $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
|
|
|
+
|
|
|
+ $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)->where('deletetime',NULL)->find();
|
|
|
+ if(empty($info)){
|
|
|
+ $this->error('没找到该信息,请刷新重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ $data = [
|
|
|
+ 'title' => input('title',''),
|
|
|
+ 'type' => input('type',1),
|
|
|
+ 'info' => input('info',''),
|
|
|
+ 'weigh' => input('weigh',$id),
|
|
|
+ ];
|
|
|
+
|
|
|
+ Db::name($this->table)->where('id',$id)->update($data);
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function del(){
|
|
|
+ $ids = input('ids','');
|
|
|
+
|
|
|
+ if (empty($ids)) {
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::name($this->table)->where('id',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
|
|
|
+ Db::name($this->table)->where('pid',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|