goods_logs_1109

This commit is contained in:
dengbw
2021-11-09 13:45:32 +08:00
parent db3b66e088
commit 7364745129
6 changed files with 778 additions and 53 deletions
+6 -5
View File
@@ -8,7 +8,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
*/
class Goods extends HD_Controller
{
private $statusAry = array(1 => '未配', 2 => '已配', 0 => '下架');
private $statusAry = array(1 => '未配', 2 => '已配', 0 => '下架');
public function __construct()
{
@@ -784,27 +784,28 @@ class Goods extends HD_Controller
, 'com_time' => $info['bill_time'], 'biz_id' => $info['biz_id'], 'addr_id' => $info['addr_id']);
$this->items_entity->add_log($params);
}
$com_time = date('Y-m-d H:i:s');
if ($re['biz_id'] > 0 && $biz_id > 0) {//门店间变化
if ($re['biz_id'] != $biz_id) {
$params = array('item_id' => $info['id'], 'type' => 2, 'uid' => $this->uid, 'uname' => $this->username
, 'com_time' => $info['bill_time'], 'biz_id' => $re['biz_id'], 'biz_id_to' => $biz_id);
, 'com_time' => $com_time, 'biz_id' => $re['biz_id'], 'biz_id_to' => $biz_id);
$this->items_entity->add_log($params);
}
} else if ($re['biz_id'] > 0 && $biz_id == -1) {//门店转地址变化
if ($addr_id) {
$params = array('item_id' => $info['id'], 'type' => 2, 'uid' => $this->uid, 'uname' => $this->username
, 'com_time' => $info['bill_time'], 'biz_id' => $re['biz_id'], 'addr_id_to' => $addr_id);
, 'com_time' => $com_time, 'biz_id' => $re['biz_id'], 'addr_id_to' => $addr_id);
$this->items_entity->add_log($params);
}
} else if ($re['biz_id'] == -1 && $biz_id == -1) {//地址间变化
if ($re['addr_id'] != $addr_id) {
$params = array('item_id' => $info['id'], 'type' => 2, 'uid' => $this->uid, 'uname' => $this->username
, 'com_time' => $info['bill_time'], 'biz_id' => -1, 'addr_id' => $re['addr_id'], 'addr_id_to' => $addr_id);
, 'com_time' => $com_time, 'biz_id' => -1, 'addr_id' => $re['addr_id'], 'addr_id_to' => $addr_id);
$this->items_entity->add_log($params);
}
} else if ($re['biz_id'] == -1 && $biz_id > 0) {//地址转门店变化
$params = array('item_id' => $info['id'], 'type' => 2, 'uid' => $this->uid, 'uname' => $this->username
, 'com_time' => $info['bill_time'], 'biz_id' => -1, 'addr_id' => $re['addr_id'], 'biz_id_to' => $biz_id);
, 'com_time' => $com_time, 'biz_id' => -1, 'addr_id' => $re['addr_id'], 'biz_id_to' => $biz_id);
$this->items_entity->add_log($params);
}
$this->data['status'] = 2;
+209 -19
View File
@@ -8,15 +8,20 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class Logs extends HD_Controller
{
private $statusAry = array(1 => '未分配', 2 => '已分配', 0 => '下架');
public function __construct()
{
parent::__construct();
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
$this->load->model('auto/auto_attr_model', 'mdAutoAttr');
$this->load->model('items/items_oplogs_model', 'mdItemsOplogs');
$this->load->model('items/items_model', 'mdItems');
$this->load->model("biz/biz_model", 'mdBiz');
$this->load->model("sys/sys_addr_model", 'mdAddr');
$this->load->model('area_model', 'mdArea');
$this->load->model('items/items_relate_model');
}
public function index()
@@ -26,6 +31,178 @@ 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;
$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');
}
if ($params['s_id']) {
$where['s_id'] = $params['s_id'];
$autoList[3] = $this->mdAutoAttr->select(array('type' => 1, 's_id' => $params['s_id']), 'id desc', 0, 0, 'id,title as name');
}
if ($params['v_id']) {
$where['v_id'] = $params['v_id'];
}
//车身颜色
if ($params['cor_id']) {
$where['cor_id'] = $params['cor_id'];
} else {
$params['cor_id'] = '';
}
//地址筛选
if ($params['biz_id']) {
$where['biz_id'] = $params['biz_id'];
}
if ($params['biz_id'] == -1 && $params['addr_id']) {
$where['addr_id'] = $params['addr_id'];
} else if ($params['city_id']) {
$where_biz['status'] = 1;
$params['city_id'] && $where_biz['city_id'] = $params['city_id'];
$params['county_id'] && $where_biz['county_id'] = $params['county_id'];
$res_biz = $this->mdBiz->select($where_biz, 'id desc', 0, 0, 'id');
if ($res_biz) {
$str_ids = implode(',', array_column($res_biz, 'id'));
$where["biz_id in ({$str_ids})"] = null;
} else {
$where['biz_id'] = -2;
}
} else {
$params['city_id'] = '';
$params['county_id'] = '';
$params['addr_id'] = '';
$params['biz_id'] = '';
}
if (strlen($params['status']) > 0) {
$where['status'] = $params['status'];
} else {
$params['status'] = '';
}
if ($params['vin']) {
$where["vin like '%{$params['vin']}%'"] = null;
}
$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name');
$statusAry = $this->statusAry;
$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);
$brand_ids = $s_ids = $attr_vids = $attr_corids = $biz_ids = $addr_ids = array();
$ids = array();
foreach ($rows as $v) {
$ids[] = $v['id'];
$v['brand_id'] && !in_array($v['brand_id'], $brand_ids) && $brand_ids[] = $v['brand_id'];
$v['biz_id'] && !in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
$v['addr_id'] && !in_array($v['addr_id'], $addr_ids) && $addr_ids[] = $v['addr_id'];
$v['s_id'] && !in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id'];
$v['v_id'] && !in_array($v['v_id'], $attr_vids) && $attr_vids[] = $v['v_id'];
$v['cor_id'] && !in_array($v['cor_id'], $attr_corids) && $attr_corids[] = $v['cor_id'];
}
$map_brand = $map_sery = $map_vid = $map_corid = $map_incorid = $map_biz = $map_addr = array();
if ($brand_ids) {
$str_ids = implode(',', $brand_ids);
$where = array("id in ({$str_ids})" => null);
$map_brand = $this->mdAutoBrand->map('id', 'name', $where);
}
if ($s_ids) {
$str_ids = implode(',', $s_ids);
$where = array("id in ({$str_ids})" => null);
$map_sery = $this->mdAutoSeries->map('id', 'name', $where);
}
if ($attr_vids) {
$str_ids = implode(',', $attr_vids);
$where = array("id in ({$str_ids})" => null);
$map_vid = $this->mdAutoAttr->map('id', 'title', $where);
}
if ($attr_corids) {
$str_ids = implode(',', $attr_corids);
$where = array("id in ({$str_ids})" => null);
$map_corid = $this->mdAutoAttr->map('id', 'title', $where);
}
if ($biz_ids) {
$str_ids = implode(',', $biz_ids);
$where = array("id in ({$str_ids})" => null);
$map_biz = $this->mdBiz->map('id', 'biz_name', $where);
}
if ($addr_ids) {
$str_ids = implode(',', $addr_ids);
$where = array("id in ({$str_ids})" => null);
$orderby = 'id desc';
$select = 'id, title, city_name, county_name';
$rows_addr = $this->mdAddr->select($where, $orderby, 0, 0, $select);
foreach ($rows_addr as $v) {
$map_addr[$v['id']] = ['title' => "{$v['city_name']} {$v['county_name']} 其它 {$v['title']}", 'name' => $v['title']];
}
}
foreach ($rows as $k => $v) {
$address = $last_db_time = $log_max = $log_min_kc = $log_max_kc = $inventory_time = $biz_name = '';
if ($v['biz_id'] > 0) {
$address = $map_biz[$v['biz_id']];
$biz_name = $map_biz[$v['biz_id']];
$re_biz = $this->mdBiz->get(array('id' => $v['biz_id']));
if ($re_biz['county_id']) {
$re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id']));
$re_area && $address = "{$re_area['city_name']} {$re_area['county_name']} {$address}";
} else if ($re_biz['city_id']) {
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
$re_area && $address = "{$re_area['city_name']} {$address}";
}
$log_max = $this->mdItemsOplogs->max('com_time', ["type in(1,2) AND item_id={$v['id']}
AND (biz_id={$v['biz_id']} or biz_id_to={$v['biz_id']})" => null]);
$log_min_kc = $this->mdItemsOplogs->get(["item_id={$v['id']}
AND (biz_id={$v['biz_id']} or biz_id_to={$v['biz_id']})" => null], 'com_time');
$log_max_kc = $this->mdItemsOplogs->max('com_time', ["item_id={$v['id']}
AND (biz_id={$v['biz_id']} or biz_id_to={$v['biz_id']})" => null]);
} else if ($v['biz_id'] == -1 && $v['addr_id']) {
$address = $map_addr[$v['addr_id']]['title'];
$biz_name = $map_addr[$v['addr_id']]['name'];
$log_max = $this->mdItemsOplogs->max('com_time', ["type in(1,2) AND item_id={$v['id']}
AND (addr_id={$v['addr_id']} or addr_id_to={$v['addr_id']})" => null]);
$log_min_kc = $this->mdItemsOplogs->get(["item_id={$v['id']}
AND (addr_id={$v['addr_id']} or addr_id_to={$v['addr_id']})" => null], 'com_time');
$log_max_kc = $this->mdItemsOplogs->max('com_time', ["item_id={$v['id']}
AND (addr_id={$v['addr_id']} or addr_id_to={$v['addr_id']})" => null]);
}
($log_max['com_time'] && '0000-00-00 00:00:00' != $log_max['com_time']) && $last_db_time = $log_max['com_time'];
if (!$last_db_time && $v['in_time'] != '0000-00-00 00:00:00') {
$last_db_time = $v['in_time'];
}
$days = 0;
if (($log_min_kc['com_time'] && $log_max_kc['com_time']) && ($log_min_kc['com_time'] != $log_max_kc['com_time'])) {
$days = round((strtotime($log_max_kc['com_time']) - strtotime($log_min_kc['com_time'])) / 3600 / 24);
} else if ($v['in_time'] != '0000-00-00 00:00:00' && $v['bill_time'] != '0000-00-00 00:00:00') {
$days = round((strtotime($v['bill_time']) - strtotime($v['in_time'])) / 3600 / 24);
} else if ($v['in_time'] != '0000-00-00 00:00:00') {
$days = round((time() - strtotime($v['in_time'])) / 3600 / 24);
}
$title = "{$map_brand[$v['brand_id']]}-{$map_sery[$v['s_id']]}-{$map_vid[$v['v_id']]}-{$map_corid[$v['cor_id']]}";
$lists[] = array(
'id' => $v['id'],
'title' => $title,
'biz_name' => $biz_name,
'vin' => $v['vin'],
'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'] ? '已出售' : '未出售',
'last_db_time' => $last_db_time,
'inventory_time' => $days > 0 ? '库存' . $days . '天' : '',
);
}
}
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);
}
public function get()
@@ -36,6 +213,7 @@ class Logs extends HD_Controller
return $this->show_json(SYS_CODE_FAIL, '商品不存在!');
}
$title = $this->input->get('title');
$biz_name = $this->input->get('biz_name');
$res_log = $this->mdItemsOplogs->select(array('item_id' => $id), 'id asc', 0, 0);
$biz_ids = $biz_ids_to = $addr_ids = $addr_ids_to = array();
foreach ($res_log as $v) {
@@ -123,17 +301,17 @@ class Logs extends HD_Controller
}
if ($value['biz_id'] > 0) {
if ($value['biz_id_to'] > 0) {
if ($map_biz[$value['biz_id']]['s_time']) {
$days = round(($value['c_time'] - $map_biz[$value['biz_id']]['s_time']) / 3600 / 24);
if ($map_biz[$value['biz_id']]['s_time'] > 0) {
$days = round((strtotime($value['com_time']) - strtotime($map_biz[$value['biz_id']]['s_time'])) / 3600 / 24);
$setValue['log'] = $setValue['log'] . ',库存' . $days . '天';
}
$map_biz[$value['biz_id_to']]['s_time'] = $value['c_time'];
$value['com_time'] != '0000-00-00 00:00:00' && $map_biz[$value['biz_id_to']]['s_time'] = $value['com_time'];
} else {
if ($value['type'] == 3 && $map_biz[$value['biz_id']]['s_time']) {
$days = round(($value['c_time'] - $map_biz[$value['biz_id']]['s_time']) / 3600 / 24);
$setValue['log'] = $setValue['log'] . ',用时' . $days . '天出车辆';
if ($value['type'] == 3 && $map_biz[$value['biz_id']]['s_time'] > 0) {
$days = round((strtotime($value['com_time']) - strtotime($map_biz[$value['biz_id']]['s_time'])) / 3600 / 24);
$setValue['log'] = $setValue['log'] . ',用时' . $days . '天出车辆';
}
$map_biz[$value['biz_id']]['s_time'] = $value['c_time'];
$value['com_time'] != '0000-00-00 00:00:00' && $map_biz[$value['biz_id']]['s_time'] = $value['com_time'];
}
$map_biz[$value['biz_id']]['lists'][] = $setValue;
}
@@ -142,40 +320,52 @@ class Logs extends HD_Controller
}
if ($value['addr_id'] > 0) {
if ($value['biz_id_to'] > 0) {
if ($map_addr[$value['addr_id']]['s_time']) {
$days = round(($value['c_time'] - $map_addr[$value['addr_id']]['s_time']) / 3600 / 24);
if ($map_addr[$value['addr_id']]['s_time'] > 0) {
$days = round((strtotime($value['com_time']) - strtotime($map_addr[$value['addr_id']]['s_time'])) / 3600 / 24);
$setValue['log'] = $setValue['log'] . ',库存' . $days . '天';
}
$map_addr[$value['addr_id_to']]['s_time'] = $value['c_time'];
$value['com_time'] != '0000-00-00 00:00:00' && $map_addr[$value['addr_id_to']]['s_time'] = $value['com_time'];
} else {
if ($value['type'] == 3 && $map_addr[$value['addr_id']]['s_time']) {
$days = round(($value['c_time'] - $map_addr[$value['addr_id']]['s_time']) / 3600 / 24);
$setValue['log'] = $setValue['log'] . ',用时' . $days . '天出车辆';
if ($value['type'] == 3 && $map_addr[$value['addr_id']]['s_time'] > 0) {
$days = round((strtotime($value['com_time']) - strtotime($map_addr[$value['addr_id']]['s_time'])) / 3600 / 24);
$setValue['log'] = $setValue['log'] . ',用时' . $days . '天出车辆';
}
$map_addr[$value['addr_id']]['s_time'] = $value['c_time'];
$value['com_time'] != '0000-00-00 00:00:00' && $map_addr[$value['addr_id']]['s_time'] = $value['com_time'];
}
$map_addr[$value['addr_id']]['lists'][] = $setValue;
}
$lists[] = $setValue;
}
//echo json_encode($map_biz,JSON_UNESCAPED_UNICODE);
$all = array('lists' => $lists);
if ($re['in_time'] != '0000-00-00 00:00:00' && $re['bill_time'] != '0000-00-00 00:00:00') {
$days = round((strtotime($re['bill_time']) - strtotime($re['in_time'])) / 3600 / 24);
$all['title'] = "总用时{$days}出车辆";
} else {
$all['title'] = "总用时{$days}天出车辆";
} else if ($re['in_time'] != '0000-00-00 00:00:00') {
$days = round((time() - strtotime($re['in_time'])) / 3600 / 24);
$all['title'] = "至今已库存{$days}";
}
$lists = array();
foreach ($map_biz as $key => $value) {
$lists[] = $value;
if ($biz_name) {
if ($value['title'] == $biz_name) {
$lists[] = $value;
}
} else {
$lists[] = $value;
}
}
foreach ($map_addr as $key => $value) {
$lists[] = $value;
if ($biz_name) {
if ($value['title'] == $biz_name) {
$lists[] = $value;
}
} else {
$lists[] = $value;
}
}
$this->data['all'] = $all;
$this->data['lists'] = $lists;
$this->data['biz_name'] = $biz_name;
$this->data['_title'] = $title;
return $this->show_view('/items/logs/get', true);
}
+36 -29
View File
@@ -9,42 +9,49 @@
<div class="am-panel-bd">
<div class="am-tabs" data-am-tabs>
<ul class="am-tabs-nav am-nav am-nav-tabs">
<li class="am-active"><a href="javascript: void(0)">车辆记录</a></li>
<?
if ($lists) {
foreach ($lists as $key => $val) { ?>
<li><a href="javascript: void(0)"><?= $val['title'] ?></a></li>
<? }
} ?>
<? if ($biz_name) { ?>
<li class="am-active"><a href="javascript: void(0)"><?= $biz_name ?></a></li>
<? } else { ?>
<li class="am-active"><a href="javascript: void(0)">车辆记录</a></li>
<?
if ($lists) {
foreach ($lists as $key => $val) { ?>
<li <?= $biz_name ? 'class="am-active"' : '' ?>>
<a href="javascript: void(0)"><?= $val['title'] ?></a></li>
<? }
} ?>
<? } ?>
</ul>
<div class="am-tabs-bd">
<div class="am-tab-panel am-active">
<div><?= $all['title'] ?></div>
<table class="am-table">
<thead>
<tr>
<th width="10%"><span>操作人员</span></th>
<th width=""><span>内容</span></th>
<th width="13%"><span>类型</span></th>
<th width="15%"><span>操作时间</span></th>
</tr>
</thead>
<tbody>
<?php foreach ($all['lists'] as $key => $val) { ?>
<? if (!$biz_name) { ?>
<div class="am-tab-panel am-active">
<div><?= $all['title'] ?></div>
<table class="am-table">
<thead>
<tr>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['uname'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['log'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['type_name'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word;"><?= $val['c_time'] ?></td>
<th width="10%"><span>操作人员</span></th>
<th width=""><span>内容</span></th>
<th width="13%"><span>类型</span></th>
<th width="15%"><span>操作时间</span></th>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</thead>
<tbody>
<?php foreach ($all['lists'] as $key => $val) { ?>
<tr>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['uname'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['log'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['type_name'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word;"><?= $val['c_time'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<? } ?>
<?
if ($lists) {
foreach ($lists as $key => $val) { ?>
<div class="am-tab-panel">
<div class="am-tab-panel<?= $biz_name ? ' am-active' : '' ?>">
<table class="am-table">
<thead>
<tr>
+477
View File
@@ -0,0 +1,477 @@
<div class="coms-table-wrap mt10">
<form class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="/items/goods/logs">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w100">车型:</label>
<div class="am-para-inline w120">
<select id="bd-auto1-id" name="brand_id" data-toggle="next-select"
data-refurl="/common/auto?pid={value}&type=2"
data-next="#bd-auto2-id">
<option value="0">选择品牌</option>
<? if ($autoList[1]) {
foreach ($autoList[1] as $v) { ?>
<option value="<?= $v['id'] ?>" <?= $v['id'] == $params['brand_id'] ? 'selected' : '' ?>
><?= $v['name'] ?></option>
<? }
} ?>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w120">
<select id="bd-auto2-id" name="s_id" data-toggle="next-select"
data-refurl="/common/auto?pid={value}&type=3"
data-next="#bd-auto3-id" @change="set_sery">
<option value="0">选择车系</option>
<?php if ($autoList[2]) {
foreach ($autoList[2] as $v) { ?>
<option value="<?= $v['id'] ?>" <?= $v['id'] == $params['s_id'] ? 'selected' : '' ?>
><?= $v['name'] ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w120">
<select id="bd-auto3-id" name="v_id">
<option value="0">选择车型</option>
<?php if ($autoList[3]) {
foreach ($autoList[3] as $v) { ?>
<option value="<?= $v['id'] ?>" <?= $v['id'] == $params['v_id'] ? 'selected' : '' ?>
><?= $v['name'] ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w120">
<select name="cor_id" v-model="params.cor_id">
<option value="">车身颜色</option>
<option :value="v.id" v-for="(v,i) in attrs_cor">{{v.title}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">状态:</label>
<div class="am-para-inline w120">
<select title="状态" name="status" v-model="params.status">
<option value="">选择状态</option>
<option :value="i" v-for="(v,i) in statusAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label w100">车架号:</label>
<div class="am-para-inline w250">
<input type="text" name="vin" placeholder="车架号关键字" v-model="params.vin"/>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">门店:</label>
<div class="am-para-inline w120">
<select title="城市" name="city_id" v-model="params.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w120">
<select title="行政区" name="county_id" v-model="params.county_id" @change="set_county">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in countyAry">{{v.name}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w120">
<select title="门店" name="biz_id" v-model="params.biz_id" @change="set_biz">
<option value="">选择门店</option>
<option :value="v.id" v-for="(v,i) in bizAry">{{v.title}}</option>
</select>
</div>
</div>
<div class="am-form-group fl" v-if="params.biz_id==-1">
<div class="am-para-inline w160">
<select title="地址" name="addr_id" v-model="params.addr_id">
<option value="">选择地址</option>
<option :value="v.id" v-for="(v,i) in addrAry">{{v.title}}</option>
</select>
</div>
</div>
<div class="am-form-group"></div>
<div class="am-form-group fl ml100">
<div class="am-form-group fl ml10">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml10">
<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>-->
</div>
</div>
</div>
</form>
<div class="coms-table-bd">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="3%"><span>ID</span></th>
<th width="20%"><span>门店</span></th>
<th width="20%"><span>车辆</span></th>
<th width="12%"><span>车架号</span></th>
<th width="10%"><span>入库日期</span></th>
<th width="10%"><span>最后调拨时间</span></th>
<th width="10%"><span>库存时间</span></th>
<th width="7%"><span>是否出售</span></th>
<th width="7%"><span>状态</span></th>
</tr>
</thead>
<tbody>
<template v-for="(v,i) in lists">
<tr>
<td>{{v.id}}</td>
<td>{{v.address}}</td>
<td>{{v.title}}</td>
<td><a href="javascript:void(0);" :data-modal="'/items/goods/goods/get_info?id='+v.id"
data-title="详情">{{v.vin}}</a>
</td>
<td>{{v.in_time}}</td>
<td>{{v.last_db_time}}</td>
<td>{{v.inventory_time}}</td>
<td>{{v.bill_time}}</td>
<td>{{v.status_name}}</td>
</tr>
<tr>
<td colspan="9">
<div class="row">
<div class="col-md-4 align-l">
</div>
<div class="col-md-8 align-r" style="padding-right: 30px;">
<a href="javascript:void(0);"
:data-open="'/items/goods/logs/get?id='+v.id+'&title='+v.title+'&biz_name='+v.biz_name"
class="am-btn am-btn-primary am-btn-xs">调拨记录</a>
</div>
</td>
</tr>
</template>
</tbody>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
</div>
<script>
$(function () {
vue_obj = new Vue({
el: '.coms-table-wrap',
data: {
params: [],
statusAry: [],//状态
cityAry: [],//城市
countyAry: [],//行政区
bizAry: [],//门店
addrAry: [],//地址
lists: [],
attrs_cor: [],//车身颜色选项
},
mounted: function () {
var vm = this;
vm.lists = <?=json_encode($lists)?>;
vm.params = <?=json_encode($params)?>;
vm.statusAry = <?=json_encode($statusAry)?>;
vm.init_citys();
vm.set_sery();
},
methods: {
init_citys: function () {
var vm = this;
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
}
});
},
set_county: function () {
var that = this;
that.bizAry = that.addrAry = [];
that.params.biz_id = that.params.addr_id = '';
},
set_biz: function () {
var that = this;
that.addrAry = [];
that.params.addr_id = '';
},
set_sery: function () {
var vm = this;
var s_id = $('#bd-auto2-id').val();
if (s_id > 0) {
$.ajax({
type: 'post',
url: '/auto/attr/json_lists',
dataType: 'json',
data: {
s_id: s_id,
status: 1,
type: 0
},
success: function (response) {
if (response.code == 1) {
vm.attrs_cor = response.data.list;
}
}
});
} else {
vm.attrs_cor = [];
vm.params.cor_id = '';
}
},
reset: function () {
var that = this;
that.params.cor_id = '';
that.params.city_id = '';
that.params.status = '';
that.params.vin = '';
that.fines = [];
$('#bd-auto1-id').val(0);
$('#bd-auto2-id').val(0);
$('#bd-auto3-id').val(0);
}
},
watch: {
'params.city_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.countyAry = [];
that.params.county_id = '';
} else {
if (nv.substring(0, 4) != that.params.county_id.substring(0, 4)) {
that.params.county_id = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key: 'county',
type: 1
},
success: function (response) {
if (response.code == 1) {
that.countyAry = response.data;
}
}
});
}
},
'params.county_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.bizAry = that.addrAry = [];
that.params.biz_id = that.params.addr_id = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.params.city_id,
county_id: that.params.county_id,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.bizAry = response.data.list;
that.bizAry.push({id: -1, title: '其它'});
var biz_id = '';
if (that.params.biz_id > 0 || that.params.biz_id == -1) {
for (var i in that.bizAry) {
if (that.params.biz_id == that.bizAry[i].id) {
biz_id = that.params.biz_id;
break;
}
}
}
that.params.biz_id = biz_id;
}
}
});
}
},
'params.biz_id': function (nv, ov) {
var that = this;
if (that.params.biz_id != -1) {
return;
}
nv = that.params.county_id;
if (nv == '') {
that.addrAry = [];
that.params.addr_id = '';
} else {
$.ajax({
type: 'get',
url: '/sys/addr/json_lists',
dataType: 'json',
data: {
county_id: nv,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.addrAry = response.data.lists;
if (that.params.addr_id > 0) {
var addr_id = '';
for (var i in that.addrAry) {
if (that.params.addr_id == that.addrAry[i].id) {
addr_id = that.params.addr_id;
break;
}
}
that.params.addr_id = addr_id;
}
}
}
});
}
}
}
});
<?php page_script($pager) ?>
$('#export').click(function () {
var count = <?=$pager['totle']?>;
if (count > 10000) {
layer.msg('单次导出数据不能超过10000');
return false;
}
var href = $.menu.parseUri(window.location.href);
var arr = href.split('?');
href = '/items/goods/goods/export?' + arr[1];
window.location.href = href;
});
$('#bd-auto1-id').change(function () {
$('#bd-auto2-id').empty();
$('#bd-auto3-id').empty();
$("#bd-auto3-id").prepend("<option value='0'>选择车型</option>");
});
$('#bd-auto2-id').change(function () {
$('#bd-auto3-id').empty();
});
});
</script>
<link rel="stylesheet" type="text/css" href="/static/css/appitem/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/appitem/AdminLTE.min.css">
<style>
.label-group-wrap {
margin-top: 10px;
font-size: 0;
}
.label-group {
display: inline-block;
margin-right: 4px;
margin-bottom: 16px;
font-size: 0;
white-space: nowrap;
}
.label-group-wrap .label, .label-group > .label {
font-size: 10px;
font-weight: normal;
margin-right: 1px;
white-space: normal;
line-height: 1.4;
}
.label {
font-weight: normal;
}
.label-group > span + a.label {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: 1px solid #fff;
margin-left: -3px;
}
.label-group-wrap .label, .label-group > .label {
font-size: 10px;
font-weight: normal;
margin-right: 1px;
white-space: normal;
line-height: 1.4;
}
.order-on {
border-bottom: 2px solid #e61773;
height: 40px;
}
.order-none {
height: 38px;
}
.order {
width: 150px;
display: table-cell;
position: relative;
}
.order a {
display: block;
overflow: hidden;
width: 100%;
height: 30px;
line-height: 30px;
text-align: center;
color: #5e5e5e;
}
.angle_top {
content: '';
width: 0;
height: 0;
display: block;
border-style: solid;
border-width: 0 6px 6px;
border-color: transparent transparent #5e5e5e;
position: absolute;
transform: rotate(180deg);
bottom: 14px;
right: 17px;
}
.angle_bottom {
content: '';
width: 0;
height: 0;
display: block;
border-style: solid;
border-width: 0 6px 6px;
border-color: transparent transparent #5e5e5e;
position: absolute;
top: 10px;
right: 17px;
}
</style>
+49
View File
@@ -16,6 +16,55 @@ class Temp extends HD_Controller
$this->log_file = 'temp.log';
}
/**
* Notes:更新商品操作日志
* Created on: 2021/9/18 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/items_oplogs
* https://api.liche.cn/plan/temp/items_oplogs
*/
public function items_oplogs()
{
$this->load->model('items/items_model', 'mdItems');
$this->load->model('items/items_oplogs_model', 'mdItemsOplogs');
$this->load->library('entity/items_entity');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 50;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = array('status >' => 0, 'in_time <>' => '0000-00-00 00:00:00');
$res = $this->mdItems->select($where, 'id ASC', $param['page'], $param['size'], 'id,biz_id,addr_id,in_time');
if (!$res) {
echo '<br>本次更新商品操作日志完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/items_oplogs">点击将再次更新商品操作日志>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$re_c = $this->mdItemsOplogs->get(array('item_id' => $value['id'], 'biz_id' => $value['biz_id'], 'type' => 1));
if (!$re_c['id']) {
if ($value['biz_id'] == -1 && !$value['addr_id']) {
continue;
}
$params = array('item_id' => $value['id'], 'type' => 1, 'uid' => 0, 'uname' => '系统'
, 'com_time' => $value['in_time'], 'biz_id' => $value['biz_id'], 'addr_id' => $value['addr_id']);
$this->items_entity->add_log($params);
$log[] = array('id' => $value['id']);
$counts++;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/items_oplogs?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新客户表来源id
* Created on: 2021/9/18 11:58
+1
View File
@@ -45,6 +45,7 @@ class Items_entity
} elseif ($params['type'] == 2) {//调拨
$params['biz_id_to'] && $add_data['biz_id_to'] = $params['biz_id_to'];
$params['addr_id_to'] && $add_data['addr_id_to'] = $params['addr_id_to'];
$params['com_time'] && $add_data['com_time'] = $params['com_time'];
}
if ($edit_data) {
$result = $this->ci->mdItemsOplogs->update($edit_data, ['item_id' => $params['item_id'], 'type' => $params['type']]);