- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
iptTable规范
规范之HTML
先在当前页面放入几个表格设置按钮的html(样式可能需重新调整)
<div class="bottom_nav1 ta_l"style="padding: 0;height: 32px;width: 300px;margin:4px auto 0;">
<a class="qxfp"ng-click="addRow();"href="javascript:void(0)" >添加货品行</a>
<a class="qxfp"ng-click="cutRow();"href="javascript:void(0)" >减少货品行</a>
<a class="qxfp"ng-click="setTabel()"href="javascript:void(0)" >自定义货品行</a>
<div class="setTableRow"style="display:inline-block;top: 381px;">
<div ng-show="setTabelShow"style="margin:30px 0; bottom:0; top:auto; ">
<div class="listShow"style="height: 250px;">
<div ng-repeat="hd in headList"ng-drop="true"ng-drop-success="onDropComplete($index, $data,$event)">
<label ng-drag="true"ng-drag-data="hd">
<input ng-model="myCheck"type="checkbox"ng-checked="!hd.isHide"ng-click="myChange($index)"/>{{hd.name}}
<br />
</label>
</div>
</div>
<div class="botBtn">
<div class="selectBtn">
<label><input type="checkbox"id="selectAllBtn"ng-model="selectAllModel"ng-click="selectAll()" />全选</label>
<label><input type="checkbox"ng-model="selectBackModel"ng-click="selectBack()" />反选</label>
</div>
<a class="saveBtn"style="width: 40px"ng-click="saveRowSet()"href="javascript:void(0)">保存</a>
<a class="cancelBtn"style="width: 40px"ng-click="cancelRowSet()"href="javascript:void(0)">取消</a>
</div>
</div>
</div>
</div>
由于组件已经标签化,因此我们html导入一个组件化标签
<my-Ipt-Table name="tablaData"></my-Ipt-Table>
标签会引用到iptTable.html
<table width="100%"border="0"cellspacing="0"cellpadding="0"id="myTab"class="yd_table_list xx_kzj"style="table-layout: fixed;">
<tr class="list_header">
<td style="width:90px"ng-repeat="hd in headList"ng-hide="hd.isHide"ng-class="{true:'bj_f83'}[hd.istatol]">{{hd.name}}</td>
</tr>
<tr ng-repeat="data in tableData track by $index">
<!--循环 -->
<td ng-repeat="hd in headList"ng-hide="hd.isHide"style="width:150px;"ipt-repeat-finish>
<div ng-if="hd.type=='diy1'">
<input type="hidden"ng-model= "data[hd.code][modelHid]"/>
<input id="{{data[hd.code].id}}"maxlength="255"type="text"ng-disabled="all"class="form_input input_td co_35a"ng-model="data[hd.code].value"ng-focus="showOrHideGoodsNameSelect($parent.$parent.$index, 1);"ng-blur="showOrHideGoodsNameSelect($parent.$parent.$index, 0);"ng-change="echoData($parent.$parent.$index,hd.code,data[hd.code].value,data[hd.code].model)"/>
<div class="list_xl ng-cloak"style="margin-left: 1px; margin-top: 6px; height: 220px; width: 280px;"ng-show="data[hd.code].showGoodsName">
<h2>请选择常见品名</h2>
<i class="list_xl_icon icon"><a class="gone"href="javascript:void(0)"ng-click="showOrHideGoodsNameSelect($parent.$parent.$index, 0);"></a></i>
<div class="list_xl_tbody">
<table width="100%"border="0"cellspacing="0"cellpadding="0">
<tbody>
<tr ng-repeat="obj in commonGoodsName"ng-click="selectGoodsName($parent.$parent.$parent.$index,obj);">
<td class="ng-cloak"style="width:100%; border-right: 0px;">{{obj.codeValue}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div ng-if="hd.type=='select'"class="yd_select"><select id="{{data[hd.code].id}}"class="xl_z"style="padding: 0 10px 0 5px;"ng-model="data[hd.code].value"ng-disabled="all"ng-options="objCon.codeValue as objCon.codeName for objCon in packTypeData"ng-change="echoData($parent.$parent.$index,hd.code,data[hd.code].value,data[hd.code].model)"></select></div>
<input ng-if="hd.type=='input'"id="{{data[hd.code].id}}"type="text"class="form_input input_td"ng-disabled="all"maxlength="{{data[hd.code].maxlength}}"ng-model="data[hd.code].value"ng-change="goChange($parent.$parent.$index,hd.code,data[hd.code].change,data[hd.code].value,data[hd.code].model)"my-double-val="{{data[hd.code].doubleVal}}"ng-blur="goBlur($parent.$parent.$index,hd.code,data[hd.code].blur)"ng-keyup="goKeyup($parent.$parent.$index,hd.code,data[hd.code].keyup)">
<div ng-if="hd.type=='buttonVolume'"style="position: relative;">
<input id="{{data[hd.code].id}}"type="text"class="form_input input_td"ng-focus="goFocus($parent.$parent.$index,hd.code,data[hd.code].focus);"ng-disabled="all"maxlength="{{data[hd.code].maxlength}}"ng-model="data[hd.code].value"ng-change="goChange($parent.$parent.$index,hd.code,data[hd.code].change,data[hd.code].value,data[hd.code].model)"my-double-val="{{data[hd.code].doubleVal}}"ng-blur="goBlur($parent.$parent.$index,hd.code,data[hd.code].blur);"ng-keyup="goKeyup($parent.$parent.$index,hd.code,data[hd.code].keyup)">
<i class="icon_j"ng-show="volume{{$parent.$parent.$index}}"ng-click="showVolumeAlert($parent.$parent.$index,hd.code);"><img src="../image/$tenantId$/jsj.png"ng-src=""alt=""></i>
</div>
<div ng-if="hd.type=='buttonWeight'"style="position: relative;">
<input id="{{data[hd.code].id}}"type="text"class="form_input input_td"ng-focus="goFocus($parent.$parent.$index,hd.code,data[hd.code].focus);"ng-disabled="all"maxlength="{{data[hd.code].maxlength}}"ng-model="data[hd.code].value"ng-change="goChange($parent.$parent.$index,hd.code,data[hd.code].change,data[hd.code].value,data[hd.code].model)"my-double-val="{{data[hd.code].doubleVal}}"ng-blur="goBlur($parent.$parent.$index,hd.code,data[hd.code].blur);"ng-keyup="goKeyup($parent.$parent.$index,hd.code,data[hd.code].keyup)">
<i class="icon_j"ng-show="weight{{$parent.$parent.$index}}"ng-click="showWeightAlert($parent.$parent.$index,hd.code);"><img src="../image/$tenantId$/jsj.png"ng-src=""alt=""></i>
</div>
</td>
</tr>
<tr>
<td ng-repeat="hd in headList"ng-hide="hd.isHide">{{amountList[hd.code].value == 0 ? '' : amountList[hd.code].value}}</td>
</tr>
</table>
规范之JS:
创建一个head的数组对象(用于遍历table列数)
var head =[
{code:"_goodsName",type:"diy1",name:"货品名",istatol:true},
{code:"_packingType",type:"select",name:"包装",istatol:true},
{code:"_packageCounts",type:"input",name:"包装件数",istatol:true},
{code:"_volume",type:"buttonVolume",name:"体积(方)",istatol:true},
{code:"_volumeUnit",type:"input",name:"体积单价",istatol:false},
{code:"_weight",type:"buttonWeight",name:"重量(千克)",istatol:true},
{code:"_weightUnit",type:"input",name:"重量单价",istatol:false},
{code:"_installCosts",type:"input",name:"配安费",istatol:false},
{code:"_branchFee",type:"input",name:"送货费",istatol:false},
{code:"_mountingCosts",type:"input",name:"安装费",istatol:false},
{code:"_freight",type:"input",name:"运费",istatol:true},
{code:"_discount",type:"input",name:"回扣",istatol:false},
{code:"_collectingMoney",type:"input",name:"代收货款",istatol:false},
{code:"_procedureFee",type:"input",name:"代收手续费",istatol:false},
{code:"_advanceMoney",type:"input",name:"垫付货款",istatol:false},
{code:"_deliveryCosts",type:"input",name:"物流配送费",istatol:false},
{code:"_pickingCosts",type:"input",name:"提货费",istatol:false},
{code:"_actualBillCosts",type:"input",name:"实际提货费",istatol:false},
{code:"_upstairsFee",type:"input",name:"上楼费",istatol:false},
{code:"_goodsPrice",type:"input",name:"申明价值",istatol:false},
{code:"_offer",type:"input",name:"保险费",istatol:false},
{code:"_handingCosts",type:"input",name:"装卸费",istatol:false},
{code:"_packingCost",type:"input",name:"包装费",istatol:false},
{code:"_shortDistanceFee",type:"input",name:"短途费",istatol:false},
{code:"_actualShortDistanceFee",type:"input",name:"实际短途费",istatol:false},
{code:"_installCount",type:"input",name:"安装件数",istatol:false},
{code:"_custOrder",type:"input",name:"订单号",istatol:false},
{code:"_transferCharge",type:"input",name:"中转费",istatol:false}
];
code:与下面数组对象相对应;
type:该列的类型,例如input为输入类型,特殊类型可自行起名,如diy1;
name:该列的名称;
istatol:表头是否有特殊样式,有则true;
之后创建一个tableData数组对象(用于存储每行的信息)
var tableData ={_goodsName:{value:"",name:"货品名",id:"_goodsName0",type:"diy1",maxlength:"255",model:"goodsName",modelHid:"id",showGoodsName:false},
_packingType:{value:"",name:"包装",id:"_packingType0",model:"packingType",value:""},
_packageCounts:{value:"",name:"包装件数",id:"_packageCounts0",type:"input",maxlength:"11",model:"packageCounts",change:"$scope.upNum('form.goodsDetail.goods_i.packageCounts'); $scope.updateCount();"},
_volume:{value:"",name:"体积(方)",id:"_volume0",type:"buttonVolume",model:"volume",maxlength:"8",focus:"$scope.ngFocusShow(1,goods_i)",blur:"$scope.ngBlurShow(1,goods_i)",change:"$scope.calculatePrice();$scope.updateGoodsDetailAmount();$scope.updateTotalCosts();",doubleVal:"keyup"},
_volumeUnit:{value:"",name:"体积单价",id:"_volumeUnit0",type:"input",maxlength:"8",model:"volumeUnit",change:"$scope.calculatePrice();$scope.updateGoodsDetailAmount();$scope.updateTotalCosts();",doubleVal:"keyup"},
_weight:{value:"",name:"重量(千克)",id:"_weight0",type:"buttonWeight",maxlength:"8",model:"weight",focus:"$scope.ngFocusShow(2,goods_i)",blur:"$scope.ngBlurShow(2,goods_i)",change:"$scope.calculatePrice();$scope.updateGoodsDetailAmount();$scope.updateTotalCosts();",doubleVal:"keyup"},
_weightUnit:{value:"",name:"重量单价",id:"_weightUnit0",type:"input",maxlength:"8",model:"weightUnit",change:"$scope.calculatePrice();$scope.updateGoodsDetailAmount();$scope.updateTotalCosts();",doubleVal:"keyup"},
_installCosts:{value:"",name:"配安费",id:"_installCosts0",type:"input",maxlength:"11",model:"installCosts",change:"$scope.updateGoodsDetailAmount();$scope.changeServiceType();$scope.modifyMoney();",doubleVal:"keyup",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();"},
_branchFee:{value:"",name:"送货费",id:"_branchFee0",type:"input",maxlength:"11",model:"branchFee",change:"$scope.updateGoodsDetailAmount();$scope.changeServiceType();$scope.modifyMoney();",doubleVal:"keyup",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();"},
_mountingCosts:{value:"",name:"安装费",id:"_mountingCosts0",type:"input",maxlength:"11",model:"mountingCosts",change:"$scope.updateGoodsDetailAmount();$scope.changeServiceType();$scope.modifyMoney();",doubleVal:"keyup",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();"},
_freight:{value:"",name:"运费",id:"_freight0",type:"input",maxlength:"11",model:"freight",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",doubleVal:"keyup",keyup:"$scope.upCosts('form.goodsDetail.goods_i.freight')",blur:"$scope.updateTotalCosts();$scope.updateGoodsDetailAmount();"},
_discount:{value:"",name:"回扣",id:"_discount0",type:"input",maxlength:"11",model:"discount",change:"$scope.updateGoodsDetailAmount();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_collectingMoney:{value:"",name:"代收货款",id:"_collectingMoney0",type:"input",maxlength:"11",model:"collectingMoney",change:"$scope.updateGoodsDetailAmount();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_procedureFee:{value:"",name:"代收手续费",id:"_procedureFee0",type:"input",maxlength:"11",model:"procedureFee",change:"$scope.updateGoodsDetailAmount();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_advanceMoney:{value:"",name:"垫付货款",id:"_advanceMoney0",type:"input",maxlength:"11",model:"advanceMoney",change:"$scope.updateGoodsDetailAmount();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_deliveryCosts:{value:"",name:"物流配送费",type:"input",maxlength:"11",model:"deliveryCosts",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",doubleVal:"keyup",blur:"$scope.updateGoodsDetailAmount();",keyup:"$scope.upCosts('form.goodsDetail.goods_i.deliveryCosts')"},
_pickingCosts:{value:"",name:"提货费",id:"_pickingCosts0",type:"input",maxlength:"11",model:"pickingCosts",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_actualBillCosts:{value:"",name:"实际提货费",id:"_actualBillCosts0",type:"input",maxlength:"11",model:"actualBillCosts",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_upstairsFee:{value:"",name:"上楼费",type:"input",maxlength:"11",model:"upstairsFee",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateGoodsDetailAmount();",doubleVal:"keyup",keyup:"$scope.upCosts('form.goodsDetail.goods_i.upstairsFee')"},
_goodsPrice:{value:"",name:"申明价值",id:"_goodsPrice0",type:"input",maxlength:"11",model:"goodsPrice",change:"$scope.updateGoodsDetailAmount();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup",keyup:"$scope.upCosts('form.goodsDetail.goods_i.goodsPrice')"},
_offer:{value:"",name:"保险费",id:"_offer0",type:"input",maxlength:"11",model:"offer",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_handingCosts:{value:"",name:"装卸费",id:"_handingCosts0",type:"input",maxlength:"11",model:"handingCosts",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_packingCost:{value:"",name:"包装费",id:"_packingCosts0",type:"input",maxlength:"11",model:"packingCosts",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_shortDistanceFee:{value:"",name:"短途费",id:"_shortDistanceFee0",type:"input",maxlength:"11",model:"shortDistanceFee",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_actualShortDistanceFee:{value:"",name:"实际短途费",id:"_actualShortDistanceFee0",type:"input",maxlength:"11",model:"ctualShortDistanceFee",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();",doubleVal:"keyup"},
_installCount:{value:"",name:"安装件数",id:"_installCount0",type:"input",maxlength:"11",model:"installCount",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",blur:"$scope.updateGoodsDetailAmount();",doubleVal:"keyup",keyup:"$scope.upCosts('form.goodsDetail.goods_i.installCount')"},
_custOrder:{value:"",name:"订单号",id:"_custOrder0",type:"input",model:"custOrder"},
_transferCharge:{value:"",name:"中转费",id:"_transferCharge0",type:"input",maxlength:"11",model:"transferCharge",change:"$scope.updateGoodsDetailAmount();$scope.modifyMoney();",doubleVal:"keyup",blur:"$scope.updateTotalCosts(); $scope.updateGoodsDetailAmount();"}
}
name:该列的名称(方便知道对应的head,可以删除);
value:用于存储输入时的值;(input类型是必填)
id:当前ID(第一行若为_goodsName0,第二行会生成_goodsName1,如此类推);(必填)
maxlength:设置输入位数;
model:当前的model值;(有input是必填)
change:ng-change时需要运行的方法(可动态传参,具见下);
keyup:ng-keyup时需要运行的方法;
focus:ng-focus时需要运行的方法;
blur:ng-blur时需要运行的方法;
之后创建一个amountList数组对象(用于表格脚部的费用统计)
var amountList ={
_goodsName:{name:"货品名",value:"合计"},
_packingType:{name:"包装",value:""},
_packageCounts:{name:"包装件数",value:""},
_volume:{name:"体积(方)",value:""},
_volumeUnit:{name:"体积单价",value:""},
_weight:{name:"重量(千克)",value:""},
_weightUnit:{name:"重量单价",value:""},
_installCosts:{name:"配安费",value:""},
_freight:{name:"运费",value:""},
_branchFee:{name:"送货费",value:""},
_mountingCosts:{name:"安装费",value:""},
_discount:{name:"回扣",value:""},
_collectingMoney:{name:"代收货款",value:""},
_procedureFee:{name:"代收手续费",value:""},
_advanceMoney:{name:"垫付货款",value:""},
_deliveryCosts:{name:"物流配送费",value:""},
_pickingCosts:{name:"提货费",value:""},
_actualBillCosts:{name:"实际提货费",value:""},
_upstairsFee:{name:"上楼费",value:""},
_goodsPrice:{name:"申明价值",value:""},
_offer:{name:"保险费",value:""},
_handingCosts:{name:"装卸费",value:""},
_packingCosts:{name:"包装费",value:""},
_shortDistanceFee:{name:"短途费",value:""},
_actualShortDistanceFee:{name:"实际短途费",value:""},
_installCount:{name:"安装件数",value:""},
_custOrder:{name:"订单号",value:""},
_transferCharge:{name:"中转费",value:""}
}
name:该列的名称(方便知道对应的head,可以删除);
value:统计的数值;
在当前页面angular的controller方法,我们需要做点事情
$scope.rowLength = 2; //table初始行数
$scope.headList =head;
$scope.amountList = amountList;
controller一开始的时候还需要运行一下这方法生成我们的tableData(该方法可以用于重新初始化表格信息)
initTableData : function(){
$scope.tableData =[];
var tableDataCopy =[];
for(var i=0;i<$scope.rowLength;i++){
var obj = $.extend(true,{},tableData);
for(o inobj){
var id = o +i;
obj[o].id = id; //重新生成对应的ID
if(obj[o].keyup != undefined){ //方法动态传参
var keyup = "$scope.upCosts('form.goodsDetail.goods_" + i + "." + obj[o].model +"')"obj[o].keyup =keyup;
}
}
tableDataCopy.push(obj);
}
$scope.tableData =tableDataCopy;
for(var i=0;i<$scope.tableData.length;i++){
var name = "goods_" +i;
if($scope.form.goodsDetail[name] ==undefined){
$scope.form.goodsDetail[name] ={};
}
}
},
change、keyup等动态传参方法可参照这里
var keyup = "$scope.upCosts('form.goodsDetail.goods_" + i + "." + obj[o].model +"')"
其中i表示行数(第一行为0,第二行为1)
另外我们需要用到第三方插件ngDraggable,因此当前页面需要引用ngDraggable.js
<script type="text/javascript"src="../js/ngDraggable.js"></script>
除此之外我们单独创建了一个该组件js文件,iptTable.js
开始我们先导入ngDraggable插件
var iptTable = angular.module("iptTable", ["ngDraggable"]);
之后为my-Ipt-Table创建一个指令方法
iptTable.directive('myIptTable', function() {
return{
restrict:"E",
templateUrl : function(tElement, tAttrs) {
return '/js/table/iptTable.html?ver='+tAttrs.ver; //请填写您iptTTable.html的路径
},
scope:function(){
},
controller : [ "$scope", "commonService", "$timeout","$interval",
function($scope, commonService, $timeout,$interval){
var table ={
init : function(){
$scope.goChange = this.goChange;
$scope.goBlur = this.goBlur;
$scope.goKeyup = this.goKeyup;
$scope.addRow = this.addRow;
$scope.cutRow = this.cutRow;
$scope.goFocus = this.goFocus;
$scope.echoData = this.echoData;
$scope.clearRowData = this.clearRowData;
this.setRow();
},
echoData : function(index,code,value,model){ //同步form与tableData的数据
var goods = "goods_" +index;
if(value == 0){
$scope.tableData[index][code].value = "";
}else{
$scope.tableData[index][code].value =value;
}
if($scope.form.goodsDetail[goods] ==undefined){
$scope.form.goodsDetail[goods] ={};
$scope.form.goodsDetail[goods][model] =value;
}else{
$scope.form.goodsDetail[goods][model] =value;
}
//console.log($scope.form.goodsDetail[goods][model]);
},
goChange : function(index,code,change,value,model){
//console.log(index+','+code+','+change+','+value+','+model);
if(change !=undefined){
var goods = "goods_" +index;
change = change.replace(/goods_i/g,goods); //如果方法里有传参,替换goods_i;
$scope.tableData[index][code].change =change;
$scope.echoData(index,code,value,model);
var func =$scope.tableData[index][code].change;
eval(func)
}
},
goBlur : function(index,code,blur){
if(blur !=undefined){
blur = blur.replace(/goods_i/g,index); //如果方法里有传参,替换goods_i;
$scope.tableData[index][code].blur =blur;
var func =$scope.tableData[index][code].blur;
eval(func)
}
},
goFocus : function(index,code,focus){
if(focus !=undefined){
focus = focus.replace(/goods_i/g,index); //如果方法里有传参,替换goods_i;
$scope.tableData[index][code].focus =focus;
var func =$scope.tableData[index][code].focus;
eval(func)
}
},
goKeyup : function(index,code,keyup){
if(keyup !=undefined){
var func =$scope.tableData[index][code].keyup;
eval(func)
}
},
addRow : function(){
var obj = $.extend(true,{},tableData);
var index =$scope.tableData.length;
for(o inobj){
var id = o +index;
obj[o].id =id;
if(obj[o].keyup !=undefined){
var keyup = "$scope.upCosts('form.goodsDetail.goods_" + index + "." + obj[o].model +"')"obj[o].keyup =keyup;
}
}
$scope.tableData.push(obj);
var name = "goods_" +index;
$scope.form.goodsDetail[name] ={};
$timeout(function(){
setContentHeight();
},300);
//重新绑定快捷键
$scope.registerKeyEvent()
},
cutRow : function(){
var tbIndex = $scope.tableData.length-1;
$scope.clearRowData(tbIndex);
var name = "goods_" +tbIndex;
$scope.tableData.splice(tbIndex,1);
$scope.form.goodsDetail[name] ={};
$scope.goChange();
$timeout(function(){
setContentHeight();
},300);
},
clearRowData : function(tbIndex){
for(var obj in$scope.tableData[tbIndex]){
$scope.echoData(tbIndex,obj,0,$scope.tableData[tbIndex][obj].model);
}
},
setRow : function(){
//请求后台回去列显示信息
var headList = window.top.tableHead["goodsRow"];
if(typeof headList != "undefined" && headList != null && headList != ""){
for(var i in$scope.headList){
var hd =$scope.headList[i];
$scope.headList[i].isHide = true;
if(headList.hasOwnProperty(hd.name+"#"+hd.code)){
$scope.headList[i].isHide = false;
}
}
var list=[];
for(var i in$scope.headList){
var hd =$scope.headList[i];
list.push(hd);
}
for(var i inlist){
var hd =list[i];
if(headList.hasOwnProperty(hd.name+"#"+hd.code)){
var index = parseInt(headList[hd.name+"#"+hd.code]);
var otherObj =$scope.headList[index];
var otherIndex =$scope.headList.indexOf(hd);
$scope.headList[index] =hd;
$scope.headList[otherIndex] =otherObj;
}
}
}
//列表设置显示隐藏
$scope.setTabelShow = false;
$scope.setTabel = function(){
isSelectAll()
if($scope.setTabelShow){
$scope.setTabelShow = false;
}else{
$scope.setTabelShow = true;
}
}
//保存表格设置
$scope.saveRowSet = function(){
var headConfig={};
headConfig.tableName ="goodsRow";
headConfig.sysTableHeadConfigList =[];
$scope.tableHeadValue ={};
//组装要保存的table,目前保存需要显示的
for(var i in$scope.headList){
var hd =$scope.headList[i];
if(!hd.isHide){
var tableHeadConfig ={};
tableHeadConfig.headName =hd.name;
tableHeadConfig.headCode =hd.code;
tableHeadConfig.headIndex =i;
headConfig.sysTableHeadConfigList.push(tableHeadConfig);
$scope.tableHeadValue[hd.name+"#"+hd.code]=i;
}
}
var param ={};
param.paramStr =JSON.stringify(headConfig);
var url = "sysTableHeadConfigBO.ajax?cmd=saveSysTableHeadConfigs";
commonService.postUrl(url,param,function(data){
commonService.alert("保存完成!",function(){
$scope.setTabelShow = false;
//更新头部的参数
window.top.tableHead[$scope.tableName]=$scope.tableHeadValue;
$scope.$apply();
});
});
}
//取消保存
$scope.cancelRowSet = function(){
$scope.setTabelShow = false;
}
//显示隐藏列
$scope.myChange = function(index){
if($scope.headList[index].isHide){
$scope.headList[index].isHide = false;
}else{
$scope.headList[index].isHide = true;
}
isSelectAll();
}
//拖动调整
$scope.onDropComplete = function(index, obj, evt) {
var otherObj =$scope.headList[index];
var otherIndex =$scope.headList.indexOf(obj);
$scope.headList.splice(otherIndex,1);
$scope.headList.splice(index,0,obj);
}
//全选
$scope.selectAll = function(){
for(var i in$scope.headList){
$scope.headList[i].isHide = false;
}
}
//反选
$scope.selectBack = function(){
for(var index in$scope.headList){
if($scope.headList[index].isHide){
$scope.headList[index].isHide = false;
}else{
$scope.headList[index].isHide = true;
}
}
isSelectAll()
}
//判断是否全选
functionisSelectAll(){
var isAll = true;
for(var i in$scope.headList){
if($scope.headList[i].isHide){
isAll = false;
$("#selectAllBtn").prop({checked:false});
}
}
if(isAll){
$("#selectAllBtn").prop({checked:true});
}
}
}
}
table.init();
}],
};
});
各个方法的用处:
init:初始化;
echoData:同步form与tableData的数据(如今与页面输入绑定的值为tableData的value,但是为了不改变原来联运汇的数据结构,因此页面数据改变时需同步改变form对应的值,对于新项目建议直接操作tableData的value);
goChange、goBlur、goFocus、goKeyup:运行ng-Change、ng-Blur、ng-Focus、ng-Keyup,如需方法动态传参也可参考这里;
addRow:增加一行,与initTableData方法相似;
cutRow:减少一行;
clearRowData:清除当前一行所有数据;
setRow:表格设置;
最后还有一个表格宽度拖拽,首先需要判断一下ng-repeat是否结束
html(一开始的html其实已经有写):
<td ng-repeat="hd in headList"ng-hide="hd.isHide"style="width:150px;"ipt-repeat-finish></td>
iptTable.js:
//判断是否渲染完毕
iptTable.directive('iptRepeatFinish',function(){
return{
link: function($scope,element,attr){
if($scope.$last == true){
stretch($scope);
}
}
}
});
//表单列宽自由拖动
functionstretch($scope){
var myTAbId = document.getElementById("myTab");
var tTD; //用来存储当前更改宽度的Table Cell,避免快速移动鼠标的问题
var wData ={};
for (var j = 0; j < myTAbId.rows[0].cells.length; j++) {
myTAbId.rows[0].cells[j].onmousedown = function(event) {
//记录单元格
tTD = this;
if (event.offsetX > tTD.offsetWidth - 10) {
tTD.mouseDown = true;
tTD.oldX =event.clientX;
tTD.oldWidth =tTD.offsetWidth;
}
//记录Table宽度
//table = tTD; while (table.tagName != ‘TABLE') table = table.parentElement;
//tTD.tableWidth = table.offsetWidth;
};
myTAbId.rows[0].cells[j].onmouseup = function(event) {
//结束宽度调整
if (tTD == undefined) tTD = this;
tTD.mouseDown = false;
tTD.style.cursor = 'default';
};
myTAbId.rows[0].cells[j].onmousemove = function(event) {
//更改鼠标样式
if (event.offsetX > this.offsetWidth - 10)
this.style.cursor = 'col-resize';
else
this.style.cursor = 'default';
//取出暂存的Table Cell
if (tTD == undefined) tTD = this;
//调整宽度
if (tTD.mouseDown != null && tTD.mouseDown == true) {
tTD.style.cursor = 'default';
if (tTD.oldWidth + (event.clientX - tTD.oldX)>0)
tTD.width = tTD.oldWidth + (event.clientX -tTD.oldX);
//调整列宽
tTD.style.width =tTD.width;
tTD.style.cursor = 'col-resize';
//myTAbId.rows[8].cells[j].style.width = tTD.width;
//调整该列中的每个Cell
myTAbId = tTD; while (myTAbId.tagName != 'TABLE') myTAbId =myTAbId.parentElement;
for (var k = 0; k < myTAbId.rows.length; k++) {
myTAbId.rows[k].cells[tTD.cellIndex].width =tTD.width;
}
//调整整个表
//table.width = tTD.tableWidth + (tTD.offsetWidth – tTD.oldWidth);
//table.style.width = table.width;
}
};
}
}
我们有一个 Java 项目,每天晚上使用 TeamCity 对 Java 类进行静态分析,以查找代码中容易出现的错误。我们想告诉 TeamCity 寻找开发人员可能引入的与 == 与 .equals
Promises/A+ 这是一个开放标准,旨在让不同开发者实现的 JavaScript Promise 能够无缝衔接并应用——由前辈们制定,为其他后来者提供参考 一个 promise 所
前言 🍊缘由 Git分支管理好,走到哪里都是宝 🏀事情起因: 最近翻看博客中小伙伴评论时,发现文章【规范】看看人家Git提交描述,那叫一个规矩一条回复: 本狗亲测在我司中使用规范
使用带有不存在的命名空间的命名空间限定关键字来定义规范是否被认为是不好的做法?我想在公共(public) domain 命名空间中定义实体映射...所以为了避免在合并规范时丢失数据,我使用约定 :en
有没有办法在调用 clojure.spec.test.alpha/check 时覆盖核心谓词函数的生成器? 可以通过 s/gen 中的路径覆盖谓词生成器: (gen/generate (s/gen
以内核 rpm 为例,它允许在一个系统上同时安装多个版本。规范文件中究竟是什么允许的? 我想打包一个已经存在的具有不同安装前缀的多个版本的项目。 最佳答案 百胜 找到了让 yum 安装而不是更新的方法
我正在尝试用 C# 编写 PDF 解析器,但我遇到了一个问题,我不确定如何解释规范。 除非另有说明,否则 PDF 文档中的用户空间为 1/72 英寸(即 1pt)。 Tf 运算符提供的比例将字体从标准
我正在编写一些代码,需要能够获取两个 pdf 并将它们附加到页面级别(例如,如果它们都是 2 页文档,则有一个 4 页文档,其中所有 4 页都与原始文档相同). 在不使用库的情况下,最好的方法是什么?
是否有序言语言语法,或接近它的通常用作引用的东西?我正在使用 SWI-prolog,所以有一个适合这种风格的会很好,否则一般的 prolog 语言语法/规范也能工作。 最佳答案 自 1995 年起,P
我需要一个函数来过滤参数和构建查询。我有 4 个参数,因此如果我尝试为每个条件实现查询,我将不得不写 16 (2^4)实现 - 这不是一个好主意。 我尝试使用界面改进我的代码 Specificatio
这个 ExtGState 对象对图像做了什么: > 我有 PDF 规范,但一点也不清楚。显然,这将身份函数(什么的身份?单位矩阵?)从 [0.0 1.0] 映射到 [0.0 1.0](相同),这是没有
只是想获得有关 ePub 规范的一些帮助。toc.ncx 是否必须具有 src(即 xhtml)。我观察到 .opf 文件中也提供了相同的内容 src。 最佳答案 是的,这是强制性的,这是一个设计问题
让我们看看莱宁根项目 map 的真实示例 :global-vars : ;; Sets the values of global vars within Clojure. This example
我正在开发一个 LOB 框架,它具有 SL 和 MVC 前端、WCF 后端以及在服务器上运行的几个服务模块。我一直在查看 Spec#,看它是否对我有任何帮助。不可空类型和检查异常本身非常好,但我还没有
Promises/A+规范是最小的规范之一。因此,实现它是理解它的最佳方法。福布斯·林德赛(Forbes Lindesay)的以下回答将引导我们完成实现Promises / A +规范Basic Ja
哪个文档指定了 MySQL definer 格式? 具体来说,definer admin@% 中的 % 是什么意思(以及为什么使用这个符号)? 最佳答案 这里MySQL使用的格式定义在the MySQ
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
在 css 规范中,什么会影响更多的 inline 样式或外部 !important 外部“style.css”: #di{color: green!important;} div 文本颜色是红色还
我正在努力思考 CSS 的一些细节,我从 W3 CSS Visual Formatting Spec 9.2.2 中找到了这部分摘录。特别迟钝: Inline-level boxes that are
这个问题在这里已经有了答案: Are (non-void) self-closing tags valid in HTML5? (8 个答案) 关闭 9 年前。 在 HTML5 中你应该使用 或
我是一名优秀的程序员,十分优秀!