goods_logs_1111

This commit is contained in:
dengbw
2021-11-11 10:54:44 +08:00
parent 2489cf390a
commit 5f83d9a92a
3 changed files with 115 additions and 17 deletions
+58 -14
View File
@@ -9,6 +9,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class Logs extends HD_Controller
{
private $statusAry = array(1 => '未分配', 2 => '已分配', 0 => '下架');
private $soldAry = array(1 => '未出售', 2 => '已出售');
public function __construct()
{
@@ -32,10 +33,16 @@ class Logs extends HD_Controller
public function lists()
{
$params = $this->input->get();
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$this->data = $this->dataSelect($params);
return $this->show_view('/items/logs/lists', true);
}
private function dataSelect($params)
{
$lists = $autoList = array();
$where = array('id<>1' => null, 'status>' => 0);
$autoList = array();
if ($params['brand_id']) {
$where['brand_id'] = $params['brand_id'];
$autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name');
@@ -84,14 +91,21 @@ class Logs extends HD_Controller
if ($params['vin']) {
$where["vin like '%{$params['vin']}%'"] = null;
}
if ($params['sold'] == 1) {
$where["bill_time"] = '0000-00-00 00:00:00';
} else if ($params['sold'] == 2) {
$where["bill_time<>"] = '0000-00-00 00:00:00';
} else {
$params['sold'] = '';
}
$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name');
$statusAry = $this->statusAry;
$soldAry = $this->soldAry;
$count = $this->mdItems->count($where);
$lists = array();
if ($count) {
$fileds = 'id,brand_id,s_id,vin,v_id,cor_id,incor_id,in_time,bill_time,biz_id,addr_id,status';
$orderby = "id desc";
$rows = $this->mdItems->select($where, $orderby, $page, $size, $fileds);
$rows = $this->mdItems->select($where, $orderby, $params['page'], $params['size'], $fileds);
$brand_ids = $s_ids = $attr_vids = $attr_corids = $biz_ids = $addr_ids = array();
$ids = array();
foreach ($rows as $v) {
@@ -195,20 +209,21 @@ class Logs extends HD_Controller
'address' => $address,
'in_time' => '0000-00-00 00:00:00' != $v['in_time'] ? date('Y-m-d', strtotime($v['in_time'])) : '',
'status_name' => $statusAry[$v['status']],
'bill_time' => '0000-00-00 00:00:00' != $v['bill_time'] ? '已出售' : '未出售',
'bill_time' => '0000-00-00 00:00:00' != $v['bill_time'] ? $soldAry[2] : $soldAry[1],
'last_db_time' => $last_db_time,
'inventory_time' => $inventory_time,
);
}
}
unset($statusAry[0]);
$this->data['lists'] = $lists;
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$this->data['params'] = $params;
$this->data['autoList'] = $autoList;
$this->data['statusAry'] = $statusAry;
$this->data['_title'] = '门店调拨记录';
return $this->show_view('/items/logs/lists', true);
$data['lists'] = $lists;
$data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
$data['params'] = $params;
$data['autoList'] = $autoList;
$data['statusAry'] = $statusAry;
$data['soldAry'] = $soldAry;
$data['_title'] = '门店调拨记录';
return $data;
}
public function get()
@@ -395,6 +410,35 @@ class Logs extends HD_Controller
public function export()
{
$params = $this->input->get();
$params['page'] = 1;
$params['size'] = 10000;
$data = $indexs = array();
$res = $this->dataSelect($params);
$fileName = '门店调拨记录';
foreach ($res['lists'] as $key => $value) {
$temp['address'] = $value['address'];
$temp['title'] = $value['title'];
$temp['vin'] = $value['vin'];
$temp['in_time'] = $value['in_time'];
$temp['last_db_time'] = $value['last_db_time'];
$temp['inventory_time'] = $value['inventory_time'];
$temp['bill_time'] = $value['bill_time'];
$temp['status_name'] = $value['status_name'];
$data[] = $temp;
}
$indexs = [
'address' => '门店',
'title' => '车辆',
'vin' => '车架号',
'in_time' => '入库日期',
'last_db_time' => '最后调拨时间',
"inventory_time" => "库存时间",
"bill_time" => "是否出售",
"status_name" => "状态",
];
array_unshift($data, $indexs);
$this->load->library('excel');
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
}
}
+14 -3
View File
@@ -55,7 +55,16 @@
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">状态</label>
<label class="am-para-label w100">是否出售</label>
<div class="am-para-inline w120">
<select title="出售" name="sold" v-model="params.sold">
<option value="">请选择</option>
<option :value="i" v-for="(v,i) in soldAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w80">状态:</label>
<div class="am-para-inline w120">
<select title="状态" name="status" v-model="params.status">
<option value="">选择状态</option>
@@ -111,7 +120,7 @@
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
</div>
<div class="am-form-group fl ml10">
<!-- <button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>-->
<button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>
</div>
</div>
</div>
@@ -168,6 +177,7 @@
data: {
params: [],
statusAry: [],//状态
soldAry: [],//出售
cityAry: [],//城市
countyAry: [],//行政区
bizAry: [],//门店
@@ -180,6 +190,7 @@
vm.lists = <?=json_encode($lists)?>;
vm.params = <?=json_encode($params)?>;
vm.statusAry = <?=json_encode($statusAry)?>;
vm.soldAry = <?=json_encode($soldAry)?>;
vm.init_citys();
vm.set_sery();
},
@@ -358,7 +369,7 @@
}
var href = $.menu.parseUri(window.location.href);
var arr = href.split('?');
href = '/items/goods/goods/export?' + arr[1];
href = '/items/goods/logs/export?' + arr[1];
window.location.href = href;
});
+43
View File
@@ -218,6 +218,49 @@ class Home extends Wxapp
}
}
protected function get_biz()
{
if (!$this->biz_id) {
throw new Hd_exception('参数错误', API_CODE_FAIL);
}
$re = $this->mdBiz->get(array('id' => $this->biz_id, 'status' => 1));
if (!$re) {
throw new Hd_exception('门店不存在!', API_CODE_FAIL);
}
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
$posters = $jsondata['posters'] ? build_qiniu_image_url($jsondata['posters']) : '';
$this->data['posters'] = $posters;
$this->data['biz_name'] = $re['biz_name'];
$this->data['address'] = $re['address'];
return $this->data;
}
/**
* Notes:保存海报
* Created on: 2021/11/9 14:46
* Created by: dengbw
* @throws Hd_exception
*/
protected function put_posters()
{
$posters = $this->input_param('posters');
if (!$posters || !$this->biz_id) {
throw new Hd_exception('参数错误', API_CODE_FAIL);
}
$re_b = $this->mdBiz->get(array('id' => $this->biz_id, 'status' => 1));
if (!$re_b) {
throw new Hd_exception('门店不存在!', API_CODE_FAIL);
}
$jsondata = $re_b['jsondata'] ? json_decode($re_b['jsondata'], true) : [];
$jsondata['posters'] = $posters;
$ret = $this->mdBiz->update(['jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)], array('id' => $this->biz_id));
if ($ret) {
throw new Exception('保存成功', API_CODE_SUCCESS);
} else {
throw new Exception('保存失败', API_CODE_FAIL);
}
}
/**
* Notes:获取二维码
* Created on: 2021/8/27 16:34