Commit 9afc8c42 authored by hujun's avatar hujun

素质测评 方法分析 价值观考核图片

parent 52f14d64
...@@ -107,17 +107,12 @@ class Statement extends Basic ...@@ -107,17 +107,12 @@ class Statement extends Basic
$data['img_url'] = $img_name; $data['img_url'] = $img_name;
$data['type'] = $this->params['type']; $data['type'] = $this->params['type'];
$data['img_name'] = IMAGES_URL.$url; $data['img_name'] = IMAGES_URL.$url;
$result = $agent_report->editData($data); $agent_report->editData($data);
} else { } else {
$result = 0;
}
if (!$result) {
$code = 101; $code = 101;
$msg = '生成图片失败'; $msg = '生成图片失败';
} }
return $this->response($code, $msg, $img_name);
return $this->response($code, $msg, $data['img_name']);
} }
/** /**
......
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\model\RWorkLearningModel;
class uploadWorkLearning extends Basic
{
/**
* 保存0素质测评 1方法分析 2价值观考核图片
*
* @return \think\Response
*/
public function workLearningImage()
{
header('Access-Control-Allow-Origin:*');
if (empty($this->params["agent_id"]) || empty($this->params["img"])) {
return $this->response("101", "参数错误");
}
if (!in_array($this->params['type'], [0,1,2])) {
return $this->response("101", "类型错误");
}
$img_title = "";
$img = "";
//单图
$base64_image_content = $this->params["img"];
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $array)) {
$img_title = $array[2]; //jpeg
$img = base64_decode(str_replace($array[1], '', $base64_image_content)); //返回文件流
}
$tmp_file = time();
$img_name = md5(uniqid($tmp_file)) . '.' . $img_title;//图片名
$url = 'static/week_work_img/' . $img_name;
$code = 200;
$msg = '';
if (file_put_contents($url, $img)) {
$agent_report = new RWorkLearningModel();
$data['agent_id'] = $this->params['agent_id'];
$data['img_url'] = $img_name;
$data['type'] = $this->params['type']; //0素质测评 1方法分析 2价值观考核
$data['img_name'] = IMAGES_URL.$url;
$agent_report->editData($data);
} else {
$code = 101;
$msg = '生成图片失败';
}
return $this->response($code, $msg, $img_name);
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
class RWorkLearningModel extends BaseModel
{
protected $table = 'r_work_learning';
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
}
\ No newline at end of file
...@@ -1046,6 +1046,7 @@ Route::group('broker', [ ...@@ -1046,6 +1046,7 @@ Route::group('broker', [
'addFeeImage' => ['api_broker/StoreFee/addFeeImage', ['method' => 'POST']],//新增报销申请图片 'addFeeImage' => ['api_broker/StoreFee/addFeeImage', ['method' => 'POST']],//新增报销申请图片
'getApplyForFeeStore' => ['api_broker/StoreFee/getApplyForFeeStore', ['method' => 'GET']],//获取门店地址 'getApplyForFeeStore' => ['api_broker/StoreFee/getApplyForFeeStore', ['method' => 'GET']],//获取门店地址
'deviceList' => ['api_broker/Broker/deviceList', ['method' => 'GET']],//设备列表 'deviceList' => ['api_broker/Broker/deviceList', ['method' => 'GET']],//设备列表
'uploadWorkLearning' => ['api_broker/workLearningImage/uploadWorkLearning', ['method' => 'GET']],//保存0素质测评 1方法分析 2价值观考核图片
]); ]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment