You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
2.7 KiB
128 lines
2.7 KiB
var referenceDrawing = function (item, planList) {
|
|
|
|
if (!item || !planList || !planList.length > 0) {
|
|
return []
|
|
}
|
|
|
|
|
|
// console.log("item====item", JSON.stringify(item))
|
|
|
|
// console.log("planList====planList", JSON.stringify(planList))
|
|
|
|
var planTypeObj = {}
|
|
for (var index = 0; index < planList.length; index++) {
|
|
var element = planList[index];
|
|
if (element.allPlan.length > 0) {
|
|
for (var indexItem = 0; indexItem < element.allPlan.length; indexItem++) {
|
|
var elementItem = element.allPlan[indexItem];
|
|
if (elementItem.id == item.id) {
|
|
planTypeObj = element
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// console.log("planTypeObj===planTypeObj", JSON.stringify(planTypeObj))
|
|
|
|
var planNameObj = {}
|
|
if(planTypeObj.allPlan&&planTypeObj.allPlan.length){
|
|
for (var index = 0; index < planTypeObj.allPlan.length; index++) {
|
|
var element = planTypeObj.allPlan[index];
|
|
if (element.id == item.id) {
|
|
planNameObj = element
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
var list = []
|
|
if (planNameObj.attach && planNameObj.attach_name) {
|
|
list.push({
|
|
"name": planNameObj.attach_name,
|
|
"path": planNameObj.attach
|
|
})
|
|
}
|
|
|
|
if (planNameObj.attach2 && planNameObj.attach_name2) {
|
|
list.push({
|
|
"name": planNameObj.attach_name2,
|
|
"path": planNameObj.attach2
|
|
})
|
|
}
|
|
|
|
|
|
// console.log("===================================", JSON.stringify(list))
|
|
|
|
return list
|
|
}
|
|
|
|
var formartFileName = function(url){
|
|
var fName = url;
|
|
fName = fName.trim();
|
|
return fName.substring(fName.lastIndexOf("/")+1)
|
|
}
|
|
|
|
var itemListLen = function(arr, materialModel, str){
|
|
var newArr = []
|
|
arr.forEach(function(item){
|
|
if(item.model === materialModel && item.spec === str){
|
|
newArr.push(item)
|
|
}
|
|
})
|
|
if(newArr.length>0){
|
|
return newArr[0].itemList.length
|
|
}else{
|
|
return 0
|
|
}
|
|
}
|
|
|
|
var findItem = function(key, value, arr){
|
|
if (!arr.length > 0) {
|
|
return []
|
|
}
|
|
var item = [];
|
|
for(var i = 0; i<arr.length; i++){
|
|
if(arr[i][key] === value){
|
|
item = arr[i]
|
|
}
|
|
}
|
|
return item
|
|
}
|
|
var filterItem = function(key, value, arr){
|
|
if (!(arr && arr.length > 0)) {
|
|
return []
|
|
}
|
|
var item = [];
|
|
for(var i = 0; i<arr.length; i++){
|
|
if(arr[i][key]*1 >= value){
|
|
item.push(arr[i])
|
|
}
|
|
}
|
|
return item
|
|
}
|
|
|
|
var toFixedNum = function(num, len=2){
|
|
var numStr = num*1;
|
|
return numStr.toFixed(len)
|
|
}
|
|
|
|
var platformCheck = function(perm, permList){
|
|
var isCheck = false
|
|
permList.forEach(function(item){
|
|
if(item === perm){
|
|
isCheck = true
|
|
}
|
|
})
|
|
return isCheck
|
|
}
|
|
|
|
module.exports = {
|
|
referenceDrawing: referenceDrawing,
|
|
formartFileName: formartFileName,
|
|
itemListLen: itemListLen,
|
|
toFixedNum: toFixedNum,
|
|
findItem: findItem,
|
|
filterItem: filterItem,
|
|
platformCheck:platformCheck
|
|
} |