Commit f100e9a5 authored by wxl's avatar wxl

一键复制粘贴出库商品

parent 0fab4369
...@@ -65,8 +65,17 @@ class ExWarehouseController extends AbstractActionController ...@@ -65,8 +65,17 @@ class ExWarehouseController extends AbstractActionController
} }
$array['searchForm'] = $searchForm; $array['searchForm'] = $searchForm;
$query = $this->entityManager->getRepository(ExWarehouseOrder::class)->findExWarehouseOrderList($search); $query = $this->entityManager->getRepository(ExWarehouseOrder::class)->findExWarehouseOrderList($search);
$array['orderList'] = $this->adminCommon()->erpPaginator($query, $page); $orderList=$this->adminCommon()->erpPaginator($query, $page);
foreach ($orderList as $key=>$value){
$orderGoodsIds = $this->entityManager->getRepository(ExWarehouseOrderGoods::class)->findGoodsIdSearch(['ex_warehouse_order_id' => $value->getExWarehouseOrderId()]);
if($orderGoodsIds){
$goodsIds=array_column($orderGoodsIds, "goodsId");
$value->orderGoodsIds=implode(",",$goodsIds);
}else{
$value->orderGoodsIds='';
}
}
$array['orderList'] = $orderList;
return $array; return $array;
} }
......
...@@ -35,6 +35,22 @@ class ExWarehouseOrderGoodsRepository extends EntityRepository ...@@ -35,6 +35,22 @@ class ExWarehouseOrderGoodsRepository extends EntityRepository
return $ExWarehouseAmount ? $ExWarehouseAmount : 0; return $ExWarehouseAmount ? $ExWarehouseAmount : 0;
} }
/**
* 检索商品id
* @param $goodsName
* @return mixed
*/
public function findGoodsIdSearch($search = [])
{
//当定义为某个字段时,输出的是数组
$query = $this->getEntityManager()->createQueryBuilder()
->select('e.goodsId,e.goodsName')
->from(ExWarehouseOrderGoods::class, 'e');
$this->querySearchData($search, $query);
$goodsIdResult = $query->getQuery()->getResult();
return $goodsIdResult;
}
private function querySearchData($search, QueryBuilder $queryBuilder) private function querySearchData($search, QueryBuilder $queryBuilder)
{ {
if(isset($search['ex_warehouse_order_goods_id']) && !empty($search['ex_warehouse_order_goods_id'])) $queryBuilder->andWhere($queryBuilder->expr()->eq('e.exWarehouseOrderGoodsId', $search['ex_warehouse_order_goods_id'])); if(isset($search['ex_warehouse_order_goods_id']) && !empty($search['ex_warehouse_order_goods_id'])) $queryBuilder->andWhere($queryBuilder->expr()->eq('e.exWarehouseOrderGoodsId', $search['ex_warehouse_order_goods_id']));
......
...@@ -64,6 +64,14 @@ ...@@ -64,6 +64,14 @@
</div> </div>
<div class="row">
<div class="col-xs-4 form-group">
<div class="col-sm-12">
<input type="text" id="pastevalue" placeholder="这里是粘贴的内容" />
<button type="button" onclick="toPaste();" class="btn btn-primary btn-sm"><i class="fa fa-copy" aria-hidden="true"></i> <?php echo $this->translate('粘贴'); ?></button>
</div>
</div>
</div>
<?php <?php
$goodsForm = $this->goodsForm; $goodsForm = $this->goodsForm;
?> ?>
...@@ -241,4 +249,17 @@ ...@@ -241,4 +249,17 @@
function searchGoods() { function searchGoods() {
dberpAjaxList('<?php echo $this->url('goods', ['action' => 'ajaxGoodsSearch']);?>?searchGoodsName='+$('#searchGoodsName').val(), 'addGoodsListBody'); dberpAjaxList('<?php echo $this->url('goods', ['action' => 'ajaxGoodsSearch']);?>?searchGoodsName='+$('#searchGoodsName').val(), 'addGoodsListBody');
} }
function toPaste() {
var pastevalue= document.getElementById("pastevalue").value;
var array = pastevalue.split(',');
if(array.length>0){
for(var i = 0; i < array.length; i++){
addSelectGoods(array[i]);
}
}else{
alert("请输入商品id");
}
}
</script> </script>
\ No newline at end of file
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
</h1> </h1>
</section> </section>
<section class="content"> <section class="content">
<?php echo $this->partial('layout/messages'); ?> <?php echo $this->partial('layout/messages'); ?>
...@@ -91,7 +90,8 @@ ...@@ -91,7 +90,8 @@
['action'=>'view', 'id'=>$order->getExWarehouseOrderId()]); ?>" ['action'=>'view', 'id'=>$order->getExWarehouseOrderId()]); ?>"
class="btn btn-xs btn-info"><i class="fa fa-info-circle"></i> <?php echo $this->translate('查看'); ?> class="btn btn-xs btn-info"><i class="fa fa-info-circle"></i> <?php echo $this->translate('查看'); ?>
</a> </a>
</td> <input type="hidden" value="<?php echo $this->escapeHtml($order->orderGoodsIds); ?>" id="orderIds<?php echo $this->escapeHtml($order->getExWarehouseOrderId()); ?>">
<button type="button" onclick="toCopy(<?php echo $this->escapeHtml($order->getExWarehouseOrderId()); ?>);" class="btn btn-primary btn-sm"><i class="fa fa-copy" aria-hidden="true"></i> <?php echo $this->translate('复制'); ?></button>
</tr> </tr>
<?php } } else { ?> <?php } } else { ?>
<tfoot> <tfoot>
...@@ -115,4 +115,31 @@ ...@@ -115,4 +115,31 @@
<script type="text/javascript"> <script type="text/javascript">
laydate.render({elem: '#start_time'}); laydate.render({elem: '#start_time'});
laydate.render({elem: '#end_time'}); laydate.render({elem: '#end_time'});
//复制
function toCopy(id) {
var copyval= $('#orderIds'+id).val();
console.log("复制的内容:" + copyval);
copyText(copyval);
}
//复制事件
function copyText(text) {
var textarea = document.createElement("textarea");
var currentFocus = document.activeElement;
document.body.appendChild(textarea);
textarea.value = text;
textarea.focus();
if (textarea.setSelectionRange)
textarea.setSelectionRange(0, textarea.value.length);
else
textarea.select();
try {
var flag = document.execCommand("copy");
} catch (eo) {
var flag = false;
}
document.body.removeChild(textarea);
currentFocus.focus();
return flag;
}
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment