diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index 723b8cf1..61ca823c 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -1317,14 +1317,19 @@ class Common extends CI_Controller $tp == 0 && $lists[] = array('id' => 0, 'name' => $name ? $name : '选择车型'); $res = $this->mdAutoAttr->select(array('type' => 1, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name'); } - foreach ($res as $key => $value) { - $lists[] = array('id' => $value['id'], 'name' => $value['name']); + if ($tp == 1 && $type == 3) { + $lists[3] = $res;//车型 + $lists[4] = $this->mdAutoAttr->select(array('type' => 0, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//车身颜色 + $lists[5] = $this->mdAutoAttr->select(array('type' => 2, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//内饰颜色 + } else { + foreach ($res as $key => $value) { + $lists[] = array('id' => $value['id'], 'name' => $value['name']); + } } $this->data = $lists; - $hasNext = ceil($count / $size) > $page ? 1 : 0; - $this->data['page'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext); return $this->show_json(SYS_CODE_SUCCESS); } + /** * Notes:获取商品列表 */ @@ -1345,21 +1350,21 @@ class Common extends CI_Controller $count = $this->items_model->count($where); if ($count) { - $rows = $this->items_model->select($where, "id desc", $page, $size,'id,brand_id,s_id,v_id,cor_id,incor_id,vin'); + $rows = $this->items_model->select($where, "id desc", $page, $size, 'id,brand_id,s_id,v_id,cor_id,incor_id,vin'); //品牌车型 - $brand_arr = array_unique(array_column($rows,'brand_id')); - $brands = $this->auto_brand_model->get_map_by_ids($brand_arr,'id,name'); + $brand_arr = array_unique(array_column($rows, 'brand_id')); + $brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name'); //车系车型 - $series_arr = array_unique(array_column($rows,'s_id')); - $series = $this->auto_series_model->get_map_by_ids($series_arr,'id,name'); + $series_arr = array_unique(array_column($rows, 's_id')); + $series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name'); //获取属性 - $v_arr = array_unique(array_column($rows,'v_id')); - $cor_arr = array_unique(array_column($rows,'cor_id')); - $incor_arr = array_unique(array_column($rows,'incor_id')); - $attr_arr = array_merge($v_arr,$cor_arr,$incor_arr); - $attr = $this->auto_attr_model->get_map_by_ids($attr_arr,'id,title'); - foreach($rows as $key=>$val){ + $v_arr = array_unique(array_column($rows, 'v_id')); + $cor_arr = array_unique(array_column($rows, 'cor_id')); + $incor_arr = array_unique(array_column($rows, 'incor_id')); + $attr_arr = array_merge($v_arr, $cor_arr, $incor_arr); + $attr = $this->auto_attr_model->get_map_by_ids($attr_arr, 'id,title'); + foreach ($rows as $key => $val) { $setval = [ 'id' => $val['id'], 'vin' => $val['vin'] diff --git a/admin/controllers/items/goods/Goods.php b/admin/controllers/items/goods/Goods.php index b0c72008..0d96473a 100644 --- a/admin/controllers/items/goods/Goods.php +++ b/admin/controllers/items/goods/Goods.php @@ -88,13 +88,19 @@ class Goods extends HD_Controller { $autoList = array(); $id = intval($this->input->get('id')); - $info['brand_id'] = $info['s_id'] = $info['v_id'] = 0; + $info['brand_id'] = $info['s_id'] = $info['v_id'] = $info['cor_id'] = $info['incor_id'] = $info['if_pack'] = 0; + $info['status'] = 1; + $autoList[2] = $autoList[3] = $autoList[4] = $autoList[5] = array(); if ($id > 0) { $re = $this->mdItems->get(array('id' => $id)); if (!$re || empty($re)) { return $this->show_json(SYS_CODE_FAIL, '商品不存在!'); } $info = $re; + $info['pro_time'] = $re['pro_time'] != '0000-00-00 00:00:00' ? $re['pro_time'] : ''; + $info['p_time'] = $re['p_time'] != '0000-00-00 00:00:00' ? $re['p_time'] : ''; + $info['out_time'] = $re['out_time'] != '0000-00-00 00:00:00' ? $re['out_time'] : ''; + $info['bill_time'] = $re['bill_time'] != '0000-00-00 00:00:00' ? $re['bill_time'] : ''; if ($re['brand_id']) { $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $re['brand_id']), 'id desc', 0, 0, 'id,name'); } @@ -175,6 +181,42 @@ class Goods extends HD_Controller //添加单条数据 public function add() { + $info = $this->input->post('info'); + $checkInfo = $this->checkInfo($info); + if (!$checkInfo['code']) { + return $this->show_json($checkInfo['code'], $checkInfo['msg']); + } + $addData['brand_id'] = $info['brand_id']; + $addData['s_id'] = $info['s_id']; + $addData['v_id'] = $info['v_id']; + $addData['cor_id'] = $info['cor_id']; + $addData['incor_id'] = $info['incor_id']; + $addData['if_pack'] = $info['if_pack']; + $addData['status'] = $info['status']; + + $addData['address'] = $info['address']; + $addData['vin'] = $info['vin']; + $addData['stdard_num'] = $info['stdard_num']; + $addData['engine_num'] = $info['engine_num']; + $addData['frame_num'] = $info['frame_num']; + $addData['ori_price'] = $info['ori_price']; + $addData['discount'] = $info['discount']; + $addData['dis_price'] = $info['dis_price']; + $addData['bill_num'] = $info['bill_num']; + $addData['bill_price'] = $info['bill_price']; + $addData['buy_price'] = $info['buy_price']; + + $addData['pro_time'] = $info['pro_time']; + $addData['p_time'] = $info['p_time']; + $addData['out_time'] = $info['out_time']; + $addData['bill_time'] = $info['bill_time']; + $addData['c_time'] = time(); + $id = $this->mdItems->add($addData); + if (!$id) { + return $this->show_json(SYS_CODE_FAIL, '添加失败!'); + } + $this->data['status'] = 1; + return $this->show_json(SYS_CODE_SUCCESS, '添加成功!'); } //编辑单条数据 @@ -209,7 +251,10 @@ class Goods extends HD_Controller $editData['p_time'] = $info['p_time']; $editData['out_time'] = $info['out_time']; $editData['bill_time'] = $info['bill_time']; - $this->mdItems->update($editData, array('id' => $info['id'])); + $ret = $this->mdItems->update($editData, array('id' => $info['id'])); + if (!$ret) { + return $this->show_json(SYS_CODE_FAIL, '修改失败!'); + } $this->data['status'] = 2; return $this->show_json(SYS_CODE_SUCCESS, '修改成功!'); } diff --git a/admin/views/items/goods/edit.php b/admin/views/items/goods/edit.php index b215c939..285b7f52 100644 --- a/admin/views/items/goods/edit.php +++ b/admin/views/items/goods/edit.php @@ -288,9 +288,9 @@ vm.info.v_id = 0; vm.info.cor_id = 0; vm.info.incor_id = 0; - vm.showInfo['autoList'][3] = data.data; - vm.showInfo['autoList'][4] = []; - vm.showInfo['autoList'][5] = []; + vm.showInfo['autoList'][3] = data.data[3]; + vm.showInfo['autoList'][4] = data.data[4]; + vm.showInfo['autoList'][5] = data.data[5]; } } }, diff --git a/admin/views/items/goods/lists.php b/admin/views/items/goods/lists.php index 0c19b995..d071a56e 100644 --- a/admin/views/items/goods/lists.php +++ b/admin/views/items/goods/lists.php @@ -11,7 +11,7 @@ - @@ -26,7 +26,7 @@ - @@ -39,7 +39,7 @@ -