/**
* Created by pushkeji on 2018/8/16.
*/
angular.module('push')
.controller('toDeclareCtrl', function ($scope, $stateParams, $ionicActionSheet, $ionicLoading, $ionicScrollDelegate, UtilService, dataToolsService, $sce, AccountService, UserService, $ionicSlideBoxDelegate, $timeout, $state, $http, ConfigService, CommonService, $ionicPopup, ResourceLibraryService, taskModuleService, ScienceCircleService, $ionicModal, $q, ionicDatePicker) {
console.log($stateParams);
// 弹出任务邀请框
$scope.tempData = {};
$scope.node = UserService.node;
$stateParams.list=JSON.parse($stateParams.list)
$scope.list = $stateParams.list;
console.log( $stateParams)
$scope.by2 = $stateParams.by2;
$scope.imageList1 = [];
$scope.imageList2 = [];
$scope.imageList3 = [];
$scope.imageList4 = [];
$scope.imageList5 = [];
$scope.policeinfoid = ($scope.by2 == 'technical' ? '2' : $scope.by2 == 'broker' ? '1' : $scope.by2 == 'subsidy' ? '3' : '');
$scope.picturelist = $stateParams.picturelist;
var userid=$stateParams.list.creator?$stateParams.list.creator:UserService.id
AccountService.getAuthorizationLetterList(userid, UserService.node).then(function (res) {
console.log(res)
if (res.data.length > 0) {
$scope.companylist = res.data;
// $scope.comnpanyoriginname = res.data[0].applyname;
// $scope.content=res.data[0].applyname;
$scope.orgid=res.data[0].orgid
var id
if($stateParams.list.title=='研发后补助申报'||$stateParams.list.restype==1611726857){
id=$stateParams.list.researchCostId
$scope.viewtitle='申报研发后补助'
}else {
id=$stateParams.list.technicalcontractid
$scope.viewtitle='申报产学研合作补助'
}
console.log(id)
if(id&&$stateParams.list.restype){
ResourceLibraryService.getresearchcostdetail(id,$stateParams.list.restype).then(function (res) {
console.log(res)
if (res.code == 3350) {
$scope.echolist = res.data;
$scope.picturelist=JSON.parse(res.data.images)
angular.forEach($scope.picturelist, function (val) {
if (val.remark == "经技术合同登记的产学研合作合同(技术开发、技术转让、技术咨询、技术服务)"||val.remark == "A000000基础信息表") {
$scope.imageList1.push(val)
}
if (val.remark == "发票"||val.remark == "A107012研发费用加计扣除优惠明细表") {
$scope.imageList2.push(val)
}
if (val.remark == "支付凭证(银行转账凭证)"||val.remark == "A107012研发费用加计扣除优惠明细表") {
$scope.imageList3.push(val)
}
if (val.remark == "结果凭证(结题报告、进度报告等)"||val.remark == "上传法定代表人授权委托书") {
$scope.imageList4.push(val)
}
if (val.remark == "法定代表人授权委托书"||val.remark == "上传材料真实性承诺书") {
$scope.imageList5.push(val)
}
})
f()
}
})
}else {
f()
}
}
});
if ($scope.node == '330122000') {
$scope.agree = 1;
} else {
$scope.agree = true;
}
if (UserService.user.data == null || UserService.user.data == undefined || UserService.user.data == "") {
$scope.mobile = UserService.user.mobile;
} else {
$scope.mobile = UserService.user.data.mobile;
}
$scope.index = 0;
var permissionvalue = "1";
$scope.url = 'http://pic.ubittc.com/group2/M00/03/B7/wKjIKluVD3OAfkH4AAA74dltjKY89.docx';
$scope.alertInfo = function () {
// CommonService.showMessage('请在电脑端下载打印',$scope)
if ($scope.app) {
$ionicPopup.alert({
title: '提示',
template: '《企业认证申请公函》请在电脑端下载打印,并加盖企业公章后上传。电脑端web网址:ubittc.com'
});
}
}
if ($scope.app) {
$scope.url = '';
// $scope.alertInfo()
}
if ($stateParams.pageTitle) {
$scope.pageTitle = $stateParams.pageTitle;
} else {
$scope.pageTitle = sessionStorage.indentifyDetailTitle;
}
if ($stateParams.code) {
$scope.code = $stateParams.code;
} else {
$scope.code = sessionStorage.indentifyDetailCode;
}
$scope.action = $stateParams.action;
$scope.type = $stateParams.type;
// console.log($stateParams);
// console.log($scope.pageTitle,$scope.code,$scope.action);
// if($stateParams.type=){
// $scope.type=$stateParams.type;
// }else{
// $scope.type=sessionStorage.type;
// }
$scope.orgid = null;
$scope.showNew = false;
$scope.showHistory = false;
$scope.showFinish = false;
$scope.showReject = false;
$scope.refusereason = '';
if ($stateParams.type == 5100) {
$scope.showNew = true;
} else if ($stateParams.type == 5101 || $stateParams.type == 0 || $scope.action == 'check' || $stateParams.type == 5102 || $stateParams.type == 5103) {
$scope.showHistory = true;
if ($stateParams.type == 5102 || $stateParams.type == 5103) {
$scope.showFinish = true;
}
if ($stateParams.type == 5103) {
$scope.showReject = true;
}
}
function f() {
var a = [
{
title: '企业名称',
placeholder: '请选择企业名称',
fuzzyQuery: true,
content: $scope.echolist?$scope.echolist.buyorgname:'',
type: 'companySelect',
needed: true,
saveKey: 'buyorgname',
}, {
title: '企业类别',
placeholder: '请选择企业类别',
content: $scope.echolist?$scope.echolist.orgtype == '8311' ? '高新潜力企业' : $scope.echolist.orgtype == '8310' ? '科技型初创企业' : $scope.echolist.orgtype == '8301' ? '国家高新技术企业' : $scope.echolist.orgtype == '8312' ? '创新引领企业' : $scope.echolist.orgtype == '8307' ? '其他企业': "":"",
key: '',
type: 'selectorgtype',
needed: true,
saveKey: 'orgtype',
}, {
title: '合同名称',
placeholder: '请填写合同名称',
fuzzyQuery: false,
content: $scope.echolist? $scope.echolist.projectname : '',
type: 'input',
needed: true,
saveKey: 'projectname',
}, {
title: '合同金额(万)',
placeholder: '请填写',
fuzzyQuery: false,
regex:"number",
content: $scope.echolist? $scope.echolist.contractamount : '',
type: 'input',
needed: true,
saveKey: 'contractamount',
}, {
title: '当年实际支付金额(万)',
placeholder: '请填写',
fuzzyQuery: false,
regex:"number",
content: $scope.echolist ? $scope.echolist.actualamountpaid : '',
type: 'input',
needed: true,
saveKey: 'actualamountpaid',
}, {
title: '当年实际支付的除税金额(万)(增值税普通发票不需要除税)',
placeholder: '请填写',
fuzzyQuery: false,
regex:"number",
content: $scope.echolist? $scope.echolist.actualamountpaidexcepttax : '',
type: 'input',
needed: true,
saveKey: 'actualamountpaidexcepttax',
}, {
title: '合作方名称',
placeholder: '请填写合作方名称',
content: $scope.echolist? $scope.echolist.sellorgname : '',
type: 'input',
needed: true,
saveKey: 'sellorgname',
}, {
title: '发票号码',
placeholder: '请填写发票号码',
regex:"number",
content: $scope.echolist ? $scope.echolist.invoicenumber : '',
type: 'input',
needed: true,
saveKey: 'invoicenumber',
}, {
title: '发票代码',
placeholder: '请填写发票代码',
regex:"number",
content: $scope.echolist? $scope.echolist.invoicecode : '',
type: 'input',
needed: true,
saveKey: 'invoicecode',
}, {
title: '经技术合同登记的产学研合作合同(技术开发、技术转让、技术咨询、技术服务)',
content: '',
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList1 ? $scope.imageList1 : '[]',
imageDeleteList: [],
doctype: 4903,
remarkType: 'normal',
}, {
title: '发票',
content: '',
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList2 ? $scope.imageList2 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'normal'
}, {
title: '支付凭证(银行转账凭证)',
content: '',
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList3 ? $scope.imageList3 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'normal'
}, {
title: '结果凭证(结题报告、进度报告等)',
content:'' ,
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList4 ? $scope.imageList4 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'normal'
}, {
title: '法定代表人授权委托书',
content: '',
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList5 ? $scope.imageList5 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'add'
},
];
var b = [
{
title: '企业名称',
placeholder: '请选择企业名称',
fuzzyQuery: true,
content: $scope.echolist?$scope.echolist.orgName:'',
type: 'companySelect',
needed: true,
saveKey: 'orgName',
}, {
title: '社会统一信用代码',
placeholder: '请填写社会统一信用代码',
content: $scope.echolist?$scope.echolist.orgCode:'',
regex:true,
type: 'input',
needed: true,
saveKey: 'orgCode',
}, {
title: '申报人姓名',
placeholder: '请填写申报人姓名',
fuzzyQuery: false,
content: $scope.echolist? $scope.echolist.applicantName : '',
type: 'input',
needed: true,
saveKey: 'applicantName',
}, {
title: '联系电话',
placeholder: '请填写联系电话',
fuzzyQuery: false,
regex:"phone",
content: $scope.echolist? $scope.echolist.applicantContact : '',
type: 'input',
needed: true,
saveKey: 'applicantContact',
}, {
title: '近三年企业研发费用',
fuzzyQuery: false,
type: 'group',
needed: true,
form:[
{
title: new Date().getFullYear()-1,
placeholder: '请输入',
fuzzyQuery: false,
regex:"number",
content: $scope.echolist? $scope.echolist.pastOneResearchMoney : '',
type: 'companySelect',
needed: true,
saveKey: 'pastOneResearchMoney',
}, {
title: new Date().getFullYear()-2,
placeholder: '请输入',
fuzzyQuery: false,
regex:"number",
content: $scope.echolist? $scope.echolist.pastThreeResearchMoney : '',
type: 'companySelect',
needed: true,
saveKey: 'pastThreeResearchMoney',
}, {
title: new Date().getFullYear()-3,
placeholder: '请输入',
fuzzyQuery: false,
regex:"number",
content: $scope.echolist ? $scope.echolist.pastTwoResearchMoney : '',
type: 'companySelect',
needed: true,
saveKey: 'pastTwoResearchMoney',
}, {
title: '估算可补助金额',
placeholder: '等待计算',
fuzzyQuery: false,
content: $scope.echolist? $scope.echolist.estimateSubsidyMoney : '',
type: 'companySelect',
needed: true,
saveKey: 'estimateSubsidyMoney',
},
]
}, {
title: 'A000000基础信息表',
content:"" ,
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList1 ? $scope.imageList1 : '[]',
imageDeleteList: [],
doctype: 4903,
remarkType: 'normal',
}, {
title: 'A100000年度纳税申报表(A类)',
content: '',
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList2 ? $scope.imageList2 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'normal'
}, {
title: 'A107012研发费用加计扣除优惠明细表',
content:'' ,
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList3 ? $scope.imageList3 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'normal'
}, {
title: '上传法定代表人授权委托书',
content:'' ,
type: 'upload',
needed: true,
imagelist: [],
imageSaveList:$scope.imageList4 ? $scope.imageList4 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'normal',
Lowerdie:true
}, {
title: '上传材料真实性承诺书',
content: '',
type: 'upload',
needed: true,
imagelist: [],
imageSaveList: $scope.imageList5 ? $scope.imageList5 : '[]',
imageDeleteList: [],
doctype: 4908,
remarkType: 'normal',
Lowerdie:true
},
];
var enterprise
if($stateParams.list.title=='研发后补助申报'||$stateParams.list.restype==1611726857){
enterprise=b
}else{
enterprise=a
}
$scope.formList = enterprise;
}
// 验证输入的是数字
$scope.clearNoNum = function(obj,attr,regex){//先把非数字的都替换掉,除了数字和.
if(regex=='number'){
obj[attr] = obj[attr].replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
obj[attr] = obj[attr].replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj[attr] = obj[attr].replace(/\.{2,}/g,"");
//保证.只出现一次,而不能出现两次以上
obj[attr] = obj[attr].replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}
}
//下载模板
$scope.Lowerdie=function(index){
dataToolsService.downloadcommonmodel('docx',index+1).then(function (res) {
console.log(res)
var aEle = document.createElement("a");// 创建a标签
var blob = new Blob([res], {type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'});
// aEle.download = item.modelName;// 设置下载文件的文件名
aEle.href = URL.createObjectURL(blob);
aEle.click();// 设置点击事件
})
};
// 模糊查询
$scope.queryOrgName = function (index) {
if ($scope.formList[index].fuzzyQuery) {
if ($scope.formList[index].content) {
var pagecode = $scope.code == 4803 ? 1000003 : 1000004;
dataToolsService.getOrganizationModelByOrgname($scope.formList[index].content, pagecode, 0).then(function (response) {
// console.log(response);
if (response.code == 3350) {
$scope.orgList = response.data;
$scope.isRelateUl = true;
} else {
$scope.orgList = [];
$scope.isRelateUl = false;
}
}, function () {
})
} else {
$scope.isRelateUl = false;
$scope.orgList = [];
}
}
}
//近三年企业研发费用
$scope.rdchange=function(index){
console.log($scope.formList[index].form)
var a=[]
$scope.formList[index].form.forEach(function (res) {
if(res.content==''&&res.title!='估算可补助金额'){
a.push(true)
}
})
if(a.length==0){
var params={
aMoney: $scope.formList[index].form[0].content,
bMoney: $scope.formList[index].form[1].content,
cMoney: $scope.formList[index].form[2].content
}
dataToolsService.usercalresearchcost(params).then(function (res) {
console.log(res)
$scope.formList[index].form[3].content=res.data
})
}
}
$scope.ttt = function (tmptitle) {
return $sce.trustAsHtml(tmptitle);
}
if ($scope.code == 4803 && $stateParams.companyName && $stateParams.companyName != '') {
$scope.formList[0].content = $stateParams.companyName;
$scope.queryOrgName(0);
}
angular.forEach($scope.formList, function (val) {
if (val.type == 'affiliatedOrg') {
var pagecode = $scope.code == 4803 ? 1000003 : 1000004;
dataToolsService.getOrganizationModelByOrgname(' ', pagecode, 0, 1).then(function (response) {
console.log(response);
if (response.data.length > 0) {
if ($stateParams.type == 5100) {
$scope.brokernode = UserService.node;
if (UserService.node != '330122000') {
val.content = '普适云平台';
val.key = '123456';
}
}
val.listItem = [];
angular.forEach(response.data, function (value) {
val.listItem.push({
text: '' + value.name + '',
itemkey: value.id,
itemvalue: value.name //名字
})
})
}
}, function () {
});
}
if (val.type == 'select') {
val.listItem = [];
dataToolsService.getTypeEntryListByTypeName(val.selectkey).then(function (res) {
if (res.code == 3350) {
angular.forEach(res.data, function (value) {
val.listItem.push({
text: '' + value.itemkey + '',
itemkey: value.itemvalue,
itemvalue: value.itemkey //名字
})
})
$timeout(function () {
if (val.content) {
var temp = val.listItem.filter(function (vv) {
return vv.itemvalue == val.content;
})
if (temp.length > 0) {
val.key = temp[0].itemkey;
}
}
}, 1000);
}
})
}
if (val.type == 'selectArea') {
getAreaList(0, 0);
}
if (val.type == 'selectDomain') {
// getDomainList(0,0);
// console.log(val);
val.listItem = [];
AccountService.getDomainInfo(0, $scope.node).then(function (res) {
if (res.code == 3350) {
// console.log(res);
angular.forEach(res.data, function (value) {
val.listItem.push({
text: '' + value.name + '',
itemkey: value.code,
itemvalue: value.name, //名字,
// itemcode:value.code
})
})
} else {
}
})
}
})
$timeout(function () {
console.log($scope.formList);
}, 4000)
// 获取数据处理
var dealWithData = function (temp) {
console.log(temp);
$scope.orgid = temp.orgid ? temp.orgid : 0;
// 处理数据
var arr = [];
$scope.refusereason = temp.refusereason;
if (temp.images != '' && temp.images != null) {
arr = JSON.parse(temp.images);
}
// console.log(temp);
for (var key in temp) {
for (var i = 0; i < $scope.formList.length; i++) {
if (key == $scope.formList[i].saveKey) {
console.log(key);
$scope.formList[i].content = temp[key];
// if(key=='district'&&temp[key]!=''&&$scope.formList[i].type=='selectArea'){
// console.log(temp[key]);
// var tp=JSON.parse(temp[key]);
// var str='';
// angular.forEach(tp,function(val,index){
// str+=val.name+' ';
// })
// $scope.formList[i].content=str;
// }
if ($scope.showNew == true && key == 'district' && temp[key] != '' && $scope.formList[i].type == 'selectArea') {
var tempArry = temp[key].split('/')
// console.log(temp);
for (var j = 0; j < $scope.areaDropDown.length; j++) {
$scope.areaDropDown[j].selectName = tempArry[j];
}
}
if ($scope.formList[i].type == 'select' || $scope.formList[i].type == 'selectDomain' || $scope.formList[i].type == 'affiliatedOrg' || $scope.formList[i].type == 'companyTaskSelect') {
// console.log($scope.formList[i]);
// console.log(temp[key]);
var tparr = $scope.formList[i].listItem.filter(function (vv) {
return vv.itemkey == temp[key];
})
// console.log(tparr);
$scope.formList[i].content = tparr.length > 0 ? tparr[0].itemvalue : '';
$scope.formList[i].key = tparr.length > 0 ? tparr[0].itemkey : '';
}
if ($scope.formList[i].type == 'toggle') {
$scope.formList[i].content = temp[key] == 10501 ? '是' : '否';
$scope.formList[i].togglecontent = temp[key] == 10501 ? true : false;
}
}
if ($scope.formList[i].type == 'upload' && arr.length > 0) {
$scope.formList[i].imagelist = arr.filter(function (va, ind) {
return $scope.formList[i].doctype == va.doctype;
})
$scope.formList[i].imageSaveList = arr.filter(function (va, ind) {
return $scope.formList[i].doctype == va.doctype;
})
$scope.formList[i].content = '点击放大查看图片';
}
}
}
console.log($scope.formList);
};
$scope.checkData = {};
$scope.agree = true;
if ($scope.showHistory == true) {
if ($scope.action == 'submit') {
// 获取认证信息
// console.log($scope.code);
AccountService.getAuthMessageInfo($scope.code).then(function (res) {
console.log(res);
if (res.code == 3350) {
// $scope.dataList=res.data;
// console.log(res);
// console.log($stateParams);
var temp = res.data.filter(function (val, index, arr) {
return val.id == $stateParams.id;
})[0];
$scope.id = temp.id;
dealWithData(temp);
}
})
} else if ($scope.action == 'check') {
// console.log(2);
AccountService.getAuthCheckInfo($stateParams.pagenum, $stateParams.pagesize, '', 0, 0).then(function (res) {
console.log(res);
if (res.code == 3350) {
// $scope.dataList=res.data;
var temp = res.data.filter(function (val, index, arr) {
return val.id == $stateParams.id;
})[0];
console.log(temp);
$scope.checkData = temp;
$scope.agree = $scope.checkData.authenstatus != 5103
dealWithData(temp);
}
})
}
}
$scope.orgtype = [
{itemkey: '高新潜力企业', itemvalue: "8311"},
{itemkey: '科技型初创企业', itemvalue: "8310"},
{itemkey: '国家高新技术企业', itemvalue: "8301"},
{itemkey: '创新引领企业', itemvalue: "8312"},
{itemkey: '其他企业', itemvalue: "8307"}
];
$scope.selectItems = function (index) {
// console.log(index);
if ($scope.formList[index].type == 'selectorgtype') {
var obtainlist = [];
angular.forEach($scope.orgtype, function (val) {
obtainlist.push({
text: '' + val.itemkey + '',
itemkey: val.itemkey,
itemvalue: val.itemvalue
})
})
$ionicActionSheet.show({
cancelOnStateChange: true,
cssClass: 'action_s',
cancelText: '取消',
buttons: obtainlist,
buttonClicked: function (indx) {
$scope.formList[index].content = obtainlist[indx].itemkey;
return true;
}
});
}
if ($scope.formList[index].type == 'companySelect') {
var obtainlist = [];
angular.forEach($scope.companylist, function (val) {
obtainlist.push({
text: '' + val.applyname + '',
itemkey: val.applyname,
itemvalue: val.orgid,
itemcode:val.orgcode
})
})
$ionicActionSheet.show({
cancelOnStateChange: true,
cssClass: 'action_s',
cancelText: '取消',
buttons: obtainlist,
buttonClicked: function (indx) {
$scope.orgid=obtainlist[indx].itemvalue
$scope.formList[index].content = obtainlist[indx].itemkey;
$scope.formList.forEach(function (res) {
if(res.saveKey=='orgCode'){
res.content=obtainlist[indx].itemcode
}
})
return true;
}
});
}
}
$scope.gobackpage = function () {
$scope.goback();
/*if(UserService.isTaskFlag == 1){
$scope.go('taskHoll');
UserService.isTaskFlag = 0;
}else{
goback();
}*/
}
// 选中机构
$scope.setOrgName = function (org) {
console.log(org);
$scope.orgid = org.id;
for (var key in org) {
for (var i = 0; i < $scope.formList.length; i++) {
if ($scope.formList[i].saveKey == 'buyorgname') {
$scope.formList[i].content = org.name;
}
}
}
// console.log($scope.formList);
$scope.isRelateUl = false;
if ($stateParams.comfrom == 'dockingInput') {
taskModuleService.searchCompanyTask(org.id, 1, 200).then(function (res) {
console.log(res);
if (res.code == 3350) {
$scope.formList[1].listItem = [];
angular.forEach(res.data, function (val) {
$scope.formList[1].listItem.push({
text: '' + val.projectname + '',
itemkey: val.id,
itemvalue: val.projectname //名字
})
})
}
})
}
}
// *************上传照片
// 先从数据中读取照片
angular.forEach($scope.formList, function (val, index) {
if (val.type == 'upload') {
if (val.content != '') {
/*var temp = JSON.parse(val.content);*/
if (val.content != null && val.content != undefined && val.content != "") {
//val.imagelist = Object.assign([], JSON.parse(val.content));
val.imagelist = Object.assign(JSON.parse(JSON.stringify(val.content)));
val.imageSaveList = val.imagelist;
val.content = [];
}
console.log(val);
}
}
;
})
// console.log($scope.formList);
//加载动画
$scope.showLoadingToast = function () {
$ionicLoading.show({
template: '',
content: '努力加载中',
animation: 'fade-in',
showBackdrop: true,//是否显示蒙层
maxWidth: 150,
showDelay: 0
});
// $timeout(function () {
// $ionicLoading.hide();
// }, 15000);
};
//关闭加载动画
$scope.hideLoadingToast = function () {
$ionicLoading.hide();
};
var listIndex = 1000;
$scope.addImage = function (index) {
listIndex = index;
if ($scope.app) {
var list = [
{text: '拍照'},
{text: '从相册上传'},
];
var clickfunction = function (indx) {
if (indx == 0) {
$scope.openCamera();
} else {
getPictures();
}
return true;
}
} else {
var files = document.getElementById('file');
files.click();
$(files).unbind().on('change', function (e) {
console.log(e)
if(!/.(jpg|jpeg|png|JPG|pdf|PDF)$/.test(e.target.value)){
$ionicPopup.alert({
title: '提示',
template: "图片类型必须是jpeg,jpg,png,中的一种"
});
return;
}
if ($scope.formList[listIndex].imagelist.length > 9||(e.target.files.length+$scope.formList[listIndex].imageSaveList.length)>9) {
$ionicPopup.alert({
title: '提示',
template: '最多只能上传9个文件!'
});
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);
// }
// console.log($scope.formList[listIndex])
// $scope.formList[listIndex].imagelist.push({photoName: url, originalName: url});
// })
$.each(e.target.files, function (i, file) {
console.log(file)
$scope.showLoadingToast();
var data = new FormData();
data.append('file', file);
CommonService.webUploadImage(data).then(function (res) {
files.value=''
$scope.hideLoadingToast();
var temp = {
id: 0,
title: res.title,
doctype: $scope.formList[listIndex].doctype,//文档类型 1图片,2文件,3pdf,4xls
isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
photoName: res.photoName,
originalName: res.originalName,
sourceName: res.sourceName,
sourceSize: res.sourceSize
}
$scope.formList[listIndex].imageSaveList.push(temp);
console.log(temp);
console.log($scope.formList[listIndex]);
})
});
})
return true;
}
$ionicActionSheet.show({
buttons: list,
cancelText: '取消',
buttonClicked: clickfunction
})
}
$scope.openCamera = function () {
if ($scope.formList[listIndex].imagelist.length >= 9) {
if ($scope.app) {
UtilService.showMess("最多选取9张图片");
} else {
CommonService.showMessage("最多选取9张图片", $scope)
}
return;
}
UtilService.getPicture(1).then(function (results) {
$scope.showLoadingToast();
$scope.formList[listIndex].imagelist.push({photoName: results, originalName: results})
UtilService.uploadFile([results], 0, "image/jpeg").then(function (response) {
angular.forEach(response, function (value) {
$scope.formList[listIndex].imageSaveList.push({
id: 0,
title: value.title,
doctype: $scope.formList[listIndex].doctype,//文档类型 1图片,2文件,3pdf,4xls
isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
photoName: value.photoName,
originalName: value.originalName,
sourceName: value.sourceName,
sourceSize: value.sourceSize
})
})
$scope.hideLoadingToast();
}, function () {
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess("网络不给力,请重试");
} else {
CommonService.showMessage("网络不给力,请重试", $scope)
}
});
$ionicScrollDelegate.$getByHandle("scrollimage").resize();
}, function (err) {
});
}
var getPictures = function () {
if (device.platform == "Android") {
verifyStorage();
} else {
getPic();
}
};
var verifyStorage = function () {
window.imagePicker.verifyStorage(
function (results) {
if (results == "1") {
getPic();
}
}, function (error) {
}
);
};
var getPic = function () {
var imagelistLength = $scope.formList[listIndex].imagelist.length;
if (imagelistLength >= 9) {
if ($scope.app) {
UtilService.showMess("最多选取9张图片");
} else {
CommonService.showMessage("最多选取9张图片", $scope)
}
return;
}
UtilService.getPictureList(9 - imagelistLength).then(function (results) {
$scope.showLoadingToast();
angular.forEach(results, function (val, i) {
$scope.formList[listIndex].imagelist.push({photoName: val, originalName: val});
})
UtilService.uploadFile(results, 0, "image/jpeg").then(function (response) {
angular.forEach(response, function (value) {
if (value.status) {
$scope.formList[listIndex].imageSaveList.push({
id: 0,
title: value.title,
doctype: $scope.formList[listIndex].doctype,//文档类型 1图片,2文件,3pdf,4xls
isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
photoName: value.photoName,
originalName: value.originalName,
sourceName: value.sourceName,
sourceSize: value.sourceSize
});
}
})
$scope.hideLoadingToast();
}, function () {
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess("网络不给力,请重试");
} else {
CommonService.showMessage("网络不给力,请重试", $scope)
}
});
$ionicScrollDelegate.$getByHandle("scrollimage").resize();
}, function (err) {
});
};
//删除图片
$scope.deletePhoto = function (index, outerIndex) {
if ($scope.formList[outerIndex].imageSaveList[index].id != 0) {
$scope.formList[outerIndex].imageSaveList[index].isenabled = 2;
$scope.formList[outerIndex].imageDeleteList.push($scope.formList[outerIndex].imageSaveList[index]);
}
$scope.formList[outerIndex].imagelist.splice(index, 1);
$scope.formList[outerIndex].imageSaveList.splice(index, 1);
}
$scope.uploadPic = function (e) {
// console.log(2);
// console.log(e.target);
}
// **************切换开关
$scope.watchIsChange = function (index) {
$scope.formList[index].content = $scope.formList[index].togglecontent ? "10501" : "10502";
}
// **************提交按钮
$scope.checkNotice = function () {
$scope.isChecked = !$scope.isChecked;
}
// 处理审核
$scope.reSubmit = function () {
$scope.showNew = true;
$scope.showHistory = false;
$scope.tempData = {};
$scope.tempData.id = $scope.id;
console.log($scope.formList);
angular.forEach($scope.formList, function (val) {
if (val.type == 'upload') {
val.imageSaveList = Object.assign([], val.imagelist);
}
if (val.type == 'selectArea' && val.content != '') {
var temp = val.content.split('/')
// console.log(temp);
for (var i = 0; i < $scope.areaDropDown.length; i++) {
$scope.areaDropDown[i].selectName = temp[i];
}
}
})
}
if ($stateParams.comfrom == 'resubmit') {
$scope.id = $stateParams.id;
$scope.reSubmit();
}
var dealWidthData = function () {
console.log($scope.formList);
var tempImages = [];
angular.forEach($scope.formList, function (val, index) {
if (val.type == 'upload') {
// 处理照片
// if(val.imagelist.length>0){
// val.imageSaveList=Object.assign([],val.imagelist);
// }
val.content = '';
var temp = Object.assign([], val.imageSaveList);
angular.forEach(val.imageSaveList, function (v) {
tempImages.push(v);
});
console.log(tempImages);
if (val.imageDeleteList.length > 0) {
angular.forEach(val.imageDeleteList, function (value) {
tempImages.push(value);
/*temp.push(value)*/
})
}
console.log(tempImages);
val.content = JSON.stringify(temp);
} else if (val.type == 'select' || val.type == 'selectDomain' || val.type == 'affiliatedOrg' || val.type == 'companyTaskSelect') {
$scope.tempData[val.saveKey] = val.key;
} else if (val.type == 'selectArea') {
$scope.tempData[val.saveKey] = val.content;
$scope.tempData.regionsid = val.code;
} else if (val.type == 'toggle') {
if (val.content == '是' || val.content == '否') {
val.content = val.content == '是' ? 10502 : 10501;
}
$scope.tempData[val.saveKey] = val.content;
} else if(val.type == 'group'){
val.form.forEach(function (res) {
$scope.tempData[res.saveKey] = res.content;
})
}else {
$scope.tempData[val.saveKey] = val.content;
}
})
console.log(tempImages);
angular.forEach(tempImages, function (value, index) {
value.createtime = new Date().Format("yyyy-MM-dd hh:mm:ss");
value.updatetime = new Date().Format("yyyy-MM-dd hh:mm:ss");
})
$scope.tempData.images = JSON.stringify(tempImages);
}
$scope.readCommit = false;
$scope.readCommition = function () {
$scope.readCommit = !$scope.readCommit;
}
$scope.goToMyCommit = function () {
//$scope.commitmentCom.show();
permissionvalue = "";
angular.forEach($scope.taskTypeList, function (val) {
if (val.isSelected) {
permissionvalue = permissionvalue + "," + val.value;
}
})
if ($scope.taskTypeList[2].isSelected) {
permissionvalue = "";
angular.forEach($scope.sonTaskTypeList, function (val) {
if (val.isSelected) {
permissionvalue = permissionvalue + "," + val.value;
}
})
}
$scope.formList.permissionvalue = permissionvalue;
$scope.go('commitment', {formlist: $scope.formList});
}
$scope.gobackToTashHoll = function () {
$scope.go('taskHoll');
}
// 保存对接信息
// 获取connid
var getDockingConnid = function () {
var def = $q.defer();
$scope.requestModel = {
data: {
templettype: 16,
title: $scope.formList[0].content,
organizationInfo: {
name: $scope.formList[0].content,
id: $scope.orgid ? $scope.orgid : 0
},
userModel: {
userid: UserService.id
}
},
node: UserService.node,
userid: UserService.id
}
console.log($scope.requestModel);
dataToolsService.saveOrganizationInfo($scope.requestModel).then(function (response) {
console.log(response);
if (response.code == 3350) {
def.resolve(response.data);
} else {
def.reject('错误');
}
})
return def.promise;
}
var submitTaskDocking = false;
$scope.submitTaskDocking = function () {
if (submitTaskDocking) {
return;
}
submitTaskDocking = true;
$scope.tempData = $scope.tempData ? $scope.tempData : {};
for (var i = 0; i < $scope.formList.length; i++) {
var val = $scope.formList[i];
if (val.remarkType == 'manage' && $scope.formList[i - 1].type == 'toggle' && ($scope.formList[i - 1].content == '10502' || $scope.formList[i - 1].content == '否')) {
continue;
}
if (val.needed && (val.content === '' || val.content == null || (val.type == 'upload' && val.imagelist.length == 0))) {
if (val.type == 'upload') {
if ($scope.app) {
UtilService.showMess('请上传' + val.title);
} else {
CommonService.showMessage('请上传' + val.title, $scope);
}
} else if (val.type == 'select' || val.type == 'affiliatedOrg' || val.type == 'selectArea' || val.type == 'selectDomain' || val.type == 'companyTaskSelect') {
if ($scope.app) {
UtilService.showMess('请选择' + val.title);
} else {
CommonService.showMessage('请选择' + val.title, $scope);
}
} else {
if ($scope.app) {
UtilService.showMess('请填写' + val.title);
} else {
CommonService.showMessage('请填写' + val.title, $scope);
}
}
submitTaskDocking = false;
return;
}
}
dealWidthData();
$scope.tempData.companyid = $scope.orgid;
$scope.tempData.action = 5322;
$scope.tempData.creator = UserService.id;
// var senddata={
// data:$scope.tempData,
// node:UserService.node
// }
$scope.showLoadingToast();
getDockingConnid().then(function (data) {
console.log(data);
$scope.tempData.connid = data.id;
$scope.tempData.orgid = data.organizationInfo.id;
$scope.tempData.companyid = data.organizationInfo.id;
$scope.tempData.tasktitle = $scope.tasktitle;
$scope.tempData.taskid = $stateParams.taskid;
if ($scope.tempData.jointtime == null || $scope.tempData.jointtime == undefined || $scope.tempData.jointtime == "") {
$scope.tempData.jointtime = new Date();
} else {
$scope.tempData.jointtime += ' 00:00:00';
}
var senddata = {
data: $scope.tempData,
node: UserService.node
}
console.log(senddata);
taskModuleService.saveOrupdatetaskDocking(senddata).then(function (res) {
console.log(res);
if (res.code == 3350) {
$scope.goback();
}
$scope.hideLoadingToast();
})
})
}
var submitFormAction = false;
$scope.submitForm = function () {
// if(!$scope.isChecked){
// return;
// }
/*if (submitFormAction) {
return;
}
submitFormAction = true;*/
angular.forEach($scope.formList, function (val) {
if (val.type == "upload") {
angular.forEach(val.imageSaveList, function (image) {
image.remark = val.title;
})
}
})
// 先处理数据 判断非空
$scope.tempData = $scope.tempData ? $scope.tempData : {};
dealWidthData();
$scope.tempData.creator = UserService.id;
$scope.tempData.userid = UserService.id;
$scope.tempData.node = UserService.node;
$scope.tempData.id=$scope.echolist?$scope.echolist.id:0
$scope.tempData.orgid = $scope.orgid;
$scope.tempData.resid = 0;
for (var i = 0; i < $scope.formList.length; i++) {
var val = $scope.formList[i];
if (val.remarkType == 'manage' && $scope.formList[i - 1].type == 'toggle' && ($scope.formList[i - 1].content == '10502' || $scope.formList[i - 1].content == '否')) {
continue;
}
if (val.type == 'upload') {
// console.log(val.content);
console.log(val.content == '');
console.log(val.type == 'upload');
console.log(val.imagelist.length == 0);
}
if (val.needed && (val.content == '' || !val.content ||(val.type == 'upload' && val.imageSaveList.length == 0))) {
if (val.type == 'upload') {
$ionicPopup.alert({
title: '提示',
template: '请上传' + val.title
});
return;
} else {
if (val.type == 'selectorgtype') {
if (!val.content) {
$ionicPopup.alert({
title: '提示',
template: '请选择' + val.title
});
return;
}
} else if(val.type == 'group'){
val.form.forEach(function (res) {
if(!res.content){
$ionicPopup.alert({
title: '提示',
template: '请选择' + res.title
});
return;
}
})
}else {
$ionicPopup.alert({
title: '提示',
template: '请填写' + val.title
});
return;
}
}
submitFormAction = false;
}
}
$scope.showLoadingToast();
if (!$scope.tempData.orgid) {
$scope.tempData.orgid = 0;
}
console.log($scope.formList);
if($stateParams.list.title=='研发后补助申报'||$stateParams.list.restype==1611726857){
$scope.tempData.updater = "";
$scope.tempData.createtime = "";
$scope.tempData.updatetime = "";
$scope.tempData.by1 = $scope.echolist?$scope.echolist.by1:"";
$scope.tempData.by2 = "";
$scope.tempData.by3 = "";
$scope.tempData.tablename = $scope.echolist?$scope.echolist.tablename:"";
$scope.tempData.tablecode = "";
console.log( $scope.tempData)
AccountService.postresearchcosts($scope.tempData).then(function (res) {
console.log(res)
$scope.hideLoadingToast();
if (res.code == 3350) {
$ionicPopup.alert({
title: '提示',
template: '提交成功!可电话联系高新科58508190,催促研发后补助审核'
}).then(function () {
$scope.go('reward');
});
}
})
}else {
console.log( $scope.tempData)
$scope.tempData.applytype = $scope.code;
$scope.tempData.authenstatus = 5101;
$scope.tempData.policysettingid = $scope.list.id;
$scope.tempData.buyorgid = $scope.orgid;
// AccountService.getTechContractCooperateInfo($scope.tempData.projectname, $scope.tempData.orgid, $scope.tempData.buyorgname).then(function (res) {
// if (res.code == 3350) {
// if (res.data.length != 0) {
// $ionicPopup.alert({
// title: '提示',
// template: '已申报产学研合作补助'
// })
// return;
// }
// }
// })
AccountService.submitAuthMessageCooperateInfo($scope.tempData).then(function (res) {
console.log(res);
$scope.hideLoadingToast();
if (res.code == 3350) {
$ionicPopup.alert({
title: '提示',
template: '提交成功!'
});
ResourceLibraryService.judgeManager(UserService.id, 10501).then(function (res) {
$scope.hasAuth = res.data;
if (!$scope.hasAuth) {
$scope.go('reward');
}
else {
$scope.go('cooperationSubsidyCheck');
}
})
}
})
}
}
$scope.agreeClick = function () {
if ($scope.node == '330122000') {
$scope.agree = 1;
} else {
$scope.agree = true;
}
}
$scope.rollClick = function () {
$scope.agree = -2;
}
$scope.rejectClick = function () {
if ($scope.node == '330122000') {
$scope.agree = -1;
} else {
$scope.agree = false;
}
}
var submitCheckAction = false;
$scope.submitCheck = function () {
if (submitCheckAction) {
return;
}
submitCheckAction = true;
// console.log($scope.agree);
if ($scope.node == '330122000') {
$scope.checkData.authenstatus = $scope.agree == 1 ? 5102 : ($scope.agree == -1 ? 5103 : 5104);
$scope.checkData.refusereason = $scope.agree == 1 ? '' : $scope.checkData.refusereason;
} else {
$scope.checkData.authenstatus = $scope.agree ? 5102 : 5103;
$scope.checkData.refusereason = $scope.agree ? '' : $scope.checkData.refusereason;
}
$scope.checkData.authorityid = UserService.id;
// console.log($scope.checkData);
$scope.showLoadingToast();
AccountService.submitAuthCheckInfo($scope.checkData).then(function (res) {
$scope.hideLoadingToast();
// console.log(res);
if (res.code == 3350) {
$state.go('identifyDetail', {pageTitle: '认证审核', code: $scope.code, action: 'check'});
}
})
}
//点击图片放大
$scope.bigImage = false; //初始默认大图是隐藏的
$scope.hideBigImage = function () {
$timeout(function () {
$scope.bigImage = false;
}, 400);
};
$scope.shouBigImage = function (piclist, index) { //传递一个参数(图片的URl)
window.open(ConfigService.imgurl + piclist[index].sourceName);
return;
};
window.addEventListener("resize", function () {
var domWidth = window.document.documentElement.getBoundingClientRect().width;
if (domWidth > 540) {
$scope.viewscreen = 'browser';
} else {
$scope.viewscreen = 'app';
}
})
// 任务邀请页面
var taskInviteModal = function () {
$ionicModal.fromTemplateUrl('./modules/common/views/taskInviteModal.html', {
scope: $scope,
animation: 'slide-in-left'
}).then(function (modal) {
$scope.taskInvite = modal;
});
}
taskInviteModal();
// 选择热门标签
$scope.selectLable = function (index, label) {
$scope.formList[index].content = label;
}
//删除图片集合中存在的相同图片
angular.forEach($scope.formList, function (val) {
if (val.type == 'upload') {
$scope.differentflag = false;
if (val.imagelist.length != 0) {
$scope.newimagelist = [];
$scope.newimagelist.push(val.imagelist[0]);
for (var i = 0; i < val.imagelist.length; i++) {
for (var j = 0; j < $scope.newimagelist.length; j++) {
if (val.imagelist[i].sourceName == $scope.newimagelist[j].sourceName) {
$scope.differentflag = false;
break;
} else {
$scope.differentflag = true;
}
}
if ($scope.differentflag) {
$scope.newimagelist.push(val.imagelist[i]);
}
}
val.imagelist = $scope.newimagelist;
}
$scope.differentflag = false;
if (val.imageSaveList.length != 0) {
$scope.newimagelist = [];
$scope.newimagelist.push(val.imageSaveList[0]);
for (var i = 0; i < val.imageSaveList.length; i++) {
for (var j = 0; j < $scope.newimagelist.length; j++) {
if (val.imageSaveList[i].sourceName == $scope.newimagelist[j].sourceName) {
$scope.differentflag = false;
break;
} else {
$scope.differentflag = true;
}
}
if ($scope.differentflag) {
$scope.newimagelist.push(val.imageSaveList[i]);
}
}
val.imageSaveList = $scope.newimagelist;
}
}
})
});