|
@@ -76,7 +76,7 @@ class Lists extends Backend
|
|
|
public function add()
|
|
public function add()
|
|
|
{
|
|
{
|
|
|
if (false === $this->request->isPost()) {
|
|
if (false === $this->request->isPost()) {
|
|
|
- $this->assignconfig('areaData', []);
|
|
|
|
|
|
|
+
|
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
|
}
|
|
}
|
|
|
$params = $this->request->post('row/a');
|
|
$params = $this->request->post('row/a');
|
|
@@ -96,15 +96,10 @@ class Lists extends Backend
|
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
|
|
$this->model->validateFailException()->validate($validate);
|
|
$this->model->validateFailException()->validate($validate);
|
|
|
}
|
|
}
|
|
|
- if(!empty($params['is_area'])){
|
|
|
|
|
- $areaArr = json_decode($params['product_area'], true);
|
|
|
|
|
- $areaArrTxt = json_decode($params['product_area_txt'], true);
|
|
|
|
|
- if(empty($areaArr) || empty($areaArrTxt)) throw new ValidateException('请添加商品关联区域');
|
|
|
|
|
- }
|
|
|
|
|
- unset($params['product_area'], $params['product_area_txt']);
|
|
|
|
|
|
|
+
|
|
|
//商品
|
|
//商品
|
|
|
$result = $this->model->create($params);
|
|
$result = $this->model->create($params);
|
|
|
- if(!empty($params['is_area'])) $result= self::setEqualArea($result->id, $areaArr, $areaArrTxt, 0);
|
|
|
|
|
|
|
+ //if(!empty($params['is_area'])) $result= self::setEqualArea($result->id, $areaArr, $areaArrTxt, 0);
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
Db::rollback();
|
|
@@ -134,32 +129,6 @@ class Lists extends Backend
|
|
|
$this->error(__('You have no permission'));
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
}
|
|
|
if (false === $this->request->isPost()) {
|
|
if (false === $this->request->isPost()) {
|
|
|
- $area = $this->productArea::where('product_id', $ids)->select();
|
|
|
|
|
- $areaData = array();
|
|
|
|
|
- $areaCode = array();
|
|
|
|
|
- $areaTxt = array();
|
|
|
|
|
- foreach ($area as $key =>$item) {
|
|
|
|
|
- if($item->province > 0){
|
|
|
|
|
- $areaData[$key] = $item->province;
|
|
|
|
|
- $areaCode[$key][0] = $item->province;
|
|
|
|
|
- }
|
|
|
|
|
- if($item->city > 0){
|
|
|
|
|
- $areaData[$key] = $item->city;
|
|
|
|
|
- $areaCode[$key][1] = $item->city;
|
|
|
|
|
- }
|
|
|
|
|
- if($item->area > 0) {
|
|
|
|
|
- $areaData[$key] = $item->area;
|
|
|
|
|
- $areaCode[$key][2] = $item->area;
|
|
|
|
|
- }
|
|
|
|
|
- if($item->county > 0) {
|
|
|
|
|
- $areaData[$key] = $item->county;
|
|
|
|
|
- $areaCode[$key][3] = $item->county;
|
|
|
|
|
- }
|
|
|
|
|
- $areaTxt[] = [$item->address];
|
|
|
|
|
- }
|
|
|
|
|
- $this->assignconfig('areaData', json_encode($areaData));
|
|
|
|
|
- $this->view->assign('areaTxt', json_encode($areaTxt, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
- $this->view->assign('areaCode', json_encode($areaCode));
|
|
|
|
|
$this->view->assign('row', $row);
|
|
$this->view->assign('row', $row);
|
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
|
}
|
|
}
|
|
@@ -177,15 +146,9 @@ class Lists extends Backend
|
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
$row->validateFailException()->validate($validate);
|
|
$row->validateFailException()->validate($validate);
|
|
|
}
|
|
}
|
|
|
- if(!empty($params['is_area'])){
|
|
|
|
|
- $areaArr = json_decode($params['product_area'], true);
|
|
|
|
|
- $areaArrTxt = json_decode($params['product_area_txt'], true);
|
|
|
|
|
- if(empty($areaArr) || empty($areaArrTxt)) throw new ValidateException('请添加商品关联区域');
|
|
|
|
|
- }
|
|
|
|
|
- unset($params['product_area'], $params['product_area_txt']);
|
|
|
|
|
|
|
+
|
|
|
$result=$row->allowField(true)->save($params);
|
|
$result=$row->allowField(true)->save($params);
|
|
|
- //更新地区
|
|
|
|
|
- if(!empty($params['is_area'])) $result= self::setEqualArea($ids, $areaArr, $areaArrTxt, 1);
|
|
|
|
|
|
|
+
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
Db::rollback();
|