Vue和Java常用代码

一、Java分组,加收集ID获取数据

//收集查询的ID
List<String> materialIds = receiveGoodsOrder.getReceiveGoodsOrderDetailList().stream()
                .map(ReceiveGoodsOrderDetail::getGoodsId)
				.filter(o -> o != null)
				.distinct()
				.collect(Collectors.toList());

//mybatis根据ID集合查询
<select id="findByIds" resultType="Material">
		SELECT
		<include refid="materialColumns"/>
		FROM ship_material a
		<include refid="materialJoins"/>
		<where>
			a.del_flag = '0' and a.id in
			<foreach collection="materialIds" close=")" open="(" separator="," item="id">
				#{id}
			</foreach>
		</where>
	</select>

//查询后转换成map,得到每个物料对应的类
Map<String, Material> materialMap = materialService.findByIds(materialIds).stream()
				.collect(Collectors.toMap(Material::getId, v -> v, (v1, v2) -> v2));

//根据仓库ID分组,无序
Map<String, List<ReceiveGoodsOrderDetail>> listMap =			receiveGoodsOrder.getReceiveGoodsOrderDetailList().stream().collect(Collectors.groupingBy(t -> t.getStorageId()));
 //根据仓库 拆单
for(Map.Entry<String, List<ReceiveGoodsOrderDetail>> entry : listMap.entrySet()){
	String storageId = entry.getKey();
    for (ReceiveGoodsOrderDetail receiveGoodsOrderDetail : entry.getValue()) {

    }
}

//有序分组
LinkedHashMap<String,List<MachineTypeDetail>> prodMap = detailList.stream()      .collect(Collectors.groupingBy(MachineTypeDetail::getProdStage,LinkedHashMap::new,Collectors.toList()));

二、Css 动态设置背景颜色宽度

下图红框样式

 backgroundSize为后端返回的比率

  <div class="intPutRow" >
                  <div class="intPutClass put "  :style="{backgroundSize: (orderInfo.lcd_put_ratio || 0)+'% auto' }"> 
                    <div> 实际投入</div>
                    <div class="big-screen-foot"> {{orderInfo.lcm_put_num}}</div>
                  </div> 
                </div>
.intPutClass.put{
    border: 1px solid #f2c63e;
    background: linear-gradient(to left , #f2c63e , #f2c63e)  left top no-repeat ;
  }

三、Vue

1、定时任务,创建和销毁

  created() {
    //轮询刷新页面数据,5秒轮询
    let _this = this
    _this.timer = setInterval(
    function() {
      LcdEvent.initOrderInfo()
    }, 5000 )
  },
  
  beforeDestroy() {
    //销毁
    clearInterval(this.timer)
    this.timer = null
  },

2、页面默认焦点与选中

created() {
    //orderNo为,input的ref
    this.$nextTick(() => {
      this.$refs['orderNo'].$refs.input.focus()
    })
  },

 document.getElementById('orderNo').select()  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值