Commit 8237f91297c4327520a547420f6d005039c634f9

Authored by 曹明
1 parent cb9961d8
Exists in master

app-ht(v1.8.6 build 14)

1.所有物理删除改为逻辑删除
2.版本管理添加厂商过滤
app-ht/config/params.php
1 <?php 1 <?php
2 return [ 2 return [
3 - 'VERSION' => 'v1.8.6 build 13', 3 + 'VERSION' => 'v1.8.6 build 14',
4 'MANUFACTURE_ROLE_ID' => 1 4 'MANUFACTURE_ROLE_ID' => 1
5 ]; 5 ];
6 \ No newline at end of file 6 \ No newline at end of file
app-ht/modules/upgrade/controllers/UpgradeController.php
@@ -69,6 +69,10 @@ class UpgradeController extends BaseController @@ -69,6 +69,10 @@ class UpgradeController extends BaseController
69 if ($dataType) { 69 if ($dataType) {
70 $where[] = ['=', 'u.type', $dataType]; 70 $where[] = ['=', 'u.type', $dataType];
71 } 71 }
  72 + $user = Yii::$app->user->identity;
  73 + if (isset($user->is_manufacture) && $user->is_manufacture == 1) {
  74 + $where[] = ['like', 'mf.sys_user_id', $user->id];
  75 + }
72 if ($type == 0) { 76 if ($type == 0) {
73 $pageList = UpgradeRepository::getPageList($where, 0 , 0); 77 $pageList = UpgradeRepository::getPageList($where, 0 , 0);
74 $pages = null; 78 $pages = null;
@@ -95,6 +99,15 @@ class UpgradeController extends BaseController @@ -95,6 +99,15 @@ class UpgradeController extends BaseController
95 public function actionCreate() 99 public function actionCreate()
96 { 100 {
97 $gets = $this->request->get(); 101 $gets = $this->request->get();
  102 + $user = Yii::$app->user->identity;
  103 + if (isset($user->is_manufacture) && $user->is_manufacture == 1) {
  104 + $gets["is_manufacture"] = 1;
  105 + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]);
  106 + if ($manufacturer) {
  107 + $gets["manufacture_name"] = $manufacturer->name;
  108 + $gets["manufacture_id"] = $manufacturer->id;
  109 + }
  110 + }
98 return $this->render('create', ['gets' => $gets]); 111 return $this->render('create', ['gets' => $gets]);
99 } 112 }
100 113
@@ -110,6 +123,14 @@ class UpgradeController extends BaseController @@ -110,6 +123,14 @@ class UpgradeController extends BaseController
110 Yii::$app->session->setFlash('error', '版本不能为空'); 123 Yii::$app->session->setFlash('error', '版本不能为空');
111 return $this->render('create'); 124 return $this->render('create');
112 } 125 }
  126 + $user = Yii::$app->user->identity;
  127 + if (isset($user->is_manufacture) && $user->is_manufacture == 1) {
  128 + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]);
  129 + if (empty($manufacturer) || $manufacturer->id != $request->post("manufacturer_id")) {
  130 + Yii::$app->session->setFlash('error', '添加失败');
  131 + return $this->render('create');
  132 + }
  133 + }
113 $result = Upgrade::create($request->post()); 134 $result = Upgrade::create($request->post());
114 if ($result === -1) { 135 if ($result === -1) {
115 Yii::$app->session->setFlash('error', '添加失败,版本' . $version . '已存在'); 136 Yii::$app->session->setFlash('error', '添加失败,版本' . $version . '已存在');
@@ -157,6 +178,15 @@ class UpgradeController extends BaseController @@ -157,6 +178,15 @@ class UpgradeController extends BaseController
157 $params = $this->dataList(1); 178 $params = $this->dataList(1);
158 return $this->render('index', $params); 179 return $this->render('index', $params);
159 } 180 }
  181 + $user = Yii::$app->user->identity;
  182 + if (isset($user->is_manufacture) && $user->is_manufacture == 1) {
  183 + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]);
  184 + if (empty($manufacturer) || $manufacturer->id != $request->post("manufacturer_id")) {
  185 + Yii::$app->session->setFlash('error', '编辑失败');
  186 + $params = $this->dataList(1);
  187 + return $this->render('index', $params);
  188 + }
  189 + }
