angular.module('push')
.controller('inputFormCtrl', ['$scope', '$ionicActionSheet', '$sce', '$ionicPopup', '$ionicLoading', '$stateParams', 'UserService', 'UtilService', 'roleService', 'ConstantService', '$timeout', '$ionicScrollDelegate', 'ActivityService', 'TechnicalBrokerPublishTrainService', 'dataToolsService', '$state', '$ionicSlideBoxDelegate', 'CommonService', 'ionicDatePicker', '$interval', function ($scope, $ionicActionSheet, $sce, $ionicPopup, $ionicLoading, $stateParams, UserService, UtilService, roleService, ConstantService, $timeout, $ionicScrollDelegate, ActivityService, TechnicalBrokerPublishTrainService, dataToolsService, $state, $ionicSlideBoxDelegate, CommonService, ionicDatePicker, $interval) {
console.log($scope.fatherdata)
$scope.connEnterpriseModuleMode = {};
$scope.fatherdata.imagelist = [];
// $scope.tempdata=[];
$scope.delimagelist = [];
$scope.isRelateUl = false;
var upOrdown = 0;
$scope.defaultLan = UserService.defaultLan;
// //TODO 设置IOS状态栏
// $scope.setStatusBar = function (flg) {
// if (device.platform != "Android") {
// if (flg == 0) {
// StatusBar.styleDefault();//黑色
// } else {
// StatusBar.styleLightContent();//白色
// }
// }
// };
$scope.setStatusBar = function (flg) {
if (device.platform != "Android") {
if (flg == 0) {
StatusBar.styleDefault();//黑色
} else {
StatusBar.styleLightContent();//白色
}
}
};
//加载动画
$scope.showLoadingToast = function () {
$ionicLoading.show({
template: '',
content: '努力加载中',
animation: 'fade-in',
showBackdrop: false,//是否显示蒙层
maxWidth: 150,
showDelay: 0
});
// $timeout(function () {
// $ionicLoading.hide();
// }, 15000);
$scope.isShowLoadingSvg = false;
};
//关闭加载动画
$scope.hideLoadingToast = function () {
$ionicLoading.hide();
$scope.isShowLoadingSvg = true;
};
$scope.showrichbox = function () {
CKEDITOR.replace('editor');
};
$scope.showrichbox1 = function (index1) {
CKEDITOR.replace(index1 + "");
};
var getSelectListItems = function (val, upOrdown) {
//政策库
if (val.resinnertype == 34) {
val.dictionarytype = 35184;
}
val.dictionary = val.dictionary || 0;
if (val.dictionarytype == 30050 || val.dictionarytype == 305150) {
console.log(val);
dataToolsService.getTypeEntryListByTypeName(val.dictionary).then(function (response) {
if (UtilService.isDefined(response.data) && response.data.length > 0) {
val.list = [];
angular.forEach(response.data, function (value, ind) {
var temphtml = {
text: '' + value.itemkey + '',
itemkey: value.itemvalue,
itemvalue: value.itemkey
};
val.itemIndex = value.itemkey == val.content ? value.itemvalue : val.itemIndex;
val.list.push(temphtml);
});
}
}, function () {
})
} else if (val.dictionarytype == 30051) {
dataToolsService.getYearMultiSetupList(val.dictionary).then(function (response) {
if (UtilService.isDefined(response.data) && response.data.length > 0) {
val.list = [];
angular.forEach(response.data, function (value, ind) {
var temphtml = {
text: '' + value.setupname + '',
itemkey: value.id,
itemvalue: value.setupname
};
val.itemIndex = value.setupname == val.content ? value.id : val.itemIndex;
val.list.push(temphtml);
});
}
}, function () {
})
} else if (val.dictionarytype == 30137) {
dataToolsService.getCategoryByNode(val.dictionary).then(function (res) {
if (res.code == 3350 && res.data) {
$scope.industryItems = res.data.items;
var arrtemp = [];
angular.forEach($scope.industryItems, function (val) {
var obj = {
text: val.labelName,
stausName: val.labelName,
stausId: val.labelKey
};
arrtemp.push(obj);
})
val.list = [];
angular.forEach(arrtemp, function (value, index) {
var temphtml = {
text: '' + value.text + '',
itemvalue: value.stausName,
itemkey: value.stausId
};
val.itemIndex = value.stausName == val.content ? value.stausId : val.itemIndex;
val.list.push(temphtml);
})
return val.list;
}
})
} else if (val.dictionarytype == 30090) {
dataToolsService.getWebCascade(val.dictionary, upOrdown).then(function (response) {
if (UtilService.isDefined(response.data) && response.data.length > 0) {
console.log(response);
val.list = [];
angular.forEach(response.data, function (value, ind) {
var temphtml = {
text: '' + value.name + '',
itemkey: value.code,
itemvalue: value.name
};
val.itemIndex = value.name == val.content ? value.code : val.itemIndex;
val.list.push(temphtml);
});
}
}, function () {
})
}
//政策库
else if (val.dictionarytype == 35184) {
val.dictionary = "34b";
dataToolsService.getWebCascade(val.dictionary, upOrdown).then(function (response) {
if (UtilService.isDefined(response.data) && response.data.length > 0) {
console.log(response);
val.list = [];
angular.forEach(response.data, function (value, ind) {
var temphtml = {
text: '' + value.name + '',
itemkey: value.code,
itemvalue: value.name
};
val.itemIndex = value.name == val.content ? value.code : val.itemIndex;
val.list.push(temphtml);
});
}
}, function () {
})
}
}
var getSelectList = function (arr) {
angular.forEach(arr, function (val, index) {
// if($scope.isedit==0){
// val.tempimagelist=[];
// val.imagelist=[];
// val.orgimages=[];
// }
if ($scope.isedit == 0 && val.selectorgname) {
$scope.selectOrgname(val.selectorgname, index);
}
getSelectListItems(val, upOrdown);
})
}
// console.log($scope.fatherdata);
$scope.showLoadingToast();
$scope.carryout.reset=function (){
console.log(666655222355)
$scope.forbid=false
Selectionbox()
}
function Selectionbox() {
console.log($scope.fatherdata);
console.log(String($scope.fatherdata.detailList))
if ((String($scope.fatherdata.detailList) && $scope.fatherdata.detailList) || ($scope.fatherdata.addList && String($scope.fatherdata.addList))) {
getSelectList($scope.fatherdata.detailList);
angular.forEach($scope.fatherdata.addList, function (val) {
console.log(val);
getSelectList(val.unitItems[0]);
})
if ($scope.tempdata) {
angular.forEach($scope.tempdata, function (value) {
if (value.detailList.length > 0) {
getSelectList(value.detailList);
}
if (value.addList && value.addList.length > 0) {
angular.forEach(value.addList, function (vv) {
getSelectList(vv.unitItems[0]);
})
}
})
}
$scope.hideLoadingToast();
$interval.cancel(timer)
}
$scope.fatherdata.detailList.forEach(function (res) {
if (res.title == '技术合同预计签约时间') {
res.ifshow = true
}
res.hidden.split(',').forEach(function (hiress) {
$scope.fatherdata.detailList.forEach(function (fares) {
if (fares.id == hiress) {
fares.ifshow = true
}
})
})
})
console.log($scope.fatherdata.detailList)
console.log("1111")
}
var timer = $interval(Selectionbox, 300)
$scope.changetechnicaltransform = function (item, tmp) {
item.show = !item.show
tmp.content = ''
for (var i of tmp.list) {
if (i.show) {
console.log(i)
if (tmp.content) {
tmp.content = tmp.content + "、" + i.itemvalue
} else {
tmp.content = i.itemvalue
}
}
}
}
//下拉框选择事件,包括添加logo
$scope.selectItems = function (action, logoimg, index) {
$scope.logIndex = index;
if (action || logoimg) {
var list = [];
var clickfunction;
if (action) {
list = $scope.fatherdata.detailList[index].list;
if (!list) {
list = getSelectListItems($scope.fatherdata.detailList[index], upOrdown);
if ($scope.fatherdata.detailList[index - 1].type == 'cascade' && !list) {
$scope.showmessage({ msg: '请先选择大类!' });
return;
}
}
clickfunction = function (indx) {
// if($scope.fatherdata.detailList[index-1].type=='cascade'){
// $scope.showmessage({msg:'请先选择大类!'});
// return;
// }
$scope.fatherdata.detailList[index].itemIndex = list[indx].itemkey;
$scope.fatherdata.detailList[index].content = list[indx].itemvalue;
if ($scope.fatherdata.detailList[index].type == 'cascade') {
$scope.fatherdata.detailList[index + 1].dictionary = list[indx].itemkey;
getSelectListItems($scope.fatherdata.detailList[index + 1], upOrdown);
}
return true;
}
} else if (logoimg) {
if ($scope.app) {
list = [
{ text: '拍照' },
{ text: '从相册上传' },
]
clickfunction = function (indx) {
if (indx == 0) {
openCamera(1, 1);
} else {
openCamera(0, 1);
}
return true;
}
} else {
list = [
{ text: '从相册上传' },
];
clickfunction = function (indx) {
if (indx == 0) {
var files = document.getElementById('file');
files.click();
$(files).unbind().on('change', function (e) {
var data = new FormData();
data.append('file', e.target.files[0]);
// $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push();
CommonService.webUploadImage(data).then(function (res) {
$scope.fatherdata.detailList[index].content = res.originalName;
})
})
}
return true;
}
}
}
$ionicActionSheet.show({
buttons: list,
cancelText: '取消',
buttonClicked: clickfunction
})
}
}
var openCamera = function (srcType) {
var options = {
// Some common settings are 20, 50, and 100
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
// In this app, dynamically set the picture source, Camera or photo gallery
sourceType: srcType,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
allowEdit: false,
correctOrientation: true //Corrects Android orientation quirks
};
navigator.camera.getPicture(function (imageData) {
$scope.imgurl = imageData;
$scope.showLoadingToast();
UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
// 企业logo
// $scope.connEnterpriseModuleModel.orglogo = response[0].photoName;
$scope.fatherdata.detailList[$scope.logIndex].content = response[0].photoName;
$scope.hideLoadingToast();
}, function () {
$scope.hideLoadingToast();
});
}, function (message) {
}, options);
};
// 添加图片选择事件
$scope.addImage = function (index, key, outerIndex, innerIndex) {
$scope.imgIndex = index;
$scope.key = key;
$scope.outerIndex = outerIndex || 0;
$scope.innerIndex = innerIndex || 0;
if ($scope.app) {
var list = [
{ text: '拍照' },
{ text: '从相册上传' },
];
var clickfunction = function (indx) {
if (indx == 0) {
$scope.openCamera(index, key, outerIndex, innerIndex);
} else {
getPictures(index, key, outerIndex, innerIndex);
}
return true;
}
$ionicActionSheet.show({
buttons: list,
cancelText: '取消',
buttonClicked: clickfunction
})
} else {
var list = [
{ text: '从相册上传' },
];
var clickfunction = function (indx) {
if (indx == 0) {
var files = document.getElementById('file');
files.click();
$(files).unbind().on('change', function (e) {
// if($scope.fatherdata.detailList[$scope.imgIndex].imagelist.length>1){
// CommonService.showMessage('只能上传一张照片',$scope);
// return;
// }
$.each(e.target.files, function (i, file) {
var url = null;
if (window.createObjectURL != undefined) { // basic
url = window.createObjectURL(file);
} else if (window.URL != undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file);
} else if (window.webkitURL != undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file);
}
if (key == 'detail') {
$scope.fatherdata.detailList[index].tempimagelist.push({
photoName: url,
originalName: url
});
} else {
// console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist);
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.push({
photoName: url,
originalName: url
});
}
})
$.each(e.target.files, function (i, file) {
// console.log(file);
var data = new FormData();
data.append('file', file);
// $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push();
CommonService.webUploadImage(data).then(function (res) {
// console.log(res);
var temp = {
id: 0,
title: "",
doctype: res.doctype,//文档类型 1图片,2文件,3pdf,4xls
isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
photoName: res.photoName,
originalName: res.originalName,
sourceName: res.sourceName,
sourceSize: res.sourceSize
};
if (key == 'detail') {
$scope.fatherdata.detailList[index].imagelist.push(temp);
} else {
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.push(temp);
}
// console.log($scope.fatherdata.addList[$scope.outerIndex]);
})
});
})
}
return true;
}
$ionicActionSheet.show({
buttons: list,
cancelText: '取消',
buttonClicked: clickfunction
})
}
}
$scope.openCamera = function (index, key, outerIndex, innerIndex) {
if (key == 'detail' && $scope.fatherdata.detailList[index].imagelist.length >= 9) {
UtilService.showMess("最多选取9张图片");
return;
}
if (key == 'addList' && $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.length >= 9) {
UtilService.showMess("最多选取9张图片");
return;
}
UtilService.getPicture(1).then(function (results) {
// $scope.fatherdata.detailList[$scope.logIndex].imagelist.push({photoName: results, originalName: results});
// $scope.totalImglength = 600 * $scope.fatherdata.imagelist.length;
if (key == 'detail') {
$scope.fatherdata.detailList[index].tempimagelist.push({ photoName: results, originalName: results });
} else {
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.push({
photoName: results,
originalName: results
});
}
UtilService.uploadFile([results], 0, "image/jpeg").then(function (response) {
// $scope.fatherdata.detailList[$scope.imgIndex].imagelist=[];
angular.forEach(response, function (value) {
if (value.status) {
var temp = {
id: 0,
title: "",
doctype: value.doctype,//文档类型 1图片,2文件,3pdf,4xls
isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
photoName: value.photoName,
originalName: value.originalName,
sourceName: value.sourceName,
sourceSize: value.sourceSize
};
if (key == 'detail') {
$scope.fatherdata.detailList[index].imagelist.push(temp);
} else {
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.push(temp);
}
}
})
}, function () {
$scope.hideLoadingToast();
UtilService.showMess("网络不给力,请重试");
saveflg = 0;
});
// if($scope.key=='detail'){
// $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push({photoName: results, originalName: results,id:0});
// }else{
// $scope.fatherdata.addList[$scope.outerIndex].unitItems[$scope.innerIndex][$scope.imgIndex].imagelist.push({photoName: results, originalName: results,id:0});
// }
// $timeout(function(){
//
// },500)
$ionicScrollDelegate.$getByHandle("scrollimage").resize();
}, function (err) {
});
};
var getPictures = function (index, key, outerIndex, innerIndex) {
if (device.platform == "Android") {
verifyStorage(index, key, outerIndex, innerIndex);
} else {
getPic(index, key, outerIndex, innerIndex);
}
};
var verifyStorage = function (index, key, outerIndex, innerIndex) {
window.imagePicker.verifyStorage(
function (results) {
if (results == "1") {
getPic(index, key, outerIndex, innerIndex);
}
}, function (error) {
}
);
};
var getPic = function (index, key, outerIndex, innerIndex) {
var imagelistLength = 0;
if (key == 'detail') {
if ($scope.fatherdata.detailList[index].imagelist.length >= 9) {
UtilService.showMess("最多选取9张图片");
return;
} else {
imagelistLength = $scope.fatherdata.detailList[index].imagelist.length;
}
} else {
if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.length >= 9) {
UtilService.showMess("最多选取9张图片");
return;
} else {
imagelistLength = $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.length;
}
}
UtilService.getPictureList(9 - imagelistLength).then(function (results) {
// console.log(results);
angular.forEach(results, function (val) {
if (key == 'detail') {
$scope.fatherdata.detailList[index].tempimagelist.push({ photoName: val, originalName: val });
} else {
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.push({
photoName: val,
originalName: val
});
}
})
UtilService.uploadFile(results, 0, "image/jpeg").then(function (response) {
angular.forEach(response, function (value) {
if (value.status) {
var temp = {
id: 0,
title: "",
doctype: value.doctype,//文档类型 1图片,2文件,3pdf,4xls
isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
photoName: value.photoName,
originalName: value.originalName,
sourceName: value.sourceName,
sourceSize: value.sourceSize
};
if (key == 'detail') {
$scope.fatherdata.detailList[index].imagelist.push(temp);
} else {
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.push(temp);
}
}
})
}, function () {
$scope.hideLoadingToast();
UtilService.showMess("网络不给力,请重试");
saveflg = 0;
});
// angular.forEach(results, function (value, index) {
// // $scope.imagelist.push({photoName: value, originalName: value})
// if($scope.key=='detail'){
// $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push({photoName: value, originalName: value,id:0});
// }else{
// $scope.fatherdata.addList[$scope.outerIndex].unitItems[$scope.innerIndex][$scope.imgIndex].imagelist.push({photoName: value, originalName: value,id:0});
// }
// });
// $scope.totalImglength = 600 * $scope.imagelist.length;
// if($scope.key=='detail'){
// $scope.fatherdata.detailList[$scope.logIndex].content=JSON.stringify($scope.imagelist)
// }else{
// $scope.fatherdata.addList[$scope.outerIndex].unitItems[$scope.innerIndex][$scope.imgIndex].content=JSON.stringify($scope.imagelist)
// }
$ionicScrollDelegate.$getByHandle("scrollimage").resize();
}, function (err) {
});
};
//删除图片
$scope.deletePhoto = function (key, imgIndex, index, innerIndex, outerIndex) {
// console.log(imgIndex,index);
if (key == 'detail') {
// 如果删除的是原有图片,设置原有图片的isenabled=2
// console.log($scope.fatherdata.detailList[$scope.imgIndex]);
// console.log($scope.fatherdata.detailList[$scope.imgIndex].imagelist[index]);
// console.log($scope.fatherdata.detailList);
// console.log($scope.fatherdata.detailList[imgIndex]);
if ($scope.fatherdata.detailList[imgIndex].imagelist[index].id != undefined && $scope.fatherdata.detailList[imgIndex].imagelist[index].id != 0) {
// if($scope.fatherdata.detailList[imgIndex].imagelist[index].id!=undefined&&$scope.fatherdata.detailList[imgIndex].imagelist[index].id!=0&&$scope.fatherdata.detailList[imgIndex].orgimages.length>0){
// angular.forEach($scope.fatherdata.detailList[imgIndex].orgimages,function(v,i){
// if(v.id==$scope.fatherdata.detailList[imgIndex].imagelist[index].id){
// v.isenabled=2
// }
// })
$scope.fatherdata.detailList[imgIndex].imagelist[index].isenabled = 2;
$scope.fatherdata.detailList[imgIndex].orgimages.push($scope.fatherdata.detailList[imgIndex].imagelist[index]);
}
$scope.fatherdata.detailList[imgIndex].imagelist.splice(index, 1);
$scope.fatherdata.detailList[imgIndex].tempimagelist.splice(index, 1);
console.log($scope.fatherdata.detailList[imgIndex]);
} else {
// 如果删除的是原有图片,设置原有图片的isenabled=2
// console.log($scope.fatherdata.addList);
// console.log($scope.fatherdata.addList[outerIndex]);
// console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index]);
if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id != undefined && $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id != 0) {
// if($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id!=undefined&&$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id!=0&&$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].orgimages.length>0){
// angular.forEach($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].orgimages,function(v1,i1){
// if(v1.id==$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id){
// v1.isenabled=2
// }
// })
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].isenabled = 2;
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].orgimages.push($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex]);
}
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.splice(imgIndex, 1);
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.splice(imgIndex, 1);
}
};
//点击图片放大
$scope.bigImage = false; //初始默认大图是隐藏的
$scope.hideBigImage = function () {
if ($scope.app) {
$scope.setStatusBar(0);
}
$timeout(function () {
$scope.bigImage = false;
}, 400);
};
$scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
if ($scope.app) {
$scope.setStatusBar(1);
}
$(function () {
$('div.pinch-zoom').each(function () {
new RTP.PinchZoom($(this), {});
});
});
$scope.bigImage = true;//显示大图
$ionicSlideBoxDelegate.update();//重绘,让图片显示出来
//图片总数量
setTimeout(function () {
$ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
//获取图片
var imgObj = document.getElementsByClassName('bigimage');
var n;
for (n = 0; n < imgObj.length; n++) {
// 获取图片的原始高度和宽度
var oldWid = imgObj[n].naturalWidth;
var oldHei = imgObj[n].naturalHeight;
var screen = document.body.offsetWidth;
var screenH = window.innerHeight;
var rate = oldWid / oldHei;
if (oldWid >= screen && oldHei >= screenH) {
var tw = screen;
var th = tw / rate;
if (th < screenH) {
imgObj[n].style.width = tw + 'px';
imgObj[n].style.height = th + 'px';
imgObj[n].style.marginTop = (screenH - th) / 2 + 'px';
} else {
imgObj[n].style.width = screenH * rate + 'px';
imgObj[n].style.height = screenH + 'px';
imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
}
} else if (oldWid >= screen && oldHei <= screenH) {
imgObj[n].style.width = screen + 'px';
imgObj[n].style.height = screen / rate + 'px';
imgObj[n].style.marginTop = (screenH - screen / rate) / 2 + 'px';
} else if (oldWid <= screen && oldHei >= screenH) {
// var hh=screenH;
// var ww=screenH*rate;
imgObj[n].style.width = screenH * rate + 'px';
imgObj[n].style.height = screenH + 'px';
imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
} else {
imgObj[n].style.width = oldWid + 'px';
imgObj[n].style.height = oldHei + 'px';
imgObj[n].style.marginLeft = (screen - oldWid) / 2 + 'px';
imgObj[n].style.marginTop = (screenH - oldHei) / 2 + 'px';
}
}
}, 500);
};
// getSelectList($scope.fatherdata.detailList);
$scope.selecBlocktItems = function (action, outerIndex, innerIndex, index) {
// console.log(action);
if (action) {
// console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index]);
var list = $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].list;
if (!list) {
list = getSelectListItems($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index], upOrdown);
if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index - 1].type == 'cascade' && !list) {
$scope.showmessage({ msg: '请先选择大类!' });
return;
}
}
var clickfunction = function (indx) {
// if($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index-1].type=='cascade'){
// $scope.showmessage({msg:'请先选择大类!'});
// return;
// }
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].itemIndex = list[indx].itemkey;
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].content = list[indx].itemvalue;
if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].type = 'cascade') {
$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index + 1].dictionary = list[indx].itemkey;
getSelectListItems($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index + 1], upOrdown)
}
// console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index]);
return true;
}
// clickfunction=function(indx){
// $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].content=arr[indx];
// return true;
// }
if (list) {
console.log(list);
$ionicActionSheet.show({
buttons: list,
cancelText: '取消',
buttonClicked: clickfunction
})
// $interval.cancel(tt);
}
}
}
$scope.ttt = function (tmptitle) {
return $sce.trustAsHtml(tmptitle);
}
var resetList = function (arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].tcname == 'orgname') continue;
arr[i].content = '';
}
}
$scope.selectOrgname = function (action, index,row) {
if(row?row.title=='所属单位':false){
$scope.forbid=false
}
if (action) {
if ($scope.fatherdata.detailList[index].content) {
$timeout(function () {
dataToolsService.getOrganizationModelByOrgname($scope.fatherdata.detailList[index].content, $scope.fatherdata.pagecode, 0).then(function (response) {
// console.log(response);
$scope.companylist = response.data;
$scope.isRelateUl = true;
}, function () {
})
}, 1000);
} else {
$scope.isRelateUl = false;
$scope.companylist = [];
}
}
}
//进入资源详情
$scope.jumpResourceDetail = function (company) {
// 先预设信息
$scope.setCompanyName(company);
// 再跳转到资源详情页
$state.go('resourceCommonDetailsPage', {
recourceid: company.resourcelibrary.id,
recourcetype: company.resourcelibrary.restype,
recourcecomefrom: company.resourcelibrary.comefrom,
creator: company.resourcelibrary.creator,
title: company.name
});
};
var getSaveKeyContent = function (detailList, key1, organizationInfo, key2) {
console.log(key2)
for (var i = 0; i < detailList.length; i++) {
if (detailList[i].tcname == key1) {
if (detailList[i].type == 'number') {
detailList[i].content = Number(organizationInfo[key2]);
} else {
detailList[i].content = organizationInfo[key2];
}
if (detailList[i].toggle && organizationInfo[key2]) {
detailList[i].togglecontent = true
$scope.watchIsChange(i)
}
if (key2 == 'ishigh') {
detailList[i].togglecontent = organizationInfo[key2] == 1;
detailList[i].content = organizationInfo[key2] == 1 ? '是' : '否';
}
if (detailList[i].list) {
// console.log(key2);
// console.log(detailList[i].list);
// console.log(organizationInfo[key2]);
var temp = detailList[i].list.filter(function (val, ii, arr) {
return val.itemkey == organizationInfo[key2];
})
console.log(temp)
if (temp.length > 0) {
detailList[i].content = temp[0].itemvalue;
} else {
detailList[i].content = '';
}
if(detailList[i].tcname=="naturefirm") {
console.log(organizationInfo['orgtype'], organizationInfo[key2])
detailList[i].content=organizationInfo['orgtype'] == 10104 ? '企业' : '高校'
}
if (key2 == "classesType") {
detailList[i].content = organizationInfo[key2]
console.log(organizationInfo[key2])
if (organizationInfo[key2]) {
var array = organizationInfo[key2].split("、")
for (var ary of array) {
console.log(ary)
detailList[i].list.filter(function (val, i, arr) {
if (val.itemvalue == ary) {
val.show = true
};
})
}
}
}
}
if (detailList[i].selectaction) {
// console.log(detailList[i]);
// console.log(organizationInfo[key1]);
var temp1 = detailList[i].list.filter(function (val) {
return val.itemkey == organizationInfo[key1];
})
// console.log(temp1);
if (temp1.length > 0) {
detailList[i].content = temp1[0].itemvalue;
detailList[i].itemIndex = temp1[0].itemkey;
}
}
return;
}
}
}
$scope.forbid=false
// 选中机构
$scope.setCompanyName = function (organizationInfo) {
console.log(organizationInfo)
console.log($scope.fatherdata)
// dataToolsService.getFormStructureFill($stateParams.pagecode, '30003', '0', $stateParams.node, $stateParams.resourcetype,organizationInfo.name).then(function (res) {
// console.log(res)
// })
// console.log(organizationInfo);
$scope.fatherdata.conpanyInfo = organizationInfo;
// 全部置空
resetList($scope.fatherdata.detailList);
$scope.fatherdata.orgid = organizationInfo.id;
organizationInfo.name = organizationInfo.name.replace("", "");
organizationInfo.name = organizationInfo.name.replace("", "");
for (var key in organizationInfo) {
if (key == 'name') {
getSaveKeyContent($scope.fatherdata.detailList, 'orgname', organizationInfo, key);
getSaveKeyContent($scope.fatherdata.detailList, 'companyid', organizationInfo, key);
} else if (key == 'logo') {
getSaveKeyContent($scope.fatherdata.detailList, 'orglogo', organizationInfo, key);
} else if (key == 'rdinstitutiontype') {
getSaveKeyContent($scope.fatherdata.detailList, 'orggradecode', organizationInfo, key);
} else if (key == 'contactnum') {
getSaveKeyContent($scope.fatherdata.detailList, 'orgcontactnum', organizationInfo, key);
} else if (key == 'contact') {
getSaveKeyContent($scope.fatherdata.detailList, 'orgcontact', organizationInfo, key);
} else if (key == 'classesType') {
getSaveKeyContent($scope.fatherdata.detailList, 'orgClassesType', organizationInfo, key);
} else {
getSaveKeyContent($scope.fatherdata.detailList, key, organizationInfo, key);
}
}
// console.log($scope.fatherdata);
$scope.isRelateUl = false;
$scope.forbid=true
}
$scope.watchIsChange = function (index) {
$scope.fatherdata.detailList[index].content = $scope.fatherdata.detailList[index].togglecontent ? "是" : "否";
$scope.fatherdata.detailList.forEach(function (res) {
if (res.title == '技术合同预计签约时间') {
res.ifshow = $scope.fatherdata.detailList[index].togglecontent ? false : true;
}
})
$scope.fatherdata.detailList[index].hidden.split(',').forEach(function (hiress) {
$scope.fatherdata.detailList.forEach(function (fares) {
if (fares.id == hiress) {
console.log("走了")
fares.ifshow = $scope.fatherdata.detailList[index].togglecontent ? false : true;
}
})
})
}
$scope.addBlockList = function (index) {
var arr = [];
for (var i = 0; i < $scope.fatherdata.addList[index].unitItems[0].length; i++) {
var temp = Object.assign({}, $scope.fatherdata.addList[index].unitItems[0][i])
temp.content = null;
// temp.imagelist=[];
temp.orgimages = [];
temp.tempimagelist = [];
temp.imagelist = [];
temp.itemIndex = null;
arr.push(temp);
}
console.log(arr);
$scope.fatherdata.addList[index].unitItems.unshift(arr);
console.log($scope.fatherdata.addList[index].unitItems);
}
$scope.minusBlockList = function (outindex, index) {
if ($scope.fatherdata.addList[outindex].unitItems.length == 1) {
$scope.showmessage({ msg: '请至少留下一组项目' })
return;
}
// if($scope.isedit==1){
angular.forEach($scope.fatherdata.addList[outindex].unitItems[index], function (val, i) {
if (val.tcname == 'id' && val.content != '') {
$scope.fatherdata.addList[outindex]['deletUnitItems'] = [];
$scope.fatherdata.addList[outindex]['deletUnitItems'].push($scope.fatherdata.addList[outindex].unitItems[index]);
}
})
// }
$scope.fatherdata.addList[outindex].unitItems.splice(index, 1);
}
$scope.showDetails = function (index) {
$scope.fatherdata.addList[index].ishiddensection = !$scope.fatherdata.addList[index].ishiddensection;
}
// 日期选择
$scope.validedTime = new Date();
var datePickerObj = {
//选择日期后的回掉
callback: function (val) {
console.log('111111', val);
if (typeof (val) === 'undefined') {
} else {
var temp = new Date(val).toLocaleString().replace(/\//g, "-");
// var temp = new Date(val).toLocaleString().split(' ')[0].replace(/\//g, "-") ;
// var temp=new Date(val).toJSON().substr(0, 19).replace('T', ' ').replace(/-/g, '-')
// console.log(temp)
if ($scope.type == 'addList') {
$scope.fatherdata.addList[$scope.outerTimeIndex].unitItems[$scope.innerTimeIndex][$scope.timeIndex].content = temp;
} else {
$scope.fatherdata.detailList[$scope.timeIndex].content = temp;
console.log('ssss', $scope.fatherdata.detailList[$scope.timeIndex]);
}
datePickerObj.inputDate = new Date(val); //更新日期弹框上的日期
}
},
disabledDates: [
new Date(2016, 2, 16),
new Date(2015, 3, 16),
new Date(2015, 4, 16),
new Date(2015, 5, 16),
new Date('Wednesday, August 12, 2015'),
new Date("2016-08-16"),
new Date(1439676000000)
],
from: new Date(1970, 1, 1),
to: new Date(2050, 10, 30),
inputDate: new Date(),
mondayFirst: true,
disableWeekdays: [], //设置不能选中
closeOnSelect: false,
dateFormat: 'yyyy-MM-dd',
templateType: 'popup',
need: true,
};
//打开日期选择框
$scope.openDatePicker = function (type, Index, outerIndex, innerIndex) {
$scope.timeIndex = Index;
$scope.type = type;
if (type == 'addList') {
$scope.outerTimeIndex = outerIndex;
$scope.innerTimeIndex = innerIndex;
}
ionicDatePicker.openDatePicker(datePickerObj);
};
$scope.navigate = function (state) {
nav.navigate(state);
};
}]);