|
|
@@ -3,6 +3,8 @@
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
+use think\exception\PDOException;
|
|
|
+use think\exception\ValidateException;
|
|
|
use think\Session;
|
|
|
use think\Db;
|
|
|
|
|
|
@@ -19,11 +21,13 @@ class Order extends Backend
|
|
|
* @var \app\admin\model\Order
|
|
|
*/
|
|
|
protected $model = null;
|
|
|
+ protected $logmodel = null;
|
|
|
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
$this->model = new \app\admin\model\Order;
|
|
|
+ $this->logmodel = new \app\admin\model\OrderLog;
|
|
|
$this->view->assign("statusList", $this->model->getStatusList());
|
|
|
}
|
|
|
|
|
|
@@ -89,7 +93,6 @@ class Order extends Backend
|
|
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
|
|
$params[$this->dataLimitField] = $this->auth->id;
|
|
|
}
|
|
|
-// halt($params);die;
|
|
|
$result = false;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
@@ -100,6 +103,11 @@ class Order extends Backend
|
|
|
$this->model->validateFailException()->validate($validate);
|
|
|
}
|
|
|
$result = $this->model->allowField(true)->save($params);
|
|
|
+ $arr['oid'] = $this->model->getLastInsID();
|
|
|
+ $arr['userid'] = $user_info['id'];
|
|
|
+ $arr['username'] = $user_info['nickname'];
|
|
|
+ $arr['type'] = 1;
|
|
|
+ $this->logmodel->save($arr);
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
|
@@ -110,6 +118,88 @@ class Order extends Backend
|
|
|
}
|
|
|
$this->success();
|
|
|
}
|
|
|
+
|
|
|
+ public function edit($ids = null)
|
|
|
+ {
|
|
|
+ $row = $this->model->get($ids);
|
|
|
+ if (!$row) {
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
+ }
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
+ }
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
+ $this->view->assign('row', $row);
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+ $params = $this->request->post('row/a');
|
|
|
+ if (empty($params)) {
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
+ }
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ //是否采用模型验证
|
|
|
+ if ($this->modelValidate) {
|
|
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
+ $row->validateFailException()->validate($validate);
|
|
|
+ }
|
|
|
+ $arr = [];
|
|
|
+ foreach ($params as $k=>$v){
|
|
|
+ if($v!=$row[$k]) {
|
|
|
+ if ($k == 'no') {
|
|
|
+ $arr['field'] = '编号';
|
|
|
+ } elseif ($k == 'customer') {
|
|
|
+ $arr['field'] = '订货单位';
|
|
|
+ } elseif ($k == 'product') {
|
|
|
+ $arr['field'] = '品名';
|
|
|
+ } elseif ($k == 'specs') {
|
|
|
+ $arr['field'] = '包装规格';
|
|
|
+ } elseif ($k == 'unit') {
|
|
|
+ $arr['field'] = '单位';
|
|
|
+ } elseif ($k == 'number') {
|
|
|
+ $arr['field'] = '数量';
|
|
|
+ } elseif ($k == 'price') {
|
|
|
+ $arr['field'] = '单价';
|
|
|
+ } elseif ($k == 'delivery_date') {
|
|
|
+ $arr['field'] = '交货期';
|
|
|
+ } elseif ($k == 'remark') {
|
|
|
+ $arr['field'] = '备注';
|
|
|
+ } elseif ($k == 'date') {
|
|
|
+ $arr['field'] = '日期';
|
|
|
+ } elseif ($k == 'user_name') {
|
|
|
+ $arr['field'] = '经办';
|
|
|
+ } elseif ($k == 'examine') {
|
|
|
+ $arr['field'] = '审核';
|
|
|
+ } elseif ($k == 'status') {
|
|
|
+ $arr['field'] = '状态';
|
|
|
+ }
|
|
|
+ $user_info = Session::get('admin');
|
|
|
+ $arr['userid'] = $user_info['id'];
|
|
|
+ $arr['username'] = $user_info['nickname'];
|
|
|
+ $arr['oid'] = $row['id'];
|
|
|
+ $arr['type'] = 2;
|
|
|
+ $res[]=$arr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->logmodel->saveAll($res);
|
|
|
+
|
|
|
+ $result = $row->allowField(true)->save($params);
|
|
|
+ Db::commit();
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if (false === $result) {
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//生产作业票
|
|
|
public function task(){
|
|
|
$ids = input('ids');
|