|
@@ -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
|