hrjy 2 years ago
parent
commit
4e891184c3

+ 8 - 2
app/admin/controller/water/WaterCate.php

@@ -42,7 +42,8 @@ class WaterCate extends AuthController
             ['page', 1],
             ['limit', 20],
             ['name', ''],
-            ['role', '']
+            ['role', ''],
+            ['type', ''],
         ]);
 
         return Json::successlayui(model::list($where));
@@ -69,6 +70,7 @@ class WaterCate extends AuthController
             ['value' => 8, 'label' => '槽钢'],
             ['value' => 9, 'label' => '扶梯管'],
         ])->filterable(true);
+        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
         return $this->fetch('public/form-builder');
@@ -82,6 +84,7 @@ class WaterCate extends AuthController
         $data = Util::postMore([
             'name',
             'type',
+            'is_gc',
         ]);
         $validate = Validate::rule([
             'name' => 'require',
@@ -122,6 +125,7 @@ class WaterCate extends AuthController
             ['value' => 8, 'label' => '槽钢'],
             ['value' => 9, 'label' => '扶梯管'],
         ])->filterable(true);
+        $f[] = Form::radio('is_gc', '公差',  $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
         $this->assign(compact('form'));
@@ -142,7 +146,8 @@ class WaterCate extends AuthController
         $data = Util::postMore([
             'name',
             'type',
-            'id'
+            'id',
+            'is_gc'
         ]);
         $validate = Validate::rule([
             'title' => 'require',
@@ -155,6 +160,7 @@ class WaterCate extends AuthController
         $details = $model->find($data['id']);
         $details['name'] = $data['name'];
         $details['type'] = $data['type'];
+        $details['is_gc'] = $data['is_gc'];
         $res = $details->save();
         if ($res) return Json::successful('修改成功');
         return Json::fail('修改失败');

+ 95 - 11
app/admin/controller/water/WaterMaterialScience.php

@@ -12,13 +12,16 @@ use crmeb\services\{ExpressService,
     JsonService,
     JsonService as Json,
     MiniProgramService,
+    upload\Upload,
     WechatService,
     FormBuilder as Form,
     CacheService,
     UtilService as Util};
+use think\facade\Env;
 use think\facade\Route as Url;
 use think\facade\Validate;
 Use app\admin\model\water\WaterMaterialScience as model;
+use function GuzzleHttp\Psr7\str;
 
 /**
  * 订单管理控制器 同一个订单表放在一个控制器
@@ -128,7 +131,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('company', '单位');
         $f[] = Form::input('long', '长');
         $f[] = Form::input('wide', '宽');
-        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
         return $this->fetch('public/form-builder');
@@ -166,7 +169,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('weight', '重量(kg)');
         $f[] = Form::input('unit_price', '单价');
         $f[] = Form::input('company', '单位');
-        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
         return $this->fetch('public/form-builder');
@@ -197,7 +200,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('company', '单位');
         $f[] = Form::input('long', '长');
         $f[] = Form::input('wide', '宽');
-        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
         return $this->fetch('public/form-builder');
@@ -227,7 +230,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('weight', '重量(kg)');
         $f[] = Form::input('unit_price', '单价');
         $f[] = Form::input('company', '单位');
-        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
         return $this->fetch('public/form-builder');
@@ -245,7 +248,7 @@ class WaterMaterialScience extends AuthController
             'company',
             'long',
             'wide',
-            'is_gc',
+//            'is_gc',
             'cate_id',
         ]);
         $validate = Validate::rule('name', 'require')->rule([
@@ -294,7 +297,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('company', '单位', $data['company']);
         $f[] = Form::input('long', '长', $data['long']);
         $f[] = Form::input('wide', '宽', $data['wide']);
-        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
         $this->assign(compact('form'));
@@ -320,7 +323,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('weight', '重量(kg)', $data['weight']);
         $f[] = Form::input('unit_price', '单价', $data['unit_price']);
         $f[] = Form::input('company', '单位', $data['company']);
-        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
         $this->assign(compact('form'));
@@ -345,7 +348,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('company', '单位', $data['company']);
         $f[] = Form::input('long', '长', $data['long']);
         $f[] = Form::input('wide', '宽', $data['wide']);
-        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
         $this->assign(compact('form'));
@@ -369,7 +372,7 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('weight', '重量(kg)', $data['weight']);
         $f[] = Form::input('unit_price', '单价', $data['unit_price']);
         $f[] = Form::input('company', '单位', $data['company']);
-        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+//        $f[] = Form::radio('is_gc', '公差', $data['is_gc'])->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
         $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
         $this->assign(compact('form'));
@@ -395,7 +398,7 @@ class WaterMaterialScience extends AuthController
             'long',
             'wide',
             'id',
-            'is_gc',
+//            'is_gc',
             'cate_id'
         ]);
         $validate = Validate::rule('name', 'require')->rule([
@@ -419,7 +422,7 @@ class WaterMaterialScience extends AuthController
         $details['weight'] = $data['weight'];
         $details['unit_price'] = $data['unit_price'];
         $details['company'] = $data['company'];
-        $details['is_gc'] = $data['is_gc'];
+//        $details['is_gc'] = $data['is_gc'];
         $details['long'] = $data['long'];
         $details['wide'] = $data['wide'];
         $details['cate_id'] = $data['cate_id'];
@@ -429,6 +432,87 @@ class WaterMaterialScience extends AuthController
     }
 
 
+    public function excel()
+    {
+        $upload = new Upload('local');
+        $res = $upload->to('config/file')->move($this->request->param('file', 'file'));
+
+        $file = app()->getRootPath().'public'.$res->filePath;
+        $PHPExcel = new \PHPExcel();//创建一个excel对象
+        $PHPReader = new \PHPExcel_Reader_Excel2007(); //建立reader对象,excel—2007以后格式
+        if (!$PHPReader->canRead($file)) {
+            $PHPReader = new \PHPExcel_Reader_Excel5();//建立reader对象,excel—2007以前格式
+            if (!$PHPReader->canRead($file)) {
+                $msg = '不是excel格式文件';
+                $this->apiReturn(303,$msg);
+            }
+        }
+
+        $PHPExcel = $PHPReader->load($file); //加载excel对象
+        $sheet = $PHPExcel->getSheet(0); //获取指定的sheet表
+        $rows = $sheet->getHighestRow();//行数
+        $cols = $sheet->getHighestColumn();//列数
+        $data = array();
+        for ($i = 1; $i <= $rows; $i++){ //行数是以第1行开始
+            $count = 0;
+            for ($j = 'A'; $j <= $cols; $j++) { //列数是以A列开始
+                $value = (string)$sheet->getCell($j . $i)->getValue();
+                if ($value) {
+                    $data[$i - 1][$count] = (string)$sheet->getCell($j . $i)->getValue();
+                    if ($sheet->getCell($j . $i)->getOldCalculatedValue()){
+                        if ($j == 'J') $data[$i - 1][7] = $sheet->getCell($j . $i)->getOldCalculatedValue();
+                        if ($j == 'K') $data[$i - 1][8] = $sheet->getCell($j . $i)->getOldCalculatedValue();
+                    }
+                    $count += 1;
+                }
+            }
+        }
+        foreach ($data as $k => $item){
+            if (isset($item[3])){;
+                if (!strstr($item[3], '双') and strstr($item[3], '/') and isset($item[8])){
+                        $array = explode('/', $item['3']);
+                        $name = $item[2].$array[1].'mm';
+                        if (strstr(explode('×',$array[2])[0], 'm')){
+                            $long =  substr(explode('×',$array[2])[0],0,strrpos(explode('×',$array[2])[0],"m"));
+                            $wide =  substr(explode('×',$array[2])[1],0,strrpos(explode('×',$array[2])[1],"m"));
+                        }else{
+                            $long = explode('×',$array[2])[0];
+                            $wide = explode('×',$array[2])[1];
+                        }
+
+                        $cate = \app\admin\model\water\WaterCate::where('name', 'like', '%'.$name.'%')->select()->toArray();
+                        if (count($cate) > 0){
+                            foreach ($cate as $value){
+                                $details = \app\admin\model\water\WaterMaterialScience::where('number', $item['1'])->where('type', $value['type'])->find();
+                                if (!$details){
+                                    \app\admin\model\water\WaterMaterialScience::create([
+                                        'name' => $item[2].$array[1].'mm',
+                                        'number' => $item[1],
+                                        'type' => $value['type'],
+                                        'cate_id' => $value['id'],
+                                        'th_id' => \app\admin\model\water\WaterThickness::where('thickness', $array[1])->value('id'),
+                                        'weight' => $item[6],
+                                        'unit_price' => $item[8],
+                                        'company' => $item[5],
+                                        'long' => $long,
+                                        'wide' => $wide,
+                                    ]);
+                                }else{
+                                    $details['unit_price'] = $item[8];
+                                    $details['long'] = $long;
+                                    $details['wide'] = $wide;
+                                    $details['name'] = $name;
+                                    $details->save();
+                                }
+                            }
+                        }
+                    }
+            }
+        }
+        return Json::successful('导入成功!');
+    }
+
+
     /**
      * 删除
      * @param $id

+ 2 - 2
app/admin/controller/water/WaterThickness.php

@@ -57,7 +57,7 @@ class WaterThickness extends AuthController
     {
         $f = [];
         $f[] = Form::input('name', '名称')->col(12);
-        $f[] = Form::input('weight', '重量');
+        $f[] = Form::input('thickness', '厚度');
         if ($id) $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
@@ -99,7 +99,7 @@ class WaterThickness extends AuthController
         $data = model::find($id);
         $f = [];
         $f[] = Form::input('name', '名称',$data->getData('name'))->col(12);
-        $f[] = Form::input('thickness', '度', $data->getData('thickness'));
+        $f[] = Form::input('thickness', '度', $data->getData('thickness'));
         $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
         $this->assign(compact('form'));

+ 1 - 0
app/admin/model/water/WaterCate.php

@@ -43,6 +43,7 @@ class WaterCate extends BaseModel
         $model = self::field('*')->order('id DESC');
 
         if ($where['name'])$model->where('name' , 'like', '%'.$where['name'],'%');
+        if ($where['type'])$model->where('type' , $where['type']);
         $data['count'] = $model->count();
         if ($where['page'] && $where['limit']){
             $model->page($where['page'], $where['limit']);

+ 8 - 0
app/admin/model/water/WaterMaterialScience.php

@@ -67,6 +67,14 @@ class WaterMaterialScience extends BaseModel
             $model->page(20, 1);
         }
         $list = $model->select()->toArray();
+        if (count($list) > 0){
+            foreach ($list as &$item){
+                $item['long'] = $item['long'].'m';
+                $item['wide'] = $item['wide'].'m';
+                $item['weight'] = $item['weight'].'kg';
+            }
+
+        }
         $data['data'] = $list;
         return $data;
 

+ 24 - 27
app/admin/view/water/water_cate/index.php

@@ -40,6 +40,23 @@
                                     <div class="layui-input-inline">
                                         <input type="text" id="name" name="name" class="layui-input" placeholder="请输入名称">
                                     </div>
+                                    <div class="layui-inline">
+                                        <label class="layui-form-label" style="top: -4.5px">分类</label>
+                                        <div class="layui-input-block">
+                                            <select name="type">
+                                                <option value="">全部</option>
+                                                <option value="1">顶板</option>
+                                                <option value="2">侧板</option>
+                                                <option value="3">拉筋</option>
+                                                <option value="4">底板</option>
+                                                <option value="5">立柱</option>
+                                                <option value="6">辅拉</option>
+                                                <option value="7">保温</option>
+                                                <option value="8">槽钢</option>
+                                                <option value="9">扶梯管</option>
+                                            </select>
+                                        </div>
+                                    </div>
                                 </div>
                                 <div class="layui-inline">
                                     <div class="layui-input-inline">
@@ -74,33 +91,11 @@
                     <table class="layui-hide" id="List" lay-filter="List"></table>
 
 
-                    <script type="text/html" id="image">
-                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
-                    </script>
-                    <script type="text/html" id="status">
-                        {{#  if(d.status == 0){ }}
-                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs" id="">
-                            关闭
-                        </button>
-                        {{#  } else if(d.status == 1) { }}
-                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
-                            开启
-                        </button>
-                        {{#  } }}
-                    </script>
-                    <script type="text/html" id="suc">
-                        {{#  if(d.suc == 0){ }}
-                        <button type="button" name="suc" class="layui-btn layui-btn-xs" id="">
-                            正常
-                        </button>
-                        {{#  } else if(d.suc == 1) { }}
-                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
-                            种植成功
-                        </button>
-                        {{#  } else if(d.suc == 2) { }}
-                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs layui-btn-danger" id="">
-                            种植失败
-                        </button>
+                    <script type="text/html" id="is_gc">
+                        {{#  if(d.is_gc == 0){ }}
+                        正常
+                        {{#  } else if(d.is_gc == 1) { }}
+                        大公差
                         {{#  } }}
                     </script>
                     <script type="text/html" id="act">
@@ -122,12 +117,14 @@
 {/block}
 {block name="script"}
 <script>
+    layList.form.render();
     layList.tableList('List', "{:Url('list')}", function () {
         return [
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
             {field: 'type', title: '分类', templet: '#name',  align: 'center'},
+            {field: 'is_gc', title: '公差', templet: '#is_gc',  align: 'center'},
             {field: 'create_time', title: '时间', align: 'center', width: '8%'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];

+ 1 - 1
app/admin/view/water/water_material_science/channel.php

@@ -119,7 +119,7 @@
             {field: 'company', title: '单位', align: 'center'},
             // {field: 'long', title: '长度', align: 'center'},
             // {field: 'wide', title: '宽度', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 1 - 1
app/admin/view/water/water_material_science/column.php

@@ -129,7 +129,7 @@
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},
             {field: 'company', title: '单位', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 1 - 1
app/admin/view/water/water_material_science/escalator.php

@@ -119,7 +119,7 @@
             {field: 'company', title: '单位', align: 'center'},
             // {field: 'long', title: '长度', align: 'center'},
             // {field: 'wide', title: '宽度', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 1 - 1
app/admin/view/water/water_material_science/floor.php

@@ -127,7 +127,7 @@
             {field: 'company', title: '单位', align: 'center'},
             {field: 'long', title: '长度', align: 'center'},
             {field: 'wide', title: '宽度', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 3 - 1
app/admin/view/water/water_material_science/fula.php

@@ -129,7 +129,9 @@
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},
             {field: 'company', title: '单位', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            {field: 'long', title: '长度', align: 'center'},
+            {field: 'wide', title: '宽度', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 3 - 1
app/admin/view/water/water_material_science/lacing.php

@@ -125,7 +125,9 @@
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},
             {field: 'company', title: '单位', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            {field: 'long', title: '长度', align: 'center'},
+            {field: 'wide', title: '宽度', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 25 - 1
app/admin/view/water/water_material_science/roof.php

@@ -45,8 +45,12 @@
                                     <div class="layui-input-inline">
                                         <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
                                             <i class="layui-icon layui-icon-search"></i>搜索</button>
+                                            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="test1">
+                                                <i class="layui-icon">&#xe67c;</i>导入
+                                            </button>
                                     </div>
                                 </div>
+
                             </div>
                         </form>
                     </div>
@@ -126,7 +130,7 @@
             {field: 'company', title: '单位', align: 'center'},
             {field: 'long', title: '长度', align: 'center'},
             {field: 'wide', title: '宽度', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });
@@ -136,6 +140,26 @@
         layList.reload(where,true);
     });
 
+    layui.use('upload', function(){
+        var upload = layui.upload;
+
+        //执行实例
+        var uploadInst = upload.render({
+            elem: '#test1' //绑定元素
+            ,url: '{:Url('excel')}' //上传接口
+            ,accept:'file'
+            ,done: function(res){
+                $eb.$swal('success','导入成功');
+                //上传完毕回调
+            }
+            ,error: function(){
+                //请求异常回调
+                $eb.$swal('error','导入失败');
+            }
+        });
+    });
+
+
     //点击事件绑定
     layList.tool(function (event,data,obj) {
         switch (event) {

+ 1 - 1
app/admin/view/water/water_material_science/side_plate.php

@@ -128,7 +128,7 @@
             {field: 'company', title: '单位', align: 'center'},
             {field: 'long', title: '长度', align: 'center'},
             {field: 'wide', title: '宽度', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 1 - 1
app/admin/view/water/water_material_science/warm.php

@@ -119,7 +119,7 @@
             {field: 'company', title: '单位', align: 'center'},
             {field: 'long', title: '长度', align: 'center'},
             {field: 'wide', title: '宽度', align: 'center'},
-            {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
+            // {field: 'is_gc', title: '公差',templet: '#is_gc', align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
     });

+ 41 - 33
app/api/controller/water/WaterQueryController.php

@@ -76,8 +76,8 @@ class WaterQueryController
 //            }
 
             if ($user['phone']){
-                $this->NewSmsSend('13905764599', ['code' => $user['phone']], '');
-                $this->NewSmsSend('13905764591', ['code' => $user['phone']], '');
+                $res1 = $this->NewSmsSend('13905764599', ['code' => $user['phone']], '');
+                $res1 = $this->NewSmsSend('13905764591', ['code' => $user['phone']], '');
             }
             Db::commit();
             return app('json')->success($amount);
@@ -144,25 +144,29 @@ class WaterQueryController
             }
         }
         // 底板
-        foreach ($calculation['floor_number'] as $k => $v){
-            if ($k == '1*1'){
-                $details = WaterMaterialScience::where('cate_id', $data['floor'])->where($where)->where([['long', '=', 1], ['wide', '=', 1]])->find();
-
-                $zj += $details['unit_price'] * $v;
-                $zzl += $details['weight'] * $v;
-                $table[] = ['title' => '底板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v ,'type' => 4];
-            }elseif ($k == '1*0.5'){
-                $details = WaterMaterialScience::where('cate_id', $data['floor'])->where($where)->where([['long', '=', 1], ['wide', '=', 0.5]])->find();
-
-                $zj += $details['unit_price'] * $v;
-                $zzl += $details['weight'] * $v;
-                $table[] = ['title' => '底板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v ,'type' => 4];
-            }elseif ($k == '0.5*0.5'){
-                $details = WaterMaterialScience::where('cate_id', $data['floor'])->where($where)->where([['long', '=', 0.5], ['wide', '=', 0.5]])->find();
-
-                $zj += $details['unit_price'] * $v;
-                $zzl += $details['weight'] * $v;
-                $table[] = ['title' => '底板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 4];
+        $science = WaterMaterialScience::where('cate_id', $data['floor'])->order('wide DESC')->select()->toArray();
+        if (count($science) == 1){
+            $floor = $calculation['floor_number'];
+            foreach ($science as $item) {
+                $m2 = $item['long'] * $item['wide'];
+                $floor1 = ceil($floor / $m2);
+                $table[] = ['title' => '底板', 'name' => $item['name'], 'specifications' => $item['long'] . '*' . $item['wide'], 'number' => $floor1, 'unit_price' => $item['unit_price'], 'company' => $item['company'], 'ot_price' => $item['unit_price'] * $floor1, 'weight' => $item['weight'] * $v, 'type' => 4];
+            }
+        }else {
+            $floor = $calculation['floor_number'];
+            foreach ($science as $item) {
+                if ($floor > 0) {
+                    $m2 = $item['long'] * $item['wide'];
+                    if ($floor >= $m2) {
+                        $floor1 = intval($floor / $m2);
+                        $floor = $floor - ($m2 * $floor1);
+                        if ($floor < 0.5 and $floor > 0) {
+                            $floor1 += 1;
+                            $floor = 0;
+                        }
+                        $table[] = ['title' => '底板', 'name' => $item['name'], 'specifications' => $item['long'] . '*' . $item['wide'], 'number' => $floor1, 'unit_price' => $item['unit_price'], 'company' => $item['company'], 'ot_price' => $item['unit_price'] * $floor1, 'weight' => $item['weight'] * $v, 'type' => 4];
+                    }
+                }
             }
         }
         // 侧板
@@ -194,7 +198,7 @@ class WaterQueryController
         $lac_storey = 0;
         foreach ($calculation['lacing_number'] as $v){
             $lac_storey ++;
-            $details = WaterMaterialScience::where('cate_id', $data['lacing'][$lac_storey-1])->where($where)->find();
+            $details = WaterMaterialScience::where('cate_id', $data['lacing'][$lac_storey-1])->where([['long', '=', 4], ['wide', '=', 4]])->where($where)->find();
             $zj += $details['unit_price'] * $v;
             $zzl += $details['weight'] * $v;
             $table[] = ['title' => '主拉B'.$lac_storey.'层' , 'name' => $details['name'], 'specifications' => '1', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 3];
@@ -204,7 +208,7 @@ class WaterQueryController
         $fula_storey = 0;
         foreach ($calculation['fula_number'] as $v){
             $fula_storey ++;
-            $details = WaterMaterialScience::where('cate_id', $data['fula'][$fula_storey-1])->where($where)->find();
+            $details = WaterMaterialScience::where('cate_id', $data['fula'][$fula_storey-1])->where([['long', '=', 4], ['wide', '=', 4]])->where($where)->find();
             $zj += $details['unit_price'] * $v;
             $zzl += $details['weight'] * $v;
             $table[] = ['title' => '辅拉B'.$fula_storey.'层' , 'name' => $details['name'], 'specifications' => '1', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 6];
@@ -251,6 +255,9 @@ class WaterQueryController
             $zzl += $details['weight'] * $calculation['ladder'];
             $table[] = ['title' => '扶梯' , 'name' => $details['name'], 'specifications' => '1', 'number' => $calculation['ladder'], 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $calculation['ladder'], 'weight' => $details['weight'] * $calculation['ladder'] , 'type' => 9];
         }
+        foreach ($table as &$i){
+            $i['ot_price'] = number_format($i['ot_price'], 2);
+        }
 
         return ['table' => $table, 'zj' => $zj, 'zzl' => $zzl];
 
@@ -271,7 +278,7 @@ class WaterQueryController
         $high = (double)$data['high'];
         $high_array = []; // 高度数组
         $roof_number = []; // 顶板数量
-        $floor_number = []; // 底板数量
+        $floor_number = 0; // 底板数量
         $side_number = []; // 侧板数量
         $lacing_number = []; // 拉经数量
         $fula_number = [];//辅拉数量
@@ -284,17 +291,18 @@ class WaterQueryController
         if (intval($high) != $high){
             $high_array = array_merge($high_array, [0.5]);
         }
+        $floor_number = $long * $wide;
         if (ceil($long) == $long && ceil($wide) == $wide && ceil($high) == $high){
             //都为整数
             $roof_number = ['1*1' =>  $long * $wide]; // 顶板数量
-            $floor_number = ['1*1' => $long * $wide];// 底板数量
+//            $floor_number = ['1*1' => $long * $wide];// 底板数量
             foreach ($high_array as $item){
                 $side_number[] = ['1*1' => (($item * $long) + ($item * $wide)) * 2];
             }
         }elseif (ceil($long) != $long && ceil($wide) != $wide && ceil($high) != $high){
             //都不为整数
             $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1]; // 顶板数量
-            $floor_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1];// 底板数量
+//            $floor_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1];// 底板数量
             foreach ($high_array as $item){
                 if ($item >= 1){
                     $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 4];
@@ -306,25 +314,25 @@ class WaterQueryController
             //一个整数
             if (ceil($long) != $long && ceil($wide) == $wide && ceil($high) == $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => $wide]; // 顶板数量
-                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $wide];// 底板数量
+//                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $wide];// 底板数量
                 foreach ($high_array as $item){
                     $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
                 }
             }elseif (ceil($long) == $long && ceil($wide) != $wide and ceil($high) == $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => $long]; // 顶板数量
-                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $long];// 底板数量
+//                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $long];// 底板数量
                 foreach ($high_array as $item){
                     $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
                 }
             }elseif (ceil($long) != $long && ceil($wide) != $wide and ceil($high) == $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1]; // 顶板数量
-                $floor_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1];// 底板数量
+//                $floor_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1];// 底板数量
                 foreach ($high_array as $item){
                     $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 4];
                 }
             } elseif (ceil($long) != $long && ceil($wide) == $wide and ceil($high) != $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => $wide]; // 顶板数量
-                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $wide];// 底板数量
+//                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $wide];// 底板数量
                 foreach ($high_array as $item){
                     if ($item >= 1){
                         $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
@@ -334,7 +342,7 @@ class WaterQueryController
                 }
             }elseif (ceil($long) == $long && ceil($wide) != $wide and ceil($high) != $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => $long]; // 顶板数量
-                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $long];// 底板数量
+//                $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $long];// 底板数量
                 foreach ($high_array as $item){
                     if ($item >= 1){
                         $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
@@ -344,7 +352,7 @@ class WaterQueryController
                 }
             }elseif (ceil($long) == $long && ceil($wide) == $wide and ceil($high) != $high){
                 $roof_number = ['1*1' =>  $long * $wide]; // 顶板数量
-                $floor_number = ['1*1' => $long * $wide];// 底板数量
+//                $floor_number = ['1*1' => $long * $wide];// 底板数量
                 foreach ($high_array as $item){
                     if ($item >= 1){
                         $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2];
@@ -401,7 +409,7 @@ class WaterQueryController
                     }
                 }
             }
-            foreach ($floor_number as $key => $value){
+            foreach ($roof_number as $key => $value){
                 // 顶板
                 if ($key == '1*1'){
                     $warm1 += $value;

+ 4 - 1
app/api/controller/wechat/AuthController.php

@@ -56,16 +56,18 @@ class AuthController
                 return app('json')->fail('获取session_key失败,请检查您的配置!', ['line' => $e->getLine(), 'message' => $e->getMessage()]);
             }
         }
-
         $data = UtilService::postMore([
             ['spread_spid', 0],
             ['spread_code', ''],
             ['iv', ''],
             ['encryptedData', ''],
+            ['iv1', ''],
+            ['encryptedData1', ''],
         ]);//获取前台传的code
         try {
             //解密获取用户信息
             $userInfo = MiniProgramService::encryptor($session_key, $data['iv'], $data['encryptedData']);
+            $userPhone = MiniProgramService::encryptor($session_key, $data['iv1'], $data['encryptedData1']);
         } catch (\Exception $e) {
             if ($e->getCode() == '-41003') return app('json')->fail('获取会话密匙失败');
         }
@@ -76,6 +78,7 @@ class AuthController
         $userInfo['code'] = $data['spread_code'];
         $userInfo['session_key'] = $session_key;
         $userInfo['login_type'] = $login_type;
+        $userInfo['phone'] = $userPhone['phoneNumber'];
         $uid = WechatUser::routineOauth($userInfo);
         $userInfo = User::where('uid', $uid)->find();
         if ($userInfo->login_type == 'h5' && ($h5UserInfo = User::where(['account' => $userInfo->phone, 'phone' => $userInfo->phone, 'user_type' => 'h5'])->find()))

+ 1 - 0
app/models/user/WechatUser.php

@@ -80,6 +80,7 @@ class WechatUser extends BaseModel
     public static function routineOauth($routine)
     {
         $routineInfo['nickname'] = filter_emoji($routine['nickName']);//姓名
+        $routineInfo['phone'] = $routine['phone'];//姓名
         $routineInfo['sex'] = $routine['gender'];//性别
         $routineInfo['language'] = $routine['language'];//语言
         $routineInfo['city'] = $routine['city'];//城市