160 $upgrade = UpgradeRepository::selectOne($uid,true); 190 $upgrade = UpgradeRepository::selectOne($uid,true);
161 if (isset($upgrade["path"])) { 191 if (isset($upgrade["path"])) {
162 $upgrade["oldName"] = $upgrade["path"]; 192 $upgrade["oldName"] = $upgrade["path"];
@@ -207,6 +237,16 @@ class UpgradeController extends BaseController @@ -207,6 +237,16 @@ class UpgradeController extends BaseController
207 $request = Yii::$app->request; 237 $request = Yii::$app->request;
208 $itemId = $request->post("data_id"); 238 $itemId = $request->post("data_id");
209 $msg = array(); 239 $msg = array();
  240 + $user = Yii::$app->user->identity;
  241 + if (isset($user->is_manufacture) && $user->is_manufacture == 1) {
  242 + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]);
  243 + $upgrade = UpgradeRepository::selectOne($itemId,true);
  244 + if (empty($upgrade) || empty($manufacturer) || $manufacturer->id != $request->post("manufacturer_id")) {
  245 + $msg['status'] = 0;
  246 + $msg['msg'] = "删除";
  247 + return $this->renderJson($msg);
  248 + }
  249 + }
210 250
211 // 删除对应的版本 251 // 删除对应的版本
212 if (Upgrade::delete($itemId)) { 252 if (Upgrade::delete($itemId)) {
app-ht/modules/upgrade/views/upgrade/create.php
@@ -50,7 +50,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -50,7 +50,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
50 <label for="skillName" class="col-sm-4 control-label text-right"><span style="color: #ff0000;">*</span>请选择厂商名称:</label> 50 <label for="skillName" class="col-sm-4 control-label text-right"><span style="color: #ff0000;">*</span>请选择厂商名称:</label>
51 <div class="col-sm-4 text-left"> 51 <div class="col-sm-4 text-left">
52 <input type="hidden" id="manufacture_id" name="manufacture_id" value="<?= (isset($gets["manufacture_id"]) ? $gets["manufacture_id"] : "") ?>"/> 52 <input type="hidden" id="manufacture_id" name="manufacture_id" value="<?= (isset($gets["manufacture_id"]) ? $gets["manufacture_id"] : "") ?>"/>
53 - <div class="form-control text-center" id="select_manufacture"><span id="manufactureName"><?= (isset($gets["manufacture_name"]) && !empty($gets["manufacture_name"]) ? $gets["manufacture_name"] : "请选择厂商名称") ?></span> <span style="float: right;padding-right: 13px"> > </span></div> 53 + <?php if (isset($gets["is_manufacture"]) && $gets["is_manufacture"] == 1) { ?>
  54 + <div class="form-control text-center"><span id="manufactureName"><?= (isset($gets["manufacture_name"]) && !empty($gets["manufacture_name"]) ? $gets["manufacture_name"] : "请选择厂商名称") ?></span> <span style="float: right;padding-right: 13px"> > </span></div>
  55 + <?php } else { ?>
  56 + <div class="form-control text-center" id="select_manufacture"><span id="manufactureName"><?= (isset($gets["manufacture_name"]) && !empty($gets["manufacture_name"]) ? $gets["manufacture_name"] : "请选择厂商名称") ?></span> <span style="float: right;padding-right: 13px"> > </span></div>
  57 + <?php } ?>
54 </div> 58 </div>
55 </div> 59 </div>
56 <div class="form-group col-sm-12"> 60 <div class="form-group col-sm-12">
@@ -122,7 +126,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -122,7 +126,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
122 l.start(); 126 l.start();
123 return false; 127 return false;
124 }); 128 });
125 - 129 + <?php if (!isset($gets["is_manufacture"]) || $gets["is_manufacture"] != 1) { ?>
126 $("#select_manufacture").bind("click", function () { 130 $("#select_manufacture").bind("click", function () {
127 var getUrl = '<?=Url::toRoute("/upgrade/upgrade/select-manufacture")?>'; 131 var getUrl = '<?=Url::toRoute("/upgrade/upgrade/select-manufacture")?>';
128 var version = $("input[name='version']").val(); 132 var version = $("input[name='version']").val();
@@ -142,7 +146,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -142,7 +146,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
142 getUrl = getUrl + "&isCreate=" + 1; 146 getUrl = getUrl + "&isCreate=" + 1;
143 window.location.href = getUrl; 147 window.location.href = getUrl;
144 }); 148 });
145 - 149 + <?php } ?>
146 //上传文件函数 150 //上传文件函数
147 //ids唯一ID 151 //ids唯一ID
148 //folder文件保存目录 152 //folder文件保存目录
domain/manufacturer/Manufacturer.php
@@ -124,11 +124,11 @@ class Manufacturer @@ -124,11 +124,11 @@ class Manufacturer
124 return false; 124 return false;
125 } 125 }
126 if (isset($manufacturerModel->sys_user_id)) { 126 if (isset($manufacturerModel->sys_user_id)) {
127 - SysUserModel::deleteAll(["id" => $manufacturerModel->sys_user_id]); // 删除登录用户  
128 - SysUserProfileModel::deleteAll(["sys_user_id" => $manufacturerModel->sys_user_id]); // 删除登录用户 127 + SysUserModel::updateAll(["is_enable" => 0], ["id" => $manufacturerModel->sys_user_id]); // 删除登录用户
  128 + //SysUserProfileModel::deleteAll(["sys_user_id" => $manufacturerModel->sys_user_id]); // 删除登录用户
129 } 129 }
130 130
131 - return ManufacturerModel::deleteAll(["id" => $id]); 131 + return ManufacturerModel::updateAll(["is_delete" => 1], ["id" => $id]);
132 } 132 }
133 133
134 /** 134 /**
domain/manufacturer/ManufacturerRepository.php
@@ -39,7 +39,7 @@ class ManufacturerRepository @@ -39,7 +39,7 @@ class ManufacturerRepository
39 if ($limit) { 39 if ($limit) {
40 $manufacturerFind->limit($limit); 40 $manufacturerFind->limit($limit);
41 } 41 }
42 - 42 + $manufacturerFind->andWhere(["is_delete" => 0]);
43 $manufacturerFind->orderBy("m.id desc"); 43 $manufacturerFind->orderBy("m.id desc");
44 $manufacturerFind->asArray(); 44 $manufacturerFind->asArray();
45 $dataList = $manufacturerFind->all(); 45 $dataList = $manufacturerFind->all();
@@ -61,6 +61,7 @@ class ManufacturerRepository @@ -61,6 +61,7 @@ class ManufacturerRepository
61 if (!empty($map)) { 61 if (!empty($map)) {
62 $manufacturerFind->where($map); 62 $manufacturerFind->where($map);
63 } 63 }
  64 + $manufacturerFind->andWhere(["is_delete" => 0]);
64 $pageCount = $manufacturerFind->count(); 65 $pageCount = $manufacturerFind->count();
65 66
66 return $pageCount; 67 return $pageCount;
domain/model/Model.php
@@ -73,7 +73,7 @@ class Model @@ -73,7 +73,7 @@ class Model
73 return false; 73 return false;
74 } 74 }
75 75
76 - return ModelModel::deleteAll(["id" => $id]); 76 + return ModelModel::updateAll(["is_delete" => 1], ["id" => $id]);
77 } 77 }
78 78
79 /** 79 /**
domain/model/ModelRepository.php
@@ -35,7 +35,7 @@ class ModelRepository @@ -35,7 +35,7 @@ class ModelRepository
35 if ($limit) { 35 if ($limit) {
36 $modelFind->limit($limit); 36 $modelFind->limit($limit);
37 } 37 }
38 - 38 + $modelFind->andWhere(["is_delete" => 0]);
39 $modelFind->orderBy("m.id desc"); 39 $modelFind->orderBy("m.id desc");
40 $modelFind->asArray(); 40 $modelFind->asArray();
41 $dataList = $modelFind->all(); 41 $dataList = $modelFind->all();
@@ -53,6 +53,7 @@ class ModelRepository @@ -53,6 +53,7 @@ class ModelRepository
53 if (!empty($map)) { 53 if (!empty($map)) {
54 $modelFind->where($map); 54 $modelFind->where($map);
55 } 55 }
  56 + $modelFind->andWhere(["is_delete" => 0]);
56 $pageCount = $modelFind->count(); 57 $pageCount = $modelFind->count();
57 58
58 return $pageCount; 59 return $pageCount;
domain/production/Production.php
@@ -73,7 +73,7 @@ class Production @@ -73,7 +73,7 @@ class Production
73 return false; 73 return false;
74 } 74 }
75 75
76 - return ProductionModel::deleteAll(["id" => $id]); 76 + return ProductionModel::updateAll(["is_delete" => 1], ["id" => $id]);
77 } 77 }
78 78
79 /** 79 /**
domain/production/ProductionRepository.php
@@ -35,7 +35,7 @@ class ProductionRepository @@ -35,7 +35,7 @@ class ProductionRepository
35 if ($limit) { 35 if ($limit) {
36 $productionFind->limit($limit); 36 $productionFind->limit($limit);
37 } 37 }
38 - 38 + $productionFind->andWhere(["is_delete" => 0]);
39 $productionFind->orderBy("p.id desc"); 39 $productionFind->orderBy("p.id desc");
40 $productionFind->asArray(); 40 $productionFind->asArray();
41 $dataList = $productionFind->all(); 41 $dataList = $productionFind->all();
@@ -53,6 +53,7 @@ class ProductionRepository @@ -53,6 +53,7 @@ class ProductionRepository
53 if (!empty($map)) { 53 if (!empty($map)) {
54 $productionFind->where($map); 54 $productionFind->where($map);
55 } 55 }
  56 + $productionFind->andWhere(["is_delete" => 0]);
56 $pageCount = $productionFind->count(); 57 $pageCount = $productionFind->count();
57 58
58 return $pageCount; 59 return $pageCount;
domain/project/Project.php
@@ -73,7 +73,7 @@ class Project @@ -73,7 +73,7 @@ class Project
73 return false; 73 return false;
74 } 74 }
75 75
76 - return ProjectModel::deleteAll(["id" => $id]); 76 + return ProjectModel::updateAll(["is_delete" => 1], ["id" => $id]);
77 } 77 }
78 78
79 /** 79 /**
domain/project/ProjectRepository.php
@@ -35,7 +35,7 @@ class ProjectRepository @@ -35,7 +35,7 @@ class ProjectRepository
35 if ($limit) { 35 if ($limit) {
36 $modelFind->limit($limit); 36 $modelFind->limit($limit);
37 } 37 }
38 - 38 + $modelFind->andWhere(["is_delete" => 0]);
39 $modelFind->orderBy("p.id desc"); 39 $modelFind->orderBy("p.id desc");
40 $modelFind->asArray(); 40 $modelFind->asArray();
41 $dataList = $modelFind->all(); 41 $dataList = $modelFind->all();
@@ -53,6 +53,7 @@ class ProjectRepository @@ -53,6 +53,7 @@ class ProjectRepository
53 if (!empty($map)) { 53 if (!empty($map)) {
54 $modelFind->where($map); 54 $modelFind->where($map);
55 } 55 }
  56 + $modelFind->andWhere(["is_delete" => 0]);
56 $pageCount = $modelFind->count(); 57 $pageCount = $modelFind->count();
57 58
58 return $pageCount; 59 return $pageCount;