Selaa lähdekoodia

检测数据确认

huangsanjia 2 vuotta sitten
vanhempi
commit
ea0f353ef1

+ 34 - 4
application/admin/controller/Entrust.php

@@ -51,14 +51,26 @@ class Entrust extends Backend
         $params['name'] = preg_replace('/\s+/','',$params['name']);//去掉所有空格
         $params['user_id'] = Session::get('admin')['id'];
         $params['user_name'] = Session::get('admin')['username'];
-        $params = $this->preExcludeFields($params);
+//        $params = $this->preExcludeFields($params);
+        $is_exit = false;//默认样品编号唯一
         if ($params['is_two'] == 1){//双样
             for ($i=0;$i<2;$i++){
                 $data[$i] = $params;
                 $data[$i]['sample_no'] = $params['sample_no'].'-'.($i+1);
+                $is_exit = Db::name('entrust')->where('sample_no',$data[$i]['sample_no'])->find();
+                if ($is_exit){
+                    $is_exit = true;
+                }
             }
         }else{//单样
-            $data = $params;
+            $data[0] = $params;
+            $is_exit = Db::name('entrust')->where('sample_no',$params['sample_no'])->find();
+            if ($is_exit){
+                $is_exit = true;
+            }
+        }
+        if ($is_exit === true){
+            $this->error('样品编号已存在,请关闭此页面后重新打开!');
         }
         $result = false;
         Db::startTrans();
@@ -155,10 +167,10 @@ class Entrust extends Backend
          * 1、先去找gcms表     没有查到数据    再找gc表
         */
         $data_txt = $entrust['sample_no'].'MS.D'; //如果是GCMS机台,数据文件为委托编号+MS.D
-        $gather_gcms = Db::name('gather_txt_gcms')->where('data_txt_name',$data_txt)->find();
+        $gather_gcms = Db::name('gather_txt_gcms')->where('data_txt_name',$data_txt)->order('id desc')->find();
         if (empty($gather_gcms)){
             $data_txt_gc = $entrust['sample_no'].'.D';
-            $gather_gc = Db::name('gather_txt_gc')->where('data_txt_name',$data_txt_gc)->find();
+            $gather_gc = Db::name('gather_txt_gc')->where('data_txt_name',$data_txt_gc)->order('id desc')->find();
             if (empty($gather_gc)){
                 $this->error('未获取到检测数据');
             }
@@ -327,16 +339,34 @@ class Entrust extends Backend
             $data = Db::name('gather_txt_check_gcms')->where('pid',$gather_id['gather_id'])->select();
             $this->view->assign('gather', $gather);
             $this->view->assign('data', $data);
+            $this->view->assign('id', $params);
             return $this->view->fetch();
         }else if ($gather_id['gather_tab'] == 'gather_txt_check_gc'){
             $gather = Db::name('gather_txt_gc')->where('id',$gather_id['gather_id'])->find();
             $data = Db::name('gather_txt_check_gc')->where('pid',$gather_id['gather_id'])->select();
             $this->view->assign('gather', $gather);
             $this->view->assign('data', $data);
+            $this->view->assign('id', $params);
             return $this->fetch('datagc');
         }
 
     }
+    public function dataSure(){
+        $params = input('id');
+        if (empty($params)){
+            $this->error('参数错误');
+        }
+        $gather_id = Db::name('entrust')->where('id',$params)->find();
+        if (empty($gather_id['gather_id'])){
+            $this->error('此委托单还未提交检测,暂无检测数据');
+        }
+        if ($gather_id['gather_tab'] == 'gather_txt_check_gcms'){
+            Db::name('gather_txt_gcms')->where('id',$gather_id['gather_id'])->setField('status',1);
+        }else{
+            Db::name('gather_txt_gc')->where('id',$gather_id['gather_id'])->setField('status',1);
+        }
+        $this->success('确认成功');
+    }
     //委托单
     public function commissionSheet(){
 

+ 11 - 1
application/admin/view/entrust/data.html

@@ -81,6 +81,7 @@
             <input class="form-control" name="row[remark]" type="text" value="{$gather['response']}">
         </div>
     </div>
+    <input type="hidden" id="id" value="{$id}">
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-3"></label>
         <table class="col-xs-12 col-sm-6 gridtable" id="check_child">
@@ -112,5 +113,14 @@
             </tbody>
         </table>
     </div>
-
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-2">
+            {if condition='$gather.status eq 1'}
+            <button type="button" class="btn  btn-danger disabled">检测结果已确认</button>
+            {else/}
+            <button type="button" class="btn btn-primary btn-embossed submit">检测结果确认</button>
+            {/if}
+        </div>
+    </div>
 </form>

+ 11 - 2
application/admin/view/entrust/datagc.html

@@ -122,7 +122,7 @@
             <input class="form-control" name="row[remark]" type="text" value="{$gather['signal_one']}">
         </div>
     </div>
-
+    <input type="hidden" id="id" value="{$id}">
 
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-3"></label>
@@ -153,5 +153,14 @@
             </tbody>
         </table>
     </div>
-
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            {if condition='$gather.status eq 1'}
+            <button type="button" class="btn btn-danger btn-embossed disabled">检测结果已确认</button>
+            {else/}
+            <button type="button" class="btn btn-primary btn-embossed submit">检测结果确认</button>
+            {/if}
+        </div>
+    </div>
 </form>

+ 23 - 0
public/assets/js/backend/entrust.js

@@ -238,6 +238,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Controller.api.bindevent();
         },
         data:function () {
+            $('.submit').click(function () {
+                console.log(1111)
+                var id = $('#id').val();
+                if (id == 0 || id == ''){
+                    layer.confirm('未获取到参数!');
+                    return false;
+                }
+                Fast.api.ajax({
+                    url:'entrust/dataSure',
+                    data:{id:id}
+                },function (data,ret) {
+                    //成功回调
+                    parent.Toastr.success("确认成功");
+                    Fast.api.close();
+                    parent.Fast.api.refreshmenu();
+                    return false;
+                },function (data,ret) {
+                    parent.Toastr.error("确认失败");
+                    Fast.api.close();
+                    return false;
+                });
+                return false;
+            })
             Controller.api.bindevent();
         },
         commissionSheet:function () {