inve add city about
This commit is contained in:
@@ -46,7 +46,9 @@ class Inventory extends HD_Controller
|
||||
foreach ($res as $key => $value) {
|
||||
$setValue = [];
|
||||
$setValue['id'] = $value['id'];
|
||||
$setValue['title'] = '盘点时间_' . date('Y-m-d', $value['c_time']);
|
||||
$jsondata = $value['jsondata'] ? json_decode($value['jsondata'], true) : array();
|
||||
$city_name = $jsondata['city_name'] ? '_'.$jsondata['city_name'] : '';
|
||||
$setValue['title'] = '盘点时间_' . date('Y-m-d', $value['c_time']).$city_name;
|
||||
$lists[] = $setValue;
|
||||
}
|
||||
}
|
||||
@@ -190,6 +192,7 @@ class Inventory extends HD_Controller
|
||||
$map_addr[$v['id']] = "{$v['city_name']} {$v['county_name']} 其它 {$v['title']}";
|
||||
}
|
||||
}
|
||||
$row_id = 0;
|
||||
foreach ($res as $key => $v) {
|
||||
$address = $mileage = $itemStatus_name = $car_img = $where_logs = '';
|
||||
if ($v['biz_id'] > 0) {
|
||||
@@ -217,20 +220,38 @@ class Inventory extends HD_Controller
|
||||
}
|
||||
$jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : [];
|
||||
$jsondata['mileage'] && $mileage = $jsondata['mileage'];
|
||||
if ($jsondata['car_img']) {
|
||||
/*if ($jsondata['car_img']) {
|
||||
foreach ($carImgAry as $key2 => $value2) {
|
||||
$src = $jsondata['car_img'][$key2];
|
||||
$src && $car_img[] = ['title' => $value2, 'src' => build_qiniu_image_url($src)];
|
||||
}
|
||||
}*/
|
||||
$car_img_layer = $car_img = array();
|
||||
if ($jsondata['car_img']) {
|
||||
$car_img_layer['title'] = '';
|
||||
$car_img_layer['id'] = $v['item_id'];
|
||||
$car_img_layer['start'] = 0;
|
||||
$data = array();
|
||||
$pid = 0;
|
||||
foreach ($carImgAry as $key2 => $value2) {
|
||||
$src = $jsondata['car_img'][$key2];
|
||||
$src && $src = build_qiniu_image_url($src);
|
||||
$src && $data[] = ['alert' => $value2, 'pid' => $pid, 'src' => $src, 'thumb' => $src];
|
||||
$src && $car_img[] = ['title' => $value2, 'pid' => $pid, 'src' => $src];
|
||||
$src && $pid += 1;
|
||||
}
|
||||
$data && $car_img_layer['data'] = $data;
|
||||
}
|
||||
|
||||
$in_time = $v['in_time'];
|
||||
if ($where_logs) {
|
||||
$re_logs = $this->mdItemsOplogs->max('com_time', $where_logs);
|
||||
$re_logs['com_time'] && $in_time = $re_logs['com_time'];
|
||||
}
|
||||
$lists[] = ['item_id' => $v['item_id'], 'title' => $title, 'vin' => $v['vin'], 'address' => $address,
|
||||
'itemStatus_name' => $itemStatus_name, 'status_name' => $statusAry[$v['status']], 'mileage' => $mileage, 'car_img' => $car_img,
|
||||
$lists[] = ['row_id' => $row_id, 'item_id' => $v['item_id'], 'title' => $title, 'vin' => $v['vin'], 'address' => $address,
|
||||
'itemStatus_name' => $itemStatus_name, 'status_name' => $statusAry[$v['status']], 'mileage' => $mileage, 'car_img' => $car_img, 'car_img_layer'=>$car_img_layer,
|
||||
'in_time' => '0000-00-00 00:00:00' == $in_time ? '' : substr($in_time, 0, 10)];
|
||||
$row_id += 1;
|
||||
}
|
||||
}
|
||||
$this->data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total);
|
||||
@@ -248,12 +269,33 @@ class Inventory extends HD_Controller
|
||||
|
||||
public function add()
|
||||
{
|
||||
$params = $this->input->post();
|
||||
$city_id = $params['city_id'] ? intval($params['city_id']) : 0;
|
||||
$force = $params['force'] ? intval($params['force']) : 0;
|
||||
# 如果当前(该月)有相同的盘点任务,再弹窗确认是否继续发起
|
||||
$starttime = mktime(0,0,0, date('m'),1, date('Y'));
|
||||
$endtime = mktime(23,59,59, date('m'),date('t'), date('Y'));
|
||||
$where = array('city_id' => $city_id, "c_time >= {$starttime}" => null, "c_time <= {$endtime}" => null);
|
||||
$res = $this->mdInventory->count($where);
|
||||
if (!$force && $res){
|
||||
return $this->show_json(-1, '本月已有此盘点,确认要重新发起吗?');
|
||||
}
|
||||
$c_time = time();
|
||||
$inve_id = $this->mdInventory->add(['c_time' => $c_time]);
|
||||
#$inve_id = $this->mdInventory->add(['c_time' => $c_time]);
|
||||
$jsondata = json_encode(array('city_name'=> $params['city_id'] && $params['city_name'] ? $params['city_name'] : ''));
|
||||
$inve_id = $this->mdInventory->add(['c_time' => $c_time, 'city_id' => $city_id, 'jsondata' => $jsondata]);
|
||||
if (!$inve_id) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '发起盘点失败');
|
||||
}
|
||||
$where = array('status>' => 0, 'bill_time' => '0000-00-00 00:00:00');
|
||||
if ($city_id){
|
||||
$where_biz['city_id'] = $params['city_id'];
|
||||
$res_biz = $this->mdBiz->select($where_biz, 'id desc', 0, 0, 'id');
|
||||
$res_addr = $this->addr_model->select($where_biz, 'id desc', 0, 0, 'id');
|
||||
$str_ids = $res_biz ? implode(',', array_column($res_biz, 'id')) : '-2';
|
||||
$str_addr_ids = $res_addr ? implode(',', array_column($res_addr, 'id')) : '-2';
|
||||
$where["(biz_id in ({$str_ids}) or addr_id in ({$str_addr_ids}))"] = null;
|
||||
}
|
||||
$res = $this->mdItems->select($where, 'id asc', 0, 0, 'id,biz_id,addr_id');
|
||||
$addDate = [];
|
||||
foreach ($res as $key => $value) {
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
<div class="am-form-group fl ml20">
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
<button type="button" id="inve_add" class="am-btn am-btn-success am-btn-sm w100">发起盘点</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<a data-ajax="post" data-action="/items/inventory/add" class="am-btn am-btn-success am-btn-sm w100">发起盘点</a>
|
||||
<a data-ajax="post" data-action="/items/inventory/add" class="am-btn am-btn-success am-btn-sm w100" style="display: none">发起盘点</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -63,6 +64,24 @@
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="inve-modal" style="display: none;padding: 10px">
|
||||
<div class="modal-body">
|
||||
<div class="text-center">
|
||||
<div class="form-group-action">
|
||||
<form id="inve-form">
|
||||
<label class="am-para-label w150">选择需盘点的城市:</label>
|
||||
<select title="城市" id="city_id" name="city_id" v-model="city_id">
|
||||
<option value="">选择城市</option>
|
||||
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
|
||||
</select>
|
||||
<label class="am-para-label w30"></label>
|
||||
<button type="button" id="inve" class="am-btn am-btn-success am-btn-sm w100" onclick="load_inve()">盘 点</button>
|
||||
</form>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require(['laydate', 'autocomplete'], function (laydate) {
|
||||
@@ -91,4 +110,107 @@
|
||||
$('#' + source_id).val(date);
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params: [],
|
||||
lists: [],
|
||||
cityAry: [],//城市
|
||||
city_id:'',
|
||||
},
|
||||
mounted: function () {
|
||||
var vm = this;
|
||||
vm.lists = <?=json_encode($lists)?>;
|
||||
vm.init_citys();
|
||||
},
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
watch: {}
|
||||
});
|
||||
|
||||
<?php page_script($pager) ?>
|
||||
|
||||
$("#inve_add").click(function () {
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['40%'], //宽高
|
||||
content: $('#inve-modal'),
|
||||
title: '发起盘点',
|
||||
shade: false,
|
||||
btn: ['关闭'],
|
||||
yes: function (index) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function load_inve(force=0) {
|
||||
var loading = layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
// let myselect=document.getElementById("city_id");
|
||||
// let index=myselect.selectedIndex;
|
||||
// alert(myselect.options[index].value);
|
||||
let city_id = $("#city_id option:selected").val();
|
||||
let city_name = $("#city_id option:selected").text();
|
||||
var options = {
|
||||
url: "/items/inventory/add",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {'city_id_': city_id, 'city_name': city_name, 'force': force},
|
||||
success: function (res) {
|
||||
if (res['code'] > 0) {
|
||||
layer.msg(res.msg, {
|
||||
icon: 1,
|
||||
time: 2000
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
else if (res['code'] == -1){
|
||||
layer.confirm(res.msg, {
|
||||
btn: ['确认','取消'] //按钮
|
||||
}, function(){
|
||||
load_inve(force=1)
|
||||
}, function(){
|
||||
// layer.msg('也可以这样', {
|
||||
// time: 1000, //20s后自动关闭
|
||||
// btn: ['明白了', '知道了']
|
||||
// });
|
||||
});
|
||||
}
|
||||
else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
};
|
||||
$("#inve-form").ajaxSubmit(options);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -158,8 +158,8 @@
|
||||
<td><?= $v['mileage'] ?></td>
|
||||
<td><? if ($v['car_img']) {
|
||||
foreach ($v['car_img'] as $key => $v2) { ?>
|
||||
<img title="<?= $v2['title'] ?>" src="<?= $v2['src'] ?>" data-tips-image
|
||||
style="width:22px;height:22px;margin-right: 5px;">
|
||||
<img title="<?= $v2['title'] ?>" src="<?= $v2['src'] ?>"
|
||||
style="width:22px;height:22px;margin-right: 5px;" @click="show_car_img(<?= $v['row_id'] ?>, <?= $v2['pid'] ?>);">
|
||||
<?
|
||||
}
|
||||
} ?>
|
||||
@@ -186,6 +186,7 @@
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params: {},
|
||||
lists: {},
|
||||
cityAry: [],//城市
|
||||
countyAry: [],//行政区
|
||||
bizAry: [],//门店
|
||||
@@ -194,6 +195,7 @@
|
||||
},
|
||||
mounted: function () {
|
||||
var vm = this;
|
||||
vm.lists = <?=json_encode($lists)?>;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.set_sery();
|
||||
vm.init_citys();
|
||||
@@ -260,6 +262,21 @@
|
||||
$('#bd-auto2-id').val(0);
|
||||
$('#bd-auto3-id').val(0);
|
||||
$('#bd-auto4-id').val('');
|
||||
},
|
||||
show_car_img: function (row_id, pid) {
|
||||
// alert(row_id + ' - '+ pid);
|
||||
var vm = this;
|
||||
let car_img_layer = vm.lists[row_id]['car_img_layer'];
|
||||
// alert(car_img_layer['id']);
|
||||
// console.dir(car_img_layer['start']); # 该值在辅值前后输出是不一样的
|
||||
// console.dir(car_img_layer); # 该值在辅值前后输出不一样的
|
||||
car_img_layer['start'] = pid;
|
||||
// console.dir(car_img_layer['start']);
|
||||
// console.dir(car_img_layer);
|
||||
layer.photos({
|
||||
photos: car_img_layer,
|
||||
anim: 5 // 0-6的选择,指定弹出图片动画类型,默认随机
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
Reference in New Issue
Block a user