diff --git a/app/common.php b/app/common.php index 8429880a..0484e10f 100644 --- a/app/common.php +++ b/app/common.php @@ -92,26 +92,26 @@ } - // // 整理教师名 - // function teacherNames($list = array()) - // { - // if(count($list) == 0 ) - // { - // return ''; - // } + // 整理教师名 + function teacherNames($list = array()) + { + if(count($list) == 0 ) + { + return ''; + } - // $names = ''; - // foreach ($list as $key => $value) { - // if($key == 0) - // { - // $names = $value['teacher']['xingming']; - // }else{ - // $names = $names . '、'. $value['teacher']['xingming']; - // } - // } + $names = ''; + foreach ($list as $key => $value) { + if($key == 0) + { + $names = $value['teacher']['xingming']; + }else{ + $names = $names . '、'. $value['teacher']['xingming']; + } + } - // return $names; - // } + return $names; + } // 给数组按多条件排序 @@ -123,12 +123,12 @@ } - /** + /* * 根据键值,用数组2的值替换数组1的值 * $cover 覆盖数组,存储新值的数组 * $covered 被覆盖数组,被更改值的数组 * 返回 新arr1 - * */ + */ function array_cover($cover = array(), $covered = array()) { $tools = new \app\tools\controller\Index; diff --git a/app/keti/controller/KetiInfo.php b/app/keti/controller/KetiInfo.php index c110b268..c6f0a202 100644 --- a/app/keti/controller/KetiInfo.php +++ b/app/keti/controller/KetiInfo.php @@ -10,6 +10,9 @@ use app\keti\model\KetiInfo as ktinfo; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +// 引用上传文件 +use app\tools\controller\File; + class KetiInfo extends BaseController { @@ -192,14 +195,17 @@ class KetiInfo extends BaseController // 批量保存图片 public function saveAll($ketice_id) { - // 获取文件信息 - $list['text'] = $this->request->post('text'); - $list['serurl'] = $this->request->post('serurl'); + // 获取表单数据 + $list = request()->only([ + 'text' + ,'serurl' + ], 'post'); // 获取表单上传文件 $file = request()->file('file'); // 上传文件并返回结果 - $data = saveFileInfo($file, $list, false); + $fileObj = new File(); + $data = $fileObj->saveFileInfo($file, $list, false); if($data['val'] != 1) { @@ -427,7 +433,7 @@ class KetiInfo extends BaseController }else{ $data = true; } - + // 根据更新结果设置返回提示信息 $data ? $data = ['msg' => '更新成功', 'val' => 1] diff --git a/app/rongyu/controller/Danwei.php b/app/rongyu/controller/Danwei.php index 18ddef78..f77fcf30 100644 --- a/app/rongyu/controller/Danwei.php +++ b/app/rongyu/controller/Danwei.php @@ -6,6 +6,9 @@ namespace app\rongyu\controller; use app\BaseController; // 引用教师数据模型类 use app\rongyu\model\DwRongyu as DW; +// 引用上传文件 +use app\tools\controller\File; + class Danwei extends BaseController { @@ -155,14 +158,17 @@ class Danwei extends BaseController // 保存批传 public function saveAll() { - // 获取文件信息 - $list['text'] = $this->request->post('text'); - $list['serurl'] = $this->request->post('serurl'); + // 获取表单数据 + $list = request()->only([ + 'text' + ,'serurl' + ], 'post'); // 获取表单上传文件 $file = request()->file('file'); // 上传文件并返回结果 - $data = saveFileInfo($file, $list, false); + $fileObj = new File(); + $data = $fileObj->saveFileInfo($file, $list, false); if($data['val'] != true) { @@ -173,6 +179,7 @@ class Danwei extends BaseController $createInfo = [ 'url' => $data['url'] ,'title' => '批传单位荣誉图片' + ,'project' => '无' ]; // 实例化验证类 @@ -200,15 +207,17 @@ class Danwei extends BaseController */ public function upload() { - - // 获取文件信息 - $list['text'] = $this->request->post('text'); - $list['serurl'] = $this->request->post('serurl'); + // 获取表单数据 + $list = request()->only([ + 'text' + ,'serurl' + ], 'post'); // 获取表单上传文件 $file = request()->file('file'); // 上传文件并返回结果 - $data = saveFileInfo($file, $list, false); + $fileObj = new File(); + $data = $fileObj->saveFileInfo($file, $list, false); return json($data); } diff --git a/app/rongyu/controller/JsRongyuInfo.php b/app/rongyu/controller/JsRongyuInfo.php index 0143f369..29a42744 100644 --- a/app/rongyu/controller/JsRongyuInfo.php +++ b/app/rongyu/controller/JsRongyuInfo.php @@ -11,6 +11,10 @@ use app\rongyu\model\JsRongyuInfo as ryinfo; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +// 引用上传文件 +use app\tools\controller\File; + + class JsRongyuInfo extends BaseController { /** @@ -214,14 +218,17 @@ class JsRongyuInfo extends BaseController // 保存批传 public function saveall($rongyuce_id) { - // 获取文件信息 - $list['text'] = $this->request->post('text'); - $list['serurl'] = $this->request->post('serurl'); + // 获取表单数据 + $list = request()->only([ + 'text' + ,'serurl' + ], 'post'); // 获取表单上传文件 $file = request()->file('file'); // 上传文件并返回结果 - $data = saveFileInfo($file, $list, false); + $fileObj = new File(); + $data = $fileObj->saveFileInfo($file, $list, false); if($data['val'] != 1) { diff --git a/app/rongyu/model/JsRongyuInfo.php b/app/rongyu/model/JsRongyuInfo.php index 259e1867..7ba74461 100644 --- a/app/rongyu/model/JsRongyuInfo.php +++ b/app/rongyu/model/JsRongyuInfo.php @@ -290,24 +290,4 @@ class JsRongyuInfo extends BaseModel } return $value; } - - // // 获奖教师名整理 - // public function getHjJsNameAttr($value) - // { - // $teacherList = $this->getAttr('hjJsry'); - // $teachNames = teacherNames($teacherList); - - // return $teachNames; - - // } - - // // 获奖教师名整理 - // public function getCyJsNameAttr($value) - // { - // $teacherList = $this->getAttr('cyJsry'); - // $teachNames = teacherNames($teacherList); - - // return $teachNames; - - // } } diff --git a/app/rongyu/validate/Upload.php b/app/rongyu/validate/Upload.php new file mode 100644 index 00000000..eb5f8931 --- /dev/null +++ b/app/rongyu/validate/Upload.php @@ -0,0 +1,37 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = [ + 'text' => 'require', + 'serurl' => 'require', + 'isSave' => 'require|boolean' + ]; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = [ + + ]; + + // 验证场景 + protected $scene = [ + 'save' => ['text', 'serurl', 'isSave'], + 'nosave' => ['text', 'serurl'] + ]; +} diff --git a/app/rongyu/view/danwei/create_all.html b/app/rongyu/view/danwei/create_all.html index 2dbd70c8..ec930ec0 100644 --- a/app/rongyu/view/danwei/create_all.html +++ b/app/rongyu/view/danwei/create_all.html @@ -1,10 +1,13 @@ {extend name=".././view/create.html" /} {block name="form"} -
点击上传,或将文件拖拽到此处
+