123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- angular.module('push')
- .controller('TeclcontractCtrl', function ($scope,SelfcheckService,$stateParams,UserService,$ionicPopup,CommonService,ConfigService,AccountService,
- $timeout,$ionicModal,$ionicActionSheet,ionicDatePicker,$ionicScrollDelegate) {
- $scope.data=[
- {
- info:'合同名称',
- ismust:true,
- value:'',
- type:1,
- key:'name'
- },{
- info:'合同金额(万)',
- ismust:true,
- value:'',
- type:2,
- key:'amount'
- },{
- info:'甲方名称',
- ismust:true,
- value:'',
- type:1,
- key:'firstName'
- },{
- info:'甲方联系人',
- ismust:true,
- value:'',
- type:1,
- key:'firstContact'
- },{
- info:'乙方名称',
- ismust:true,
- value:'',
- type:1,
- key:'secondName'
- },{
- info:'乙方联系人',
- ismust:true,
- value:'',
- type:1,
- key:'secondContact'
- },{
- info:'上传合同',
- ismust:true,
- value:[],
- type:3,
- key:'url'
- },
- ]
- $scope.status=null
- $scope.oninputs=function (row){
- $scope.TeclcontractModal.show();
- }
- //下面是录入弹框
- $ionicModal.fromTemplateUrl('modules/account/views/Teclcontractinput.html', {
- scope: $scope,
- backdropClickToClose:false
- }).then(function (modal) {
- $scope.TeclcontractModal = modal;
- });
- function getcontractlist(){
- SelfcheckService.getcontractlist({userId:UserService.id}).then(function (res){
- if(res.code==3350){
- res.data.forEach((item)=>{
- if(item.url){
- item.url = JSON.parse(item.url)
- }
- })
- $scope.checkList = res.data;
- // if(res.data.length!=0){
- // $scope.data.forEach((item)=>{
- // if(res.data[0][item.key]){
- // if(item.key=='url'){
- // item.value=JSON.parse(res.data[0][item.key])
- // }else {
- // item.value=res.data[0][item.key]
- // }
- // }
- // })
- // console.log($scope.data)
- // $scope.status=res.data[0].status
- // }
- }else {
- $ionicPopup.alert({
- title: '提示',
- template: res.message
- });
- }
- }).catch(function () {
- $ionicPopup.alert({
- title: '提示',
- template: "服务器错误"
- });
- })
- }getcontractlist()
- //验证
- $scope.clearNum = function(obj, attr){
- if(obj[attr] != obj[attr].replace(/\D/g,"")){
- var alertPopup = $ionicPopup.alert({
- template: '请输入正整数!'
- });
- alertPopup.then(function(res) {
- console.log('Thank you for not eating my delicious ice cream cone');
- });
- }
- obj[attr] = obj[attr].replace(/\D/g,"");
- }
- $scope.addImage = function (val) {
- 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 (val.value.length > 9||(e.target.files.length+val.value.length)>9) {
- $ionicPopup.alert({
- title: '提示',
- template: '最多只能上传9个文件!'
- });
- return;
- }
- $.each(e.target.files, function (i, file) {
- console.log(file)
- $scope.showLoadingToastUtilEnd();
- var data = new FormData();
- data.append('file', file);
- CommonService.webUploadImage(data).then(function (res) {
- files.value=''
- $scope.hideLoadingToast();
- var temp = {
- title: res.title,
- sourceName: res.sourceName
- }
- val.value.push(temp);
- })
- });
- })
- return true;
- }
- //删除图片
- $scope.deletePhoto = function (val,index) {
- val.splice(index, 1);
- }
- $scope.shouBigImage = function (val) { //传递一个参数(图片的URl)
- window.open(ConfigService.imgurl + val.sourceName);
- return;
- };
- //录入
- function Processingdata(){
- var params={}
- for(let row of $scope.data){
- if(row.ismust&&(!row.value||row.value==false)){
- $ionicPopup.alert({
- template: '请输入'+row.info
- });
- return false
- }else {
- if(row.key=='url'){
- params[row.key]=JSON.stringify(row.value)
- }else {
- params[row.key]=row.value
- }
- }
- }
- console.log(params)
- return params
- }
- $scope.gotest=function (){
- let Processingfinal=Processingdata()
- if(Processingfinal){
- $scope.showLoadingToastUtilEnd();
- let pams={creater:UserService.id,...Processingfinal}
- console.log(pams)
- SelfcheckService.postcontractinsert(pams).then(function (res){
- $scope.hideLoadingToast();
- console.log(res)
- if(res.code==3350){
- CommonService.prompt('登记成功');
- getcontractlist()
- $scope.TeclcontractModal.hide()
- }else {
- $ionicPopup.alert({
- title: '提示',
- template: res.message
- });
- }
- }).catch(function () {
- $ionicPopup.alert({
- title: '提示',
- template: "服务器错误"
- });
- })
- }
- }
- })
|