|
|
@@ -267,7 +267,7 @@
|
|
|
<i class="fa fa-spinner fa-spin"></i>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="h-100 txt-sty w-100 el-center" :class="element.turn ? 're' : ''" v-else>@{{ element.code | removePrefix }}</div>
|
|
|
+ <div class="h-100 txt-sty w-100 el-center" :class="element.turn ? 're' : ''" v-else>@{{ element.code}}</div>
|
|
|
</vue-drag-resize>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -378,6 +378,16 @@
|
|
|
}
|
|
|
return layer;
|
|
|
},
|
|
|
+ flipChildren(){
|
|
|
+ if(!this.current.children){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ let children = [];
|
|
|
+ for (let i=this.current.children.length - 1;i>=0;i--){
|
|
|
+ children.push(this.current.children[i]);
|
|
|
+ }
|
|
|
+ return children;
|
|
|
+ },
|
|
|
},
|
|
|
created: function() {
|
|
|
let content = document.getElementById("canvasApp");
|
|
|
@@ -411,6 +421,87 @@
|
|
|
};
|
|
|
},
|
|
|
methods:{
|
|
|
+ //仓库切换
|
|
|
+ selectedWarehouse(warehouse){
|
|
|
+ this.isLoad = false;
|
|
|
+ setTimeout(()=>{
|
|
|
+ this.selected = warehouse.id;
|
|
|
+ this.name = warehouse.name;
|
|
|
+ this.ratio = warehouse.ratio;
|
|
|
+ this.container = {width:warehouse.length*this.ratio,height:warehouse.width*this.ratio};
|
|
|
+ localStorage.setItem("equipment:warehouse", warehouse.id);
|
|
|
+ $.ajax({
|
|
|
+ url : this.baseUrl+"warehouse/detail/getCoordsInfo",
|
|
|
+ type : "post",
|
|
|
+ dataType : "JSON",
|
|
|
+ data : {id:warehouse.id},
|
|
|
+ success : (res,status)=>{
|
|
|
+ this.elements = res.data[0] ? JSON.parse(res.data[0]) : [];
|
|
|
+ if(res.data[1] && res.data[1].length>0){
|
|
|
+ let equipmentElements = [];
|
|
|
+ res.data[1].forEach(eq=>{
|
|
|
+ let coords = JSON.parse(eq.info);
|
|
|
+ let selfInfo = this.equipments[coords.id-1];
|
|
|
+ equipmentElements.push(Object.assign({
|
|
|
+ eqId:eq.id,
|
|
|
+ exist:eq.exist,
|
|
|
+ code:eq.code,
|
|
|
+ width:eq.width,
|
|
|
+ depth:eq.depth,
|
|
|
+ repository:eq.repositoryId,
|
|
|
+ x:coords.x,
|
|
|
+ y:coords.y,
|
|
|
+ turn:!!coords.turn,
|
|
|
+ },selfInfo));
|
|
|
+ });
|
|
|
+ this.equipmentElements = equipmentElements;
|
|
|
+ }else this.equipmentElements = [];
|
|
|
+ this.repositories = res.data[2];
|
|
|
+ this.isNotEdit = true;
|
|
|
+ this.isLoad = true;
|
|
|
+ },
|
|
|
+ error : (err,status)=>{
|
|
|
+ window.tempTip.show("坐标信息加载失败");
|
|
|
+ },
|
|
|
+ timeout:3000,
|
|
|
+ })
|
|
|
+ },200);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 初始页加载
|
|
|
+ */
|
|
|
+ initPage(){
|
|
|
+ $.ajax({
|
|
|
+ url : this.baseUrl+"warehouse/detail",
|
|
|
+ type : "GET",
|
|
|
+ success : (res,status)=>{
|
|
|
+ this.warehouses = res.data;
|
|
|
+ //这里获取warehouses
|
|
|
+ let id = localStorage.getItem("equipment:warehouse");
|
|
|
+ if (!id || !this.warehouses.some(warehouse=>{
|
|
|
+ if (warehouse.id == id){
|
|
|
+ this.selectedWarehouse(warehouse);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ){
|
|
|
+ if (this.warehouses.length>0)this.selectedWarehouse(this.warehouses[0]);
|
|
|
+ }
|
|
|
+ $("#loading").hide();
|
|
|
+ },
|
|
|
+ error : (err,status)=>{
|
|
|
+ window.tempTip.show("加载失败");
|
|
|
+ },
|
|
|
+ timeout:3000,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ flipArr(arr){
|
|
|
+ let flip = [];
|
|
|
+ for (let i=arr.length-1;i>=0;i--){
|
|
|
+ flip.push(arr[i]);
|
|
|
+ }
|
|
|
+ return flip;
|
|
|
+ },
|
|
|
loadElement(){
|
|
|
if (this.isShowRatio===undefined){
|
|
|
this.isShowRatio = true;
|
|
|
@@ -710,31 +801,6 @@
|
|
|
timeout:10000,
|
|
|
})
|
|
|
},
|
|
|
- initPage(){
|
|
|
- $.ajax({
|
|
|
- url : this.baseUrl+"warehouse/detail",
|
|
|
- type : "GET",
|
|
|
- success : (res,status)=>{
|
|
|
- this.warehouses = res.data;
|
|
|
- //这里获取warehouses
|
|
|
- let id = localStorage.getItem("equipment:warehouse");
|
|
|
- if (!id || !this.warehouses.some(warehouse=>{
|
|
|
- if (warehouse.id == id){
|
|
|
- this.selectedWarehouse(warehouse);
|
|
|
- return true;
|
|
|
- }
|
|
|
- })
|
|
|
- ){
|
|
|
- if (this.warehouses.length>0)this.selectedWarehouse(this.warehouses[0]);
|
|
|
- }
|
|
|
- $("#loading").hide();
|
|
|
- },
|
|
|
- error : (err,status)=>{
|
|
|
- window.tempTip.show("加载失败");
|
|
|
- },
|
|
|
- timeout:3000,
|
|
|
- })
|
|
|
- },
|
|
|
//备选设备拖拽按下事件
|
|
|
eqDown(equipment){
|
|
|
if (this.isNotEdit)return;
|
|
|
@@ -860,52 +926,6 @@
|
|
|
this.currentEl.updateCoords = true;
|
|
|
$("#canvas").focus();
|
|
|
},
|
|
|
- //仓库切换
|
|
|
- selectedWarehouse(warehouse){
|
|
|
- this.isLoad = false;
|
|
|
- setTimeout(()=>{
|
|
|
- this.selected = warehouse.id;
|
|
|
- this.name = warehouse.name;
|
|
|
- this.ratio = warehouse.ratio;
|
|
|
- this.container = {width:warehouse.length*this.ratio,height:warehouse.width*this.ratio};
|
|
|
- localStorage.setItem("equipment:warehouse", warehouse.id);
|
|
|
- $.ajax({
|
|
|
- url : this.baseUrl+"warehouse/detail/getCoordsInfo",
|
|
|
- type : "post",
|
|
|
- dataType : "JSON",
|
|
|
- data : {id:warehouse.id},
|
|
|
- success : (res,status)=>{
|
|
|
- this.elements = res.data[0] ? JSON.parse(res.data[0]) : [];
|
|
|
- if(res.data[1] && res.data[1].length>0){
|
|
|
- let equipmentElements = [];
|
|
|
- res.data[1].forEach(eq=>{
|
|
|
- let coords = JSON.parse(eq.info);
|
|
|
- let selfInfo = this.equipments[coords.id-1];
|
|
|
- equipmentElements.push(Object.assign({
|
|
|
- eqId:eq.id,
|
|
|
- exist:eq.exist,
|
|
|
- code:eq.code,
|
|
|
- width:eq.width,
|
|
|
- depth:eq.depth,
|
|
|
- repository:eq.repositoryId,
|
|
|
- x:coords.x,
|
|
|
- y:coords.y,
|
|
|
- turn:!!coords.turn,
|
|
|
- },selfInfo));
|
|
|
- });
|
|
|
- this.equipmentElements = equipmentElements;
|
|
|
- }else this.equipmentElements = [];
|
|
|
- this.repositories = res.data[2];
|
|
|
- this.isNotEdit = true;
|
|
|
- this.isLoad = true;
|
|
|
- },
|
|
|
- error : (err,status)=>{
|
|
|
- window.tempTip.show("坐标信息加载失败");
|
|
|
- },
|
|
|
- timeout:3000,
|
|
|
- })
|
|
|
- },200);
|
|
|
- },
|
|
|
//文本类属性改变
|
|
|
changeText(key){
|
|
|
this.currentEl[key] = event.target.value;
|
|
|
@@ -968,6 +988,10 @@
|
|
|
$("#locationModal").modal("show");
|
|
|
},20);
|
|
|
let children = this.current.children[this.currentEqChildIndex];
|
|
|
+ this.current.children.forEach(item=>{
|
|
|
+ item.row = Number(item.row);
|
|
|
+ item.column = Number(item.column);
|
|
|
+ });
|
|
|
$.ajax({
|
|
|
url : this.baseUrl+"location/get",
|
|
|
type : "post",
|
|
|
@@ -1052,9 +1076,15 @@
|
|
|
switch (res.code){
|
|
|
case 200:
|
|
|
equipment.eqId = res.data[0];
|
|
|
+ let locCount = 0;
|
|
|
equipment.children.forEach((item,index)=>{
|
|
|
item.id = res.data[1][index];
|
|
|
- })
|
|
|
+ if (item.row && Number(item.row) > 0){
|
|
|
+ locCount += Number(item.row) * Number(item.column)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ equipment.exist = locCount;
|
|
|
+ this.$forceUpdate();
|
|
|
$("#detailInfo").modal("hide");
|
|
|
window.toast.success("保存成功");
|
|
|
break;
|
|
|
@@ -1062,14 +1092,15 @@
|
|
|
this.error = res.data;
|
|
|
break;
|
|
|
case 414:
|
|
|
- this.error = {"code":"设备编码重复"};
|
|
|
- this.toast.error(this.error.code);
|
|
|
+ this.error = {code:"设备编码重复"};
|
|
|
+ window.toast.error(this.error.code);
|
|
|
break;
|
|
|
default:
|
|
|
window.toast.error("服务器错误:"+res.message);
|
|
|
}
|
|
|
},
|
|
|
error : (err)=>{
|
|
|
+ console.error(err);
|
|
|
window.tempTip.setIndex(999);
|
|
|
window.tempTip.show("网络错误");
|
|
|
},
|
|
|
@@ -1081,7 +1112,6 @@
|
|
|
if (!equipment.code)error.code = "设备编号未填写";
|
|
|
if (!equipment.width)error.width = "设备宽度未填写";
|
|
|
if (!equipment.depth)error.depth = "设备深度未填写";
|
|
|
- //if (!equipment.repository)error.repositoryId = "设备库区未选定";
|
|
|
if (equipment.layer !== equipment.children.length)error.children = "设备绑定错误";
|
|
|
for (let i=0;i<equipment.layer;i++){
|
|
|
if (!equipment.children[i].height)error["children["+i+"].height"] = "设备高度不得为空"
|
|
|
@@ -1191,7 +1221,7 @@
|
|
|
}
|
|
|
if (this.isLoadLocation)return;
|
|
|
let eq = this.current.children[this.currentEqChildIndex];
|
|
|
- let code = this.current.code+'-'+((this.currentEqChildIndex+1)<10 ? '0'+(this.currentEqChildIndex+1) : (this.currentEqChildIndex+1));
|
|
|
+ let code = this.current.code+'-'+(this.currentEqChildIndex+1);
|
|
|
this.isLoadLocation = true;
|
|
|
$.ajax({
|
|
|
url : this.baseUrl+"location/locationBind",
|
|
|
@@ -1206,7 +1236,8 @@
|
|
|
window.toast.success("构建成功!");
|
|
|
this.current.children[this.currentEqChildIndex].row = Number(this.buildPool.row);
|
|
|
this.current.children[this.currentEqChildIndex].column = Number(this.buildPool.column);
|
|
|
- this.buildPool = {};
|
|
|
+ this._locationAttrDefault();
|
|
|
+ $("#locationModal").modal("hide");
|
|
|
this.$forceUpdate();
|
|
|
break;
|
|
|
default:
|
|
|
@@ -1325,6 +1356,7 @@
|
|
|
case 200:
|
|
|
this.repositories.push(res.data);
|
|
|
$("#repository").modal("hide");
|
|
|
+ this.repository = {};
|
|
|
break;
|
|
|
default:
|
|
|
window.toast.error("库区建立失败");
|
|
|
@@ -1377,9 +1409,6 @@
|
|
|
formatCount(tab){
|
|
|
let arr = tab.split("-");
|
|
|
return arr[0]*arr[1];
|
|
|
- },
|
|
|
- removePrefix(code){
|
|
|
- return code.slice(3);
|
|
|
}
|
|
|
}
|
|
|
});
|